source file of the GNU LilyPond music typesetter
- (c) 1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1999--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "lily-guile.hh"
#include "moment.hh"
#include "warn.hh"
+#include "ly-smobs.icc"
+
+IMPLEMENT_UNSMOB(Moment,moment);
+IMPLEMENT_SIMPLE_SMOBS(Moment);
+IMPLEMENT_TYPE_P (Moment, "moment?");
SCM
-Moment::mark_smob (SCM s)
+Moment::mark_smob (SCM)
{
return SCM_EOL;
}
-Moment::~Moment()
+SCM
+Moment::make_scm () const
{
- self_scm_ = SCM_EOL;
+ Moment * m = new Moment (*this);
+ return m->smobbed_self();
}
+
int
Moment::print_smob (SCM s, SCM port, scm_print_state *)
{
return 1;
}
-void
-Moment::do_smobify_self ()
-{}
-
SCM
make_rational (SCM n, SCM d)
{
+ Moment m (1,1);
+
if (SCM_INUMP (n) && SCM_INUMP(d))
{
- Moment *r = new Moment (gh_scm2int (n), gh_scm2int (d));
- return r->smobify_self ();
+ m = Moment (gh_scm2int (n), gh_scm2int (d));
}
else
{
- ::error ("Not a number");
- assert(false);
+ ::error ("make-moment takes two integer arguments. Using 1/1");
}
-}
-#include "ly-smobs.icc"
+ return m.make_scm ();
+}
-IMPLEMENT_SMOBS(Moment);
void
init_moments ()
{
- scm_make_gsubr ("make-moment", 2 , 0, 0, (SCM(*)(...)) make_rational);
+ scm_make_gsubr ("make-moment", 2 , 0, 0, (Scheme_function_unknown) make_rational);
+ scm_make_gsubr ("make-moment", 2 , 0, 0, (Scheme_function_unknown) make_rational);
}
ADD_SCM_INIT_FUNC(moms,init_moments);
SCM
Moment::equal_p (SCM a, SCM b)
{
- Moment *m1 = SMOB_TO_TYPE(Moment, a);
- Moment *m2 = SMOB_TO_TYPE(Moment, b);
+ Moment *m1 = unsmob_moment (a);
+ Moment *m2 = unsmob_moment (b);
return (*m1 == *m2) ? SCM_BOOL_T : SCM_BOOL_F;
}
+