X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Frequest-chord-iterator.cc;h=118279299b768acc65af42ae4fc06399350f6888;hb=b7e3626cf632670001a2e74af5083abafd32be55;hp=47d28ce770484c69e928723bb0ba3b9ebb2b1148;hpb=ad4297de0246935caa4c51f4e152e20009a6f64e;p=lilypond.git diff --git a/lily/request-chord-iterator.cc b/lily/request-chord-iterator.cc index 47d28ce770..118279299b 100644 --- a/lily/request-chord-iterator.cc +++ b/lily/request-chord-iterator.cc @@ -3,7 +3,7 @@ source file of the GNU LilyPond music typesetter - (c) 1997--1999 Han-Wen Nienhuys + (c) 1997--2001 Han-Wen Nienhuys */ #include "translator-group.hh" @@ -12,91 +12,71 @@ #include "music-list.hh" #include "request.hh" - - -void -Request_chord_iterator::construct_children() +Request_chord_iterator::Request_chord_iterator () { - elt_length_mom_ =elt_l ()->length_mom (); - get_req_translator_l(); } -Request_chord* -Request_chord_iterator::elt_l () const +Request_chord_iterator::Request_chord_iterator (Request_chord_iterator const &src) + : Simple_music_iterator (src) { - return (Request_chord*) music_l_; } -Request_chord_iterator::Request_chord_iterator () +Translator_group* +Request_chord_iterator::get_req_translator_l () { - last_b_ = false; - // cursor_ = elt_l ()->music_p_list_p_->head_; - cursor_ = 0; -} + assert (report_to_l ()); + if (report_to_l ()->is_bottom_translator_b ()) + return report_to_l (); + set_translator (report_to_l ()->get_default_interpreter ()); + return report_to_l (); +} -bool -Request_chord_iterator::ok() const +void +Request_chord_iterator::construct_children() { - return (elt_length_mom_ && !last_b_) || first_b_; + Simple_music_iterator::construct_children (); + get_req_translator_l(); } -Moment -Request_chord_iterator::next_moment() const +Request_chord* +Request_chord_iterator::elt_l () const { - Moment m (0); - if (!first_b_) - m = elt_length_mom_; - return m; + return (Request_chord*) music_l_; } -Music* -Request_chord_iterator::next_music_l () +SCM +Request_chord_iterator::get_music (Moment) const { - if (first_b_) + SCM s = SCM_EOL; + if (last_processed_mom_ < Moment (0)) { - cursor_ = elt_l ()->music_p_list_p_->head_; - first_b_ = false; - } - else - { - if (cursor_) - cursor_ = cursor_->next_; + Music_sequence * ms = dynamic_cast (music_l_); + + for (SCM m = ms->music_list (); gh_pair_p (m); m = gh_cdr (m)) + { + s = gh_cons (gh_car (m) , s); + } } - if (cursor_) - return cursor_->car_; - else - return 0; + return s; } void -Request_chord_iterator::do_print() const +Request_chord_iterator::process (Moment m) { -#ifndef NPRINT - DOUT << "duration: " << elt_length_mom_; -#endif -} - -void -Request_chord_iterator::do_process_and_next (Moment mom) -{ - if (first_b_) + if (last_processed_mom_ < Moment (0)) { - for (Cons *i = elt_l ()->music_p_list_p_->head_; i; i = i->next_) + for (SCM s = dynamic_cast (music_l_)->music_list (); + gh_pair_p (s); s = gh_cdr (s)) { - if (Request * req_l = dynamic_cast (i->car_)) - { - bool gotcha = report_to_l()->try_music (req_l); - if (!gotcha) - req_l->warning (_f ("junking request: `%s\'", classname( req_l))); - } - else - i->car_->warning (_f ("Huh? Not a Request: `%s\'", - classname (i->car_))); + Music *mus = unsmob_music (gh_car (s)); + + bool gotcha = try_music (mus); + if (!gotcha) + mus->origin ()->warning (_f ("Junking request: `%s'", classname(mus))); } - first_b_ = false; } - - if (mom >= elt_length_mom_) - last_b_ = true; + skip (m); } + +IMPLEMENT_CTOR_CALLBACK(Request_chord_iterator);