]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/music.cc
LSR Update
[lilypond.git] / lily / music.cc
index 613b5387ff772989ad19adf62b0338c89ba33553..60d33436b98bf1ea17cc2bad6475a222e8b60c45 100644 (file)
@@ -28,6 +28,7 @@
 #include "music-sequence.hh"
 #include "score.hh"
 #include "warn.hh"
+#include "lily-imports.hh"
 
 /*
   Music is anything that has (possibly zero) duration and supports
@@ -67,7 +68,7 @@ Music::derived_mark () const
 SCM
 Music::copy_mutable_properties () const
 {
-  return ly_music_deep_copy (mutable_property_alist_);
+  return music_deep_copy (mutable_property_alist_);
 }
 
 void
@@ -269,7 +270,7 @@ Music::to_event () const
     programming_error ("Not a music type");
 
   Stream_event *e = new Stream_event
-    (scm_call_1 (ly_lily_module_constant ("ly:make-event-class"), class_name),
+    (Lily::ly_make_event_class (class_name),
      mutable_property_alist_);
   Moment length = get_length ();
   if (length.to_bool ())
@@ -308,8 +309,7 @@ Music::send_to_context (Context *c)
 Music *
 make_music_by_name (SCM sym)
 {
-  SCM make_music_proc = ly_lily_module_constant ("make-music");
-  SCM rv = scm_call_1 (make_music_proc, sym);
+  SCM rv = Lily::make_music (sym);
 
   /* UGH. */
   Music *m = unsmob<Music> (rv);
@@ -329,3 +329,40 @@ Music::duration_length_callback (SCM m)
     mom = d->get_length ();
   return mom.smobbed_copy ();
 }
+
+SCM
+music_deep_copy (SCM m)
+{
+  if (Music *mus = unsmob<Music> (m))
+      return mus->clone ()->unprotect ();
+  if (scm_is_pair (m))
+    {
+      SCM copy = SCM_EOL;
+      do
+        {
+          copy = scm_cons (music_deep_copy (scm_car (m)), copy);
+          m = scm_cdr (m);
+        }
+      while (scm_is_pair (m));
+      // Oh, come on, GUILE.  Why do you require the second argument
+      // of scm_reverse_x to be a proper list?  That makes no sense.
+      // return scm_reverse_x (copy, music_deep_copy (m));
+      SCM last_cons = copy;
+      copy = scm_reverse_x (copy, SCM_EOL);
+      scm_set_cdr_x (last_cons, music_deep_copy (m));
+      return copy;
+    }
+  return m;
+}
+
+void
+set_origin (SCM m, SCM origin)
+{
+  while (scm_is_pair (m))
+    {
+      set_origin (scm_car (m), origin);
+      m = scm_cdr (m);
+    }
+  if (Music *mus = unsmob<Music> (m))
+    mus->set_property ("origin", origin);
+}