X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Ftranslator.cc;h=41111b075e6c48a7fc5012c56c406986779b347f;hb=94189ec2b8da6d7e89dc619c646a927adead9b19;hp=58b4c589178f09a50610562213b83339187d61fa;hpb=2181534bd94587fcac8f1769f2dda7bece693649;p=lilypond.git diff --git a/lily/translator.cc b/lily/translator.cc index 58b4c58917..41111b075e 100644 --- a/lily/translator.cc +++ b/lily/translator.cc @@ -3,34 +3,53 @@ source file of the GNU LilyPond music typesetter - (c) 1997 Han-Wen Nienhuys + (c) 1997--2001 Han-Wen Nienhuys */ #include "translator.hh" #include "debug.hh" #include "translator-group.hh" -#include "dictionary-iter.hh" + +#include "moment.hh" +#include "ly-smobs.icc" + +char const* +Translator::name() const +{ + return classname(this); +} Translator::~Translator () { } +void +Translator::init () +{ + simple_trans_list_ = SCM_EOL; + trans_group_list_ = SCM_EOL; + properties_scm_ = SCM_EOL; + definition_ = SCM_EOL; + daddy_trans_l_ =0; +} + Translator::Translator () { - status = ORPHAN; - daddy_trans_l_ = 0; + init (); output_def_l_ = 0; + smobify_self (); + } Translator::Translator (Translator const &s) : Input (s) { - status = ORPHAN; - daddy_trans_l_ =0; + init (); output_def_l_ = s.output_def_l_; - properties_dict_ = s.properties_dict_; type_str_ = s.type_str_; + + smobify_self (); } bool @@ -40,142 +59,132 @@ Translator::is_alias_b (String s) const } 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_l_->now_mom (); } + + + void -Translator::add_processing () +Translator::post_move_processing () { - if (status > ORPHAN) - return; - - do_add_processing (); - status = VIRGIN; + start_translation_timestep (); } void -Translator::do_add_processing () +Translator::removal_processing () { + finalize (); } + void -Translator::print () const +Translator::announces () { -#ifndef NPRINT - DOUT << name () << " {"; - if (name () != type_str_) - DOUT << "type = " << type_str_; - for (Dictionary_iter i (properties_dict_); i.ok (); i++) - { - DOUT << i.key () << "=" << i.val () <<"\n"; - } - do_print (); - DOUT << "}\n"; -#endif + do_announces (); } + void -Translator::do_print () const +Translator::pre_move_processing () { + stop_translation_timestep (); } -IMPLEMENT_IS_TYPE_B(Translator); -void -Translator::creation_processing () +Music_output_def * +Translator::output_def_l () const { - if (status >= CREATION_INITED) - return ; - - do_creation_processing (); - status = CREATION_INITED; + return output_def_l_; } -void -Translator::post_move_processing() +SCM +Translator::get_property (char const * id) const { - if (status >= MOVE_INITED) - return; + return daddy_trans_l_->get_property (ly_symbol2scm (id)); +} - creation_processing(); - do_post_move_processing(); - status = MOVE_INITED; +SCM +Translator::get_property (SCM sym) const +{ + return daddy_trans_l_->get_property (sym); } void -Translator::removal_processing() +Translator:: stop_translation_timestep () { - if (status == ORPHAN) - return; - creation_processing(); - do_removal_processing(); - // elegancy ... - // status = ORPHAN; } - -bool -Translator::try_request (Request * r) +void +Translator::start_translation_timestep () { - if (status < MOVE_INITED) - post_move_processing(); - - return do_try_request (r); } void -Translator::process_requests() +Translator::do_announces () { - if (status < PROCESSED_REQS) - post_move_processing(); - else if (status >= PROCESSED_REQS) - return; - - status = PROCESSED_REQS; - do_process_requests(); } void -Translator::pre_move_processing() +Translator::initialize () { - do_pre_move_processing(); - status = CREATION_INITED; } -Scalar -Translator::get_property (String id) +void +Translator::finalize () { - if (properties_dict_.elt_b (id)) - { - return properties_dict_[id]; - } - - if (daddy_trans_l_) - return daddy_trans_l_->get_property (id); - - return ""; } -void -Translator::set_property (String id, Scalar val) + +/* + + SMOBS + +*/ +SCM +Translator::mark_smob (SCM sm) { - properties_dict_[id] = val; + 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_); + + return me->properties_scm_; } -Music_output_def * -Translator::output_def_l () const +int +Translator::print_smob (SCM s, SCM port, scm_print_state *) { - return output_def_l_; + Translator *sc = (Translator *) gh_cdr (s); + + scm_puts ("#name (), port); + scm_display (sc->simple_trans_list_, port); + /* + don't try to print properties, that is too much hassle. + */ + scm_puts (" >", port); + + + + return 1; } + + + +IMPLEMENT_UNSMOB(Translator, translator); +IMPLEMENT_SMOBS(Translator); +IMPLEMENT_DEFAULT_EQUAL_P(Translator);