]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/music-scheme.cc
Merge branch 'jneeman' of git+ssh://jneem@git.sv.gnu.org/srv/git/lilypond into jneeman
[lilypond.git] / lily / music-scheme.cc
index f898ba8f6ab53107241c5619ab13365411cddc77..365c3f434474166b64fa6b5df2b9dc03005ecfb5 100644 (file)
@@ -3,13 +3,13 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  (c) 2005--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
 */
 
+#include "music.hh"
+
 #include "duration.hh"
 #include "warn.hh"
-#include "music.hh"
-#include "pitch.hh"
 
 LY_DEFINE (ly_music_length, "ly:music-length",
           1, 0, 0, (SCM mus),
@@ -21,15 +21,13 @@ LY_DEFINE (ly_music_length, "ly:music-length",
 }
 
 LY_DEFINE (ly_music_property,
-          "ly:music-property", 2, 0, 0, (SCM mus, SCM sym),
+          "ly:music-property", 2, 1, 0, (SCM mus, SCM sym, SCM dfault),
           "Get the property @var{sym} of music expression @var{mus}.\n"
-          "If @var{sym} is undefined, return @code{' ()}.\n")
+          "If @var{sym} is undefined, return @code{'()}.\n")
 {
   Music *sc = unsmob_music (mus);
   SCM_ASSERT_TYPE (sc, mus, SCM_ARG1, __FUNCTION__, "music");
-  SCM_ASSERT_TYPE (scm_is_symbol (sym), sym, SCM_ARG2, __FUNCTION__, "symbol");
-
-  return sc->internal_get_property (sym);
+  return ly_prob_property (mus,sym,dfault);
 }
 
 LY_DEFINE (ly_music_set_property, "ly:music-set-property!",
@@ -38,27 +36,9 @@ LY_DEFINE (ly_music_set_property, "ly:music-set-property!",
 {
   Music *sc = unsmob_music (mus);
   SCM_ASSERT_TYPE (sc, mus, SCM_ARG1, __FUNCTION__, "music");
-  SCM_ASSERT_TYPE (scm_is_symbol (sym), sym, SCM_ARG2, __FUNCTION__, "symbol");
-
-  bool ok = type_check_assignment (sym, val, ly_symbol2scm ("music-type?"));
-  if (ok)
-    {
-      sc->internal_set_property (sym, val);
-    }
-
-  return SCM_UNSPECIFIED;
+  return ly_prob_set_property_x (mus, sym, val);
 }
 
-LY_DEFINE (ly_music_name, "ly:music-name",
-          1, 0, 0, (SCM mus),
-          "Return the name of @var{music}.")
-{
-  Music *m = unsmob_music (mus);
-  SCM_ASSERT_TYPE (m, mus, SCM_ARG1, __FUNCTION__, "music");
-
-  char const *nm = classname (m);
-  return scm_makfrom0str (nm);
-}
 
 /* todo:  property args */
 LY_DEFINE (ly_make_music, "ly:make-music",
@@ -74,6 +54,13 @@ LY_DEFINE (ly_make_music, "ly:make-music",
   return ms->unprotect ();
 }
 
+LY_DEFINE (ly_music_p, "ly:music?",
+          1, 0, 0, (SCM obj),
+          "Type predicate")
+{
+  return scm_from_bool (unsmob_music (obj));
+}
+
 /* todo: property args */
 LY_DEFINE (ly_music_mutable_properties, "ly:music-mutable-properties",
           1, 0, 0, (SCM mus),
@@ -110,7 +97,7 @@ LY_DEFINE (ly_music_deep_copy, "ly:music-deep-copy",
   SCM copy = m;
   if (unsmob_music (m))
     {
-      Music * mcopy = unsmob_music (m)->clone ();
+      Music *mcopy = unsmob_music (m)->clone ();
       copy = mcopy->unprotect ();
     }
   else if (scm_is_pair (m))
@@ -208,10 +195,10 @@ LY_DEFINE (ly_transpose_key_alist, "ly:transpose-key-alist",
 
          orig = orig.transposed (*p);
 
-         SCM key = scm_cons (scm_int2num (orig.get_octave ()),
-                             scm_int2num (orig.get_notename ()));
+         SCM key = scm_cons (scm_from_int (orig.get_octave ()),
+                             scm_from_int (orig.get_notename ()));
 
-         newlist = scm_cons (scm_cons (key, scm_int2num (orig.get_alteration ())),
+         newlist = scm_cons (scm_cons (key, scm_from_int (orig.get_alteration ())),
                              newlist);
        }
       else if (scm_is_number (key))
@@ -219,10 +206,11 @@ LY_DEFINE (ly_transpose_key_alist, "ly:transpose-key-alist",
          Pitch orig (0, scm_to_int (key), scm_to_int (alter));
          orig = orig.transposed (*p);
 
-         key = scm_int2num (orig.get_notename ());
-         alter = scm_int2num (orig.get_alteration ());
+         key = scm_from_int (orig.get_notename ());
+         alter = scm_from_int (orig.get_alteration ());
          newlist = scm_cons (scm_cons (key, alter), newlist);
        }
     }
   return scm_reverse_x (newlist, SCM_EOL);
 }
+