]> git.donarmstrong.com Git - lilypond.git/commitdiff
patch::: 1.3.87.jcn2
authorJan Nieuwenhuizen <janneke@gnu.org>
Tue, 19 Sep 2000 10:00:47 +0000 (12:00 +0200)
committerJan Nieuwenhuizen <janneke@gnu.org>
Tue, 19 Sep 2000 10:00:47 +0000 (12:00 +0200)
1.3.87.jcn2
===========

* Added skip (M) to music-iterator which fixes ugly non-const hack
  of get-music (M).

CHANGES
VERSION
lily/include/music-iterator.hh
lily/include/simple-music-iterator.hh
lily/music-iterator.cc
lily/request-chord-iterator.cc
lily/sequential-music-iterator.cc
lily/simple-music-iterator.cc

diff --git a/CHANGES b/CHANGES
index 243f56c9aae764e604072c6679924e4e7f6d37e7..79a11c407876f3cfd7c3d29e0914a20c71f365d4 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,9 @@
+1.3.87.jcn2
+===========
+
+* Added skip (M) to music-iterator which fixes ugly non-const hack 
+  of get-music (M).
+
 1.3.87.jcn1
 ===========
 
diff --git a/VERSION b/VERSION
index f9581647fb90a17276665fb3932ee37e352ac1d9..4055f6ef3f3735a463263b019ac17407262018a9 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond
 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.
index 2f9c6cf7cc887f3109c0b8353a75972315dbc396..25d099ecccd105416885da1ceb89a8d829aebad8 100644 (file)
     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
 {
@@ -75,6 +72,7 @@ public:
   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 
index 6d86c1c35cddb93f57bca56ce245bf6165512d46..c9b861dce39c6b58a081acd47dce24d31d0e66b0 100644 (file)
@@ -21,7 +21,8 @@ public:
   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 ();
 };
index 51ae61f1ce333ff0c6bd46d767dfb3492989f3e0..3806c4e7f7e69a30d47ad029a184428b9dca5a46 100644 (file)
@@ -85,6 +85,12 @@ Music_iterator::pending_moment () const
 }
 
 
+void
+Music_iterator::skip (Moment)
+{
+  assert (0);
+}
+
 void
 Music_iterator::process (Moment)
 {
index 86ab37eaf3eb62aade141f656cb268d88a4b07d2..080240a8b519b726b25d9dc6d8e1e3fe58d0009c 100644 (file)
@@ -46,11 +46,8 @@ Request_chord_iterator::elt_l () const
 }
 
 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_)
     {
@@ -60,7 +57,6 @@ Request_chord_iterator::get_music (Moment m) const
        {
          s = gh_cons (gh_car (m) , s);
        }
-      urg->music_l_ = 0;
     }
   return s;
 }
@@ -68,7 +64,6 @@ Request_chord_iterator::get_music (Moment m) const
 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 ();
@@ -86,7 +81,6 @@ Request_chord_iterator::process (Moment m)
            mus->origin ()->warning (_f ("Huh?  Not a Request: `%s'",
                                         classname (mus)));
        }
-
-     music_l_ =0;
     }
+  skip (m);
 }
index 82051844b418c9b03326a2fa38e04d7ab69823a9..18d9a4915a7d25967ce726543de47c52b1211d61 100644 (file)
@@ -90,45 +90,36 @@ Sequential_music_iterator::set_sequential_music_translator()
 
 
 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
index e919d4b5a0b23939a1b15a24f09420a8e5afce08..b185f8ac24b6c97cb0532ba0a49aa138b9947222 100644 (file)
@@ -45,6 +45,13 @@ Simple_music_iterator::pending_moment ()const
     return length_mom_;
 }
 
+void
+Simple_music_iterator::skip (Moment m)
+{
+  music_l_ = 0;
+  last_processed_mom_ = m;
+}
+
 void
 Simple_music_iterator::process (Moment m)
 {
@@ -60,6 +67,5 @@ Simple_music_iterator::process (Moment m)
                                          classname (music_l_)));
     }
 #endif
-  music_l_ = 0;
-  last_processed_mom_ = m;
+  skip (m);
 }