]> git.donarmstrong.com Git - lilypond.git/blob - lily/translator.cc
ef5f4b100a8d3e126e53e14a05124375c4a95dc9
[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
101 SCM
102 Translator::get_property (char const * id) const
103 {
104   return daddy_trans_l_->get_property (ly_symbol2scm (id));
105 }
106
107 SCM
108 Translator::get_property (SCM sym) const
109 {
110   return daddy_trans_l_->get_property (sym);
111 }
112
113 void
114 Translator:: stop_translation_timestep ()
115 {
116 }
117
118 void
119 Translator::start_translation_timestep ()
120 {
121 }
122
123 void
124 Translator::do_announces ()
125 {
126 }
127
128 void
129 Translator::initialize ()
130 {
131 }
132
133 void
134 Translator::finalize ()
135 {
136 }
137
138
139 /*
140
141   SMOBS
142
143 */
144 SCM
145 Translator::mark_smob (SCM sm)
146 {
147   Translator * me = (Translator*) SCM_CELL_WORD_1 (sm);
148   scm_gc_mark (me->simple_trans_list_);
149   scm_gc_mark (me->trans_group_list_);
150   scm_gc_mark (me->definition_);  
151   scm_gc_mark (me->properties_scm_);  
152
153   return me->properties_scm_;
154 }
155
156 MAKE_SCHEME_CALLBACK(Translator,name,1);
157 SCM
158 Translator::name (SCM trans) 
159 {
160   if (unsmob_translator (trans))
161     {
162       char const* nm = classname (unsmob_translator (trans));
163       return ly_str02scm (nm);
164     }
165   return
166     SCM_EOL;
167 }
168
169 MAKE_SCHEME_CALLBACK(Translator,description,1)
170 SCM
171 Translator::description (SCM me) 
172 {
173   if (unsmob_translator (me))
174     return unsmob_translator(me)->translator_description ();
175   else
176     {
177       programming_error ("Translator::description ()");  
178       return SCM_EOL;
179     }
180 }
181
182 SCM
183 Translator::translator_description () const
184 {
185   return SCM_EOL;
186 }
187
188 int
189 Translator::print_smob (SCM s, SCM port, scm_print_state *)
190 {
191   Translator *sc = (Translator *) ly_cdr (s);
192      
193   scm_puts ("#<Translator ", port);
194   scm_display (name (s), port);
195   scm_display (sc->simple_trans_list_, port);
196   /*
197     don't try to print properties, that is too much hassle.
198    */
199   scm_puts (" >", port);
200   
201   return 1;
202 }
203
204 SCM
205 Translator::static_translator_description ()const
206 {
207   return SCM_EOL;
208 }
209
210
211 IMPLEMENT_SMOBS (Translator);
212 IMPLEMENT_DEFAULT_EQUAL_P (Translator);