source file of the GNU LilyPond music typesetter
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+ (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "translator.hh"
-#include "debug.hh"
+#include "warn.hh"
#include "translator-group.hh"
-#include "dictionary-iter.hh"
+#include "context-def.hh"
+
+#include "moment.hh"
+#include "ly-smobs.icc"
+
Translator::~Translator ()
{
}
+void
+Translator::init ()
+{
+ simple_trans_list_ = SCM_BOOL_F;
+ trans_group_list_ = SCM_EOL;
+ properties_scm_ = SCM_EOL;
+ definition_ = SCM_EOL;
+ daddy_trans_ =0;
+ accepts_list_ = SCM_EOL;
+}
+
Translator::Translator ()
{
- status = ORPHAN;
- daddy_trans_l_ = 0;
- output_def_l_ = 0;
+ self_scm_ = SCM_EOL;
+ init ();
+ output_def_ = 0;
+ smobify_self ();
}
Translator::Translator (Translator const &s)
- : Input (s)
{
- status = ORPHAN;
- daddy_trans_l_ =0;
- output_def_l_ = s.output_def_l_;
- properties_dict_ = s.properties_dict_;
- type_str_ = s.type_str_;
+ self_scm_ = SCM_EOL;
+ init ();
+ output_def_ = s.output_def_;
+
+ smobify_self ();
}
bool
-Translator::is_alias_b (String s) const
+Translator::is_alias (SCM sym) const
{
- return s == type_str_;
+ return unsmob_context_def (definition_)->is_alias (sym);
}
bool
-Translator::do_try_request (Request *)
+Translator::try_music (Music *)
{
return false;
}
Moment
-Translator::now_moment () const
+Translator::now_mom () const
{
- return daddy_trans_l_->now_moment ();
+ return daddy_trans_->now_mom ();
}
-
void
-Translator::add_processing ()
+Translator::do_announces ()
{
- if (status > ORPHAN)
- return;
-
- do_add_processing ();
- status = VIRGIN;
}
-void
-Translator::do_add_processing ()
+Music_output_def *
+Translator::get_output_def () const
{
+ return
+ (daddy_trans_)
+ ? daddy_trans_->get_output_def ()
+ : 0;
}
-void
-Translator::print () const
+SCM
+Translator::internal_get_property (SCM sym) const
{
-#ifndef NPRINT
- DOUT << name () << " {";
- if (name () != type_str_)
- DOUT << "type = " << type_str_;
- for (Dictionary_iter<Scalar> i (properties_dict_); i.ok (); i++)
- {
- DOUT << i.key () << "=" << i.val () <<"\n";
- }
- do_print ();
- DOUT << "}\n";
-#endif
+ return daddy_trans_->internal_get_property (sym);
}
void
-Translator::do_print () const
+Translator::stop_translation_timestep ()
{
}
-IMPLEMENT_IS_TYPE_B(Translator);
+/*
+ this function has 2 properties
+
+ - It is called before try_music()
+ - It is called before any user information enters the translators.
+ (i.e. any \property or event is not processed yet.)
+ */
void
-Translator::creation_processing ()
+Translator::start_translation_timestep ()
{
- if (status >= CREATION_INITED)
- return ;
-
- do_creation_processing ();
- status = CREATION_INITED;
}
void
-Translator::post_move_processing()
+Translator::initialize ()
{
- if (status >= MOVE_INITED)
- return;
-
- creation_processing();
- do_post_move_processing();
- status = MOVE_INITED;
}
void
-Translator::removal_processing()
+Translator::finalize ()
{
- if (status == ORPHAN)
- return;
- creation_processing();
- do_removal_processing();
- // elegancy ...
- // status = ORPHAN;
}
-bool
-Translator::try_request (Request * r)
-{
- if (status < MOVE_INITED)
- post_move_processing();
+/*
- return do_try_request (r);
-}
+ SMOBS
-void
-Translator::process_requests()
+*/
+SCM
+Translator::mark_smob (SCM sm)
{
- if (status < PROCESSED_REQS)
- post_move_processing();
- else if (status >= PROCESSED_REQS)
- return;
-
- status = PROCESSED_REQS;
- do_process_requests();
-}
+ Translator * me = (Translator*) SCM_CELL_WORD_1 (sm);
+ scm_gc_mark (me->simple_trans_list_);
+ scm_gc_mark (me->trans_group_list_);
+ scm_gc_mark (me->definition_);
+ scm_gc_mark (me->properties_scm_);
+ scm_gc_mark (me->accepts_list_);
-void
-Translator::pre_move_processing()
-{
- do_pre_move_processing();
- status = CREATION_INITED;
+ return me->properties_scm_;
}
-Scalar
-Translator::get_property (String id)
+SCM
+Translator::translator_description () const
{
- if (properties_dict_.elt_b (id))
- {
- return properties_dict_[id];
- }
-
- if (daddy_trans_l_)
- return daddy_trans_l_->get_property (id);
-
- return "";
+ return SCM_EOL;
}
-void
-Translator::set_property (String id, Scalar val)
+SCM
+Translator::static_translator_description ()const
{
- properties_dict_[id] = val;
+ return SCM_EOL;
}
-Music_output_def *
-Translator::output_def_l () const
+IMPLEMENT_SMOBS (Translator);
+IMPLEMENT_DEFAULT_EQUAL_P (Translator);
+IMPLEMENT_TYPE_P(Translator,"ly:translator?");
+
+SCM
+Translator::get_simple_trans_list()
{
- return output_def_l_;
+ return SCM_EOL;
}