]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/music-scheme.cc
Run grand-replace (issue 3765)
[lilypond.git] / lily / music-scheme.cc
index 34545fa911d33da5293c4c656e2342da1d4ad329..55f1333bf5dbb297d3f00426865113b7c6c5a871 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 2005--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  Copyright (C) 2005--2014 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
   LilyPond is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -76,11 +76,11 @@ LY_DEFINE (ly_music_p, "ly:music?",
 
 LY_DEFINE (ly_event_p, "ly:event?",
            1, 0, 0, (SCM obj),
-           "Is @var{obj} an event object?")
+           "Is @var{obj} a proper (non-rhythmic) event object?")
 {
   if (Music *m = unsmob_music (obj))
     {
-      return scm_from_bool (m->is_mus_type ("event"));
+      return scm_from_bool (m->is_mus_type ("post-event"));
     }
   return SCM_BOOL_F;
 }
@@ -114,18 +114,30 @@ LY_DEFINE (ly_music_list_p, "ly:music-list?",
 
 LY_DEFINE (ly_music_deep_copy, "ly:music-deep-copy",
            1, 0, 0, (SCM m),
-           "Copy @var{m} and all sub expressions of@tie{}@var{m}.")
+           "Copy @var{m} and all sub expressions of@tie{}@var{m}."
+           " @var{m} may be an arbitrary type; cons cells and music"
+           " are copied recursively.")
 {
-  SCM copy = m;
   if (unsmob_music (m))
+      return unsmob_music (m)->clone ()->unprotect ();
+  if (scm_is_pair (m))
     {
-      Music *mcopy = unsmob_music (m)->clone ();
-      copy = mcopy->unprotect ();
+      SCM copy = SCM_EOL;
+      do
+        {
+          copy = scm_cons (ly_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, ly_music_deep_copy (m));
+      SCM last_cons = copy;
+      copy = scm_reverse_x (copy, SCM_EOL);
+      scm_set_cdr_x (last_cons, ly_music_deep_copy (m));
+      return copy;
     }
-  else if (scm_is_pair (m))
-    copy = scm_cons (ly_music_deep_copy (scm_car (m)),
-                     ly_music_deep_copy (scm_cdr (m)));
-  return copy;
+  return m;
 }
 
 LY_DEFINE (ly_music_transpose, "ly:music-transpose",
@@ -160,23 +172,20 @@ LY_DEFINE (ly_music_compress, "ly:music-compress",
 }
 
 LY_DEFINE (ly_make_music_relative_x, "ly:make-music-relative!",
-          2, 0, 0, (SCM music, SCM pitch),
-          "Make @var{music} relative to @var{pitch},"
-          " return final pitch.")
+           2, 0, 0, (SCM music, SCM pitch),
+           "Make @var{music} relative to @var{pitch},"
+           " return final pitch.")
 {
   LY_ASSERT_TYPE (unsmob_music, music, 1);
   LY_ASSERT_TYPE (unsmob_pitch, pitch, 2);
 
-       Pitch start = *unsmob_pitch (pitch);
-       Music *m = unsmob_music (music);
-       Pitch last = m->to_relative_octave (start);
-       if (lily_1_8_relative)
-               m->set_property ("last-pitch", last.smobbed_copy ());
+  Pitch start = *unsmob_pitch (pitch);
+  Music *m = unsmob_music (music);
+  Pitch last = m->to_relative_octave (start);
 
-       return last.smobbed_copy ();
+  return last.smobbed_copy ();
 }
 
-
 LY_DEFINE (ly_music_duration_length, "ly:music-duration-length", 1, 0, 0,
            (SCM mus),
            "Extract the duration field from @var{mus} and return the"