source file of the GNU LilyPond music typesetter
- (c) 1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "translator-group.hh"
#include "warn.hh"
#include "simultaneous-music-iterator.hh"
#include "music-list.hh"
-#include "translator-def.hh"
+#include "context-def.hh"
Simultaneous_music_iterator::Simultaneous_music_iterator ()
children_list_ = SCM_EOL;
}
-Simultaneous_music_iterator::Simultaneous_music_iterator (Simultaneous_music_iterator const& src)
- : Music_iterator (src)
-{
- separate_contexts_b_
- = src.separate_contexts_b_;
- children_list_ = SCM_EOL;
-
- SCM children_list = SCM_EOL;
- SCM *tail = &children_list;
- for (SCM s = src.children_list_; gh_pair_p (s); s = gh_cdr(s))
- {
- Music_iterator *i = unsmob_iterator (gh_car (s));
- SCM cl = i->clone ()->self_scm();
- *tail = scm_cons (cl, *tail);
- tail = SCM_CDRLOC (*tail);
- scm_gc_unprotect_object (cl);
- }
-
- children_list_ = children_list;
- scm_remember_upto_here_1 (children_list);
-}
void
Simultaneous_music_iterator::derived_mark()const
scm_gc_mark (children_list_);
}
-SCM
-Simultaneous_music_iterator::get_pending_events (Moment m)const
+void
+Simultaneous_music_iterator::derived_substitute(Translator_group*f,Translator_group*t)
{
- SCM l = SCM_EOL;
for (SCM s = children_list_; gh_pair_p (s); s = gh_cdr(s))
- {
- l = gh_append2 (unsmob_iterator (gh_car (s))->get_pending_events (m), l);
- }
- return l;
+ unsmob_iterator (gh_car (s))-> substitute_outlet (f,t);
}
void
/* if separate_contexts_b_ is set, create a new context with the
number number as name */
- SCM name = unsmob_context_def (report_to ()->definition_)->get_context_name ();
+ SCM name = unsmob_context_def (get_outlet ()->definition_)->get_context_name ();
Translator_group * t = (j && separate_contexts_b_)
- ? report_to ()->find_create_translator (name, to_string (j), SCM_EOL)
- : report_to ();
+ ? get_outlet ()->find_create_translator (name, to_string (j), SCM_EOL)
+ : get_outlet ();
if (!t)
- t = report_to ();
+ t = get_outlet ();
mi->init_translator (mus, t);
mi->construct_children ();
}
}
-void
-Simultaneous_music_iterator::skip (Moment until)
-{
- SCM *proc = &children_list_;
- while(gh_pair_p (*proc))
- {
- Music_iterator * i = unsmob_iterator (gh_car (*proc));
- if (i->pending_moment () <= until)
- {
- i->skip (until);
- }
- if (!i->ok ())
- {
- i->quit ();
- *proc = gh_cdr (*proc);
- }
- else
- {
- proc = SCM_CDRLOC(*proc);
- }
- }
-}
-
Moment
Simultaneous_music_iterator::pending_moment () const
{
for (SCM s = children_list_; gh_pair_p (s); s = gh_cdr(s))
{
Music_iterator * it = unsmob_iterator (gh_car (s));
- if (!it-> run_always ())
- next = next <? it->pending_moment ();
+ next = next <? it->pending_moment ();
}
+
return next;
}
bool
Simultaneous_music_iterator::ok () const
{
+ bool run_always_ok = false;
for (SCM s = children_list_; gh_pair_p (s); s = gh_cdr(s))
{
Music_iterator * it = unsmob_iterator (gh_car (s));
if (!it->run_always ())
return true;
+ else
+ run_always_ok = run_always_ok || it->ok ();
+ }
+ return run_always_ok;
+}
+
+bool
+Simultaneous_music_iterator::run_always () const
+{
+ for (SCM s = children_list_; gh_pair_p (s); s = gh_cdr(s))
+ {
+ Music_iterator * it = unsmob_iterator (gh_car (s));
+ if (it->run_always ())
+ return true;
}
return false;
}