]> git.donarmstrong.com Git - lilypond.git/blob - lily/translator.cc
release: 1.5.44
[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 {
43   init ();
44   output_def_l_ = s.output_def_l_;
45   type_str_ = s.type_str_;
46
47   smobify_self ();
48 }
49
50 bool
51 Translator::is_alias_b (String s) const
52 {
53   bool b  = s == type_str_;
54
55   for (SCM a = unsmob_translator_def (definition_)->type_aliases_;
56        !b && gh_pair_p (a); a = ly_cdr (a))
57     b = b || s == ly_scm2string (ly_car (a));
58
59   return b;
60 }
61
62 bool
63 Translator::try_music (Music *)
64 {
65   return false;
66 }
67                             
68
69 Moment
70 Translator::now_mom () const
71 {
72   return daddy_trans_l_->now_mom ();
73 }
74
75 void
76 Translator::removal_processing ()
77 {
78   finalize ();
79 }
80
81 void
82 Translator::announces ()
83 {
84   do_announces ();
85 }
86
87 Music_output_def *
88 Translator::output_def_l () const
89 {
90   return output_def_l_;
91 }
92
93 SCM
94 Translator::internal_get_property (SCM sym) const
95 {
96   return daddy_trans_l_->internal_get_property (sym);
97 }
98
99 void
100 Translator:: stop_translation_timestep ()
101 {
102 }
103
104 void
105 Translator::start_translation_timestep ()
106 {
107 }
108
109 void
110 Translator::do_announces ()
111 {
112 }
113
114 void
115 Translator::initialize ()
116 {
117 }
118
119 void
120 Translator::finalize ()
121 {
122 }
123
124
125 /*
126
127   SMOBS
128
129 */
130 SCM
131 Translator::mark_smob (SCM sm)
132 {
133   Translator * me = (Translator*) SCM_CELL_WORD_1 (sm);
134   scm_gc_mark (me->simple_trans_list_);
135   scm_gc_mark (me->trans_group_list_);
136   scm_gc_mark (me->definition_);  
137   scm_gc_mark (me->properties_scm_);  
138
139   return me->properties_scm_;
140 }
141
142 MAKE_SCHEME_CALLBACK(Translator,name,1);
143 SCM
144 Translator::name (SCM trans) 
145 {
146   if (unsmob_translator (trans))
147     {
148       char const* nm = classname (unsmob_translator (trans));
149       return ly_str02scm (nm);
150     }
151   return
152     SCM_EOL;
153 }
154
155 MAKE_SCHEME_CALLBACK(Translator,description,1)
156 SCM
157 Translator::description (SCM me) 
158 {
159   if (unsmob_translator (me))
160     return unsmob_translator(me)->translator_description ();
161   else
162     {
163       programming_error ("Translator::description ()");  
164       return SCM_EOL;
165     }
166 }
167
168 SCM
169 Translator::translator_description () const
170 {
171   return SCM_EOL;
172 }
173
174 int
175 Translator::print_smob (SCM s, SCM port, scm_print_state *)
176 {
177   Translator *sc = (Translator *) ly_cdr (s);
178      
179   scm_puts ("#<Translator ", port);
180   scm_display (name (s), port);
181   scm_display (sc->simple_trans_list_, port);
182   /*
183     don't try to print properties, that is too much hassle.
184    */
185   scm_puts (" >", port);
186   
187   return 1;
188 }
189
190 SCM
191 Translator::static_translator_description ()const
192 {
193   return SCM_EOL;
194 }
195
196
197 IMPLEMENT_SMOBS (Translator);
198 IMPLEMENT_DEFAULT_EQUAL_P (Translator);