]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/moment.cc
release: 1.3.93
[lilypond.git] / lily / moment.cc
index 45002d8eed960afa0f791885a3d2f9632f1d3795..c3ebbf02c9028f252210701d462d6b7b4cf94e28 100644 (file)
@@ -3,7 +3,7 @@
   
   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);
+
 
 SCM
 Moment::mark_smob (SCM)
@@ -19,11 +24,14 @@ Moment::mark_smob (SCM)
 }
 
 
-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 *)
 {
@@ -37,40 +45,28 @@ 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 *r;
-  SCM retval = SCM_EOL;
+  Moment m (1,1);
+
   if (SCM_INUMP (n) && SCM_INUMP(d))
     {
-      r= new Moment (gh_scm2int (n), gh_scm2int (d));
+      m =  Moment (gh_scm2int (n), gh_scm2int (d));
     }
   else
     {
-      ::error ("make-moment takes two integer arguments.");
-      r = new Moment (1,1);
+      ::error ("make-moment takes two integer arguments. Using 1/1");
     }
 
-  retval = r->smobify_self ();
-  scm_unprotect_object (r->self_scm_);
-  return retval ;  
+  return m.make_scm ();
 }
 
-#include "ly-smobs.icc"
-
-IMPLEMENT_UNSMOB(Moment,moment);
-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);
 }
 
 ADD_SCM_INIT_FUNC(moms,init_moments);
@@ -78,8 +74,9 @@ 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;
 }
+