]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/quote-iterator.cc
Fix some bugs in the dynamic engraver and PostScript backend
[lilypond.git] / lily / quote-iterator.cc
index ab7a206ce1a7b90aab03fbb76bd70975c6778a90..9ca8fd25b7ed4dacf22b551e35bf838350894f91 100644 (file)
@@ -3,14 +3,17 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  (c) 2004--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
 */
 
+#include "music-wrapper-iterator.hh"
+
 #include "context.hh"
-#include "event.hh"
-#include "music-sequence.hh"
+#include "input.hh"
+#include "international.hh"
 #include "lily-guile.hh"
-#include "music-wrapper-iterator.hh"
+#include "music-sequence.hh"
+#include "music.hh"
 #include "warn.hh"
 
 class Quote_iterator : public Music_wrapper_iterator
@@ -18,27 +21,36 @@ class Quote_iterator : public Music_wrapper_iterator
 public:
   Quote_iterator ();
   Moment vector_moment (int idx) const;
-  Interpretation_context_handle quote_outlet_;
+  Context_handle quote_outlet_;
 
   Moment start_moment_;
   Moment stop_moment_;
   SCM event_vector_;
   int event_idx_;
   int end_idx_;
-
+  
   SCM transposed_musics_;
 
   DECLARE_SCHEME_CALLBACK (constructor, ());
   bool quote_ok () const;
   bool accept_music_type (Music *) const;
+
 protected:
   virtual void derived_mark () const;
   virtual void construct_children ();
   virtual Moment pending_moment () const;
   virtual void process (Moment);
+  virtual void do_quit ();
   virtual bool ok () const;
 };
 
+void
+Quote_iterator::do_quit ()
+{
+  Music_wrapper_iterator::do_quit ();
+  quote_outlet_.set_context (0);
+}
+
 bool
 Quote_iterator::accept_music_type (Music *mus) const
 {
@@ -56,6 +68,7 @@ Quote_iterator::accept_music_type (Music *mus) const
 void
 Quote_iterator::derived_mark () const
 {
+  Music_wrapper_iterator::derived_mark ();
   scm_gc_mark (transposed_musics_);
 }
 
@@ -94,7 +107,7 @@ void
 Quote_iterator::construct_children ()
 {
   Music_wrapper_iterator::construct_children ();
-
+      
   SCM name = get_music ()->get_property ("quoted-context-type");
   SCM id = get_music ()->get_property ("quoted-context-id");
 
@@ -106,9 +119,7 @@ Quote_iterator::construct_children ()
       quote_outlet_.set_context (cue_context);
     }
   else
-    {
-      quote_outlet_.set_context (get_outlet ());
-    }
+    quote_outlet_.set_context (get_outlet ());
 
   event_vector_ = get_music ()->get_property ("quoted-events");
 
@@ -149,14 +160,14 @@ Quote_iterator::pending_moment () const
   Moment m (infty);
 
   if (Music_wrapper_iterator::ok ())
-    m = m <? Music_wrapper_iterator::pending_moment ();
+    m = min (m, Music_wrapper_iterator::pending_moment ());
 
   /*
     In case event_idx_ < 0, we're not initted yet, and the wrapped
     music expression determines the starting moment.
   */
   if (quote_ok ())
-    m = m <? vector_moment (event_idx_) - start_moment_;
+    m = min (m, vector_moment (event_idx_) - start_moment_);
 
   return m;
 }
@@ -211,7 +222,9 @@ Quote_iterator::process (Moment m)
       /*
        The pitch that sounds like central C
       */
-      Pitch *me_pitch = unsmob_pitch (get_outlet ()->get_property ("instrumentTransposition"));
+      Pitch *me_pitch = unsmob_pitch (get_music ()->get_property ("quoted-transposition"));
+      if (!me_pitch)
+       me_pitch = unsmob_pitch (get_outlet ()->get_property ("instrumentTransposition"));
 
       for (SCM s = scm_cdr (entry); scm_is_pair (s); s = scm_cdr (s))
        {
@@ -219,7 +232,7 @@ Quote_iterator::process (Moment m)
 
          Music *mus = unsmob_music (scm_car (ev_acc));
          if (!mus)
-           programming_error ("need music in quote.");
+           programming_error ("no music found in quote");
          else if (accept_music_type (mus))
            {
              if (quote_pitch || me_pitch)
@@ -239,9 +252,7 @@ Quote_iterator::process (Moment m)
                  mus->transpose (diff);
                }
 
-             bool b = quote_outlet_.get_outlet ()->try_music (mus);
-             if (!b)
-               mus->origin ()->warning (_f ("In quotation: junking event %s", mus->name ()));
+             quote_outlet_.get_outlet ()->try_music (mus);
            }
        }