1 #ifndef DL_DVI_PROGRAM_HH__
2 #define DL_DVI_PROGRAM_HH__
11 #include "dl-refcounted.hh"
12 #include "dl-dvi-runtime.hh"
16 class DviCommand : public RefCounted
19 virtual void execute (DviRuntime& runtime) = 0;
20 virtual ~DviCommand() {};
23 class AbstractDviProgram : public RefCounted
26 virtual void execute (DviRuntime &runtime) = 0;
27 virtual ~AbstractDviProgram (void) {};
30 class DviProgram : public AbstractDviProgram
33 vector <DviCommand *> commands;
34 void add_command (DviCommand *cmd);
35 virtual void execute (DviRuntime& runtime);
36 virtual ~DviProgram (void);
39 class DviCharCommand : public DviCommand
45 DviCharCommand (uint c_arg)
49 uint get_c (void) const { return c; }
52 class DviPutCharCommand : public DviCharCommand
55 DviPutCharCommand (uint ch) : DviCharCommand (ch) {};
56 virtual void execute (DviRuntime& runtime)
58 runtime.put_char (get_c());
62 class DviSetCharCommand : public DviCharCommand
65 DviSetCharCommand (uint ch) : DviCharCommand (ch) {};
66 virtual void execute (DviRuntime& runtime)
68 runtime.set_char (get_c());
72 class DviRuleCommand : public DviCommand
78 DviRuleCommand (int h_arg, int w_arg) : h(h_arg), w(w_arg)
81 std::cout << "rule cmd " << h << " " << w << std::endl;
84 int get_h (void) const { return h; }
85 int get_w (void) const { return w; }
88 class DviPutRuleCommand : public DviRuleCommand
91 DviPutRuleCommand (int h, int w) : DviRuleCommand (h, w) {};
92 virtual void execute (DviRuntime& runtime)
94 runtime.put_rule (get_h(), get_w());
98 class DviSetRuleCommand : public DviRuleCommand
101 DviSetRuleCommand (int h, int w) : DviRuleCommand (h, w) {};
102 virtual void execute (DviRuntime& runtime)
104 runtime.set_rule (get_h(), get_w());
108 class DviPushCommand : public DviCommand
111 DviPushCommand () {};
112 virtual void execute (DviRuntime& runtime)
118 class DviPopCommand : public DviCommand
122 virtual void execute (DviRuntime& runtime)
128 class DviMoveCommand : public DviCommand
134 DviMoveCommand (int len_arg) : len (len_arg) {};
135 int get_len (void) { return len; }
138 class DviRightCommand : public DviMoveCommand
141 DviRightCommand (int len) : DviMoveCommand (len)
144 cout << "right command " << get_len() << endl;
147 virtual void execute (DviRuntime& runtime)
149 runtime.right (get_len());
153 class DviWCommand : public DviMoveCommand
156 DviWCommand (int len) : DviMoveCommand (len) {};
157 virtual void execute (DviRuntime& runtime)
159 runtime.w (get_len());
163 class DviXCommand : public DviMoveCommand
166 DviXCommand (int len) : DviMoveCommand (len) {};
167 virtual void execute (DviRuntime& runtime)
169 runtime.x (get_len());
173 class DviDownCommand : public DviMoveCommand
176 DviDownCommand (int len) : DviMoveCommand (len)
179 cout << "down command " << get_len() << endl;
182 virtual void execute (DviRuntime& runtime)
184 runtime.down (get_len());
188 class DviYCommand : public DviMoveCommand
191 DviYCommand (int len) : DviMoveCommand (len) {};
192 virtual void execute (DviRuntime& runtime)
194 runtime.y (get_len());
198 class DviZCommand : public DviMoveCommand
201 DviZCommand (int len) : DviMoveCommand (len) {};
202 virtual void execute (DviRuntime& runtime)
204 runtime.z (get_len());
208 class DviFontNumCommand : public DviCommand
214 DviFontNumCommand (int num_arg) : num (num_arg) {}
215 virtual void execute (DviRuntime& runtime)
217 runtime.font_num (num);
221 class DviSpecialCommand : public DviCommand
225 DviSpecialCommand (string s) : spc (s) {};
226 virtual ~DviSpecialCommand () {};
227 virtual void execute (DviRuntime& runtime)
229 runtime.special (spc);
233 class DviWRepCommand : public DviCommand
236 DviWRepCommand () {};
237 virtual void execute (DviRuntime& runtime)
243 class DviXRepCommand : public DviCommand
246 DviXRepCommand () {};
247 virtual void execute (DviRuntime& runtime)
253 class DviYRepCommand : public DviCommand
256 DviYRepCommand () {};
257 virtual void execute (DviRuntime& runtime)
263 class DviZRepCommand : public DviCommand
266 DviZRepCommand () {};
267 virtual void execute (DviRuntime& runtime)
274 #endif // DL_DVI_PROGRAM_HH__