X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fglobal-translator.cc;h=ce30c74db6feebf5d78560a85006867e915ed78c;hb=ab7a4832dbcc1964c023d6035830b96b8e9076a3;hp=f7848d72a2206a292fd1d3374ca3f0124f0801d5;hpb=d8691dd2c4cf8e365c544e535a6c6d08aa231c8d;p=lilypond.git diff --git a/lily/global-translator.cc b/lily/global-translator.cc index f7848d72a2..ce30c74db6 100644 --- a/lily/global-translator.cc +++ b/lily/global-translator.cc @@ -3,12 +3,13 @@ source file of the GNU LilyPond music typesetter - (c) 1997--2001 Han-Wen Nienhuys + (c) 1997--2003 Han-Wen Nienhuys */ +#include -#include "debug.hh" +#include "warn.hh" #include "music.hh" -#include "request.hh" +#include "event.hh" #include "music-list.hh" #include "music-iterator.hh" #include "global-translator.hh" @@ -41,7 +42,7 @@ Global_translator::sneaky_insert_extra_moment (Moment w) } int -Global_translator::moments_left_i () const +Global_translator::get_moments_left () const { return extra_mom_pq_.size (); } @@ -62,7 +63,7 @@ Global_translator::now_mom () const Music_output* -Global_translator::get_output_p () +Global_translator::get_output () { return 0; } @@ -71,6 +72,7 @@ void Global_translator::one_time_step () { } + void Global_translator::start () { @@ -86,9 +88,8 @@ Global_translator::run_iterator_on_me (Music_iterator * iter) if (iter-> ok ()) prev_mom_ = now_mom_ = iter->pending_moment (); - bool first = true; - while (iter->ok () || moments_left_i ()) + while (iter->ok () || get_moments_left ()) { Moment w; w.set_infinite (1); @@ -98,14 +99,12 @@ Global_translator::run_iterator_on_me (Music_iterator * iter) } w = sneaky_insert_extra_moment (w); - - // cout << "Proccing " << w << endl; - + // printf ("proccing %s\n ", w.to_string ().to_str0 ()); if (first) { first = false; - set_property (ly_symbol2scm ("measurePosition"), w.smobbed_copy ()); + set_property ("measurePosition", w.smobbed_copy ()); } prepare (w); @@ -115,3 +114,39 @@ Global_translator::run_iterator_on_me (Music_iterator * iter) one_time_step (); } } + +void +Global_translator::apply_finalizations () +{ + SCM lst = get_property ("finalizations"); + set_property ("finalizations" , SCM_EOL); + for (SCM s = lst ; gh_pair_p (s); s = gh_cdr (s)) + { + scm_primitive_eval (gh_car (s)); + } +} + +/* + Add a function to execute before stepping to the next time step. + */ +void +Global_translator::add_finalization (SCM x) +{ + SCM lst = get_property ("finalizations"); + lst = scm_cons (x, lst); + set_property ("finalizations" ,lst); +} + + +Global_translator * +Translator::top_translator()const +{ + if (dynamic_cast((Translator*)this)) + return dynamic_cast ((Translator*)this); + + if (daddy_trans_) + return daddy_trans_->top_translator (); + + programming_error ("No top translator!"); + return 0; +}