]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.0.49
authorfred <fred>
Sun, 24 Mar 2002 19:38:23 +0000 (19:38 +0000)
committerfred <fred>
Sun, 24 Mar 2002 19:38:23 +0000 (19:38 +0000)
Documentation/CodingStyle.pod
lib/duration.cc
lib/include/duration.hh

index 5ce7a20e04bd83982c930ff5ed7d419fc8a5cdee..c1a9c7aed0981db668ecd76276027c59b2f65aba 100644 (file)
@@ -375,3 +375,5 @@ Variable foo: an C<Int*> that you must delete
 Variable bar: an C<Int*> that you must not delete
 
 =back
+
+Generally default arguments are taboo, except for nil pointers.
index 48e07059a13e61452038db89683b3c862736d2e0..0c95c66a37ea94b064e33d102a48956b83ce08af 100644 (file)
@@ -8,8 +8,6 @@
   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
 */
 
-// split into 4?
-
 #include "proto.hh"
 #include "plist.hh"
 #include "string.hh"
 #include "source.hh"
 #include "moment.hh"
 #include "duration.hh"
-#include "debug.hh"  //ugh
 #include "duration-convert.hh"
 
 // statics Duration
 int Duration::division_1_i_s = 384 * 4;
 
+bool
+Duration::duration_type_b(int t)
+{
+    int bit_i=0;
+    while (t > 0)
+    {
+       int rem = t % 2;
+       t /= 2;
+       bit_i += (rem == 1);
+    }
+    return bit_i == 1;
+}
+
 Duration::Duration( int type_i, int dots_i = 0)
 {
+    assert(duration_type_b(type_i));
        type_i_ = type_i;
        dots_i_ = dots_i;
        ticks_i_ = 0;
index de576e9884d78f275f2a7207e80ae0adff73acb6..c07dcefc6068eb728af76bff3b6231db1a6a2e6f 100644 (file)
@@ -36,15 +36,15 @@ struct Plet {
   (dur)
   */
 struct Duration {
-    /* actually i hate it when other people use default arguments,
-       because it makes you easily loose track of what-s really
-       happening; in the routine-s implementation you-re not aware
-       of this defaultness (who sets this stupid value?).*/
+    /**
+      Ctor of Duration. type_i should be a power of 2. 
+       */
     Duration( int type_i = 1, int dots_i = 0);
     /// is the "plet factor" of this note != 1 ?
     bool plet_b();
     String str()const;
     void set_plet(int,int );
+    static bool duration_type_b(int t);
     void set_ticks( int ticks_i );
     Moment length() const ;    // zo naai mij
     static int division_1_i_s;