From 1c3d2fc2d0695d1885dd74aed1248f1fe5dfbf3c Mon Sep 17 00:00:00 2001 From: fred Date: Sun, 24 Mar 2002 19:38:23 +0000 Subject: [PATCH] lilypond-0.0.49 --- Documentation/CodingStyle.pod | 2 ++ lib/duration.cc | 17 ++++++++++++++--- lib/include/duration.hh | 8 ++++---- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/Documentation/CodingStyle.pod b/Documentation/CodingStyle.pod index 5ce7a20e04..c1a9c7aed0 100644 --- a/Documentation/CodingStyle.pod +++ b/Documentation/CodingStyle.pod @@ -375,3 +375,5 @@ Variable foo: an C that you must delete Variable bar: an C that you must not delete =back + +Generally default arguments are taboo, except for nil pointers. diff --git a/lib/duration.cc b/lib/duration.cc index 48e07059a1..0c95c66a37 100644 --- a/lib/duration.cc +++ b/lib/duration.cc @@ -8,8 +8,6 @@ (c) 1997 Han-Wen Nienhuys */ -// split into 4? - #include "proto.hh" #include "plist.hh" #include "string.hh" @@ -17,14 +15,27 @@ #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; diff --git a/lib/include/duration.hh b/lib/include/duration.hh index de576e9884..c07dcefc60 100644 --- a/lib/include/duration.hh +++ b/lib/include/duration.hh @@ -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; -- 2.39.5