X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fmusic-scheme.cc;h=27e5db98804752020a1460fb1cff339eac7f1398;hb=cd97f3fa5b1275595307e89b5b070f833adb573a;hp=da81ec6381003493eef9217563e381e0ce226ed8;hpb=57be7394ffa2e7d7ba6d60548dba563f3409d472;p=lilypond.git diff --git a/lily/music-scheme.cc b/lily/music-scheme.cc index da81ec6381..27e5db9880 100644 --- a/lily/music-scheme.cc +++ b/lily/music-scheme.cc @@ -3,7 +3,7 @@ source file of the GNU LilyPond music typesetter - (c) 2005 Han-Wen Nienhuys + (c) 2005--2006 Han-Wen Nienhuys */ #include "duration.hh" @@ -11,6 +11,7 @@ #include "music.hh" #include "pitch.hh" + LY_DEFINE (ly_music_length, "ly:music-length", 1, 0, 0, (SCM mus), "Get the length of music expression @var{mus}, and return as a @code{Moment} object.") @@ -21,15 +22,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,42 +37,29 @@ 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_extended_make_music, "ly:make-bare-music", - 2, 0, 0, (SCM type, SCM props), - "Make a C++ music object of type @var{type}, initialize with\n" +LY_DEFINE (ly_make_music, "ly:make-music", + 1, 0, 0, (SCM props), + "Make a C++ Music object, initialize with\n" "@var{props}. \n\n" "" "This function is for internal use, and is only called by " "@code{make-music}, which is the preferred interface " "for creating music objects. ") { - SCM_ASSERT_TYPE (scm_is_string (type), type, SCM_ARG1, __FUNCTION__, "string"); - SCM s = make_music (ly_scm2string (type), props)->self_scm (); - scm_gc_unprotect_object (s); - return s; + Music *ms = new Music (props); + 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 */ @@ -112,8 +98,8 @@ LY_DEFINE (ly_music_deep_copy, "ly:music-deep-copy", SCM copy = m; if (unsmob_music (m)) { - copy = unsmob_music (m)->clone ()->self_scm (); - scm_gc_unprotect_object (copy); + Music *mcopy = unsmob_music (m)->clone (); + copy = mcopy->unprotect (); } else if (scm_is_pair (m)) copy = scm_cons (ly_music_deep_copy (scm_car (m)), @@ -210,10 +196,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)) @@ -221,10 +207,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); } +