]> git.donarmstrong.com Git - lilypond.git/blob - lily/translator.cc
* VERSION (MY_PATCH_LEVEL): make 1.7.0
[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_ =0;
31 }
32
33 Translator::Translator ()
34 {
35   self_scm_ = SCM_EOL;
36   init ();
37   output_def_ = 0;
38   smobify_self ();
39 }
40
41 Translator::Translator (Translator const &s)
42 {
43   self_scm_ = SCM_EOL;
44   init ();
45   output_def_ = s.output_def_;
46   type_string_ = s.type_string_;
47
48   smobify_self ();
49 }
50
51 bool
52 Translator::is_alias_b (String s) const
53 {
54   bool b  = s == type_string_;
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_->now_mom ();
74 }
75
76 void
77 Translator::removal_processing ()
78 {
79   finalize ();
80 }
81
82 void
83 Translator::do_announces ()
84 {
85 }
86
87 Music_output_def *
88 Translator::get_output_def () const
89 {
90   return output_def_;
91 }
92
93 SCM
94 Translator::internal_get_property (SCM sym) const
95 {
96   return daddy_trans_->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::initialize ()
111 {
112 }
113
114 void
115 Translator::finalize ()
116 {
117 }
118
119
120 /*
121
122   SMOBS
123
124 */
125 SCM
126 Translator::mark_smob (SCM sm)
127 {
128   Translator * me = (Translator*) SCM_CELL_WORD_1 (sm);
129   scm_gc_mark (me->simple_trans_list_);
130   scm_gc_mark (me->trans_group_list_);
131   scm_gc_mark (me->definition_);  
132   scm_gc_mark (me->properties_scm_);  
133
134   return me->properties_scm_;
135 }
136
137 LY_DEFINE(ly_translator_name,
138           "ly-translator-name", 1,0,0,  (SCM trans),
139           "Return the type name of the translator @var{trans}.
140 ")
141 {
142   Translator* tr =  unsmob_translator (trans);
143   SCM_ASSERT_TYPE(tr, trans, SCM_ARG1, __FUNCTION__, "Context");
144
145   char const* nm = classname (tr);
146   return scm_makfrom0str (nm);
147 }
148
149 LY_DEFINE(ly_translator_description,
150           "ly-translator-description",
151           1,0,0, (SCM me),
152           "Return an alist of properties of  translator @var{me}.")
153 {
154   Translator *tr =unsmob_translator (me);
155   SCM_ASSERT_TYPE (tr, me, SCM_ARG1, __FUNCTION__, "Context");
156
157   return tr->translator_description ();
158 }
159
160 SCM
161 Translator::translator_description () const
162 {
163   return SCM_EOL;
164 }
165
166 int
167 Translator::print_smob (SCM s, SCM port, scm_print_state *)
168 {
169   Translator *sc = (Translator *) ly_cdr (s);
170      
171   scm_puts ("#<Translator ", port);
172   scm_display (ly_translator_name (s), port);
173   scm_display (sc->simple_trans_list_, port);
174   /*
175     don't try to print properties, that is too much hassle.
176    */
177   scm_puts (" >", port);
178   
179   return 1;
180 }
181
182 SCM
183 Translator::static_translator_description ()const
184 {
185   return SCM_EOL;
186 }
187
188
189 IMPLEMENT_SMOBS (Translator);
190 IMPLEMENT_DEFAULT_EQUAL_P (Translator);