X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fmoment.cc;h=adcecff767140095dd22e5fbb5aa3d8a5453fdb5;hb=5bbfc22fce036b9b69df5e420de93e11da23c05e;hp=f4caf2823e9b4ab1186a12800485861367f23557;hpb=326d4b9575d9b8af02c246d421ba5b1fa952119e;p=lilypond.git diff --git a/lily/moment.cc b/lily/moment.cc index f4caf2823e..adcecff767 100644 --- a/lily/moment.cc +++ b/lily/moment.cc @@ -1,15 +1,25 @@ -/* - moment.cc -- implement Moment +/* + This file is part of LilyPond, the GNU music typesetter. + + Copyright (C) 1999--2014 Han-Wen Nienhuys + + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - source file of the GNU LilyPond music typesetter + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - (c) 1999--2004 Han-Wen Nienhuys + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . */ -#include "lily-guile.hh" #include "moment.hh" -#include "warn.hh" +#include "warn.hh" Moment::Moment () { @@ -18,7 +28,7 @@ Moment::Moment () Moment::Moment (int m) { main_part_ = Rational (m); - grace_part_ = Rational ( 0); + grace_part_ = Rational (0); } Moment::Moment (Rational m, Rational g) @@ -34,6 +44,7 @@ Moment::Moment (Rational m) } #include "ly-smobs.icc" + IMPLEMENT_SIMPLE_SMOBS (Moment); IMPLEMENT_TYPE_P (Moment, "ly:moment?"); @@ -46,115 +57,45 @@ Moment::mark_smob (SCM) int Moment::print_smob (SCM s, SCM port, scm_print_state *) { - Moment *r = (Moment *) SCM_CELL_WORD_1 (s); - + Moment *r = (Moment *) SCM_CELL_WORD_1 (s); + scm_puts ("#to_string (); - scm_puts ((char *)str.to_str0 (), port); + string str = r->to_string (); + scm_puts ((char *)str.c_str (), port); scm_puts (">", port); - - return 1; -} - -/* TODO: add optional factor argument. */ -LY_DEFINE (ly_make_moment, "ly:make-moment", - 2, 2, 0, (SCM n, SCM d, SCM gn, SCM gd), - "Create the rational number with main timing @var{n}/@var{d}, " - "and optional grace timin @var{gn}/@var{gd}.\n" - "\n" - "\n" - "Moment is a point in musical time. " - "It is consists of a pair of rationals (@var{m},@var{g}), " - "where @var{m} is the timing for the main\n" - "notes, and @var{g} the timing for grace notes. " - "In absence of grace notes, @var{g} is zero.\n") -{ - SCM_ASSERT_TYPE (scm_is_integer (n), n, SCM_ARG1, __FUNCTION__, "integer"); - SCM_ASSERT_TYPE (scm_is_integer (d), d, SCM_ARG2, __FUNCTION__, "integer"); - - int grace_num = 0; - if (gn != SCM_UNDEFINED) - { - SCM_ASSERT_TYPE (scm_is_integer (gn), gn, SCM_ARG3, __FUNCTION__, "integer"); - grace_num = scm_to_int (gn); - } - - int grace_den = 1; - if (gd != SCM_UNDEFINED) - { - SCM_ASSERT_TYPE (scm_is_integer (gd), gd, SCM_ARG4, __FUNCTION__, "integer"); - grace_den = scm_to_int (gd); - } - - return Moment (Rational (scm_to_int (n), scm_to_int (d)), - Rational (grace_num, grace_den)).smobbed_copy (); -} - -LY_DEFINE (ly_add_moment, "ly:add-moment", - 2, 0, 0, (SCM a, SCM b), - "Add two moments.") -{ - Moment *ma = unsmob_moment (a); - Moment *mb = unsmob_moment (b); - SCM_ASSERT_TYPE (ma, a, SCM_ARG1, __FUNCTION__, "moment"); - SCM_ASSERT_TYPE (mb, b, SCM_ARG2, __FUNCTION__, "moment"); - return (*ma + *mb).smobbed_copy (); -} - -LY_DEFINE (ly_mul_moment,"ly:mul-moment", - 2, 0, 0, (SCM a, SCM b), - "Multiply two moments.") -{ - Moment *ma = unsmob_moment (a); - Moment *mb = unsmob_moment (b); - SCM_ASSERT_TYPE (ma, a, SCM_ARG1, __FUNCTION__, "moment"); - SCM_ASSERT_TYPE (mb, b, SCM_ARG2, __FUNCTION__, "moment"); - return (*ma * *mb).smobbed_copy (); -} -LY_DEFINE (ly_div_moment,"ly:div-moment", - 2, 0, 0, (SCM a, SCM b), - "Divide two moments.") -{ - Moment *ma = unsmob_moment (a); - Moment *mb = unsmob_moment (b); - SCM_ASSERT_TYPE (ma, a, SCM_ARG1, __FUNCTION__, "moment"); - SCM_ASSERT_TYPE (mb, b, SCM_ARG2, __FUNCTION__, "moment"); - return (*ma / *mb).smobbed_copy (); + return 1; } -LY_DEFINE (ly_moment_less_p,"ly:moment