+1.3.87.jcn2
+===========
+
+* Added skip (M) to music-iterator which fixes ugly non-const hack
+ of get-music (M).
+
1.3.87.jcn1
===========
MAJOR_VERSION=1
MINOR_VERSION=3
PATCH_LEVEL=87
-MY_PATCH_LEVEL=jcn1
+MY_PATCH_LEVEL=jcn2
# use the above to send patches: MY_PATCH_LEVEL is always empty for a
# released version.
thus changing the state of the interpretation context.
get_music (M) -- return all events starting at M (pre: no events
- before M). Side effects:
+ before M).
- * This removes all events at M from the pending queue.
+ skip (M) -- remove all events at M from the pending queue.
- Because next (M) is rolled into process () as a side effect,
- we need to roll next (M) into get_music too. Urg.
-
*/
class Music_iterator
{
virtual bool ok () const;
virtual SCM get_music (Moment until)const;
virtual void process (Moment until);
+ virtual void skip (Moment until);
/**
Construct sub-iterators, and set the translator to
Simple_music_iterator ();
Simple_music_iterator (Simple_music_iterator const &);
virtual void process (Moment);
- virtual bool ok()const;
+ virtual bool ok ()const;
+ virtual void skip (Moment);
virtual Moment pending_moment ()const;
virtual void construct_children ();
};
}
+void
+Music_iterator::skip (Moment)
+{
+ assert (0);
+}
+
void
Music_iterator::process (Moment)
{
}
SCM
-Request_chord_iterator::get_music (Moment m) const
+Request_chord_iterator::get_music (Moment) const
{
- Request_chord_iterator* urg = (Request_chord_iterator*)this;
- urg->last_processed_mom_ = m;
- urg->last_processed_mom_.set_infinite (1);
SCM s = SCM_EOL;
if (music_l_)
{
{
s = gh_cons (gh_car (m) , s);
}
- urg->music_l_ = 0;
}
return s;
}
void
Request_chord_iterator::process (Moment m)
{
- last_processed_mom_ = m;
if (music_l_)
{
for (SCM s = dynamic_cast<Music_sequence *> (music_l_)->music_list ();
mus->origin ()->warning (_f ("Huh? Not a Request: `%s'",
classname (mus)));
}
-
- music_l_ =0;
}
+ skip (m);
}
SCM
-Sequential_music_iterator::get_music (Moment until)const
+Sequential_music_iterator::get_music (Moment until) const
{
-#if 1
- /*
- FIXME: get_music () is const, so we must operate on a copy of child-iter.
-
- hmm, part-combiner does work on a copy; why copy again?
- Also, simply `working on a copy' doesn't work: if request-chord's
- get_music doesn't do next (), we'll stay in this loop forever?
- */
-
- Sequential_music_iterator* urg = (Sequential_music_iterator*)this;
+ Sequential_music_iterator* i = dynamic_cast<Sequential_music_iterator *> (this->clone ());
SCM s = SCM_EOL;
while (1)
{
- Moment local_until = until - here_mom_;
- while (urg->iter_p_->ok ())
+ Moment local_until = until - i->here_mom_;
+ while (i->iter_p_->ok ())
{
- Moment here = iter_p_->pending_moment ();
+ Moment here = i->iter_p_->pending_moment ();
if (here != local_until)
- return s;
+ goto finalise;
- s = gh_append2 (urg->iter_p_->get_music (local_until), s);
+ s = gh_append2 (i->iter_p_->get_music (local_until), s);
+ i->iter_p_->skip (local_until);
}
- if (!urg->iter_p_->ok ())
+ if (!i->iter_p_->ok ())
{
- urg->leave_element ();
+ i->leave_element ();
- if (gh_pair_p (urg->cursor_))
- urg->start_next_element ();
+ if (gh_pair_p (i->cursor_))
+ i->start_next_element ();
else
- return s;
+ goto finalise;
}
}
+ finalise:
+ delete i;
return s;
-#else
- return SCM_EOL;
-#endif
}
void
return length_mom_;
}
+void
+Simple_music_iterator::skip (Moment m)
+{
+ music_l_ = 0;
+ last_processed_mom_ = m;
+}
+
void
Simple_music_iterator::process (Moment m)
{
classname (music_l_)));
}
#endif
- music_l_ = 0;
- last_processed_mom_ = m;
+ skip (m);
}