-
-
-Unfolded_repeat_iterator::~Unfolded_repeat_iterator ()
-{
- delete current_iter_p_;
-}
-
-Unfolded_repeat_iterator::Unfolded_repeat_iterator (Unfolded_repeat_iterator const &src)
- : Music_iterator (src)
-{
- done_count_ = src.done_count_;
- current_iter_p_ = (src.current_iter_p_)? src.current_iter_p_->clone () : 0;
- do_main_b_ = src.do_main_b_;
- volta_b_ = src.volta_b_;
- here_mom_ = src.here_mom_;
- alternative_count_i_ = src.alternative_count_i_;
- alternative_cons_ = src.alternative_cons_;
-}
-
-Unfolded_repeat_iterator::Unfolded_repeat_iterator ()
-{
- done_count_ =0;
- current_iter_p_ =0;
- volta_b_ = false;
- do_main_b_ = false;
- here_mom_ = Moment (0);
- alternative_count_i_ =0;
- alternative_cons_ = SCM_EOL;
-}
-
-/**
-
-If we are in the body of the repeat always go to the current alternative.
-
-If we are not in the body, then we are in an alternative. If we are
-fully unfolding, advance the current alternative and go back to main.
-If we are semi-unfolding, advance the current alternative, and go to
-the alternative just set.
-
- */
-void
-Unfolded_repeat_iterator::next_element (bool side_effect)
-{
- Repeated_music * repmus =dynamic_cast<Repeated_music *> (music_l ());
- delete current_iter_p_;
- current_iter_p_ =0;
-
- bool do_repcommands = side_effect && volta_b_;
-
- if (do_main_b_)
- {
- /*
- we were busy doing the main body, so
-
- - go to alternative if we're a volta
-
- - make a :| if there are no alternatives
-
- - do something intelligent when we're fully unfolding (fixcomment)
- */
-
- here_mom_ += repmus->body ()->length_mom ();
-
- if (!volta_b_)
- done_count_ ++;
-
- if (gh_pair_p (alternative_cons_))
- {
- current_iter_p_ = get_iterator_p (unsmob_music (ly_car (alternative_cons_)));
- do_main_b_ = false;
-
- if (volta_b_)
- {
- String repstr = to_str (done_count_ + 1) + ".";
-
- /*
- we're coming in from main, so we're always on the first repeat.
- */
- assert (done_count_ == 0);
-
- if (done_count_ == 0
- && alternative_count_i_ < repmus->repeat_count ())
- {
- done_count_ += repmus->repeat_count () - alternative_count_i_;
- repstr = "1.--" + to_str (done_count_ + 1) + ".";
- }
-
- if (do_repcommands)
- add_repeat_command (scm_list_n (ly_symbol2scm ("volta"),
- ly_str02scm (repstr.ch_C ()), SCM_UNDEFINED));
- }
- }
- else if (volta_b_)
- {
- add_repeat_command (ly_symbol2scm ("end-repeat"));
- }
- else if (done_count_ < repmus->repeat_count ())
- {
- current_iter_p_ = get_iterator_p (repmus->body ());
- do_main_b_ = true;
- }
- }
- else
- {
- /*
- we're not in the main part. So we're either in an alternative, or
- we just finished.
- */
-
- /*
- we're in the alternatives. We move the pointer to the
- next alternative.
- */
- if (alternative_cons_)
- {
- here_mom_ += unsmob_music (ly_car (alternative_cons_))->length_mom ();
-
- if (volta_b_ ||
- repmus->repeat_count () - done_count_ < alternative_count_i_)
- alternative_cons_ = ly_cdr (alternative_cons_);
-
- if (do_repcommands)
- add_repeat_command (scm_list_n (ly_symbol2scm ("volta"), SCM_BOOL_F, SCM_UNDEFINED));
-
-
-
- /*
- we've done the main body as well, but didn't go over the other
- increment. */
- if (volta_b_)
- done_count_ ++;
- }
-
- /*
- We still have alternatives left, so
-
- if we're volta: traverse them
-
- if we're full unfold: go back to main body.
- */
-
- if (done_count_ < repmus->repeat_count () && gh_pair_p (alternative_cons_))
- {
- if (do_repcommands)
- {
- String repstr = to_str (done_count_ + 1) + ".";
- add_repeat_command (scm_list_n (ly_symbol2scm ("volta"),
- ly_str02scm (repstr.ch_C ()), SCM_UNDEFINED));
- add_repeat_command (ly_symbol2scm ("end-repeat"));
- }
-
-
- if (volta_b_)
- current_iter_p_ = get_iterator_p (unsmob_music (ly_car (alternative_cons_)));
- else
- {
- current_iter_p_ = get_iterator_p (repmus->body ());
- do_main_b_ = true;
- }
- }
- }
-}
-
-
-bool
-Unfolded_repeat_iterator::ok () const
-{
- return current_iter_p_;
-}
-
-Moment
-Unfolded_repeat_iterator::pending_moment () const
-{
- return here_mom_ + current_iter_p_->pending_moment ();
-}
-
-void
-Unfolded_repeat_iterator::construct_children ()