]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/moment.cc
release commit
[lilypond.git] / lily / moment.cc
index f8e32be86fc1b0c67274f5594dd754e59da134b3..14afed0907bd50f64031dadcb8ab927ab0120112 100644 (file)
@@ -37,25 +37,25 @@ Moment::print_smob (SCM s, SCM port, scm_print_state *)
   Moment  *r = (Moment *) ly_cdr (s);
      
   scm_puts ("#<Mom ", port);
-  String str = r->string ();
+  String str = r->to_string ();
   scm_puts ((char *)str.to_str0 (), port);
-  scm_puts (" >", 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"
-)
+          "\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"
+          )
 {
   SCM_ASSERT_TYPE(SCM_INUMP (n), n, SCM_ARG1, __FUNCTION__, "integer");
   SCM_ASSERT_TYPE(SCM_INUMP (d), d, SCM_ARG2, __FUNCTION__, "integer");
@@ -65,7 +65,7 @@ LY_DEFINE (make_moment,"ly:make-moment", 2,0,0, (SCM n, SCM d),
 
 LY_DEFINE (add_moment,"ly:add-moment", 2,0,0, (SCM a, SCM b),
           "Add two moments."
-)
+          )
 {
   Moment * ma = unsmob_moment (a);
   Moment * mb = unsmob_moment (b);
@@ -78,7 +78,7 @@ LY_DEFINE (add_moment,"ly:add-moment", 2,0,0, (SCM a, SCM b),
 
 LY_DEFINE (mul_moment,"ly:mul-moment", 2,0,0, (SCM a, SCM b),
           "Multiply two moments."
-)
+          )
 {
   Moment * ma = unsmob_moment (a);
   Moment * mb = unsmob_moment (b);
@@ -92,7 +92,7 @@ LY_DEFINE (mul_moment,"ly:mul-moment", 2,0,0, (SCM a, SCM b),
 
 LY_DEFINE (div_moment,"ly:div-moment", 2,0,0, (SCM a, SCM b),
           "Divide two moments."
-)
+          )
 {
   Moment * ma = unsmob_moment (a);
   Moment * mb = unsmob_moment (b);
@@ -102,6 +102,17 @@ LY_DEFINE (div_moment,"ly:div-moment", 2,0,0, (SCM a, SCM b),
   return (*ma /  *mb).smobbed_copy();
 }
 
+LY_DEFINE (ly_moment_less_p,"ly:moment<?", 2,0,0, (SCM a, SCM b),
+          "Comparation.")
+{
+  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 gh_bool2scm (*ma <  *mb);
+}
+
 
 
 SCM
@@ -169,7 +180,7 @@ Moment::operator -= (Moment const &src)
 
 /*
   only take the main part of SRC for multiplication.
- */
+*/
 void
 Moment::operator *= (Moment const &src)
 {
@@ -179,7 +190,7 @@ Moment::operator *= (Moment const &src)
 
 /*
   only take the main part of SRC for multiplication.
- */
+*/
 void
 Moment::operator /= (Moment const &src)
 {
@@ -188,12 +199,6 @@ Moment::operator /= (Moment const &src)
 }
 
 
-#if 0
-Moment::operator Rational()
-{
-  return main_part_;
-}
-#endif
 
 int
 Moment::den () const { return main_part_.den (); }
@@ -215,12 +220,12 @@ Moment::set_infinite (int k)
 
 
 String
-Moment::string () const
+Moment::to_string () const
 {
-  String s =  main_part_.string ();
+  String s =  main_part_.to_string ();
   if (grace_part_)
     {
-      s += "G" + grace_part_.string ();
+      s += "G" + grace_part_.to_string ();
     }
   return s;
 }
@@ -239,7 +244,7 @@ Moment::operator - () const
 std::ostream &
 operator << (std::ostream &os, Moment const &m)
 {
-  os << m.string ();
+  os << m.to_string ();
   return os;
 }
 #endif