2 moment.cc -- implement Moment
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
11 #include "lily-guile.hh"
14 #include "ly-smobs.icc"
16 IMPLEMENT_UNSMOB(Moment,moment);
17 IMPLEMENT_SIMPLE_SMOBS(Moment);
21 Moment::mark_smob (SCM)
28 Moment::make_scm () const
30 Moment * m = new Moment (*this);
31 return m->smobbed_self();
36 Moment::print_smob (SCM s, SCM port, scm_print_state *)
38 Moment *r = (Moment *) gh_cdr (s);
40 scm_puts ("#<Mom ", port);
42 scm_puts ((char *)str.ch_C(), port);
43 scm_puts (" >", port);
49 make_rational (SCM n, SCM d)
53 if (SCM_INUMP (n) && SCM_INUMP(d))
55 m = Moment (gh_scm2int (n), gh_scm2int (d));
59 ::error ("make-moment takes two integer arguments. Using 1/1");
69 scm_make_gsubr ("make-moment", 2 , 0, 0, (Scheme_function_unknown) make_rational);
72 ADD_SCM_INIT_FUNC(moms,init_moments);
75 Moment::equal_p (SCM a, SCM b)
77 Moment *m1 = unsmob_moment (a);
78 Moment *m2 = unsmob_moment (b);
80 return (*m1 == *m2) ? SCM_BOOL_T : SCM_BOOL_F;