]> git.donarmstrong.com Git - lilypond.git/blob - lily/translator.cc
release: 1.5.19
[lilypond.git] / lily / translator.cc
1 /*
2   translator.cc -- implement Translator
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9
10 #include "translator.hh"
11 #include "debug.hh"
12 #include "translator-group.hh"
13 #include "translator-def.hh"
14
15 #include "moment.hh"
16 #include "ly-smobs.icc"
17
18
19 Translator::~Translator ()
20 {
21 }
22
23 void
24 Translator::init ()
25 {
26   simple_trans_list_ = SCM_EOL;
27   trans_group_list_ = SCM_EOL;
28   properties_scm_ = SCM_EOL;
29   definition_ = SCM_EOL;
30   daddy_trans_l_ =0;
31 }
32
33 Translator::Translator ()
34 {
35   init ();
36   output_def_l_ = 0;
37   smobify_self ();
38
39 }
40
41 Translator::Translator (Translator const &s)
42   : Input (s)
43 {
44   init ();
45   output_def_l_ = s.output_def_l_;
46   type_str_ = s.type_str_;
47
48   smobify_self ();
49 }
50
51 bool
52 Translator::is_alias_b (String s) const
53 {
54   bool b  = s == type_str_;
55
56   for (SCM a = unsmob_translator_def (definition_)->type_aliases_;
57        !b && gh_pair_p (a); a = ly_cdr (a))
58     b = b || s == ly_scm2string (ly_car (a));
59
60   return b;
61 }
62
63 bool
64 Translator::try_music (Music *)
65 {
66   return false;
67 }
68                             
69
70 Moment
71 Translator::now_mom () const
72 {
73   return daddy_trans_l_->now_mom ();
74 }
75
76
77
78
79
80
81 void
82 Translator::removal_processing ()
83 {
84   finalize ();
85 }
86
87
88 void
89 Translator::announces ()
90 {
91   do_announces ();
92 }
93
94
95 Music_output_def *
96 Translator::output_def_l () const
97 {
98   return output_def_l_;
99 }
100 #if 0
101 SCM
102 Translator::get_property (char const * id) const
103 {
104   return daddy_trans_l_->get_property (ly_symbol2scm (id));
105 }
106 #endif
107
108 SCM
109 Translator::internal_get_property (SCM sym) const
110 {
111   return daddy_trans_l_->internal_get_property (sym);
112 }
113
114 void
115 Translator:: stop_translation_timestep ()
116 {
117 }
118
119 void
120 Translator::start_translation_timestep ()
121 {
122 }
123
124 void
125 Translator::do_announces ()
126 {
127 }
128
129 void
130 Translator::initialize ()
131 {
132 }
133
134 void
135 Translator::finalize ()
136 {
137 }
138
139
140 /*
141
142   SMOBS
143
144 */
145 SCM
146 Translator::mark_smob (SCM sm)
147 {
148   Translator * me = (Translator*) SCM_CELL_WORD_1 (sm);
149   scm_gc_mark (me->simple_trans_list_);
150   scm_gc_mark (me->trans_group_list_);
151   scm_gc_mark (me->definition_);  
152   scm_gc_mark (me->properties_scm_);  
153
154   return me->properties_scm_;
155 }
156
157 MAKE_SCHEME_CALLBACK(Translator,name,1);
158 SCM
159 Translator::name (SCM trans) 
160 {
161   if (unsmob_translator (trans))
162     {
163       char const* nm = classname (unsmob_translator (trans));
164       return ly_str02scm (nm);
165     }
166   return
167     SCM_EOL;
168 }
169
170 MAKE_SCHEME_CALLBACK(Translator,description,1)
171 SCM
172 Translator::description (SCM me) 
173 {
174   if (unsmob_translator (me))
175     return unsmob_translator(me)->translator_description ();
176   else
177     {
178       programming_error ("Translator::description ()");  
179       return SCM_EOL;
180     }
181 }
182
183 SCM
184 Translator::translator_description () const
185 {
186   return SCM_EOL;
187 }
188
189 int
190 Translator::print_smob (SCM s, SCM port, scm_print_state *)
191 {
192   Translator *sc = (Translator *) ly_cdr (s);
193      
194   scm_puts ("#<Translator ", port);
195   scm_display (name (s), port);
196   scm_display (sc->simple_trans_list_, port);
197   /*
198     don't try to print properties, that is too much hassle.
199    */
200   scm_puts (" >", port);
201   
202   return 1;
203 }
204
205 SCM
206 Translator::static_translator_description ()const
207 {
208   return SCM_EOL;
209 }
210
211
212 IMPLEMENT_SMOBS (Translator);
213 IMPLEMENT_DEFAULT_EQUAL_P (Translator);