X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fduration-scheme.cc;h=a90fb1fda81079f6a8b95659e1bfb25a36add4ee;hb=a6a4b3fc2009f17a1a48cca0c11bfd3f38645937;hp=0ecf130acfa361f49ae48c76be3490949e5e4cd2;hpb=51dd610fd06e1a5ebb8a8e84d13abd83feaafd55;p=lilypond.git diff --git a/lily/duration-scheme.cc b/lily/duration-scheme.cc index 0ecf130acf..a90fb1fda8 100644 --- a/lily/duration-scheme.cc +++ b/lily/duration-scheme.cc @@ -3,9 +3,8 @@ source file of the LilyPond music typesetter - (c) 1997--2005 Jan Nieuwenhuizen - Han-Wen Nienhuys - + (c) 1997--2008 Jan Nieuwenhuizen + Han-Wen Nienhuys */ #include "duration.hh" @@ -26,14 +25,14 @@ Duration::less_p (SCM p1, SCM p2) LY_DEFINE (ly_duration_less_p, "ly:durationduration_log ()); + LY_ASSERT_SMOB (Duration, dur, 1); + return scm_from_int (unsmob_duration (dur)->duration_log ()); } LY_DEFINE (ly_duration_dot_count, "ly:duration-dot-count", 1, 0, 0, (SCM dur), - "Extract the dot count from @var{dur}") + "Extract the dot count from @var{dur}.") { - SCM_ASSERT_TYPE (unsmob_duration (dur), dur, SCM_ARG1, __FUNCTION__, "duration"); - return scm_int2num (unsmob_duration (dur)->dot_count ()); + LY_ASSERT_SMOB (Duration, dur, 1); + return scm_from_int (unsmob_duration (dur)->dot_count ()); } LY_DEFINE (ly_intlog2, "ly:intlog2", 1, 0, 0, (SCM d), - "The 2-logarithm of 1/@var{d}.") + "The 2-logarithm of 1/@var{d}.") { - SCM_ASSERT_TYPE (scm_is_number (d), d, SCM_ARG1, __FUNCTION__, "integer"); + LY_ASSERT_TYPE (scm_is_number, d, 1); int log = intlog2 (scm_to_int (d)); - return scm_int2num (log); + return scm_from_int (log); +} + +LY_DEFINE (ly_duration_length, "ly:duration-length", + 1, 0, 0, (SCM dur), + "The length of the duration as a @code{moment}.") +{ + LY_ASSERT_SMOB (Duration, dur, 1); + return Moment (unsmob_duration (dur)->get_length ()).smobbed_copy (); +} + +LY_DEFINE (ly_duration_2_string, "ly:duration->string", + 1, 0, 0, (SCM dur), + "Convert @var{dur} to a string.") +{ + LY_ASSERT_SMOB (Duration, dur, 1); + return ly_string2scm (unsmob_duration (dur)->to_string ()); } LY_DEFINE (ly_duration_factor, "ly:duration-factor", 1, 0, 0, (SCM dur), - "Extract the compression factor from @var{dur}. Return as a pair.") + "Extract the compression factor from @var{dur}." + " Return it as a pair.") { - SCM_ASSERT_TYPE (unsmob_duration (dur), dur, SCM_ARG1, __FUNCTION__, "duration"); + LY_ASSERT_SMOB (Duration, dur, 1); Rational r = unsmob_duration (dur)->factor (); - return scm_cons (scm_int2num (r.num ()), scm_int2num (r.den ())); + return scm_cons (scm_from_int64 (r.num ()), scm_from_int64 (r.den ())); }