]> git.donarmstrong.com Git - lilypond.git/blob - lily/translator.cc
release: 1.5.29
[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--2002 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 void
77 Translator::removal_processing ()
78 {
79   finalize ();
80 }
81
82 void
83 Translator::announces ()
84 {
85   do_announces ();
86 }
87
88 Music_output_def *
89 Translator::output_def_l () const
90 {
91   return output_def_l_;
92 }
93
94 SCM
95 Translator::internal_get_property (SCM sym) const
96 {
97   return daddy_trans_l_->internal_get_property (sym);
98 }
99
100 void
101 Translator:: stop_translation_timestep ()
102 {
103 }
104
105 void
106 Translator::start_translation_timestep ()
107 {
108 }
109
110 void
111 Translator::do_announces ()
112 {
113 }
114
115 void
116 Translator::initialize ()
117 {
118 }
119
120 void
121 Translator::finalize ()
122 {
123 }
124
125
126 /*
127
128   SMOBS
129
130 */
131 SCM
132 Translator::mark_smob (SCM sm)
133 {
134   Translator * me = (Translator*) SCM_CELL_WORD_1 (sm);
135   scm_gc_mark (me->simple_trans_list_);
136   scm_gc_mark (me->trans_group_list_);
137   scm_gc_mark (me->definition_);  
138   scm_gc_mark (me->properties_scm_);  
139
140   return me->properties_scm_;
141 }
142
143 MAKE_SCHEME_CALLBACK(Translator,name,1);
144 SCM
145 Translator::name (SCM trans) 
146 {
147   if (unsmob_translator (trans))
148     {
149       char const* nm = classname (unsmob_translator (trans));
150       return ly_str02scm (nm);
151     }
152   return
153     SCM_EOL;
154 }
155
156 MAKE_SCHEME_CALLBACK(Translator,description,1)
157 SCM
158 Translator::description (SCM me) 
159 {
160   if (unsmob_translator (me))
161     return unsmob_translator(me)->translator_description ();
162   else
163     {
164       programming_error ("Translator::description ()");  
165       return SCM_EOL;
166     }
167 }
168
169 SCM
170 Translator::translator_description () const
171 {
172   return SCM_EOL;
173 }
174
175 int
176 Translator::print_smob (SCM s, SCM port, scm_print_state *)
177 {
178   Translator *sc = (Translator *) ly_cdr (s);
179      
180   scm_puts ("#<Translator ", port);
181   scm_display (name (s), port);
182   scm_display (sc->simple_trans_list_, port);
183   /*
184     don't try to print properties, that is too much hassle.
185    */
186   scm_puts (" >", port);
187   
188   return 1;
189 }
190
191 SCM
192 Translator::static_translator_description ()const
193 {
194   return SCM_EOL;
195 }
196
197
198 IMPLEMENT_SMOBS (Translator);
199 IMPLEMENT_DEFAULT_EQUAL_P (Translator);