X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fmoment.cc;h=9f3e8ed383837e3fb7059eebff437cac5423588a;hb=47db9a3883d726ca53e2133a3b2298f78dd6a32e;hp=39c509f7347b455a4c058e54236ab82265248136;hpb=e37010af17faa8b185de836664b6544bd29dc1d0;p=lilypond.git diff --git a/lily/moment.cc b/lily/moment.cc index 39c509f734..9f3e8ed383 100644 --- a/lily/moment.cc +++ b/lily/moment.cc @@ -1,210 +1,148 @@ -/* - moment.cc -- implement Moment - - source file of the GNU LilyPond music typesetter - - (c) 1999--2004 Han-Wen Nienhuys - - */ +/* + This file is part of LilyPond, the GNU music typesetter. + Copyright (C) 1999--2015 Han-Wen Nienhuys -#include "lily-guile.hh" -#include "moment.hh" -#include "warn.hh" -#include "ly-smobs.icc" + 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. -IMPLEMENT_SIMPLE_SMOBS (Moment); -IMPLEMENT_TYPE_P (Moment, "ly:moment?"); - -SCM -Moment::mark_smob (SCM) -{ - return SCM_EOL; -} + 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. + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . +*/ -SCM -Moment::smobbed_copy () const -{ - Moment * m = new Moment (*this); - return m->smobbed_self (); -} +#include "moment.hh" +#include "warn.hh" -int -Moment::print_smob (SCM s, SCM port, scm_print_state *) +Moment::Moment () { - Moment *r = (Moment *) ly_cdr (s); - - scm_puts ("#to_string (); - scm_puts ((char *)str.to_str0 (), port); - scm_puts (">", port); - - return 1; } -/* - TODO: add optional factor argument. -*/ -LY_DEFINE (make_moment,"ly:make-moment", 2,0,0, (SCM n, SCM d), - "create the rational number with main timing @var{n}/@var{d}. \n" - "\n" - "\n" - "Moment is a point in musical time. It is consists of a pair of\n" - "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\n" - "notes, @var{g} is zero.\n" - ) +Moment::Moment (int m) { - SCM_ASSERT_TYPE(SCM_INUMP (n), n, SCM_ARG1, __FUNCTION__, "integer"); - SCM_ASSERT_TYPE(SCM_INUMP (d), d, SCM_ARG2, __FUNCTION__, "integer"); - - return Moment (Rational (gh_scm2int (n), gh_scm2int (d))).smobbed_copy(); + main_part_ = Rational (m); + grace_part_ = Rational (0); } -LY_DEFINE (add_moment,"ly:add-moment", 2,0,0, (SCM a, SCM b), - "Add two moments." - ) +Moment::Moment (Rational m, Rational g) { - 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(); + main_part_ = m; + grace_part_ = g; } - -LY_DEFINE (mul_moment,"ly:mul-moment", 2,0,0, (SCM a, SCM b), - "Multiply two moments." - ) +Moment::Moment (Rational m) { - 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(); + main_part_ = m; + grace_part_ = Rational (0); } +const char Moment::type_p_name_[] = "ly:moment?"; + -LY_DEFINE (div_moment,"ly:div-moment", 2,0,0, (SCM a, SCM b), - "Divide two moments." - ) +int +Moment::print_smob (SCM port, scm_print_state *) { - 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"); + scm_puts ("#", port); - return (*ma / *mb).smobbed_copy(); + return 1; } -LY_DEFINE (ly_moment_less_p,"ly:moment