From 8e276d6b0caa7b3f1717f604bc49d4e47b9ac6bd Mon Sep 17 00:00:00 2001 From: fred Date: Sun, 24 Mar 2002 19:53:54 +0000 Subject: [PATCH] lilypond-0.1.8 --- flower/include/interval.hh | 38 +++++++++++++--------------- flower/include/interval.tcc | 50 +++++++++++++++++++++++++------------ flower/include/plist.tcc | 10 ++++---- lily/template2.cc | 2 +- lily/template3.cc | 4 +-- lily/template5.cc | 6 ++--- lily/template6.cc | 4 +-- lily/template7.cc | 4 +-- lily/template8.cc | 4 +-- 9 files changed, 69 insertions(+), 53 deletions(-) diff --git a/flower/include/interval.hh b/flower/include/interval.hh index bf4e4cc0e7..19d5061114 100644 --- a/flower/include/interval.hh +++ b/flower/include/interval.hh @@ -26,24 +26,24 @@ struct Interval_t { static T infinity() ; T center() { return (left + right) / T(2);} - void translate(T t) { + void translate (T t) { left += t; right += t; } - T& idx(int j) { + T& idx (int j) { if (j==-1) return left; else if (j==1) return right; else - assert(false); + assert (false); return left; } T& operator[](int j) { - return idx(j); + return idx (j); } T operator[](int j) const { - return ((Interval_t *)this)->idx(j); + return ((Interval_t *)this)->idx (j); } T &max() { return right;} T max()const { return right;} @@ -53,17 +53,17 @@ struct Interval_t { PRE *this and h are comparable */ - void unite(Interval_t h); - void intersect(Interval_t h); + void unite (Interval_t h); + void intersect (Interval_t h); T length() const; void set_empty() ; bool empty_b() const { return left > right; } - bool contains_b(Interval_t const&) const; + bool contains_b (Interval_t const&) const; Interval_t() { set_empty(); } - Interval_t(T m, T M) { + Interval_t (T m, T M) { left =m; right = M; } @@ -83,7 +83,7 @@ struct Interval_t { return *this; } String str() const; - bool elt_b(T r); + bool elt_b (T r); }; @@ -91,7 +91,7 @@ struct Interval_t { inclusion ordering. Crash if not comparable. */ template -int Interval__compare(const Interval_t&,Interval_t const&); +int Interval__compare (const Interval_t&,Interval_t const&); /* INLINE @@ -99,21 +99,21 @@ int Interval__compare(const Interval_t&,Interval_t const&); #include "compare.hh" -template_instantiate_compare(Interval_t&, Interval__compare, template); +TEMPLATE_INSTANTIATE_COMPARE(Interval_t&, Interval__compare, template); template inline Interval_t -intersection(Interval_t a, Interval_t const&b) +intersection (Interval_t a, Interval_t const&b) { - a.intersect(b); + a.intersect (b); return a; } template inline -Interval_t operator +(T a,Interval_t i ) +Interval_t operator +(T a,Interval_t i) { i += a; return i; @@ -121,13 +121,13 @@ Interval_t operator +(T a,Interval_t i ) template inline -Interval_t operator +(Interval_t i,T a ){ +Interval_t operator +(Interval_t i,T a){ return a+i; } template inline -Interval_t operator *(T a,Interval_t i ) +Interval_t operator *(T a,Interval_t i) { i *= a; return i; @@ -135,15 +135,13 @@ Interval_t operator *(T a,Interval_t i ) template inline -Interval_t operator *(Interval_t i,T a ){ +Interval_t operator *(Interval_t i,T a){ return a*i; } typedef Interval_t Interval; -#define Interval__instantiate(T) template struct Interval_t;\ - template int Interval__compare(const Interval_t&,Interval_t const&) #endif // INTERVAL_HH diff --git a/flower/include/interval.tcc b/flower/include/interval.tcc index ab2eb95ec3..efb7644133 100644 --- a/flower/include/interval.tcc +++ b/flower/include/interval.tcc @@ -1,3 +1,15 @@ +/* + interval.tcc -- implement Interval_t + + source file of the Flower Library + + (c) 1996,1997 Han-Wen Nienhuys +*/ + + +#ifndef INTERVAL_TCC +#define INTERVAL_TCC + #include #include #include "interval.hh" @@ -6,7 +18,7 @@ template int -_Interval__compare(const Interval_t&a,Interval_t const&b) +_Interval__compare (const Interval_t&a,Interval_t const&b) { if (a.left == b.left && a.right == b.right) return 0; @@ -22,9 +34,9 @@ _Interval__compare(const Interval_t&a,Interval_t const&b) template bool -Interval_t::contains_b(Interval_t const& a)const +Interval_t::contains_b (Interval_t const& a)const { - int c_i= _Interval__compare( *this, a); + int c_i= _Interval__compare (*this, a); if (c_i == -2) return false; return c_i >= 0; @@ -32,11 +44,11 @@ Interval_t::contains_b(Interval_t const& a)const template int -Interval__compare(const Interval_t&a,Interval_t const&b) +Interval__compare (const Interval_t&a,Interval_t const&b) { - int i = _Interval__compare(a,b); + int i = _Interval__compare (a,b); if (i < -1) - assert(false); + assert (false); return i; } @@ -51,13 +63,13 @@ Interval_t::set_empty() template T Interval_t::length() const { - assert(right >= left); + assert (right >= left); return right-left; } template void -Interval_t::unite(Interval_t h) +Interval_t::unite (Interval_t h) { if (h.left::unite(Interval_t h) template void -Interval_t::intersect(Interval_t h) +Interval_t::intersect (Interval_t h) { #if defined (__GNUG__) && ! defined (__STRICT_ANSI__) left = h.left >? left; right = h.right Interval_t -intersect(Interval_t x, Interval_t const &y) +intersect (Interval_t x, Interval_t const &y) { - x.intersect(y); + x.intersect (y); return x; } @@ -96,14 +108,20 @@ Interval_t::str() const { if (empty_b()) return "[empty]"; - String s("["); + String s ("["); - return s + String( left ) + String( "," ) + String( right ) + String( "]" ); + return s + String (left) + String ("," ) + String (right ) + String ("]" ); } template bool -Interval_t::elt_b(T r) +Interval_t::elt_b (T r) { return r >= left && r <= right; } + + +#define INTERVAL__INSTANTIATE(T) struct Interval_t;\ + template int Interval__compare(const Interval_t&,Interval_t const&) + +#endif // INTERVAL_TCC diff --git a/flower/include/plist.tcc b/flower/include/plist.tcc index ba4a0f20b0..f7733d508d 100644 --- a/flower/include/plist.tcc +++ b/flower/include/plist.tcc @@ -1,15 +1,15 @@ #include "plist.hh" -#define PL_instantiate(a) template class Link_list; \ +#define PL_INSTANTIATE(a) class Link_list; \ template class PCursor; -#define IPL_instantiate(a) PL_instantiate(a); \ +#define IPL_INSTANTIATE(a) PL_INSTANTIATE(a); \ template class Pointer_list template void Pointer_list::junk() { - PCursor c( *this ); + PCursor c (*this); while (c.ok()) { delete c.remove_p(); } @@ -17,9 +17,9 @@ Pointer_list::junk() template PCursor -Link_list::find(T what ) const +Link_list::find (T what) const { - PCursor i(*this); + PCursor i (*this); for (; i.ok(); i++) if (i.ptr() == what) break; diff --git a/lily/template2.cc b/lily/template2.cc index b09b378aee..67c24f5a58 100644 --- a/lily/template2.cc +++ b/lily/template2.cc @@ -10,4 +10,4 @@ #include "plist.tcc" #include "pcursor.tcc" -IPL_instantiate(Line_spacer); + template IPL_INSTANTIATE(Line_spacer); diff --git a/lily/template3.cc b/lily/template3.cc index 82d84d1965..2e368d5219 100644 --- a/lily/template3.cc +++ b/lily/template3.cc @@ -13,5 +13,5 @@ #include "plist.tcc" #include "pcursor.tcc" -IPL_instantiate(Atom); -IPL_instantiate(Input_translator); +template IPL_INSTANTIATE(Atom); +template IPL_INSTANTIATE(Input_translator); diff --git a/lily/template5.cc b/lily/template5.cc index e57925bf5b..bf7523d7d8 100644 --- a/lily/template5.cc +++ b/lily/template5.cc @@ -14,13 +14,13 @@ #include "interval.tcc" -Interval__instantiate(Rational); -Interval__instantiate(int); +template INTERVAL__INSTANTIATE(Rational); +template INTERVAL__INSTANTIATE(int); Rational Interval_t::infinity() { - return Rational(INT_MAX); + return Rational (INT_MAX); } int diff --git a/lily/template6.cc b/lily/template6.cc index 38344df600..e8f04f8122 100644 --- a/lily/template6.cc +++ b/lily/template6.cc @@ -3,5 +3,5 @@ #include "engraver.hh" #include "performer.hh" -IPL_instantiate(Engraver); -IPL_instantiate(Performer); +template IPL_INSTANTIATE(Engraver); +template IPL_INSTANTIATE(Performer); diff --git a/lily/template7.cc b/lily/template7.cc index 6a5bb7d83f..b36c232753 100644 --- a/lily/template7.cc +++ b/lily/template7.cc @@ -14,5 +14,5 @@ #include "music-list.hh" #include "music-iterator.hh" -IPL_instantiate(Music); -IPL_instantiate(Music_iterator); +template IPL_INSTANTIATE(Music); +template IPL_INSTANTIATE(Music_iterator); diff --git a/lily/template8.cc b/lily/template8.cc index de06b70477..de2fa8af8e 100644 --- a/lily/template8.cc +++ b/lily/template8.cc @@ -15,7 +15,7 @@ #include "plist.tcc" -IPL_instantiate(Audio_element); -IPL_instantiate(Audio_column); +template IPL_INSTANTIATE(Audio_element); +template IPL_INSTANTIATE(Audio_column); -- 2.39.5