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