]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-1.0.1
authorfred <fred>
Sun, 24 Mar 2002 20:12:12 +0000 (20:12 +0000)
committerfred <fred>
Sun, 24 Mar 2002 20:12:12 +0000 (20:12 +0000)
16 files changed:
flower/flower-debug.cc
flower/include/array.hh [new file with mode: 0644]
flower/include/array.icc [new file with mode: 0644]
flower/include/assoc.hh
flower/include/string-convert.hh
flower/include/unionfind.hh
flower/include/varray.icc
flower/include/vector.hh
input/test/clefs.ly
input/test/grace.ly [new file with mode: 0644]
input/test/sizes.fly [new file with mode: 0644]
lib/binary-source-file.cc
lib/warn.cc
lily/include/box.hh [new file with mode: 0644]
lily/include/tex-stream.hh
lily/note.cc

index f3131c8254f8f287dfa53df7c0ad5189515cc78d..bb001511c2dab053ba9384125afa2f3eca92a7e7 100644 (file)
@@ -14,7 +14,7 @@ void set_flower_debug (Dstream&ds, bool b)
 {
 #ifdef NPRINT
   if (b)
-    cout << _("Debug printout disabled.  Compiled with NPRINT.") << endl;
+    cout << _ ("Debug output disabled.  Compiled with NPRINT.") << endl;
 #endif
 
   flower_check_debug = b;
diff --git a/flower/include/array.hh b/flower/include/array.hh
new file mode 100644 (file)
index 0000000..c40e639
--- /dev/null
@@ -0,0 +1,235 @@
+/*
+  (c) Han-Wen Nienhuys 1995,96,97
+
+  Distributed under GNU GPL  
+*/
+
+#ifndef ARRAY_H
+#define ARRAY_H
+#include <assert.h>
+
+#ifndef INLINE
+#define INLINE inline
+#endif
+
+/// copy a bare (C-)array from #src# to #dest# sized  #count#
+template<class T> void arrcpy (T*dest, T*src, int count);
+
+/**
+  Scaleable array/stack template, for a type T with default constructor.
+  
+  
+  This template implements a scaleable vector. With (or without) range
+  checking. The type T should have a default constructor. It is
+  best suited for simple types, such as int, double or String, it
+  provides a paranoidly safe replacement for the new T[int] construct.
+
+  You should \bf{never} store pointers to objects in an Array (since
+  the array may be relocated without the pointer knowing it).
+  
+  It uses stack terminology, (push, pop, top), and  can be used as a stack.
+
+  
+  */
+template<class T>
+class Array
+{
+protected:
+  /// maximum length of array.
+  int max_;
+
+  /// the data itself
+  T *array_p_;
+
+  /// stretch or shrink  array.
+  void remax (int newmax) 
+    {   
+      T* newarr = new T[newmax];
+      size_ = (newmax < size_) ? newmax : size_;
+      arrcpy (newarr, array_p_, size_);
+       
+      delete[] array_p_;
+      array_p_ = newarr;
+      max_ = newmax;
+    }
+  int size_;
+
+public:
+  /// check invariants
+  void OK() const 
+    {
+      assert (max_ >= size_ && size_ >=0);
+      if (max_) assert (array_p_);
+    }
+  /** report the size_.
+      @see 
+      {setsize_}
+  */
+  int size() const  
+    { return size_; }
+    
+  /// POST: size() == 0
+    void clear() 
+    { size_ = 0; }
+
+  Array() 
+    { array_p_ = 0; max_ =0; size_ =0; }
+
+  // ugh, get around gcc 2.8.1 ice; see bezier.cc
+  Array (int i) 
+  { 
+    max_ = size_ = i; 
+    array_p_ = new T[i];
+  }
+
+
+  /** set the size_ to #s#.
+      POST: size() == s.
+      Warning: contents are unspecified */
+  void set_size (int s) 
+    {
+      if (s >= max_) remax (s);
+      size_ = s;    
+    }
+    
+  ~Array() 
+    { delete[] array_p_; }
+
+  /// return a  "new"ed copy of array 
+    T* copy_array() const 
+    {
+      T* Tarray = new T[size_];
+      arrcpy (Tarray, array_p_, size_);
+      return Tarray;
+    }
+  // depracated
+  operator T*() const 
+    {
+      return copy_array();     
+    }
+  void operator=(Array const & src) 
+    {
+      set_size (src.size_);
+      arrcpy (array_p_,src.array_p_, size_);
+    }
+  Array (Array const & src) 
+    {
+      array_p_ = src.copy_array();
+      max_ = size_ = src.size_;        
+    }
+
+  /// tighten array size_.
+    void precompute()     {
+      remax (size_);
+    }
+    
+  T * remove_array_p () {
+    T * p = array_p_;
+    size_ = 0;
+    max_ = 0;
+    array_p_ =0;
+    return p;
+  }
+
+  /// access element
+  T &operator[] (int i)  
+    {
+      return elem (i);
+    }
+  /// access element
+    T const & operator[] (int i) const 
+    {
+      return elem (i);
+    }
+  /// access element
+    T &elem (int i) const 
+    {
+      assert (i >=0&&i<size_);
+      return ((T*)array_p_)[i];        
+    }
+
+  /// add to the end of array
+    void push (T x) 
+    {
+      if (size_ == max_)
+       remax (2*max_ + 1);
+
+      // T::operator=(T &) is called here. Safe to use with automatic
+      // vars
+      array_p_[size_++] = x;
+    }
+  /// remove and return last entry 
+    T pop() 
+    {
+      assert (!empty());
+      T l = top (0);
+      set_size (size()-1);
+      return l;
+    }
+  /// access last entry
+    T& top (int j=0) 
+    {
+      return (*this)[size_-j-1];
+    }
+  /// return last entry
+    T top (int j=0) const 
+    {
+      return (*this)[size_-j-1];
+    }
+
+
+  void swap (int i,int j) 
+    {
+      T t ((*this)[i]);
+      (*this)[i]=(*this)[j];
+      (*this)[j]=t;
+    }
+  bool empty() const 
+    { return !size_; }
+
+  void insert (T k, int j);
+  /**
+     remove  i-th element, and return it.
+  */
+  T get (int i) 
+    {
+      T t = elem (i);
+      del (i);
+      return t;
+    }
+  void unordered_del (int i)
+    
+    {
+      elem (i) = top();
+      set_size (size() -1);
+    }
+  void del (int i) 
+    {
+      assert (i >=0&& i < size_);
+      arrcpy (array_p_+i, array_p_+i+1, size_-i-1);
+      size_--;
+    }
+  // quicksort.
+  void sort (int (*compare)(T const&,T const&),
+            int lower = -1, int upper = -1);
+  void concat (Array<T> const &src) 
+    {
+      int s = size_;
+      set_size (size_ + src.size_);
+      arrcpy (array_p_+s,src.array_p_, src.size_);     
+    }
+  Array<T> slice (int lower, int upper) 
+    {
+      assert (lower >= 0 && lower <=upper&& upper <= size_);
+      Array<T> r;
+      int s =upper-lower;
+      r.set_size (s);
+      arrcpy (r.array_p_, array_p_  + lower, s);
+      return r;
+    }
+  void reverse();
+};
+
+#include "array.icc"
+
+#endif
diff --git a/flower/include/array.icc b/flower/include/array.icc
new file mode 100644 (file)
index 0000000..0077a01
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+  (c) Han-Wen Nienhuys 1995,96,97,98
+
+  Distributed under GNU GPL
+*/
+
+
+#if 0
+#include "array.hh"
+#ifdef INLINE
+#undef INLINE
+#endif
+
+#define INLINE
+#endif
+
+/*
+ functions with loops don't inline
+ */
+
+template<class T> INLINE void 
+arrcpy (T*dest, T*src, int count)
+{
+  for (int i_shadows_local=0; i_shadows_local < count ; i_shadows_local++)
+    *dest++ = *src++;
+}
+
+template<class T> INLINE void
+Array<T>::insert (T k, int j) 
+{
+  assert (j >=0 && j<= size_);
+  set_size (size_+1);
+  for (int i=size_-1; i > j; i--)
+    array_p_[i] = array_p_[i-1];
+  array_p_[j] = k;
+}
+
+template<class T> INLINE void
+Array<T>::sort (int (*compare)(T const&,T const&),
+          int lower = -1, int upper = -1) 
+{
+  if (lower < 0) 
+    {
+      lower = 0 ;
+      upper = size () - 1;
+    }
+  if (lower >= upper)
+    return;
+  swap (lower, (lower+upper)/2);
+  int last = lower;
+  for (int i= lower +1; i <= upper; i++)
+    if (compare (array_p_[i], array_p_[lower]) < 0)
+      swap (++last,i);
+  swap (lower, last);
+  sort (compare, lower, last-1);
+  sort (compare, last+1, upper);
+}
+
+template<class T> INLINE void
+Array<T>::reverse () 
+{
+  int h = size_/2;
+  for (int i =0,j = size_-1; i < h; i++,j--)
+    swap (i,j);
+}
+
index f4558545a1e972d0a0bbab3bd4c176aa8834360c..3840b4bd5aa765f01902836ae8314a84b0d27d33 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef ASSOC_HH
 #define ASSOC_HH
 
-#include "varray.hh"
+#include "array.hh"
 #include <assert.h>
 
 /**
index 4842eac2d7add955f6844c9f923eba1755f8c396..3feba87bf271ab5c2810d40479b04425c72a2f15 100644 (file)
@@ -7,6 +7,7 @@
 #ifndef STRING_CONVERT_HH
 #define STRING_CONVERT_HH
 
+#include <stdarg.h>
 #include "fproto.hh"
 #include "string.hh"
 
@@ -18,6 +19,7 @@ class String_convert {
     static int hex2nibble_i (Byte byte);
     static Byte nibble2hex_byte (Byte byte);
 public:
+    static String bool_str (bool b);
     static String bin2dec_str (String bin_str);
     static String bin2hex_str (String bin_str);
     static String dec2bin_str (String str);
@@ -27,6 +29,8 @@ public:
     static int dec2_i (String dec_str);
     static double dec2_f (String dec_str);
     static String double_str (double f, char const* fmt=0);
+    static String form_str (char const* format, ...);
+    static String vform_str (char const* format, va_list args);
     static int hex2_i (String str);
     static unsigned hex2_u (String str);
     static String hex2bin_str (String str);
index 94a3e9f667bc73d22f3b62615adf6d451f7777ec..4f98d8801d157fd70faf6038a6eaaaf38c87655f 100644 (file)
@@ -1,6 +1,6 @@
 #ifndef UNIONFIND_HH
 #define UNIONFIND_HH
-#include "varray.hh"
+#include "array.hh"
 
 /*
     which points of a graph are connected?.
index 4d8ccb938717179da51ce14c5a02a8517b3c08a4..ae6b315fc88ff688fd56627fef7f46f16bc76ea6 100644 (file)
@@ -1,3 +1,4 @@
+#error
 /*
   (c) Han-Wen Nienhuys 1995,96,97,98
 
@@ -6,7 +7,7 @@
 
 
 #if 0
-#include "varray.hh"
+#include "array.hh"
 #ifdef INLINE
 #undef INLINE
 #endif
index 1d986c53b751c52c8e6ab2c94d6cb81a40f2c1ff..8b4d280cf5e940783692facc1198103b8a1d1e18 100644 (file)
@@ -3,7 +3,7 @@
 
 #include <math.h>
 #include "real.hh"
-#include "varray.hh"
+#include "array.hh"
 
 class Dstream;
 class String;
@@ -41,7 +41,8 @@ public:
        dat.insert (v,i);
     }
     void del (int i) { dat.del (i); }
-    operator String() const;
+
+    String str () const;
 
     void operator +=(Vector v) {
        assert (v.dim() == dim ());
index 3c14564347d60d111c36b00f2605e349957bf25c..a49133116b3844156075b2ea6e318d8e01881a92 100644 (file)
@@ -1,17 +1,17 @@
 \score {
-       \melodic{ \octave c'; 
-         \clef "violin"; c1^"{violin}" \bar "||";
-         \clef "french";c1^"{french}" \bar "||";
-         \clef "soprano";c1^"{soprano}" \bar "||";
-         \clef "mezzosoprano";c1^"{mezzosoprano}" \bar "||";
-         \clef "alto";c1^"{alto}" \bar "||";
-         \clef "tenor";c1^"{tenor}" \bar "||";
-         \clef "baritone";c1^"{baritone}" \bar "||";
-         \clef "varbaritone";c1^"{varbaritone}" \bar "||";
-         \clef "G_8";c1^"{sub 8?}" \bar "||";
-         \clef "G^8";c1^"{sup 8?}" \bar "|.";
-         \clef "bass";c1^"{bass}" \bar "||";
-         \clef "subbass";c1^"{subbass}" \bar "|.";
+       \melodic{ 
+         \clef "violin"; c'1^"{violin}" \bar "||";
+         \clef "french";c'1^"{french}" \bar "||";
+         \clef "soprano";c'1^"{soprano}" \bar "||";
+         \clef "mezzosoprano";c'1^"{mezzosoprano}" \bar "||";
+         \clef "alto";c'1^"{alto}" \bar "||";
+         \clef "tenor";c'1^"{tenor}" \bar "||";
+         \clef "baritone";c'1^"{baritone}" \bar "||";
+         \clef "varbaritone";c'1^"{varbaritone}" \bar "||";
+         \clef "G_8";c'1^"{sub 8?}" \bar "||";
+         \clef "G^8";c'1^"{sup 8?}" \bar "|.";
+         \clef "bass";c'1^"{bass}" \bar "||";
+         \clef "subbass";c'1^"{subbass}" \bar "|.";
          }
          \paper{
          }
diff --git a/input/test/grace.ly b/input/test/grace.ly
new file mode 100644 (file)
index 0000000..deec5f4
--- /dev/null
@@ -0,0 +1,27 @@
+
+\include "table13.ly";
+\include "table16.ly";
+
+\score{
+       <
+       \type Staff = a \melodic\relative c <
+%              {\grace b''8 \graceat a4 \ecarg g fis2 | a2 a }
+               {\tiny b''8*1/16 \normalsize a4*31/32 g fis2 | a2 a }
+       >
+       \type Staff = b \melodic\relative c <
+%              {\grace g''16 b16 \graceat a4 \ecarg g fis2 | }
+               {\tiny g''16*1/16 b16*1/16 \normalsize a4*31/32 g fis2 | a1 }
+       >
+       \type Staff = c \melodic\relative c <
+%              {\grace [2/48 g''16 b g]/1 \graceat a4 \ecarg g fis2 | a1 }
+               {\tiny [2/48 g''16 b g]/1 \normalsize a4*31/32 g fis2 | a1 }
+       >
+       >
+       \paper {
+               linewidth = 120.0\mm;
+               -2 = \symboltables { \table_thirteen }  
+               -1 = \symboltables { \table_sixteen }
+
+       }
+}
+
diff --git a/input/test/sizes.fly b/input/test/sizes.fly
new file mode 100644 (file)
index 0000000..0092336
--- /dev/null
@@ -0,0 +1,10 @@
+% to see the magic: uncomment size stuff in init/paper20.ly
+
+c'4 c4
+
+\property Voice.fontsize= "-2"
+b16 * 1 / 2 (
+\property Voice.fontsize= "0" )
+g4 *31/32
+
+a a g2
index 971d4d0c21dfc58d63bf9cc5bfda6608d7132ae3..9bcf0e5f70fa1ab4dffd161c8c12755534548494 100644 (file)
@@ -39,15 +39,15 @@ Binary_source_file::error_str (char const* pos_ch_c_l) const
     String pre_str ((Byte const*)begin_ch_c_l, pos_ch_c_l - begin_ch_c_l);
     pre_str = String_convert::bin2hex_str (pre_str);
     for (int i = 2; i < pre_str.length_i (); i += 3)
-       pre_str = pre_str.left_str (i) + " " + pre_str.cut (i, INT_MAX);
+       pre_str = pre_str.left_str (i) + " " + pre_str.cut_str (i, INT_MAX);
     String post_str ((Byte const*)pos_ch_c_l, end_ch_c_l - pos_ch_c_l);
     post_str = String_convert::bin2hex_str (post_str);
     for (int i = 2; i < post_str.length_i (); i += 3)
-       post_str = post_str.left_str (i) + " " + post_str.cut (i, INT_MAX);
+       post_str = post_str.left_str (i) + " " + post_str.cut_str (i, INT_MAX);
 
     String str = pre_str
-       + String ('\n')
-       + String (' ', pre_str.length_i () + 1) 
+       + to_str ('\n')
+       + to_str (' ', pre_str.length_i () + 1) 
        + post_str;
     return str;
 }
index afdbd97f4f6e33e4b39b140101cb78195b09e087..afc6f7b9ceef32314c8303f0b4fd139d44061c8d 100644 (file)
@@ -4,7 +4,7 @@
 void
 error (String s)
 {
-    cerr <<  _ ("error: ") << s << "\n";
+    cerr <<  _ ("error: ") << s << '\n';
 
     exit (1);
 }
@@ -12,7 +12,7 @@ error (String s)
 void
 non_fatal_error (String s)
 {
-    cerr <<  _ ("error: ") << s << "\n";
+    cerr <<  _ ("error: ") << s << '\n';
 }
 
 void
diff --git a/lily/include/box.hh b/lily/include/box.hh
new file mode 100644 (file)
index 0000000..b26c6e3
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+    some 2D geometrical concepts
+*/
+
+#ifndef BOXES_HH
+#define BOXES_HH
+
+#include "fproto.hh"
+#include "real.hh"
+#include "interval.hh"
+#include "offset.hh"
+#include "axes.hh"
+
+
+struct Box {
+  Interval interval_a_[NO_AXES];
+    
+  Interval &x() {return interval_a_[X_AXIS]; }
+  Interval &y(){ return interval_a_[Y_AXIS]; }
+  Interval x() const{ return interval_a_[X_AXIS]; }
+  Interval y() const{return interval_a_[Y_AXIS]; }
+  Interval operator[](Axis a) const;
+  Interval &operator[] (Axis a);
+    
+  void translate (Offset o);
+  /// smallest box enclosing #b#
+  void unite (Box b);
+  Box();
+  Box (Interval ix, Interval iy);
+};
+
+
+#endif
index e8011bb3ee7ade21bc723a8b3049b02140b5facc..e26c8328cb3edb102eba7a4e5158883d40630826 100644 (file)
@@ -22,8 +22,9 @@ public:
     /// open a file for writing
     Tex_stream (String filename);
     void header();
-    /// delegate conversion to string class.
-    Tex_stream &operator<<(String);
+
+    /// delegate conversion to scalar class
+    Tex_stream &operator <<(Scalar);
 
     /// close the file
     ~Tex_stream();
index 78e64294731e26f6cb536b580142b9a46beedb11..a32cabab79ce880fc0885d28cee951e35963818b 100644 (file)
@@ -11,7 +11,7 @@
 #include "command-request.hh"
 #include "music-list.hh"
 #include "identifier.hh"
-#include "varray.hh"
+#include "array.hh"
 #include "text-def.hh"
 #include "parseconstruct.hh"