lilypond-1.3.11
[lilypond.git] / lily / moment.cc
blob94d65eab45908f2c7505172309927af96bde03fb
1 /*
2 moment.cc -- implement Moment
4 source file of the GNU LilyPond music typesetter
6 (c) 1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 */
11 #include "lily-guile.hh"
12 #include "moment.hh"
13 #include "warn.hh"
15 SCM
16 Moment::mark_smob (SCM s)
18 return SCM_EOL;
22 Moment::~Moment()
24 self_scm_ = SCM_EOL;
27 int
28 Moment::print_smob (SCM s, SCM port, scm_print_state *)
30 Moment *r = (Moment *) SCM_CDR (s);
32 scm_puts ("#<Mom ", port);
33 String str(r->str());
34 scm_puts ((char *)str.ch_C(), port);
35 scm_puts (" >", port);
37 return 1;
40 void
41 Moment::do_smobify_self ()
44 SCM
45 make_rational (SCM n, SCM d)
47 if (SCM_INUMP (n) && SCM_INUMP(d))
49 Moment *r = new Moment (gh_scm2int (n), gh_scm2int (d));
50 return r->smobify_self ();
52 else
54 ::error ("Not a number");
55 assert(false);
59 #include "ly-smobs.icc"
61 IMPLEMENT_SMOBS(Moment);
63 void
64 init_moments ()
66 scm_make_gsubr ("make-moment", 2 , 0, 0, (SCM(*)(...)) make_rational);
69 ADD_SCM_INIT_FUNC(moms,init_moments);
71 SCM
72 Moment::equal_p (SCM a, SCM b)
74 Moment *m1 = SMOB_TO_TYPE(Moment, a);
75 Moment *m2 = SMOB_TO_TYPE(Moment, b);
77 return (*m1 == *m2) ? SCM_BOOL_T : SCM_BOOL_F;