source file of the GNU LilyPond music typesetter
- (c) 1997--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
+#include <stdio.h>
-#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"
}
int
-Global_translator::moments_left_i () const
+Global_translator::get_moments_left () const
{
return extra_mom_pq_.size ();
}
Music_output*
-Global_translator::get_output_p ()
+Global_translator::get_output ()
{
return 0;
}
Global_translator::one_time_step ()
{
}
+
void
Global_translator::start ()
{
void
Global_translator::run_iterator_on_me (Music_iterator * iter)
{
- while (iter->ok () || moments_left_i ())
+ if (iter-> ok ())
+ prev_mom_ = now_mom_ = iter->pending_moment ();
+
+ bool first = true;
+ while (iter->ok () || get_moments_left ())
{
Moment w;
w.set_infinite (1);
if (iter->ok ())
{
w = iter->pending_moment ();
-
}
w = sneaky_insert_extra_moment (w);
+
+ // printf ("proccing %s\n ", w.string ().to_str0 ());
+ if (first)
+ {
+ first = false;
+ set_property ("measurePosition", w.smobbed_copy ());
+ }
+
prepare (w);
if (iter->ok ())
iter->process (w);
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<Global_translator*>((Translator*)this))
+ return dynamic_cast<Global_translator*> ((Translator*)this);
+
+ if (daddy_trans_)
+ return daddy_trans_->top_translator ();
+
+ programming_error ("No top translator!");
+ return 0;
+}