2 translator.cc -- implement Translator
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "translator.hh"
12 #include "translator-group.hh"
13 #include "translator-def.hh"
16 #include "ly-smobs.icc"
19 Translator::~Translator ()
26 simple_trans_list_ = SCM_EOL;
27 trans_group_list_ = SCM_EOL;
28 properties_scm_ = SCM_EOL;
29 definition_ = SCM_EOL;
33 Translator::Translator ()
41 Translator::Translator (Translator const &s)
44 output_def_l_ = s.output_def_l_;
45 type_str_ = s.type_str_;
51 Translator::is_alias_b (String s) const
53 bool b = s == type_str_;
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));
63 Translator::try_music (Music *)
70 Translator::now_mom () const
72 return daddy_trans_l_->now_mom ();
76 Translator::removal_processing ()
82 Translator::announces ()
88 Translator::output_def_l () const
94 Translator::internal_get_property (SCM sym) const
96 return daddy_trans_l_->internal_get_property (sym);
100 Translator:: stop_translation_timestep ()
105 Translator::start_translation_timestep ()
110 Translator::do_announces ()
115 Translator::initialize ()
120 Translator::finalize ()
131 Translator::mark_smob (SCM sm)
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_);
139 return me->properties_scm_;
142 LY_DEFINE(ly_translator_name,
143 "ly-translator-name", 1,0,0, (SCM trans),
144 "Return the type name of the translator @var{trans}.
147 Translator* tr = unsmob_translator (trans);
148 SCM_ASSERT_TYPE(tr, trans, SCM_ARG1, __FUNCTION__, "Context");
150 char const* nm = classname (tr);
151 return ly_str02scm (nm);
154 LY_DEFINE(ly_translator_description,
155 "ly-translator-description",
157 "Return an alist of properties of translator @var{me}.")
159 Translator *tr =unsmob_translator (me);
160 SCM_ASSERT_TYPE (tr, me, SCM_ARG1, __FUNCTION__, "Context");
162 return tr->translator_description ();
166 Translator::translator_description () const
172 Translator::print_smob (SCM s, SCM port, scm_print_state *)
174 Translator *sc = (Translator *) ly_cdr (s);
176 scm_puts ("#<Translator ", port);
177 scm_display (ly_translator_name (s), port);
178 scm_display (sc->simple_trans_list_, port);
180 don't try to print properties, that is too much hassle.
182 scm_puts (" >", port);
188 Translator::static_translator_description ()const
194 IMPLEMENT_SMOBS (Translator);
195 IMPLEMENT_DEFAULT_EQUAL_P (Translator);