From: Jan Nieuwenhuizen Date: Thu, 10 Mar 2005 14:36:16 +0000 (+0000) Subject: * flower X-Git-Tag: release/2.5.15~14 X-Git-Url: https://git.donarmstrong.com/lilypond.git?a=commitdiff_plain;h=58bcc84c9480dae1b21bc24d8396b91fe19e0131;p=lilypond.git * flower * lily * kpath-guile: Nitpick run: buildscripts/fixcc.py. --- diff --git a/ChangeLog b/ChangeLog index 54bef83301..d50507cb93 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-03-10 Jan Nieuwenhuizen + + * flower + * lily + * kpath-guile: Nitpick run: buildscripts/fixcc.py. + 2005-03-10 Han-Wen Nienhuys * lily/accidental.cc: special bboxes for natural. diff --git a/flower/cpu-timer.cc b/flower/cpu-timer.cc index 6789b5b0af..832606b701 100644 --- a/flower/cpu-timer.cc +++ b/flower/cpu-timer.cc @@ -12,9 +12,9 @@ // nextstep #ifndef CLOCKS_PER_SEC #ifdef CLK_TCK -#define CLOCKS_PER_SEC CLK_TCK +#define CLOCKS_PER_SEC CLK_TCK #elif defined _SC_CLK_TCK -#define CLOCKS_PER_SEC sysconf (_SC_CLK_TCK) +#define CLOCKS_PER_SEC sysconf (_SC_CLK_TCK) #else #error cannot determine CLOCKS_PER_SEC #endif @@ -34,5 +34,5 @@ Real Cpu_timer::read () { clock_t stop = clock (); - return (stop-start_clock_)/Real (CLOCKS_PER_SEC); + return (stop - start_clock_) / Real (CLOCKS_PER_SEC); } diff --git a/flower/direction.cc b/flower/direction.cc index fc543b51bb..71e700893e 100644 --- a/flower/direction.cc +++ b/flower/direction.cc @@ -1,11 +1,10 @@ -/* +/* direction.cc -- implement Direction - + source file of the GNU LilyPond music typesetter - + (c) 1998--2005 Han-Wen Nienhuys - - */ +*/ #include "direction.hh" @@ -17,11 +16,11 @@ direction_string (Direction d, Axis a) String s ("center"); if (a == Y_AXIS) { - s = ( d == UP ? "up" : "down"); + s = (d == UP ? "up" : "down"); } else if (a == X_AXIS) { - s = (d == LEFT ? "left" : "right" ); + s = (d == LEFT ? "left" : "right"); } return s; } diff --git a/flower/file-name.cc b/flower/file-name.cc index 7c93ee65ce..12a63ba694 100644 --- a/flower/file-name.cc +++ b/flower/file-name.cc @@ -1,10 +1,10 @@ /* file-name.cc - implement File_name - + source file of the Flower Library - + (c) 1997--2005 Han-Wen Nienhuys - Jan Nieuwenhuizen + Jan Nieuwenhuizen */ #include "file-name.hh" @@ -14,7 +14,7 @@ #include "config.hh" -#if HAVE_SYS_STAT_H +#if HAVE_SYS_STAT_H #include #endif @@ -63,7 +63,7 @@ File_name::to_string () const return s; } -char const* +char const * File_name::to_str0 () const { return to_string ().to_str0 (); diff --git a/flower/file-path.cc b/flower/file-path.cc index 88ccd59e17..07b278ce4a 100644 --- a/flower/file-path.cc +++ b/flower/file-path.cc @@ -1,10 +1,10 @@ /* file-path.cc - implement File_path - + source file of the Flower Library - + (c) 1997--2005 Han-Wen Nienhuys - Jan Nieuwenhuizen + Jan Nieuwenhuizen */ #include "file-path.hh" @@ -13,7 +13,7 @@ #include #include "config.hh" -#if HAVE_SYS_STAT_H +#if HAVE_SYS_STAT_H #include #endif @@ -48,18 +48,18 @@ File_path::parse_path (String p) } /** Find a file. - - Check absolute file name, search in the current dir (DUH! FIXME!), - in the construction-arg (what's that?), and in any other appended - directory, in this order. - @return - The file name if found, or empty string if not found. */ +Check absolute file name, search in the current dir (DUH! FIXME!), +in the construction-arg (what's that?), and in any other appended +directory, in this order. + +@return +The file name if found, or empty string if not found. */ String File_path::find (String name) const { - if (!name.length () || (name == "-") ) + if (!name.length () || (name == "-")) return name; /* Handle absolute file name. */ @@ -71,7 +71,7 @@ File_path::find (String name) const return name; } } - + for (int i = 0; i < size (); i++) { String file_name = elem (i); @@ -86,12 +86,12 @@ File_path::find (String name) const struct stat sbuf; if (stat (file_name.to_str0 (), &sbuf) != 0) continue; - + if (! (sbuf.st_mode & __S_IFREG)) continue; #endif #if !STAT_MACROS_BROKEN - + struct stat sbuf; if (stat (file_name.to_str0 (), &sbuf) != 0) continue; @@ -112,15 +112,15 @@ File_path::find (String name) const } /** Find a file. - - Seach in the current dir (DUH! FIXME?), in the construction-arg - (what's that?, and in any other appended directory, in this order. - Search for NAME, or name without extension, or name with any of - EXTENSIONS, in that order. +Seach in the current dir (DUH! FIXME?), in the construction-arg +(what's that?, and in any other appended directory, in this order. + +Search for NAME, or name without extension, or name with any of +EXTENSIONS, in that order. - @return - The file name if found, or empty string if not found. */ +@return +The file name if found, or empty string if not found. */ String File_path::find (String name, char const *extensions[]) { @@ -150,7 +150,7 @@ bool File_path::try_append (String s) { if (s == "") - s = "."; + s = "."; if (FILE *f = fopen (s.to_str0 (), "r")) { fclose (f); diff --git a/flower/getopt-long.cc b/flower/getopt-long.cc index 0cc117b9ae..e3850b153c 100644 --- a/flower/getopt-long.cc +++ b/flower/getopt-long.cc @@ -1,8 +1,8 @@ /* - process command line, GNU style. + process command line, GNU style. - this is Copyleft (c) 1996--2005 Han-Wen Nienhuys, - */ + this is Copyleft (c) 1996--2005 Han-Wen Nienhuys, +*/ #include "getopt-long.hh" @@ -16,10 +16,10 @@ #include "string-convert.hh" #if !HAVE_GETTEXT -inline char* -gettext (char const* s) +inline char * +gettext (char const *s) { - return (char*)s; + return (char *)s; } #else #include @@ -39,7 +39,7 @@ Getopt_long::get_argument_index () const Long_option_init * Getopt_long::parselong () { - char const *optnm = arg_value_char_a_a_[array_index_] + 2 ; + char const *optnm = arg_value_char_a_a_[array_index_] + 2; assert (*optnm); char const *endopt = strchr (optnm, '='); @@ -94,7 +94,7 @@ Long_option_init::to_string () const { String str; if (shortname_char_) - str += "-" + shortname_char_; + str += "-" + shortname_char_; if (shortname_char_ && longname_str0_) str += ", "; if (longname_str0_) @@ -122,7 +122,7 @@ Long_option_init::str_for_help () const s = s + "="; else s = s + " "; - + s = s + gettext (take_arg_str0_); } return s; @@ -142,41 +142,41 @@ Getopt_long::report (Errorcod c) { case E_ARGEXPECT: str += _f ("option `%s' requires an argument", - found_option_->to_string ()); + found_option_->to_string ()); break; - case E_NOARGEXPECT: + case E_NOARGEXPECT: str += _f ("option `%s' doesn't allow an argument", - found_option_->to_string ()); + found_option_->to_string ()); break; case E_UNKNOWNOPTION: str += _f ("unrecognized option: `%s'", - String (argument_index_ - ? String ("-" + String_convert::form_string ("%c", - arg_value_char_a_a_[array_index_][argument_index_])) - : String (arg_value_char_a_a_[array_index_]))); + String (argument_index_ + ? String ("-" + String_convert::form_string ("%c", + arg_value_char_a_a_[array_index_][argument_index_])) + : String (arg_value_char_a_a_[array_index_]))); break; case E_ILLEGALARG: str += _f ("invalid argument `%s' to option `%s'", - optional_argument_str0_, found_option_->to_string ()); + optional_argument_str0_, found_option_->to_string ()); break; default: assert (false); } - fprintf(error_out_, "%s\n", str.to_str0 ()); + fprintf (error_out_, "%s\n", str.to_str0 ()); exit (2); } const Long_option_init * Getopt_long::parseshort () { - char c=arg_value_char_a_a_[array_index_][argument_index_]; - found_option_=0; + char c = arg_value_char_a_a_[array_index_][argument_index_]; + found_option_ = 0; assert (c); - for (int i=0; i < table_len_; i++) + for (int i = 0; i < table_len_; i++) if (option_a_[i].shortname_char_ == c) { - found_option_ = option_a_+i; + found_option_ = option_a_ + i; break; } @@ -194,13 +194,13 @@ Getopt_long::parseshort () } optional_argument_str0_ = arg_value_char_a_a_[array_index_] + argument_index_; - array_index_ ++; + array_index_++; argument_index_ = 0; if (!optional_argument_str0_[0]) { optional_argument_str0_ = arg_value_char_a_a_[array_index_]; - array_index_ ++; + array_index_++; } if (!optional_argument_str0_) { @@ -211,7 +211,7 @@ Getopt_long::parseshort () } const Long_option_init * -Getopt_long::operator () () +Getopt_long::operator() () { if (!ok ()) return 0; @@ -223,7 +223,7 @@ Getopt_long::operator () () if (argument_index_) return parseshort (); - const char * argument = arg_value_char_a_a_[array_index_]; + const char *argument = arg_value_char_a_a_[array_index_]; if (argument[0] != '-') return 0; @@ -248,9 +248,7 @@ Getopt_long::operator () () } } - - -Getopt_long::Getopt_long (int c, char **v, Long_option_init *lo) +Getopt_long::Getopt_long (int c, char **v, Long_option_init *lo) { option_a_ = lo; error_out_ = stderr; @@ -261,15 +259,15 @@ Getopt_long::Getopt_long (int c, char **v, Long_option_init *lo) // reached end of option table? table_len_ =0; - for (int i = 0; option_a_[i].longname_str0_ ||option_a_[i].shortname_char_; i++) - table_len_ ++; + for (int i = 0; option_a_[i].longname_str0_ ||option_a_[i].shortname_char_; i++) + table_len_++; } bool Getopt_long::ok () const { - return array_index_ < argument_count_; + return array_index_ < argument_count_; } void @@ -289,46 +287,44 @@ Getopt_long::current_arg () { if (array_index_ >= argument_count_) return 0; - char const * a = arg_value_char_a_a_[array_index_]; + char const *a = arg_value_char_a_a_[array_index_]; return a + argument_index_; } char const * Getopt_long::get_next_arg () { - char const * a = current_arg (); + char const *a = current_arg (); if (a) { - array_index_ ++; + array_index_++; argument_index_= 0; } return a; } - const int EXTRA_SPACES = 5; String -Long_option_init::table_string (Long_option_init *l) +Long_option_init::table_string (Long_option_init *l) { String argstr = "ARG"; String tabstr = ""; int wid = 0; - for (int i=0; l[i].shortname_char_ || l[i].longname_str0_; i++) + for (int i = 0; l[i].shortname_char_ || l[i].longname_str0_; i++) { wid = wid >? l[i].str_for_help ().length (); } - for (int i=0; l[i].shortname_char_ || l[i].longname_str0_; i++) + for (int i = 0; l[i].shortname_char_ || l[i].longname_str0_; i++) { - String s = " " + l[i].str_for_help (); + String s = " " + l[i].str_for_help (); s += String_convert::char_string (' ', wid - s.length () + EXTRA_SPACES); tabstr += s + gettext (l[i].help_str0_) + "\n"; } - return tabstr; } @@ -348,6 +344,6 @@ Long_option_init::compare (Long_option_init const &a, Long_option_init const &b) char s[2] = {a.shortname_char_, 0}; return strcmp (s, b.longname_str0_); } - + return strcmp (a.longname_str0_, b.longname_str0_); } diff --git a/flower/include/arithmetic-operator.hh b/flower/include/arithmetic-operator.hh index 63318d9338..de07f21a1b 100644 --- a/flower/include/arithmetic-operator.hh +++ b/flower/include/arithmetic-operator.hh @@ -1,22 +1,21 @@ -/* - arithmetic-operator.hh -- declare - +/* + arithmetic-operator.hh -- declare + source file of the Flower Library - + (c) 1997--2005 Han-Wen Nienhuys - - */ +*/ #ifndef ARITHMETIC_OPERATOR_HH #define ARITHMETIC_OPERATOR_HH -#define IMPLEMENT_ARITHMETIC_OPERATOR(type, op) \ -inline type \ -operator op (type a1, type const& a2) \ -{ \ - a1 op ## = a2; \ - return a1; \ -} +#define IMPLEMENT_ARITHMETIC_OPERATOR(type, op) \ + inline type \ + operator op (type a1, type const &a2) \ + { \ + a1 op ## = a2; \ + return a1; \ + } #endif /* ARITHMETIC_OPERATOR_HH */ diff --git a/flower/include/array.hh b/flower/include/array.hh index e1b39fb58f..10b91ed97b 100644 --- a/flower/include/array.hh +++ b/flower/include/array.hh @@ -1,7 +1,7 @@ /* (c) 1995--2005 Han-Wen Nienhuys - Distributed under GNU GPL + Distributed under GNU GPL */ #ifndef ARRAY_H @@ -13,24 +13,22 @@ #endif /// copy a bare (C-)array from #src# to #dest# sized #count# -template void arrcpy (T*dest, T const*src, int count); +template void arrcpy (T *dest, T const *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. - - - */ + 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 Array { @@ -42,209 +40,209 @@ protected: T *array_; /// stretch or shrink array. - void remax (int newmax) - { - T* newarr = new T[newmax]; - size_ = (newmax < size_) ? newmax : size_; - arrcpy (newarr, array_, size_); - - delete[] array_; - array_ = newarr; - max_ = newmax; - } + void remax (int newmax) + { + T *newarr = new T[newmax]; + size_ = (newmax < size_) ? newmax : size_; + arrcpy (newarr, array_, size_); + + delete[] array_; + array_ = newarr; + max_ = newmax; + } int size_; public: /// check invariants - void OK () const ; + void OK () const; /** report the size_. - @see + @see {setsize_} */ - int size () const - { - return size_; - } - + int size () const + { + return size_; + } + /// POST: size () == 0 - void clear () - { - size_ = 0; - } + void clear () + { + size_ = 0; + } Array (T *tp, int n) - { - array_ = new T[n]; - max_ =size_ = n; - arrcpy (array_, tp, n); - } - - Array () - { array_ = 0; max_ =0; size_ =0; } + { + array_ = new T[n]; + max_ =size_ = n; + arrcpy (array_, tp, n); + } - // ugh, get around gcc 2.8.1 ice; see bezier.cc - Array (int i) - { - max_ = size_ = i; - array_ = new T[i]; - } + Array () + { array_ = 0; max_ =0; size_ =0; } + // ugh, get around gcc 2.8.1 ice; see bezier.cc + Array (int i) + { + max_ = size_ = i; + array_ = 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_; } + void set_size (int s) + { + if (s > max_) remax (s); + size_ = s; + } + + ~Array () + { delete[] array_; } /// return a "new"ed copy of array - T* copys () const - { - T* Tarray = new T[size_]; - arrcpy (Tarray, array_, size_); - return Tarray; - } + T *copys () const + { + T *Tarray = new T[size_]; + arrcpy (Tarray, array_, size_); + return Tarray; + } T const *accesses () const - { - return array_; - } - void operator= (Array const & src) - { - set_size (src.size_); - arrcpy (array_,src.array_, size_); - } - Array (Array const & src) - { - array_ = src.copys (); - max_ = size_ = src.size_; - } + { + return array_; + } + void operator= (Array const &src) + { + set_size (src.size_); + arrcpy (array_, src.array_, size_); + } + Array (Array const &src) + { + array_ = src.copys (); + max_ = size_ = src.size_; + } /// tighten array size_. - void tighten_maxsize () { + void tighten_maxsize () + { remax (size_); } - - T * remove_array (); + + T *remove_array (); /// access element - T &operator[] (int i) - { - return elem_ref (i); - } + T &operator[] (int i) + { + return elem_ref (i); + } /// access element - T const & operator[] (int i) const - { - return elem_ref (i); - } + T const &operator[] (int i) const + { + return elem_ref (i); + } /// access element - T &elem_ref (int i) const - { - assert (i >=0 && i < size_); - return ((T*)array_)[i]; - } + T &elem_ref (int i) const + { + assert (i >=0 && i < size_); + return ((T *)array_)[i]; + } /// access element - T elem (int i) const - { - return elem_ref (i); - } + T elem (int i) const + { + return elem_ref (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_[size_++] = x; - } + void push (T x) + { + if (size_ == max_) + remax (2*max_ + 1); + + // T::operator= (T &) is called here. Safe to use with automatic + // vars + array_[size_++] = x; + } /// remove and return last entry - T pop () - { - assert (!is_empty ()); - T l = top (0); - set_size (size ()-1); - return l; - } + T pop () + { + assert (!is_empty ()); + T l = top (0); + set_size (size () - 1); + return l; + } /// access last entry - T& top (int j=0) - { - return (*this)[size_-j-1]; - } + T &top (int j = 0) + { + return (*this)[size_ - j - 1]; + } /// return last entry - T top (int j=0) const - { - return (*this)[size_-j-1]; - } - - T& boundary (int dir, int idx) - { - assert (dir); - if (dir == 1) - return top (idx); - else - return elem_ref (idx); - } + T top (int j = 0) const + { + return (*this)[size_ - j - 1]; + } + + T &boundary (int dir, int idx) + { + assert (dir); + if (dir == 1) + return top (idx); + else + return elem_ref (idx); + } T boundary (int dir, int idx) const - { - assert (dir); - if (dir == 1) - return top (idx); - else - return elem (idx); - } - void swap (int i,int j) - { - T t ((*this)[i]); - (*this)[i]= (*this)[j]; - (*this)[j]=t; - } - bool is_empty () const - { return !size_; } + { + assert (dir); + if (dir == 1) + return top (idx); + else + return elem (idx); + } + void swap (int i, int j) + { + T t ((*this)[i]); + (*this)[i]= (*this)[j]; + (*this)[j] = t; + } + bool is_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; - } + T get (int i) + { + T t = elem (i); + del (i); + return t; + } void unordered_del (int i) - { - elem_ref (i) = top (); - set_size (size () -1); - } - void del (int i) - { - assert (i >=0&& i < size_); - arrcpy (array_+i, array_+i+1, size_-i-1); - size_--; - } + { + elem_ref (i) = top (); + set_size (size () -1); + } + void del (int i) + { + assert (i >=0&& i < size_); + arrcpy (array_ + i, array_ + i + 1, size_ - i - 1); + size_--; + } // quicksort. - void sort (int (*compare) (T const&,T const&), + void sort (int (*compare) (T const &, T const &), int lower = -1, int upper = -1); - void concat (Array const &src) - { - int s = size_; - set_size (size_ + src.size_); - arrcpy (array_+s,src.array_, src.size_); - } - Array slice (int lower, int upper) const; + void concat (Array const &src) + { + int s = size_; + set_size (size_ + src.size_); + arrcpy (array_ + s, src.array_, src.size_); + } + Array slice (int lower, int upper) const; void reverse (); }; template -int default_compare (T const&a , T const&b) +int default_compare (T const &a, T const &b) { if (a < b) return -1; diff --git a/flower/include/array.icc b/flower/include/array.icc index a84fe937e4..088a137252 100644 --- a/flower/include/array.icc +++ b/flower/include/array.icc @@ -4,7 +4,6 @@ Distributed under GNU GPL */ - #if 0 #include "array.hh" #ifdef INLINE @@ -15,65 +14,65 @@ #endif /* - functions with loops don't inline - */ + functions with loops don't inline +*/ -template INLINE void -arrcpy (T*dest, T const* src, int count) +template INLINE void +arrcpy (T *dest, T const *src, int count) { - for (int i_shadows_local=0; i_shadows_local < count ; i_shadows_local++) + for (int i_shadows_local = 0; i_shadows_local < count; i_shadows_local++) #ifdef __powerpc__ { /* urg: wierd egcs-1.1.2-12c (stock LinuxPPC R5) bug on ppc bug report filed fixed in egcs-1.1.2-12f - ftp://dev.linuxppc.org/users/fsirl/R5/RPMS/ppc/ + ftp://dev.linuxppc.org/users/fsirl/R5/RPMS/ppc/ */ *dest = *src; dest++, src++; } #else - *dest++ = *src++; + *dest++ = *src++; #endif } template INLINE void -Array::insert (T k, int j) +Array::insert (T k, int j) { assert (j >=0 && j<= size_); - set_size (size_+1); - for (int i=size_-1; i > j; i--) - array_[i] = array_[i-1]; + set_size (size_ + 1); + for (int i = size_ - 1; i > j; i--) + array_[i] = array_[i - 1]; array_[j] = k; } template INLINE void -Array::sort (int (*compare) (T const&,T const&), int lower, int upper) +Array::sort (int (*compare) (T const &, T const &), int lower, int upper) { - if (lower < 0) + if (lower < 0) { - lower = 0 ; + lower = 0; upper = size () - 1; } if (lower >= upper) return; - swap (lower, (lower+upper)/2); + swap (lower, (lower + upper) / 2); int last = lower; for (int i= lower +1; i <= upper; i++) if (compare (array_[i], array_[lower]) < 0) - swap (++last,i); + swap (++last, i); swap (lower, last); - sort (compare, lower, last-1); - sort (compare, last+1, upper); + sort (compare, lower, last - 1); + sort (compare, last + 1, upper); } template INLINE void -Array::reverse () +Array::reverse () { - int h = size_/2; - for (int i =0,j = size_-1; i < h; i++,j--) - swap (i,j); + int h = size_ / 2; + for (int i =0, j = size_ - 1; i < h; i++, j--) + swap (i, j); } template INLINE @@ -88,7 +87,7 @@ template INLINE T * Array::remove_array () { - T * p = array_; + T *p = array_; size_ = 0; max_ = 0; array_ =0; @@ -101,17 +100,16 @@ Array::slice (int lower, int upper) const { assert (lower >= 0 && lower <=upper&& upper <= size_); Array r; - int s =upper-lower; + int s =upper - lower; r.set_size (s); - arrcpy (r.array_, array_ + lower, s); + arrcpy (r.array_, array_ + lower, s); return r; } - template void binary_search_bounds (Array const &table, - T const &key, int (*compare) (T const&, T const &), + T const &key, int (*compare) (T const &, T const &), int *lo, int *hi) { @@ -120,30 +118,28 @@ binary_search_bounds (Array const &table, /* binary search */ do - { + { cmp = (*lo + *hi) / 2; - result = (*compare) (key, table[cmp]); + result = (*compare) (key, table[cmp]); if (result < 0) - *hi = cmp; + *hi = cmp; else - *lo = cmp; + *lo = cmp; } while (*hi - *lo > 1); } - /* lookup with binsearch, return array index. */ template int binary_search (Array const &table, - T const &key, int (*compare) (T const&, T const &), + T const &key, int (*compare) (T const &, T const &), int lo = 0, - int hi = -1 - ) + int hi = -1) { if (hi < 0) hi = table.size (); diff --git a/flower/include/axes.hh b/flower/include/axes.hh index f0f438af1f..3a1a7fc9dc 100644 --- a/flower/include/axes.hh +++ b/flower/include/axes.hh @@ -6,17 +6,17 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef AXES_HH #define AXES_HH #include -enum Axis { +enum Axis + { X_AXIS =0, Y_AXIS =1, - NO_AXES=2, -}; + NO_AXES = 2, + }; static inline Axis @@ -31,7 +31,7 @@ static inline Axis other_axis (Axis a) { - return a == Y_AXIS ? X_AXIS : Y_AXIS; + return a == Y_AXIS ? X_AXIS : Y_AXIS; } #endif // AXES_HH diff --git a/flower/include/compare.hh b/flower/include/compare.hh index d956c7157c..a9fde513a5 100644 --- a/flower/include/compare.hh +++ b/flower/include/compare.hh @@ -2,54 +2,50 @@ flowerlib (c) 1996--2005 Han-Wen Nienhuys - */ +*/ #ifndef COMPARE_HH #define COMPARE_HH -#define ONE_OPERATOR(type, function, op) \ -inline bool \ -operator op (type t1, type t2) {\ - return function (t1, t2) op 0;\ -}\ - -#define GPP_MINMAX_OPERATOR(type, op, opp) \ -inline type \ -operator op (type t1, type t2)\ -{\ - return (t1 opp t2) ? t1 : t2;\ -}\ +#define ONE_OPERATOR(type, function, op) \ + inline bool \ + operator op (type t1, type t2) \ + { \ + return function (t1, t2) op 0; \ + } +#define GPP_MINMAX_OPERATOR(type, op, opp) \ + inline type \ + operator op (type t1, type t2) \ + { \ + return (t1 opp t2) ? t1 : t2; \ + } #if defined (__GNUG__) && ! defined (__STRICT_ANSI__) -#define GPP_MINMAX(type, prefix)\ - prefix GPP_MINMAX_OPERATOR (type, ?, >) +#define GPP_MINMAX(type, prefix) \ + prefix GPP_MINMAX_OPERATOR (type, ?, >) #else -#define GPP_MINMAX(type, prefix) +#define GPP_MINMAX (type, prefix) #endif -/** handy notations for a signed comparison. - make the operators{<,<=,==,>=,>} and the MAX and MIN of two. - Please fill a & in the type argument if necessary. - */ -#define TEMPLATE_INSTANTIATE_COMPARE(type, function, prefix) \ -prefix ONE_OPERATOR (type, function, >)\ -prefix ONE_OPERATOR (type, function, >=)\ -prefix ONE_OPERATOR (type, function, ==)\ -prefix ONE_OPERATOR (type, function, !=)\ -prefix ONE_OPERATOR (type, function, <)\ -prefix ONE_OPERATOR (type, function, <=)\ -GPP_MINMAX (type, prefix)\ -prefix inline type max (type t1, type t2) { return (t1 > t2)? t1 : t2; }\ -prefix inline type min (type t1, type t2) { return (t1 < t2)? t1 : t2; }\ - \ -prefix bool operator< (type t1, type t2) /* stupid fix to allow ; */ - - - -#define INSTANTIATE_COMPARE(type, func) TEMPLATE_INSTANTIATE_COMPARE (type,func,) - - - +/** handy notations for a signed comparison. + make the operators{<,<=,==,>=,>} and the MAX and MIN of two. + Please fill a & in the type argument if necessary. +*/ +#define TEMPLATE_INSTANTIATE_COMPARE(type, function, prefix) \ + prefix ONE_OPERATOR (type, function, >) \ + prefix ONE_OPERATOR (type, function, >=) \ + prefix ONE_OPERATOR (type, function, ==) \ + prefix ONE_OPERATOR (type, function, !=) \ + prefix ONE_OPERATOR (type, function, <) \ + prefix ONE_OPERATOR (type, function, <=) \ + GPP_MINMAX (type, prefix) \ + prefix inline type max (type t1, type t2) { return (t1 > t2)? t1 : t2; } \ + prefix inline type min (type t1, type t2) { return (t1 < t2)? t1 : t2; } \ + \ + prefix bool operator< (type t1, type t2) /* stupid fix to allow ; */ + +#define INSTANTIATE_COMPARE(type, func) TEMPLATE_INSTANTIATE_COMPARE (type, func,) + #endif - + diff --git a/flower/include/cons.hh b/flower/include/cons.hh index a12c3f312e..3e6b64f1ab 100644 --- a/flower/include/cons.hh +++ b/flower/include/cons.hh @@ -1,38 +1,36 @@ -/* +/* cons.hh -- declare LISP like datatypes - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - - */ +*/ #ifndef CONS_HH #define CONS_HH - #include template class Cons { public: - T * car_; - Cons * next_; + T *car_; + Cons *next_; Cons () - { - car_=0; - next_ =0; - } - Cons (T*t, Cons*c) - { - car_ = t; - next_ = c; - } - virtual ~Cons () - { - delete next_; - } + { + car_ = 0; + next_ =0; + } + Cons (T *t, Cons*c) + { + car_ = t; + next_ = c; + } + virtual ~Cons () + { + delete next_; + } }; template @@ -40,13 +38,12 @@ class Killing_cons : public Cons { public: Killing_cons (T *t, Cons *p) - : Cons ( t,p) - { - } + : Cons (t, p) + { + } virtual ~Killing_cons (); }; - /// remove the link pointed to by *p. template Cons *remove_cons (Cons **pp) @@ -59,19 +56,16 @@ Cons *remove_cons (Cons **pp) template int cons_list_size (Cons *l) { - int i=0; + int i = 0; while (l) { l = l->next_; - i++; + i++; } return i; } - - - template Cons * last_cons (Cons * head) { @@ -84,12 +78,12 @@ Cons * last_cons (Cons * head) /** - Invariants: +Invariants: + +(*tail_) is either the head_ pointer, or a next_ pointer from the list. - (*tail_) is either the head_ pointer, or a next_ pointer from the list. - - **tail_ == NULL - */ +**tail_ == NULL +*/ template class Cons_list @@ -98,72 +92,71 @@ public: Cons * head_; Cons ** nil_pointer_address_; Cons_list () - { - init (); - } + { + init (); + } void init () - { - head_ =0; - nil_pointer_address_ = &head_; - } + { + head_ =0; + nil_pointer_address_ = &head_; + } void append (T *c) - { - append (new Cons (c,0)); - } + { + append (new Cons (c, 0)); + } void append (Cons *c) - { - assert (!c->next_); - *nil_pointer_address_ = c; - while (*nil_pointer_address_) - nil_pointer_address_ = & (*nil_pointer_address_)->next_; - } + { + assert (!c->next_); + *nil_pointer_address_ = c; + while (*nil_pointer_address_) + nil_pointer_address_ = &(*nil_pointer_address_)->next_; + } /** PRE: *pp should either be the head_ pointer, or the next_ pointer from a list cell. */ Cons *remove_cons (Cons **pp) - { - if (& (*pp)->next_ == nil_pointer_address_) - nil_pointer_address_ = pp; + { + if (& (*pp)->next_ == nil_pointer_address_) + nil_pointer_address_ = pp; - return ::remove_cons (pp); - } + return ::remove_cons (pp); + } /// junk everything after the first I elements. void truncate (int i) - { - Cons **p = &head_; - for (; *p && i; p = & ((*p)->next_)) - { - i--; - } - - if (*p) - { - delete *p; - *p = 0; - } - nil_pointer_address_ = p; - } + { + Cons **p = &head_; + for (; *p && i; p = &((*p)->next_)) + { + i--; + } + + if (*p) + { + delete *p; + *p = 0; + } + nil_pointer_address_ = p; + } void junk () - { - delete head_; - head_ =0; - } + { + delete head_; + head_ =0; + } ~Cons_list () - { - junk (); - } + { + junk (); + } int size () - { - return cons_list_size (head_); - } + { + return cons_list_size (head_); + } }; - template -void copy_killing_cons_list (Cons_list&, Cons *src); +void copy_killing_cons_list (Cons_list&, Cons *src); template void clone_killing_cons_list (Cons_list&, Cons *src); diff --git a/flower/include/cpu-timer.hh b/flower/include/cpu-timer.hh index 055b6aad04..47aae73f04 100644 --- a/flower/include/cpu-timer.hh +++ b/flower/include/cpu-timer.hh @@ -6,7 +6,6 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef CPU_TIMER_HH #define CPU_TIMER_HH @@ -14,7 +13,8 @@ #include "real.hh" -class Cpu_timer { +class Cpu_timer +{ clock_t start_clock_; public: Cpu_timer (); diff --git a/flower/include/direction.hh b/flower/include/direction.hh index 53d7249b03..6ff794be86 100644 --- a/flower/include/direction.hh +++ b/flower/include/direction.hh @@ -6,37 +6,36 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef DIRECTION_HH #define DIRECTION_HH #include "axes.hh" -enum Direction -{ - UP=1, - DOWN=-1, - LEFT=-1, - RIGHT=1, - MIN=-1, - MAX=1, - CENTER=0, - SMALLER=-1, - BIGGER=1, - START = -1, - STOP = 1, +enum Direction + { + UP = 1, + DOWN=-1, + LEFT=-1, + RIGHT = 1, + MIN=-1, + MAX = 1, + CENTER = 0, + SMALLER=-1, + BIGGER = 1, + START = -1, + STOP = 1, + + /* + This is necessary to safely write loops, + since - /* - This is necessary to safely write loops, - since - dir <= RIGHT - is otherwise transformed into true unconditionally. - */ - DIRECTION_LIMIT = 2, - DIRECTION_NEG_LIMIT = -2, -}; + is otherwise transformed into true unconditionally. + */ + DIRECTION_LIMIT = 2, + DIRECTION_NEG_LIMIT = -2, + }; inline Direction other_dir (Direction const d) @@ -45,17 +44,18 @@ other_dir (Direction const d) } inline Direction -operator - (Direction const d) +operator- (Direction const d) { return other_dir (d); } // huh? inline Direction -flip (Direction *i) { +flip (Direction *i) +{ if (*i == (Direction)1) - *i = (Direction)-1; - else if (*i == (Direction)-1) + *i = (Direction) - 1; + else if (*i == (Direction) - 1) *i = (Direction)1; return *i; } @@ -63,7 +63,7 @@ flip (Direction *i) { /** if d > 0: the max operator if d < 0: the min operator - */ +*/ template T minmax (Direction d, T, T); // String direction_string (Direction, Axis); diff --git a/flower/include/drul-array.hh b/flower/include/drul-array.hh index e6d8ee0eaf..f670a56286 100644 --- a/flower/include/drul-array.hh +++ b/flower/include/drul-array.hh @@ -6,7 +6,6 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef DRUL_ARRAY_HH #define DRUL_ARRAY_HH @@ -14,21 +13,21 @@ #include "real.hh" /** - Left/right or Up/down arrays. Drul is nicer sounding than udlr - */ + Left/right or Up/down arrays. Drul is nicer sounding than udlr +*/ template struct Drul_array { T array_[2]; T &elem_ref (Direction d) { - assert (d==1 || d== -1); - return array_[ (d+1)/2]; + assert (d == 1 || d== -1); + return array_[ (d + 1) / 2]; } T elem (Direction d) const { - assert (d==1 || d== -1); - return array_[ (d+1)/2]; + assert (d == 1 || d== -1); + return array_[ (d + 1) / 2]; } T &operator[] (Direction d) { diff --git a/flower/include/file-name.hh b/flower/include/file-name.hh index 44061fa2c2..be2268ec85 100644 --- a/flower/include/file-name.hh +++ b/flower/include/file-name.hh @@ -21,7 +21,7 @@ public: String ext_; File_name (String); - + String to_string () const; char const *to_str0 () const; }; diff --git a/flower/include/file-path.hh b/flower/include/file-path.hh index 5f5549cb19..f9d9f816cc 100644 --- a/flower/include/file-path.hh +++ b/flower/include/file-path.hh @@ -12,13 +12,13 @@ #include "array.hh" #include "string.hh" -/** - search in directories for a file. +/** + search in directories for a file. Abstraction of PATH variable. An interface for searching input files. Search a number of dirs for a file. - TODO: add a unix style PATH interface + TODO: add a unix style PATH interface */ class File_path : private Array diff --git a/flower/include/file-storage.hh b/flower/include/file-storage.hh index a4ac51fb33..425a61c3d7 100644 --- a/flower/include/file-storage.hh +++ b/flower/include/file-storage.hh @@ -6,21 +6,19 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef FILE_STORAGE_HH #define FILE_STORAGE_HH #include "flower-proto.hh" - /** - store a file in-memory. - */ + store a file in-memory. +*/ class File_storage { public: - virtual char const* to_str0 () const=0; - virtual int length () const=0; + virtual char const *to_str0 () const = 0; + virtual int length () const = 0; virtual ~File_storage (){} }; diff --git a/flower/include/flower-proto.hh b/flower/include/flower-proto.hh index a3a8b80eb2..68fa918527 100644 --- a/flower/include/flower-proto.hh +++ b/flower/include/flower-proto.hh @@ -8,14 +8,13 @@ #ifndef FPROTO_HH #define FPROTO_HH - -char const * flower_version_str0 (); +char const *flower_version_str0 (); template struct Link_array; template struct Array; -template struct Assoc; -template struct Hash_table; -template struct Hash_table_iter; +template < class T, class K> struct Assoc; +template < class K, class V> struct Hash_table; +template < class K, class V> struct Hash_table_iter; template struct Link_list; template struct Interval_t; template struct PQueue; @@ -58,7 +57,5 @@ struct File_storage; struct Mapped_file_storage; struct Simple_file_storage; - - #endif // FPROTO_HH diff --git a/flower/include/getopt-long.hh b/flower/include/getopt-long.hh index 8233114ed7..6d3598954d 100644 --- a/flower/include/getopt-long.hh +++ b/flower/include/getopt-long.hh @@ -8,56 +8,56 @@ /** a struct this for initialising the commandline options. */ -struct Long_option_init { - char const * take_arg_str0_; - char const * longname_str0_; +struct Long_option_init +{ + char const *take_arg_str0_; + char const *longname_str0_; /* = 0: don't take short version. */ char shortname_char_; - char const * help_str0_; - + char const *help_str0_; + String to_string () const; String str_for_help () const; // NO constructor! - static int compare (Long_option_init const&,Long_option_init const&); - static String table_string (Long_option_init *); + static int compare (Long_option_init const &, Long_option_init const &); + static String table_string (Long_option_init *); }; - /** C++ for version of long_getopt. For processing GNU style command - line arguments. No pointer (return values, arguments) contents are - copied. - - TODO: handle - command - , and command -- - - argument reordering - */ -class Getopt_long { + line arguments. No pointer (return values, arguments) contents are + copied. + + TODO: handle + command - , and command -- + + argument reordering +*/ +class Getopt_long +{ /// the option info. const Long_option_init *option_a_; int table_len_; - + /// if doing short option, arg_value_char_a_a_[optind][optindind] is processed next. int argument_index_; /// the option found const Long_option_init *found_option_; - -public: +public: /** errorcodes: no error, argument expected, no argument expected, - unknown option, illegal argument (eg. int expected). */ + unknown option, illegal argument (eg. int expected). */ enum Errorcod { E_NOERROR = 0, E_ARGEXPECT, E_NOARGEXPECT, E_UNKNOWNOPTION, - E_ILLEGALARG } ; + E_ILLEGALARG }; /// argument. Set to 0 if not present - char const * optional_argument_str0_; + char const *optional_argument_str0_; /// current error status Errorcod error_; @@ -84,30 +84,28 @@ public: /// report an error and abort void report (Errorcod c); - /// return an integer (with err. detect) long get_argument_index (); - - + /** - What to do with errors. - report messages on #*os#, and abort. - if #os# is null, then do not report nor abort, just set #error# - */ - + What to do with errors. + report messages on #*os#, and abort. + if #os# is null, then do not report nor abort, just set #error# + */ + void seterror (FILE *os); /// construct: pass arguments and option info. - Getopt_long (int c, char **v, Long_option_init *lo); + Getopt_long (int c, char **v, Long_option_init *lo); - /** get the next option. - @return pointer to next option found. - 0 if error occurred, or next argument is no option. - */ - const Long_option_init *operator () (); + /** get the next option. + @return pointer to next option found. + 0 if error occurred, or next argument is no option. + */ + const Long_option_init *operator() (); char const *current_arg (); - char const * get_next_arg (); + char const *get_next_arg (); }; #endif // GETOPT_LONG_HH diff --git a/flower/include/guile-compatibility.hh b/flower/include/guile-compatibility.hh index 78ec55575b..690db85d19 100644 --- a/flower/include/guile-compatibility.hh +++ b/flower/include/guile-compatibility.hh @@ -1,10 +1,9 @@ -/* +/* guile-compatibility.hh -- declare compat functions for GUILE 1.6 - + source file of the GNU LilyPond music typesetter - + (c) 2004--2005 Han-Wen Nienhuys - */ #ifndef GUILE_COMPATIBILITY_HH @@ -22,7 +21,7 @@ inline SCM scm_cdr (SCM x) inline SCM scm_car (SCM x) { if (SCM_NCONSP (x)) - abort (); + abort (); return SCM_CAR (x); } inline SCM scm_caar (SCM x) { return SCM_CAAR (x); } @@ -37,7 +36,7 @@ inline SCM scm_cadar (SCM x) { return SCM_CADAR (x); } #define scm_gc_register_collectable_memory(a, b, c) scm_done_malloc (b) #define scm_is_vector(x) (SCM_VECTORP ((SCM) x)) #define SCM_HASHTABLE_P(x) (SCM_VECTORP ((SCM) x)) -#define SCM_VECTOR_REF(v, i) (SCM_VELTS ((v))[(i)]) +#define SCM_VECTOR_REF(v, i) (SCM_VELTS ((v))[ (i)]) #define scm_from_bool(x) (x ? SCM_BOOL_T : SCM_BOOL_F) #define scm_from_int(x) SCM_MAKINUM (x) #define scm_from_unsigned_integer(x) scm_uint2num (x) @@ -54,7 +53,7 @@ inline int ly_scm2int (SCM x) { return scm_num2int (x, 0, "ly_scm2int"); } inline int ly_c_symbol_p (SCM x) { return SCM_SYMBOLP (x); } #define scm_is_symbol(x) ly_c_symbol_p (x) inline int ly_c_boolean_p (SCM x) { return SCM_BOOLP (x); } -#define scm_is_bool(x) ly_c_boolean_p(x) +#define scm_is_bool(x) ly_c_boolean_p (x) inline int ly_c_eq_p (SCM x, SCM y) { return SCM_EQ_P (x, y); } #define scm_is_eq(x, y) (SCM_EQ_P ((x), (y))) @@ -62,7 +61,7 @@ inline int ly_c_eq_p (SCM x, SCM y) { return SCM_EQ_P (x, y); } #define scm_is_pair(x) (SCM_CONSP (x)) #define scm_c_vector_length(x) SCM_VECTOR_LENGTH (x) -#define scm_c_vector_ref(x, y) SCM_VECTOR_REF(x, y) +#define scm_c_vector_ref(x, y) SCM_VECTOR_REF (x, y) inline double ly_scm2double (SCM x) { return scm_num2dbl (x, "ly_scm2double"); } #define scm_to_double(x) (ly_scm2double (x)) diff --git a/flower/include/international.hh b/flower/include/international.hh index 60fb4c2710..5d1d27f40e 100644 --- a/flower/include/international.hh +++ b/flower/include/international.hh @@ -1,35 +1,33 @@ -/* +/* international.hh -- declare stuff for internationalization - + source file of the GNU LilyPond music typesetter - + (c) 1997--2005 Jan Nieuwenhuizen - - */ +*/ #ifndef INTERNATIONAL_HH #define INTERNATIONAL_HH - /** - Internationalisation: _i ("to be translated") gets an entry in the POT file - gettext () must be invoked explicitely to do the actual "translation". - See flower/getopt-long.cc. - */ + Internationalisation: _i ("to be translated") gets an entry in the POT file + gettext () must be invoked explicitely to do the actual "translation". + See flower/getopt-long.cc. +*/ #define _i(sz) sz // don't inline: get warnings only once /** - Internationalisation: _ ("to be translated") gets "translated" by GNU gettext + Internationalisation: _ ("to be translated") gets "translated" by GNU gettext */ String _ (char const *ch); /** - Internationalisation: _f ("Usage: %s [FILE]", "lilypond") gets "translated" by - GNU gettext + Internationalisation: _f ("Usage: %s [FILE]", "lilypond") gets "translated" by + GNU gettext */ -String _f (char const* format, ...); -String _f (char const* format, String s, String s2 = "", String s3 = ""); +String _f (char const *format, ...); +String _f (char const *format, String s, String s2 = "", String s3 = ""); #endif // INTERNATIONAL_HH diff --git a/flower/include/interval-set.hh b/flower/include/interval-set.hh index fef00300e7..4c0ba0ac6a 100644 --- a/flower/include/interval-set.hh +++ b/flower/include/interval-set.hh @@ -1,10 +1,9 @@ -/* +/* interval-set.hh -- declare Interval_set - + source file of the GNU LilyPond music typesetter - + (c) 2004 Han-Wen Nienhuys - */ #ifndef INTERVAL_SET_HH @@ -19,7 +18,7 @@ Abysmal performance (quadratic) for large N, hopefully we don't have that large N. In any case, this should probably be rewritten to use a balanced tree. - */ +*/ struct Interval_set { Array allowed_regions_; diff --git a/flower/include/interval.hh b/flower/include/interval.hh index 97f1b1225a..3c319cf9d3 100644 --- a/flower/include/interval.hh +++ b/flower/include/interval.hh @@ -1,6 +1,6 @@ /* interval.hh -- part of flowerlib - + (c) 1996--2005 Han-Wen Nienhuys */ @@ -23,16 +23,16 @@ struct Interval_t : public Drul_array static String T_to_string (T arg); T center () const; void translate (T t) - { - elem_ref (LEFT) += t; - elem_ref (RIGHT) += t; - } + { + elem_ref (LEFT) += t; + elem_ref (RIGHT) += t; + } void widen (T t) { elem_ref (LEFT) -= t; - elem_ref (RIGHT) += t; + elem_ref (RIGHT) += t; } - + T distance (T t) const { if (t > elem (RIGHT)) @@ -43,15 +43,15 @@ struct Interval_t : public Drul_array return T (0); } /** - PRE - *this and h are comparable - */ + PRE + *this and h are comparable + */ void unite (Interval_t h); void intersect (Interval_t h); void add_point (T p) { - elem_ref(LEFT) = elem (LEFT) ? p; + elem_ref (LEFT) = elem (LEFT) ? p; } T length () const; T delta () const; @@ -60,36 +60,39 @@ struct Interval_t : public Drul_array /* TODO: strip hungarian suffix. - */ + */ bool is_empty () const { return elem (LEFT) > elem (RIGHT); } - bool superset (Interval_t const&) const; + bool superset (Interval_t const &) const; Interval_t () { set_empty (); } - Interval_t (T m, T M) : Drul_array (m,M) - { - } - Interval_t &operator -= (T r) { + Interval_t (T m, T M) : Drul_array (m, M) + { + } + Interval_t &operator-= (T r) + { *this += -r; return *this; } - Interval_t &operator += (T r) { + Interval_t &operator+= (T r) + { elem_ref (LEFT) += r; elem_ref (RIGHT) +=r; return *this; } - Interval_t &operator *= (T r) { + Interval_t &operator*= (T r) + { if (!is_empty ()) { elem_ref (LEFT) *= r; elem_ref (RIGHT) *= r; if (r < T (0)) - swap(); + swap (); } return *this; @@ -119,42 +122,39 @@ struct Interval_t : public Drul_array } }; - /** - inclusion ordering. Crash if not comparable. - */ + 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 &); /** Inclusion ordering. return -2 if not comparable - */ +*/ template int -_Interval__compare (const Interval_t&a,Interval_t const&b); - +_Interval__compare (const Interval_t&a, Interval_t const &b); /* INLINE - */ +*/ #include "compare.hh" 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); return a; - + } template inline -Interval_t operator + (T a,Interval_t i) +Interval_t operator+ (T a, Interval_t i) { i += a; return i; @@ -162,7 +162,7 @@ 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) { i += -a; return i; @@ -170,7 +170,7 @@ Interval_t operator - (Interval_t i, T a) template inline -Interval_t operator - (T a,Interval_t i) +Interval_t operator- (T a, Interval_t i) { i.negate (); i += a; @@ -179,13 +179,14 @@ Interval_t operator - (T a,Interval_t i) template inline -Interval_t operator + (Interval_t i,T a){ - return a+i; +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; @@ -193,11 +194,11 @@ 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 T Interval_t::center () const diff --git a/flower/include/interval.tcc b/flower/include/interval.tcc index 028ad5187e..b67f18165d 100644 --- a/flower/include/interval.tcc +++ b/flower/include/interval.tcc @@ -6,24 +6,22 @@ (c) 1996--2005 Han-Wen Nienhuys */ - #ifndef INTERVAL_TCC #define INTERVAL_TCC -#include +#include #include #include "interval.hh" #include "string.hh" - template int -_Interval__compare (const Interval_t&a,Interval_t const&b) +_Interval__compare (const Interval_t&a, Interval_t const &b) { if (a.elem (LEFT) == b.elem (LEFT) && a.elem (RIGHT) == b.elem (RIGHT)) return 0; - + if (a.elem (LEFT) <= b.elem (LEFT) && a.elem (RIGHT) >= b.elem (RIGHT)) return 1; @@ -34,8 +32,8 @@ _Interval__compare (const Interval_t&a,Interval_t const&b) } template -bool -Interval_t::superset (Interval_t const& a) const +bool +Interval_t::superset (Interval_t const &a) const { int c_i = _Interval__compare (*this, a); if (c_i == -2) @@ -45,9 +43,9 @@ Interval_t::superset (Interval_t const& a) const template int -Interval__compare (Interval_t const& a,Interval_t const& b) +Interval__compare (Interval_t const &a, Interval_t const &b) { - int i = _Interval__compare (a,b); + int i = _Interval__compare (a, b); if (i < -1) assert (false); return i; @@ -71,17 +69,17 @@ Interval_t::set_full () template T -Interval_t::length () const +Interval_t::length () const { - if (elem (RIGHT) <= elem (LEFT)) + if (elem (RIGHT) <= elem (LEFT)) return 0; - else + else return elem (RIGHT) - elem (LEFT); } template T -Interval_t::delta () const +Interval_t::delta () const { return elem (RIGHT) - elem (LEFT); } @@ -125,9 +123,9 @@ Interval_t::to_string () const if (is_empty ()) return "[empty]"; String s ("["); - - return (s + T_to_string (elem (LEFT)) + String ("," ) - + T_to_string (elem (RIGHT) ) + String ("]" )); + + return (s + T_to_string (elem (LEFT)) + String (",") + + T_to_string (elem (RIGHT)) + String ("]")); } template @@ -137,7 +135,7 @@ Interval_t::contains (T r) return r >= elem (LEFT) && r <= elem (RIGHT); } -#define INTERVAL__INSTANTIATE(T) struct Interval_t;\ -template int Interval__compare (const Interval_t&,Interval_t const&) +#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/killing-cons.tcc b/flower/include/killing-cons.tcc index 556d56deed..3ae9ce66ba 100644 --- a/flower/include/killing-cons.tcc +++ b/flower/include/killing-cons.tcc @@ -1,11 +1,10 @@ -/* +/* killing-cons.tcc -- declare Killing_cons - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - - */ +*/ #ifndef KILLING_CONS_TCC #define KILLING_CONS_TCC @@ -19,13 +18,13 @@ Killing_cons::~Killing_cons () } template -void -copy_killing_cons_list (Cons_list &dest, Cons *src) +void +copy_killing_cons_list (Cons_list &dest, Cons *src) { - for (; src; src = src->next_) + for (; src; src = src->next_) { T *t = new T (*src->car_); - dest.append ( new Killing_cons (t, 0)); + dest.append (new Killing_cons (t, 0)); } } @@ -33,10 +32,10 @@ template void clone_killing_cons_list (Cons_list & dest, Cons *src) { - for (; src; src = src->next_) + for (; src; src = src->next_) { T *t = src->car_->clone (); - dest.append (new Killing_cons (t, 0)); + dest.append (new Killing_cons (t, 0)); } } diff --git a/flower/include/libc-extension.hh b/flower/include/libc-extension.hh index 9978e237c3..a6b5cf8392 100644 --- a/flower/include/libc-extension.hh +++ b/flower/include/libc-extension.hh @@ -18,7 +18,7 @@ char *strnlwr (char *start, int n); char *strnupr (char *start, int n); #if ! HAVE_MEMMEM /* GNU extension. */ -void *memmem (void const* haystack, int haystack_len, +void *memmem (void const *haystack, int haystack_len, void const *needle, int needle_len); #endif /* HAVE_MEMMEM */ @@ -55,14 +55,15 @@ extern "C" { #if 1 //! HAVE_FUNOPEN -#define cookie_io_functions_t le_cookie_io_functions_t +#define cookie_io_functions_t le_cookie_io_functions_t typedef struct { ssize_t (*read) (void *, char *, size_t); ssize_t (*write) (void *, char const *, size_t); int (*seek) (void *, off64_t *, int); int (*close) (void *); - } cookie_io_functions_t; + } + cookie_io_functions_t; #else @@ -72,7 +73,8 @@ extern "C" { int (*write) (void *, char const *, int); fpos_t (*seek) (void *, fpos_t, int); int (*close) (void *); - } cookie_io_functions_t; + } + cookie_io_functions_t; #endif /* ! HAVE_FUNOPEN */ #endif /* ! HAVE_LIBIO_H */ @@ -86,9 +88,9 @@ extern "C" { int handle_cookie_io_fprintf (FILE *file, char const *format, ...); int handle_cookie_io_putc (int c, FILE *file); -/* FIXME: ttftool uses fclose fopencookie fprintf and putc only. if - ALIAS_FILE_TO_FILECOOKIE, blondly redefine those functions - to wrappers that check for and handle Memory_out_stream. */ + /* FIXME: ttftool uses fclose fopencookie fprintf and putc only. if + ALIAS_FILE_TO_FILECOOKIE, blondly redefine those functions + to wrappers that check for and handle Memory_out_stream. */ #ifdef ALIAS_FILE_TO_FILECOOKIE #define fclose handle_cookie_io_fclose diff --git a/flower/include/memory-stream.hh b/flower/include/memory-stream.hh index f01c5f4d43..12d2607a37 100644 --- a/flower/include/memory-stream.hh +++ b/flower/include/memory-stream.hh @@ -4,7 +4,6 @@ source file of the GNU LilyPond music typesetter (c) 2005 Han-Wen Nienhuys - */ #ifndef MEMORY_STREAM_HH diff --git a/flower/include/offset.hh b/flower/include/offset.hh index 98f400ed9d..a782eb0507 100644 --- a/flower/include/offset.hh +++ b/flower/include/offset.hh @@ -14,20 +14,17 @@ Offset complex_multiply (Offset, Offset); Offset complex_divide (Offset, Offset); Offset complex_exp (Offset); - /* - -This is a mixture a 2D vector. Sometimes it can -also be convenient to think of 2D vectors as complex numbers -(ie. x + i y). The naming of some methods reflects that. - + This is a mixture a 2D vector. Sometimes it can + also be convenient to think of 2D vectors as complex numbers + (ie. x + i y). The naming of some methods reflects that. */ -class Offset +class Offset { public: Real coordinate_a_[NO_AXES]; - - Real &operator[] (Axis i) + + Real &operator[] (Axis i) { return coordinate_a_[i]; } @@ -36,32 +33,32 @@ public: { return coordinate_a_[i]; } - - Offset& operator+= (Offset o) + + Offset &operator+= (Offset o) { (*this)[X_AXIS] += o[X_AXIS]; (*this)[Y_AXIS] += o[Y_AXIS]; return *this; } - Offset operator - () const + Offset operator- () const { Offset o = *this; - - o[X_AXIS] = - o[X_AXIS]; - o[Y_AXIS] = - o[Y_AXIS]; + + o[X_AXIS] = -o[X_AXIS]; + o[Y_AXIS] = -o[Y_AXIS]; return o; } - Offset& operator-= (Offset o) + Offset &operator-= (Offset o) { (*this)[X_AXIS] -= o[X_AXIS]; (*this)[Y_AXIS] -= o[Y_AXIS]; return *this; } - - Offset &scale (Offset o) + + Offset &scale (Offset o) { (*this)[X_AXIS] *= o[X_AXIS]; (*this)[Y_AXIS] *= o[Y_AXIS]; @@ -69,37 +66,37 @@ public: return *this; } - Offset &operator *= (Real a) + Offset &operator*= (Real a) { (*this)[X_AXIS] *= a; (*this)[Y_AXIS] *= a; return *this; } - - Offset (Real ix , Real iy) + + Offset (Real ix, Real iy) { coordinate_a_[X_AXIS] =ix; - coordinate_a_[Y_AXIS] =iy; + coordinate_a_[Y_AXIS] =iy; } - Offset () + Offset () { coordinate_a_[X_AXIS] = coordinate_a_[Y_AXIS]= 0.0; } String to_string () const; - Offset& mirror (Axis a) + Offset &mirror (Axis a) { - coordinate_a_[a] = - coordinate_a_[a]; + coordinate_a_[a] = -coordinate_a_[a]; return *this; } - + Real arg () const; Real length () const; - Offset operator *= (Offset z2) + Offset operator*= (Offset z2) { *this = complex_multiply (*this, z2); return *this; @@ -134,12 +131,10 @@ mirror (Offset o, Axis a) inline Real -dot_product (Offset o1, Offset o2) +dot_product (Offset o1, Offset o2) { return o1[X_AXIS] * o2[X_AXIS] + o1[Y_AXIS] * o2[Y_AXIS]; } - #endif /* OFFSET_HH */ - diff --git a/flower/include/parray.hh b/flower/include/parray.hh index bbaf1275ee..5467bf2573 100644 --- a/flower/include/parray.hh +++ b/flower/include/parray.hh @@ -6,133 +6,133 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef PARRAY_HH #define PARRAY_HH #include "array.hh" - - /** - an array of pointers. + an array of pointers. - TODO - should init to 0. - */ + TODO + should init to 0. +*/ template class Link_array : private Array { - Link_array (Array v) - :Array (v) - { - } + Link_array (Array v) + :Array (v) + { + } public: Link_array () - {} + {} - static int default_compare (T *const& p1, T *const&p2) + static int default_compare (T *const &p1, T *const &p2) { /* can't do p1 -p2, since T might be an incomplete type */ if (p1 < p2) - return -1 ; + return -1; if (p2 < p1) return 1; return 0; } - Link_array (T * const *tp, int n) - : Array ((void **)tp, n) - { - } + Link_array (T *const *tp, int n) + : Array ((void **)tp, n) + { + } Link_array (Link_array const &src) - : Array (src) - { - } + : Array (src) + { + } /// access element - T *elem (int i) const - { - return elem_ref (i); - } + T *elem (int i) const + { + return elem_ref (i); + } T *&elem_ref (int i) const - { - return (T*&) Array::elem_ref (i); - } + { + return (T *&) Array::elem_ref (i); + } /// access element - T* &operator[] (int i) - { - return (T*&) Array::elem_ref (i); - } + T *&operator[] (int i) + { + return (T *&) Array::elem_ref (i); + } /// access element - T *const operator[] (int i) const - { - return (T *const) Array::elem (i); - } + T *const operator[] (int i) const + { + return (T *const) Array::elem (i); + } T *pop () - { - return (T*) Array::pop (); - } + { + return (T *) Array::pop (); + } void insert (T *t, int i) - { - Array::insert (t, i); - } - void push (T* t) - { - Array::push (t); - } + { + Array::insert (t, i); + } + void push (T *t) + { + Array::push (t); + } /// return last entry - T* top (int j=0) const - { - return (T*) Array::top (j); - } - T *& top (int i=0) - { - return (T*&) Array::top (i); - } - void substitute (T *old, T*new_p) - { - int i; - while ((i = find_index (old)) >=0) - if (new_p) - elem_ref (i) =new_p; - else - del (i); - } - void unordered_substitute (T* old, T * new_p) - { - int i; - while ((i = find_index (old)) >=0) - if (new_p) - elem_ref (i) =new_p; - else { + T *top (int j = 0) const + { + return (T *) Array::top (j); + } + T *& top (int i = 0) + { + return (T *&) Array::top (i); + } + void substitute (T *old, T *new_p) + { + int i; + while ((i = find_index (old)) >=0) + if (new_p) + elem_ref (i) =new_p; + else + del (i); + } + void unordered_substitute (T *old, T *new_p) + { + int i; + while ((i = find_index (old)) >=0) + if (new_p) + elem_ref (i) =new_p; + else + { unordered_del (i); } - - } - void default_sort () { + + } + void default_sort () + { sort (default_compare); } // quicksort. - void sort (int (*compare) (T *const&,T *const&), + void sort (int (*compare) (T *const &, T *const &), int lower = -1, int upper = -1); - - void uniq () { + + void uniq () + { Link_array ls; - for (int i=0; i < size (); i++) - if (!i || elem (i-1) != elem (i)) - ls.push (elem (i)); + for (int i = 0; i < size (); i++) + if (!i || elem (i - 1) != elem (i)) + ls.push (elem (i)); *this = ls; } - Array::del; - Array::unordered_del; - Array::size; - Array::clear; - Array::set_size; - Array::is_empty; - Array::reverse; - Array::tighten_maxsize; + Array::del; + Array::unordered_del; + Array::size; + Array::clear; + Array::set_size; + Array::is_empty; + Array::reverse; + Array::tighten_maxsize; T *& boundary (int d, int i) { @@ -142,7 +142,7 @@ public: else return elem_ref (i); } - T * boundary (int d, int i)const + T *boundary (int d, int i)const { assert (d); if (d == 1) @@ -151,91 +151,87 @@ public: return elem_ref (i); } - T ** accesses () const - { - return (T**) Array::accesses (); - } - T * get (int i) - { - return (T*) Array::get (i); - } + { + return (T **) Array::accesses (); + } + T *get (int i) + { + return (T *) Array::get (i); + } Link_array - slice (int l,int u) - { - return Array::slice (l,u); - } + slice (int l, int u) + { + return Array::slice (l, u); + } void concat (Link_array const &a2) - { - Array::concat (a2); - } - int find_index (T const * t) const { - for (int i=0; i < size (); i++) + { + Array::concat (a2); + } + int find_index (T const *t) const + { + for (int i = 0; i < size (); i++) if (elem (i) == t) return i; return -1; } T *find (T const *t) const - { - int i = find_index (t); - if (i >= 0) - return elem (i); - else - return 0; - } + { + int i = find_index (t); + if (i >= 0) + return elem (i); + else + return 0; + } }; -template +template < class T, class V> Link_array -typecasts (Link_array const &a, T * /* dummy */ ) +typecasts (Link_array const &a, T * /* dummy */) { Link_array ret; - for (int i=a.size (); i-- ; ) - ret.push (dynamic_cast (a[i])); // ugh? + for (int i = a.size (); i--;) + ret.push (dynamic_cast (a[i])); // ugh? return ret; } - - template inline void -Link_array::sort (int (*compare)(T *const&,T *const&), int lower, int upper) +Link_array::sort (int (*compare) (T *const &, T *const &), int lower, int upper) { - if (lower < 0) + if (lower < 0) { - lower = 0 ; + lower = 0; upper = size () - 1; } if (lower >= upper) return; - swap (lower, (lower+upper)/2); + swap (lower, (lower + upper) / 2); int last = lower; for (int i= lower +1; i <= upper; i++) if (compare (elem (i), elem (lower)) < 0) - swap (++last,i); + swap (++last, i); swap (lower, last); - sort (compare, lower, last-1); - sort (compare, last+1, upper); + sort (compare, lower, last - 1); + sort (compare, last + 1, upper); } template void junk_pointers (Link_array &a) { - for (int i=0; i < a.size (); i++) + for (int i = 0; i < a.size (); i++) { delete a[i]; } a.clear (); } - - /* lookup with binsearch, return tokencode. */ template int -binsearch (Array const &arr, T t, int (*compare) (T const&,T const&)) +binsearch (Array const &arr, T t, int (*compare) (T const &, T const &)) { int lo; int hi; @@ -246,15 +242,15 @@ binsearch (Array const &arr, T t, int (*compare) (T const&,T const&)) /* binary search */ do - { + { cmp = (lo + hi) / 2; result = compare (t, arr[cmp]); if (result < 0) - hi = cmp; + hi = cmp; else - lo = cmp; + lo = cmp; } while (hi - lo > 1); if (!compare (t, arr[lo])) @@ -263,12 +259,11 @@ binsearch (Array const &arr, T t, int (*compare) (T const&,T const&)) return -1; /* not found */ } - template int binsearch_links (Link_array const &arr, T *t, - int (*compare) (T *const&,T *const&), - int lo = 0, int hi = -1 ) + int (*compare) (T *const &, T *const &), + int lo = 0, int hi = -1) { int cmp; int result; @@ -277,18 +272,18 @@ binsearch_links (Link_array const &arr, T *t, if (hi == 0) return -1; - + /* binary search */ do - { + { cmp = (lo + hi) / 2; result = (*compare) (t, arr[cmp]); if (result < 0) - hi = cmp; + hi = cmp; else - lo = cmp; + lo = cmp; } while (hi - lo > 1); if (!compare (t, arr[lo])) @@ -297,11 +292,10 @@ binsearch_links (Link_array const &arr, T *t, return -1; /* not found */ } - template void binary_search_bounds (Link_array const &table, - T const *key, int (*compare) (T * const& , T *const &), + T const *key, int (*compare) (T *const &, T *const &), int *lo, int *hi) { @@ -310,15 +304,15 @@ binary_search_bounds (Link_array const &table, /* binary search */ do - { + { cmp = (*lo + *hi) / 2; - result = (*compare) ((T*) key, table[cmp]); + result = (*compare) ((T *) key, table[cmp]); if (result < 0) - *hi = cmp; + *hi = cmp; else - *lo = cmp; + *lo = cmp; } while (*hi - *lo > 1); } diff --git a/flower/include/parse-afm.hh b/flower/include/parse-afm.hh index 3b2d30b577..534dba344e 100644 --- a/flower/include/parse-afm.hh +++ b/flower/include/parse-afm.hh @@ -7,20 +7,20 @@ * (C) 1988, 1989 by Adobe Systems Incorporated. All rights reserved. * * This file may be freely copied and redistributed as long as: - * 1) This entire notice continues to be included in the file, + * 1) This entire notice continues to be included in the file, * 2) If the file has been modified in any way, a notice of such * modification is conspicuously indicated. * * PostScript, Display PostScript, and Adobe are registered trademarks of * Adobe Systems Incorporated. - * + * * ************************************************************************ * THE INFORMATION BELOW IS FURNISHED AS IS, IS SUBJECT TO CHANGE WITHOUT * NOTICE, AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY ADOBE SYSTEMS - * INCORPORATED. ADOBE SYSTEMS INCORPORATED ASSUMES NO RESPONSIBILITY OR - * LIABILITY FOR ANY ERRORS OR INACCURACIES, MAKES NO WARRANTY OF ANY - * KIND (EXPRESS, IMPLIED OR STATUTORY) WITH RESPECT TO THIS INFORMATION, - * AND EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES OF MERCHANTABILITY, + * INCORPORATED. ADOBE SYSTEMS INCORPORATED ASSUMES NO RESPONSIBILITY OR + * LIABILITY FOR ANY ERRORS OR INACCURACIES, MAKES NO WARRANTY OF ANY + * KIND (EXPRESS, IMPLIED OR STATUTORY) WITH RESPECT TO THIS INFORMATION, + * AND EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES OF MERCHANTABILITY, * FITNESS FOR PARTICULAR PURPOSES AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. * ************************************************************************ */ @@ -31,23 +31,23 @@ * Together these files provide the functionality to parse Adobe Font * Metrics files and store the information in predefined data structures. * It is intended to work with an application program that needs font metric - * information. The program can be used as is by making a procedure call to + * information. The program can be used as is by making a procedure call to * parse an AFM file and have the data stored, or an application developer - * may wish to customize the code. + * may wish to customize the code. * - * This header file defines the data structures used as well as the key + * This header file defines the data structures used as well as the key * strings that are currently recognized by this version of the AFM parser. - * This program is based on the document "Adobe Font Metrics Files, + * This program is based on the document "Adobe Font Metrics Files, * Specification Version 2.0". * * AFM files are separated into distinct sections of different data. Because * of this, the parseAFM program can parse a specified file to only save - * certain sections of information based on the application's needs. A record + * certain sections of information based on the application's needs. A record * containing the requested information will be returned to the application. - * + * * AFM files are divided into five sections of data: * 1) The Global Font Information - * 2) The Character Metrics Information + * 2) The Character Metrics Information * 3) The Track Kerning Data * 4) The Pair-Wise Kerning Data * 5) The Composite Character Data @@ -56,22 +56,22 @@ * of what other sections are requested. In addition, in recognizing that * many applications will want ONLY the x-width of characters and not all * of the other character metrics information, there is a way to receive - * only the width information so as not to pay the storage cost for the - * unwanted data. An application should never request both the - * "quick and dirty" char metrics (widths only) and the Character Metrics - * Information since the Character Metrics Information will contain all + * only the width information so as not to pay the storage cost for the + * unwanted data. An application should never request both the + * "quick and dirty" char metrics (widths only) and the Character Metrics + * Information since the Character Metrics Information will contain all * of the character widths as well. - * - * There is a procedure in parseAFM.c, called parseFile, that can be + * + * There is a procedure in parseAFM.c, called parseFile, that can be * called from any application wishing to get information from the AFM File. * This procedure expects 3 parameters: a vaild file descriptor, a pointer - * to a (FontInfo *) variable (for which space will be allocated and then + * to a (FontInfo *) variable (for which space will be allocated and then * will be filled in with the data requested), and a mask specifying * which data from the AFM File should be saved in the FontInfo structure. - * + * * The flags that can be used to set the appropriate mask are defined below. - * In addition, several commonly used masks have already been defined. - * + * In addition, several commonly used masks have already been defined. + * * History: * original: DSM Thu Oct 20 17:39:59 PDT 1988 * modified: DSM Mon Jul 3 14:17:50 PDT 1989 @@ -84,21 +84,19 @@ #define BOOL int #define FLAGS int - - /* Possible return codes from the parseFile procedure. - * + * * ok means there were no problems parsing the file. * * parseError means that there was some kind of parsing error, but the * parser went on. This could include problems like the count for any given * section does not add up to how many entries there actually were, or * there was a key that was not recognized. The return record may contain - * vaild data or it may not. + * vaild data or it may not. * * earlyEOF means that an End of File was encountered before expected. This * may mean that the AFM file had been truncated, or improperly formed. - * + * * storageProblem means that there were problems allocating storage for * the data structures that would have contained the AFM data. */ @@ -107,153 +105,150 @@ #define AFM_earlyEOF -2 #define AFM_storageProblem -3 - - /************************* TYPES *********************************/ /* Below are all of the data structure definitions. These structures - * try to map as closely as possible to grouping and naming of data + * try to map as closely as possible to grouping and naming of data * in the AFM Files. */ - -/* Bounding box definition. Used for the Font AFM_BBox as well as the +/* Bounding box definition. Used for the Font AFM_BBox as well as the * Character AFM_BBox. */ typedef struct -{ - int llx; /* lower left x-position */ - int lly; /* lower left y-position */ - int urx; /* upper right x-position */ - int ury; /* upper right y-position */ -} AFM_BBox; - +{ + int llx; /* lower left x-position */ + int lly; /* lower left y-position */ + int urx; /* upper right x-position */ + int ury; /* upper right y-position */ +} + AFM_BBox; /* Global Font information. - * The key that each field is associated with is in comments. For an + * The key that each field is associated with is in comments. For an * explanation about each key and its value please refer to the AFM - * documentation (full title & version given above). + * documentation (full title & version given above). */ typedef struct -{ - char *afmVersion; /* key: StartFontMetrics */ - char *fontName; /* key: FontName */ - char *fullName; /* key: FullName */ - char *familyName; /* key: FamilyName */ - char *weight; /* key: Weight */ - float italicAngle; /* key: ItalicAngle */ - BOOL isFixedPitch; /* key: IsFixedPitch */ - AFM_BBox fontBBox; /* key: FontBBox */ - int underlinePosition; /* key: UnderlinePosition */ - int underlineThickness; /* key: UnderlineThickness */ - char *version; /* key: Version */ - char *notice; /* key: Notice */ - char *encodingScheme; /* key: EncodingScheme */ - int capHeight; /* key: CapHeight */ - int xHeight; /* key: XHeight */ - int ascender; /* key: Ascender */ - int descender; /* key: Descender */ -} AFM_GlobalFontInfo; - +{ + char *afmVersion; /* key: StartFontMetrics */ + char *fontName; /* key: FontName */ + char *fullName; /* key: FullName */ + char *familyName; /* key: FamilyName */ + char *weight; /* key: Weight */ + float italicAngle; /* key: ItalicAngle */ + BOOL isFixedPitch; /* key: IsFixedPitch */ + AFM_BBox fontBBox; /* key: FontBBox */ + int underlinePosition; /* key: UnderlinePosition */ + int underlineThickness; /* key: UnderlineThickness */ + char *version; /* key: Version */ + char *notice; /* key: Notice */ + char *encodingScheme; /* key: EncodingScheme */ + int capHeight; /* key: CapHeight */ + int xHeight; /* key: XHeight */ + int ascender; /* key: Ascender */ + int descender; /* key: Descender */ +} + AFM_GlobalFontInfo; /* Ligature definition is a linked list since any character can have * any number of ligatures. */ typedef struct _t_ligature { - char *succ, *lig; - struct _t_ligature *next; -} AFM_Ligature; - + char *succ, *lig; + struct _t_ligature *next; +} + AFM_Ligature; -/* Character Metric Information. This structure is used only if ALL +/* Character Metric Information. This structure is used only if ALL * character metric information is requested. If only the character * widths is requested, then only an array of the character x-widths * is returned. * - * The key that each field is associated with is in comments. For an - * explanation about each key and its value please refer to the + * The key that each field is associated with is in comments. For an + * explanation about each key and its value please refer to the * Character Metrics section of the AFM documentation (full title - * & version given above). + * & version given above). */ typedef struct { - int code, /* key: C */ - wx, /* key: WX */ - wy; /* together wx and wy are associated with key: W */ - char *name; /* key: N */ - AFM_BBox charBBox; /* key: B */ - AFM_Ligature *ligs; /* key: L (linked list; not a fixed number of Ls */ -} AFM_CharMetricInfo; - + int code, /* key: C */ + wx, /* key: WX */ + wy; /* together wx and wy are associated with key: W */ + char *name; /* key: N */ + AFM_BBox charBBox; /* key: B */ + AFM_Ligature *ligs; /* key: L (linked list; not a fixed number of Ls */ +} + AFM_CharMetricInfo; /* Track kerning data structure. - * The fields of this record are the five values associated with every + * The fields of this record are the five values associated with every * TrackKern entry. - * - * For an explanation about each value please refer to the + * + * For an explanation about each value please refer to the * Track Kerning section of the AFM documentation (full title - * & version given above). + * & version given above). */ -typedef struct +typedef struct { - int degree; - float minPtSize, - minKernAmt, - maxPtSize, - maxKernAmt; -} AFM_TrackKernData; - + int degree; + float minPtSize, + minKernAmt, + maxPtSize, + maxKernAmt; +} + AFM_TrackKernData; /* Pair Kerning data structure. * The fields of this record are the four values associated with every * KP entry. For KPX entries, the yamt will be zero. * - * For an explanation about each value please refer to the + * For an explanation about each value please refer to the * Pair Kerning section of the AFM documentation (full title - * & version given above). + * & version given above). */ -typedef struct +typedef struct { - char *name1; - char *name2; - int xamt, - yamt; -} AFM_PairKernData; - + char *name1; + char *name2; + int xamt, + yamt; +} + AFM_PairKernData; /* AFM_Pcc is a piece of a composite character. This is a sub structure of a * AFM_CompCharData described below. * These fields will be filled in with the values from the key AFM_Pcc. - * - * For an explanation about each key and its value please refer to the + * + * For an explanation about each key and its value please refer to the * Composite Character section of the AFM documentation (full title - * & version given above). + * & version given above). */ typedef struct { - char *AFM_PccName; - int deltax, - deltay; -} AFM_Pcc; + char *AFM_PccName; + int deltax, + deltay; +} + AFM_Pcc; - -/* Composite Character Information data structure. +/* Composite Character Information data structure. * The fields ccName and numOfPieces are filled with the values associated * with the key CC. The field pieces points to an array (size = numOfPieces) * of information about each of the parts of the composite character. That * array is filled in with the values from the key AFM_Pcc. - * - * For an explanation about each key and its value please refer to the + * + * For an explanation about each key and its value please refer to the * Composite Character section of the AFM documentation (full title - * & version given above). + * & version given above). */ typedef struct { - char *ccName; - int numOfPieces; - AFM_Pcc *pieces; -} AFM_CompCharData; - + char *ccName; + int numOfPieces; + AFM_Pcc *pieces; +} + AFM_CompCharData; /* FontInfo * Record type containing pointers to all of the other data @@ -262,19 +257,19 @@ typedef struct * parseFile function. */ typedef struct -{ - AFM_GlobalFontInfo *gfi; /* ptr to a AFM_GlobalFontInfo record */ - int *cwi; /* ptr to 256 element array of just char widths */ - int numOfChars; /* number of entries in char metrics array */ - AFM_CharMetricInfo *cmi; /* ptr to char metrics array */ - int numOfTracks; /* number to entries in track kerning array */ - AFM_TrackKernData *tkd; /* ptr to track kerning array */ - int numOfPairs; /* number to entries in pair kerning array */ - AFM_PairKernData *pkd; /* ptr to pair kerning array */ - int numOfComps; /* number to entries in comp char array */ - AFM_CompCharData *ccd; /* ptr to comp char array */ -} AFM_Font_info; - +{ + AFM_GlobalFontInfo *gfi; /* ptr to a AFM_GlobalFontInfo record */ + int *cwi; /* ptr to 256 element array of just char widths */ + int numOfChars; /* number of entries in char metrics array */ + AFM_CharMetricInfo *cmi; /* ptr to char metrics array */ + int numOfTracks; /* number to entries in track kerning array */ + AFM_TrackKernData *tkd; /* ptr to track kerning array */ + int numOfPairs; /* number to entries in pair kerning array */ + AFM_PairKernData *pkd; /* ptr to pair kerning array */ + int numOfComps; /* number to entries in comp char array */ + AFM_CompCharData *ccd; /* ptr to comp char array */ +} + AFM_Font_info; /************************* PROCEDURES ****************************/ @@ -283,7 +278,7 @@ typedef struct * * "fp" should be a valid file pointer to an AFM file. * - * "fi" is a pointer to a pointer to a FontInfo record sturcture + * "fi" is a pointer to a pointer to a FontInfo record sturcture * (defined above). Storage for the FontInfo structure will be * allocated in parseFile and the structure will be filled in * with the requested data from the AFM File. diff --git a/flower/include/polynomial.hh b/flower/include/polynomial.hh index 1422f9d63d..ec61d47103 100644 --- a/flower/include/polynomial.hh +++ b/flower/include/polynomial.hh @@ -19,20 +19,20 @@ struct Polynomial int degree ()const; /// coefficients - Array coefs_; + Array coefs_; // leading coef Real &lc (); // leading coef Real lc () const; - void print () const ; - Real eval (Real) const ; - void print_sols (Array) const ; - void check_sols (Array) const ; + void print () const; + Real eval (Real) const; + void print_sols (Array) const; + void check_sols (Array) const; void check_sol (Real x) const; - static Polynomial multiply (const Polynomial & p1, const Polynomial & p2); - static Polynomial power (int exponent, const Polynomial & src); + static Polynomial multiply (const Polynomial &p1, const Polynomial &p2); + static Polynomial power (int exponent, const Polynomial &src); /// chop low coefficients void clean (); @@ -40,15 +40,15 @@ struct Polynomial /// eliminate #x# close to zero void real_clean (); void scalarmultiply (Real fact); - void operator *= (Real f) { scalarmultiply (f); } - void operator /= (Real f) { scalarmultiply (1/f); } - void operator += (Polynomial const &p2); - void operator *= (Polynomial const &p2); - void operator -= (Polynomial const &p2); + void operator*= (Real f) { scalarmultiply (f); } + void operator/= (Real f) { scalarmultiply (1 / f); } + void operator+= (Polynomial const &p2); + void operator*= (Polynomial const &p2); + void operator-= (Polynomial const &p2); Polynomial (Real a, Real b =0.0); Polynomial (){} - void set_negate (const Polynomial & src); - + void set_negate (const Polynomial &src); + /// take the derivative void differentiate (); int set_mod (const Polynomial &u, const Polynomial &v); @@ -62,19 +62,18 @@ struct Polynomial Array solve () const; }; - -IMPLEMENT_ARITHMETIC_OPERATOR (Polynomial, - ); -IMPLEMENT_ARITHMETIC_OPERATOR (Polynomial, + ); -IMPLEMENT_ARITHMETIC_OPERATOR (Polynomial, * ); +IMPLEMENT_ARITHMETIC_OPERATOR (Polynomial, -); +IMPLEMENT_ARITHMETIC_OPERATOR (Polynomial, +); +IMPLEMENT_ARITHMETIC_OPERATOR (Polynomial, *); inline Polynomial -operator * (Polynomial p, Real a) +operator* (Polynomial p, Real a) { p *=a; return p; } inline Polynomial -operator * (Real a,Polynomial p) +operator* (Real a, Polynomial p) { p *=a; return p; diff --git a/flower/include/pqueue.hh b/flower/include/pqueue.hh index d7a8375fcb..c80dae2131 100644 --- a/flower/include/pqueue.hh +++ b/flower/include/pqueue.hh @@ -6,104 +6,115 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef PQUEUE_HH #define PQUEUE_HH #include "array.hh" - -template +template < class K, class T> struct PQueue_ent { - T val; - K key; + T val; + K key; }; -template -int compare (PQueue_ent const &e1 , PQueue_ent const &e2) { - return compare (e1.key , e2.key); +template < class K, class T> +int compare (PQueue_ent < K, T> const &e1, PQueue_ent < K, T> const &e2) +{ + return compare (e1.key, e2.key); } /** - Priority queue using a (variable size) in-situ heap. + Priority queue using a (variable size) in-situ heap. - Hungarian postfix pq - - TODO: add increase/decrease operations, - add max () operation - */ + Hungarian postfix pq + + TODO: add increase/decrease operations, + add max () operation +*/ template -class PQueue { - Array heap_array_; - T &elt (int i) { - return heap_array_[i-1]; - } - T const&elt (int i) const { - return heap_array_[i-1]; - } +class PQueue +{ + Array heap_array_; + T &elt (int i) + { + return heap_array_[i - 1]; + } + T const &elt (int i) const + { + return heap_array_[i - 1]; + } public: - /** acces an heap element. Careful with this, as changing the + /** acces an heap element. Careful with this, as changing the priority might fuck up the invariants @param 1 <= i < size () */ - T& operator[] (int i) { return heap_array_[i]; } - T operator[] (int i) const { return heap_array_[i]; } - void OK () const - { + T &operator[] (int i) { return heap_array_[i]; } + T operator[] (int i) const { return heap_array_[i]; } + void OK () const + { #ifndef NDEBUG - for (int i =2; i <= size (); i++) - assert (compare (elt (i/2), elt (i)) <= 0); + for (int i =2; i <= size (); i++) + assert (compare (elt (i / 2), elt (i)) <= 0); #endif - } - T front () const { return elt (1); } - int size () const { return heap_array_.size (); } - void insert (T v) { - heap_array_.push (v); - int i = heap_array_.size (); - int j = i / 2 ; - while (j) { - if (compare (elt (j), v) > 0) { - elt (i) = elt (j); - i = j; - j = i/2; - } else { - break; - } - } - elt (i) = v; - OK (); - } - T max () const { - //int first_leaf_i = size (); - T max_t; - return max_t; - } - void delmin () { - assert (size ()); - T last = heap_array_.top (); - - int mini=2; - int lasti=1; + } + T front () const { return elt (1); } + int size () const { return heap_array_.size (); } + void insert (T v) + { + heap_array_.push (v); + int i = heap_array_.size (); + int j = i / 2; + while (j) + { + if (compare (elt (j), v) > 0) + { + elt (i) = elt (j); + i = j; + j = i / 2; + } + else - while (mini < size ()) { - if (compare (elt (mini + 1), elt (mini)) <0) - mini++; - if (compare (last,elt (mini)) < 0) - break; - elt (lasti) = elt (mini); - lasti = mini; - mini *= 2; - } - elt (lasti) = last; - heap_array_.pop (); - OK (); - } - T get () { - T t = front (); - delmin (); - return t; - } -}; + { + break; + } + } + elt (i) = v; + OK (); + } + T max () const + { + //int first_leaf_i = size (); + T max_t; + return max_t; + } + void delmin () + { + assert (size ()); + T last = heap_array_.top (); + int mini = 2; + int lasti = 1; + + while (mini < size ()) + { + if (compare (elt (mini + 1), elt (mini)) <0) + mini++; + if (compare (last, elt (mini)) < 0) + break; + elt (lasti) = elt (mini); + lasti = mini; + mini *= 2; + } + elt (lasti) = last; + heap_array_.pop (); + OK (); + } + T get () + { + T t = front (); + delmin (); + return t; + } +}; #endif // PQUEUE_HH diff --git a/flower/include/rational.hh b/flower/include/rational.hh index 8ac80fb124..a0973e2d58 100644 --- a/flower/include/rational.hh +++ b/flower/include/rational.hh @@ -6,7 +6,6 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef RATIONAL_HH #define RATIONAL_HH @@ -14,8 +13,9 @@ /** Rational numbers. Included is support for + and - infinity. - */ -class Rational { +*/ +class Rational +{ /** Sign of rational. -2, .. 2 @@ -23,7 +23,7 @@ class Rational { -2,2 is - and + infinity. -1,1 is negative and positive. 0 if *this is zero. - */ + */ int sign_; unsigned int num_, den_; void normalise (); @@ -35,8 +35,8 @@ public: void invert (); int numerator () const { return sign_ * num_; } int denominator () const { return den_; } - int num () const { return numerator(); } - int den () const { return denominator(); } + int num () const { return numerator (); } + int den () const { return denominator (); } Rational trunc_rat () const; Rational div_rat (Rational) const; @@ -45,42 +45,43 @@ public: // operator bool () const; int to_int () const; operator double () const; - Rational operator - () const; + Rational operator- () const; /** - Initialize to 0. - */ + Initialize to 0. + */ Rational (); Rational (int); Rational (int, int); Rational (double); - Rational (Rational const&r) { copy (r);} - Rational &operator = (Rational const &r) { + Rational (Rational const &r) { copy (r);} + Rational &operator= (Rational const &r) + { copy (r); return *this; } - Rational &operator *= (Rational); - Rational &operator /= (Rational); - Rational &operator += (Rational); - Rational &operator -= (Rational); - Rational &operator %= (Rational); - static int compare (Rational const&, Rational const&); + Rational &operator*= (Rational); + Rational &operator/= (Rational); + Rational &operator+= (Rational); + Rational &operator-= (Rational); + Rational &operator%= (Rational); + static int compare (Rational const &, Rational const &); int sign () const; String to_string () const; }; -IMPLEMENT_ARITHMETIC_OPERATOR (Rational, / ); -IMPLEMENT_ARITHMETIC_OPERATOR (Rational, + ); -IMPLEMENT_ARITHMETIC_OPERATOR (Rational, * ); -IMPLEMENT_ARITHMETIC_OPERATOR (Rational, - ); -IMPLEMENT_ARITHMETIC_OPERATOR (Rational, % ); +IMPLEMENT_ARITHMETIC_OPERATOR (Rational, /); +IMPLEMENT_ARITHMETIC_OPERATOR (Rational, +); +IMPLEMENT_ARITHMETIC_OPERATOR (Rational, *); +IMPLEMENT_ARITHMETIC_OPERATOR (Rational, -); +IMPLEMENT_ARITHMETIC_OPERATOR (Rational, %); -INSTANTIATE_COMPARE (Rational const&, Rational::compare); +INSTANTIATE_COMPARE (Rational const &, Rational::compare); -int compare (Rational const&,Rational const&); +int compare (Rational const &, Rational const &); int sign (Rational r); inline void -Rational::copy (Rational const&r) +Rational::copy (Rational const &r) { sign_ = r.sign_; num_ = r.num_; @@ -89,7 +90,7 @@ Rational::copy (Rational const&r) #if 0 ostream & -operator << (ostream &, Rational); +operator<< (ostream &, Rational); #endif const Rational infinity_rat = INT_MAX; diff --git a/flower/include/real.hh b/flower/include/real.hh index ce7a0e0a85..43a35179a6 100644 --- a/flower/include/real.hh +++ b/flower/include/real.hh @@ -6,11 +6,9 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef REAL_HH #define REAL_HH - #include typedef double Real; @@ -38,16 +36,15 @@ template inline T sqr (T x) return x*x; } - template inline T min (T x, T y) { return x split (String str, char c); - static String i64_string (I64, char const * fmt = 0); + static String i64_string (I64, char const *fmt = 0); }; #endif // __STRING_CONVERT_HH // diff --git a/flower/include/string-data.hh b/flower/include/string-data.hh index 4cb3bbc317..378432f3ee 100644 --- a/flower/include/string-data.hh +++ b/flower/include/string-data.hh @@ -6,7 +6,6 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef STRINGDATA_HH #define STRINGDATA_HH @@ -14,76 +13,75 @@ /**Internal String struct. the data itself. Handles simple tasks (resizing, resetting) - */ -class String_data { - // GNU malloc: storage overhead is 8 bytes anyway. - -friend class String_handle; - int maxlen; // maxlen is arraysize-1 - - int length_; - Byte* data_byte_; - int ref_count_; - - /// init to "" - String_data (); - - /// init from src. Conservative allocation. - String_data (String_data const &src); - - ~String_data (); - - /** POST: maxlen >= j. - @param j, maximum stringlength_. +*/ +class String_data +{ + // GNU malloc: storage overhead is 8 bytes anyway. + + friend class String_handle; + int maxlen; // maxlen is arraysize-1 + + int length_; + Byte *data_byte_; + int ref_count_; + + /// init to "" + String_data (); + + /// init from src. Conservative allocation. + String_data (String_data const &src); + + ~String_data (); + + /** POST: maxlen >= j. + @param j, maximum stringlength_. contents thrown away. - */ - void setmax (int j); - - /** POST: maxlen >= j. + */ + void setmax (int j); + + /** POST: maxlen >= j. @param j, maximum stringlength_. contents are kept if it grows. - */ - void remax (int j); + */ + void remax (int j); + + /// check if writeable. + void OKW (); - /// check if writeable. - void OKW (); + /// check state. + void OK (); - /// check state. - void OK (); + /// reduce memory usage. + void tighten (); - /// reduce memory usage. - void tighten (); + // assignment. + void set (Byte const *byte, int length_i); - // assignment. - void set (Byte const* byte, int length_i); + void set (char const *str0); - void set (char const* str0); - - /// concatenation. - void append (Byte const* byte, int length_i); + /// concatenation. + void append (Byte const *byte, int length_i); - void operator += (char const* str0); + void operator+= (char const *str0); - char const* to_str0 () const; + char const *to_str0 () const; - char* get_str0 (); + char *get_str0 (); - Byte const* to_bytes () const; + Byte const *to_bytes () const; - // idem, non const - Byte* get_bytes (); + // idem, non const + Byte *get_bytes (); - void trunc (int j); + void trunc (int j); - /** access element. not really safe. Can alter length_ without + /** access element. not really safe. Can alter length_ without #String_data# knowing it. */ - Byte &operator [] (int j); - Byte operator [] (int j) const; - bool is_binary_bo () const; + Byte &operator[] (int j); + Byte operator[] (int j) const; + bool is_binary_bo () const; }; - - #ifdef STRING_UTILS_INLINED #ifndef INLINE #define INLINE inline @@ -92,5 +90,4 @@ friend class String_handle; #endif - #endif // STRING_DATA_HH diff --git a/flower/include/string-data.icc b/flower/include/string-data.icc index 5f3ca8b626..9e7fe6f0ad 100644 --- a/flower/include/string-data.icc +++ b/flower/include/string-data.icc @@ -1,9 +1,9 @@ /* -*-C++-*- - String_data.inl -- implement String_data + String_data.inl -- implement String_data - source file of Flower lib + source file of Flower lib - (c) 1997--2005 Han-Wen Nienhuys + (c) 1997--2005 Han-Wen Nienhuys */ #ifndef STRINGDATA_INL @@ -15,29 +15,28 @@ #include #include "string-data.hh" -const int INITIALMAX=8; +const int INITIALMAX = 8; #include -INLINE void -String_data::OKW () +INLINE void +String_data::OKW () { assert (ref_count_ == 1); } -INLINE void -String_data::OK () +INLINE void +String_data::OK () { assert (maxlen >= length_); assert (bool (data_byte_)); assert (ref_count_ >= 1); } - INLINE -String_data::String_data () +String_data::String_data () { - ref_count_=0; + ref_count_ = 0; maxlen = INITIALMAX; data_byte_ = new Byte[maxlen + 1]; data_byte_[0] = 0; @@ -45,143 +44,140 @@ String_data::String_data () } INLINE -String_data::String_data (String_data const &src) +String_data::String_data (String_data const &src) { - ref_count_=0; - maxlen = length_ = src.length_; - data_byte_ = new Byte[maxlen+1]; // should calc GNU 8byte overhead. - memcpy (data_byte_, src.data_byte_, length_ + 1); + ref_count_ = 0; + maxlen = length_ = src.length_; + data_byte_ = new Byte[maxlen + 1]; // should calc GNU 8byte overhead. + memcpy (data_byte_, src.data_byte_, length_ + 1); } INLINE -String_data::~String_data () +String_data::~String_data () { assert (ref_count_ == 0); delete[] data_byte_; } -INLINE void -String_data::setmax (int j) -{ +INLINE void +String_data::setmax (int j) +{ OKW (); - if (j > maxlen) + if (j > maxlen) { delete[] data_byte_; maxlen = j; data_byte_ = new Byte[maxlen + 1]; - + data_byte_[0] = 0; length_ = 0; } } -/* this is all quite hairy: - update of length_ - update of maxlen - alloc of buffer - copying of buffer - needs blondification: - split tasks - define change authority +/* this is all quite hairy: + update of length_ + update of maxlen + alloc of buffer + copying of buffer + needs blondification: + split tasks + define change authority */ -INLINE void -String_data::remax (int j) +INLINE void +String_data::remax (int j) { OKW (); - if (j > maxlen) + if (j > maxlen) { - Byte *p = new Byte[j + 1]; - memcpy (p, data_byte_, (maxlen = 0 && j <= length_); data_byte_[j] = 0; length_ = j; @@ -191,24 +187,22 @@ INLINE bool String_data::is_binary_bo () const { // return !memchr (data_byte_, length_, 0); - return ((int)strlen ((char const*)data_byte_) != length_ ); + return ((int)strlen ((char const *)data_byte_) != length_); } -INLINE Byte& -String_data::operator [] (int j) +INLINE Byte & +String_data::operator[] (int j) { assert (j >= 0 && j <= length_); - return data_byte_[j] ; + return data_byte_[j]; } -INLINE Byte -String_data::operator [] (int j) const +INLINE Byte +String_data::operator[] (int j) const { assert (j >= 0 && j <= length_); - return data_byte_[j]; + return data_byte_[j]; } - - #endif // __STRING_UTIL_CC // diff --git a/flower/include/string-handle.hh b/flower/include/string-handle.hh index c9cd7f384b..32810219d6 100644 --- a/flower/include/string-handle.hh +++ b/flower/include/string-handle.hh @@ -6,54 +6,52 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef STRINGHANDLE_HH #define STRINGHANDLE_HH #include "flower-proto.hh" - /** - Reference counting for strings. - + Reference counting for strings. + handles ref. counting, and provides a very thin interface using Byte * +*/ +class String_handle +{ + String_data *data; - */ -class String_handle { - String_data* data; - /// decrease ref count. Named kind of like a Tanenbaum semafore void down (); void up (String_data *d); - - /** make sure data has only one reference. + + /** make sure data has only one reference. POST: data->ref_count_ == 1 */ void copy (); - + public: String_handle (); ~String_handle (); - String_handle (String_handle const & src); + String_handle (String_handle const &src); - Byte const* to_bytes () const; - char const* to_str0 () const; - Byte* get_bytes (); - char* get_str0 (); + Byte const *to_bytes () const; + char const *to_str0 () const; + Byte *get_bytes (); + char *get_str0 (); bool is_binary_bo () const; - void operator = (String_handle const &src); - void operator += (char const *s); + void operator= (String_handle const &src); + void operator+= (char const *s); Byte operator[] (int j) const; /** Access elements. WARNING: NOT SAFE don't use this for loops. Use to_bytes () */ Byte &operator[] (int j); - void append (Byte const* byte, int length_i); - void set (Byte const* byte, int length_i); - void operator = (char const *p); + void append (Byte const *byte, int length_i); + void set (Byte const *byte, int length_i); + void operator= (char const *p); void trunc (int j); int length () const; }; @@ -66,5 +64,4 @@ public: /* we should be resetting INLINE. oh well. */ #endif - #endif // STRINGHANDLE_HH diff --git a/flower/include/string-handle.icc b/flower/include/string-handle.icc index aed19027d0..91af2c56d3 100644 --- a/flower/include/string-handle.icc +++ b/flower/include/string-handle.icc @@ -1,10 +1,10 @@ /* -*-c++-*- - - stringhandle.inl -- implement String_handle - source file of Flower lib +stringhandle.inl -- implement String_handle - (c) 1997--2005 Han-Wen Nienhuys +source file of Flower lib + +(c) 1997--2005 Han-Wen Nienhuys */ #ifndef STRINGHANDLE_INL @@ -17,12 +17,12 @@ #include "string-data.hh" #include "string-handle.hh" -INLINE void -String_handle::down () -{ +INLINE void +String_handle::down () +{ if (! (--data->ref_count_)) delete data; - data = 0; + data = 0; } /* @@ -30,15 +30,15 @@ String_handle::down () THIS does not have to be initialized. */ -INLINE void -String_handle::up (String_data *d) -{ - data=d; - data->ref_count_ ++; +INLINE void +String_handle::up (String_data *d) +{ + data = d; + data->ref_count_++; } -INLINE void -String_handle::copy () +INLINE void +String_handle::copy () { if (data->ref_count_ !=1) { @@ -49,51 +49,51 @@ String_handle::copy () } INLINE -String_handle::String_handle () +String_handle::String_handle () { up (new String_data); } INLINE -String_handle::~String_handle () -{ +String_handle::~String_handle () +{ down (); -} +} INLINE -String_handle::String_handle (String_handle const & src) -{ +String_handle::String_handle (String_handle const &src) +{ up (src.data); } -INLINE Byte* -String_handle::get_bytes () +INLINE Byte * +String_handle::get_bytes () { copy (); return data->get_bytes (); } -INLINE char* -String_handle::get_str0 () +INLINE char * +String_handle::get_str0 () { copy (); - return (char*)data->get_bytes (); + return (char *)data->get_bytes (); } -INLINE Byte -const* String_handle::to_bytes () const +INLINE Byte +const *String_handle::to_bytes () const { return data->to_bytes (); } -INLINE char const* -String_handle::to_str0 () const +INLINE char const * +String_handle::to_str0 () const { - return (char const*)data->to_bytes (); + return (char const *)data->to_bytes (); } -INLINE void -String_handle::operator = (String_handle const &src) +INLINE void +String_handle::operator= (String_handle const &src) { if (this == &src) return; @@ -101,64 +101,64 @@ String_handle::operator = (String_handle const &src) up (src.data); } -INLINE void -String_handle::operator += (char const *s) -{ +INLINE void +String_handle::operator+= (char const *s) +{ copy (); *data += s; -} - +} -INLINE Byte -String_handle::operator[] (int j) const -{ - return (*data)[j]; +INLINE Byte +String_handle::operator[] (int j) const +{ + return (*data)[j]; } // !NOT SAFE! // don't use this for loops. Use to_bytes () INLINE Byte & -String_handle::operator[] (int j) +String_handle::operator[] (int j) { copy (); // hmm. Not efficient return data->get_bytes ()[j]; } -INLINE void -String_handle::append (Byte const* byte, int length_i) +INLINE void +String_handle::append (Byte const *byte, int length_i) { copy (); data->append (byte, length_i); } - -INLINE void -String_handle::set (Byte const* byte, int length_i) + +INLINE void +String_handle::set (Byte const *byte, int length_i) { copy (); data->set (byte, length_i); } - -INLINE void -String_handle::operator = (char const *p) + +INLINE void +String_handle::operator= (char const *p) { copy (); data->set (p); } - -INLINE void -String_handle::trunc (int j) + +INLINE void +String_handle::trunc (int j) { - copy (); data->trunc (j); + copy (); data->trunc (j); } -INLINE int -String_handle::length () const -{ - return data->length_; +INLINE int +String_handle::length () const +{ + return data->length_; } INLINE bool -String_handle::is_binary_bo () const { +String_handle::is_binary_bo () const +{ return data->is_binary_bo (); } diff --git a/flower/include/string.hh b/flower/include/string.hh index b3f08e6738..70e9dd59aa 100644 --- a/flower/include/string.hh +++ b/flower/include/string.hh @@ -1,19 +1,17 @@ /* - FILE : string.hh -- declare String - + Rehacked by HWN 3/nov/95 removed String & 's introduced Class String_handle - */ +*/ #ifndef STRING_HH #define STRING_HH - // too darn slow with gcc3 #ifdef STREAM_SUPPORT -#if ( __GNUC__ > 2 ) +#if (__GNUC__ > 2) #include #else class ostream; @@ -23,70 +21,69 @@ class ostream; #include "arithmetic-operator.hh" #include "string-handle.hh" -/** - - Intuitive string class. provides +/** + +Intuitive string class. provides \begin{itemize} \item - ref counting through #String_handle# +ref counting through #String_handle# \item - conversion from bool, int, double, char* , char. +conversion from bool, int, double, char* , char. \item - to be moved to String_convert: - conversion to int, upcase, downcase +to be moved to String_convert: +conversion to int, upcase, downcase \item - printable. +printable. \item - indexing (index_i, index_any_i, last_index_i) +indexing (index_i, index_any_i, last_index_i) \item - cutting (left_string, right_string, mid_string) +cutting (left_string, right_string, mid_string) \item - concat (+=, +) +concat (+=, +) \item - signed comparison (<, >, ==, etc) +signed comparison (<, >, ==, etc) \item - No operator[] is provided, since this would be enormously slow. If needed, - convert to char const* . +No operator[] is provided, since this would be enormously slow. If needed, +convert to char const* . \end{itemize} - */ class String { protected: - String_handle strh_; + String_handle strh_; bool null_terminated (); - + public: /** init to empty string. This is needed because other - constructors are provided.*/ + constructors are provided.*/ String (); /// String s = "abc"; - String (char const* source); - String (Byte const* byte, int length_i); + String (char const *source); + String (Byte const *byte, int length_i); /// return "new"-ed copy of contents - Byte* get_copy_byte () const; - char* get_copy_str0 () const; + Byte *get_copy_byte () const; + char *get_copy_str0 () const; - char const* to_str0 () const; - Byte const* to_bytes () const; + char const *to_str0 () const; + Byte const *to_bytes () const; char *get_str0 (); Byte *get_bytes (); - String &operator = (String const & source); + String &operator= (String const &source); /// concatenate s - void operator += (char const* s) { strh_ += s; } - void operator += (String s); + void operator+= (char const *s) { strh_ += s; } + void operator+= (String s); bool is_empty () const; @@ -94,10 +91,10 @@ public: void prepend (String); /** - Return a char. UNSAFE because it may change strlen () result - */ - char &operator [] (int n); - char operator [] (int n) const; + Return a char. UNSAFE because it may change strlen () result + */ + char &operator[] (int n); + char operator[] (int n) const; /// return n leftmost chars String left_string (int n) const; @@ -115,20 +112,19 @@ public: String nomid_string (int index_i, int n) const; /// signed comparison, analogous to memcmp; - static int compare (String const & s1,const String& s2); - + static int compare (String const &s1, const String &s2); + /// index of rightmost c int index_last (char c) const; /// index of rightmost element of string (???) - int index_last (char const* string) const; + int index_last (char const *string) const; int index (char c) const; /// index of leftmost occurance of STRING int index (String) const; - int index_any (String) const; void to_upper (); @@ -138,7 +134,7 @@ public: /// provide Stream output void print_on (ostream& os) const; #endif - + /// the length of the string int length () const; @@ -152,33 +148,32 @@ public: }; /* - better to clutter global namespace, than suffer *ugh, ugh, ugh* - implicit conversions. + better to clutter global namespace, than suffer *ugh, ugh, ugh* + implicit conversions. - it might be cool to have no type-checking at all in a language, - but once there is, having this silently circumvented is a nightmare. + it might be cool to have no type-checking at all in a language, + but once there is, having this silently circumvented is a nightmare. - whenever implicit conversions seem necessary (e.g. operator << ()), - use Scalar as the generic type iso String. - */ + whenever implicit conversions seem necessary (e.g. operator << ()), + use Scalar as the generic type iso String. +*/ /// for completeness (=handy) inline String to_string (String s) { return s; } /// "cccc" String to_string (char c, int n = 1); -String to_string (int i, char const* format = 0); -String to_string (double f, char const* format = 0); -String to_string (long b); +String to_string (int i, char const *format = 0); +String to_string (double f, char const *format = 0); +String to_string (long b); String to_string (bool b); -String to_string (char const* format, ... ); +String to_string (char const *format, ...); /* technically incorrect, but lets keep it here: this is a catch all place for this stuff. - */ - -#include "international.hh" +*/ +#include "international.hh" #include "compare.hh" INSTANTIATE_COMPARE (String const &, String::compare); @@ -191,26 +186,27 @@ INSTANTIATE_COMPARE (String const &, String::compare); /* we should be resetting INLINE. oh well. */ #endif - // because char const* also has an operator ==, this is for safety: -inline bool operator== (String s1, char const* s2) +inline bool operator== (String s1, char const *s2) { return s1 == String (s2); } -inline bool operator== (char const* s1, String s2) +inline bool operator== (char const *s1, String s2) { - return String (s1)==s2; + return String (s1) == s2; } -inline bool operator!= (String s1, char const* s2 ) { - return s1!=String (s2); +inline bool operator!= (String s1, char const *s2) +{ + return s1 != String (s2); } -inline bool operator!= (char const* s1,String s2) { +inline bool operator!= (char const *s1, String s2) +{ return String (s2) !=s1; } IMPLEMENT_ARITHMETIC_OPERATOR (String, +); #ifdef STREAM_SUPPORT -ostream &operator << (ostream& os, String d); +ostream &operator<< (ostream& os, String d); #endif #endif diff --git a/flower/include/string.icc b/flower/include/string.icc index 4e558e8f72..ed6a5887ee 100644 --- a/flower/include/string.icc +++ b/flower/include/string.icc @@ -1,41 +1,38 @@ -/* +/* string.icc -- implement String inlines - + source file of the Flower Library - + (c) 1997--2005 Han-Wen Nienhuys - - */ +*/ #ifndef STRING_ICC #define STRING_ICC - -INLINE +INLINE char & -String::operator [] (int n) +String::operator[] (int n) { - return (char &) strh_[n]; + return (char &) strh_[n]; } -INLINE -char -String::operator [] (int n) const +INLINE +char +String::operator[] (int n) const { - return strh_[n]; + return strh_[n]; } -INLINE -String::String () +INLINE +String::String () { } INLINE -String::String (char const* source) -{ - assert (source); - strh_ = source; +String::String (char const *source) +{ + assert (source); + strh_ = source; } - #endif /* STRING_ICC */ diff --git a/flower/include/virtual-methods.hh b/flower/include/virtual-methods.hh index b448f66d2b..64f30bc6db 100644 --- a/flower/include/virtual-methods.hh +++ b/flower/include/virtual-methods.hh @@ -6,13 +6,12 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef VIRTUAL_METHODS_HH #define VIRTUAL_METHODS_HH #include -#define classname(class_ptr) demangle_classname (typeid (*(class_ptr))) +#define classname(class_ptr) demangle_classname (typeid (* (class_ptr))) const char * demangle_classname (std::type_info const &); @@ -22,21 +21,21 @@ demangle_classname (std::type_info const &); class Foo : Baseclass { - VIRTUAL_COPY_CONSTRUCTOR (Baseclass, Foo); + VIRTUAL_COPY_CONSTRUCTOR (Baseclass, Foo); }; */ -#define VIRTUAL_COPY_CONSTRUCTOR(base, name) \ - /* Hack to fix constness: gcc >= 2.95 is correct in defining \ - typeof (*this) in a const member function to be const. */ \ - virtual base* clone_const_helper () \ - { \ - return new name (*this); \ - } \ - virtual base *clone () const \ - { \ - /* return new name (*this); */ \ - base *urg = (base*) this; \ - return urg->clone_const_helper (); \ - } +#define VIRTUAL_COPY_CONSTRUCTOR(base, name) \ + /* Hack to fix constness: gcc >= 2.95 is correct in defining \ + typeof (*this) in a const member function to be const. */ \ + virtual base* clone_const_helper () \ + { \ + return new name (*this); \ + } \ + virtual base *clone () const \ + { \ + /* return new name (*this); */ \ + base *urg = (base*) this; \ + return urg->clone_const_helper (); \ + } #endif /* VIRTUAL_METHODS_HH */ diff --git a/flower/international.cc b/flower/international.cc index 1196cb2573..1e908cc5fd 100644 --- a/flower/international.cc +++ b/flower/international.cc @@ -1,33 +1,32 @@ -/* +/* international.cc -- implement stuff for internationalisation - + source file of the GNU LilyPond music typesetter - + (c) 1997--2005 Jan Nieuwenhuizen - - */ +*/ #include "config.hh" #include "string-convert.hh" #if !HAVE_GETTEXT -inline char* -gettext (char const* s) +inline char * +gettext (char const *s) { - return (char*)s; + return (char *)s; } #else #include #endif -String +String _ (char const *ch) { return String (gettext (ch)); } -String -_f (char const* format, ...) +String +_f (char const *format, ...) { va_list args; va_start (args, format); @@ -36,9 +35,9 @@ _f (char const* format, ...) return str; } -String -_f (char const* format, String s, String s2, String s3) +String +_f (char const *format, String s, String s2, String s3) { - return String_convert::form_string (gettext (format), s.to_str0 (), s2.to_str0 (), - s3.to_str0 ()); + return String_convert::form_string (gettext (format), s.to_str0 (), s2.to_str0 (), + s3.to_str0 ()); } diff --git a/flower/interval-set.cc b/flower/interval-set.cc index c0d3241fc9..89e5188830 100644 --- a/flower/interval-set.cc +++ b/flower/interval-set.cc @@ -1,10 +1,9 @@ -/* - interval-set.hh -- implement Interval_set - - source file of the GNU LilyPond music typesetter - - (c) 2004 Han-Wen Nienhuys - +/* + interval-set.hh -- implement Interval_set + + source file of the GNU LilyPond music typesetter + + (c) 2004 Han-Wen Nienhuys */ #include "interval-set.hh" @@ -34,7 +33,7 @@ Interval_set::set_full () void Interval_set::remove_interval (Interval rm) { - for (int i = 0; i < allowed_regions_.size (); ) + for (int i = 0; i < allowed_regions_.size ();) { Interval s = rm; diff --git a/flower/interval.cc b/flower/interval.cc index 6a7628702b..d833d3151f 100644 --- a/flower/interval.cc +++ b/flower/interval.cc @@ -12,7 +12,7 @@ template<> Real -Interval_t::infinity () +Interval_t::infinity () { return HUGE_VAL; } @@ -26,12 +26,11 @@ Interval_t::T_to_string (Real r) template<> int -Interval_t::infinity () +Interval_t::infinity () { return INT_MAX; } - template<> String Interval_t::T_to_string (int i) @@ -42,4 +41,3 @@ Interval_t::T_to_string (int i) template INTERVAL__INSTANTIATE (int); template INTERVAL__INSTANTIATE (Real); - diff --git a/flower/libc-extension.cc b/flower/libc-extension.cc index b6b32a31cd..7078a3be4e 100644 --- a/flower/libc-extension.cc +++ b/flower/libc-extension.cc @@ -14,22 +14,22 @@ #include "libc-extension.hh" -char* -strnlwr (char* start ,int n) +char * +strnlwr (char *start, int n) { - char * p = start + n; - while (--p >= start) + char *p = start + n; + while (--p >= start) { *p = tolower (*p); /* a macro on some compilers */ } return start; } -char* -strnupr (char* start, int n) +char * +strnupr (char *start, int n) { - char * p = start + n; - while (--p >= start) + char *p = start + n; + while (--p >= start) { *p = toupper (*p); /* a macro on some compilers */ } @@ -42,7 +42,7 @@ strnupr (char* start, int n) double my_round (double x) { - return floor (x -0.5)+ 1.0 ; + return floor (x -0.5)+ 1.0; } #ifndef isinf @@ -50,7 +50,7 @@ my_round (double x) int isinf (double x) { - return x && ( x == x/ 2) ; + return x && (x == x/ 2); } #endif #endif @@ -65,21 +65,21 @@ isinf (double x) unsigned char * _memmem (unsigned char const *haystack, int haystack_len, - unsigned char const *needle,int needle_len) + unsigned char const *needle, int needle_len) { - unsigned char const * end_haystack = haystack + haystack_len - needle_len + 1; - unsigned char const * end_needle = needle + needle_len ; + unsigned char const *end_haystack = haystack + haystack_len - needle_len + 1; + unsigned char const *end_needle = needle + needle_len; /* Ahhh ... Some minimal lowlevel stuff. This *is* nice; Varation is the spice of life */ - while (haystack < end_haystack) + while (haystack < end_haystack) { unsigned char const *subneedle = needle; unsigned char const *subhaystack = haystack; - while (subneedle < end_needle) - if (*subneedle++ != *subhaystack++) + while (subneedle < end_needle) + if (*subneedle++ != *subhaystack++) goto next; - + /* Completed the needle. Gotcha. */ return (unsigned char *) haystack; next: @@ -90,10 +90,10 @@ _memmem (unsigned char const *haystack, int haystack_len, void * memmem (void const *haystack, int haystack_len, - void const *needle,int needle_len) + void const *needle, int needle_len) { - unsigned char const* haystack_byte_c = (unsigned char const*)haystack; - unsigned char const* needle_byte_c = (unsigned char const*)needle; + unsigned char const *haystack_byte_c = (unsigned char const *)haystack; + unsigned char const *needle_byte_c = (unsigned char const *)needle; return _memmem (haystack_byte_c, haystack_len, needle_byte_c, needle_len); } @@ -103,15 +103,14 @@ unsigned char * memrchr (unsigned char const *p, int n, char c) { const unsigned char *q = p + n; - while (q > p) + while (q > p) { if (*--q == c) - return (unsigned char*)q; + return (unsigned char *)q; } return 0; } - template inline void my_swap (T &t1, T &t2, T &tmp) @@ -128,13 +127,13 @@ strrev (unsigned char *byte, int length) unsigned char *left = byte; unsigned char *right = byte + length; - while (right > left) - my_swap (*right--, *left++ , tmp_byte); + while (right > left) + my_swap (*right--, *left++, tmp_byte); return byte; } #if ! HAVE_SNPRINTF -int +int snprintf (char *str, size_t, char const *format, ...) { va_list ap; @@ -146,7 +145,7 @@ snprintf (char *str, size_t, char const *format, ...) #endif #if ! HAVE_VSNPRINTF -int +int vsnprintf (char *str, size_t, char const *format, va_list args) { int i = vsprintf (str, format, args); @@ -157,15 +156,15 @@ vsnprintf (char *str, size_t, char const *format, va_list args) #include extern "C" { - + #if ! HAVE_FOPENCOOKIE #if HAVE_FUNOPEN - + FILE * fopencookie (void *cookie, char const *mode, cookie_io_functions_t fun) { (void) mode; -#if 0 +#if 0 return funopen (cookie, fun.read, fun.write, fun.seek, fun.close); #else return funopen (cookie, @@ -173,8 +172,8 @@ extern "C" { (int (*) (void *, char const *, int)) fun.write, (fpos_t (*) (void *, fpos_t, int)) fun.seek, (int (*) (void *)) fun.close); - -#endif + +#endif } #else /* ! HAVE_FUNOPEN */ @@ -185,8 +184,8 @@ extern "C" { static bool is_memory_stream (void *foo) { - Memory_out_stream* cookie = (Memory_out_stream*) foo; - return dynamic_cast (cookie); + Memory_out_stream *cookie = (Memory_out_stream *) foo; + return dynamic_cast (cookie); } FILE * @@ -196,12 +195,12 @@ extern "C" { (void) modes; (void) io_funcs; if (is_memory_stream (cookie)) - return (FILE*) cookie; + return (FILE *) cookie; assert (false); return 0; } - int + int handle_cookie_io_fclose (FILE *file) { if (is_memory_stream (file)) @@ -209,7 +208,7 @@ extern "C" { return fclose (file); } - int + int handle_cookie_io_fprintf (FILE *file, char const *format, ...) { va_list ap; @@ -227,7 +226,7 @@ extern "C" { return i; } - int + int handle_cookie_io_putc (int c, FILE *file) { if (is_memory_stream (file)) @@ -238,7 +237,7 @@ extern "C" { } return putc (c, file); } - + #endif /* ! HAVE_FUNOPEN */ #endif /* ! HAVE_FOPENCOOKIE */ diff --git a/flower/memory-stream.cc b/flower/memory-stream.cc index 30e2453fa4..3d29993486 100644 --- a/flower/memory-stream.cc +++ b/flower/memory-stream.cc @@ -4,7 +4,6 @@ source file of the GNU LilyPond music typesetter (c) 2005 Han-Wen Nienhuys - */ #include @@ -13,14 +12,14 @@ #include "memory-stream.hh" - /* TODO: add read support as well. */ const int Memory_out_stream::block_size_ = 1024; cookie_io_functions_t -Memory_out_stream::functions_ = { +Memory_out_stream::functions_ += { Memory_out_stream::reader, Memory_out_stream::writer, Memory_out_stream::seeker, @@ -30,7 +29,7 @@ Memory_out_stream::functions_ = { int Memory_out_stream::cleaner (void *cookie) { - Memory_out_stream *stream = (Memory_out_stream*) cookie; + Memory_out_stream *stream = (Memory_out_stream *) cookie; stream->file_ = 0; return 0; @@ -41,7 +40,7 @@ Memory_out_stream::Memory_out_stream () size_ = 0; buffer_ = 0; buffer_blocks_ = 0; - file_ = fopencookie ((void*) this, "w", functions_); + file_ = fopencookie ((void *) this, "w", functions_); } Memory_out_stream::~Memory_out_stream () @@ -75,7 +74,7 @@ Memory_out_stream::writer (void *cookie, const char *buffer, size_t size) { - Memory_out_stream *stream = (Memory_out_stream*) cookie; + Memory_out_stream *stream = (Memory_out_stream *) cookie; ssize_t newsize = stream->size_ + size; @@ -88,8 +87,8 @@ Memory_out_stream::writer (void *cookie, } if (change) - stream->buffer_ = (char*) realloc (stream->buffer_, - stream->buffer_blocks_ * block_size_); + stream->buffer_ = (char *) realloc (stream->buffer_, + stream->buffer_blocks_ * block_size_); memcpy (stream->buffer_ + stream->size_, buffer, size); stream->size_ = newsize; diff --git a/flower/offset.cc b/flower/offset.cc index 9af1f0d907..a3ed32aecb 100644 --- a/flower/offset.cc +++ b/flower/offset.cc @@ -15,13 +15,12 @@ String Offset::to_string () const { String s; - s = String (" (") + ::to_string (coordinate_a_[X_AXIS]) + ", " + s = String (" (") + ::to_string (coordinate_a_[X_AXIS]) + ", " + ::to_string (coordinate_a_[Y_AXIS]) + ")"; return s; } #endif - bool isinf_b (Real r) { @@ -30,25 +29,24 @@ isinf_b (Real r) /* free bsd fix by John Galbraith - */ - +*/ + Offset complex_multiply (Offset z1, Offset z2) { Offset z; if (!isinf_b (z2[Y_AXIS])) - { + { z[X_AXIS] = z1[X_AXIS] * z2[X_AXIS] - z1[Y_AXIS]*z2[Y_AXIS]; z[Y_AXIS] = z1[X_AXIS] * z2[Y_AXIS] + z1[Y_AXIS] * z2[X_AXIS]; - } + } return z; } - Offset complex_conjugate (Offset o) { - o[Y_AXIS] = - o[Y_AXIS]; + o[Y_AXIS] = -o[Y_AXIS]; return o; } @@ -57,18 +55,16 @@ complex_divide (Offset z1, Offset z2) { z2 = complex_conjugate (z2); Offset z = complex_multiply (z1, z2); - z *= 1/z2.length (); + z *= 1 / z2.length (); return z; } - - Offset complex_exp (Offset o) { Real s = sin (o[Y_AXIS]); Real c = cos (o[Y_AXIS]); - + Real r = exp (o[X_AXIS]); return Offset (r*c, r*s); @@ -82,7 +78,7 @@ Offset::arg () const /** euclidian vector length / complex modulus - */ +*/ Real Offset::length () const { diff --git a/flower/parse-afm.cc b/flower/parse-afm.cc index 00c348e79f..fdd8ec846c 100644 --- a/flower/parse-afm.cc +++ b/flower/parse-afm.cc @@ -14,7 +14,6 @@ Raph Levien writing on 4 Oct 1998, updating 21 Oct 1998 2. Leak fix in parseFile. Morten Welinder September 1999. - */ /* @@ -85,31 +84,28 @@ Morten Welinder September 1999. #define EOL '\n' /* end-of-line indicator */ #define MAX_NAME 4096 /* max length for identifiers */ - - /* Flags that can be AND'ed together to specify exactly what * information from the AFM file should be saved. */ -#define P_G 0x01 /* 0000 0001 */ /* Global Font Info */ -#define P_W 0x02 /* 0000 0010 */ /* Character Widths ONLY */ -#define P_M 0x06 /* 0000 0110 */ /* All Char Metric Info */ -#define P_P 0x08 /* 0000 1000 */ /* Pair Kerning Info */ -#define P_T 0x10 /* 0001 0000 */ /* Track Kerning Info */ -#define P_C 0x20 /* 0010 0000 */ /* Composite Char Info */ - +#define P_G 0x01 /* 0000 0001 */ /* Global Font Info */ +#define P_W 0x02 /* 0000 0010 */ /* Character Widths ONLY */ +#define P_M 0x06 /* 0000 0110 */ /* All Char Metric Info */ +#define P_P 0x08 /* 0000 1000 */ /* Pair Kerning Info */ +#define P_T 0x10 /* 0001 0000 */ /* Track Kerning Info */ +#define P_C 0x20 /* 0010 0000 */ /* Composite Char Info */ /* Commonly used flags */ -#define P_GW\ - (P_G | P_W) -#define P_GM\ - (P_G | P_M) -#define P_GMP\ - (P_G | P_M | P_P) -#define P_GMK\ - (P_G | P_M | P_P | P_T) -#define P_GALL\ - (P_G | P_M | P_P | P_T | P_C) +#define P_GW \ + (P_G | P_W) +#define P_GM \ + (P_G | P_M) +#define P_GMP \ + (P_G | P_M | P_P) +#define P_GMK \ + (P_G | P_M | P_P | P_T) +#define P_GALL \ + (P_G | P_M | P_P | P_T | P_C) #define METATYPE1_BUG /* Parse Metatype1's (version unknown) 'Generated' global tag as comment. */ @@ -123,15 +119,12 @@ Morten Welinder September 1999. #define False "false" /* used in string comparison to check the value of */ /* boolean keys (e.g. IsFixedPitch) */ -#define MATCH(A,B) (strncmp ((A), (B), MAX_NAME) == 0) - - +#define MATCH(A, B) (strncmp ((A), (B), MAX_NAME) == 0) /*************************** GLOBALS ***********************/ static char *ident = NULL; /* storage buffer for keywords */ - /* "shorts" for fast case statement * The values of each of these enumerated items correspond to an entry in the * table of strings defined below. Therefore, if you add a new string as @@ -147,21 +140,22 @@ static char *ident = NULL; /* storage buffer for keywords */ * "recognize" procedure to calculate how many possible keys there are. */ -enum parseKey { - ASCENDER, CHARBBOX, CODE, COMPCHAR, CAPHEIGHT, COMMENT, - DESCENDER, ENCODINGSCHEME, ENDCHARMETRICS, ENDCOMPOSITES, - ENDFONTMETRICS, ENDKERNDATA, ENDKERNPAIRS, ENDTRACKKERN, - FAMILYNAME, FONTBBOX, FONTNAME, FULLNAME, +enum parseKey + { + ASCENDER, CHARBBOX, CODE, COMPCHAR, CAPHEIGHT, COMMENT, + DESCENDER, ENCODINGSCHEME, ENDCHARMETRICS, ENDCOMPOSITES, + ENDFONTMETRICS, ENDKERNDATA, ENDKERNPAIRS, ENDTRACKKERN, + FAMILYNAME, FONTBBOX, FONTNAME, FULLNAME, #ifdef METATYPE1_BUG - GENERATED, + GENERATED, #endif - ISFIXEDPITCH, - ITALICANGLE, KERNPAIR, KERNPAIRXAMT, LIGATURE, CHARNAME, - NOTICE, COMPCHARPIECE, STARTCHARMETRICS, STARTCOMPOSITES, - STARTFONTMETRICS, STARTKERNDATA, STARTKERNPAIRS, - STARTTRACKKERN, TRACKKERN, UNDERLINEPOSITION, - UNDERLINETHICKNESS, VERSION, XYWIDTH, XWIDTH, WEIGHT, XHEIGHT, - NOPE }; + ISFIXEDPITCH, + ITALICANGLE, KERNPAIR, KERNPAIRXAMT, LIGATURE, CHARNAME, + NOTICE, COMPCHARPIECE, STARTCHARMETRICS, STARTCOMPOSITES, + STARTFONTMETRICS, STARTKERNDATA, STARTKERNPAIRS, + STARTTRACKKERN, TRACKKERN, UNDERLINEPOSITION, + UNDERLINETHICKNESS, VERSION, XYWIDTH, XWIDTH, WEIGHT, XHEIGHT, + NOPE }; /* keywords for the system: * This a table of all of the current strings that are vaild AFM keys. @@ -176,7 +170,8 @@ enum parseKey { * end. */ -static char *keyStrings[] = { +static char *keyStrings[] += { "Ascender", "B", "C", "CC", "CapHeight", "Comment", "Descender", "EncodingScheme", "EndCharMetrics", "EndComposites", "EndFontMetrics", "EndKernData", "EndKernPairs", "EndTrackKern", @@ -202,7 +197,7 @@ static char *keyStrings[] = { * reads all tokens until the next end-of-line. */ -static char* +static char * token (FILE *stream) { int ch, idx; @@ -230,7 +225,6 @@ token (FILE *stream) } /* token */ - /*************************** linetoken *************************/ /* "linetoken" will get read all tokens until the EOL character from @@ -238,7 +232,7 @@ token (FILE *stream) * more than one word (like Comment lines and FullName). */ -static char* +static char * linetoken (FILE *stream) { int ch, idx; @@ -260,7 +254,6 @@ linetoken (FILE *stream) } /* linetoken */ - /*************************** recognize *************************/ /* This function tries to match a string to a known list of @@ -282,7 +275,7 @@ recognize (register char *ident) while ((upper >= lower) && !found) { - midpoint = (lower + upper)/2; + midpoint = (lower + upper) / 2; if (keyStrings[midpoint] == NULL) break; cmpvalue = strncmp (ident, keyStrings[midpoint], MAX_NAME); @@ -291,8 +284,8 @@ recognize (register char *ident) else if (cmpvalue < 0) upper = midpoint - 1; - else - lower = midpoint + 1; + else + lower = midpoint + 1; } if (found) @@ -301,7 +294,6 @@ recognize (register char *ident) return NOPE; } - /************************* parseGlobals *****************************/ /* This function is called by "parseFile". It will parse the AFM File @@ -337,19 +329,19 @@ parseGlobals (FILE *fp, register AFM_GlobalFontInfo *gfi) if (keyword == NULL) /* Have reached an early and unexpected EOF. */ /* Set flag and stop parsing */ - { + { error = AFM_earlyEOF; break; /* get out of loop */ - } + } if (!save) /* get tokens until the end of the Global Font info section */ /* without saving any of the data */ switch (recognize (keyword)) - { + { case STARTCHARMETRICS: cont = FALSE; break; - case ENDFONTMETRICS: + case ENDFONTMETRICS: cont = FALSE; error = normalEOF; break; @@ -369,7 +361,7 @@ parseGlobals (FILE *fp, register AFM_GlobalFontInfo *gfi) case COMMENT: #ifdef METATYPE1_BUG case GENERATED: -#endif +#endif keyword = linetoken (fp); break; case FONTNAME: @@ -472,7 +464,6 @@ parseGlobals (FILE *fp, register AFM_GlobalFontInfo *gfi) } /* parseGlobals */ - #if 0 /************************* initializeArray ************************/ @@ -504,12 +495,12 @@ initializeArray (FILE *fp, register int *cwi) { keyword = token (fp); if (keyword == NULL) - { + { error = AFM_earlyEOF; break; /* get out of loop */ - } + } switch (recognize (keyword)) - { + { case COMMENT: keyword = linetoken (fp); break; @@ -538,7 +529,7 @@ initializeArray (FILE *fp, register int *cwi) default: error = AFM_parseError; break; - } /* switch */ + } /* switch */ } /* while */ if (!found) @@ -587,15 +578,15 @@ parseCharWidths (FILE *fp, register int *cwi) /* Have reached an early and unexpected EOF. */ /* Set flag and stop parsing */ if (keyword == NULL) - { + { error = AFM_earlyEOF; break; /* get out of loop */ - } - if (!save) + } + if (!save) /* get tokens until the end of the Char Metrics section without */ /* saving any of the data*/ switch (recognize (keyword)) - { + { case ENDCHARMETRICS: cont = FALSE; break; @@ -656,7 +647,6 @@ parseCharWidths (FILE *fp, register int *cwi) } /* parseCharWidths */ - /************************* parseCharMetrics ************************/ /* This function is called by parseFile if the caller of parseFile @@ -686,12 +676,12 @@ parseCharMetrics (FILE *fp, register AFM_Font_info *fi) { keyword = token (fp); if (keyword == NULL) - { + { error = AFM_earlyEOF; break; /* get out of loop */ - } + } switch (recognize (keyword)) - { + { case COMMENT: keyword = linetoken (fp); break; @@ -719,13 +709,13 @@ parseCharMetrics (FILE *fp, register AFM_Font_info *fi) case XWIDTH: temp->wx = atoi (token (fp)); break; - + case CHARNAME: keyword = token (fp); temp->name = (char *) malloc (strlen (keyword) + 1); strcpy (temp->name, keyword); break; - + case CHARBBOX: temp->charBBox.llx = atoi (token (fp)); temp->charBBox.lly = atoi (token (fp)); @@ -733,25 +723,26 @@ parseCharMetrics (FILE *fp, register AFM_Font_info *fi) temp->charBBox.ury = atoi (token (fp)); break; - case LIGATURE: { - AFM_Ligature **tail = & (temp->ligs); - AFM_Ligature *node = *tail; + case LIGATURE: + { + AFM_Ligature **tail = &(temp->ligs); + AFM_Ligature *node = *tail; - if (*tail != NULL) - { - while (node->next != NULL) - node = node->next; - tail = & (node->next); - } + if (*tail != NULL) + { + while (node->next != NULL) + node = node->next; + tail = &(node->next); + } - *tail = (AFM_Ligature *) calloc (1, sizeof (AFM_Ligature)); - keyword = token (fp); - (*tail)->succ = (char *) malloc (strlen (keyword) + 1); - strcpy ((*tail)->succ, keyword); - keyword = token (fp); - (*tail)->lig = (char *) malloc (strlen (keyword) + 1); - strcpy ((*tail)->lig, keyword); - break; } + *tail = (AFM_Ligature *) calloc (1, sizeof (AFM_Ligature)); + keyword = token (fp); + (*tail)->succ = (char *) malloc (strlen (keyword) + 1); + strcpy ((*tail)->succ, keyword); + keyword = token (fp); + (*tail)->lig = (char *) malloc (strlen (keyword) + 1); + strcpy ((*tail)->lig, keyword); + break; } case ENDCHARMETRICS: cont = FALSE;; break; @@ -762,10 +753,10 @@ parseCharMetrics (FILE *fp, register AFM_Font_info *fi) case NOPE: default: warning ("Unknown token"); - + error = AFM_parseError; break; - } /* switch */ + } /* switch */ } /* while */ if ((error == AFM_ok) && (count != fi->numOfChars)) @@ -777,8 +768,6 @@ parseCharMetrics (FILE *fp, register AFM_Font_info *fi) } /* parseCharMetrics */ - - /************************* parseAFM_TrackKernData ***********************/ /* This function is called by "parseFile". It will parse the AFM File @@ -806,10 +795,10 @@ parseAFM_TrackKernData (FILE *fp, register AFM_Font_info *fi) keyword = token (fp); if (keyword == NULL) - { + { error = AFM_earlyEOF; break; /* get out of loop */ - } + } if (!save) /* get tokens until the end of the Track Kerning Data */ /* section without saving any of the data */ @@ -832,9 +821,9 @@ parseAFM_TrackKernData (FILE *fp, register AFM_Font_info *fi) switch (recognize (keyword)) { case COMMENT: -#ifdef METATYPE1_BUG +#ifdef METATYPE1_BUG case GENERATED: -#endif +#endif keyword = linetoken (fp); break; case TRACKKERN: @@ -884,7 +873,6 @@ parseAFM_TrackKernData (FILE *fp, register AFM_Font_info *fi) } /* parseAFM_TrackKernData */ - /************************* parseAFM_PairKernData ************************/ /* This function is called by "parseFile". It will parse the AFM File @@ -912,10 +900,10 @@ parseAFM_PairKernData (FILE *fp, register AFM_Font_info *fi) keyword = token (fp); if (keyword == NULL) - { + { error = AFM_earlyEOF; break; /* get out of loop */ - } + } if (!save) /* get tokens until the end of the Pair Kerning Data */ /* section without saving any of the data */ @@ -1006,7 +994,6 @@ parseAFM_PairKernData (FILE *fp, register AFM_Font_info *fi) } /* parseAFM_PairKernData */ - /************************* parseAFM_CompCharData **************************/ /* This function is called by "parseFile". It will parse the AFM File @@ -1038,15 +1025,15 @@ parseAFM_CompCharData (FILE *fp, register AFM_Font_info *fi) if (keyword == NULL) /* Have reached an early and unexpected EOF. */ /* Set flag and stop parsing */ - { + { error = AFM_earlyEOF; break; /* get out of loop */ - } + } if (ccount > fi->numOfComps) - { + { error = AFM_parseError; break; /* get out of loop */ - } + } if (!save) /* get tokens until the end of the Composite Character info */ /* section without saving any of the data */ @@ -1133,72 +1120,78 @@ parseAFM_CompCharData (FILE *fp, register AFM_Font_info *fi) } /* parseAFM_CompCharData */ - - /*************************** 'PUBLIC' FUNCTION ********************/ void AFM_free (AFM_Font_info *fi) { - if (fi->gfi) { - free (fi->gfi->afmVersion); - free (fi->gfi->fontName); - free (fi->gfi->fullName); - free (fi->gfi->familyName); - free (fi->gfi->weight); - free (fi->gfi->version); - free (fi->gfi->notice); - free (fi->gfi->encodingScheme); - free (fi->gfi); - } + if (fi->gfi) + { + free (fi->gfi->afmVersion); + free (fi->gfi->fontName); + free (fi->gfi->fullName); + free (fi->gfi->familyName); + free (fi->gfi->weight); + free (fi->gfi->version); + free (fi->gfi->notice); + free (fi->gfi->encodingScheme); + free (fi->gfi); + } /* This contains just scalars. */ free (fi->cwi); - if (fi->cmi) { - int i; - for (i = 0; i < fi->numOfChars; i++) { - free (fi->cmi[i].name); - while (fi->cmi[i].ligs) { - AFM_Ligature *tmp; - tmp = fi->cmi[i].ligs; - free (tmp->succ); - free (tmp->lig); - free (tmp); - fi->cmi[i].ligs = fi->cmi[i].ligs->next; - } + if (fi->cmi) + { + int i; + for (i = 0; i < fi->numOfChars; i++) + { + free (fi->cmi[i].name); + while (fi->cmi[i].ligs) + { + AFM_Ligature *tmp; + tmp = fi->cmi[i].ligs; + free (tmp->succ); + free (tmp->lig); + free (tmp); + fi->cmi[i].ligs = fi->cmi[i].ligs->next; + } + } + free (fi->cmi); } - free (fi->cmi); - } /* This contains just scalars. */ free (fi->tkd); - if (fi->pkd) { - int i; - for (i = 0; i < fi->numOfPairs; i++) { - free (fi->pkd[i].name1); - free (fi->pkd[i].name2); + if (fi->pkd) + { + int i; + for (i = 0; i < fi->numOfPairs; i++) + { + free (fi->pkd[i].name1); + free (fi->pkd[i].name2); + } + free (fi->pkd); } - free (fi->pkd); - } - - if (fi->ccd) { - int i, j; - for (i = 0; i < fi->numOfComps; i++) { - free (fi->ccd[i].ccName); - for (j = 0; j < fi->ccd[i].numOfPieces; j++) { - free (fi->ccd[i].pieces[j].AFM_PccName); - } - free (fi->ccd[i].pieces); + + if (fi->ccd) + { + int i, j; + for (i = 0; i < fi->numOfComps; i++) + { + free (fi->ccd[i].ccName); + for (j = 0; j < fi->ccd[i].numOfPieces; j++) + { + free (fi->ccd[i].pieces[j].AFM_PccName); + } + free (fi->ccd[i].pieces); + } + free (fi->ccd); } - free (fi->ccd); - } free (fi); } - /*************************** parseFile *****************************/ /* parseFile is the only 'public' procedure available. It is called @@ -1227,10 +1220,9 @@ AFM_parseFile (FILE *fp, AFM_Font_info **fi, int flags) int code = AFM_ok; /* return code from each of the parsing routines */ int error = AFM_ok; /* used as the return code from this function */ - register char *keyword; /* used to store a token */ + register char *keyword; /* used to store a token */ - - /* storage data for the global variable ident */ + /* storage data for the global variable ident */ if (!ident) ident = (char *) calloc (MAX_NAME, sizeof (char)); if (ident == NULL) @@ -1276,7 +1268,7 @@ AFM_parseFile (FILE *fp, AFM_Font_info **fi, int flags) { (*fi)->numOfChars = atoi (token (fp)); if (flags & (P_M ^ P_W)) - { + { (*fi)->cmi = (AFM_CharMetricInfo *) calloc ((*fi)->numOfChars, sizeof (AFM_CharMetricInfo)); if ((*fi)->cmi == NULL) @@ -1285,21 +1277,21 @@ AFM_parseFile (FILE *fp, AFM_Font_info **fi, int flags) return error; } code = parseCharMetrics (fp, *fi); - } + } else - { + { if (flags & P_W) - { + { (*fi)->cwi = (int *) calloc (256, sizeof (int)); if ((*fi)->cwi == NULL) - { + { error = AFM_storageProblem; return (error); - } - } + } + } /* parse section regardless */ code = parseCharWidths (fp, (*fi)->cwi); - } /* else */ + } /* else */ } /* if */ if ((error != AFM_earlyEOF) && (code < 0)) @@ -1317,12 +1309,12 @@ AFM_parseFile (FILE *fp, AFM_Font_info **fi, int flags) if (keyword == NULL) /* Have reached an early and unexpected EOF. */ /* Set flag and stop parsing */ - { + { code = AFM_earlyEOF; break; /* get out of loop */ - } + } switch (recognize (keyword)) - { + { case STARTKERNDATA: break; case ENDKERNDATA: @@ -1379,7 +1371,7 @@ AFM_parseFile (FILE *fp, AFM_Font_info **fi, int flags) default: code = AFM_parseError; break; - } /* switch */ + } /* switch */ if ((error != AFM_earlyEOF) && (code < 0)) error = code; diff --git a/flower/polynomial.cc b/flower/polynomial.cc index 8994d73214..92447b6300 100644 --- a/flower/polynomial.cc +++ b/flower/polynomial.cc @@ -1,18 +1,18 @@ /* - poly.cc -- routines for manipulation of polynomials in one var + poly.cc -- routines for manipulation of polynomials in one var (c) 1993--2005 Han-Wen Nienhuys - */ +*/ #include "polynomial.hh" #include /* - Een beter milieu begint bij uzelf. Hergebruik! + Een beter milieu begint bij uzelf. Hergebruik! - This was ripped from Rayce, a raytracer I once wrote. + This was ripped from Rayce, a raytracer I once wrote. */ Real @@ -21,15 +21,14 @@ Polynomial::eval (Real x)const Real p = 0.0; // horner's scheme - for (int i = coefs_.size (); i--; ) + for (int i = coefs_.size (); i--;) p = x * p + coefs_[i]; - + return p; } - Polynomial -Polynomial::multiply (const Polynomial & p1, const Polynomial & p2) +Polynomial::multiply (const Polynomial &p1, const Polynomial &p2) { Polynomial dest; @@ -41,7 +40,7 @@ Polynomial::multiply (const Polynomial & p1, const Polynomial & p2) if (i - j <= p2.degree () && j <= p1.degree ()) dest.coefs_.top () += p1.coefs_[j] * p2.coefs_[i - j]; } - + return dest; } @@ -50,33 +49,35 @@ Polynomial::differentiate () { for (int i = 1; i<= degree (); i++) { - coefs_[i-1] = coefs_[i] * i; + coefs_[i - 1] = coefs_[i] * i; } coefs_.pop (); } Polynomial -Polynomial::power (int exponent, const Polynomial & src) +Polynomial::power (int exponent, const Polynomial &src) { int e = exponent; Polynomial dest (1), base (src); - + /* classic int power. invariant: src^exponent = dest * src ^ e greetings go out to Lex Bijlsma & Jaap vd Woude */ while (e > 0) { if (e % 2) - { + { dest = multiply (dest, base); e--; - } else - { - base = multiply (base, base); - e /= 2; - } + } + else + + { + base = multiply (base, base); + e /= 2; + } } - return dest; + return dest; } static Real const FUDGE = 1e-8; @@ -84,39 +85,35 @@ static Real const FUDGE = 1e-8; void Polynomial::clean () { -/* - We only do relative comparisons. Absolute comparisons break down in - degenerate cases. */ - while (degree () > 0 && - (fabs (coefs_.top ()) < FUDGE * fabs (coefs_.top (1)) - || !coefs_.top ())) + /* + We only do relative comparisons. Absolute comparisons break down in + degenerate cases. */ + while (degree () > 0 + && (fabs (coefs_.top ()) < FUDGE *fabs (coefs_.top (1)) + || !coefs_.top ())) coefs_.pop (); } - - void -Polynomial::operator += (Polynomial const &p) +Polynomial::operator+= (Polynomial const &p) { - while (degree () < p.degree()) + while (degree () < p.degree ()) coefs_.push (0.0); - for (int i = 0; i <= p.degree(); i++) + for (int i = 0; i <= p.degree (); i++) coefs_[i] += p.coefs_[i]; } - void -Polynomial::operator -= (Polynomial const &p) +Polynomial::operator-= (Polynomial const &p) { - while (degree () < p.degree()) + while (degree () < p.degree ()) coefs_.push (0.0); - for (int i = 0; i <= p.degree(); i++) + for (int i = 0; i <= p.degree (); i++) coefs_[i] -= p.coefs_[i]; } - void Polynomial::scalarmultiply (Real fact) { @@ -124,33 +121,35 @@ Polynomial::scalarmultiply (Real fact) coefs_[i] *= fact; } - - void -Polynomial::set_negate (const Polynomial & src) +Polynomial::set_negate (const Polynomial &src) { for (int i = 0; i <= src.degree (); i++) coefs_[i] = -src.coefs_[i]; } /// mod of #u/v# -int +int Polynomial::set_mod (const Polynomial &u, const Polynomial &v) { - (*this) = u; - - if (v.lc () < 0.0) { - for (int k = u.degree () - v.degree () - 1; k >= 0; k -= 2) - coefs_[k] = -coefs_[k]; - - for (int k = u.degree () - v.degree (); k >= 0; k--) - for (int j = v.degree () + k - 1; j >= k; j--) - coefs_[j] = -coefs_[j] - coefs_[v.degree () + k] * v.coefs_[j - k]; - } else { - for (int k = u.degree () - v.degree (); k >= 0; k--) - for (int j = v.degree () + k - 1; j >= k; j--) - coefs_[j] -= coefs_[v.degree () + k] * v.coefs_[j - k]; - } + (*this) = u; + + if (v.lc () < 0.0) + { + for (int k = u.degree () - v.degree () - 1; k >= 0; k -= 2) + coefs_[k] = -coefs_[k]; + + for (int k = u.degree () - v.degree (); k >= 0; k--) + for (int j = v.degree () + k - 1; j >= k; j--) + coefs_[j] = -coefs_[j] - coefs_[v.degree () + k] * v.coefs_[j - k]; + } + else + + { + for (int k = u.degree () - v.degree (); k >= 0; k--) + for (int j = v.degree () + k - 1; j >= k; j--) + coefs_[j] -= coefs_[v.degree () + k] * v.coefs_[j - k]; + } int k = v.degree () - 1; while (k >= 0 && coefs_[k] == 0.0) @@ -161,24 +160,23 @@ Polynomial::set_mod (const Polynomial &u, const Polynomial &v) } void -Polynomial::check_sol (Real x) const +Polynomial::check_sol (Real x) const { - Real f=eval (x); + Real f = eval (x); Polynomial p (*this); p.differentiate (); Real d = p.eval (x); - - if ( abs (f) > abs (d) * FUDGE) - ; + + if (abs (f) > abs (d) * FUDGE); /* warning ("x=%f is not a root of polynomial\n" "f (x)=%f, f' (x)=%f \n", x, f, d); */ } - + void Polynomial::check_sols (Array roots) const { - for (int i=0; i< roots.size (); i++) + for (int i = 0; i< roots.size (); i++) check_sol (roots[i]); } @@ -193,9 +191,9 @@ Polynomial::Polynomial (Real a, Real b) inline Real cubic_root (Real x) { if (x > 0.0) - return pow (x, 1.0/3.0) ; + return pow (x, 1.0 / 3.0); else if (x < 0.0) - return -pow (-x, 1.0/3.0); + return -pow (-x, 1.0 / 3.0); else return 0.0; } @@ -210,7 +208,7 @@ Array Polynomial::solve_cubic ()const { Array sol; - + /* normal form: x^3 + Ax^2 + Bx + C = 0 */ Real A = coefs_[2] / coefs_[3]; Real B = coefs_[1] / coefs_[3]; @@ -220,39 +218,40 @@ Polynomial::solve_cubic ()const * substitute x = y - A/3 to eliminate quadric term: x^3 +px + q = 0 */ - Real sq_A = A * A; + Real sq_A = A *A; Real p = 1.0 / 3 * (-1.0 / 3 * sq_A + B); - Real q = 1.0 / 2 * (2.0 / 27 * A * sq_A - 1.0 / 3 * A * B + C); + Real q = 1.0 / 2 * (2.0 / 27 * A *sq_A - 1.0 / 3 * A *B + C); /* use Cardano's formula */ Real cb = p * p * p; Real D = q * q + cb; - if (iszero (D)) { - if (iszero (q)) { /* one triple solution */ - sol.push (0); - sol.push (0); - sol.push (0); - } else { /* one single and one double solution */ - Real u = cubic_root (-q); - - sol.push (2 * u); - sol.push (-u); - } - } else if (D < 0) { /* Casus irreducibilis: three real solutions */ + if (iszero (D)) + { + if (iszero (q)) { /* one triple solution */ + sol.push (0); + sol.push (0); + sol.push (0); + } else { /* one single and one double solution */ + Real u = cubic_root (-q); + + sol.push (2 * u); + sol.push (-u); + } + } else if (D < 0) { /* Casus irreducibilis: three real solutions */ Real phi = 1.0 / 3 * acos (-q / sqrt (-cb)); Real t = 2 * sqrt (-p); sol.push (t * cos (phi)); sol.push (-t * cos (phi + M_PI / 3)); - sol.push ( -t * cos (phi - M_PI / 3)); + sol.push (-t * cos (phi - M_PI / 3)); } else { /* one real solution */ Real sqrt_D = sqrt (D); Real u = cubic_root (sqrt_D - q); Real v = -cubic_root (sqrt_D + q); - sol.push ( u + v); + sol.push (u + v); } /* resubstitute */ @@ -263,10 +262,10 @@ Polynomial::solve_cubic ()const sol[i] -= sub; #ifdef PARANOID - assert (fabs (eval (sol[i]) ) < 1e-8); + assert (fabs (eval (sol[i])) < 1e-8); #endif } - + return sol; } @@ -276,8 +275,8 @@ Polynomial::lc () const return coefs_.top (); } -Real& -Polynomial::lc () +Real & +Polynomial::lc () { return coefs_.top (); } @@ -288,8 +287,8 @@ Polynomial::degree ()const return coefs_.size () -1; } /* - all roots of quadratic eqn. - */ + all roots of quadratic eqn. +*/ Array Polynomial::solve_quadric ()const { @@ -300,13 +299,14 @@ Polynomial::solve_quadric ()const Real D = p * p - q; - if (D>0) { - D = sqrt (D); + if (D > 0) + { + D = sqrt (D); - sol.push ( D - p); - sol.push ( -D - p); - } - return sol; + sol.push (D - p); + sol.push (-D - p); + } + return sol; } /* solve linear equation */ @@ -315,17 +315,16 @@ Polynomial::solve_linear ()const { Array s; if (coefs_[1]) - s.push ( -coefs_[0] / coefs_[1]); + s.push (-coefs_[0] / coefs_[1]); return s; } - Array Polynomial::solve () const { - Polynomial * me = (Polynomial*) this; + Polynomial *me = (Polynomial *) this; me->clean (); - + switch (degree ()) { case 1: @@ -340,9 +339,8 @@ Polynomial::solve () const } void -Polynomial:: operator *= (Polynomial const &p2) +Polynomial:: operator*= (Polynomial const &p2) { - *this = multiply (*this,p2); -} - + *this = multiply (*this, p2); +} diff --git a/flower/rational.cc b/flower/rational.cc index 888a82ae9d..a21b939565 100644 --- a/flower/rational.cc +++ b/flower/rational.cc @@ -1,6 +1,6 @@ /* rational.cc -- implement Rational - + source file of the Flower Library (c) 1997--2005 Han-Wen Nienhuys @@ -11,7 +11,7 @@ #include #include -#include "string-convert.hh" +#include "string-convert.hh" #include "libc-extension.hh" Rational::operator double () const @@ -21,14 +21,13 @@ Rational::operator double () const #ifdef STREAM_SUPPORT ostream & -operator << (ostream &o, Rational r) +operator<< (ostream &o, Rational r) { - o << r.string (); + o << r.string (); return o; } #endif - Rational Rational::trunc_rat () const { @@ -68,15 +67,14 @@ int gcd (int a, int b) return b; } - void Rational::set_infinite (int s) { - sign_ = ::sign (s) * 2; + sign_ = ::sign (s) * 2; } Rational -Rational::operator - () const +Rational::operator- () const { Rational r (*this); r.negate (); @@ -119,7 +117,7 @@ Rational::normalise () } else { - int g = gcd (num_ , den_); + int g = gcd (num_, den_); num_ /= g; den_ /= g; @@ -144,48 +142,46 @@ Rational::compare (Rational const &r, Rational const &s) return 0; else { - return r.sign_ * ::sign (int (r.num_ * s.den_) - int (s.num_ * r.den_)); + return r.sign_ * ::sign (int (r.num_ * s.den_) - int (s.num_ * r.den_)); } } int compare (Rational const &r, Rational const &s) { - return Rational::compare (r, s ); + return Rational::compare (r, s); } Rational & -Rational::operator %= (Rational r) +Rational::operator%= (Rational r) { *this = r.mod_rat (r); return *this; } Rational & -Rational::operator += (Rational r) +Rational::operator+= (Rational r) { - if (is_infinity ()) - ; + if (is_infinity ()); else if (r.is_infinity ()) { *this = r; } - else + else { int n = sign_ * num_ *r.den_ + r.sign_ * den_ * r.num_; int d = den_ * r.den_; - sign_ = ::sign (n) * ::sign (d); + sign_ = ::sign (n) * ::sign (d); num_ = abs (n); den_ = abs (d); normalise (); } return *this; } - /* copied from libg++ 2.8.0 - */ +*/ Rational::Rational (double x) { if (x != 0.0) @@ -208,7 +204,7 @@ Rational::Rational (double x) num_ = (unsigned int) (mantissa * FACT); den_ = (unsigned int) FACT; - normalise (); + normalise (); if (expt < 0) den_ <<= -expt; else @@ -224,21 +220,20 @@ Rational::Rational (double x) } } - void Rational::invert () { int r (num_); - num_ = den_; + num_ = den_; den_ = r; } Rational & -Rational::operator *= (Rational r) +Rational::operator*= (Rational r) { sign_ *= ::sign (r.sign_); if (r.is_infinity ()) - { + { sign_ = sign () * 2; goto exit_func; } @@ -250,9 +245,9 @@ Rational::operator *= (Rational r) exit_func: return *this; } - + Rational & -Rational::operator /= (Rational r) +Rational::operator/= (Rational r) { r.invert (); return (*this *= r); @@ -264,8 +259,8 @@ Rational::negate () sign_ *= -1; } -Rational& -Rational::operator -= (Rational r) +Rational & +Rational::operator-= (Rational r) { r.negate (); return (*this += r); @@ -276,7 +271,7 @@ Rational::to_string () const { if (is_infinity ()) { - String s (sign_ > 0 ? "" : "-" ); + String s (sign_ > 0 ? "" : "-"); return String (s + "infinity"); } diff --git a/flower/string-convert.cc b/flower/string-convert.cc index d2fd21ce97..be044e062f 100644 --- a/flower/string-convert.cc +++ b/flower/string-convert.cc @@ -2,7 +2,7 @@ PROJECT: FlowerSoft C++ library FILE : string-convert.cc ---*/ + --*/ #include "string-convert.hh" @@ -20,11 +20,11 @@ 2e318, this number would have approx 318 zero's in its string. Should enlarge buff dynamically. - + @see man 3 snprintf - */ -static const int STRING_BUFFER_LEN=1024; +*/ +static const int STRING_BUFFER_LEN = 1024; String String_convert::bool_string (bool b) @@ -36,8 +36,8 @@ String String_convert::bin2hex (String bin_string) { String str; - Byte const* byte = bin_string.to_bytes (); - for (int i = 0; i < bin_string.length (); i++) + Byte const *byte = bin_string.to_bytes (); + for (int i = 0; i < bin_string.length (); i++) { str += to_string ((char)nibble2hex_byte (*byte >> 4)); str += to_string ((char)nibble2hex_byte (*byte++)); @@ -57,7 +57,7 @@ String_convert::bin2unsigned (String bin_string) assert (bin_string.length () <= (int)sizeof (unsigned)); unsigned result_u = 0; - for (int i = 0; i < bin_string.length (); i++) + for (int i = 0; i < bin_string.length (); i++) { result_u <<= 8; result_u += (Byte)bin_string[ i ]; @@ -80,11 +80,11 @@ String_convert::dec2int (String dec_string) } String -String_convert::i64_string (I64 i64, char const* fmt) +String_convert::i64_string (I64 i64, char const *fmt) { char buffer[STRING_BUFFER_LEN]; snprintf (buffer, STRING_BUFFER_LEN, - (fmt ? fmt : "%Ld"), i64); // assume radix 10 + (fmt ? fmt : "%Ld"), i64); // assume radix 10 return String (buffer); } @@ -101,27 +101,27 @@ String_convert::dec2double (String dec_string) } int -String_convert::hex2bin (String hex_string, String& bin_string_r) +String_convert::hex2bin (String hex_string, String &bin_string_r) { if (hex_string.length () % 2) hex_string = "0" + hex_string; bin_string_r = ""; - Byte const* byte= hex_string.to_bytes (); + Byte const *byte= hex_string.to_bytes (); int i = 0; - while (i < hex_string.length ()) + while (i < hex_string.length ()) { int high_i = hex2nibble (*byte++); int low_i = hex2nibble (*byte++); if (high_i < 0 || low_i < 0) return 1; // illegal char - bin_string_r += to_string ((char) (high_i << 4 | low_i), 1 ); + bin_string_r += to_string ((char) (high_i << 4 | low_i), 1); i += 2; } return 0; } -String +String String_convert::hex2bin (String hex_string) { String str; @@ -132,7 +132,7 @@ String_convert::hex2bin (String hex_string) return str; } -int +int String_convert::hex2nibble (Byte byte) { if (byte >= '0' && byte <= '9') @@ -145,7 +145,7 @@ String_convert::hex2nibble (Byte byte) } // stupido. Should use int_string () -String +String String_convert::int2dec (int i, int length_i, char ch) { char fill_char = ch; @@ -154,14 +154,13 @@ String_convert::int2dec (int i, int length_i, char ch) // ugh String dec_string = to_string (i); - + // ugh return to_string (fill_char, length_i - dec_string.length ()) + dec_string; } - // stupido. Should use int_string () -String +String String_convert::unsigned2hex (unsigned u, int length_i, char fill_char) { String str; @@ -169,9 +168,9 @@ String_convert::unsigned2hex (unsigned u, int length_i, char fill_char) str = "0"; #if 1 // both go... - while (u) + while (u) { - str = to_string ((char) ((u % 16)["0123456789abcdef"] ) ) + str; + str = to_string ((char) ((u % 16)["0123456789abcdef"])) + str; u /= 16; } #else @@ -200,22 +199,22 @@ String_convert::nibble2hex_byte (Byte byte) return (byte & 0x0f) - 10 + 'a'; } /** - Convert an integer to a string + Convert an integer to a string - @param - #fmt# is a printf style format, default assumes "%d" as format. - */ + @param + #fmt# is a printf style format, default assumes "%d" as format. +*/ String -String_convert::int_string (int i, char const* fmt) +String_convert::int_string (int i, char const *fmt) { char buffer[STRING_BUFFER_LEN]; snprintf (buffer, STRING_BUFFER_LEN, - (fmt ? fmt : "%d"), i); // assume radix 10 + (fmt ? fmt : "%d"), i); // assume radix 10 return String (buffer); } String -String_convert::form_string (char const* format, ...) +String_convert::form_string (char const *format, ...) { va_list args; va_start (args, format); @@ -225,8 +224,8 @@ String_convert::form_string (char const* format, ...) return String (buffer); } -String -String_convert::vform_string (char const* format, va_list args) +String +String_convert::vform_string (char const *format, va_list args) { char buffer[STRING_BUFFER_LEN]; vsnprintf (buffer, STRING_BUFFER_LEN, format, args); @@ -234,32 +233,32 @@ String_convert::vform_string (char const* format, va_list args) } /** - Convert a double to a string. + Convert a double to a string. - @param #fmt# is a printf style format, default assumes "%lf" as format - */ + @param #fmt# is a printf style format, default assumes "%lf" as format +*/ String -String_convert::double_string (double f, char const* fmt) +String_convert::double_string (double f, char const *fmt) { - char buf[STRING_BUFFER_LEN]; + char buf[STRING_BUFFER_LEN]; snprintf (buf, STRING_BUFFER_LEN, fmt ? fmt : "%f", f); return String (buf); } /** -Make a string from a single character. + Make a string from a single character. - @param - #n# is a repetition count, default value is 1 - */ + @param + #n# is a repetition count, default value is 1 +*/ String String_convert::char_string (char c, int n) { n = n >= 0 ? n : 0; - char* ch = new char[ n ]; + char *ch = new char[ n ]; memset (ch, c, n); - String s ((Byte*)ch, n); + String s ((Byte *)ch, n); delete[] ch; return s; } @@ -267,23 +266,23 @@ String_convert::char_string (char c, int n) String String_convert::rational_string (Rational r) { - return r.to_string (); + return r.to_string (); } String String_convert::pointer_string (void const *l) { char buffer[STRING_BUFFER_LEN]; - snprintf (buffer, STRING_BUFFER_LEN, "%p", l); // assume radix 10 + snprintf (buffer, STRING_BUFFER_LEN, "%p", l); // assume radix 10 return String (buffer); } /** - Convert a double to a string. + Convert a double to a string. - @param - #n# is the number of nonzero digits - */ + @param + #n# is the number of nonzero digits +*/ String String_convert::precision_string (double x, int n) { @@ -324,8 +323,7 @@ String_convert::split (String str, char c) { String s = str.left_string (i); a.push (s); - while (str[++i] == c) - ; + while (str[++i] == c); str = str.cut_string (i, INT_MAX); i = str.index (c); } @@ -334,12 +332,11 @@ String_convert::split (String str, char c) return a; } - String String_convert::long_string (long l) { char s[STRING_BUFFER_LEN]; - sprintf (s,"%ld", l); + sprintf (s, "%ld", l); return s; } diff --git a/flower/string.cc b/flower/string.cc index dceafbc267..0f8aa09011 100644 --- a/flower/string.cc +++ b/flower/string.cc @@ -1,10 +1,8 @@ /* + string.cc - implement String - string.cc - implement String - (c) 1997--2005 Han-Wen Nienhuys & Jan Nieuwenhuizen - - */ +*/ #ifndef _GNU_SOURCE // we want memmem #define _GNU_SOURCE @@ -23,47 +21,46 @@ #include "string-convert.hh" #ifdef STRING_DEBUG -void* mymemmove (void* dest, void const* src, size_t n); +void *mymemmove (void *dest, void const *src, size_t n); #define memmove mymemmove #endif // return array, alloced with new. -Byte* +Byte * String::get_copy_byte () const { - Byte const* src = strh_.to_bytes (); - Byte* dest = new Byte[strh_.length () + 1]; + Byte const *src = strh_.to_bytes (); + Byte *dest = new Byte[strh_.length () + 1]; memcpy (dest, src, strh_.length () + 1); - return dest; + return dest; } -char* +char * String::get_copy_str0 () const { - return (char*)get_copy_byte (); + return (char *)get_copy_byte (); } /* copying, constructing. - */ -String& -String::operator = (String const&source) +*/ +String & +String::operator= (String const &source) { strh_ = source.strh_; return *this; } - -String::String (Byte const* byte, int len_i) -{ +String::String (Byte const *byte, int len_i) +{ strh_.set (byte, len_i); } /** - @see - String_convert:: - */ + @see + String_convert:: +*/ String to_string (char c, int n) { @@ -71,13 +68,13 @@ to_string (char c, int n) } String -to_string (double f, char const* format) +to_string (double f, char const *format) { return String_convert::double_string (f, format); } String -to_string (int i, char const * format) +to_string (int i, char const *format) { return String_convert::int_string (i, format); } @@ -93,8 +90,8 @@ to_string (long b) return String_convert::long_string (b); } -String -to_string (char const* format, ... ) +String +to_string (char const *format, ...) { va_list args; va_start (args, format); @@ -110,7 +107,7 @@ String::append (String s) strh_.append (s.to_bytes (), s.length ()); } void -String::operator += (String s) +String::operator+= (String s) { append (s); } @@ -128,49 +125,49 @@ String::length () const return strh_.length (); } -Byte const* +Byte const * String::to_bytes () const { return strh_.to_bytes (); } -char const* +char const * String::to_str0 () const { return strh_.to_str0 (); } -Byte* +Byte * String::get_bytes () { return strh_.get_bytes (); } -char* +char * String::get_str0 () { return strh_.get_str0 (); } -bool +bool String::is_empty () const { return !length (); } /** - Do a signed comparison, analogous to memcmp; - */ + Do a signed comparison, analogous to memcmp; +*/ int -String::compare (String const& s1, String const& s2) +String::compare (String const &s1, String const &s2) { - Byte const* p1 = s1.to_bytes (); - Byte const* p2 = s2.to_bytes (); + Byte const *p1 = s1.to_bytes (); + Byte const *p2 = s2.to_bytes (); if (p1 == p2) return 0; /* don't forget the terminating '\0' - */ + */ int f = (s1.length () = 0) + while (next_i >= 0) { index_i += next_i; - next_i = right_string (length () - index_i - len).index (string ); + next_i = right_string (length () - index_i - len).index (string); } return index_i; } /** find a character. - @return - the index of the leftmost character #c# (0 <= return < length ()), - or -1 if not found. +@return +the index of the leftmost character #c# (0 <= return < length ()), +or -1 if not found. - ? should return length ()?, as in string.left_string (index (delimiter)) +? should return length ()?, as in string.left_string (index (delimiter)) */ int String::index (char c) const { - char const* me = strh_.to_str0 (); - char const* p = (char const *) memchr (me,c, length ()); + char const *me = strh_.to_str0 (); + char const *p = (char const *) memchr (me, c, length ()); if (p) return p - me; return -1; } /** - find a substring. + find a substring. - @return - index of leftmost occurrence of #searchfor# - */ + @return + index of leftmost occurrence of #searchfor# +*/ int String::index (String searchfor) const { - char const* me = strh_.to_str0 (); + char const *me = strh_.to_str0 (); - char const* p = (char const *) + char const *p = (char const *) memmem (me, length (), searchfor.to_str0 (), searchfor.length ()); - + if (p) return p - me; @@ -252,12 +249,10 @@ String::index (String searchfor) const /** find chars of a set. - @return - - the index of the leftmost occurance of an element of #set#. -1 if - nothing is found. - +@return +the index of the leftmost occurance of an element of #set#. -1 if +nothing is found. */ int String::index_any (String set) const @@ -266,13 +261,13 @@ String::index_any (String set) const if (!n) return -1; - void const * me = (void const *) strh_.to_str0 (); - for (int i=0; i < set.length (); i++) + void const *me = (void const *) strh_.to_str0 (); + for (int i = 0; i < set.length (); i++) { - char * found= (char*) memchr (me, set[i], n ); - if (found) + char *found= (char *) memchr (me, set[i], n); + if (found) { - return found - (char const*)me; + return found - (char const *)me; } } return -1; @@ -284,10 +279,10 @@ String::left_string (int n) const if (n >= length ()) return *this; - String retval; + String retval; if (n < 1) return retval; - + retval = *this; retval.strh_.trunc (n); return retval; @@ -298,41 +293,40 @@ String::right_string (int n) const { if (n > length ()) return *this; - + if (n < 1) return ""; - - return String (strh_.to_bytes () + length () - n, n); -} + return String (strh_.to_bytes () + length () - n, n); +} String String::nomid_string (int index_i, int n) const { - if (index_i < 0) + if (index_i < 0) { n += index_i; index_i = 0; } if (n <= 0) return *this; - + return left_string (index_i) + right_string (length () - index_i - n); } String String::cut_string (int index_i, int n) const { - if (index_i <0) + if (index_i <0) { n += index_i; - index_i=0; + index_i = 0; } - - if (!length () || (index_i < 0) || (index_i >= length () ) || (n < 1 ) ) + + if (!length () || (index_i < 0) || (index_i >= length ()) || (n < 1)) return String (); - if ((n > length ()) || (index_i + n > length () ) ) + if ((n > length ()) || (index_i + n > length ())) n = length () - index_i; return String (to_bytes () + index_i, n); @@ -348,10 +342,10 @@ String::to_upper () void String::to_lower () { - strnlwr (get_str0 (), length ()); + strnlwr (get_str0 (), length ()); } -void +void String::reverse () { strrev (get_bytes (), length ()); @@ -371,7 +365,7 @@ String::to_double () const #ifdef STREAM_SUPPORT ostream & -operator << (ostream& os, String d) +operator<< (ostream& os, String d) { d.print_on (os); return os; diff --git a/flower/stringutil.cc b/flower/stringutil.cc index a9e67a2513..0e42eac4e4 100644 --- a/flower/stringutil.cc +++ b/flower/stringutil.cc @@ -1,5 +1,5 @@ /* - stringutil.cc -- generate non-inline members. + stringutil.cc -- generate non-inline members. This should be in a separate file, because one can include the .icc only once. @@ -8,7 +8,7 @@ (c) 1997--2005 Han-Wen Nienhuys */ -#ifdef STRING_DEBUG +#ifdef STRING_DEBUG #define memmove mymemmove #endif @@ -32,9 +32,9 @@ #ifdef STRING_DEBUG #include #include -void* -mymemmove (void* dest, void const* src, size_t n) +void * +mymemmove (void *dest, void const *src, size_t n) { - return memcpy (dest, src, n); + return memcpy (dest, src, n); } #endif diff --git a/lily/accidental-engraver.cc b/lily/accidental-engraver.cc index a60c3880bc..64965254d0 100644 --- a/lily/accidental-engraver.cc +++ b/lily/accidental-engraver.cc @@ -59,10 +59,10 @@ protected: virtual void derived_mark () const; public: SCM last_keysig_; // ugh. - + /* Urgh. Since the accidentals depend on lots of variables, we have - to store all information before we can really create the - accidentals. */ + to store all information before we can really create the + accidentals. */ Link_array left_objects_; Link_array right_objects_; @@ -72,7 +72,6 @@ public: Link_array ties_; }; - /* TODO: @@ -80,7 +79,7 @@ public: aren't. eg. localKeySignature is changed at runtime, which means that references in grobs should always store ly_deep_copy ()s of those. - */ +*/ static void set_property_on_children (Context *trans, char const *sym, SCM val) @@ -124,17 +123,16 @@ Accidental_engraver::update_local_key_signature () void Accidental_engraver::initialize () { - update_local_key_signature (); + update_local_key_signature (); } - /** Calculate the number of accidentals on basis of the current local key sig (passed as argument) - + * First check step+octave (taking into account barnumbers if necessary). - + * Then check the global signature (only step). - + Return number of accidentals (0, 1 or 2). */ static bool @@ -143,7 +141,7 @@ recent_enough (int bar_number, SCM alteration_def, SCM laziness) if (scm_is_number (alteration_def) || laziness == SCM_BOOL_T) return true; - + return (bar_number <= scm_to_int (scm_cdr (alteration_def)) + scm_to_int (laziness)); } @@ -177,19 +175,17 @@ number_accidentals_from_sig (bool *different, SCM sig, Pitch *pitch, SCM previous_alteration = SCM_BOOL_F; - SCM from_same_octave = ly_assoc_get (scm_cons (scm_int2num (o), - scm_int2num (n)), sig, SCM_BOOL_F); + scm_int2num (n)), sig, SCM_BOOL_F); SCM from_key_signature = ly_assoc_get (scm_int2num (n), sig, SCM_BOOL_F); SCM from_other_octaves = SCM_BOOL_F; - for (SCM s = sig ; scm_is_pair (s); s = scm_cdr (s)) + for (SCM s = sig; scm_is_pair (s); s = scm_cdr (s)) { SCM entry = scm_car (s); if (scm_is_pair (scm_car (entry)) && scm_cdar (entry) == scm_int2num (n)) - from_other_octaves = scm_cdr (entry); + from_other_octaves = scm_cdr (entry); } - if (from_same_octave != SCM_BOOL_F && recent_enough (bar_number, from_same_octave, laziness)) @@ -206,7 +202,7 @@ number_accidentals_from_sig (bool *different, SCM sig, Pitch *pitch, { previous_alteration = from_key_signature; } - + int num = 1; if (is_tied (previous_alteration)) { @@ -215,9 +211,9 @@ number_accidentals_from_sig (bool *different, SCM sig, Pitch *pitch, } else { - int prev = extract_alteration (previous_alteration); + int prev = extract_alteration (previous_alteration); int alter = pitch->get_alteration (); - + if (alter == prev) num = 0; else if ((abs (alter) < abs (prev) || prev*alter < 0) && alter != 0) @@ -236,9 +232,9 @@ number_accidentals (bool *different, *different = false; if (scm_is_pair (accidentals) && !scm_is_symbol (scm_car (accidentals))) - warning (_f ("Accidental typesetting list must begin with context-name: %s", + warning (_f ("Accidental typesetting list must begin with context-name: %s", ly_scm2string (scm_car (accidentals)).to_str0 ())); - + for (; scm_is_pair (accidentals) && origin; accidentals = scm_cdr (accidentals)) { @@ -249,11 +245,11 @@ number_accidentals (bool *different, SCM type = scm_car (rule); SCM laziness = scm_cdr (rule); SCM localsig = origin->get_property ("localKeySignature"); - - bool same_octave_b = - scm_is_eq (ly_symbol2scm ("same-octave"), type); - bool any_octave_b = - scm_is_eq (ly_symbol2scm ("any-octave"), type); + + bool same_octave_b + = scm_is_eq (ly_symbol2scm ("same-octave"), type); + bool any_octave_b + = scm_is_eq (ly_symbol2scm ("any-octave"), type); if (same_octave_b || any_octave_b) { @@ -261,13 +257,12 @@ number_accidentals (bool *different, int n = number_accidentals_from_sig (&d, localsig, pitch, bar_number, laziness, any_octave_b); *different = *different || d; - number = max (number, n); + number = max (number, n); } else - warning (_f ("ignoring unknown accidental: %s", + warning (_f ("ignoring unknown accidental: %s", ly_symbol2string (type).to_str0 ())); } - /* if symbol then it is a context name. Scan parent contexts to find it. @@ -277,11 +272,11 @@ number_accidentals (bool *different, Context *dad = origin; while (dad && !dad->is_alias (rule)) dad = dad->get_parent_context (); - + if (dad) origin = dad; } - else warning (_f ("Accidental rule must be pair or context-name; Found %s", + else warning (_f ("Accidental rule must be pair or context-name; Found %s", ly_scm2string (rule).to_str0 ())); } @@ -295,11 +290,11 @@ Accidental_engraver::get_bar_number () SCM smp = get_property ("measurePosition"); int bn = robust_scm2int (barnum, 0); - - Moment mp = robust_scm2moment (smp, Moment (0)); + + Moment mp = robust_scm2moment (smp, Moment (0)); if (mp.main_part_ < Rational (0)) bn--; - + return bn; } @@ -308,16 +303,16 @@ Accidental_engraver::process_acknowledged_grobs () { if (accidentals_.size () && !accidentals_.top ().done_) { - SCM accidentals = get_property ("autoAccidentals"); - SCM cautionaries = get_property ("autoCautionaries"); + SCM accidentals = get_property ("autoAccidentals"); + SCM cautionaries = get_property ("autoCautionaries"); int barnum = get_bar_number (); - + bool extra_natural_b = get_property ("extraNatural") == SCM_BOOL_T; - for (int i = 0; i < accidentals_.size (); i++) + for (int i = 0; i < accidentals_.size (); i++) { - if (accidentals_[i].done_ ) + if (accidentals_[i].done_) continue; - accidentals_[i].done_ = true; + accidentals_[i].done_ = true; Grob *support = accidentals_[i].head_; Music *note = accidentals_[i].melodic_; Context *origin = accidentals_[i].origin_; @@ -328,7 +323,7 @@ Accidental_engraver::process_acknowledged_grobs () bool different = false; bool different_caut = false; - + int num = number_accidentals (&different, pitch, origin, accidentals, barnum); @@ -337,7 +332,7 @@ Accidental_engraver::process_acknowledged_grobs () cautionaries, barnum); bool cautionary = to_boolean (note->get_property ("cautionary")); - + if (num_caut > num) { num = num_caut; @@ -347,26 +342,24 @@ Accidental_engraver::process_acknowledged_grobs () if (num == 0 && to_boolean (note->get_property ("force-accidental"))) num = 1; - /* Can not look for ties: it's not guaranteed that they reach us before the notes - */ - + */ + if (num) { /* We construct the accidentals at the originating Voice level, so that we get the property settings for Accidental from the respective Voice. - */ + */ Grob *a = make_item_from_properties (accidentals_[i].origin_trans_, ly_symbol2scm ("Accidental"), note->self_scm (), - "Accidental" - ); + "Accidental"); a->set_parent (support, Y_AXIS); if (!accidental_placement_) @@ -382,7 +375,7 @@ Accidental_engraver::process_acknowledged_grobs () if (cautionary) a->set_property ("cautionary", SCM_BOOL_T); - + support->set_property ("accidental-grob", a->self_scm ()); a->set_property ("accidentals", accs); @@ -392,9 +385,9 @@ Accidental_engraver::process_acknowledged_grobs () We add the accidentals to the support of the arpeggio, so it is put left of the accidentals. */ - for (int i = 0; i < left_objects_.size (); i++) + for (int i = 0; i < left_objects_.size (); i++) Side_position_interface::add_support (left_objects_[i], a); - for (int i = 0; i < right_objects_.size (); i++) + for (int i = 0; i < right_objects_.size (); i++) Side_position_interface::add_support (a, right_objects_[i]); } } @@ -413,7 +406,7 @@ Accidental_engraver::stop_translation_timestep () for (int j = ties_.size (); j--;) { Grob *r = Tie::head (ties_[j], RIGHT); - for (int i = accidentals_.size (); i--;) + for (int i = accidentals_.size (); i--;) if (accidentals_[i].head_ == r) { if (Grob *g = accidentals_[i].accidental_) @@ -426,12 +419,12 @@ Accidental_engraver::stop_translation_timestep () } } - for (int i = accidentals_.size (); i--;) + for (int i = accidentals_.size (); i--;) { int barnum = get_bar_number (); Music *note = accidentals_[i].melodic_; - Context * origin = accidentals_[i].origin_; + Context *origin = accidentals_[i].origin_; Pitch *pitch = unsmob_pitch (note->get_property ("pitch")); if (!pitch) @@ -446,7 +439,7 @@ Accidental_engraver::stop_translation_timestep () && origin->where_defined (ly_symbol2scm ("localKeySignature"))) { /* - huh? we set props all the way to the top? + huh? we set props all the way to the top? */ SCM localsig = origin->get_property ("localKeySignature"); bool change = false; @@ -495,14 +488,14 @@ Accidental_engraver::acknowledge_grob (Grob_info info) && note->is_mus_type ("note-event") && Rhythmic_head::has_interface (info.grob_)) { - if (to_boolean ( get_property ("harmonicAccidentals")) + if (to_boolean (get_property ("harmonicAccidentals")) || !ly_c_equal_p (info.grob_->get_property ("style"), - ly_symbol2scm ("harmonic"))) + ly_symbol2scm ("harmonic"))) { - - Accidental_entry entry ; + + Accidental_entry entry; entry.head_ = info.grob_; - entry.origin_trans_ = dynamic_cast (info.origin_trans_); + entry.origin_trans_ = dynamic_cast (info.origin_trans_); entry.origin_ = info.origin_trans_->context (); entry.melodic_ = note; @@ -510,12 +503,12 @@ Accidental_engraver::acknowledge_grob (Grob_info info) } } else if (Tie::has_interface (info.grob_)) - ties_.push (dynamic_cast (info.grob_)); + ties_.push (dynamic_cast (info.grob_)); else if (Arpeggio::has_interface (info.grob_)) - left_objects_.push (info.grob_); + left_objects_.push (info.grob_); else if (info.grob_ ->internal_has_interface (ly_symbol2scm ("finger-interface"))) - left_objects_.push (info.grob_); + left_objects_.push (info.grob_); } void @@ -529,26 +522,20 @@ Accidental_engraver::process_music () } ADD_TRANSLATOR (Accidental_engraver, - "Make accidentals. " - "Catch note heads, ties and notices key-change events. " - "This engraver usually lives at Staff level, but " - "reads the settings for Accidental at @code{Voice} level, " - "so you can @code{\\override} them at @code{Voice}. " - , - "Accidental" - , - "" - , - "arpeggio-interface " - "finger-interface " - "rhythmic-head-interface " - "tie-interface " - , - "autoAccidentals " - "autoCautionaries " - "extraNatural " - "harmonicAccidentals " - "localKeySignature" - , - "localKeySignature" - ); + "Make accidentals. " + "Catch note heads, ties and notices key-change events. " + "This engraver usually lives at Staff level, but " + "reads the settings for Accidental at @code{Voice} level, " + "so you can @code{\\override} them at @code{Voice}. ", + "Accidental", + "", + "arpeggio-interface " + "finger-interface " + "rhythmic-head-interface " + "tie-interface ", + "autoAccidentals " + "autoCautionaries " + "extraNatural " + "harmonicAccidentals " + "localKeySignature", + "localKeySignature"); diff --git a/lily/accidental-placement.cc b/lily/accidental-placement.cc index 91e0de193b..cf67149f76 100644 --- a/lily/accidental-placement.cc +++ b/lily/accidental-placement.cc @@ -1,15 +1,13 @@ -/* - accidental-placement.cc -- implement Accidental_placement - - source file of the GNU LilyPond music typesetter +/* + accidental-placement.cc -- implement Accidental_placement - (c) 2002--2005 Han-Wen Nienhuys + source file of the GNU LilyPond music typesetter + (c) 2002--2005 Han-Wen Nienhuys */ #include - #include "accidental-placement.hh" #include "libc-extension.hh" // isinf #include "skyline.hh" @@ -23,11 +21,11 @@ MAKE_SCHEME_CALLBACK (Accidental_placement, alignment_callback, 2); SCM -Accidental_placement::alignment_callback (SCM s, SCM ) +Accidental_placement::alignment_callback (SCM s, SCM) { - Grob * me = unsmob_grob (s); + Grob *me = unsmob_grob (s); - Grob * par = me->get_parent (X_AXIS); + Grob *par = me->get_parent (X_AXIS); if (!to_boolean (par->get_property ("positioning-done"))) { par->set_property ("positioning-done", SCM_BOOL_T); @@ -37,19 +35,18 @@ Accidental_placement::alignment_callback (SCM s, SCM ) return scm_int2num (0); } - void -Accidental_placement::add_accidental (Grob* me, Grob* a) +Accidental_placement::add_accidental (Grob *me, Grob *a) { a->set_parent (me, X_AXIS); a->add_offset_callback (alignment_callback_proc, X_AXIS); SCM cause = a->get_parent (Y_AXIS)->get_property ("cause"); - Music *mcause = unsmob_music (cause); + Music *mcause = unsmob_music (cause); if (!mcause) { programming_error ("Note head has no music cause!"); - return; + return; } Pitch *p = unsmob_pitch (mcause->get_property ("pitch")); @@ -68,16 +65,16 @@ Accidental_placement::add_accidental (Grob* me, Grob* a) entry = scm_cons (a->self_scm (), entry); - accs = scm_assq_set_x (accs, key, entry); + accs = scm_assq_set_x (accs, key, entry); me->set_property ("accidental-grobs", accs); } /* Split into break reminders. - */ +*/ void -Accidental_placement::split_accidentals (Grob * accs, +Accidental_placement::split_accidentals (Grob *accs, Link_array *break_reminder, Link_array *real_acc) { @@ -108,12 +105,12 @@ Accidental_placement::get_relevant_accidental_extent (Grob *me, Accidental_placement::split_accidentals (me, &br, &ra); br.concat (ra); - - if (dynamic_cast(left_object)->break_status_dir () == RIGHT) - which = & br; + + if (dynamic_cast (left_object)->break_status_dir () == RIGHT) + which = &br; else - which = & ra; - + which = &ra; + Interval extent; for (int i = 0; i < which->size (); i++) { @@ -125,12 +122,10 @@ Accidental_placement::get_relevant_accidental_extent (Grob *me, Real p = robust_scm2double (me->get_property ("left-padding"), 0.2); extent[LEFT] -= p; } - + return extent; } - - struct Accidental_placement_entry { Array left_skyline_; @@ -138,7 +133,7 @@ struct Accidental_placement_entry Interval vertical_extent_; Array extents_; Link_array grobs_; - Real offset_; + Real offset_; int notename_; Accidental_placement_entry () { @@ -148,13 +143,11 @@ struct Accidental_placement_entry }; static Interval all_accidental_vertical_extent; -Real ape_priority (Accidental_placement_entry const * a) +Real ape_priority (Accidental_placement_entry const *a) { return a->vertical_extent_[UP]; } - - int ape_compare (Accidental_placement_entry *const &a, Accidental_placement_entry *const &b) { @@ -162,28 +155,24 @@ int ape_compare (Accidental_placement_entry *const &a, } int ape_rcompare (Accidental_placement_entry *const &a, - Accidental_placement_entry *const &b) + Accidental_placement_entry *const &b) { return -sign (ape_priority (a) - ape_priority (b)); } - /* - -TODO: should favor + TODO: should favor b - b + b -placement - + placement */ void stagger_apes (Link_array *apes) { Link_array asc = *apes; - asc.sort (&ape_compare); apes->clear (); @@ -192,7 +181,7 @@ stagger_apes (Link_array *apes) int parity = 1; while (i < asc.size ()) { - Accidental_placement_entry * a = 0; + Accidental_placement_entry *a = 0; if (parity) a = asc.pop (); else @@ -205,68 +194,63 @@ stagger_apes (Link_array *apes) apes->reverse (); } - - /* - This routine computes placements of accidentals. During add_accidental (), accidentals are already grouped by note, so that octaves are placed above each other; they form columns. Then the columns are sorted: the biggest columns go closest to the note. Then the columns are spaced as closely as possible (using skyline spacing). - - + + TODO: more advanced placement. Typically, the accs should be placed to form a C shape, like this - - ## - b b - # # - b - b b - The naturals should be left of the C as well; they should - be separate accs. + ## + b b + # # + b + b b - Note that this placement problem looks NP hard, so we just use a - simple strategy, not an optimal choice. + The naturals should be left of the C as well; they should + be separate accs. + Note that this placement problem looks NP hard, so we just use a + simple strategy, not an optimal choice. */ /* TODO: there should be more space in the following situation - Natural + downstem + Natural + downstem - |_ - | | X - |_| | - | | - - */ + |_ + | | X + |_| | + | | +*/ SCM -Accidental_placement::position_accidentals (Grob * me) +Accidental_placement::position_accidentals (Grob *me) { if (!me->is_live ()) return SCM_UNSPECIFIED; - + SCM accs = me->get_property ("accidental-grobs"); if (!scm_is_pair (accs)) return SCM_UNSPECIFIED; - + /* TODO: there is a bug in this code. If two accs are on the same Y-position, they share an Ape, and will be printed in overstrike. - */ + */ Link_array apes; for (SCM s = accs; scm_is_pair (s); s = scm_cdr (s)) { Accidental_placement_entry *ape = new Accidental_placement_entry; ape->notename_ = scm_to_int (scm_caar (s)); - + for (SCM t = scm_cdar (s); scm_is_pair (t); t = scm_cdr (t)) ape->grobs_.push (unsmob_grob (scm_car (t))); @@ -278,23 +262,23 @@ Accidental_placement::position_accidentals (Grob * me) /* First we must extract *all* pointers. We can only determine extents if we're sure that we've found the right common refpoint - */ + */ Link_array note_cols, heads; for (int i = apes.size (); i--;) - { - Accidental_placement_entry * ape = apes[i]; + { + Accidental_placement_entry *ape = apes[i]; for (int j = ape->grobs_.size (); j--;) { - Grob * a = ape->grobs_[j]; + Grob *a = ape->grobs_[j]; if (common[Y_AXIS]) common[Y_AXIS] = common[Y_AXIS]->common_refpoint (a, Y_AXIS); else common[Y_AXIS] = a; - + Grob *head = a->get_parent (Y_AXIS); - Grob * col = head->get_parent (X_AXIS); + Grob *col = head->get_parent (X_AXIS); if (Note_column::has_interface (col)) note_cols.push (col); else @@ -305,20 +289,20 @@ Accidental_placement::position_accidentals (Grob * me) /* This is a little kludgy: to get all notes, we look if there are collisions as well. - */ - for (int i = note_cols.size () ; i--;) + */ + for (int i = note_cols.size (); i--;) { Grob *c = note_cols[i]->get_parent (X_AXIS); if (Note_collision_interface::has_interface (c)) { - Link_array gs = - extract_grob_array (c, ly_symbol2scm ("elements")); - + Link_array gs + = extract_grob_array (c, ly_symbol2scm ("elements")); + note_cols.concat (gs); } } - - for (int i = note_cols.size () ; i--;) + + for (int i = note_cols.size (); i--;) { heads.concat (extract_grob_array (note_cols[i], ly_symbol2scm ("note-heads"))); } @@ -326,34 +310,32 @@ Accidental_placement::position_accidentals (Grob * me) heads.uniq (); common[Y_AXIS] = common_refpoint_of_array (heads, common[Y_AXIS], Y_AXIS); - for (int i = apes.size (); i--;) { - Accidental_placement_entry * ape = apes[i]; + Accidental_placement_entry *ape = apes[i]; ape->left_skyline_ = empty_skyline (LEFT); ape->right_skyline_ = empty_skyline (RIGHT); - + for (int j = apes[i]->grobs_.size (); j--;) { - Grob * a = apes[i]->grobs_[j]; + Grob *a = apes[i]->grobs_[j]; Array boxes = Accidental_interface::accurate_boxes (a, common); - + ape->extents_.concat (boxes); - for (int j = boxes.size (); j--;) + for (int j = boxes.size (); j--;) { insert_extent_into_skyline (&ape->left_skyline_, boxes[j], Y_AXIS, LEFT); - insert_extent_into_skyline (&ape->right_skyline_ , boxes[j], Y_AXIS, RIGHT); + insert_extent_into_skyline (&ape->right_skyline_, boxes[j], Y_AXIS, RIGHT); } } } - Interval total; for (int i = apes.size (); i--;) { - Interval y ; - + Interval y; + for (int j = apes[i]->extents_.size (); j--;) { y.unite (apes[i]->extents_[j][Y_AXIS]); @@ -364,16 +346,16 @@ Accidental_placement::position_accidentals (Grob * me) all_accidental_vertical_extent = total; stagger_apes (&apes); - Accidental_placement_entry * head_ape = new Accidental_placement_entry; - common[X_AXIS] = common_refpoint_of_array (heads, common[X_AXIS], X_AXIS); + Accidental_placement_entry *head_ape = new Accidental_placement_entry; + common[X_AXIS] = common_refpoint_of_array (heads, common[X_AXIS], X_AXIS); Array head_skyline (empty_skyline (LEFT)); Array head_extents; for (int i = heads.size (); i--;) { - Box b (heads[i]->extent (common[X_AXIS] , X_AXIS), - heads[i]->extent (common[Y_AXIS], Y_AXIS)); + Box b (heads[i]->extent (common[X_AXIS], X_AXIS), + heads[i]->extent (common[Y_AXIS], Y_AXIS)); - insert_extent_into_skyline (&head_skyline, b , Y_AXIS, LEFT); + insert_extent_into_skyline (&head_skyline, b, Y_AXIS, LEFT); } head_ape-> left_skyline_ = head_skyline; @@ -386,13 +368,13 @@ Accidental_placement::position_accidentals (Grob * me) -robust_scm2double (me->get_property ("right-padding"), 0)); /* Add accs entries right-to-left. - */ + */ for (int i = apes.size (); i-- > 0;) { - Real offset = - -skyline_meshing_distance (apes[i]->right_skyline_, left_skyline); + Real offset + = -skyline_meshing_distance (apes[i]->right_skyline_, left_skyline); if (isinf (offset)) - offset = (i < apes.size () - 1) ? apes[i+1]->offset_ : 0.0; + offset = (i < apes.size () - 1) ? apes[i + 1]->offset_ : 0.0; else offset -= padding; @@ -402,35 +384,33 @@ Accidental_placement::position_accidentals (Grob * me) heighten_skyline (&new_left_skyline, apes[i]->offset_); merge_skyline (&new_left_skyline, left_skyline, LEFT); left_skyline = new_left_skyline; - } + } for (int i = apes.size (); i--;) { - Accidental_placement_entry* ape = apes[i]; - for (int j = ape->grobs_.size (); j--;) + Accidental_placement_entry *ape = apes[i]; + for (int j = ape->grobs_.size (); j--;) { ape->grobs_[j]->translate_axis (ape->offset_, X_AXIS); } } - Interval left_extent, right_extent; Accidental_placement_entry *ape = apes[0]; for (int i = ape->extents_.size (); i--;) - left_extent.unite (ape->offset_ + ape->extents_[i][X_AXIS]); + left_extent.unite (ape->offset_ + ape->extents_[i][X_AXIS]); ape = apes.top (); for (int i = ape->extents_.size (); i--;) - right_extent.unite (ape->offset_ + ape->extents_[i][X_AXIS]); + right_extent.unite (ape->offset_ + ape->extents_[i][X_AXIS]); - left_extent[LEFT] -= robust_scm2double (me->get_property ("left-padding"), 0); Interval width (left_extent[LEFT], right_extent[RIGHT]); SCM scm_width = ly_interval2scm (width); me->set_extent (scm_width, X_AXIS); - + for (int i = apes.size (); i--;) delete apes[i]; @@ -438,6 +418,6 @@ Accidental_placement::position_accidentals (Grob * me) } ADD_INTERFACE (Accidental_placement, - "accidental-placement-interface", - "Resolve accidental collisions.", - "left-padding padding right-padding accidental-grobs positioning-done") + "accidental-placement-interface", + "Resolve accidental collisions.", + "left-padding padding right-padding accidental-grobs positioning-done") diff --git a/lily/accidental.cc b/lily/accidental.cc index 54c68cb640..9aab78202a 100644 --- a/lily/accidental.cc +++ b/lily/accidental.cc @@ -2,7 +2,7 @@ accidental.cc -- implement Accidental_interface source file of the GNU LilyPond music typesetter - + (c) 2001--2005 Han-Wen Nienhuys */ @@ -14,16 +14,14 @@ #include "pitch.hh" /* - TODO: insert support for smaller cautionaries, tie-break-reminders. Either here or in new-accidental-engraver. 'accidentals should go, for a single 'accidental property -- see accidental-placement.cc - */ Stencil -parenthesize (Grob*me, Stencil m) +parenthesize (Grob *me, Stencil m) { Stencil open = Font_interface::get_default_font (me)->find_by_name ("accidentals.leftparen"); Stencil close = Font_interface::get_default_font (me)->find_by_name ("accidentals.rightparen"); @@ -34,12 +32,11 @@ parenthesize (Grob*me, Stencil m) return m; } - MAKE_SCHEME_CALLBACK (Accidental_interface, after_line_breaking, 1); SCM Accidental_interface::after_line_breaking (SCM smob) { - Grob *me = unsmob_grob (smob); + Grob *me = unsmob_grob (smob); Grob *tie = unsmob_grob (me->get_property ("tie")); if (tie && !tie->original_) @@ -50,14 +47,14 @@ Accidental_interface::after_line_breaking (SCM smob) } Array -Accidental_interface::accurate_boxes (Grob *a, Grob**common) +Accidental_interface::accurate_boxes (Grob *a, Grob **common) { Box b; b[X_AXIS] = a->extent (a, X_AXIS); b[Y_AXIS] = a->extent (a, Y_AXIS); Array boxes; - + bool parens = false; if (to_boolean (a->get_property ("cautionary"))) { @@ -72,194 +69,193 @@ Accidental_interface::accurate_boxes (Grob *a, Grob**common) && scm_ilength (accs) == 1) { switch (scm_to_int (scm_car (accs)) - { - case FLAT: { - Box stem = b; - Box bulb = b; + case FLAT: + { + Box stem = b; + Box bulb = b; + + /* + we could make the stem thinner, but that places the flats + really close. + */ + stem[X_AXIS][RIGHT] *= .5; + + /* + To prevent vertical alignment for 6ths + */ + stem[Y_AXIS] *= 1.1; + bulb[Y_AXIS][UP] *= .35; + + boxes.push (bulb); + boxes.push (stem); + } + break; + case NATURAL: + { + Box lstem = b; + Box rstem = b; + Box belly = b; + lstem[Y_AXIS] *= 1.1; + rstem[Y_AXIS] *= 1.1; + + belly[Y_AXIS] *= 0.75; + lstem[X_AXIS][RIGHT] *= .5; + rstem[X_AXIS][LEFT] = lstem[X_AXIS][RIGHT]; + lstem[Y_AXIS][DOWN] = belly[Y_AXIS][DOWN]; + rstem[Y_AXIS][UP] = belly[Y_AXIS][UP]; + boxes.push (belly); + boxes.push (lstem); + boxes.push (rstem); + } + break; /* - we could make the stem thinner, but that places the flats - really close. + TODO: add support for, double flat. */ - stem[X_AXIS][RIGHT] *= .5; + } - /* - To prevent vertical alignment for 6ths - */ - stem[Y_AXIS] *= 1.1; - bulb[Y_AXIS][UP] *= .35; + if (!boxes.size ()) + boxes.push (b); + + Offset o (a->relative_coordinate (common[X_AXIS], X_AXIS), + a->relative_coordinate (common[Y_AXIS], Y_AXIS)); + for (int i = boxes.size (); i--;) + { + boxes[i].translate (o); + } + + return boxes; + } - boxes.push (bulb); - boxes.push (stem); - } - break; - case NATURAL: - { - Box lstem = b; - Box rstem = b; - Box belly = b; - - lstem[Y_AXIS] *= 1.1; - rstem[Y_AXIS] *= 1.1; - - belly[Y_AXIS] *= 0.75; - lstem[X_AXIS][RIGHT] *= .5; - rstem[X_AXIS][LEFT] = lstem[X_AXIS][RIGHT]; - lstem[Y_AXIS][DOWN] = belly[Y_AXIS][DOWN]; - rstem[Y_AXIS][UP] = belly[Y_AXIS][UP]; - boxes.push (belly); - boxes.push (lstem); - boxes.push (rstem); - } - break; /* - TODO: add support for, double flat. + * Some styles do not provide all flavours of accidentals, e.g. there + * is currently no sharp accidental in vaticana style. In these cases + * this function falls back to one of the other styles. */ - } - - if (!boxes.size ()) - boxes.push (b); - Offset o (a->relative_coordinate (common[X_AXIS], X_AXIS), - a->relative_coordinate (common[Y_AXIS], Y_AXIS)); - for (int i = boxes.size (); i--;) - { - boxes[i].translate (o); - } - - return boxes; -} + /* + todo: this sort of stuff in Scheme. --hwn. + */ + String + Accidental_interface::get_fontcharname (String style, int alteration) + { + if (alteration == DOUBLE_FLAT + || alteration == DOUBLE_SHARP) + { + return to_string (alteration); + } -/* - * Some styles do not provide all flavours of accidentals, e.g. there - * is currently no sharp accidental in vaticana style. In these cases - * this function falls back to one of the other styles. - */ + if (style == "hufnagel") + switch (alteration) + { + case FLAT: return "hufnagel-1"; + case 0: return "vaticana0"; + case SHARP: return "mensural1"; + } + if (style == "medicaea") + switch (alteration) + { + case FLAT: return "medicaea-1"; + case 0: return "vaticana0"; + case SHARP: return "mensural1"; + } + if (style == "vaticana") + switch (alteration) + { + case FLAT: return "vaticana-1"; + case 0: return "vaticana0"; + case SHARP: return "mensural1"; + } + if (style == "mensural") + switch (alteration) + { + case FLAT: return "mensural-1"; + case 0: return "vaticana0"; + case SHARP: return "mensural1"; + } -/* - todo: this sort of stuff in Scheme. --hwn. - */ -String -Accidental_interface::get_fontcharname (String style, int alteration) -{ - if (alteration == DOUBLE_FLAT - || alteration == DOUBLE_SHARP) - { - return to_string (alteration); - } - - if (style == "hufnagel") - switch (alteration) - { - case FLAT: return "hufnagel-1"; - case 0: return "vaticana0"; - case SHARP: return "mensural1"; - } - if (style == "medicaea") - switch (alteration) - { - case FLAT: return "medicaea-1"; - case 0: return "vaticana0"; - case SHARP: return "mensural1"; + if (style == "neomensural") + style = ""; // currently same as default + if (style == "default") + style = ""; + return style + to_string (alteration); } - if (style == "vaticana") - switch (alteration) - { - case FLAT: return "vaticana-1"; - case 0: return "vaticana0"; - case SHARP: return "mensural1"; - } - if (style == "mensural") - switch (alteration) + + MAKE_SCHEME_CALLBACK (Accidental_interface, print, 1); + SCM + Accidental_interface::print (SCM smob) { - case FLAT: return "mensural-1"; - case 0: return "vaticana0"; - case SHARP: return "mensural1"; - } - - if (style == "neomensural") - style = ""; // currently same as default - if (style == "default") - style = ""; - return style + to_string (alteration); -} + Grob *me = unsmob_grob (smob); + bool smaller = false; + bool parens = false; -MAKE_SCHEME_CALLBACK (Accidental_interface, print, 1); -SCM -Accidental_interface::print (SCM smob) -{ - Grob *me = unsmob_grob (smob); - bool smaller = false; - bool parens = false; + bool caut = to_boolean (me->get_property ("cautionary")); + if (caut) + { + SCM cstyle = me->get_property ("cautionary-style"); + parens = ly_c_equal_p (cstyle, ly_symbol2scm ("parentheses")); + smaller = ly_c_equal_p (cstyle, ly_symbol2scm ("smaller")); + } - bool caut = to_boolean (me->get_property ("cautionary")); - if (caut) - { - SCM cstyle = me->get_property ("cautionary-style"); - parens = ly_c_equal_p (cstyle, ly_symbol2scm ("parentheses")); - smaller = ly_c_equal_p (cstyle, ly_symbol2scm ("smaller")); - } + SCM scm_style = me->get_property ("style"); + String style; + if (scm_is_symbol (scm_style)) + { + style = ly_symbol2string (scm_style); + } + else + { + /* + preferably no name for the default style. + */ + style = ""; + } - SCM scm_style = me->get_property ("style"); - String style; - if (scm_is_symbol (scm_style)) - { - style = ly_symbol2string (scm_style); - } - else - { - /* - preferably no name for the default style. - */ - style = ""; - } + Font_metric *fm = 0; + if (smaller) + { + SCM ac = Font_interface::music_font_alist_chain (me); + /* + TODO: should calc font-size by adding -2 to current font-size + */ + ac = scm_cons (scm_list_1 (scm_cons + (ly_symbol2scm ("font-size"), + scm_int2num (-2))), + ac); + fm = select_font (me->get_layout (), ac); + } + else + fm = Font_interface::get_default_font (me); - Font_metric *fm = 0; - if (smaller) - { - SCM ac = Font_interface::music_font_alist_chain (me); - /* - TODO: should calc font-size by adding -2 to current font-size - */ - ac = scm_cons (scm_list_1 (scm_cons - (ly_symbol2scm ("font-size"), - scm_int2num (-2))), - ac); - fm = select_font (me->get_layout (), ac); - } - else - fm = Font_interface::get_default_font (me); + Stencil mol; + for (SCM s = me->get_property ("accidentals"); + scm_is_pair (s); s = scm_cdr (s)) + { + int alteration = scm_to_int (scm_car (s)); + String font_char = get_fontcharname (style, alteration); + Stencil acc (fm->find_by_name ("accidentals." + font_char)); - Stencil mol; - for (SCM s = me->get_property ("accidentals"); - scm_is_pair (s); s = scm_cdr (s)) - { - int alteration = scm_to_int (scm_car (s)); - String font_char = get_fontcharname (style, alteration); - Stencil acc (fm->find_by_name ("accidentals." + font_char)); - - if (acc.is_empty ()) - { - me->warning (_f ("accidental `%s' not found", font_char)); - } - else - { - mol.add_at_edge (X_AXIS, RIGHT, acc, 0.1, 0); - } - } + if (acc.is_empty ()) + { + me->warning (_f ("accidental `%s' not found", font_char)); + } + else + { + mol.add_at_edge (X_AXIS, RIGHT, acc, 0.1, 0); + } + } - if (parens) - mol = parenthesize (me, mol); + if (parens) + mol = parenthesize (me, mol); - return mol.smobbed_copy (); -} + return mol.smobbed_copy (); + } + /* + TODO: should move inside-slur into item? -/* - TODO: should move inside-slur into item? - - */ -ADD_INTERFACE (Accidental_interface, "accidental-interface", - "a single accidental", - "inside-slur cautionary cautionary-style style tie accidentals"); + */ + ADD_INTERFACE (Accidental_interface, "accidental-interface", + "a single accidental", + "inside-slur cautionary cautionary-style style tie accidentals"); diff --git a/lily/afm.cc b/lily/afm.cc index 0bc5aac07d..8a1b6a8570 100644 --- a/lily/afm.cc +++ b/lily/afm.cc @@ -1,11 +1,10 @@ -/* +/* afm.cc -- implement Adobe_font_metric - + source file of the GNU LilyPond music typesetter - + (c) 2000--2005 Han-Wen Nienhuys - - */ +*/ #include "afm.hh" @@ -20,16 +19,16 @@ Adobe_font_metric::Adobe_font_metric (AFM_Font_info *fi) checksum_ = 0; font_info_ = fi; design_size_ = 1.0; - + for (int i = 256 >? fi->numOfChars; i--;) ascii_to_metric_idx_.push (-1); - + for (int i = 0; i < fi->numOfChars; i++) { - AFM_CharMetricInfo * c = fi->cmi + i; + AFM_CharMetricInfo *c = fi->cmi + i; /* Some TeX afm files contain code = -1. We don't know why, - let's ignore it. */ + let's ignore it. */ if (c->code >= 0) ascii_to_metric_idx_[c->code] = i; name_to_metric_dict_[c->name] = i; @@ -48,11 +47,11 @@ Adobe_font_metric::make_afm (AFM_Font_info *fi, { Adobe_font_metric *fm = new Adobe_font_metric (fi); fm->checksum_ = checksum; - fm->design_size_ = design_size; - return fm->self_scm (); + fm->design_size_ = design_size; + return fm->self_scm (); } -AFM_CharMetricInfo const* +AFM_CharMetricInfo const * Adobe_font_metric::find_ascii_metric (int a) const { if (ascii_to_metric_idx_[a] >= 0) @@ -64,7 +63,7 @@ Adobe_font_metric::find_ascii_metric (int a) const return 0; } -AFM_CharMetricInfo const* +AFM_CharMetricInfo const * Adobe_font_metric::find_char_metric (String nm) const { int idx = name_to_index (nm); @@ -76,10 +75,10 @@ Adobe_font_metric::find_char_metric (String nm) const int Adobe_font_metric::name_to_index (String name) const { - std::map::const_iterator ai = name_to_metric_dict_.find (name); + std::map < String, int>::const_iterator ai = name_to_metric_dict_.find (name); if (ai == name_to_metric_dict_.end ()) return -1; - return (*ai).second; + return (*ai).second; } int @@ -94,7 +93,7 @@ Adobe_font_metric::get_ascii_char (int code) const AFM_CharMetricInfo const *c = find_ascii_metric (code); Box b (Interval (0, 0), Interval (0, 0)); if (c) - b = afm_bbox_to_box (c->charBBox); + b = afm_bbox_to_box (c->charBBox); return b; } @@ -116,14 +115,14 @@ Adobe_font_metric::get_indexed_char (int code) const SCM read_afm_file (String nm) { - FILE *f = fopen (nm.to_str0 () , "r"); + FILE *f = fopen (nm.to_str0 (), "r"); char s[2048] = ""; char *check_key = "Comment TfmCheckSum"; char *size_key = "Comment DesignSize"; unsigned int cs = 0; Real ds = 1.0; - + /* Assume check_key in first 10 lines */ for (int i = 0; i < 10; i++) { @@ -133,9 +132,9 @@ read_afm_file (String nm) else if (strncmp (s, size_key, strlen (size_key)) == 0) sscanf (s + strlen (size_key), "%lf", &ds); } - + rewind (f); - + AFM_Font_info *fi; int ok = AFM_parseFile (f, &fi, ~0); @@ -175,11 +174,9 @@ Adobe_font_metric::get_indexed_wxwy (int k) const Real Adobe_font_metric::design_size () const { - return design_size_; + return design_size_; } - - String Adobe_font_metric::font_name () const { diff --git a/lily/align-interface.cc b/lily/align-interface.cc index 89c1991077..7ebe4f33cc 100644 --- a/lily/align-interface.cc +++ b/lily/align-interface.cc @@ -1,11 +1,10 @@ -/* +/* align-interface.cc -- implement Align_interface - + source file of the GNU LilyPond music typesetter - + (c) 2000--2005 Han-Wen Nienhuys - - */ +*/ #include "align-interface.hh" @@ -17,9 +16,9 @@ MAKE_SCHEME_CALLBACK (Align_interface, alignment_callback, 2); SCM Align_interface::alignment_callback (SCM element_smob, SCM axis) { - Grob * me = unsmob_grob (element_smob); + Grob *me = unsmob_grob (element_smob); Axis ax = (Axis)scm_to_int (axis); - Grob * par = me->get_parent (ax); + Grob *par = me->get_parent (ax); if (par && !to_boolean (par->get_property ("positioning-done"))) { Align_interface::align_elements_to_extents (par, ax); @@ -31,9 +30,9 @@ MAKE_SCHEME_CALLBACK (Align_interface, fixed_distance_alignment_callback, 2); SCM Align_interface::fixed_distance_alignment_callback (SCM element_smob, SCM axis) { - Grob * me = unsmob_grob (element_smob); + Grob *me = unsmob_grob (element_smob); Axis ax = (Axis)scm_to_int (axis); - Grob * par = me->get_parent (ax); + Grob *par = me->get_parent (ax); if (par && !to_boolean (par->get_property ("positioning-done"))) { Align_interface::align_to_fixed_distance (par, ax); @@ -42,21 +41,21 @@ Align_interface::fixed_distance_alignment_callback (SCM element_smob, SCM axis) } /* - merge with align-to-extents? - */ + merge with align-to-extents? +*/ void -Align_interface::align_to_fixed_distance (Grob *me , Axis a) +Align_interface::align_to_fixed_distance (Grob *me, Axis a) { me->set_property ("positioning-done", SCM_BOOL_T); - - SCM d = me->get_property ("stacking-dir"); - + + SCM d = me->get_property ("stacking-dir"); + Direction stacking_dir = scm_is_number (d) ? to_dir (d) : CENTER; if (!stacking_dir) stacking_dir = DOWN; Real dy = robust_scm2double (me->get_property ("forced-distance"), 0.0); - + Link_array elems = extract_grob_array (me, ly_symbol2scm ("elements")); @@ -65,8 +64,8 @@ Align_interface::align_to_fixed_distance (Grob *me , Axis a) Interval v; v.set_empty (); Array translates; - - for (int j = elems.size (); j--; ) + + for (int j = elems.size (); j--;) { /* This is not very elegant, in that we need special support for @@ -74,9 +73,9 @@ Align_interface::align_to_fixed_distance (Grob *me , Axis a) force_hara_kiri_callback () (extent and offset callback) is such that we might get into a loop if we call extent () or offset () the elements. - - - */ + + + */ if (a == Y_AXIS && Hara_kiri_group_spanner::has_interface (elems[j])) Hara_kiri_group_spanner::consider_suicide (elems[j]); @@ -94,7 +93,7 @@ Align_interface::align_to_fixed_distance (Grob *me , Axis a) /* TODO: support self-alignment-{Y, X} - */ + */ for (int i = 0; i < translates.size (); i++) { elems[i]->translate_axis (translates[i] - v.center (), a); @@ -117,68 +116,66 @@ Align_interface::align_to_fixed_distance (Grob *me , Axis a) align_to_fixed_distance (). */ void -Align_interface::align_elements_to_extents (Grob * me, Axis a) +Align_interface::align_elements_to_extents (Grob *me, Axis a) { me->set_property ("positioning-done", SCM_BOOL_T); - - SCM d = me->get_property ("stacking-dir"); - + + SCM d = me->get_property ("stacking-dir"); + Direction stacking_dir = scm_is_number (d) ? to_dir (d) : CENTER; if (!stacking_dir) stacking_dir = DOWN; - + Interval threshold = robust_scm2interval (me->get_property ("threshold"), Interval (0, Interval::infinity ())); - + Array dims; Link_array elems; Link_array all_grobs = extract_grob_array (me, ly_symbol2scm ("elements")); - for (int i = 0; i < all_grobs.size (); i++) + for (int i = 0; i < all_grobs.size (); i++) { Interval y = all_grobs[i]->extent (me, a); if (!y.is_empty ()) { - Grob *e = dynamic_cast (all_grobs[i]); + Grob *e = dynamic_cast (all_grobs[i]); elems.push (e); - dims.push (y); + dims.push (y); } } - - + /* Read self-alignment-X and self-alignment-Y. This may seem like code duplication. (and really: it is), but this is necessary to prevent ugly cyclic dependencies that arise when you combine self-alignment on a child with alignment of children. */ - static SCM prop_syms[2]; + static SCM prop_syms[2]; if (!prop_syms[0]) { prop_syms[X_AXIS] = ly_symbol2scm ("self-alignment-X"); prop_syms[Y_AXIS] = ly_symbol2scm ("self-alignment-Y"); } - + SCM align (me->internal_get_property (prop_syms[a])); - - Array translates ; + + Array translates; Interval total; Real where_f = 0; - - for (int j = 0 ; j < elems.size (); j++) + + for (int j = 0; j < elems.size (); j++) { - Real dy = - dims[j][-stacking_dir]; + Real dy = -dims[j][-stacking_dir]; if (j) - dy += dims[j-1][stacking_dir]; - + dy += dims[j - 1][stacking_dir]; /* we want dy to be > 0 - */ - dy *= stacking_dir; + */ + dy *= stacking_dir; if (j) { dy = (dy >? threshold[SMALLER]) @@ -186,14 +183,13 @@ Align_interface::align_elements_to_extents (Grob * me, Axis a) } where_f += stacking_dir * dy; - total.unite (dims[j] + where_f); + total.unite (dims[j] + where_f); translates.push (where_f); } - Real center_offset = 0.0; /* - also move the grobs that were empty, to maintain spatial order. + also move the grobs that were empty, to maintain spatial order. */ Array all_translates; if (translates.size ()) @@ -201,7 +197,7 @@ Align_interface::align_elements_to_extents (Grob * me, Axis a) int i = 0; int j = 0; Real w = translates[0]; - while (j < all_grobs.size ()) + while (j < all_grobs.size ()) { if (i < elems.size () && all_grobs[j] == elems[i]) { @@ -211,45 +207,43 @@ Align_interface::align_elements_to_extents (Grob * me, Axis a) j++; } - /* FIXME: uncommenting freaks out the Y-alignment of line-of-score. - */ + */ if (scm_is_number (align)) center_offset = total.linear_combination (scm_to_double (align)); - for (int j = 0 ; j < all_grobs.size (); j++) + for (int j = 0; j < all_grobs.size (); j++) all_grobs[j]->translate_axis (all_translates[j] - center_offset, a); } } Axis -Align_interface::axis (Grob*me) +Align_interface::axis (Grob *me) { - return Axis (scm_to_int (scm_car (me->get_property ("axes")))); + return Axis (scm_to_int (scm_car (me->get_property ("axes")))); } void -Align_interface::add_element (Grob*me, Grob* s, SCM cb) +Align_interface::add_element (Grob *me, Grob *s, SCM cb) { s->add_offset_callback (cb, Align_interface::axis (me)); Axis_group_interface::add_element (me, s); } void -Align_interface::set_axis (Grob*me, Axis a) +Align_interface::set_axis (Grob *me, Axis a) { Axis_group_interface::set_axes (me, a, a); } - /* Find Y-axis parent of G that has a #'forced-distance property. This has the effect of finding the piano-staff given an object in that piano staff. - */ +*/ Grob * -find_fixed_alignment_parent (Grob *g) +find_fixed_alignment_parent (Grob *g) { while (g) { @@ -263,18 +257,14 @@ find_fixed_alignment_parent (Grob *g) } - - ADD_INTERFACE (Align_interface, "align-interface", "Order grobs from top to bottom, left to right, right to left or bottom" - "to top." - , + "to top.", "forced-distance stacking-dir align-dir threshold positioning-done " "center-element elements axes"); - struct Foobar { - bool has_interface (Grob*); + bool has_interface (Grob *); }; diff --git a/lily/all-font-metrics.cc b/lily/all-font-metrics.cc index 423243ac68..6eb62bf103 100644 --- a/lily/all-font-metrics.cc +++ b/lily/all-font-metrics.cc @@ -1,8 +1,8 @@ /* all-font-metrics.cc -- implement All_font_metrics - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys */ @@ -25,19 +25,19 @@ All_font_metrics::All_font_metrics (String path) otf_dict_ = new Scheme_hash_table; #if HAVE_PANGO_FT2 - PangoFontMap*pfm = pango_ft2_font_map_new (); + PangoFontMap *pfm = pango_ft2_font_map_new (); - pango_ft2_fontmap_ = - G_TYPE_CHECK_INSTANCE_CAST(pfm, - PANGO_TYPE_FT2_FONT_MAP, - PangoFT2FontMap); + pango_ft2_fontmap_ + = G_TYPE_CHECK_INSTANCE_CAST (pfm, + PANGO_TYPE_FT2_FONT_MAP, + PangoFT2FontMap); pango_dpi_ = 1200; pango_ft2_font_map_set_resolution (pango_ft2_fontmap_, pango_dpi_, pango_dpi_); pango_dict_ = new Scheme_hash_table; #endif - + search_path_.parse_path (path); } @@ -53,21 +53,21 @@ All_font_metrics::~All_font_metrics () #endif } -All_font_metrics::All_font_metrics (All_font_metrics const&) +All_font_metrics::All_font_metrics (All_font_metrics const &) { } #if HAVE_PANGO_FT2 Pango_font * -All_font_metrics::find_pango_font (PangoFontDescription*description, +All_font_metrics::find_pango_font (PangoFontDescription *description, Real magnification, Real output_scale) { pango_font_description_set_size (description, gint (magnification * pango_font_description_get_size (description))); - + gchar *fn = pango_font_description_to_filename (description); SCM key = ly_symbol2scm (fn); @@ -90,8 +90,8 @@ All_font_metrics::find_pango_font (PangoFontDescription*description, pf->description_ = scm_cons (SCM_BOOL_F, scm_make_real (1.0)); } - g_free (fn); - return dynamic_cast (unsmob_metrics (val)); + g_free (fn); + return dynamic_cast (unsmob_metrics (val)); } #endif @@ -99,15 +99,15 @@ All_font_metrics::find_pango_font (PangoFontDescription*description, String kpathsea_find_file (String name, String ext) { - name += "." + ext; + name += "." + ext; String path = global_path.find (name); - if (path.length() > 0) + if (path.length () > 0) return path; SCM kpath = ly_lily_module_constant ("ly:kpathsea-find-file"); if (ly_c_procedure_p (kpath)) { - SCM kp_result = scm_call_1 (kpath, scm_makfrom0str (name.to_str0())); + SCM kp_result = scm_call_1 (kpath, scm_makfrom0str (name.to_str0 ())); if (scm_is_string (kp_result)) return ly_scm2string (kp_result); } @@ -121,7 +121,7 @@ kpathsea_find_file (String name, String ext) should include design size when generating an AFM metric. ugr: copied from find_tfm. - */ +*/ Adobe_font_metric * All_font_metrics::find_afm (String name) { @@ -133,7 +133,7 @@ All_font_metrics::find_afm (String name) String file_name; if (file_name.is_empty ()) - file_name = search_path_.find (name + ".afm"); + file_name = search_path_.find (name + ".afm"); if (file_name.is_empty ()) { @@ -144,13 +144,13 @@ All_font_metrics::find_afm (String name) if (file_name.is_empty ()) return 0; - + if (be_verbose_global) progress_indication ("[" + file_name); val = read_afm_file (file_name); unsmob_metrics (val)->file_name_ = file_name; - - unsmob_metrics (val)->description_ = scm_cons (name_string, + + unsmob_metrics (val)->description_ = scm_cons (name_string, scm_make_real (1.0)); if (be_verbose_global) @@ -160,14 +160,14 @@ All_font_metrics::find_afm (String name) scm_gc_unprotect_object (val); Adobe_font_metric *afm - = dynamic_cast (unsmob_metrics (val)); + = dynamic_cast (unsmob_metrics (val)); /* Only check checksums if there is one. We take the risk that some file has valid checksum 0 */ if (afm->checksum_) { - Tex_font_metric * tfm = find_tfm (name); - + Tex_font_metric *tfm = find_tfm (name); + /* FIXME: better warning message (maybe check upon startup for feta16.afm, feta16.tfm?) */ if (tfm && tfm->info ().checksum != afm->checksum_) @@ -185,18 +185,18 @@ All_font_metrics::find_afm (String name) s += "\n"; s += _ ("Rerun with -V to show font paths."); s += "\n"; - s += _("A script for removing font-files is delivered with the source-code:"); + s += _ ("A script for removing font-files is delivered with the source-code:"); s += "\n"; s += "buildscripts/clean-fonts.sh"; error (s); } } } - - return dynamic_cast (unsmob_metrics (val)); + + return dynamic_cast (unsmob_metrics (val)); } -Open_type_font* +Open_type_font * All_font_metrics::find_otf (String name) { SCM sname = ly_symbol2scm (name.to_str0 ()); @@ -205,15 +205,15 @@ All_font_metrics::find_otf (String name) if (!otf_dict_->try_retrieve (sname, &val)) { String file_name; - + if (file_name.is_empty ()) - file_name = search_path_.find (name + ".otf"); + file_name = search_path_.find (name + ".otf"); if (file_name.is_empty ()) return 0; if (be_verbose_global) progress_indication ("[" + file_name); - + val = Open_type_font::make_otf (file_name); if (be_verbose_global) @@ -226,10 +226,10 @@ All_font_metrics::find_otf (String name) scm_gc_unprotect_object (val); } - return dynamic_cast (unsmob_metrics (val)); + return dynamic_cast (unsmob_metrics (val)); } -Tex_font_metric* +Tex_font_metric * All_font_metrics::find_tfm (String name) { SCM sname = ly_symbol2scm (name.to_str0 ()); @@ -238,7 +238,7 @@ All_font_metrics::find_tfm (String name) if (!tfm_dict_->try_retrieve (sname, &val)) { String file_name; - + if (file_name.is_empty ()) { /* FIXME: should add "cork-" prefix to lm* fonts. How to do @@ -249,13 +249,13 @@ All_font_metrics::find_tfm (String name) } if (file_name.is_empty ()) - file_name = search_path_.find (name + ".tfm"); + file_name = search_path_.find (name + ".tfm"); if (file_name.is_empty ()) return 0; if (be_verbose_global) progress_indication ("[" + file_name); - + val = Tex_font_metric::make_tfm (file_name); if (be_verbose_global) @@ -268,18 +268,18 @@ All_font_metrics::find_tfm (String name) scm_gc_unprotect_object (val); } - return dynamic_cast (unsmob_metrics (val)); + return dynamic_cast (unsmob_metrics (val)); } -Font_metric* +Font_metric * All_font_metrics::find_font (String name) { Font_metric *f = find_otf (name); - - if (!f && - (name.left_string (4) == "feta" - || name.left_string (8) == "parmesan" - || name.left_string (2) == "lm")) + + if (!f + && (name.left_string (4) == "feta" + || name.left_string (8) == "parmesan" + || name.left_string (2) == "lm")) { f = find_afm (name); if (!f) @@ -297,7 +297,7 @@ All_font_metrics::find_font (String name) warning (_f ("can't find font: `%s'", name.to_str0 ())); warning (_ ("Loading default font")); } - + String def_name = default_font_str0_; /* We're in emergency recovery mode here anyway, so don't try to do @@ -320,7 +320,6 @@ All_font_metrics::find_font (String name) All_font_metrics *all_fonts_global; - LY_DEFINE (ly_font_load, "ly:font-load", 1, 0, 0, (SCM name), "Load the font @var{name}. ") diff --git a/lily/ambitus-engraver.cc b/lily/ambitus-engraver.cc index 20193234a6..bca05e3120 100644 --- a/lily/ambitus-engraver.cc +++ b/lily/ambitus-engraver.cc @@ -4,9 +4,8 @@ source file of the GNU LilyPond music typesetter (c) 2002--2005 Juergen Reuter - + Han-Wen Nienhuys set_parent (heads_[DOWN], X_AXIS); Axis_group_interface::add_element (group_, ambitus_); - - is_typeset_ = false; -} + is_typeset_ = false; +} Ambitus_engraver::Ambitus_engraver () { @@ -108,7 +106,6 @@ Ambitus_engraver::stop_translation_timestep () start_c0_ = robust_scm2int (get_property ("middleCPosition"), 0); start_key_sig_ = get_property ("keySignature"); - is_typeset_ = true; } } @@ -116,7 +113,7 @@ Ambitus_engraver::stop_translation_timestep () void Ambitus_engraver::acknowledge_grob (Grob_info info) { - Item *item = dynamic_cast (info.grob_); + Item *item = dynamic_cast (info.grob_); if (item) { if (Note_head::has_interface (info.grob_)) @@ -141,8 +138,8 @@ Ambitus_engraver::finalize () { Pitch p = pitch_interval_[d]; heads_[d]->set_property ("staff-position", - scm_from_int (start_c0_ + - p.steps ())); + scm_from_int (start_c0_ + + p.steps ())); SCM handle = scm_assoc (scm_cons (scm_from_int (p.get_octave ()), scm_from_int (p.get_notename ())), @@ -151,11 +148,11 @@ Ambitus_engraver::finalize () if (handle == SCM_BOOL_F) handle = scm_assoc (scm_from_int (p.get_notename ()), start_key_sig_); - + int sig_alter = (handle != SCM_BOOL_F) ? scm_to_int (scm_cdr (handle)) : 0; if (sig_alter == p.get_alteration ()) { - accidentals_[d]->suicide(); + accidentals_[d]->suicide (); heads_[d]->set_property ("accidental-grob", SCM_EOL); } else @@ -174,18 +171,18 @@ Ambitus_engraver::finalize () Direction d = DOWN; do { - accidentals_[d]->suicide(); - heads_[d]->suicide(); - } + accidentals_[d]->suicide (); + heads_[d]->suicide (); + } while (flip (&d) != DOWN); - ambitus_->suicide(); + ambitus_->suicide (); } } ADD_TRANSLATOR (Ambitus_engraver, -/* descr */ "", -/* creats*/ "Ambitus AmbitusLine AmbitusNoteHead AmbitusAccidental", -/* accepts */ "", -/* acks */ "note-head-interface", -/* reads */ "", -/* write */ ""); + /* descr */ "", + /* creats*/ "Ambitus AmbitusLine AmbitusNoteHead AmbitusAccidental", + /* accepts */ "", + /* acks */ "note-head-interface", + /* reads */ "", + /* write */ ""); diff --git a/lily/ambitus.cc b/lily/ambitus.cc index 43c9f0a01b..420c016834 100644 --- a/lily/ambitus.cc +++ b/lily/ambitus.cc @@ -21,22 +21,22 @@ MAKE_SCHEME_CALLBACK (Ambitus, print, 1); SCM Ambitus::print (SCM smob) { - Item *me = (Item*) unsmob_grob (smob); + Item *me = (Item *) unsmob_grob (smob); Stencil stencil; // join heads Link_array heads (extract_grob_array (me, ly_symbol2scm ("note-heads"))); if (to_boolean (me->get_property ("join-heads")) - && heads.size() > 1) + && heads.size () > 1) { Grob *common = common_refpoint_of_array (heads.slice (0, 2), me, Y_AXIS); Grob *minh = heads[0]; Grob *maxh = heads[1]; - - if (minh->relative_coordinate (common, Y_AXIS) > - maxh->relative_coordinate (common, Y_AXIS)) + + if (minh->relative_coordinate (common, Y_AXIS) + > maxh->relative_coordinate (common, Y_AXIS)) { Grob *t = maxh; maxh = minh; @@ -46,11 +46,11 @@ Ambitus::print (SCM smob) Real pad = 0.35; Real pmax = maxh->extent (common, Y_AXIS)[DOWN] - pad; Real pmin = minh->extent (common, Y_AXIS)[UP] + pad; - + if (pmin < pmax) { Real linethickness = me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness")) - * robust_scm2double (me->get_property ("thickness"), 1.0); + * robust_scm2double (me->get_property ("thickness"), 1.0); Real blotdiameter = me->get_layout ()->get_dimension (ly_symbol2scm ("blotdiameter")); Interval x_extent = 0.5 * linethickness *Interval (-1, 1); Interval y_extent = Interval (pmin, pmax); @@ -58,7 +58,7 @@ Ambitus::print (SCM smob) Stencil line = Lookup::round_filled_box (line_box, blotdiameter); line.translate_axis (- me-> relative_coordinate (common, Y_AXIS), - Y_AXIS); + Y_AXIS); return line.smobbed_copy (); } } @@ -67,5 +67,5 @@ Ambitus::print (SCM smob) } ADD_INTERFACE (Ambitus, "ambitus-interface", - "The line between note heads for a pitch range.", - "thickness note-heads join-heads"); + "The line between note heads for a pitch range.", + "thickness note-heads join-heads"); diff --git a/lily/apply-context-iterator.cc b/lily/apply-context-iterator.cc index ddb00b9df1..6f69bbc7b8 100644 --- a/lily/apply-context-iterator.cc +++ b/lily/apply-context-iterator.cc @@ -1,10 +1,9 @@ -/* +/* apply-context-iterator.cc -- implement Apply_context_iterator - + source file of the GNU LilyPond music typesetter - + (c) 2004--2005 Han-Wen Nienhuys - */ #include "simple-music-iterator.hh" @@ -13,8 +12,8 @@ #include "input.hh" /** - Iterate a property. - */ + Iterate a property. +*/ class Apply_context_iterator : public Simple_music_iterator { public: @@ -23,7 +22,6 @@ protected: virtual void process (Moment); }; - void Apply_context_iterator::process (Moment m) { @@ -32,10 +30,10 @@ Apply_context_iterator::process (Moment m) if (ly_c_procedure_p (proc)) scm_call_1 (proc, get_outlet ()->self_scm ()); else - get_music ()->origin ()->warning (_("\\applycontext argument is not a procedure")); - + get_music ()->origin ()->warning (_ ("\\applycontext argument is not a procedure")); + Simple_music_iterator::process (m); } IMPLEMENT_CTOR_CALLBACK (Apply_context_iterator); - + diff --git a/lily/arpeggio-engraver.cc b/lily/arpeggio-engraver.cc index d6667e098d..08682dd674 100644 --- a/lily/arpeggio-engraver.cc +++ b/lily/arpeggio-engraver.cc @@ -1,10 +1,10 @@ -/* +/* arpeggio-engraver.cc -- implement Arpeggio_engraver - + source file of the GNU LilyPond music typesetter - + (c) 2000--2005 Jan Nieuwenhuizen - */ +*/ #include "engraver.hh" #include "group-interface.hh" @@ -18,14 +18,14 @@ class Arpeggio_engraver : public Engraver { public: TRANSLATOR_DECLARATIONS (Arpeggio_engraver); - + protected: virtual void acknowledge_grob (Grob_info); virtual void process_music (); virtual void stop_translation_timestep (); virtual bool try_music (Music *); private: - Item *arpeggio_; + Item *arpeggio_; Music *arpeggio_req_; }; @@ -52,14 +52,14 @@ Arpeggio_engraver::acknowledge_grob (Grob_info info) { if (Stem::has_interface (info.grob_)) { - if (!arpeggio_->get_parent (Y_AXIS)) + if (!arpeggio_->get_parent (Y_AXIS)) arpeggio_->set_parent (info.grob_, Y_AXIS); - + Pointer_group_interface::add_grob (arpeggio_, ly_symbol2scm ("stems"), info.grob_); } - + /* We can't catch local key items (accidentals) from Voice context, see Local_key_engraver @@ -68,7 +68,7 @@ Arpeggio_engraver::acknowledge_grob (Grob_info info) { Side_position_interface::add_support (arpeggio_, info.grob_); } - else if (Note_column::has_interface (info.grob_ )) + else if (Note_column::has_interface (info.grob_)) { info.grob_->set_property ("arpeggio", arpeggio_->self_scm ()); } @@ -92,9 +92,9 @@ Arpeggio_engraver::stop_translation_timestep () } ADD_TRANSLATOR (Arpeggio_engraver, -/* descr */ "Generate an Arpeggio from a Arpeggio_req", -/* creats*/ "Arpeggio", -/* accepts */ "arpeggio-event", -/* acks */ "stem-interface rhythmic-head-interface note-column-interface", -/* reads */ "", -/* write */ ""); + /* descr */ "Generate an Arpeggio from a Arpeggio_req", + /* creats*/ "Arpeggio", + /* accepts */ "arpeggio-event", + /* acks */ "stem-interface rhythmic-head-interface note-column-interface", + /* reads */ "", + /* write */ ""); diff --git a/lily/arpeggio.cc b/lily/arpeggio.cc index 3ecd571675..0d432a4189 100644 --- a/lily/arpeggio.cc +++ b/lily/arpeggio.cc @@ -1,10 +1,10 @@ -/* +/* arpeggio.cc -- implement Arpeggio source file of the GNU LilyPond music typesetter - + (c) 2000--2005 Jan Nieuwenhuizen - */ +*/ #include "arpeggio.hh" @@ -16,24 +16,23 @@ #include "font-interface.hh" #include "lookup.hh" - MAKE_SCHEME_CALLBACK (Arpeggio, print, 1); -SCM -Arpeggio::print (SCM smob) +SCM +Arpeggio::print (SCM smob) { Grob *me = unsmob_grob (smob); - - Grob * common = me; + + Grob *common = me; for (SCM s = me->get_property ("stems"); scm_is_pair (s); s = scm_cdr (s)) { - Grob * stem = unsmob_grob (scm_car (s)); - common = common->common_refpoint (Staff_symbol_referencer::get_staff_symbol (stem), - Y_AXIS); + Grob *stem = unsmob_grob (scm_car (s)); + common = common->common_refpoint (Staff_symbol_referencer::get_staff_symbol (stem), + Y_AXIS); } /* TODO: - + Using stems here is not very convenient; should store noteheads instead, and also put them into the support. Now we will mess up in vicinity of a collision. @@ -41,14 +40,14 @@ Arpeggio::print (SCM smob) */ Interval heads; Real my_y = me->relative_coordinate (common, Y_AXIS); - + for (SCM s = me->get_property ("stems"); scm_is_pair (s); s = scm_cdr (s)) { - Grob * stem = unsmob_grob (scm_car (s)); - Grob * ss = Staff_symbol_referencer::get_staff_symbol (stem); + Grob *stem = unsmob_grob (scm_car (s)); + Grob *ss = Staff_symbol_referencer::get_staff_symbol (stem); Interval iv = Stem::head_positions (stem); - iv *= Staff_symbol::staff_space (ss)/2.0; - + iv *= Staff_symbol::staff_space (ss) / 2.0; + heads.unite (iv + ss->relative_coordinate (common, Y_AXIS) - my_y); } @@ -59,7 +58,7 @@ Arpeggio::print (SCM smob) Dumb blonde error :-) - */ + */ programming_error ("Huh, no heads for arpeggio found."); return SCM_EOL; } @@ -70,69 +69,68 @@ Arpeggio::print (SCM smob) { dir = to_dir (ad); } - + Stencil mol; Font_metric *fm = Font_interface::get_default_font (me); Stencil squiggle = fm->find_by_name ("scripts.arpeggio"); - Stencil arrow ; + Stencil arrow; if (dir) { arrow = fm->find_by_name ("scripts.arpeggio.arrow." + to_string (dir)); heads[dir] -= dir * arrow.extent (Y_AXIS).length (); } - - for (Real y = heads[LEFT] ; y < heads[RIGHT]; + + for (Real y = heads[LEFT]; y < heads[RIGHT]; y+= squiggle. extent (Y_AXIS).length ()) - mol.add_at_edge (Y_AXIS, UP, squiggle, 0.0, 0); + mol.add_at_edge (Y_AXIS, UP, squiggle, 0.0, 0); mol.translate_axis (heads[LEFT], Y_AXIS); if (dir) mol.add_at_edge (Y_AXIS, dir, arrow, 0, 0); - - return mol.smobbed_copy () ; + + return mol.smobbed_copy (); } -/* Draws a vertical bracket to the left of a chord +/* Draws a vertical bracket to the left of a chord Chris Jackson */ MAKE_SCHEME_CALLBACK (Arpeggio, brew_chord_bracket, 1); -SCM -Arpeggio::brew_chord_bracket (SCM smob) +SCM +Arpeggio::brew_chord_bracket (SCM smob) { Grob *me = unsmob_grob (smob); - - Grob * common = me; + + Grob *common = me; for (SCM s = me->get_property ("stems"); scm_is_pair (s); s = scm_cdr (s)) { - Grob * stem = unsmob_grob (scm_car (s)); - common = common->common_refpoint (Staff_symbol_referencer::get_staff_symbol (stem), - Y_AXIS); + Grob *stem = unsmob_grob (scm_car (s)); + common = common->common_refpoint (Staff_symbol_referencer::get_staff_symbol (stem), + Y_AXIS); } Interval heads; Real my_y = me->relative_coordinate (common, Y_AXIS); - + for (SCM s = me->get_property ("stems"); scm_is_pair (s); s = scm_cdr (s)) { - Grob * stem = unsmob_grob (scm_car (s)); - Grob * ss = Staff_symbol_referencer::get_staff_symbol (stem); + Grob *stem = unsmob_grob (scm_car (s)); + Grob *ss = Staff_symbol_referencer::get_staff_symbol (stem); Interval iv = Stem::head_positions (stem); - iv *= Staff_symbol::staff_space (ss)/2.0; - heads.unite (iv + ss->relative_coordinate (common, Y_AXIS) - my_y); + iv *= Staff_symbol::staff_space (ss) / 2.0; + heads.unite (iv + ss->relative_coordinate (common, Y_AXIS) - my_y); } - Real lt = me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness")); + Real lt = me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness")); Real sp = 1.5 * Staff_symbol_referencer::staff_space (me); Real dy = heads.length () + sp; Real x = 0.7; Stencil mol (Lookup::bracket (Y_AXIS, Interval (0, dy), lt, x, lt)); - mol.translate_axis (heads[LEFT] - sp/2.0, Y_AXIS); + mol.translate_axis (heads[LEFT] - sp / 2.0, Y_AXIS); return mol.smobbed_copy (); } - /* We have to do a callback, because print () triggers a vertical alignment if it is cross-staff. @@ -141,7 +139,7 @@ MAKE_SCHEME_CALLBACK (Arpeggio, width_callback, 2); SCM Arpeggio::width_callback (SCM smob, SCM axis) { - Grob * me = unsmob_grob (smob); + Grob *me = unsmob_grob (smob); Axis a = (Axis)scm_to_int (axis); assert (a == X_AXIS); Stencil arpeggio = Font_interface::get_default_font (me)->find_by_name ("scripts.arpeggio"); @@ -149,8 +147,7 @@ Arpeggio::width_callback (SCM smob, SCM axis) return ly_interval2scm (arpeggio.extent (X_AXIS)); } - ADD_INTERFACE (Arpeggio, "arpeggio-interface", - "Functions and settings for drawing an arpeggio symbol (a wavy line left to noteheads.", - "stems arpeggio-direction"); + "Functions and settings for drawing an arpeggio symbol (a wavy line left to noteheads.", + "stems arpeggio-direction"); diff --git a/lily/audio-column.cc b/lily/audio-column.cc index 197f2e649e..a37704ea83 100644 --- a/lily/audio-column.cc +++ b/lily/audio-column.cc @@ -4,7 +4,7 @@ source file of the GNU LilyPond music typesetter (c) 1997--2005 Jan Nieuwenhuizen - */ +*/ #include "audio-column.hh" @@ -17,10 +17,10 @@ Audio_column::Audio_column (Moment at_mom) } void -Audio_column::add_audio_item (Audio_item* l) +Audio_column::add_audio_item (Audio_item *l) { audio_items_.push (l); - l->audio_column_ = this; + l->audio_column_ = this; } Moment @@ -29,4 +29,3 @@ Audio_column::at_mom () const return at_mom_; } - diff --git a/lily/audio-element-info.cc b/lily/audio-element-info.cc index e3cd21d538..22bde52662 100644 --- a/lily/audio-element-info.cc +++ b/lily/audio-element-info.cc @@ -11,14 +11,13 @@ #include "translator-group.hh" #include "context.hh" -Audio_element_info::Audio_element_info (Audio_element*s, Music *r) +Audio_element_info::Audio_element_info (Audio_element *s, Music *r) { elem_ = s; origin_trans_ = 0; event_ = r; } - Audio_element_info::Audio_element_info () { elem_ = 0; @@ -26,16 +25,17 @@ Audio_element_info::Audio_element_info () origin_trans_ = 0; } - Link_array -Audio_element_info::origin_contexts (Translator* end) const +Audio_element_info::origin_contexts (Translator *end) const { - Context * t = origin_trans_->context (); + Context *t = origin_trans_->context (); Link_array r; - do { - r.push (t); - t = t->get_parent_context (); - } while (t && t != end->context ()); - + do + { + r.push (t); + t = t->get_parent_context (); + } + while (t && t != end->context ()); + return r; } diff --git a/lily/audio-element.cc b/lily/audio-element.cc index 84d56be3fb..c0dfcc22f1 100644 --- a/lily/audio-element.cc +++ b/lily/audio-element.cc @@ -16,7 +16,7 @@ Audio_element::~Audio_element () { } -char const * +char const * Audio_element::name () const { return classname (this); diff --git a/lily/audio-item.cc b/lily/audio-item.cc index 21d867a4a9..3774f732e9 100644 --- a/lily/audio-item.cc +++ b/lily/audio-item.cc @@ -30,17 +30,16 @@ Audio_note::Audio_note (Pitch p, Moment m, int transposing_i) } void -Audio_note::tie_to (Audio_note* t) +Audio_note::tie_to (Audio_note *t) { tied_ = t; - Audio_note* first = t; + Audio_note *first = t; while (first->tied_) first = first->tied_; first->length_mom_ += length_mom_; length_mom_ = 0; } - Audio_key::Audio_key (int acc, bool major) { accidentals_ = acc; diff --git a/lily/audio-staff.cc b/lily/audio-staff.cc index 7c3c944a28..b7508b8c25 100644 --- a/lily/audio-staff.cc +++ b/lily/audio-staff.cc @@ -4,7 +4,7 @@ source file of the GNU LilyPond music typesetter (c) 1997--2005 Jan Nieuwenhuizen - */ +*/ #include "audio-staff.hh" @@ -13,14 +13,13 @@ #include "midi-walker.hh" void -Audio_staff::add_audio_item (Audio_item* l) +Audio_staff::add_audio_item (Audio_item *l) { audio_items_.push (l); } - void -Audio_staff::output (Midi_stream& midi_stream_r, int track_i) +Audio_staff::output (Midi_stream &midi_stream_r, int track_i) { Midi_track midi_track; midi_track.number_ = track_i; @@ -30,4 +29,3 @@ Audio_staff::output (Midi_stream& midi_stream_r, int track_i) midi_stream_r << midi_track; } - diff --git a/lily/auto-beam-engraver.cc b/lily/auto-beam-engraver.cc index 94e49d549d..9164df8a74 100644 --- a/lily/auto-beam-engraver.cc +++ b/lily/auto-beam-engraver.cc @@ -1,11 +1,10 @@ -/* +/* auto-beam-engraver.cc -- implement Auto_beam_engraver - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Jan Nieuwenhuizen - - */ +*/ #include "engraver.hh" #include "beaming.hh" @@ -26,7 +25,7 @@ protected: virtual void stop_translation_timestep (); virtual void start_translation_timestep (); virtual void process_music (); - virtual bool try_music (Music*); + virtual bool try_music (Music *); virtual void finalize (); virtual void acknowledge_grob (Grob_info); virtual void process_acknowledged_grobs (); @@ -35,39 +34,38 @@ private: bool test_moment (Direction, Moment); void consider_begin (Moment); void consider_end (Moment); - Spanner* create_beam (); + Spanner *create_beam (); void begin_beam (); void end_beam (); void junk_beam (); - bool is_same_grace_state (Grob* e); + bool is_same_grace_state (Grob *e); void typeset_beam (); Music *forbid_; /* shortest_mom is the shortest note in the beam. - */ + */ Moment shortest_mom_; Spanner *finished_beam_; Link_array* stems_; - int count_; Moment last_add_mom_; /* Projected ending of the beam we're working on. - */ + */ Moment extend_mom_; Moment beam_start_moment_; Moment beam_start_location_; bool subdivide_beams_; Moment beat_length_; - + // We act as if beam were created, and start a grouping anyway. - Beaming_info_list*grouping_; - SCM beam_settings_ ; // ugh. should protect ? - - Beaming_info_list*finished_grouping_; + Beaming_info_list *grouping_; + SCM beam_settings_; // ugh. should protect ? + + Beaming_info_list *finished_grouping_; }; void @@ -86,7 +84,6 @@ Auto_beam_engraver::process_music () } } - Auto_beam_engraver::Auto_beam_engraver () { forbid_ = 0; @@ -96,14 +93,13 @@ Auto_beam_engraver::Auto_beam_engraver () finished_beam_ = 0; finished_grouping_ = 0; grouping_ = 0; - beam_settings_ = SCM_EOL; + beam_settings_ = SCM_EOL; } - bool -Auto_beam_engraver::try_music (Music*m) +Auto_beam_engraver::try_music (Music *m) { - if (m->is_mus_type ("beam-forbid-event")) + if (m->is_mus_type ("beam-forbid-event")) { forbid_ = m; return true; @@ -115,26 +111,25 @@ Auto_beam_engraver::try_music (Music*m) /* Determine end moment for auto beaming (or begin moment, but mostly 0== anywhere) In order of increasing priority: - + i. begin anywhere, end at every beat ii. end * iii. end - + iv. end * * * v. end * * - - + + Rationale: - + [to be defined in config file] i. easy catch-all rule ii. exceptions for time signature iii. exceptions for time signature, for specific duration type - + [user override] iv. generic override v. override for specific duration type - */ bool Auto_beam_engraver::test_moment (Direction dir, Moment test_mom) @@ -145,44 +140,44 @@ Auto_beam_engraver::test_moment (Direction dir, Moment test_mom) { return false; } - + SCM wild = scm_list_n (ly_symbol2scm ("*"), ly_symbol2scm ("*"), SCM_UNDEFINED); SCM function; if (dir == START) function = scm_list_n (ly_symbol2scm ("begin"), SCM_UNDEFINED); else function = scm_list_n (ly_symbol2scm ("end"), SCM_UNDEFINED); - + Moment beat_length (1, 4); - if (Moment * m = unsmob_moment (get_property ("beatLength"))) + if (Moment *m = unsmob_moment (get_property ("beatLength"))) { beat_length = *m; } Moment measure_length (1, 1); int num = 4; - if (Moment* m = unsmob_moment (get_property ("measureLength"))) + if (Moment *m = unsmob_moment (get_property ("measureLength"))) { num = int ((*m / beat_length).main_part_); } - + int den = beat_length.den (); SCM time = scm_list_n (scm_int2num (num), scm_int2num (den), SCM_UNDEFINED); SCM type = scm_list_n (scm_int2num (test_mom.num ()), - scm_int2num (test_mom.den ()), SCM_UNDEFINED); + scm_int2num (test_mom.den ()), SCM_UNDEFINED); /* UGH UGH. settings aren't grob-properties. - */ + */ SCM settings = get_property ("autoBeamSettings"); - + /* first guess */ - + /* begin beam at any position - (and fallback for end) */ + (and fallback for end) */ Moment moment (0); - + /* end beam at end of beat */ if (dir == STOP) { @@ -191,43 +186,43 @@ Auto_beam_engraver::test_moment (Direction dir, Moment test_mom) /* second guess: property generic time exception */ SCM m = scm_assoc (ly_append3 (function, wild, time), settings); - + if (m != SCM_BOOL_F && unsmob_moment (scm_cdr (m))) - moment = * unsmob_moment (scm_cdr (m)); + moment = *unsmob_moment (scm_cdr (m)); /* third guess: property time exception, specific for duration type */ m = scm_assoc (ly_append3 (function, type, time), settings); if (m != SCM_BOOL_F && unsmob_moment (scm_cdr (m))) - moment = * unsmob_moment (scm_cdr (m)); + moment = *unsmob_moment (scm_cdr (m)); /* fourth guess [user override]: property plain generic */ m = scm_assoc (ly_append3 (function, wild, wild), settings); if (m != SCM_BOOL_F && unsmob_moment (scm_cdr (m))) - moment = * unsmob_moment (scm_cdr (m)); + moment = *unsmob_moment (scm_cdr (m)); /* fifth guess [user override]: property plain, specific for duration type */ m = scm_assoc (ly_append3 (function, type, wild), settings); if (m != SCM_BOOL_F && unsmob_moment (scm_cdr (m))) - moment = * unsmob_moment (scm_cdr (m)); - + moment = *unsmob_moment (scm_cdr (m)); + Rational r; if (moment.to_bool ()) { /* Ugh? measurePosition can be negative, when \partial We may have to fix this elsewhere (timing translator) - r = unsmob_moment (get_property ("measurePosition"))->mod_rat (moment); + r = unsmob_moment (get_property ("measurePosition"))->mod_rat (moment); */ Moment pos (0); - if (Moment *m = unsmob_moment (get_property ("measurePosition"))) + if (Moment *m = unsmob_moment (get_property ("measurePosition"))) { pos = *m; } - + if (pos < Moment (0)) { - Moment length(1); + Moment length (1); - if ( Moment *m = unsmob_moment (get_property ("measureLength"))) + if (Moment *m = unsmob_moment (get_property ("measureLength"))) { length = *m; } @@ -279,13 +274,13 @@ Auto_beam_engraver::create_beam () { if (to_boolean (get_property ("skipTypesetting"))) return 0; - + Spanner *beam = new Spanner (beam_settings_, context ()->get_grob_key ("Beam")); for (int i = 0; i < stems_->size (); i++) { /* watch out for stem tremolos and abbreviation beams - */ + */ if (Stem::get_beam ((*stems_)[i])) { scm_gc_unprotect_object (beam->self_scm ()); @@ -293,7 +288,7 @@ Auto_beam_engraver::create_beam () } Beam::add_stem (beam, (*stems_)[i]); } - + announce_grob (beam, (*stems_)[0]->self_scm ()); return beam; @@ -302,35 +297,35 @@ Auto_beam_engraver::create_beam () void Auto_beam_engraver::begin_beam () { - if (stems_ || grouping_ ) + if (stems_ || grouping_) { programming_error ("already have autobeam"); - return; + return; } - + stems_ = new Link_array; grouping_ = new Beaming_info_list; beam_settings_ = updated_grob_properties (context (), ly_symbol2scm ("Beam")); - + beam_start_moment_ = now_mom (); - beam_start_location_ = - robust_scm2moment (get_property ("measurePosition"), Moment(0)); + beam_start_location_ + = robust_scm2moment (get_property ("measurePosition"), Moment (0)); subdivide_beams_ = ly_scm2bool (get_property ("subdivideBeams")); - beat_length_ = robust_scm2moment (get_property ("beatLength"), Moment(1, 4)); + beat_length_ = robust_scm2moment (get_property ("beatLength"), Moment (1, 4)); } void -Auto_beam_engraver::junk_beam () +Auto_beam_engraver::junk_beam () { if (!stems_) - return ; - + return; + delete stems_; stems_ = 0; delete grouping_; grouping_ = 0; beam_settings_ = SCM_EOL; - + shortest_mom_ = Moment (Rational (1, 8)); } @@ -363,7 +358,7 @@ Auto_beam_engraver::typeset_beam () finished_grouping_->beamify (beat_length_, subdivide_beams_); Beam::set_beaming (finished_beam_, finished_grouping_); finished_beam_ = 0; - + delete finished_grouping_; finished_grouping_ = 0; } @@ -375,7 +370,7 @@ Auto_beam_engraver::start_translation_timestep () count_ = 0; /* don't beam over skips - */ + */ if (stems_) { Moment now = now_mom (); @@ -403,21 +398,20 @@ Auto_beam_engraver::finalize () junk_beam (); } - void Auto_beam_engraver::acknowledge_grob (Grob_info info) { /* Duplicated from process_music(), since Repeat_acknowledge_engraver::process_music() may also set whichBar - */ + */ if (scm_is_string (get_property ("whichBar")) - && beam_start_moment_ < now_mom()) + && beam_start_moment_ < now_mom ()) { consider_end (shortest_mom_); junk_beam (); } - + if (stems_) { if (Beam::has_interface (info.grob_)) @@ -433,20 +427,20 @@ Auto_beam_engraver::acknowledge_grob (Grob_info info) end_beam (); } } - + if (Stem::has_interface (info.grob_)) { - Item* stem = dynamic_cast (info.grob_); - Music* m = info.music_cause (); + Item *stem = dynamic_cast (info.grob_); + Music *m = info.music_cause (); if (!m->is_mus_type ("rhythmic-event")) { programming_error ("Stem must have rhythmic structure"); return; } - + /* Don't (start) auto-beam over empty stems; skips or rests - */ + */ if (!Stem::head_count (stem)) { if (stems_) @@ -458,11 +452,11 @@ Auto_beam_engraver::acknowledge_grob (Grob_info info) { if (stems_) junk_beam (); - return ; + return; } - - int durlog = unsmob_duration (m->get_property ("duration"))->duration_log (); - + + int durlog = unsmob_duration (m->get_property ("duration"))->duration_log (); + if (durlog <= 2) { if (stems_) @@ -470,23 +464,21 @@ Auto_beam_engraver::acknowledge_grob (Grob_info info) return; } - /* ignore grace notes. - */ + */ if (bool (beam_start_location_.grace_part_) != bool (now_mom ().grace_part_)) - return ; - - + return; + Moment dur = unsmob_duration (m->get_property ("duration"))->get_length (); /* FIXME: - This comment has been here since long: + This comment has been here since long: - if shortest duration would change - consider ending and beginning beam first. + if shortest duration would change + consider ending and beginning beam first. - but the code didn't match: */ + but the code didn't match: */ #if 1 consider_end (dur); consider_begin (dur); @@ -507,11 +499,11 @@ Auto_beam_engraver::acknowledge_grob (Grob_info info) if (!stems_) return; - + Moment now = now_mom (); - + grouping_->add_stem (now - beam_start_moment_ + beam_start_location_, - durlog - 2); + durlog - 2); stems_->push (stem); last_add_mom_ = now; extend_mom_ = (extend_mom_ >? now) + m->get_length (); @@ -540,21 +532,20 @@ Auto_beam_engraver::process_acknowledged_grobs () { junk_beam (); } - } + } } - - count_ ++; + + count_++; } ADD_TRANSLATOR (Auto_beam_engraver, -/* descr */ "Generate beams based on measure characteristics and observed " -"Stems. Uses beatLength, measureLength and measurePosition to decide " -"when to start and stop a beam. Overriding beaming is done through " -"@ref{Stem_engraver} properties @code{stemLeftBeamCount} and " -"@code{stemRightBeamCount}. " -, -/* creats*/ "Beam", -/* accepts */ "beam-forbid-event", -/* acks */ "stem-interface rest-interface beam-interface bar-line-interface", -/* reads */ "autoBeaming autoBeamSettings beatLength subdivideBeams", -/* write */ ""); + /* descr */ "Generate beams based on measure characteristics and observed " + "Stems. Uses beatLength, measureLength and measurePosition to decide " + "when to start and stop a beam. Overriding beaming is done through " + "@ref{Stem_engraver} properties @code{stemLeftBeamCount} and " + "@code{stemRightBeamCount}. ", + /* creats*/ "Beam", + /* accepts */ "beam-forbid-event", + /* acks */ "stem-interface rest-interface beam-interface bar-line-interface", + /* reads */ "autoBeaming autoBeamSettings beatLength subdivideBeams", + /* write */ ""); diff --git a/lily/auto-change-iterator.cc b/lily/auto-change-iterator.cc index 6098d05c76..1fb472a1b5 100644 --- a/lily/auto-change-iterator.cc +++ b/lily/auto-change-iterator.cc @@ -1,11 +1,10 @@ -/* +/* auto-change-iterator.cc -- implement Auto_change_iterator source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - - */ +*/ #include "context.hh" #include "event.hh" @@ -16,18 +15,18 @@ class Auto_change_iterator : public Music_wrapper_iterator { public: DECLARE_SCHEME_CALLBACK (constructor, ()); - + Auto_change_iterator (); protected: virtual void do_quit (); virtual void construct_children (); - virtual void process (Moment); + virtual void process (Moment); Array pending_pitch (Moment) const; private: SCM split_list_; Direction where_dir_; - void change_to (Music_iterator* , SCM, String); + void change_to (Music_iterator *, SCM, String); Moment start_moment_; Interpretation_context_handle up_; @@ -35,25 +34,23 @@ private: }; - - void Auto_change_iterator::change_to (Music_iterator *it, SCM to_type_sym, String to_id) { - Context * current = it->get_outlet (); - Context * last = 0; + Context *current = it->get_outlet (); + Context *last = 0; /* Cut & Paste from Change_iterator (ugh). - TODO: abstract this function - */ - + TODO: abstract this function + */ + /* find the type of translator that we're changing. - - If \translator Staff = bass, then look for Staff = * - */ + + If \translator Staff = bass, then look for Staff = * + */ while (current && !current->is_alias (to_type_sym)) { last = current; @@ -65,25 +62,24 @@ Auto_change_iterator::change_to (Music_iterator *it, SCM to_type_sym, String msg; msg += _ ("Can't switch translators, I'm there already"); } - - if (current) + + if (current) if (last) { - Context * dest = - it->get_outlet ()->find_create_context (to_type_sym, to_id, SCM_EOL); + Context *dest + = it->get_outlet ()->find_create_context (to_type_sym, to_id, SCM_EOL); current->remove_context (last); dest->add_context (last); } else { /* - We could change the current translator's id, but that would make + We could change the current translator's id, but that would make errors hard to catch - + */ } - else - ; + else; } @@ -91,23 +87,23 @@ void Auto_change_iterator::process (Moment m) { Music_wrapper_iterator::process (m); - + Moment now = get_outlet ()->now_mom (); Moment *splitm = 0; - + for (; scm_is_pair (split_list_); split_list_ = scm_cdr (split_list_)) { splitm = unsmob_moment (scm_caar (split_list_)); if ((*splitm + start_moment_) > now) - break ; + break; SCM tag = scm_cdar (split_list_); - Direction d = to_dir (tag); - + Direction d = to_dir (tag); + if (d && d != where_dir_) { where_dir_ = d; - String to_id = (d >= 0) ? "up" : "down"; + String to_id = (d >= 0) ? "up" : "down"; change_to (child_iter_, ly_symbol2scm ("Staff"), to_id); @@ -124,32 +120,32 @@ Auto_change_iterator::Auto_change_iterator () void Auto_change_iterator::construct_children () { - split_list_ = get_music ()->get_property ("split-list"); + split_list_ = get_music ()->get_property ("split-list"); start_moment_ = get_outlet ()->now_mom (); - SCM props = get_outlet()->get_property ("trebleStaffProperties"); - Context *up = get_outlet()->find_create_context (ly_symbol2scm ("Staff"), - "up", props); + SCM props = get_outlet ()->get_property ("trebleStaffProperties"); + Context *up = get_outlet ()->find_create_context (ly_symbol2scm ("Staff"), + "up", props); + + props = get_outlet ()->get_property ("bassStaffProperties"); + Context *down = get_outlet ()->find_create_context (ly_symbol2scm ("Staff"), + "down", props); - props = get_outlet()->get_property ("bassStaffProperties"); - Context *down = get_outlet()->find_create_context (ly_symbol2scm ("Staff"), - "down", props); - up_.set_context (up); down_.set_context (down); Context *voice = up->find_create_context (ly_symbol2scm ("Voice"), - "", SCM_EOL); + "", SCM_EOL); set_context (voice); Music_wrapper_iterator::construct_children (); } void -Auto_change_iterator::do_quit() +Auto_change_iterator::do_quit () { up_.set_context (0); down_.set_context (0); - + } IMPLEMENT_CTOR_CALLBACK (Auto_change_iterator); diff --git a/lily/axis-group-engraver.cc b/lily/axis-group-engraver.cc index 5f646b3ee6..946914e655 100644 --- a/lily/axis-group-engraver.cc +++ b/lily/axis-group-engraver.cc @@ -1,10 +1,10 @@ -/* +/* axis-group-engraver.cc -- implement Axis_group_engraver - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - */ +*/ #include "spanner.hh" #include "paper-column.hh" @@ -15,8 +15,8 @@ /** Put stuff in a Spanner with an Axis_group_interface. - Use as last element of a context. - */ + Use as last element of a context. +*/ class Axis_group_engraver : public Engraver { protected: @@ -26,9 +26,9 @@ protected: virtual void finalize (); virtual void acknowledge_grob (Grob_info); virtual void process_acknowledged_grobs (); - virtual Spanner* get_spanner () ; - virtual void add_element (Grob*) ; -public: + virtual Spanner *get_spanner (); + virtual void add_element (Grob *); +public: TRANSLATOR_DECLARATIONS (Axis_group_engraver); }; @@ -44,42 +44,42 @@ Axis_group_engraver::process_music () if (!staffline_) { staffline_ = get_spanner (); - Grob * it = unsmob_grob (get_property ("currentCommandColumn")); + Grob *it = unsmob_grob (get_property ("currentCommandColumn")); staffline_->set_bound (LEFT, it); } -} +} -Spanner* -Axis_group_engraver::get_spanner () +Spanner * +Axis_group_engraver::get_spanner () { return make_spanner ("VerticalAxisGroup", SCM_EOL); } /* - TODO: should we junk minimumVerticalExtent/extraVerticalExtent ? - */ + TODO: should we junk minimumVerticalExtent/extraVerticalExtent ? +*/ void Axis_group_engraver::finalize () { if (!staffline_) - return ; - + return; + String type = context ()->context_name (); SCM dims = get_property ("verticalExtent"); - + if (is_number_pair (dims)) staffline_->set_extent (dims, Y_AXIS); dims = get_property ("minimumVerticalExtent"); - if (is_number_pair (dims) ) + if (is_number_pair (dims)) staffline_->set_property ("minimum-Y-extent", dims); dims = get_property ("extraVerticalExtent"); if (is_number_pair (dims)) staffline_->set_property ("extra-Y-extent", dims); - Grob * it = unsmob_grob (get_property ("currentCommandColumn")); + Grob *it = unsmob_grob (get_property ("currentCommandColumn")); staffline_->set_bound (RIGHT, it); @@ -99,30 +99,30 @@ Axis_group_engraver::acknowledge_grob (Grob_info i) void Axis_group_engraver::process_acknowledged_grobs () { - if (!staffline_) - return ; - + if (!staffline_) + return; + for (int i = 0; i < elts_.size (); i++) { - if (!unsmob_grob (elts_[i]->get_property ("axis-group-parent-Y"))) + if (!unsmob_grob (elts_[i]->get_property ("axis-group-parent-Y"))) { if (staffline_->get_parent (Y_AXIS) && staffline_->get_parent (Y_AXIS) == elts_[i]) { - String msg = _("Axis_group_engraver: vertical group already has a parent.\n" - "Do you have two Axis_group_engravers?\n" - "Killing this vertical group."); + String msg = _ ("Axis_group_engraver: vertical group already has a parent.\n" + "Do you have two Axis_group_engravers?\n" + "Killing this vertical group."); staffline_->warning (msg); staffline_->suicide (); staffline_ = 0; - break ; + break; } else if (elts_[i]->is_empty (Y_AXIS)) { /* We have to do _something_, otherwise staff objects will - end up with System as parent. - + end up with System as parent. + */ elts_[i]->set_parent (staffline_, Y_AXIS); } @@ -134,7 +134,7 @@ Axis_group_engraver::process_acknowledged_grobs () } void -Axis_group_engraver::add_element (Grob*e) +Axis_group_engraver::add_element (Grob *e) { Axis_group_interface::add_element (staffline_, e); } @@ -142,10 +142,8 @@ Axis_group_engraver::add_element (Grob*e) /****************************************************************/ /* - - maybenot such a good idea after all., to put class declarations in - .cc - + maybenot such a good idea after all., to put class declarations in + .cc */ #include "hara-kiri-group-spanner.hh" @@ -154,7 +152,7 @@ Axis_group_engraver::add_element (Grob*e) class Hara_kiri_engraver : public Axis_group_engraver { protected: - virtual Spanner*get_spanner (); + virtual Spanner *get_spanner (); virtual void acknowledge_grob (Grob_info); virtual void add_element (Grob *e); public: @@ -162,17 +160,16 @@ public: }; void -Hara_kiri_engraver::add_element (Grob*e) +Hara_kiri_engraver::add_element (Grob *e) { Hara_kiri_group_spanner::add_element (staffline_, e); } - -Spanner* -Hara_kiri_engraver::get_spanner () +Spanner * +Hara_kiri_engraver::get_spanner () { - Spanner * sp = make_spanner ("RemoveEmptyVerticalGroup", SCM_EOL); - + Spanner *sp = make_spanner ("RemoveEmptyVerticalGroup", SCM_EOL); + return sp; } @@ -182,31 +179,29 @@ Hara_kiri_engraver::acknowledge_grob (Grob_info i) Axis_group_engraver::acknowledge_grob (i); if (staffline_ && (i.grob_->internal_has_interface (ly_symbol2scm ("rhythmic-grob-interface")) - || i.grob_->internal_has_interface (ly_symbol2scm ("lyric-interface"))) - ) + || i.grob_->internal_has_interface (ly_symbol2scm ("lyric-interface")))) { Hara_kiri_group_spanner::add_interesting_item (staffline_, i.grob_); } } - Hara_kiri_engraver::Hara_kiri_engraver () { } ADD_TRANSLATOR (Hara_kiri_engraver, -/* descr */ "Like Axis_group_engraver, but make a hara-kiri spanner, and add " -"interesting items (ie. note heads, lyric syllables and normal rests) ", -/* creats*/ "RemoveEmptyVerticalGroup", -/* accepts */ "", -/* acks */ "grob-interface", -/* reads */ "", -/* write */ ""); + /* descr */ "Like Axis_group_engraver, but make a hara-kiri spanner, and add " + "interesting items (ie. note heads, lyric syllables and normal rests) ", + /* creats*/ "RemoveEmptyVerticalGroup", + /* accepts */ "", + /* acks */ "grob-interface", + /* reads */ "", + /* write */ ""); ADD_TRANSLATOR (Axis_group_engraver, -/* descr */ "Group all objects created in this context in a VerticalAxisGroup spanner.", -/* creats*/ "VerticalAxisGroup", -/* accepts */ "", -/* acks */ "grob-interface", -/* reads */ "verticalExtent minimumVerticalExtent extraVerticalExtent", -/* write */ ""); + /* descr */ "Group all objects created in this context in a VerticalAxisGroup spanner.", + /* creats*/ "VerticalAxisGroup", + /* accepts */ "", + /* acks */ "grob-interface", + /* reads */ "verticalExtent minimumVerticalExtent extraVerticalExtent", + /* write */ ""); diff --git a/lily/axis-group-interface.cc b/lily/axis-group-interface.cc index 842641d181..dde37ac72e 100644 --- a/lily/axis-group-interface.cc +++ b/lily/axis-group-interface.cc @@ -1,44 +1,42 @@ -/* +/* axis-group-interface.cc -- implement Axis_group_interface - + source file of the GNU LilyPond music typesetter - + (c) 2000--2005 Han-Wen Nienhuys - - */ +*/ #include "axis-group-interface.hh" #include "hara-kiri-group-spanner.hh" void -Axis_group_interface::add_element (Grob*me, Grob *e) +Axis_group_interface::add_element (Grob *me, Grob *e) { - for (SCM ax = me->get_property ("axes"); ax != SCM_EOL ; ax = scm_cdr (ax)) + for (SCM ax = me->get_property ("axes"); ax != SCM_EOL; ax = scm_cdr (ax)) { Axis a = (Axis) scm_to_int (scm_car (ax)); - + if (!e->get_parent (a)) e->set_parent (me, a); e->internal_set_property ((a == X_AXIS) ? ly_symbol2scm ("axis-group-parent-X") : ly_symbol2scm ("axis-group-parent-Y"), - me->self_scm () - ); + me->self_scm ()); } - + Pointer_group_interface::add_grob (me, ly_symbol2scm ("elements"), e); me->add_dependency (e); } bool -Axis_group_interface::has_axis (Grob*me, Axis a) +Axis_group_interface::has_axis (Grob *me, Axis a) { /* urg. FIXME, check for Hara_kiri_group_spanner shouldn't be necessary? - */ - return me->has_extent_callback (group_extent_callback_proc, a) || - (me->has_extent_callback (Hara_kiri_group_spanner::y_extent_proc, a)); + */ + return me->has_extent_callback (group_extent_callback_proc, a) + || (me->has_extent_callback (Hara_kiri_group_spanner::y_extent_proc, a)); } Interval @@ -47,7 +45,7 @@ Axis_group_interface::relative_group_extent (Axis a, Grob *common, SCM elts) Interval r; for (SCM s = elts; scm_is_pair (s); s = scm_cdr (s)) { - Grob * se = unsmob_grob (scm_car (s)); + Grob *se = unsmob_grob (scm_car (s)); Interval dims = se->extent (common, a); if (!dims.is_empty ()) r.unite (dims); @@ -63,7 +61,7 @@ Axis_group_interface::group_extent_callback (SCM element_smob, SCM scm_axis) Axis a = (Axis) scm_to_int (scm_axis); SCM elts = me->get_property ("elements"); - Grob * common = common_refpoint_of_list (elts, me, a); + Grob *common = common_refpoint_of_list (elts, me, a); Real my_coord = me->relative_coordinate (common, a); Interval r (relative_group_extent (a, common, elts)); @@ -72,13 +70,13 @@ Axis_group_interface::group_extent_callback (SCM element_smob, SCM scm_axis) } void -Axis_group_interface::set_axes (Grob*me, Axis a1, Axis a2) +Axis_group_interface::set_axes (Grob *me, Axis a1, Axis a2) { SCM sa1= scm_int2num (a1); SCM sa2 = scm_int2num (a2); SCM axes = me->get_property ("axes"); - + if (!scm_is_pair (axes) || scm_c_memq (sa1, axes) == SCM_BOOL_F || scm_c_memq (sa2, axes) == SCM_BOOL_F) @@ -95,35 +93,33 @@ Axis_group_interface::set_axes (Grob*me, Axis a1, Axis a2) me->set_extent (SCM_EOL, Y_AXIS); /* - why so convoluted ? (fixme/documentme?) - */ + why so convoluted ? (fixme/documentme?) + */ if (me->has_extent_callback (Grob::stencil_extent_proc, a1)) me->set_extent_callback (Axis_group_interface::group_extent_callback_proc, a1); if (me->has_extent_callback (Grob::stencil_extent_proc, a2)) me->set_extent_callback (Axis_group_interface::group_extent_callback_proc, a2); } -Link_array -Axis_group_interface::get_children (Grob*me) +Link_array +Axis_group_interface::get_children (Grob *me) { Link_array childs; - childs.push (me) ; + childs.push (me); if (!has_interface (me)) return childs; - + for (SCM ep = me->get_property ("elements"); scm_is_pair (ep); ep = scm_cdr (ep)) { - Grob* e = unsmob_grob (scm_car (ep)); + Grob *e = unsmob_grob (scm_car (ep)); if (e) childs.concat (Axis_group_interface::get_children (e)); } - + return childs; } - - ADD_INTERFACE (Axis_group_interface, "axis-group-interface", - "An object that groups other layout objects.", - "axes elements"); + "An object that groups other layout objects.", + "axes elements"); diff --git a/lily/balloon.cc b/lily/balloon.cc index 5215453558..2a2594ee92 100644 --- a/lily/balloon.cc +++ b/lily/balloon.cc @@ -19,12 +19,12 @@ class Balloon_interface { public: DECLARE_SCHEME_CALLBACK (print, (SCM)); - static bool has_interface (Grob*); + static bool has_interface (Grob *); }; MAKE_SCHEME_CALLBACK (Balloon_interface, print, 1); SCM -Balloon_interface::print (SCM smob) +Balloon_interface::print (SCM smob) { Grob *me = unsmob_grob (smob); @@ -54,16 +54,16 @@ Balloon_interface::print (SCM smob) Stencil fr = Lookup::frame (box_extent, 0.1, 0.05); fr.add_stencil (*s); - + SCM bt = me->get_property ("balloon-text"); SCM chain = Font_interface::text_font_alist_chain (me); chain = scm_cons (me->get_property ("balloon-text-props"), chain); SCM text = Text_interface::interpret_markup (me->get_layout ()->self_scm (), - chain, bt); + chain, bt); Stencil *text_stil = unsmob_stencil (text); - + Offset z1; for (int i = X_AXIS; i < NO_AXES; i++) { @@ -73,12 +73,12 @@ Balloon_interface::print (SCM smob) } Offset z2 = z1 + off; - + fr.add_stencil (Line_interface::line (me, z1, z2)); text_stil->translate (z2); fr.add_stencil (*text_stil); - + fr = Stencil (orig_extent, fr.expr ()); return fr.smobbed_copy (); } diff --git a/lily/bar-check-iterator.cc b/lily/bar-check-iterator.cc index fe203f16ec..660272cd90 100644 --- a/lily/bar-check-iterator.cc +++ b/lily/bar-check-iterator.cc @@ -1,4 +1,4 @@ -/* +/* bar-check-iterator.cc -- implement Bar_check_iterator source file of the GNU LilyPond music typesetter @@ -13,12 +13,12 @@ /* Check bar checks. We do this outside the engravers so that you can race through the score using skipTypesetting to correct durations. - */ +*/ class Bar_check_iterator : Simple_music_iterator { public: virtual void process (Moment); - Bar_check_iterator ( ); + Bar_check_iterator (); DECLARE_SCHEME_CALLBACK (constructor, ()); }; @@ -39,10 +39,10 @@ Bar_check_iterator::process (Moment m) SCM mp = tr->get_property ("measurePosition"); SCM sync = tr->get_property ("barCheckSynchronize"); - Moment * where = unsmob_moment (mp); + Moment *where = unsmob_moment (mp); if (!where) return; - + if (where->main_part_) { bool warn = true; @@ -63,8 +63,8 @@ Bar_check_iterator::process (Moment m) } if (warn) - get_music ()->origin ()->warning (_f ("barcheck failed at: %s", - where->to_string ())); + get_music ()->origin ()->warning (_f ("barcheck failed at: %s", + where->to_string ())); } } -} +} diff --git a/lily/bar-engraver.cc b/lily/bar-engraver.cc index f4bb0e5894..dad72a4fe4 100644 --- a/lily/bar-engraver.cc +++ b/lily/bar-engraver.cc @@ -14,14 +14,13 @@ /* generate bars. Either user ("|:"), or default (new measure) - - */ +*/ class Bar_engraver : public Engraver { public: TRANSLATOR_DECLARATIONS (Bar_engraver); void request_bar (String type_string); - + protected: virtual void finalize (); virtual void stop_translation_timestep (); @@ -31,7 +30,7 @@ private: void typeset_bar (); void create_bar (); - Item * bar_; + Item *bar_; }; Bar_engraver::Bar_engraver () @@ -47,7 +46,7 @@ Bar_engraver::create_bar () bar_ = make_item ("BarLine", SCM_EOL); SCM gl = get_property ("whichBar"); if (scm_equal_p (gl, bar_->get_property ("glyph")) != SCM_BOOL_T) - bar_->set_property ("glyph", gl); + bar_->set_property ("glyph", gl); } } @@ -58,7 +57,7 @@ Bar_engraver::finalize () } /* - Bar_engraver should come *after* any engravers that + Bar_engraver should come *after* any engravers that modify whichBar This is a little hairy : whichBar may be set by @@ -66,7 +65,6 @@ Bar_engraver::finalize () context. This means that grobs could should be created after process_music. We do stuff process_acknowledged_grobs (), just to be on the safe side. - */ void @@ -83,9 +81,9 @@ Bar_engraver::typeset_bar () } /* - lines may only be broken if there is a barline in all staves + lines may only be broken if there is a barline in all staves */ -void +void Bar_engraver::stop_translation_timestep () { if (!bar_) @@ -95,12 +93,11 @@ Bar_engraver::stop_translation_timestep () typeset_bar (); } - ADD_TRANSLATOR (Bar_engraver, -/* descr */ "Create barlines. This engraver is controlled through the " -"@code{whichBar} property. If it has no bar line to create, it will forbid a linebreak at this point", -/* creats*/ "BarLine", -/* accepts */ "", -/* acks */ "", -/* reads */ "whichBar", -/* write */ ""); + /* descr */ "Create barlines. This engraver is controlled through the " + "@code{whichBar} property. If it has no bar line to create, it will forbid a linebreak at this point", + /* creats*/ "BarLine", + /* accepts */ "", + /* acks */ "", + /* reads */ "whichBar", + /* write */ ""); diff --git a/lily/bar-line.cc b/lily/bar-line.cc index de9c1a2a94..cd5729a02e 100644 --- a/lily/bar-line.cc +++ b/lily/bar-line.cc @@ -6,7 +6,6 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #include #include "bar-line.hh" @@ -19,29 +18,28 @@ MAKE_SCHEME_CALLBACK (Bar_line, print, 1); -SCM -Bar_line::print (SCM smob) +SCM +Bar_line::print (SCM smob) { - Grob * me = unsmob_grob (smob); + Grob *me = unsmob_grob (smob); SCM s = me->get_property ("glyph"); SCM barsiz_proc = me->get_property ("bar-size-procedure"); if (scm_is_string (s) && ly_c_procedure_p (barsiz_proc)) { - String str = ly_scm2string (s); + String str = ly_scm2string (s); SCM siz = scm_call_1 (barsiz_proc, me->self_scm ()); Real sz = robust_scm2double (siz, 0); if (sz <= 0) return SCM_EOL; - + return compound_barline (me, str, sz).smobbed_copy (); } return SCM_EOL; } - Stencil -Bar_line::compound_barline (Grob*me, String str, Real h) +Bar_line::compound_barline (Grob *me, String str, Real h) { Real kern = robust_scm2double (me->get_property ("kern"), 1); Real thinkern = robust_scm2double (me->get_property ("thin-kern"), 1); @@ -61,22 +59,22 @@ Bar_line::compound_barline (Grob*me, String str, Real h) Stencil dot = Font_interface::get_default_font (me)->find_by_name ("dots.dot"); int lines = Staff_symbol_referencer::line_count (me); - Real dist + Real dist = ((lines & 1 || lines == 0) ? 1 - : (staff_space < 2 ? 2 : .5) ) * staff_space; + : (staff_space < 2 ? 2 : .5)) * staff_space; Stencil colon (dot); colon.translate_axis (dist, Y_AXIS); colon.add_stencil (dot); - colon.translate_axis (-dist/2, Y_AXIS); + colon.translate_axis (-dist / 2, Y_AXIS); Stencil m; if (str == "||:") str = "|:"; - + if (str == "") { - return Lookup::blank (Box (Interval (0, 0), Interval (-h/2, h/2))); + return Lookup::blank (Box (Interval (0, 0), Interval (-h / 2, h / 2))); } else if (str == "|") { @@ -84,8 +82,8 @@ Bar_line::compound_barline (Grob*me, String str, Real h) } else if (str == "|." || (h == 0 && str == ":|")) { - m.add_at_edge (X_AXIS, LEFT, thick, 0, 0); - m.add_at_edge (X_AXIS, LEFT, thin, kern, 0 ); + m.add_at_edge (X_AXIS, LEFT, thick, 0, 0); + m.add_at_edge (X_AXIS, LEFT, thin, kern, 0); } else if (str == ".|" || (h == 0 && str == "|:")) { @@ -96,20 +94,20 @@ Bar_line::compound_barline (Grob*me, String str, Real h) { m.add_at_edge (X_AXIS, LEFT, thick, 0, 0); m.add_at_edge (X_AXIS, LEFT, thin, kern, 0); - m.add_at_edge (X_AXIS, LEFT, colon, kern, 0); + m.add_at_edge (X_AXIS, LEFT, colon, kern, 0); } else if (str == "|:") { m.add_at_edge (X_AXIS, RIGHT, thick, 0, 0); m.add_at_edge (X_AXIS, RIGHT, thin, kern, 0); - m.add_at_edge (X_AXIS, RIGHT, colon, kern, 0); + m.add_at_edge (X_AXIS, RIGHT, colon, kern, 0); } else if (str == ":|:") { m.add_at_edge (X_AXIS, LEFT, thick, thinkern, 0); m.add_at_edge (X_AXIS, LEFT, colon, kern, 0); m.add_at_edge (X_AXIS, RIGHT, thick, kern, 0); - m.add_at_edge (X_AXIS, RIGHT, colon, kern, 0); + m.add_at_edge (X_AXIS, RIGHT, colon, kern, 0); } else if (str == ".|.") { @@ -128,10 +126,10 @@ Bar_line::compound_barline (Grob*me, String str, Real h) else if (str == ":") { int c = (Staff_symbol_referencer::line_count (me)); - - for (int i = 0 ; i < c - 1; i++) + + for (int i = 0; i < c - 1; i++) { - Real y = (- (c-1.0) / 2 + 0.5 + i * staff_space); + Real y = (- (c - 1.0) / 2 + 0.5 + i * staff_space); Stencil d (dot); d. translate_axis (y, Y_AXIS); @@ -144,21 +142,21 @@ Bar_line::compound_barline (Grob*me, String str, Real h) Stencil Bar_line::simple_barline (Grob *me, Real w, - Real h) + Real h) { Real blot = me->get_layout ()->get_dimension (ly_symbol2scm ("blotdiameter")); - - return Lookup::round_filled_box (Box (Interval (0, w), Interval (-h/2, h/2)), blot); + + return Lookup::round_filled_box (Box (Interval (0, w), Interval (-h / 2, h / 2)), blot); } -MAKE_SCHEME_CALLBACK (Bar_line, before_line_breaking , 1); +MAKE_SCHEME_CALLBACK (Bar_line, before_line_breaking, 1); SCM Bar_line::before_line_breaking (SCM smob) { - Grob*me = unsmob_grob (smob); - Item * item = dynamic_cast (me); - + Grob *me = unsmob_grob (smob); + Item *item = dynamic_cast (me); + SCM g = me->get_property ("glyph"); SCM orig = g; Direction bsd = item->break_status_dir (); @@ -167,7 +165,7 @@ Bar_line::before_line_breaking (SCM smob) SCM proc = me->get_property ("break-glyph-function"); g = scm_call_2 (proc, g, scm_int2num (bsd)); } - + if (!scm_is_string (g)) { me->set_property ("print-function", SCM_EOL); @@ -180,15 +178,13 @@ Bar_line::before_line_breaking (SCM smob) return SCM_UNSPECIFIED; } - - MAKE_SCHEME_CALLBACK (Bar_line, get_staff_bar_size, 1); SCM -Bar_line::get_staff_bar_size (SCM smob) +Bar_line::get_staff_bar_size (SCM smob) { - Grob*me = unsmob_grob (smob); + Grob *me = unsmob_grob (smob); Real ss = Staff_symbol_referencer::staff_space (me); SCM size = me->get_property ("bar-size"); if (scm_is_number (size)) @@ -201,28 +197,26 @@ Bar_line::get_staff_bar_size (SCM smob) barline so we return 0.0 in the next alternative. */ Real ysize = (Staff_symbol_referencer::line_count (me) -1); - ysize = ysize * ss + Staff_symbol_referencer::line_thickness (me); + ysize = ysize * ss + Staff_symbol_referencer::line_thickness (me); return scm_make_real (ysize); } else return scm_int2num (0); } - - ADD_INTERFACE (Bar_line, "bar-line-interface", - "Bar line.\n" -"\n" -"Print a special bar symbol. It replaces the \n" -"regular bar symbol with a special\n" -"symbol. The argument @var{bartype} is a string which specifies the\n" -"kind of bar to print. Options are @code{:|}, \n" -"@code{|:}, @code{:|:},\n" -"@code{||}, @code{|.},\n" -"@code{.|}, and @code{.|.}. \n" -"\n" -"These produce, respectively, a right repeat, a left repeat, a double\n" -"repeat, a double bar, a start bar, an end bar, and a thick double bar.\n" -"If @var{bartype} is set to @code{empty} then nothing is printed,\n" -"but a line break is allowed at that spot.\n", - "bar-size-procedure kern thin-kern hair-thickness thick-thickness glyph bar-size break-glyph-function"); + "Bar line.\n" + "\n" + "Print a special bar symbol. It replaces the \n" + "regular bar symbol with a special\n" + "symbol. The argument @var{bartype} is a string which specifies the\n" + "kind of bar to print. Options are @code{:|}, \n" + "@code{|:}, @code{:|:},\n" + "@code{||}, @code{|.},\n" + "@code{.|}, and @code{.|.}. \n" + "\n" + "These produce, respectively, a right repeat, a left repeat, a double\n" + "repeat, a double bar, a start bar, an end bar, and a thick double bar.\n" + "If @var{bartype} is set to @code{empty} then nothing is printed,\n" + "but a line break is allowed at that spot.\n", + "bar-size-procedure kern thin-kern hair-thickness thick-thickness glyph bar-size break-glyph-function"); diff --git a/lily/bar-number-engraver.cc b/lily/bar-number-engraver.cc index 6ef193e2eb..80b431c214 100644 --- a/lily/bar-number-engraver.cc +++ b/lily/bar-number-engraver.cc @@ -13,34 +13,30 @@ #include "context.hh" /* - -TODO: detect the top staff (stavesFound), and acknowledge staff-group -system-start-delims. If we find these, and the top staff is in the -staff-group, add padding to the bar number. - + TODO: detect the top staff (stavesFound), and acknowledge staff-group + system-start-delims. If we find these, and the top staff is in the + staff-group, add padding to the bar number. */ - class Bar_number_engraver : public Engraver { protected: - Item* text_; + Item *text_; protected: virtual void stop_translation_timestep (); virtual void acknowledge_grob (Grob_info); virtual void process_music (); void create_items (); - TRANSLATOR_DECLARATIONS (Bar_number_engraver ); + TRANSLATOR_DECLARATIONS (Bar_number_engraver); }; - void Bar_number_engraver::process_music () { // todo include (&&!time->cadenza_b_) SCM wb = get_property ("whichBar"); - + if (scm_is_string (wb)) { Moment mp (robust_scm2moment (get_property ("measurePosition"), Moment (0))); @@ -49,7 +45,7 @@ Bar_number_engraver::process_music () SCM bn = get_property ("currentBarNumber"); SCM proc = get_property ("barNumberVisibility"); if (scm_is_number (bn) && ly_c_procedure_p (proc) - && to_boolean (scm_call_1(proc, bn))) + && to_boolean (scm_call_1 (proc, bn))) { create_items (); // guh. @@ -61,20 +57,17 @@ Bar_number_engraver::process_music () } - - Bar_number_engraver::Bar_number_engraver () { text_ = 0; } - void Bar_number_engraver::acknowledge_grob (Grob_info inf) { - Grob * s = inf.grob_; + Grob *s = inf.grob_; if (text_ - && dynamic_cast (s) + && dynamic_cast (s) && s->get_property ("break-align-symbol") == ly_symbol2scm ("left-edge")) { /* @@ -84,18 +77,17 @@ Bar_number_engraver::acknowledge_grob (Grob_info inf) } } -void +void Bar_number_engraver::stop_translation_timestep () { if (text_) { text_->set_property ("side-support-elements", get_property ("stavesFound")); - + text_ = 0; } } - void Bar_number_engraver::create_items () { @@ -107,14 +99,13 @@ Bar_number_engraver::create_items () } ADD_TRANSLATOR (Bar_number_engraver, -/* descr */ "A bar number is created whenever measurePosition is zero. It is\n" - "put on top of all staves, and appears only at left side of the staff. " - "The staves are taken from @code{stavesFound}, which is maintained by " - "@code{@ref{Staff_collecting_engraver}}. " - , - -/* creats*/ "BarNumber", -/* accepts */ "", -/* acks */ "break-aligned-interface", -/* reads */ "currentBarNumber stavesFound barNumberVisibility" , -/* write */ ""); + /* descr */ "A bar number is created whenever measurePosition is zero. It is\n" + "put on top of all staves, and appears only at left side of the staff. " + "The staves are taken from @code{stavesFound}, which is maintained by " + "@code{@ref{Staff_collecting_engraver}}. ", + + /* creats*/ "BarNumber", + /* accepts */ "", + /* acks */ "break-aligned-interface", + /* reads */ "currentBarNumber stavesFound barNumberVisibility", + /* write */ ""); diff --git a/lily/beam-concave.cc b/lily/beam-concave.cc index 0f2cb2fb9c..d7ea7638e8 100644 --- a/lily/beam-concave.cc +++ b/lily/beam-concave.cc @@ -1,6 +1,6 @@ /* - Determine whether a beam is concave. - */ + Determine whether a beam is concave. +*/ #include @@ -20,38 +20,37 @@ is_concave_single_notes (Array const &positions, Direction beam_dir) bool above = false; bool below = false; bool concave = false; - + /* notes above and below the interval covered by 1st and last note. - */ + */ for (int i = 1; i < positions.size () - 1; i++) { above = above || (positions[i] > covering[UP]); below = below || (positions[i] < covering[DOWN]); } - concave = concave || (above && below); /* A note as close or closer to the beam than begin and end, but the note is reached in the opposite direction as the last-first dy - */ - int dy = positions.top() - positions[0]; - int closest = (beam_dir * positions.top()) >? (beam_dir *positions[0]); + */ + int dy = positions.top () - positions[0]; + int closest = (beam_dir * positions.top ()) >? (beam_dir *positions[0]); for (int i = 2; !concave && i < positions.size () - 1; i++) { - int inner_dy = positions[i] - positions[i-1]; + int inner_dy = positions[i] - positions[i - 1]; if (sign (inner_dy) != sign (dy) && (beam_dir * positions[i] >= closest - || beam_dir * positions[i-1] >= closest)) + || beam_dir * positions[i - 1] >= closest)) concave = true; } - - bool all_closer = true; - for (int i = 1; all_closer && i < positions.size ()-1; i++) + + bool all_closer = true; + for (int i = 1; all_closer && i < positions.size () - 1; i++) { - all_closer = all_closer && - (beam_dir * positions[i] > closest); + all_closer = all_closer + && (beam_dir * positions[i] > closest); } concave = concave || all_closer; @@ -62,16 +61,16 @@ Real calc_concaveness (Array const &positions, Direction beam_dir) { Real dy = positions.top () - positions[0]; - Real slope = dy / Real (positions.size() - 1); + Real slope = dy / Real (positions.size () - 1); Real concaveness = 0.0; - for (int i = 1; i < positions.size() - 1; i++) + for (int i = 1; i < positions.size () - 1; i++) { Real line_y = slope * i + positions[0]; concaveness += (beam_dir * (positions[i] - line_y)) >? 0.0; } - concaveness /= positions.size () ; + concaveness /= positions.size (); /* Normalize. For dy = 0, the slope ends up as 0 anyway, so the @@ -88,14 +87,14 @@ Beam::check_concave (SCM smob) { Grob *me = unsmob_grob (smob); - Link_array stems = - extract_grob_array (me, ly_symbol2scm ("stems")); + Link_array stems + = extract_grob_array (me, ly_symbol2scm ("stems")); if (is_knee (me)) return SCM_UNSPECIFIED; - + Direction beam_dir = CENTER; - for (int i = stems.size (); i--; ) + for (int i = stems.size (); i--;) { if (Stem::is_invisible (stems[i])) stems.del (i); @@ -105,11 +104,10 @@ Beam::check_concave (SCM smob) beam_dir = dir; } } - + if (stems.size () <= 2) return SCM_UNSPECIFIED; - Array close_positions; Array far_positions; for (int i = 0; i < stems.size (); i++) @@ -120,15 +118,15 @@ Beam::check_concave (SCM smob) Hmmm.. wait, for the beams in the last measure of morgenlied, this doesn't look so good. Let's try the heads farthest from the beam. - - */ + + */ Interval posns = Stem::head_positions (stems[i]); - + close_positions.push ((int) rint (posns[beam_dir])); far_positions.push ((int) rint (posns[-beam_dir])); } - if (is_concave_single_notes (far_positions, beam_dir)) + if (is_concave_single_notes (far_positions, beam_dir)) { Drul_array pos = ly_scm2interval (me->get_property ("positions")); Real r = linear_combination (pos, 0.0); @@ -140,11 +138,10 @@ Beam::check_concave (SCM smob) else { Real concaveness = (calc_concaveness (far_positions, beam_dir) - + calc_concaveness (close_positions, beam_dir))/2; - + + calc_concaveness (close_positions, beam_dir)) / 2; me->set_property ("concaveness", scm_from_double (concaveness)); } - + return SCM_UNSPECIFIED; } diff --git a/lily/beam-engraver.cc b/lily/beam-engraver.cc index 22cf46cfb5..def3e6a66b 100644 --- a/lily/beam-engraver.cc +++ b/lily/beam-engraver.cc @@ -1,11 +1,10 @@ -/* +/* beam-engraver.cc -- implement Beam_engraver - + source file of the GNU LilyPond music typesetter - + (c) 1998--2005 Han-Wen Nienhuys - - */ +*/ #include "engraver.hh" #include "beam.hh" @@ -21,17 +20,17 @@ class Beam_engraver : public Engraver { -protected: - Music * start_ev_; - +protected: + Music *start_ev_; + Spanner *finished_beam_; Spanner *beam_; - Music * prev_start_ev_; + Music *prev_start_ev_; + + Music *now_stop_ev_; - Music * now_stop_ev_; - - Beaming_info_list * beam_info_; - Beaming_info_list * finished_beam_info_; + Beaming_info_list *beam_info_; + Beaming_info_list *finished_beam_info_; /// location within measure where beam started. Moment beam_start_location_; @@ -51,21 +50,20 @@ protected: virtual void finalize (); virtual void acknowledge_grob (Grob_info); - virtual bool try_music (Music*); + virtual bool try_music (Music *); virtual void process_music (); virtual bool valid_start_point (); virtual bool valid_end_point (); - + public: TRANSLATOR_DECLARATIONS (Beam_engraver); }; - /* Hmm. this isn't necessary, since grace beams and normal beams are always nested. - */ +*/ bool Beam_engraver::valid_start_point () { @@ -146,15 +144,14 @@ Beam_engraver::process_music () beam_start_location_ = mp; beam_start_mom_ = now_mom (); - + beam_info_ = new Beaming_info_list; - + /* urg, must copy to Auto_beam_engraver too */ } } - void Beam_engraver::typeset_beam () { @@ -162,7 +159,7 @@ Beam_engraver::typeset_beam () { finished_beam_info_->beamify (beat_length_, subdivide_beams_); Beam::set_beaming (finished_beam_, finished_beam_info_); - + delete finished_beam_info_; finished_beam_info_ = 0; finished_beam_ = 0; @@ -173,11 +170,11 @@ void Beam_engraver::start_translation_timestep () { start_ev_ = 0; - + if (beam_) { set_melisma (true); - + subdivide_beams_ = to_boolean (get_property ("subdivideBeams")); beat_length_ = robust_scm2moment (get_property ("beatLength"), Moment (1, 4)); } @@ -187,7 +184,7 @@ void Beam_engraver::stop_translation_timestep () { typeset_beam (); - if (now_stop_ev_ ) + if (now_stop_ev_) { finished_beam_ = beam_; finished_beam_info_ = beam_info_; @@ -230,13 +227,13 @@ Beam_engraver::acknowledge_grob (Grob_info info) Moment now = now_mom (); if (!valid_start_point ()) - return ; - - Item *stem = dynamic_cast (info.grob_); + return; + + Item *stem = dynamic_cast (info.grob_); if (Stem::get_beam (stem)) return; - Music* m = info.music_cause (); + Music *m = info.music_cause (); if (!m->is_mus_type ("rhythmic-event")) { String s = _ ("stem must have Rhythmic structure"); @@ -244,13 +241,12 @@ Beam_engraver::acknowledge_grob (Grob_info info) info.music_cause ()->origin ()->warning (s); else ::warning (s); - + return; } - last_stem_added_at_ = now; - int durlog = unsmob_duration (m->get_property ("duration"))-> duration_log (); + int durlog = unsmob_duration (m->get_property ("duration"))-> duration_log (); if (durlog <= 2) { m->origin ()->warning (_ ("stem doesn't fit in beam")); @@ -263,33 +259,29 @@ Beam_engraver::acknowledge_grob (Grob_info info) } stem->set_property ("duration-log", - scm_int2num (durlog)); + scm_int2num (durlog)); Moment stem_location = now - beam_start_mom_ + beam_start_location_; beam_info_->add_stem (stem_location, - (durlog- 2) >? 0); + (durlog- 2) >? 0); Beam::add_stem (beam_, stem); } } } - - - ADD_TRANSLATOR (Beam_engraver, -/* descr */ "Handles Beam events by engraving Beams. If omitted, then notes will be " -"printed with flags instead of beams.", -/* creats*/ "Beam", -/* accepts */ "beam-event", -/* acks */ "stem-interface rest-interface", -/* reads */ "beamMelismaBusy beatLength subdivideBeams", -/* write */ ""); - + /* descr */ "Handles Beam events by engraving Beams. If omitted, then notes will be " + "printed with flags instead of beams.", + /* creats*/ "Beam", + /* accepts */ "beam-event", + /* acks */ "stem-interface rest-interface", + /* reads */ "beamMelismaBusy beatLength subdivideBeams", + /* write */ ""); class Grace_beam_engraver : public Beam_engraver { public: - TRANSLATOR_DECLARATIONS (Grace_beam_engraver); + TRANSLATOR_DECLARATIONS (Grace_beam_engraver); protected: virtual bool valid_start_point (); @@ -308,23 +300,19 @@ Grace_beam_engraver::valid_start_point () return n.grace_part_ != Rational (0); } - bool Grace_beam_engraver::valid_end_point () { return beam_ && valid_start_point (); } - - ADD_TRANSLATOR (Grace_beam_engraver, -/* descr */ "Handles Beam events by engraving Beams. If omitted, then notes will " -"be printed with flags instead of beams. Only engraves beams when we " -" are at grace points in time. " -, -/* creats*/ "Beam", -/* accepts */ "beam-event", -/* acks */ "stem-interface rest-interface", -/* reads */ "beamMelismaBusy beatLength allowBeamBreak subdivideBeams", -/* write */ ""); + /* descr */ "Handles Beam events by engraving Beams. If omitted, then notes will " + "be printed with flags instead of beams. Only engraves beams when we " + " are at grace points in time. ", + /* creats*/ "Beam", + /* accepts */ "beam-event", + /* acks */ "stem-interface rest-interface", + /* reads */ "beamMelismaBusy beatLength allowBeamBreak subdivideBeams", + /* write */ ""); diff --git a/lily/beam-performer.cc b/lily/beam-performer.cc index d8ba6b240d..a7cd2547b1 100644 --- a/lily/beam-performer.cc +++ b/lily/beam-performer.cc @@ -4,7 +4,7 @@ source file of the GNU LilyPond music typesetter (c) 1996--2005 Jan Nieuwenhuizen - */ +*/ #include "performer.hh" #include "audio-item.hh" @@ -12,12 +12,13 @@ #include "global-context.hh" #include "warn.hh" -class Beam_performer : public Performer { +class Beam_performer : public Performer +{ public: TRANSLATOR_DECLARATIONS (Beam_performer); - + protected: - virtual bool try_music (Music *ev) ; + virtual bool try_music (Music *ev); virtual void start_translation_timestep (); virtual void process_music (); void set_melisma (bool); @@ -34,7 +35,7 @@ Beam_performer::Beam_performer () now_stop_ev_ = 0; } -void +void Beam_performer::process_music () { if (now_stop_ev_) @@ -50,13 +51,12 @@ Beam_performer::process_music () } } - void Beam_performer::set_melisma (bool ml) { SCM b = get_property ("autoBeaming"); if (!to_boolean (b)) -context ()->set_property ("beamMelismaBusy", ml ? SCM_BOOL_T :SCM_BOOL_F); + context ()->set_property ("beamMelismaBusy", ml ? SCM_BOOL_T :SCM_BOOL_F); } void @@ -65,7 +65,7 @@ Beam_performer::start_translation_timestep () start_ev_ = 0; now_stop_ev_ = 0; } - + bool Beam_performer::try_music (Music *m) { @@ -87,5 +87,5 @@ Beam_performer::try_music (Music *m) } ADD_TRANSLATOR (Beam_performer, "", "", - "beam-event", "", "", ""); + "beam-event", "", "", ""); diff --git a/lily/beam-quanting.cc b/lily/beam-quanting.cc index a3197932f6..c18c5c4cfe 100644 --- a/lily/beam-quanting.cc +++ b/lily/beam-quanting.cc @@ -1,11 +1,10 @@ /* beam-quanting.cc -- implement Beam quanting functions - + source file of the GNU LilyPond music typesetter - + (c) 1997--2005 Han-Wen Nienhuys Jan Nieuwenhuizen - */ #include @@ -19,13 +18,13 @@ #include "align-interface.hh" const int INTER_QUANT_PENALTY = 1000; -const Real SECONDARY_BEAM_DEMERIT = 10.0; +const Real SECONDARY_BEAM_DEMERIT = 10.0; const int STEM_LENGTH_DEMERIT_FACTOR = 5; /* threshold to combat rounding errors. - */ -const Real BEAM_EPS = 1e-3; +*/ +const Real BEAM_EPS = 1e-3; // possibly ridiculous, but too short stems just won't do const int STEM_LENGTH_LIMIT_PENALTY = 5000; @@ -40,7 +39,6 @@ shrink_extra_weight (Real x, Real fac) return fabs (x) * ((x < 0) ? fac : 1.0); } - struct Quant_score { Real yl; @@ -52,21 +50,19 @@ struct Quant_score #endif }; - /* TODO: - - - Make all demerits customisable - - One sensible check per demerit (what's this --hwn) + - Make all demerits customisable - - Add demerits for quants per se, as to forbid a specific quant - entirely + - One sensible check per demerit (what's this --hwn) + - Add demerits for quants per se, as to forbid a specific quant + entirely */ int -best_quant_score_idx (Array const & qscores) +best_quant_score_idx (Array const &qscores) { Real best = 1e6; int best_idx = -1; @@ -74,7 +70,7 @@ best_quant_score_idx (Array const & qscores) { if (qscores[i].demerits < best) { - best = qscores [i].demerits ; + best = qscores [i].demerits; best_idx = i; } } @@ -84,11 +80,10 @@ best_quant_score_idx (Array const & qscores) programming_error ("Huh? No best beam quant score?"); best_idx = 0; } - - + return best_idx; } - + MAKE_SCHEME_CALLBACK (Beam, quanting, 1); SCM Beam::quanting (SCM smob) @@ -99,14 +94,13 @@ Beam::quanting (SCM smob) Real yl = scm_to_double (scm_car (s)); Real yr = scm_to_double (scm_cdr (s)); - /* Calculations are relative to a unit-scaled staff, i.e. the quants are divided by the current staff_space. - - */ + + */ Real ss = Staff_symbol_referencer::staff_space (me); - Real thickness = Beam::get_thickness (me) / ss ; + Real thickness = Beam::get_thickness (me) / ss; Real slt = Staff_symbol_referencer::line_thickness (me) / ss; Real dy_mus = robust_scm2double (me->get_property ("least-squares-dy"), 0); @@ -116,9 +110,7 @@ Beam::quanting (SCM smob) Real hang = 1.0 - (thickness - slt) / 2; Real quants [] = {straddle, sit, inter, hang }; - - - int num_quants = int (sizeof (quants)/sizeof (Real)); + int num_quants = int (sizeof (quants) / sizeof (Real)); Array quantsl; Array quantsr; @@ -127,28 +119,26 @@ Beam::quanting (SCM smob) wtk1-fugue2. - (result indexes between 70 and 575) ? --hwn. + (result indexes between 70 and 575) ? --hwn. */ - - /* Do stem computations. These depend on YL and YR linearly, so we can precompute for every stem 2 factors. - */ - Link_array stems = - extract_grob_array (me, ly_symbol2scm ("stems")); + */ + Link_array stems + = extract_grob_array (me, ly_symbol2scm ("stems")); Array stem_infos; Array base_lengths; - Array stem_xposns; + Array stem_xposns; Drul_array dirs_found (0, 0); Grob *common[2]; for (int a = 2; a--;) common[a] = common_refpoint_of_array (stems, me, Axis (a)); - Grob * fvs = first_visible_stem (me); + Grob *fvs = first_visible_stem (me); Grob *lvs = last_visible_stem (me); Real xl = fvs ? fvs->relative_coordinate (common[X_AXIS], X_AXIS) : 0.0; Real xr = fvs ? lvs->relative_coordinate (common[X_AXIS], X_AXIS) : 0.0; @@ -159,11 +149,11 @@ Beam::quanting (SCM smob) Sometimes my head is screwed on backwards. The stemlength are AFFINE linear in YL and YR. If YL == YR == 0, then we might have stem_y != 0.0, when we're cross staff. - - */ + + */ for (int i = 0; i < stems.size (); i++) { - Grob*s = stems[i]; + Grob *s = stems[i]; Stem_info si (Stem::get_stem_info (s)); si.scale (1 / ss); @@ -171,7 +161,7 @@ Beam::quanting (SCM smob) dirs_found[stem_infos.top ().dir_] = true; bool f = to_boolean (s->get_property ("french-beaming")) - && s != lvs && s != fvs; + && s != lvs && s != fvs; base_lengths.push (calc_stem_y (me, s, common, xl, xr, Interval (0, 0), f) / ss); @@ -184,23 +174,22 @@ Beam::quanting (SCM smob) Grob *commony = fvs->common_refpoint (lvs, Y_AXIS); xstaff = Align_interface::has_interface (commony); } - + Direction ldir = Direction (stem_infos[0].dir_); Direction rdir = Direction (stem_infos.top ().dir_); bool is_knee = dirs_found[LEFT] && dirs_found[RIGHT]; - int region_size = REGION_SIZE; /* - Knees are harder, lets try some more possibilities for knees. - */ + Knees are harder, lets try some more possibilities for knees. + */ if (is_knee) region_size += 2; /* Asymetry ? should run to <= region_size ? - */ - for (int i = -region_size ; i < region_size; i++) + */ + for (int i = -region_size; i < region_size; i++) for (int j = 0; j < num_quants; j++) { quantsl.push (i + quants[j] + int (yl)); @@ -208,15 +197,15 @@ Beam::quanting (SCM smob) } Array qscores; - - for (int l = 0; l < quantsl.size (); l++) + + for (int l = 0; l < quantsl.size (); l++) for (int r = 0; r < quantsr.size (); r++) { Quant_score qs; qs.yl = quantsl[l]; qs.yr = quantsr[r]; qs.demerits = 0.0; - + qscores.push (qs); } @@ -226,10 +215,10 @@ Beam::quanting (SCM smob) parameters outside of the loop, we can save a lot of time. */ for (int i = qscores.size (); i--;) { - Real d = score_slopes_dy (qscores[i].yl, qscores[i].yr, - dy_mus, yr- yl, - xr - xl, - xstaff); + Real d = score_slopes_dy (qscores[i].yl, qscores[i].yr, + dy_mus, yr- yl, + xr - xl, + xstaff); qscores[i].demerits += d; #if DEBUG_QUANTING @@ -239,9 +228,9 @@ Beam::quanting (SCM smob) Real rad = Staff_symbol_referencer::staff_radius (me); Drul_array edge_beam_counts - (Stem::beam_multiplicity (stems[0]).length () + 1, - Stem::beam_multiplicity (stems.top ()).length () + 1); - + (Stem::beam_multiplicity (stems[0]).length () + 1, + Stem::beam_multiplicity (stems.top ()).length () + 1); + Real beam_translation = get_beam_translation (me) / ss; Real reasonable_score = (is_knee) ? 200000 : 100; @@ -250,7 +239,7 @@ Beam::quanting (SCM smob) { Real d = score_forbidden_quants (qscores[i].yl, qscores[i].yr, rad, slt, thickness, beam_translation, - edge_beam_counts, ldir, rdir); + edge_beam_counts, ldir, rdir); qscores[i].demerits += d; #if DEBUG_QUANTING @@ -262,11 +251,11 @@ Beam::quanting (SCM smob) if (qscores[i].demerits < reasonable_score) { Real d = score_stem_lengths (stems, stem_infos, - base_lengths, stem_xposns, - xl, xr, - is_knee, - qscores[i].yl, qscores[i].yr); - qscores[i].demerits += d; + base_lengths, stem_xposns, + xl, xr, + is_knee, + qscores[i].yl, qscores[i].yr); + qscores[i].demerits += d; #if DEBUG_QUANTING qscores[i].score_card_ += to_string (" L %.2f", d); @@ -285,7 +274,7 @@ Beam::quanting (SCM smob) int i = 0; Real mindist = 1e6; - for (; i < qscores.size (); i ++) + for (; i < qscores.size (); i++) { Real d = fabs (qscores[i].yl- ins[LEFT]) + fabs (qscores[i].yr - ins[RIGHT]); if (d < mindist) @@ -298,7 +287,7 @@ Beam::quanting (SCM smob) programming_error ("Could not find quant."); } #endif - + me->set_property ("positions", ly_interval2scm (Drul_array (qscores[best_idx].yl, qscores[best_idx].yr))); @@ -306,7 +295,7 @@ Beam::quanting (SCM smob) if (to_boolean (me->get_layout ()->lookup_variable (ly_symbol2scm ("debug-beam-quanting")))) { qscores[best_idx].score_card_ += to_string ("i%d", best_idx); - + // debug quanting me->set_property ("quant-score", scm_makfrom0str (qscores[best_idx].score_card_.to_str0 ())); @@ -321,53 +310,53 @@ Beam::score_stem_lengths (Link_array const &stems, Array const &stem_infos, Array const &base_stem_ys, Array const &stem_xs, - Real xl, Real xr, - bool knee, + Real xl, Real xr, + bool knee, Real yl, Real yr) { Real limit_penalty = STEM_LENGTH_LIMIT_PENALTY; Drul_array score (0, 0); Drul_array count (0, 0); - + for (int i = 0; i < stems.size (); i++) { - Grob* s = stems[i]; + Grob *s = stems[i]; if (Stem::is_invisible (s)) continue; Real x = stem_xs[i]; - Real dx = xr-xl; - Real beam_y = dx ? yr *(x - xl)/dx + yl * ( xr - x)/dx : (yr + yl)/2; + Real dx = xr - xl; + Real beam_y = dx ? yr * (x - xl) / dx + yl * (xr - x) / dx : (yr + yl) / 2; Real current_y = beam_y + base_stem_ys[i]; Real length_pen = STEM_LENGTH_DEMERIT_FACTOR; - + Stem_info info = stem_infos[i]; Direction d = info.dir_; score[d] += limit_penalty * (0 >? (d * (info.shortest_y_ - current_y))); - + Real ideal_diff = d * (current_y - info.ideal_y_); Real ideal_score = shrink_extra_weight (ideal_diff, 1.5); - + /* We introduce a power, to make the scoring strictly convex. Otherwise a symmetric knee beam (up/down/up/down) does not have an optimum in the middle. */ if (knee) ideal_score = pow (ideal_score, 1.1); - + score[d] += length_pen * ideal_score; - count[d] ++; + count[d]++; } Direction d = DOWN; do - { + { score[d] /= (count[d] >? 1); } while (flip (&d) != DOWN); - return score[LEFT]+score[RIGHT]; + return score[LEFT] + score[RIGHT]; } Real @@ -385,42 +374,39 @@ Beam::score_slopes_dy (Real yl, Real yr, TODO: find a way to incorporate the complexity of the beam in this penalty. - */ - if (fabs (dy/dx) > ROUND_TO_ZERO_SLOPE + */ + if (fabs (dy / dx) > ROUND_TO_ZERO_SLOPE && sign (dy_damp) != sign (dy)) { dem += DAMPING_DIRECTION_PENALTY; } - dem += MUSICAL_DIRECTION_FACTOR * (0 >? (fabs (dy) - fabs (dy_mus))); - + dem += MUSICAL_DIRECTION_FACTOR *(0 >? (fabs (dy) - fabs (dy_mus))); - Real slope_penalty = IDEAL_SLOPE_FACTOR; + Real slope_penalty = IDEAL_SLOPE_FACTOR; - /* Xstaff beams tend to use extreme slopes to get short stems. We - put in a penalty here. */ - if (xstaff) - slope_penalty *= 10; + /* Xstaff beams tend to use extreme slopes to get short stems. We + put in a penalty here. */ + if (xstaff) + slope_penalty *= 10; - /* Huh, why would a too steep beam be better than a too flat one ? */ - dem += shrink_extra_weight (fabs (dy_damp) - fabs (dy), 1.5) - * slope_penalty; + /* Huh, why would a too steep beam be better than a too flat one ? */ + dem += shrink_extra_weight (fabs (dy_damp) - fabs (dy), 1.5) + * slope_penalty; - return dem; + return dem; } - static Real my_modf (Real x) { return x - floor (x); } - /* TODO: The fixed value SECONDARY_BEAM_DEMERIT is probably flawed: - because for 32nd and 64th beams the forbidden quants are relatively - more important than stem lengths. + because for 32nd and 64th beams the forbidden quants are relatively + more important than stem lengths. */ Real Beam::score_forbidden_quants (Real yl, Real yr, @@ -433,12 +419,11 @@ Beam::score_forbidden_quants (Real yl, Real yr, Real dy = yr - yl; Drul_array y (yl, yr); Drul_array dirs (ldir, rdir); - + Real extra_demerit = SECONDARY_BEAM_DEMERIT / (beam_counts[LEFT] >? beam_counts[RIGHT]); Direction d = LEFT; Real dem = 0.0; - do { @@ -452,32 +437,31 @@ Beam::score_forbidden_quants (Real yl, Real yr, will be in the gap of the (2, sit) quant, leading to a false demerit. */ - Real gap1 = y[d] - stem_dir * ((j-1) * beam_translation + thickness / 2 - slt/2.2 ); - Real gap2 = y[d] - stem_dir * (j * beam_translation - thickness / 2 + slt/2.2); + Real gap1 = y[d] - stem_dir * ((j - 1) * beam_translation + thickness / 2 - slt / 2.2); + Real gap2 = y[d] - stem_dir * (j * beam_translation - thickness / 2 + slt / 2.2); Interval gap; gap.add_point (gap1); gap.add_point (gap2); - for (Real k = - radius ; - k <= radius + BEAM_EPS; k += 1.0) + for (Real k = -radius; + k <= radius + BEAM_EPS; k += 1.0) if (gap.contains (k)) { - Real dist = fabs (gap[UP]-k) ? beam_counts[RIGHT]) >= 2) { @@ -486,7 +470,6 @@ Beam::score_forbidden_quants (Real yl, Real yr, Real inter = 0.5; Real hang = 1.0 - (thickness - slt) / 2; - Direction d = LEFT; do { @@ -496,7 +479,7 @@ Beam::score_forbidden_quants (Real yl, Real yr, if (dirs[d] == UP && dy <= BEAM_EPS && fabs (my_modf (y[d]) - sit) < BEAM_EPS) dem += extra_demerit; - + if (dirs[d] == DOWN && dy >= BEAM_EPS && fabs (my_modf (y[d]) - hang) < BEAM_EPS) dem += extra_demerit; @@ -508,7 +491,7 @@ Beam::score_forbidden_quants (Real yl, Real yr, if (dirs[d] == UP && dy <= BEAM_EPS && fabs (my_modf (y[d]) - straddle) < BEAM_EPS) dem += extra_demerit; - + if (dirs[d] == DOWN && dy >= BEAM_EPS && fabs (my_modf (y[d]) - straddle) < BEAM_EPS) dem += extra_demerit; @@ -516,8 +499,7 @@ Beam::score_forbidden_quants (Real yl, Real yr, } while (flip (&d) != LEFT); } - + return dem; } - diff --git a/lily/beam.cc b/lily/beam.cc index 3880f691bd..dbe22733de 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -1,31 +1,28 @@ /* beam.cc -- implement Beam - + source file of the GNU LilyPond music typesetter - + (c) 1997--2005 Han-Wen Nienhuys Jan Nieuwenhuizen */ /* -TODO: + TODO: - Determine auto knees based on positions if it's set by the user. - the code is littered with * and / staff_space calls for - #'positions. Consider moving to real-world coordinates? + #'positions. Consider moving to real-world coordinates? - Problematic issue is user tweaks (user tweaks are in staff-coordinates.) - -Notes: + Problematic issue is user tweaks (user tweaks are in staff-coordinates.) - - Stems run to the Y-center of the beam. - - - beam_translation is the offset between Y centers of the beam. - -*/ + Notes: + - Stems run to the Y-center of the beam. + - beam_translation is the offset between Y centers of the beam. +*/ #include // tanh. @@ -44,29 +41,26 @@ Notes: #include "spanner.hh" #include "warn.hh" - #if DEBUG_QUANTING -#include "text-item.hh" // debug output. -#include "font-interface.hh" // debug output. +#include "text-item.hh" // debug output. +#include "font-interface.hh" // debug output. #endif - void Beam::add_stem (Grob *me, Grob *s) { Pointer_group_interface::add_grob (me, ly_symbol2scm ("stems"), s); - + s->add_dependency (me); assert (!Stem::get_beam (s)); s->set_property ("beam", me->self_scm ()); - add_bound_item (dynamic_cast (me), dynamic_cast (s)); + add_bound_item (dynamic_cast (me), dynamic_cast (s)); } - Real -Beam::get_thickness (Grob * me) +Beam::get_thickness (Grob *me) { return robust_scm2double (me->get_property ("thickness"), 0) * Staff_symbol_referencer::staff_space (me); @@ -91,7 +85,7 @@ Beam::get_beam_translation (Grob *me) /* Maximum beam_count. */ int -Beam::get_beam_count (Grob *me) +Beam::get_beam_count (Grob *me) { int m = 0; for (SCM s = me->get_property ("stems"); scm_is_pair (s); s = scm_cdr (s)) @@ -102,28 +96,26 @@ Beam::get_beam_count (Grob *me) return m; } - /* Space return space between beams. - */ +*/ MAKE_SCHEME_CALLBACK (Beam, space_function, 2); SCM Beam::space_function (SCM smob, SCM beam_count) { Grob *me = unsmob_grob (smob); - + Real staff_space = Staff_symbol_referencer::staff_space (me); Real line = Staff_symbol_referencer::line_thickness (me); Real thickness = get_thickness (me); - + Real beam_translation = scm_to_int (beam_count) < 4 ? (2*staff_space + line - thickness) / 2.0 : (3*staff_space + line - thickness) / 3.0; - + return scm_make_real (beam_translation); } - /* After pre-processing all directions should be set. Several post-processing routines (stem, slur, script) need stem/beam direction. @@ -134,15 +126,15 @@ MAKE_SCHEME_CALLBACK (Beam, before_line_breaking, 1); SCM Beam::before_line_breaking (SCM smob) { - Grob *me = unsmob_grob (smob); + Grob *me = unsmob_grob (smob); /* Beams with less than 2 two stems don't make much sense, but could happen when you do - + [r8 c8 r8]. - - For a beam that only has one stem, we try to do some disappearance magic: - we revert the flag, and move on to The Eternal Engraving Fields. */ + + For a beam that only has one stem, we try to do some disappearance magic: + we revert the flag, and move on to The Eternal Engraving Fields. */ int count = visible_stem_count (me); if (count < 2) @@ -162,7 +154,7 @@ Beam::before_line_breaking (SCM smob) else if (scm_ilength (stems) == 0) { me->suicide (); - return SCM_UNSPECIFIED; + return SCM_UNSPECIFIED; } } if (count >= 1) @@ -180,21 +172,18 @@ Beam::before_line_breaking (SCM smob) return SCM_EOL; } - /* We want a maximal number of shared beams, but if there is choice, we take the one that is closest to the end of the stem. This is for situations like - x - | - | + x + | + | |===| |= | x - - - */ +*/ int position_with_maximal_common_beams (SCM left_beaming, SCM right_beaming, Direction left_dir, @@ -205,19 +194,19 @@ position_with_maximal_common_beams (SCM left_beaming, SCM right_beaming, int best_count = 0; int best_start = 0; for (int i = lslice[-left_dir]; - (i - lslice[left_dir])* left_dir <= 0 ; i+= left_dir) + (i - lslice[left_dir])* left_dir <= 0; i+= left_dir) { int count = 0; - for ( SCM s = scm_car (right_beaming); scm_is_pair (s); s = scm_cdr (s)) + for (SCM s = scm_car (right_beaming); scm_is_pair (s); s = scm_cdr (s)) { - int k = - right_dir * scm_to_int (scm_car (s)) + i; + int k = -right_dir * scm_to_int (scm_car (s)) + i; if (scm_c_memq (scm_int2num (k), left_beaming) != SCM_BOOL_F) - count ++; + count++; } if (count >= best_count) { - best_count = count; + best_count = count; best_start = i; } } @@ -228,8 +217,8 @@ position_with_maximal_common_beams (SCM left_beaming, SCM right_beaming, void Beam::connect_beams (Grob *me) { - Link_array stems = - extract_grob_array (me, ly_symbol2scm ("stems")); + Link_array stems + = extract_grob_array (me, ly_symbol2scm ("stems")); Slice last_int; last_int.set_empty (); @@ -246,39 +235,38 @@ Beam::connect_beams (Grob *me) int start_point = position_with_maximal_common_beams (last_beaming, this_beaming, last_dir, this_dir); - + Direction d = LEFT; - Slice new_slice ; + Slice new_slice; do { - if (d == RIGHT && i == stems.size ()-1) + if (d == RIGHT && i == stems.size () - 1) continue; - + new_slice.set_empty (); SCM s = index_get_cell (this_beaming, d); for (; scm_is_pair (s); s = scm_cdr (s)) { - int new_beam_pos = - start_point - this_dir * scm_to_int (scm_car (s)); + int new_beam_pos + = start_point - this_dir * scm_to_int (scm_car (s)); new_slice.add_point (new_beam_pos); scm_set_car_x (s, scm_int2num (new_beam_pos)); } - } while (flip (&d) != LEFT); if (!new_slice.is_empty ()) - last_int = new_slice; + last_int = new_slice; } else { - scm_set_car_x ( this_beaming, SCM_EOL); + scm_set_car_x (this_beaming, SCM_EOL); SCM s = scm_cdr (this_beaming); for (; scm_is_pair (s); s = scm_cdr (s)) { - int np = - this_dir * scm_to_int (scm_car (s)); + int np = -this_dir * scm_to_int (scm_car (s)); scm_set_car_x (s, scm_int2num (np)); last_int.add_point (np); } @@ -295,22 +283,21 @@ Beam::connect_beams (Grob *me) last_dir = this_dir; } } - } - +} /* TODO: should not make beams per stem, but per Y-level. - */ +*/ MAKE_SCHEME_CALLBACK (Beam, print, 1); SCM Beam::print (SCM grob) { Spanner *me = unsmob_spanner (grob); position_beam (me); - - Link_array stems = - extract_grob_array (me, ly_symbol2scm ("stems")); - Grob* xcommon = common_refpoint_of_array (stems, me, X_AXIS); + + Link_array stems + = extract_grob_array (me, ly_symbol2scm ("stems")); + Grob *xcommon = common_refpoint_of_array (stems, me, X_AXIS); xcommon = me->get_bound (LEFT)->common_refpoint (xcommon, X_AXIS); xcommon = me->get_bound (RIGHT)->common_refpoint (xcommon, X_AXIS); @@ -338,42 +325,42 @@ Beam::print (SCM grob) else pos = ly_scm2realdrul (posns); - scale_drul (&pos, Staff_symbol_referencer::staff_space (me)); - + scale_drul (&pos, Staff_symbol_referencer::staff_space (me)); + Real dy = pos[RIGHT] - pos[LEFT]; - Real slope = (dy && dx) ? dy/dx : 0; - + Real slope = (dy && dx) ? dy / dx : 0; + Real thick = get_thickness (me); Real bdy = get_beam_translation (me); SCM last_beaming = SCM_EOL; Real last_xposn = -1; - Real last_stem_width = -1 ; + Real last_stem_width = -1; Real gap_length = robust_scm2double (me->get_property ("gap"), 0.0); - + Stencil the_beam; Real lt = me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness")); - + for (int i = 0; i<= stems.size (); i++) { - Grob * st = (i < stems.size ()) ? stems[i] : 0; - + Grob *st = (i < stems.size ()) ? stems[i] : 0; + SCM this_beaming = st ? st->get_property ("beaming") : SCM_EOL; Real xposn = st ? st->relative_coordinate (xcommon, X_AXIS) : 0.0; - Real stem_width = st ? robust_scm2double (st->get_property ("thickness"), 1.0) *lt : 0 ; + Real stem_width = st ? robust_scm2double (st->get_property ("thickness"), 1.0) *lt : 0; Direction stem_dir = st ? to_dir (st->get_property ("direction")) : CENTER; /* We do the space left of ST, with lfliebertjes pointing to the right from the left stem, and rfliebertjes pointing left from right stem. - */ + */ SCM left = (i > 0) ? scm_cdr (last_beaming) : SCM_EOL; SCM right = st ? scm_car (this_beaming) : SCM_EOL; Array full_beams; Array lfliebertjes; - Array rfliebertjes; + Array rfliebertjes; for (SCM s = left; scm_is_pair (s); s = scm_cdr (s)) @@ -385,7 +372,7 @@ Beam::print (SCM grob) } else { - lfliebertjes.push (b); + lfliebertjes.push (b); } } for (SCM s = right; @@ -400,7 +387,7 @@ Beam::print (SCM grob) /* how much to stick out for beams across linebreaks - */ + */ Real break_overshoot = 3.0; Real w = (i > 0 && st) ? (xposn - last_xposn) : break_overshoot; @@ -412,8 +399,7 @@ Beam::print (SCM grob) } if (st) - w += stem_width/ 2 ; - + w += stem_width/ 2; Real blot = me->get_layout ()->get_dimension (ly_symbol2scm ("blotdiameter")); Stencil whole = Lookup::beam (slope, w, thick, blot); @@ -434,25 +420,25 @@ Beam::print (SCM grob) for (int j = full_beams.size (); j--;) { Stencil b (whole); - + if (k++ < gap_count) { b = gapped; b.translate_axis (gap_length, X_AXIS); } - b.translate_axis (last_xposn - x0 + stem_offset, X_AXIS); + b.translate_axis (last_xposn - x0 + stem_offset, X_AXIS); b.translate_axis (slope * (last_xposn - x0) + bdy * full_beams[j], Y_AXIS); - the_beam.add_stencil (b); + the_beam.add_stencil (b); } - + if (lfliebertjes.size () || rfliebertjes.size ()) { Real nw_f; if (st) { - int t = Stem::duration_log (st); + int t = Stem::duration_log (st); SCM proc = me->get_property ("flag-width-function"); SCM result = scm_call_1 (proc, scm_int2num (t)); @@ -460,22 +446,22 @@ Beam::print (SCM grob) } else nw_f = break_overshoot / 2; - + /* Half beam should be one note-width, but let's make sure two half-beams never touch */ Real lw = nw_f; Real rw = nw_f; if (i > 0) - rw = nw_f get_bound (LEFT)->extent (xcommon, X_AXIS)[RIGHT] - 0.5; - + if (st) - lw = nw_f get_bound (RIGHT)->relative_coordinate (xcommon, X_AXIS) - last_xposn; @@ -485,20 +471,19 @@ Beam::print (SCM grob) for (int j = lfliebertjes.size (); j--;) { Stencil b (lhalf); - b.translate_axis (last_xposn - x0, X_AXIS); - b.translate_axis (slope * (last_xposn-x0) + bdy * lfliebertjes[j], Y_AXIS); - the_beam.add_stencil (b); + b.translate_axis (last_xposn - x0, X_AXIS); + b.translate_axis (slope * (last_xposn - x0) + bdy * lfliebertjes[j], Y_AXIS); + the_beam.add_stencil (b); } for (int j = rfliebertjes.size (); j--;) { Stencil b (rhalf); - b.translate_axis (xposn - x0 - rw , X_AXIS); - b.translate_axis (slope * (xposn-x0 -rw) + bdy * rfliebertjes[j], Y_AXIS); - the_beam.add_stencil (b); + b.translate_axis (xposn - x0 - rw, X_AXIS); + b.translate_axis (slope * (xposn - x0 -rw) + bdy * rfliebertjes[j], Y_AXIS); + the_beam.add_stencil (b); } } - last_xposn = xposn; last_stem_width = stem_width; last_beaming = this_beaming; @@ -512,7 +497,7 @@ Beam::print (SCM grob) if (to_boolean (me->get_layout ()->lookup_variable (ly_symbol2scm ("debug-beam-quanting"))) && scm_is_string (quant_score)) { - + /* This code prints the demerits for each beam. Perhaps this should be switchable for those who want to twiddle with the @@ -521,62 +506,61 @@ Beam::print (SCM grob) String str; SCM properties = Font_interface::text_font_alist_chain (me); - Direction stem_dir = stems.size() ? to_dir (stems[0]->get_property ("direction")) : UP; - + Direction stem_dir = stems.size () ? to_dir (stems[0]->get_property ("direction")) : UP; + Stencil tm = *unsmob_stencil (Text_interface::interpret_markup - (me->get_layout ()->self_scm (), properties, quant_score)); + (me->get_layout ()->self_scm (), properties, quant_score)); the_beam.add_at_edge (Y_AXIS, stem_dir, tm, 1.0, 0); } #endif - + return the_beam.smobbed_copy (); } - - Direction -Beam::get_default_dir (Grob *me) +Beam::get_default_dir (Grob *me) { Drul_array total; - total[UP] = total[DOWN] = 0; - Drul_array count; - count[UP] = count[DOWN] = 0; + total[UP] = total[DOWN] = 0; + Drul_array count; + count[UP] = count[DOWN] = 0; Direction d = DOWN; - Link_array stems = - extract_grob_array (me, ly_symbol2scm ("stems")); + Link_array stems + = extract_grob_array (me, ly_symbol2scm ("stems")); for (int i = 0; i < stems.size (); i++) - do { - Grob *s = stems[i]; - Direction sd = get_grob_direction (s); - - int center_distance = int (- d * Stem::head_positions (s) [-d]) >? 0; - int current = sd ? (1 + d * sd)/2 : center_distance; + do + { + Grob *s = stems[i]; + Direction sd = get_grob_direction (s); + + int center_distance = int (- d * Stem::head_positions (s) [-d]) >? 0; + int current = sd ? (1 + d * sd) / 2 : center_distance; + + if (current) + { + total[d] += current; + count[d]++; + } + } + while (flip (&d) != DOWN); - if (current) - { - total[d] += current; - count[d] ++; - } - } while (flip (&d) != DOWN); - SCM func = me->get_property ("dir-function"); SCM s = scm_call_2 (func, - scm_cons (scm_int2num (count[UP]), - scm_int2num (count[DOWN])), - scm_cons (scm_int2num (total[UP]), - scm_int2num (total[DOWN]))); + scm_cons (scm_int2num (count[UP]), + scm_int2num (count[DOWN])), + scm_cons (scm_int2num (total[UP]), + scm_int2num (total[DOWN]))); if (scm_is_number (s) && scm_to_int (s)) return to_dir (s); - + /* If dir is not determined: get default */ return to_dir (me->get_property ("neutral-direction")); } - /* Set all stems with non-forced direction to beam direction. Urg: non-forced should become `without/with unforced' direction, once stem gets cleaned-up. */ @@ -585,14 +569,14 @@ Beam::set_stem_directions (Grob *me, Direction d) { Link_array stems = extract_grob_array (me, ly_symbol2scm ("stems")); - + for (int i = 0; i get_property ("direction"); if (!to_dir (forcedir)) - set_grob_direction (s, d); + set_grob_direction (s, d); } } @@ -601,28 +585,28 @@ Beam::set_stem_directions (Grob *me, Direction d) anything else is possible here, since we don't know funky-beaming settings, or X-distances (slopes!) People that want sloped knee-beams, should set the directions manually. - */ +*/ void -Beam::consider_auto_knees (Grob* me) +Beam::consider_auto_knees (Grob *me) { SCM scm = me->get_property ("auto-knee-gap"); if (!scm_is_number (scm)) - return ; + return; Interval_set gaps; gaps.set_full (); - Link_array stems = - extract_grob_array (me, ly_symbol2scm ("stems")); - - Grob *common = common_refpoint_of_array (stems, me, Y_AXIS); + Link_array stems + = extract_grob_array (me, ly_symbol2scm ("stems")); + + Grob *common = common_refpoint_of_array (stems, me, Y_AXIS); Real staff_space = Staff_symbol_referencer::staff_space (me); - - Array head_positions_array; + + Array head_positions_array; for (int i = 0; i < stems.size (); i++) { - Grob* stem = stems[i]; + Grob *stem = stems[i]; if (Stem::is_invisible (stem)) continue; @@ -630,20 +614,20 @@ Beam::consider_auto_knees (Grob* me) if (!head_positions.is_empty ()) { head_positions[LEFT] += -1; - head_positions[RIGHT] += 1; - head_positions *= staff_space * 0.5 ; + head_positions[RIGHT] += 1; + head_positions *= staff_space * 0.5; /* We could subtract beam Y position, but this routine only sets stem directions, a constant shift does not have an influence. - */ + */ head_positions += stem->relative_coordinate (common, Y_AXIS); if (to_dir (stem->get_property ("direction"))) { Direction stemdir = to_dir (stem->get_property ("direction")); - head_positions[-stemdir] = - stemdir * infinity_f; + head_positions[-stemdir] = -stemdir * infinity_f; } } head_positions_array.push (head_positions); @@ -654,16 +638,16 @@ Beam::consider_auto_knees (Grob* me) Interval max_gap; Real max_gap_len = 0.0; - for (int i = gaps.allowed_regions_.size () -1; i >= 0 ; i--) + for (int i = gaps.allowed_regions_.size () -1; i >= 0; i--) { Interval gap = gaps.allowed_regions_[i]; /* the outer gaps are not knees. - */ + */ if (isinf (gap[LEFT]) || isinf (gap[RIGHT])) continue; - + if (gap.length () >= max_gap_len) { max_gap_len = gap.length (); @@ -673,55 +657,51 @@ Beam::consider_auto_knees (Grob* me) Real beam_translation = get_beam_translation (me); Real beam_thickness = Beam::get_thickness (me); - int beam_count = Beam::get_beam_count (me); + int beam_count = Beam::get_beam_count (me); Real height_of_beams = beam_thickness / 2 + (beam_count - 1) * beam_translation; - Real threshold = scm_to_double (scm) + height_of_beams; - + Real threshold = scm_to_double (scm) + height_of_beams; + if (max_gap_len > threshold) { int j = 0; for (int i = 0; i < stems.size (); i++) { - Grob* stem = stems[i]; + Grob *stem = stems[i]; if (Stem::is_invisible (stem)) continue; Interval head_positions = head_positions_array[j++]; + Direction d = (head_positions.center () < max_gap.center ()) ? + UP : DOWN; - Direction d = (head_positions.center () < max_gap.center ()) ? - UP : DOWN ; - stem->set_property ("direction", scm_int2num (d)); - + head_positions.intersect (max_gap); - assert (head_positions.is_empty () || head_positions.length () < 1e-6 ); + assert (head_positions.is_empty () || head_positions.length () < 1e-6); } } } - - /* Set stem's shorten property if unset. - TODO: - take some y-position (chord/beam/nearest?) into account - scmify forced-fraction - - This is done in beam because the shorten has to be uniform over the - entire beam. +TODO: +take some y-position (chord/beam/nearest?) into account +scmify forced-fraction +This is done in beam because the shorten has to be uniform over the +entire beam. */ void Beam::set_stem_shorten (Grob *me) { /* shortening looks silly for x staff beams - */ + */ if (is_knee (me)) - return ; - + return; + Real forced_fraction = 1.0 * forced_stem_count (me) / visible_stem_count (me); @@ -732,9 +712,9 @@ Beam::set_stem_shorten (Grob *me) return; Real staff_space = Staff_symbol_referencer::staff_space (me); - - SCM shorten_elt = - robust_list_ref (beam_count -1, shorten_list); + + SCM shorten_elt + = robust_list_ref (beam_count -1, shorten_list); Real shorten_f = scm_to_double (shorten_elt) * staff_space; /* your similar cute comment here */ @@ -746,7 +726,6 @@ Beam::set_stem_shorten (Grob *me) /* Call list of y-dy-callbacks, that handle setting of grob-properties - */ MAKE_SCHEME_CALLBACK (Beam, after_line_breaking, 1); SCM @@ -762,9 +741,9 @@ void Beam::position_beam (Grob *me) { if (!me->is_live ()) - return ; + return; if (to_boolean (me->get_property ("positioning-done"))) - return ; + return; me->set_property ("positioning-done", SCM_BOOL_T); @@ -780,36 +759,35 @@ Beam::position_beam (Grob *me) scm_call_1 (scm_car (i), me->self_scm ()); } - set_stem_lengths (me); + set_stem_lengths (me); } - void -set_minimum_dy (Grob *me, Real * dy) +set_minimum_dy (Grob *me, Real *dy) { if (*dy) { /* If dy is smaller than the smallest quant, we - get absurd direction-sign penalties. + get absurd direction-sign penalties. */ - + Real ss = Staff_symbol_referencer::staff_space (me); - Real thickness = Beam::get_thickness (me) / ss ; + Real thickness = Beam::get_thickness (me) / ss; Real slt = Staff_symbol_referencer::line_thickness (me) / ss; Real sit = (thickness - slt) / 2; Real inter = 0.5; Real hang = 1.0 - (thickness - slt) / 2; - + *dy = sign (*dy) * (fabs (*dy) - >? - (sit ? + (sit set_property ("positions", ly_interval2scm (pos)); return SCM_UNSPECIFIED; } - - Array x_posns ; - Link_array stems = - extract_grob_array (me, ly_symbol2scm ("stems")); + Array x_posns; + Link_array stems + = extract_grob_array (me, ly_symbol2scm ("stems")); Grob *commonx = common_refpoint_of_array (stems, me, X_AXIS); - Grob *commony = common_refpoint_of_array (stems, me, Y_AXIS); + Grob *commony = common_refpoint_of_array (stems, me, Y_AXIS); Real my_y = me->relative_coordinate (commony, Y_AXIS); - - Grob *fvs = first_visible_stem (me); - Grob *lvs = last_visible_stem (me); - + + Grob *fvs = first_visible_stem (me); + Grob *lvs = last_visible_stem (me); + Interval ideal (Stem::get_stem_info (fvs).ideal_y_ + fvs->relative_coordinate (commony, Y_AXIS) -my_y, Stem::get_stem_info (lvs).ideal_y_ + lvs->relative_coordinate (commony, Y_AXIS) - my_y); - + Real x0 = first_visible_stem (me)->relative_coordinate (commonx, X_AXIS); for (int i = 0; i < stems.size (); i++) { - Grob* s = stems[i]; + Grob *s = stems[i]; Real x = s->relative_coordinate (commonx, X_AXIS) - x0; x_posns.push (x); } Real dx = last_visible_stem (me)->relative_coordinate (commonx, X_AXIS) - x0; - - Real y = 0; + Real y = 0; Real slope = 0; Real dy = 0; - + if (!ideal.delta ()) { Interval chord (Stem::chord_start_y (first_visible_stem (me)), @@ -864,7 +840,7 @@ Beam::least_squares (SCM smob) /* Simple beams (2 stems) on middle line should be allowed to be slightly sloped. - + However, if both stems reach middle line, ideal[LEFT] == ideal[RIGHT] and ideal.delta () == 0. @@ -874,7 +850,7 @@ Beam::least_squares (SCM smob) /* FIXME. -> UP */ Direction d = (Direction) (sign (chord.delta ()) * UP); pos[d] = get_thickness (me) / 2; - pos[-d] = - pos[d]; + pos[-d] = -pos[d]; } else { @@ -894,7 +870,7 @@ Beam::least_squares (SCM smob) Array ideals; for (int i = 0; i < stems.size (); i++) { - Grob* s = stems[i]; + Grob *s = stems[i]; if (Stem::is_invisible (s)) continue; ideals.push (Offset (x_posns[i], @@ -902,34 +878,32 @@ Beam::least_squares (SCM smob) + s->relative_coordinate (commony, Y_AXIS) - my_y)); } - + minimise_least_squares (&slope, &y, ideals); dy = slope * dx; set_minimum_dy (me, &dy); me->set_property ("least-squares-dy", scm_make_real (dy)); - pos = Interval (y, (y+dy)); + pos = Interval (y, (y + dy)); } /* "position" is relative to the staff. - */ - scale_drul (&pos, 1/ Staff_symbol_referencer::staff_space (me)); - + */ + scale_drul (&pos, 1/ Staff_symbol_referencer::staff_space (me)); + me->set_property ("positions", ly_interval2scm (pos)); - + return SCM_UNSPECIFIED; } - /* We can't combine with previous function, since check concave and slope damping comes first. TODO: we should use the concaveness to control the amount of damping applied. - */ MAKE_SCHEME_CALLBACK (Beam, shift_region_to_valid, 1); SCM @@ -938,22 +912,22 @@ Beam::shift_region_to_valid (SCM grob) Grob *me = unsmob_grob (grob); /* Code dup. - */ - Array x_posns ; - Link_array stems = - extract_grob_array (me, ly_symbol2scm ("stems")); + */ + Array x_posns; + Link_array stems + = extract_grob_array (me, ly_symbol2scm ("stems")); Grob *commonx = common_refpoint_of_array (stems, me, X_AXIS); - Grob *commony = common_refpoint_of_array (stems, me, Y_AXIS); + Grob *commony = common_refpoint_of_array (stems, me, Y_AXIS); Grob *fvs = first_visible_stem (me); if (!fvs) return SCM_UNSPECIFIED; - + Real x0 = fvs->relative_coordinate (commonx, X_AXIS); for (int i = 0; i < stems.size (); i++) { - Grob* s = stems[i]; + Grob *s = stems[i]; Real x = s->relative_coordinate (commonx, X_AXIS) - x0; x_posns.push (x); @@ -962,51 +936,50 @@ Beam::shift_region_to_valid (SCM grob) Grob *lvs = last_visible_stem (me); if (!lvs) return SCM_UNSPECIFIED; - + Real dx = lvs->relative_coordinate (commonx, X_AXIS) - x0; - Drul_array pos = ly_scm2interval ( me->get_property ("positions")); + Drul_array pos = ly_scm2interval (me->get_property ("positions")); + + scale_drul (&pos, Staff_symbol_referencer::staff_space (me)); - scale_drul (&pos, Staff_symbol_referencer::staff_space (me)); - Real dy = pos[RIGHT] - pos[LEFT]; Real y = pos[LEFT]; - Real slope = dy/dx; + Real slope = dy / dx; - /* Shift the positions so that we have a chance of finding good quants (i.e. no short stem failures.) - */ + */ Interval feasible_left_point; feasible_left_point.set_full (); for (int i = 0; i < stems.size (); i++) { - Grob* s = stems[i]; + Grob *s = stems[i]; if (Stem::is_invisible (s)) continue; Direction d = Stem::get_direction (s); - Real left_y = - Stem::get_stem_info (s).shortest_y_ + Real left_y + = Stem::get_stem_info (s).shortest_y_ - slope * x_posns [i]; /* left_y is now relative to the stem S. We want relative to ourselves, so translate: - */ - left_y += - + s->relative_coordinate (commony, Y_AXIS) + */ + left_y + += + s->relative_coordinate (commony, Y_AXIS) - me->relative_coordinate (commony, Y_AXIS); - Interval flp ; + Interval flp; flp.set_full (); flp[-d] = left_y; feasible_left_point.intersect (flp); } - + if (feasible_left_point.is_empty ()) warning (_ ("no viable initial configuration found: may not find good beam slope")); else if (!feasible_left_point.contains (y)) @@ -1018,10 +991,10 @@ Beam::shift_region_to_valid (SCM grob) else y = feasible_left_point.center (); } - - pos = Drul_array (y, (y+dy)); + + pos = Drul_array (y, (y + dy)); scale_drul (&pos, 1/ Staff_symbol_referencer::staff_space (me)); - + me->set_property ("positions", ly_interval2scm (pos)); return SCM_UNSPECIFIED; } @@ -1038,40 +1011,39 @@ Beam::slope_damping (SCM smob) if (visible_stem_count (me) <= 1) return SCM_UNSPECIFIED; - SCM s = me->get_property ("damping"); + SCM s = me->get_property ("damping"); Real damping = scm_to_double (s); if (damping) { Drul_array pos = ly_scm2interval (me->get_property ("positions")); - scale_drul (&pos, Staff_symbol_referencer::staff_space (me)); - + scale_drul (&pos, Staff_symbol_referencer::staff_space (me)); + Real dy = pos[RIGHT] - pos[LEFT]; - Grob *fvs = first_visible_stem (me); - Grob *lvs = last_visible_stem (me); + Grob *fvs = first_visible_stem (me); + Grob *lvs = last_visible_stem (me); Grob *commonx = fvs->common_refpoint (lvs, X_AXIS); - Real dx = last_visible_stem (me)->relative_coordinate (commonx, X_AXIS) - first_visible_stem (me)->relative_coordinate (commonx, X_AXIS); - Real slope = dy && dx ? dy/dx : 0; + Real slope = dy && dx ? dy / dx : 0; Real concaveness = robust_scm2double (me->get_property ("concaveness"), 0.0); - + slope = 0.6 * tanh (slope) / (damping + concaveness); Real damped_dy = slope * dx; set_minimum_dy (me, &damped_dy); - + pos[LEFT] += (dy - damped_dy) / 2; pos[RIGHT] -= (dy - damped_dy) / 2; - scale_drul (&pos, 1/Staff_symbol_referencer::staff_space (me)); - + scale_drul (&pos, 1 / Staff_symbol_referencer::staff_space (me)); + me->set_property ("positions", ly_interval2scm (pos)); } return SCM_UNSPECIFIED; @@ -1080,16 +1052,16 @@ Beam::slope_damping (SCM smob) /* Report slice containing the numbers that are both in (car BEAMING) and (cdr BEAMING) - */ +*/ Slice where_are_the_whole_beams (SCM beaming) { - Slice l; - - for ( SCM s = scm_car (beaming); scm_is_pair (s) ; s = scm_cdr (s)) + Slice l; + + for (SCM s = scm_car (beaming); scm_is_pair (s); s = scm_cdr (s)) { if (scm_c_memq (scm_car (s), scm_cdr (beaming)) != SCM_BOOL_F) - + l.add_point (scm_to_int (scm_car (s))); } @@ -1099,13 +1071,12 @@ where_are_the_whole_beams (SCM beaming) /* Return the Y position of the stem-end, given the Y-left, Y-right in POS for stem S. This Y position is relative to S. */ Real -Beam::calc_stem_y (Grob *me, Grob* s, Grob ** common, +Beam::calc_stem_y (Grob *me, Grob *s, Grob ** common, Real xl, Real xr, - Drul_array pos, bool french) + Drul_array pos, bool french) { Real beam_translation = get_beam_translation (me); - Real r = s->relative_coordinate (common[X_AXIS], X_AXIS) - xl; Real dy = pos[RIGHT] - pos[LEFT]; Real dx = xr - xl; @@ -1113,10 +1084,10 @@ Beam::calc_stem_y (Grob *me, Grob* s, Grob ** common, ? r / dx * dy : 0) + pos[LEFT]; - + Direction my_dir = get_grob_direction (s); SCM beaming = s->get_property ("beaming"); - + Real stem_y = stem_y_beam0; if (french) { @@ -1130,10 +1101,10 @@ Beam::calc_stem_y (Grob *me, Grob* s, Grob ** common, if (!bm.is_empty ()) stem_y += bm[my_dir] * beam_translation; } - + Real id = me->relative_coordinate (common[Y_AXIS], Y_AXIS) - s->relative_coordinate (common[Y_AXIS], Y_AXIS); - + return stem_y + id; } @@ -1144,19 +1115,19 @@ Beam::calc_stem_y (Grob *me, Grob* s, Grob ** common, void Beam::set_stem_lengths (Grob *me) { - Link_array stems = - extract_grob_array (me, ly_symbol2scm ("stems")); + Link_array stems + = extract_grob_array (me, ly_symbol2scm ("stems")); if (!stems.size ()) return; - + Grob *common[2]; for (int a = 2; a--;) common[a] = common_refpoint_of_array (stems, me, Axis (a)); - + Drul_array pos = ly_scm2realdrul (me->get_property ("positions")); Real staff_space = Staff_symbol_referencer::staff_space (me); - scale_drul (&pos, staff_space); + scale_drul (&pos, staff_space); bool gap = false; Real thick = 0.0; @@ -1166,17 +1137,17 @@ Beam::set_stem_lengths (Grob *me) gap = true; thick = get_thickness (me); } - + // ugh -> use commonx - Grob * fvs = first_visible_stem (me); + Grob *fvs = first_visible_stem (me); Grob *lvs = last_visible_stem (me); - + Real xl = fvs ? fvs->relative_coordinate (common[X_AXIS], X_AXIS) : 0.0; Real xr = lvs ? lvs->relative_coordinate (common[X_AXIS], X_AXIS) : 0.0; - + for (int i = 0; i < stems.size (); i++) { - Grob* s = stems[i]; + Grob *s = stems[i]; if (Stem::is_invisible (s)) continue; @@ -1188,7 +1159,7 @@ Beam::set_stem_lengths (Grob *me) /* Make the stems go up to the end of the beam. This doesn't matter for normal beams, but for tremolo beams it looks silly otherwise. - */ + */ if (gap) stem_y += thick * 0.5 * get_grob_direction (s); @@ -1199,34 +1170,34 @@ Beam::set_stem_lengths (Grob *me) void Beam::set_beaming (Grob *me, Beaming_info_list *beaming) { - Link_array stems = - extract_grob_array (me, ly_symbol2scm ("stems")); - + Link_array stems + = extract_grob_array (me, ly_symbol2scm ("stems")); + Direction d = LEFT; - for (int i = 0; i < stems.size (); i++) + for (int i = 0; i < stems.size (); i++) { /* Don't overwrite user settings. - */ - + */ + do { - /* Don't set beaming for outside of outer stems */ - if ( (d == LEFT && i == 0) + /* Don't set beaming for outside of outer stems */ + if ((d == LEFT && i == 0) || (d == RIGHT && i == stems.size () -1)) continue; - Grob *st = stems[i]; + Grob *st = stems[i]; SCM beaming_prop = st->get_property ("beaming"); - if (beaming_prop == SCM_EOL || - index_get_cell (beaming_prop, d) == SCM_EOL) + if (beaming_prop == SCM_EOL + || index_get_cell (beaming_prop, d) == SCM_EOL) { int b = beaming->infos_.elem (i).beams_i_drul_[d]; - if (i>0 + if (i > 0 && i < stems.size () -1 && Stem::is_invisible (st)) b = b infos_.elem (i).beams_i_drul_[-d]; - + Stem::set_beaming (st, b, d); } } @@ -1235,10 +1206,10 @@ Beam::set_beaming (Grob *me, Beaming_info_list *beaming) } int -Beam::forced_stem_count (Grob *me) +Beam::forced_stem_count (Grob *me) { - Link_arraystems = - extract_grob_array (me, ly_symbol2scm ("stems")); + Link_array stems + = extract_grob_array (me, ly_symbol2scm ("stems")); int f = 0; for (int i = 0; i < stems.size (); i++) { @@ -1250,66 +1221,63 @@ Beam::forced_stem_count (Grob *me) /* I can imagine counting those boundaries as a half forced stem, but let's count them full for now. */ if (abs (Stem::chord_start_y (s)) > 0.1 - && (Stem::get_direction (s) != Stem::get_default_dir (s))) - f++; + && (Stem::get_direction (s) != Stem::get_default_dir (s))) + f++; } return f; } - - int -Beam::visible_stem_count (Grob *me) +Beam::visible_stem_count (Grob *me) { - Link_arraystems = - extract_grob_array (me, ly_symbol2scm ("stems")); + Link_array stems + = extract_grob_array (me, ly_symbol2scm ("stems")); int c = 0; for (int i = stems.size (); i--;) { if (!Stem::is_invisible (stems[i])) - c++; + c++; } return c; } -Grob* -Beam::first_visible_stem (Grob *me) +Grob * +Beam::first_visible_stem (Grob *me) { - Link_arraystems = - extract_grob_array (me, ly_symbol2scm ("stems")); - + Link_array stems + = extract_grob_array (me, ly_symbol2scm ("stems")); + for (int i = 0; i < stems.size (); i++) { if (!Stem::is_invisible (stems[i])) - return stems[i]; + return stems[i]; } return 0; } -Grob* -Beam::last_visible_stem (Grob *me) +Grob * +Beam::last_visible_stem (Grob *me) { - Link_arraystems = - extract_grob_array (me, ly_symbol2scm ("stems")); + Link_array stems + = extract_grob_array (me, ly_symbol2scm ("stems")); for (int i = stems.size (); i--;) { if (!Stem::is_invisible (stems[i])) - return stems[i]; + return stems[i]; } return 0; } - /* [TODO] - + handle rest under beam (do_post: beams are calculated now) what about combination of collisions and rest under beam. Should lookup - - rest -> stem -> beam -> interpolate_y_position () + + rest -> stem -> beam -> interpolate_y_position () */ MAKE_SCHEME_CALLBACK (Beam, rest_collision_callback, 2); SCM @@ -1320,7 +1288,7 @@ Beam::rest_collision_callback (SCM element_smob, SCM axis) if (scm_is_number (rest->get_property ("staff-position"))) return scm_int2num (0); - + assert (a == Y_AXIS); Grob *st = unsmob_grob (rest->get_property ("stem")); @@ -1340,27 +1308,26 @@ Beam::rest_collision_callback (SCM element_smob, SCM axis) Real staff_space = Staff_symbol_referencer::staff_space (rest); scale_drul (&pos, staff_space); - Real dy = pos[RIGHT] - pos[LEFT]; - + // ugh -> use commonx Real x0 = first_visible_stem (beam)->relative_coordinate (0, X_AXIS); Real dx = last_visible_stem (beam)->relative_coordinate (0, X_AXIS) - x0; - Real slope = dy && dx ? dy/dx : 0; - + Real slope = dy && dx ? dy / dx : 0; + Direction d = Stem::get_direction (stem); Real stem_y = pos[LEFT] + (stem->relative_coordinate (0, X_AXIS) - x0) * slope; - + Real beam_translation = get_beam_translation (beam); Real beam_thickness = Beam::get_thickness (beam); /* - TODO: this is not strictly correct for 16th knee beams. - */ - int beam_count = - Stem::beam_multiplicity (stem).length() + 1; - + TODO: this is not strictly correct for 16th knee beams. + */ + int beam_count + = Stem::beam_multiplicity (stem).length () + 1; + Real height_of_my_beams = beam_thickness / 2 + (beam_count - 1) * beam_translation; Real beam_y = stem_y - d * height_of_my_beams; @@ -1368,11 +1335,11 @@ Beam::rest_collision_callback (SCM element_smob, SCM axis) Grob *common_y = rest->common_refpoint (beam, Y_AXIS); Real rest_dim = rest->extent (common_y, Y_AXIS)[d]; - Real minimum_distance = - + staff_space * (robust_scm2double (stem->get_property ("stemlet-length"), 0.0) - + robust_scm2double (rest->get_property ("minimum-distance"), 0.0)); + Real minimum_distance + = + staff_space * (robust_scm2double (stem->get_property ("stemlet-length"), 0.0) + + robust_scm2double (rest->get_property ("minimum-distance"), 0.0)); - Real shift = d * ( ((beam_y - d * minimum_distance) - rest_dim) * d extent (common_y, Y_AXIS)[d] + staff_space * shift) * d + if ((rest->extent (common_y, Y_AXIS)[d] + staff_space * shift) * d < rad || (rest->extent (common_y, Y_AXIS)[-d] + staff_space * shift) * -d < rad) @@ -1391,7 +1358,7 @@ Beam::rest_collision_callback (SCM element_smob, SCM axis) } bool -Beam::is_knee (Grob* me) +Beam::is_knee (Grob *me) { SCM k = me->get_property ("knee"); if (scm_is_bool (k)) @@ -1409,41 +1376,38 @@ Beam::is_knee (Grob* me) } d = dir; } - + me->set_property ("knee", ly_bool2scm (knee)); return knee; } int -Beam::get_direction_beam_count (Grob *me, Direction d ) +Beam::get_direction_beam_count (Grob *me, Direction d) { - Link_arraystems = - extract_grob_array (me, ly_symbol2scm ("stems")); + Link_array stems + = extract_grob_array (me, ly_symbol2scm ("stems")); int bc = 0; - + for (int i = stems.size (); i--;) { /* Should we take invisible stems into account? - */ + */ if (Stem::get_direction (stems[i]) == d) - bc = bc >? (Stem::beam_multiplicity (stems[i]).length () + 1); + bc = bc >? (Stem::beam_multiplicity (stems[i]).length () + 1); } return bc; } - ADD_INTERFACE (Beam, "beam-interface", "A beam. \n\n" "The @code{thickness} property is the weight of beams, and is measured " - "in staffspace" - , + "in staffspace", "knee positioning-done position-callbacks " "concaveness dir-function quant-score auto-knee-gap gap " "gap-count chord-tremolo beamed-stem-shorten shorten least-squares-dy " "damping inspect-quants flag-width-function neutral-direction positions space-function " "thickness"); - diff --git a/lily/beaming-info.cc b/lily/beaming-info.cc index 6e3841330c..1e2f3f4f4d 100644 --- a/lily/beaming-info.cc +++ b/lily/beaming-info.cc @@ -1,11 +1,10 @@ -/* - beaming-info.cc -- implement Beaming_info, Beaming_info_list - +/* + beaming-info.cc -- implement Beaming_info, Beaming_info_list + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - - */ +*/ #include "beaming.hh" @@ -13,14 +12,14 @@ Beaming_info::Beaming_info () { start_mom_ = 0; beams_i_drul_[LEFT] = 0; - beams_i_drul_[RIGHT] = 0; + beams_i_drul_[RIGHT] = 0; } Beaming_info::Beaming_info (Moment m, int i) { start_mom_ = m; beams_i_drul_[LEFT] = i; - beams_i_drul_[RIGHT] = i; + beams_i_drul_[RIGHT] = i; } const int infinity_i = INT_MAX; // guh. @@ -37,7 +36,7 @@ Beaming_info_list::best_splitpoint_index (Moment &beat_length, bool subdivide) c { beat_pos = infos_[i].start_mom_ / beat_length; int den = beat_pos.den (); - if (infos_[i].beams_i_drul_[LEFT] == infos_[i-1].beams_i_drul_[RIGHT] && !subdivide) + if (infos_[i].beams_i_drul_[LEFT] == infos_[i - 1].beams_i_drul_[RIGHT] && !subdivide) den *= 2; if (den < minden) { @@ -46,7 +45,7 @@ Beaming_info_list::best_splitpoint_index (Moment &beat_length, bool subdivide) c } } - return minidx|(minden ==1 && subdivide ? at_beat : 0); + return minidx| (minden ==1 && subdivide ? at_beat : 0); } int @@ -55,9 +54,9 @@ Beaming_info_list::beam_extend_count (Direction d) const if (infos_.size () == 1) return infos_[0].beams_i_drul_[d]; - Beaming_info thisbeam = infos_.boundary (d, 0); - Beaming_info next = infos_.boundary (d, 1); - + Beaming_info thisbeam = infos_.boundary (d, 0); + Beaming_info next = infos_.boundary (d, 1); + return thisbeam.beams_i_drul_[-d] splits; int m = best_splitpoint_index (beat_length, subdivide); - bool split = subdivide && (m & at_beat); m = m & ~at_beat; + bool split = subdivide && (m & at_beat); m = m & ~at_beat; splits[LEFT].infos_ = infos_.slice (0, m); splits[RIGHT].infos_ = infos_.slice (m, infos_.size ()); Direction d = LEFT; - + do { splits[d].beamify (beat_length, subdivide); diff --git a/lily/bezier-bow.cc b/lily/bezier-bow.cc index c7a26d9424..6ef641134c 100644 --- a/lily/bezier-bow.cc +++ b/lily/bezier-bow.cc @@ -11,11 +11,10 @@ #include "misc.hh" #include "bezier.hh" - static Real F0_1 (Real x) { - return 2 / M_PI * atan (M_PI * x / 2); + return 2 / M_PI *atan (M_PI *x / 2); } Real @@ -24,17 +23,15 @@ slur_height (Real width, Real h_inf, Real r_0) return F0_1 (width * r_0 / h_inf) * h_inf; } - /* - - - ^ x x +/* + ^ x x | -height + height | v x x - - + + For small w, the height should be proportional to w, for w -> infinity, the height should rise to a limit asymptotically. @@ -45,7 +42,7 @@ height h = h_infinity * F (x * r_0 / h_infinity) - + Examples: * F (x) = 2/pi * atan (pi x/2) @@ -72,7 +69,7 @@ height w -> 0, G(w) -> .33 w - + (due to derivative constraints, we cannot have indent > len/3) w -> inf, G(w) -> 2*h_inf @@ -84,27 +81,25 @@ height solve from - G(w) = r + p/(w+q) + G(w) = r + p/(w+q) yields - G(w) = 2 h_inf - max_fraction * q^2/ (w + q) + G(w) = 2 h_inf - max_fraction * q^2/ (w + q) - with q = 2 h_inf - - - */ + with q = 2 h_inf +*/ void get_slur_indent_height (Real *indent, Real *height, Real width, Real h_inf, Real r_0) { Real max_fraction = 1.0 / 3.1; - *height = slur_height (width, h_inf, r_0); + *height = slur_height (width, h_inf, r_0); - Real q = 2 * h_inf / max_fraction; - *indent = - 2 *h_inf - sqr (q) * max_fraction / (width + q); + Real q = 2 * h_inf / max_fraction; + *indent + = 2 *h_inf - sqr (q) * max_fraction / (width + q); } Bezier @@ -112,9 +107,9 @@ slur_shape (Real width, Real h_inf, Real r_0) { Real indent; Real height; - + get_slur_indent_height (&indent, &height, - width, h_inf, r_0); + width, h_inf, r_0); Bezier curve; curve.control_[0] = Offset (0, 0); diff --git a/lily/bezier.cc b/lily/bezier.cc index de47a3b0de..f28e18a7ab 100644 --- a/lily/bezier.cc +++ b/lily/bezier.cc @@ -13,7 +13,7 @@ #include "libc-extension.hh" Real -binomial_coefficient (Real over , int under) +binomial_coefficient (Real over, int under) { Real x = 1.0; @@ -21,14 +21,14 @@ binomial_coefficient (Real over , int under) { x *= over / Real (under); - over -= 1.0; - under --; + over -= 1.0; + under--; } return x; } void -scale (Array* array, Real x , Real y) +scale (Array* array, Real x, Real y) { for (int i = 0; i < array->size (); i++) { @@ -53,17 +53,16 @@ translate (Array* array, Offset o) } /* - Formula of the bezier 3-spline sum_{j = 0}^3 (3 over j) z_j (1-t)^ (3-j) t^j A is the axis of X coordinate. - */ +*/ Real -Bezier::get_other_coordinate (Axis a, Real x) const +Bezier::get_other_coordinate (Axis a, Real x) const { Axis other = Axis ((a +1)%NO_AXES); Array ts = solve_point (a, x); @@ -73,50 +72,48 @@ Bezier::get_other_coordinate (Axis a, Real x) const programming_error ("No solution found for Bezier intersection."); return 0.0; } - + Offset c = curve_point (ts[0]); if (fabs (c[a] - x) > 1e-8) programming_error ("Bezier intersection not correct?"); - + return c[other]; } - Offset Bezier::curve_point (Real t) const { Real tj = 1; - Real one_min_tj = (1-t)* (1-t)* (1-t); + Real one_min_tj = (1 - t)* (1 - t)* (1 - t); Offset o; - for (int j = 0 ; j < 4; j++) + for (int j = 0; j < 4; j++) { o += control_[j] * binomial_coefficient (3, j) - * pow (t, j) * pow (1-t, 3-j); + * pow (t, j) * pow (1 - t, 3 - j); tj *= t; - if (1-t) - one_min_tj /= (1-t); + if (1 - t) + one_min_tj /= (1 - t); } #ifdef PARANOID assert (fabs (o[X_AXIS] - polynomial (X_AXIS).eval (t))< 1e-8); assert (fabs (o[Y_AXIS] - polynomial (Y_AXIS).eval (t))< 1e-8); #endif - + return o; } - Polynomial Bezier::polynomial (Axis a) const { Polynomial p (0.0); for (int j = 0; j <= 3; j++) { - p += - (control_[j][a] * binomial_coefficient (3, j)) + p + += (control_[j][a] * binomial_coefficient (3, j)) * Polynomial::power (j, Polynomial (0, 1)) * Polynomial::power (3 - j, Polynomial (1, -1)); } @@ -126,7 +123,7 @@ Bezier::polynomial (Axis a) const /** Remove all numbers outside [0, 1] from SOL - */ +*/ Array filter_solutions (Array sol) { @@ -138,7 +135,7 @@ filter_solutions (Array sol) /** find t such that derivative is proportional to DERIV - */ +*/ Array Bezier::solve_derivative (Offset deriv) const { @@ -146,39 +143,38 @@ Bezier::solve_derivative (Offset deriv) const Polynomial yp = polynomial (Y_AXIS); xp.differentiate (); yp.differentiate (); - + Polynomial combine = xp * deriv[Y_AXIS] - yp * deriv [X_AXIS]; return filter_solutions (combine.solve ()); } - /* Find t such that curve_point (t)[AX] == COORDINATE */ -Array +Array Bezier::solve_point (Axis ax, Real coordinate) const { Polynomial p (polynomial (ax)); p.coefs_[0] -= coordinate; - + Array sol (p.solve ()); return filter_solutions (sol); } /** Compute the bounding box dimensions in direction of A. - */ +*/ Interval Bezier::extent (Axis a) const { - int o = (a+1)%NO_AXES; + int o = (a + 1)%NO_AXES; Offset d; d[Axis (o)] =1.0; Interval iv; Array sols (solve_derivative (d)); sols.push (1.0); - sols.push (0.0); + sols.push (0.0); for (int i = sols.size (); i--;) { Offset o (curve_point (sols[i])); @@ -189,7 +185,7 @@ Bezier::extent (Axis a) const /** Flip around axis A - */ +*/ void Bezier::scale (Real x, Real y) { @@ -228,6 +224,6 @@ Bezier::reverse () { Bezier b2; for (int i = 0; i < CONTROL_COUNT; i++) - b2.control_[CONTROL_COUNT-i-1] = control_[i]; + b2.control_[CONTROL_COUNT - i - 1] = control_[i]; *this = b2; } diff --git a/lily/binary-source-file.cc b/lily/binary-source-file.cc index cdd9bd621d..3b5affd6c2 100644 --- a/lily/binary-source-file.cc +++ b/lily/binary-source-file.cc @@ -11,7 +11,7 @@ #include "binary-source-file.hh" #include "string-convert.hh" -Binary_source_file::Binary_source_file (String& file_name_string) +Binary_source_file::Binary_source_file (String &file_name_string) : Source_file (file_name_string) { } @@ -21,20 +21,20 @@ Binary_source_file::~Binary_source_file () } String -Binary_source_file::error_string (char const* pos_str0) const +Binary_source_file::error_string (char const *pos_str0) const { assert (this); if (!contains (pos_str0)) return ""; - char const* begin_str0 = pos_str0 - 8 >? to_str0 (); - char const* end_str0 = pos_str0 + 7 ? to_str0 (); + char const *end_str0 = pos_str0 + 7 key_) - scm_gc_mark (book->key_->self_scm()); + scm_gc_mark (book->key_->self_scm ()); #endif if (book->paper_) @@ -83,15 +83,15 @@ Book::process (String outname, Output_def *default_def) Paper_book *paper_book = new Paper_book (); Real scale = scm_to_double (paper_->c_variable ("outputscale")); - Output_def * scaled_bookdef = scale_output_def (paper_, scale); + Output_def *scaled_bookdef = scale_output_def (paper_, scale); - Object_key * key = new Lilypond_general_key (0, user_key_, 0); - SCM scm_key = key->self_scm(); + Object_key *key = new Lilypond_general_key (0, user_key_, 0); + SCM scm_key = key->self_scm (); scm_gc_unprotect_object (scm_key); - + paper_book->paper_ = scaled_bookdef; - scm_gc_unprotect_object (scaled_bookdef->self_scm()); - + scm_gc_unprotect_object (scaled_bookdef->self_scm ()); + paper_book->header_ = header_; /* Render in order of parsing. */ @@ -101,7 +101,7 @@ Book::process (String outname, Output_def *default_def) { SCM systems = score ->book_rendering (outname, paper_book->paper_, default_def, key); - + /* If the score is empty, generate no output. Should we do titling? */ if (scm_is_vector (systems)) diff --git a/lily/box.cc b/lily/box.cc index 312252112d..bd15a691f9 100644 --- a/lily/box.cc +++ b/lily/box.cc @@ -24,17 +24,17 @@ Box::unite (Box b) } /** - Initialize to empty. - */ + Initialize to empty. +*/ Box::Box () -{ +{ } void Box::set_empty () { interval_a_[X_AXIS].set_empty (); - interval_a_[Y_AXIS].set_empty (); + interval_a_[Y_AXIS].set_empty (); } Box::Box (Interval ix, Interval iy) @@ -66,14 +66,14 @@ void Box::add_point (Offset o) { interval_a_[X_AXIS].add_point (o[X_AXIS]); - interval_a_[Y_AXIS].add_point (o[Y_AXIS]); + interval_a_[Y_AXIS].add_point (o[Y_AXIS]); } Offset Box::center () const { return Offset (interval_a_[X_AXIS].center (), - interval_a_[Y_AXIS].center ()); + interval_a_[Y_AXIS].center ()); } void diff --git a/lily/break-algorithm.cc b/lily/break-algorithm.cc index e112e0a19d..4575d8410e 100644 --- a/lily/break-algorithm.cc +++ b/lily/break-algorithm.cc @@ -50,30 +50,30 @@ Break_algorithm::find_breaks () const return retval; } -Simple_spacer_wrapper* +Simple_spacer_wrapper * Break_algorithm::generate_spacing_problem (Link_array const &curline, Interval line) const { - Simple_spacer_wrapper * spw = new Simple_spacer_wrapper; - Simple_spacer * sp = spw->spacer_; - + Simple_spacer_wrapper *spw = new Simple_spacer_wrapper; + Simple_spacer *sp = spw->spacer_; + /* this is hardcoded, but this shouldn't happen anyway. - used to be get_dimension (ly_symbol2scm ("loose_column_distance")); - */ + used to be get_dimension (ly_symbol2scm ("loose_column_distance")); + */ sp->default_space_ = 1.0; sp->indent_ = line[LEFT]; /* sort out how interfacing this should work; - */ + */ if (line.is_empty ()) { - sp->line_len_ = -1; + sp->line_len_ = -1; } else sp->line_len_ = line.length (); - + spw->add_columns (curline); return spw; } @@ -85,7 +85,7 @@ Break_algorithm::Break_algorithm () } void -Break_algorithm::set_pscore (Paper_score*s) +Break_algorithm::set_pscore (Paper_score *s) { pscore_ = s; linewidth_ = s->layout_->get_dimension (ly_symbol2scm ("linewidth")); @@ -95,7 +95,7 @@ Array Break_algorithm::solve () const { Array h= do_solve (); - + return h; } diff --git a/lily/break-align-engraver.cc b/lily/break-align-engraver.cc index 9903580b4a..7309342dd6 100644 --- a/lily/break-align-engraver.cc +++ b/lily/break-align-engraver.cc @@ -1,11 +1,10 @@ -/* +/* break-align-engraver.cc -- implement Break_align_engraver - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - - */ +*/ #include "engraver.hh" #include "protected-scm.hh" #include "break-align-interface.hh" @@ -20,13 +19,13 @@ class Break_align_engraver : public Engraver SCM column_alist_; Item *left_edge_; - void add_to_group (SCM, Item*); + void add_to_group (SCM, Item *); protected: virtual void acknowledge_grob (Grob_info i); virtual void stop_translation_timestep (); virtual void derived_mark () const; void add_column (SCM); - + public: TRANSLATOR_DECLARATIONS (Break_align_engraver); }; @@ -34,9 +33,9 @@ public: void Break_align_engraver::add_column (SCM smob) { - Grob * e = unsmob_grob (smob); + Grob *e = unsmob_grob (smob); Break_align_interface::add_element (align_, e); - + } void @@ -53,7 +52,6 @@ Break_align_engraver::stop_translation_timestep () left_edge_ = 0; } - Break_align_engraver::Break_align_engraver () { column_alist_ = SCM_EOL; @@ -70,58 +68,58 @@ Break_align_engraver::derived_mark () const void Break_align_engraver::acknowledge_grob (Grob_info inf) { - if (Item * item = dynamic_cast (inf.grob_)) + if (Item *item = dynamic_cast (inf.grob_)) { /* Removed check for item->empty (X_AXIS). --hwn 20/1/04 - */ + */ if (item->get_parent (X_AXIS)) return; SCM bp = item->get_property ("breakable"); bool breakable = (to_boolean (bp)); if (!breakable) - return ; + return; SCM align_name = item->get_property ("break-align-symbol"); if (!scm_is_symbol (align_name)) - return ; + return; if (!align_) { align_ = make_item ("BreakAlignment", SCM_EOL); - Context*origin = inf.origin_contexts (this)[0]; - left_edge_ = make_item_from_properties (dynamic_cast (origin->implementation ()), + Context *origin = inf.origin_contexts (this)[0]; + left_edge_ = make_item_from_properties (dynamic_cast (origin->implementation ()), ly_symbol2scm ("LeftEdge"), SCM_EOL, "LeftEdge"); add_to_group (left_edge_->get_property ("break-align-symbol"), left_edge_); } - + add_to_group (align_name, item); } } void -Break_align_engraver::add_to_group (SCM align_name, Item*item) +Break_align_engraver::add_to_group (SCM align_name, Item *item) { SCM s = scm_assoc (align_name, column_alist_); - Item * group = 0; + Item *group = 0; if (s != SCM_BOOL_F) { - Grob *e = unsmob_grob (scm_cdr (s)); - group = dynamic_cast (e); + Grob *e = unsmob_grob (scm_cdr (s)); + group = dynamic_cast (e); } else { - group = make_item ("BreakAlignGroup", item->self_scm () ); + group = make_item ("BreakAlignGroup", item->self_scm ()); group->set_property ("break-align-symbol", align_name); group->set_parent (align_, Y_AXIS); - + column_alist_ = scm_assoc_set_x (column_alist_, align_name, group->self_scm ()); } @@ -129,12 +127,11 @@ Break_align_engraver::add_to_group (SCM align_name, Item*item) } ADD_TRANSLATOR (Break_align_engraver, - "Align grobs with corresponding @code{break-align-symbols} into " - "groups, and order the groups according to @code{breakAlignOrder}. " - "The left edge of the alignment gets a separate group, with a symbol @code{left-edge}. " - , - /* creats*/ "BreakAlignment BreakAlignGroup LeftEdge", - /* accepts */ "", - /* acks */ "break-aligned-interface", - /* reads */ "", - /* write */ ""); + "Align grobs with corresponding @code{break-align-symbols} into " + "groups, and order the groups according to @code{breakAlignOrder}. " + "The left edge of the alignment gets a separate group, with a symbol @code{left-edge}. ", + /* creats*/ "BreakAlignment BreakAlignGroup LeftEdge", + /* accepts */ "", + /* acks */ "break-aligned-interface", + /* reads */ "", + /* write */ ""); diff --git a/lily/break-align-interface.cc b/lily/break-align-interface.cc index 36966bcd13..1b3daecdb3 100644 --- a/lily/break-align-interface.cc +++ b/lily/break-align-interface.cc @@ -6,7 +6,6 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #include #include "break-align-interface.hh" @@ -47,7 +46,7 @@ Break_align_interface::self_align_callback (SCM element_smob, SCM axis) Axis a = (Axis) scm_to_int (axis); assert (a == X_AXIS); - Item* item = dynamic_cast (me); + Item *item = dynamic_cast (me); Direction bsd = item->break_status_dir (); if (bsd == LEFT) { @@ -56,31 +55,29 @@ Break_align_interface::self_align_callback (SCM element_smob, SCM axis) /* Force break alignment itself to be done first, in the case - */ + */ return Self_alignment_interface::aligned_on_self (element_smob, axis); } - /* This is tricky: we cannot modify 'elements, since callers are iterating the same list. Reordering the list in-place, or resetting 'elements will skip elements in the loops of callers. So we return the correct order as an array. - */ +*/ Link_array Break_align_interface::ordered_elements (Grob *grob) { - Item *me = dynamic_cast (grob); + Item *me = dynamic_cast (grob); SCM elts = me->get_property ("elements"); SCM order_vec = me->get_property ("break-align-orders"); if (!scm_is_vector (order_vec) || scm_c_vector_length (order_vec) < 3) - return extract_grob_array (me, ly_symbol2scm ("elements")); + return extract_grob_array (me, ly_symbol2scm ("elements")); SCM order = scm_vector_ref (order_vec, scm_int2num (me->break_status_dir () + 1)); - /* Copy in order specified in BREAK-ALIGN-ORDER. */ @@ -111,8 +108,7 @@ Break_align_interface::add_element (Grob *me, Grob *toadd) void Break_align_interface::do_alignment (Grob *grob) { - Item * me = dynamic_cast (grob); - + Item *me = dynamic_cast (grob); Link_array elems = ordered_elements (me); Array extents; @@ -126,23 +122,22 @@ Break_align_interface::do_alignment (Grob *grob) last_nonempty = i; } - int idx = 0; - while (idx < extents.size () && extents[idx].is_empty ()) + int idx = 0; + while (idx < extents.size () && extents[idx].is_empty ()) idx++; Array offsets; offsets.set_size (elems.size ()); - for (int i = 0; i < offsets.size ();i ++) + for (int i = 0; i < offsets.size ();i++) offsets[i] = 0.0; - Real extra_right_space = 0.0; int edge_idx = -1; while (idx < elems.size ()) { - int next_idx = idx+1; - while (next_idx < elems.size () && - extents[next_idx].is_empty () ) + int next_idx = idx + 1; + while (next_idx < elems.size () + && extents[next_idx].is_empty ()) next_idx++; Grob *l = elems[idx]; @@ -153,27 +148,26 @@ Break_align_interface::do_alignment (Grob *grob) SCM alist = SCM_EOL; - /* Find the first grob with a space-alist entry. - */ + */ for (SCM s = l->get_property ("elements"); - scm_is_pair (s) ; s = scm_cdr (s)) - { - Grob *elt = unsmob_grob (scm_car (s)); - - if (edge_idx < 0 - && elt->get_property ("break-align-symbol") - == ly_symbol2scm ( "left-edge")) - edge_idx = idx; - - SCM l = elt->get_property ("space-alist"); - if (scm_is_pair (l)) - { - alist = l; - break; - } - } + scm_is_pair (s); s = scm_cdr (s)) + { + Grob *elt = unsmob_grob (scm_car (s)); + + if (edge_idx < 0 + && elt->get_property ("break-align-symbol") + == ly_symbol2scm ("left-edge")) + edge_idx = idx; + + SCM l = elt->get_property ("space-alist"); + if (scm_is_pair (l)) + { + alist = l; + break; + } + } SCM rsym = r ? SCM_EOL : ly_symbol2scm ("right-edge"); @@ -185,12 +179,12 @@ Break_align_interface::do_alignment (Grob *grob) for (SCM s = r ? r->get_property ("elements") : SCM_EOL; !scm_is_symbol (rsym) && scm_is_pair (s); s = scm_cdr (s)) { - Grob * elt = unsmob_grob (scm_car (s)); + Grob *elt = unsmob_grob (scm_car (s)); rsym = elt->get_property ("break-align-symbol"); } - if (rsym == ly_symbol2scm ("left-edge")) + if (rsym == ly_symbol2scm ("left-edge")) edge_idx = next_idx; SCM entry = SCM_EOL; @@ -204,13 +198,13 @@ Break_align_interface::do_alignment (Grob *grob) if (scm_is_symbol (rsym)) sym_string = ly_symbol2string (rsym); - String orig_string ; + String orig_string; if (unsmob_grob (l->get_property ("cause"))) orig_string = unsmob_grob (l->get_property ("cause"))->name (); programming_error (_f ("No spacing entry from %s to `%s'", - orig_string.to_str0 (), - sym_string.to_str0 ())); + orig_string.to_str0 (), + sym_string.to_str0 ())); } Real distance = 1.0; @@ -221,7 +215,7 @@ Break_align_interface::do_alignment (Grob *grob) entry = scm_cdr (entry); distance = scm_to_double (scm_cdr (entry)); - type = scm_car (entry) ; + type = scm_car (entry); } if (r) @@ -245,7 +239,7 @@ Break_align_interface::do_alignment (Grob *grob) Interval total_extent; Real alignment_off = 0.0; - for (int i = 0 ; i < offsets.size (); i++) + for (int i = 0; i < offsets.size (); i++) { here += offsets[i]; if (i == edge_idx) @@ -253,23 +247,21 @@ Break_align_interface::do_alignment (Grob *grob) total_extent.unite (extents[i] + here); } - if (me->break_status_dir () == LEFT) { - alignment_off = - total_extent[RIGHT] - extra_right_space; + alignment_off = -total_extent[RIGHT] - extra_right_space; } else if (edge_idx < 0) alignment_off = -total_extent[LEFT]; here = alignment_off; - for (int i = 0 ; i < offsets.size (); i++) + for (int i = 0; i < offsets.size (); i++) { here += offsets[i]; elems[i]->translate_axis (here, X_AXIS); } } - ADD_INTERFACE (Break_aligned_interface, "break-aligned-interface", "Items that are aligned in prefatory matter.\n" "\n" @@ -299,5 +291,3 @@ ADD_INTERFACE (Break_align_interface, "break-alignment-interface", "The object that performs break aligment. See @ref{break-aligned-interface}.", "positioning-done break-align-orders"); - - diff --git a/lily/break-substitution.cc b/lily/break-substitution.cc index 8c28b6fe8e..9afd8f13ea 100644 --- a/lily/break-substitution.cc +++ b/lily/break-substitution.cc @@ -4,7 +4,7 @@ #include "item.hh" #include "system.hh" -static SCM break_criterion; +static SCM break_criterion; void set_break_subsititution (SCM criterion) { @@ -12,14 +12,14 @@ set_break_subsititution (SCM criterion) } /* - Perform the substitution for a single grob. - */ + Perform the substitution for a single grob. +*/ SCM substitute_grob (Grob *sc) { if (scm_is_integer (break_criterion)) { - Item * i = dynamic_cast (sc); + Item *i = dynamic_cast (sc); Direction d = to_dir (break_criterion); if (i && i->break_status_dir () != d) { @@ -29,14 +29,14 @@ substitute_grob (Grob *sc) } else { - System * line - = dynamic_cast (unsmob_grob (break_criterion)); + System *line + = dynamic_cast (unsmob_grob (break_criterion)); if (sc->get_system () != line) { sc = sc->find_broken_piece (line); } - + /* now: !sc || (sc && sc->get_system () == line) */ if (!sc) return SCM_UNDEFINED; @@ -53,7 +53,7 @@ substitute_grob (Grob *sc) - it forces us to mark the parents of a grob, leading to a huge recursion in the GC routine. - */ + */ if (sc->common_refpoint (line, X_AXIS) && sc->common_refpoint (line, Y_AXIS)) @@ -66,8 +66,6 @@ substitute_grob (Grob *sc) return sc->self_scm (); } - - /* Do break substitution in S, using CRITERION. Return new value. CRITERION is either a SMOB pointer to the desired line, or a number @@ -86,7 +84,7 @@ SCM do_break_substitution (SCM src) { again: - + if (unsmob_grob (src)) return substitute_grob (unsmob_grob (src)); else if (scm_is_vector (src)) @@ -97,28 +95,28 @@ do_break_substitution (SCM src) { SCM si = scm_int2num (i); scm_vector_set_x (nv, si, - do_break_substitution (scm_vector_ref (src, si))); + do_break_substitution (scm_vector_ref (src, si))); } } - else if (scm_is_pair (src)) + else if (scm_is_pair (src)) { /* UGH! breaks on circular lists. */ SCM newcar = do_break_substitution (scm_car (src)); SCM oldcdr = scm_cdr (src); - + if (newcar == SCM_UNDEFINED && (scm_is_pair (oldcdr) || oldcdr == SCM_EOL)) { /* - This is tail-recursion, ie. - + This is tail-recursion, ie. + return do_break_substution (cdr); We don't want to rely on the compiler to do this. Without tail-recursion, this easily crashes with a stack overflow. */ - src = oldcdr; + src = oldcdr; goto again; } @@ -130,17 +128,16 @@ do_break_substitution (SCM src) return src; } - /* Perform substitution on GROB_LIST using a constant amount of stack. - */ +*/ SCM substitute_grob_list (SCM grob_list) { SCM l = SCM_EOL; - SCM * tail = &l; + SCM *tail = &l; - for (SCM s = grob_list; scm_is_pair (s); s = scm_cdr (s)) + for (SCM s = grob_list; scm_is_pair (s); s = scm_cdr (s)) { SCM n = substitute_grob (unsmob_grob (scm_car (s))); @@ -158,9 +155,9 @@ substitute_grob_list (SCM grob_list) We don't do forall b in broken-childs: - forall p in properties: - forall g in p (if grob-list): - g := substitute (g) + forall p in properties: + forall g in p (if grob-list): + g := substitute (g) for spanners since this is O (SYSTEMCOUNT * GROBCOUNT), and SYSTEMCOUNT = O (GROBCOUNT), we have a quadratic algorithm. --for a single spanner @@ -169,54 +166,51 @@ substitute_grob_list (SCM grob_list) significant; especially all-elements in System, can become huge. For a typical 50 page score, it requires running through a 100k list 50 times. - + Instead: forall p in properties: - (if grob list) + (if grob list) - put grob list in array, + put grob list in array, - reorder array so spanners are separate -- O (grobcount) - - find first and last indexes of grobs on a specific system + reorder array so spanners are separate -- O (grobcount) - for items this is O (itemcount) + find first and last indexes of grobs on a specific system - for spanners this is O (sum-of spanner-system-ranges) + for items this is O (itemcount) - perform the substitution O (sum-of spanner-system-ranges) + for spanners this is O (sum-of spanner-system-ranges) + + perform the substitution O (sum-of spanner-system-ranges) The complexity is harder to determine, but should be subquadratic; For the situation above, we run through the entire 100k list once, and also (more or less) once through the item part of the 100k (say - 98k elements) of the list. + 98k elements) of the list. -These timings were measured without -O2. + These timings were measured without -O2. - lehre, before 28.98 seconds, after: 27.91 seconds, 3.5 %. + lehre, before 28.98 seconds, after: 27.91 seconds, 3.5 %. coriolan, before 2:30, after: 1:59. Increase of 20%. moz-k498-p1, before 24.10, after: 19.790s, Increase of 18% - - */ - Slice -spanner_system_range (Spanner* sp) +spanner_system_range (Spanner *sp) { Slice rv; - - if (System*st = sp->get_system ()) + + if (System *st = sp->get_system ()) { rv = Slice (st->rank_, st->rank_); } - else + else { if (sp->broken_intos_.size ()) rv = Slice (sp->broken_intos_[0]->get_system ()->rank_, @@ -226,9 +220,9 @@ spanner_system_range (Spanner* sp) } Slice -item_system_range (Item* it) +item_system_range (Item *it) { - if (System*st = it->get_system ()) + if (System *st = it->get_system ()) return Slice (st->rank_, st->rank_); Slice sr; @@ -240,30 +234,28 @@ item_system_range (Item* it) sr.add_point (bi->get_system ()->rank_); } while (flip (&d)!= LEFT); - + return sr; } Slice grob_system_range (Grob *g) { - if (Spanner*s = dynamic_cast(g)) - return spanner_system_range (s); - else if (Item* it = dynamic_cast (g)) - return item_system_range (it); - else - return Slice (); + if (Spanner *s = dynamic_cast (g)) + return spanner_system_range (s); + else if (Item *it = dynamic_cast (g)) + return item_system_range (it); + else + return Slice (); } - - struct Substitution_entry { - Grob * grob_; + Grob *grob_; short left_; short right_; - - void set (Grob*g, Slice sr) + + void set (Grob *g, Slice sr) { grob_ = g; /* @@ -273,7 +265,7 @@ struct Substitution_entry { /* overflow if we don't treat this specially. - */ + */ left_ = 1; right_ = -1; } @@ -288,25 +280,23 @@ struct Substitution_entry grob_ = 0; left_ = right_ = -2; } - - int length () { return right_ - left_ ; } + + int length () { return right_ - left_; } static int - item_compare (void const * a , void const * b) + item_compare (void const *a, void const *b) { - return ((Substitution_entry*)a)->left_ - - ((Substitution_entry*)b)->left_; + return ((Substitution_entry *)a)->left_ + - ((Substitution_entry *)b)->left_; } - + static int - spanner_compare (void const * a , void const * b) + spanner_compare (void const *a, void const *b) { - return ((Substitution_entry*)a)->length () - - ((Substitution_entry*)b)->length (); + return ((Substitution_entry *)a)->length () + - ((Substitution_entry *)b)->length (); } }; - - bool Spanner::fast_fubstitute_grob_list (SCM sym, SCM grob_list) @@ -317,24 +307,23 @@ Spanner::fast_fubstitute_grob_list (SCM sym, Only do this complicated thing for large lists. This has the added advantage that we won't screw up the ordering for elements in alignments (which typically don't have more than 10 grobs.) - */ - + */ + if (len < 300) return false; - /* - TODO : should not free it some time? - */ - static Substitution_entry * vec; + TODO : should not free it some time? + */ + static Substitution_entry *vec; static int vec_room; if (vec_room < len) { - vec = (Substitution_entry*) realloc (vec, sizeof (Substitution_entry) * len); + vec = (Substitution_entry *) realloc (vec, sizeof (Substitution_entry) * len); vec_room = len; } - + Slice system_range = spanner_system_range (this); Array it_indices; @@ -344,23 +333,22 @@ Spanner::fast_fubstitute_grob_list (SCM sym, it_indices.push (Slice (len, 0)); sp_indices.push (Slice (len, 0)); } - - + int sp_index = len; int it_index = 0; for (SCM s = grob_list; scm_is_pair (s); s = scm_cdr (s)) { - Grob * g = unsmob_grob (scm_car (s)); + Grob *g = unsmob_grob (scm_car (s)); Slice sr = grob_system_range (g); sr.intersect (system_range); int idx = 0; - if (dynamic_cast(g)) + if (dynamic_cast (g)) { idx =--sp_index; } - else if (dynamic_cast (g)) + else if (dynamic_cast (g)) { idx = it_index++; } @@ -371,58 +359,58 @@ Spanner::fast_fubstitute_grob_list (SCM sym, qsort (vec, it_index, sizeof (Substitution_entry), &Substitution_entry::item_compare); - Array *arrs[] = { - &it_indices, &sp_indices - }; - - for (int i = 0; i < it_index ;i++) - { - for (int j = vec[i].left_; j <= vec[i].right_; j++) - { - it_indices[j - system_range[LEFT]].add_point (i); - } - } - - /* - sorting vec[sp_index.. len] - is a waste of time -- the staff-spanners screw up the - ordering, since they go across the entire score. - */ - for (int i = sp_indices.size (); i--;) - sp_indices[i]= Slice (sp_index, len-1); - - + Array *arrs[] + = { + &it_indices, &sp_indices + }; + + for (int i = 0; i < it_index;i++) + { + for (int j = vec[i].left_; j <= vec[i].right_; j++) + { + it_indices[j - system_range[LEFT]].add_point (i); + } + } + + /* + sorting vec[sp_index.. len] + is a waste of time -- the staff-spanners screw up the + ordering, since they go across the entire score. + */ + for (int i = sp_indices.size (); i--;) + sp_indices[i]= Slice (sp_index, len - 1); + assert (it_index <= sp_index); - assert (broken_intos_.size () == system_range.length () + 1); + assert (broken_intos_.size () == system_range.length () + 1); for (int i = 0; i < broken_intos_.size (); i++) { - Grob * sc = broken_intos_[i]; - System * l = sc->get_system (); + Grob *sc = broken_intos_[i]; + System *l = sc->get_system (); set_break_subsititution (l ? l->self_scm (): SCM_UNDEFINED); SCM newval = SCM_EOL; - SCM * tail = &newval; + SCM *tail = &newval; - for (int k = 0; k < 2;k++) + for (int k = 0; k < 2;k++) for (int j = (*arrs[k])[i][LEFT]; j <= (*arrs[k])[i][RIGHT]; j++) { SCM subs = substitute_grob (vec[j].grob_); if (subs!= SCM_UNDEFINED) { *tail = scm_cons (subs, SCM_EOL); - + tail = SCM_CDRLOC (*tail); } } - + #ifdef PARANOIA - + printf ("%d (%d), sp %d (%d)\n", it_indices [i].length (), it_index, - sp_indices[i].length () , len -sp_index); - + sp_indices[i].length (), len -sp_index); + { SCM l1 = substitute_grob_list (grob_list); assert (scm_ilength (l1) == scm_ilength (newval)); @@ -431,12 +419,12 @@ Spanner::fast_fubstitute_grob_list (SCM sym, /* see below. - */ + */ if (sym == ly_symbol2scm ("all-elements")) - sc->mutable_property_alist_ - = scm_assq_remove_x (sc->mutable_property_alist_, - ly_symbol2scm ("all-elements")); - + sc->mutable_property_alist_ + = scm_assq_remove_x (sc->mutable_property_alist_, + ly_symbol2scm ("all-elements")); + sc->mutable_property_alist_ = scm_acons (sym, newval, sc->mutable_property_alist_); } @@ -444,7 +432,6 @@ Spanner::fast_fubstitute_grob_list (SCM sym, return true; } - /* Although the substitution can be written as @@ -457,7 +444,7 @@ Spanner::fast_fubstitute_grob_list (SCM sym, This becomes a problem if lily is linked against guile with pthreads. pthreads impose small limits on the stack size. - */ +*/ SCM substitute_mutable_property_alist (SCM alist) { @@ -476,13 +463,12 @@ substitute_mutable_property_alist (SCM alist) else val = do_break_substitution (val); - if (val != SCM_UNDEFINED) { /* for ly:grob? properties, SCM_UNDEFINED could leak out through ly:grob-property - */ + */ *tail = scm_cons (scm_cons (sym, val), SCM_EOL); tail = SCM_CDRLOC (*tail); } @@ -490,24 +476,23 @@ substitute_mutable_property_alist (SCM alist) return l; } - void Spanner::substitute_one_mutable_property (SCM sym, SCM val) { SCM type = scm_object_property (sym, ly_symbol2scm ("backend-type?")); - Spanner*s = this; - + Spanner *s = this; + bool fast_done = false; SCM grob_list_p = ly_lily_module_constant ("grob-list?"); if (type == grob_list_p) fast_done = s->fast_fubstitute_grob_list (sym, val); - if (!fast_done) + if (!fast_done) for (int i = 0; i < s->broken_intos_ .size (); i++) { - Grob * sc = s->broken_intos_[i]; - System * l = sc->get_system (); + Grob *sc = s->broken_intos_[i]; + System *l = sc->get_system (); set_break_subsititution (l ? l->self_scm () : SCM_UNDEFINED); SCM newval = (type == grob_list_p) @@ -529,10 +514,10 @@ Spanner::substitute_one_mutable_property (SCM sym, if (sym == ly_symbol2scm ("all-elements")) sc->mutable_property_alist_ = scm_assq_remove_x (sc->mutable_property_alist_, - ly_symbol2scm ("all-elements")); - + ly_symbol2scm ("all-elements")); + sc->mutable_property_alist_ = scm_cons (scm_cons (sym, newval), sc->mutable_property_alist_); } } - + diff --git a/lily/breathing-sign-engraver.cc b/lily/breathing-sign-engraver.cc index e7a70c4301..ba23eede6d 100644 --- a/lily/breathing-sign-engraver.cc +++ b/lily/breathing-sign-engraver.cc @@ -5,12 +5,11 @@ written for the GNU LilyPond music typesetter -TODO: + TODO: . Cancel any beams running through the breathing sign - ([e8 \breathe f e f] should become [e8] \breathe [f e f]) + ([e8 \breathe f e f] should become [e8] \breathe [f e f]) . Spacing is not yet completely pretty - */ #include "staff-symbol-referencer.hh" @@ -18,19 +17,19 @@ TODO: #include "engraver-group-engraver.hh" #include "item.hh" - -class Breathing_sign_engraver : public Engraver { +class Breathing_sign_engraver : public Engraver +{ public: TRANSLATOR_DECLARATIONS (Breathing_sign_engraver); - + protected: virtual bool try_music (Music *req); virtual void process_acknowledged_grobs (); virtual void stop_translation_timestep (); private: - Music * breathing_sign_req_; - Grob * breathing_sign_; + Music *breathing_sign_req_; + Grob *breathing_sign_; }; Breathing_sign_engraver::Breathing_sign_engraver () @@ -40,7 +39,7 @@ Breathing_sign_engraver::Breathing_sign_engraver () } bool -Breathing_sign_engraver::try_music (Music*r) +Breathing_sign_engraver::try_music (Music *r) { breathing_sign_req_ = r; return true; @@ -56,18 +55,17 @@ Breathing_sign_engraver::process_acknowledged_grobs () } } -void +void Breathing_sign_engraver::stop_translation_timestep () { breathing_sign_ = 0; breathing_sign_req_ = 0; } - ADD_TRANSLATOR (Breathing_sign_engraver, -/* descr */ "", -/* creats*/ "BreathingSign", -/* accepts */ "breathing-event", -/* acks */ "", -/* reads */ "", -/* write */ ""); + /* descr */ "", + /* creats*/ "BreathingSign", + /* accepts */ "breathing-event", + /* acks */ "", + /* reads */ "", + /* write */ ""); diff --git a/lily/breathing-sign.cc b/lily/breathing-sign.cc index ff34cc6113..e5814b4fac 100644 --- a/lily/breathing-sign.cc +++ b/lily/breathing-sign.cc @@ -23,10 +23,8 @@ /* TODO: thickness should be a grob property (unit: linethickness) - rather than hardwired to (staff_space / 6). - */ - - + rather than hardwired to (staff_space / 6). +*/ /* UGH : this is full of C&P code. Consolidate! --hwn @@ -35,9 +33,9 @@ /* Gregorian chant divisio minima. (Actually, this was the original breathing sign by Michael. -- jr) - */ +*/ MAKE_SCHEME_CALLBACK (Breathing_sign, divisio_minima, 1); -SCM +SCM Breathing_sign::divisio_minima (SCM smob) { Grob *me = unsmob_grob (smob); @@ -68,9 +66,9 @@ Breathing_sign::divisio_minima (SCM smob) /* Gregorian chant divisio maior. - */ +*/ MAKE_SCHEME_CALLBACK (Breathing_sign, divisio_maior, 1); -SCM +SCM Breathing_sign::divisio_maior (SCM smob) { Grob *me = unsmob_grob (smob); @@ -108,9 +106,9 @@ Breathing_sign::divisio_maior (SCM smob) /* Gregorian chant divisio maxima. - */ +*/ MAKE_SCHEME_CALLBACK (Breathing_sign, divisio_maxima, 1); -SCM +SCM Breathing_sign::divisio_maxima (SCM smob) { Grob *me = unsmob_grob (smob); @@ -138,9 +136,9 @@ Breathing_sign::divisio_maxima (SCM smob) /* Gregorian chant finalis. - */ +*/ MAKE_SCHEME_CALLBACK (Breathing_sign, finalis, 1); -SCM +SCM Breathing_sign::finalis (SCM smob) { Grob *me = unsmob_grob (smob); @@ -175,7 +173,7 @@ SCM Breathing_sign::offset_callback (SCM element_smob, SCM) { Grob *me = unsmob_grob (element_smob); - + Direction d = get_grob_direction (me); if (!d) { @@ -183,11 +181,11 @@ Breathing_sign::offset_callback (SCM element_smob, SCM) set_grob_direction (me, d); } - Real inter_f = Staff_symbol_referencer::staff_space (me)/2; - int sz = Staff_symbol_referencer::line_count (me)-1; + Real inter_f = Staff_symbol_referencer::staff_space (me) / 2; + int sz = Staff_symbol_referencer::line_count (me) - 1; return scm_make_real (inter_f * sz * d); } ADD_INTERFACE (Breathing_sign, "breathing-sign-interface", - "A breathing sign.", - "direction"); + "A breathing sign.", + "direction"); diff --git a/lily/change-iterator.cc b/lily/change-iterator.cc index 5099f8bdf6..5a71519e5f 100644 --- a/lily/change-iterator.cc +++ b/lily/change-iterator.cc @@ -19,13 +19,13 @@ Change_iterator::error (String reason) String to_type = ly_symbol2string (get_music ()->get_property ("change-to-type")); String to_id = ly_scm2string (get_music ()->get_property ("change-to-id")); - String warn1 = _f ("can't change `%s' to `%s'", to_type, to_id) + String warn1 = _f ("can't change `%s' to `%s'", to_type, to_id) + ": " + reason; /* GUHG! - */ - String warn2= "Change_iterator::process (): " + */ + String warn2= "Change_iterator::process (): " + get_outlet ()->context_name () + " = `" + get_outlet ()->id_string () + "': "; warning (warn2); @@ -34,21 +34,20 @@ Change_iterator::error (String reason) /* move to construct_children ? - */ +*/ void Change_iterator::process (Moment m) { - Context * current = get_outlet (); - Context * last = 0; + Context *current = get_outlet (); + Context *last = 0; SCM to_type = get_music ()->get_property ("change-to-type"); - String to_id = ly_scm2string (get_music ()->get_property ("change-to-id")); - + String to_id = ly_scm2string (get_music ()->get_property ("change-to-id")); /* find the type of translator that we're changing. - - If \translator Staff = bass, then look for Staff = * - */ + + If \translator Staff = bass, then look for Staff = * + */ while (current && !current->is_alias (to_type)) { last = current; @@ -60,18 +59,18 @@ Change_iterator::process (Moment m) String msg; msg += _ ("Can't switch translators, I'm there already"); } - - if (current) + + if (current) if (last) { - Context * dest = 0; - Context * where = get_outlet (); + Context *dest = 0; + Context *where = get_outlet (); while (!dest && where) { dest = find_context_below (where, to_type, to_id); where = where->get_parent_context (); } - + if (dest) { current->remove_context (last); @@ -79,16 +78,16 @@ Change_iterator::process (Moment m) } else { - get_music ()->origin ()->warning ("could not find context to switch to."); + get_music ()->origin ()->warning ("could not find context to switch to."); } } else { /* - We could change the current translator's id, but that would make + We could change the current translator's id, but that would make errors hard to catch - - last->translator_id_string () = get_change ()->change_to_id_string (); + + last->translator_id_string () = get_change ()->change_to_id_string (); */ error (_ ("I'm one myself")); } @@ -98,6 +97,4 @@ Change_iterator::process (Moment m) Simple_music_iterator::process (m); } - - IMPLEMENT_CTOR_CALLBACK (Change_iterator); diff --git a/lily/chord-name-engraver.cc b/lily/chord-name-engraver.cc index af854701de..73b3251b8f 100644 --- a/lily/chord-name-engraver.cc +++ b/lily/chord-name-engraver.cc @@ -17,9 +17,9 @@ #include "context.hh" #include "warn.hh" -class Chord_name_engraver : public Engraver +class Chord_name_engraver : public Engraver { - TRANSLATOR_DECLARATIONS ( Chord_name_engraver); + TRANSLATOR_DECLARATIONS (Chord_name_engraver); protected: virtual void stop_translation_timestep (); virtual void process_music (); @@ -28,22 +28,20 @@ protected: virtual void derived_mark () const; private: void add_note (Music *); - - Item* chord_name_; + + Item *chord_name_; Link_array notes_; - + SCM last_chord_; }; - - void Chord_name_engraver::finalize () { } void -Chord_name_engraver::derived_mark() const +Chord_name_engraver::derived_mark () const { scm_gc_mark (last_chord_); } @@ -55,7 +53,7 @@ Chord_name_engraver::Chord_name_engraver () } void -Chord_name_engraver::add_note (Music * n) +Chord_name_engraver::add_note (Music *n) { notes_.push (n); } @@ -63,21 +61,21 @@ Chord_name_engraver::add_note (Music * n) void Chord_name_engraver::process_music () { - if (!notes_.size () ) + if (!notes_.size ()) return; - + SCM bass = SCM_EOL; SCM inversion = SCM_EOL; SCM pitches = SCM_EOL; - Music* inversion_event = 0; - for (int i = 0 ; i < notes_.size (); i++) + Music *inversion_event = 0; + for (int i = 0; i < notes_.size (); i++) { Music *n = notes_[i]; SCM p = n->get_property ("pitch"); if (!unsmob_pitch (p)) continue; - + if (n->get_property ("inversion") == SCM_BOOL_T) { inversion_event = n; @@ -95,9 +93,9 @@ Chord_name_engraver::process_music () if (scm_is_number (oct)) { Pitch *p = unsmob_pitch (inversion_event->get_property ("pitch")); - int octavation = scm_to_int (oct); + int octavation = scm_to_int (oct); Pitch orig = p->transposed (Pitch (-octavation, 0, 0)); - + pitches = scm_cons (orig.smobbed_copy (), pitches); } else @@ -111,15 +109,15 @@ Chord_name_engraver::process_music () context ()->self_scm ()); /* - Ugh. - */ + Ugh. + */ SCM chord_as_scm = scm_cons (pitches, scm_cons (bass, inversion)); - + chord_name_ = make_item ("ChordName", notes_[0]->self_scm ()); chord_name_->set_property ("text", markup); SCM s = get_property ("chordChanges"); - if (to_boolean (s) && scm_is_pair (last_chord_) + if (to_boolean (s) && scm_is_pair (last_chord_) && ly_c_equal_p (chord_as_scm, last_chord_)) chord_name_->set_property ("begin-of-line-visible", SCM_BOOL_T); @@ -127,11 +125,11 @@ Chord_name_engraver::process_music () } bool -Chord_name_engraver::try_music (Music* m) +Chord_name_engraver::try_music (Music *m) { /* - hmm. Should check? - */ + hmm. Should check? + */ if (m->is_mus_type ("note-event")) { add_note (m); @@ -152,11 +150,11 @@ Chord_name_engraver::stop_translation_timestep () which properties are read depend on the chord naming function active. */ ADD_TRANSLATOR (Chord_name_engraver, -/* descr */ "Catch note-events " -"and generate the appropriate chordname.", -/* creats*/ "ChordName", -/* accepts */ "note-event", -/* acks */ "", -/* reads */ "chordChanges chordNameExceptions chordNameFunction " -"chordNoteNamer chordRootNamer chordNameExceptions majorSevenSymbol", -/* write */ ""); + /* descr */ "Catch note-events " + "and generate the appropriate chordname.", + /* creats*/ "ChordName", + /* accepts */ "note-event", + /* acks */ "", + /* reads */ "chordChanges chordNameExceptions chordNameFunction " + "chordNoteNamer chordRootNamer chordNameExceptions majorSevenSymbol", + /* write */ ""); diff --git a/lily/chord-name.cc b/lily/chord-name.cc index b5cb1e98dc..360edb5648 100644 --- a/lily/chord-name.cc +++ b/lily/chord-name.cc @@ -19,19 +19,19 @@ MAKE_SCHEME_CALLBACK (Chord_name, after_line_breaking, 1); SCM Chord_name::after_line_breaking (SCM smob) { - Item* me = unsmob_item (smob); + Item *me = unsmob_item (smob); assert (me); - + SCM s = me->get_property ("begin-of-line-visible"); if (to_boolean (s)) { - if (Paper_column::get_rank (me->get_column ()) - - me->get_system ()->spanned_rank_iv ()[LEFT] > 1) + if (Paper_column::get_rank (me->get_column ()) + - me->get_system ()->spanned_rank_iv ()[LEFT] > 1) me->suicide (); } return SCM_UNSPECIFIED; } ADD_INTERFACE (Chord_name, "chord-name-interface", - "A chord name.", - "begin-of-line-visible"); + "A chord name.", + "begin-of-line-visible"); diff --git a/lily/chord-tremolo-engraver.cc b/lily/chord-tremolo-engraver.cc index 0e566b23c8..bb84edc4bc 100644 --- a/lily/chord-tremolo-engraver.cc +++ b/lily/chord-tremolo-engraver.cc @@ -1,10 +1,9 @@ -/* - chord-tremolo-engraver.cc -- implement Chord_tremolo_engraver - - source file of the GNU LilyPond music typesetter - - (c) 2000--2005 Han-Wen Nienhuys - +/* + chord-tremolo-engraver.cc -- implement Chord_tremolo_engraver + + source file of the GNU LilyPond music typesetter + + (c) 2000--2005 Han-Wen Nienhuys */ #include "beam.hh" @@ -19,7 +18,7 @@ #include "item.hh" #include "chord-tremolo-iterator.hh" #include "stem-tremolo.hh" -#include "math.h" // ceil +#include "math.h" // ceil /** @@ -34,31 +33,30 @@ create dependencies between engravers, which is bad. - create dots if appropriate. - create TremoloBeam iso Beam? - */ class Chord_tremolo_engraver : public Engraver { void typeset_beam (); TRANSLATOR_DECLARATIONS (Chord_tremolo_engraver); protected: - Music * repeat_; + Music *repeat_; /// moment (global time) where beam started. Moment start_mom_; Moment stop_mom_; - int flags_ ; + int flags_; int total_duration_flags_; - + /// location within measure where beam started. Moment beam_start_location_; bool body_is_sequential_; - Spanner * beam_; - Spanner * finished_beam_; - Item * stem_tremolo_; + Spanner *beam_; + Spanner *finished_beam_; + Item *stem_tremolo_; protected: virtual void finalize (); - virtual bool try_music (Music*); + virtual bool try_music (Music *); virtual void acknowledge_grob (Grob_info); virtual void stop_translation_timestep (); virtual void start_translation_timestep (); @@ -67,7 +65,7 @@ protected: Chord_tremolo_engraver::Chord_tremolo_engraver () { - beam_ = finished_beam_ = 0; + beam_ = finished_beam_ = 0; repeat_ = 0; flags_ = 0; stem_tremolo_ = 0; @@ -75,18 +73,17 @@ Chord_tremolo_engraver::Chord_tremolo_engraver () } bool -Chord_tremolo_engraver::try_music (Music * m) +Chord_tremolo_engraver::try_music (Music *m) { if (m->is_mus_type ("repeated-music") && m->get_property ("iterator-ctor") == Chord_tremolo_iterator::constructor_proc - && !repeat_) + && !repeat_) { Moment l = m->get_length (); repeat_ = m; start_mom_ = now_mom (); stop_mom_ = start_mom_ + l; - Music *body = Repeated_music::body (m); body_is_sequential_ = body->is_mus_type ("sequential-music"); @@ -99,14 +96,14 @@ Chord_tremolo_engraver::try_music (Music * m) if (elt_count <= 0) elt_count = 1; - + Rational total_dur = l.main_part_; Rational note_dur = total_dur / Rational (elt_count * Repeated_music::repeat_count (repeat_)); total_duration_flags_ = 0 >? (intlog2 (total_dur.den ()) - 2); - - flags_ = intlog2 (note_dur.den ()) -2 ; - + + flags_ = intlog2 (note_dur.den ()) -2; + return true; } @@ -147,13 +144,13 @@ Chord_tremolo_engraver::acknowledge_grob (Grob_info info) { if (beam_ && Stem::has_interface (info.grob_)) { - Grob * s = info.grob_; + Grob *s = info.grob_; if (start_mom_ == now_mom ()) Stem::set_beaming (s, flags_, RIGHT); else Stem::set_beaming (s, flags_, LEFT); - + if (Stem::duration_log (s) != 1) { beam_->set_property ("gap-count", scm_int2num (flags_ - total_duration_flags_)); @@ -172,8 +169,8 @@ Chord_tremolo_engraver::acknowledge_grob (Grob_info info) ::warning (s); } } - else if (repeat_ && - flags_ && !body_is_sequential_ && Stem::has_interface (info.grob_)) + else if (repeat_ + && flags_ && !body_is_sequential_ && Stem::has_interface (info.grob_)) { stem_tremolo_ = make_item ("StemTremolo", repeat_->self_scm ()); stem_tremolo_->set_property ("flag-count", @@ -184,7 +181,6 @@ Chord_tremolo_engraver::acknowledge_grob (Grob_info info) } } - void Chord_tremolo_engraver::start_translation_timestep () { @@ -196,7 +192,6 @@ Chord_tremolo_engraver::start_translation_timestep () } } - void Chord_tremolo_engraver::stop_translation_timestep () { @@ -211,12 +206,10 @@ Chord_tremolo_engraver::stop_translation_timestep () typeset_beam (); } - - ADD_TRANSLATOR (Chord_tremolo_engraver, -/* descr */ "Generates beams for tremolo repeats.", -/* creats*/ "Beam", -/* accepts */ "repeated-music", -/* acks */ "stem-interface note-head-interface", -/* reads */ "", -/* write */ ""); + /* descr */ "Generates beams for tremolo repeats.", + /* creats*/ "Beam", + /* accepts */ "repeated-music", + /* acks */ "stem-interface note-head-interface", + /* reads */ "", + /* write */ ""); diff --git a/lily/chord-tremolo-iterator.cc b/lily/chord-tremolo-iterator.cc index 04590805ad..7301066d5b 100644 --- a/lily/chord-tremolo-iterator.cc +++ b/lily/chord-tremolo-iterator.cc @@ -1,17 +1,15 @@ -/* +/* chord-tremolo-iterator.cc -- implement Chord_tremolo_iterator - + source file of the GNU LilyPond music typesetter - - (c) 2000--2005 Han-Wen Nienhuys - - */ + (c) 2000--2005 Han-Wen Nienhuys +*/ /* this is culled from various other iterators, but sharing code by subclassing proved to be too difficult. - */ +*/ #include "chord-tremolo-iterator.hh" @@ -21,9 +19,9 @@ void Chord_tremolo_iterator::construct_children () { - Music *m = get_music(); - - factor_ = Moment (Rational (1, 1)); + Music *m = get_music (); + + factor_ = Moment (Rational (1, 1)); child_iter_ = unsmob_iterator (get_iterator (Repeated_music::body (m))); } @@ -48,7 +46,7 @@ Chord_tremolo_iterator::derived_mark () const } void -Chord_tremolo_iterator::derived_substitute (Context *f, Context *t) +Chord_tremolo_iterator::derived_substitute (Context *f, Context *t) { if (child_iter_) child_iter_->substitute_outlet (f, t); @@ -57,7 +55,7 @@ Chord_tremolo_iterator::derived_substitute (Context *f, Context *t) void Chord_tremolo_iterator::process (Moment m) { - if (!m.to_bool () ) + if (!m.to_bool ()) { Music_iterator *yeah = try_music (get_music ()); if (yeah) @@ -81,8 +79,8 @@ Chord_tremolo_iterator::ok () const return child_iter_ && child_iter_->ok (); } -Music_iterator* -Chord_tremolo_iterator::try_music_in_children (Music *m) const +Music_iterator * +Chord_tremolo_iterator::try_music_in_children (Music *m) const { return child_iter_->try_music (m); } diff --git a/lily/clef-engraver.cc b/lily/clef-engraver.cc index 0bdb8443c1..86aa555336 100644 --- a/lily/clef-engraver.cc +++ b/lily/clef-engraver.cc @@ -17,7 +17,7 @@ #include "direction.hh" #include "side-position-interface.hh" -class Clef_engraver : public Engraver +class Clef_engraver : public Engraver { public: TRANSLATOR_DECLARATIONS (Clef_engraver); @@ -29,8 +29,8 @@ protected: virtual void process_music (); virtual void acknowledge_grob (Grob_info); private: - Item * clef_; - Item * octavate_; + Item *clef_; + Item *octavate_; SCM prev_glyph_; SCM prev_cpos_; @@ -48,7 +48,7 @@ Clef_engraver::Clef_engraver () /* will trigger a clef at the start since #f != ' () - */ + */ prev_cpos_ = prev_glyph_ = SCM_BOOL_F; } @@ -59,25 +59,25 @@ Clef_engraver::set_glyph () SCM glyph = get_property ("clefGlyph"); SCM basic = ly_symbol2scm ("Clef"); - + execute_pushpop_property (context (), basic, glyph_sym, SCM_UNDEFINED); execute_pushpop_property (context (), basic, glyph_sym, glyph); } -/** - Generate a clef at the start of a measure. (when you see a Bar, - ie. a breakpoint) - */ +/** + Generate a clef at the start of a measure. (when you see a Bar, + ie. a breakpoint) +*/ void Clef_engraver::acknowledge_grob (Grob_info info) { - Item * item = dynamic_cast (info.grob_); + Item *item = dynamic_cast (info.grob_); if (item) { if (Bar_line::has_interface (info.grob_) && scm_is_string (get_property ("clefGlyph"))) create_clef (); - } + } } void @@ -86,7 +86,6 @@ Clef_engraver::create_clef () if (!clef_) { Item *c = make_item ("Clef", SCM_EOL); - clef_ = c; SCM cpos = get_property ("clefPosition"); @@ -94,28 +93,28 @@ Clef_engraver::create_clef () if (scm_is_number (cpos)) clef_->set_property ("staff-position", cpos); - SCM oct = get_property ("clefOctavation"); + SCM oct = get_property ("clefOctavation"); if (scm_is_number (oct) && scm_to_int (oct)) { - Item * g = make_item ("OctavateEight", SCM_EOL); + Item *g = make_item ("OctavateEight", SCM_EOL); - int abs_oct = scm_to_int (oct) ; + int abs_oct = scm_to_int (oct); int dir = sign (abs_oct); - abs_oct = abs (abs_oct) + 1; + abs_oct = abs (abs_oct) + 1; SCM txt = scm_number_to_string (scm_int2num (abs_oct), scm_from_int (10)); g->set_property ("text", scm_list_n (ly_lily_module_constant ("vcenter-markup"), - txt, SCM_UNDEFINED)); - Side_position_interface::add_support (g, clef_); + txt, SCM_UNDEFINED)); + Side_position_interface::add_support (g, clef_); g->set_parent (clef_, Y_AXIS); g->set_parent (clef_, X_AXIS); g->set_property ("direction", scm_int2num (dir)); octavate_ = g; - + } } } @@ -132,7 +131,7 @@ Clef_engraver::inspect_clef_properties () SCM clefpos = get_property ("clefPosition"); SCM octavation = get_property ("clefOctavation"); SCM force_clef = get_property ("forceClef"); - + if (clefpos == SCM_EOL || scm_equal_p (glyph, prev_glyph_) == SCM_BOOL_F || scm_equal_p (clefpos, prev_cpos_) == SCM_BOOL_F @@ -151,18 +150,17 @@ Clef_engraver::inspect_clef_properties () if (to_boolean (force_clef)) { - Context * w = context ()->where_defined (ly_symbol2scm ("forceClef")); + Context *w = context ()->where_defined (ly_symbol2scm ("forceClef")); w->set_property ("forceClef", SCM_EOL); } } - void Clef_engraver::stop_translation_timestep () { if (clef_) { - SCM vis = 0; + SCM vis = 0; if (to_boolean (clef_->get_property ("non-default"))) { vis = get_property ("explicitClefVisibility"); @@ -177,19 +175,17 @@ Clef_engraver::stop_translation_timestep () } } - + clef_ = 0; octavate_ = 0; } } - - ADD_TRANSLATOR (Clef_engraver, -/* descr */ "Determine and set reference point for pitches", -/* creats*/ "Clef OctavateEight", -/* accepts */ "", -/* acks */ "bar-line-interface", -/* reads */ "clefPosition clefGlyph middleCPosition clefOctavation explicitClefVisibility forceClef", -/* write */ ""); + /* descr */ "Determine and set reference point for pitches", + /* creats*/ "Clef OctavateEight", + /* accepts */ "", + /* acks */ "bar-line-interface", + /* reads */ "clefPosition clefGlyph middleCPosition clefOctavation explicitClefVisibility forceClef", + /* write */ ""); diff --git a/lily/clef.cc b/lily/clef.cc index 4f08375f2c..dafb09d4e5 100644 --- a/lily/clef.cc +++ b/lily/clef.cc @@ -14,7 +14,7 @@ #include "font-interface.hh" /* - FIXME: should use symbol for #'style. + FIXME: should use symbol for #'style. */ MAKE_SCHEME_CALLBACK (Clef, before_line_breaking, 1); SCM @@ -34,7 +34,7 @@ Clef::before_line_breaking (SCM smob) && !to_boolean (s->get_property ("full-size-change"))) { str += "_change"; - s->set_property ("glyph-name", scm_makfrom0str (str.to_str0 ())); + s->set_property ("glyph-name", scm_makfrom0str (str.to_str0 ())); } } @@ -42,7 +42,7 @@ Clef::before_line_breaking (SCM smob) } MAKE_SCHEME_CALLBACK (Clef, print, 1) -SCM + SCM Clef::print (SCM smob) { Grob *me = unsmob_grob (smob); @@ -59,6 +59,6 @@ Clef::print (SCM smob) } ADD_INTERFACE (Clef, "clef-interface", - "A clef sign", - "non-default full-size-change glyph-name"); + "A clef sign", + "non-default full-size-change glyph-name"); diff --git a/lily/cluster-engraver.cc b/lily/cluster-engraver.cc index ec65f0ef38..02c7613cbc 100644 --- a/lily/cluster-engraver.cc +++ b/lily/cluster-engraver.cc @@ -18,17 +18,17 @@ class Cluster_spanner_engraver : public Engraver protected: TRANSLATOR_DECLARATIONS (Cluster_spanner_engraver); virtual bool try_music (Music *); - virtual void process_music (); + virtual void process_music (); virtual void acknowledge_grob (Grob_info); virtual void stop_translation_timestep (); virtual void finalize (); private: Link_array cluster_notes_; - Item* beacon_; + Item *beacon_; void typeset_grobs (); Spanner *spanner_; - Spanner *finished_spanner_ ; + Spanner *finished_spanner_; }; Cluster_spanner_engraver::Cluster_spanner_engraver () @@ -64,7 +64,7 @@ Cluster_spanner_engraver::try_music (Music *m) } else if (m->is_mus_type ("busy-playing-event")) return cluster_notes_.size (); - + return false; } @@ -75,31 +75,31 @@ Cluster_spanner_engraver::process_music () { SCM c0scm = get_property ("middleCPosition"); - int c0 = scm_is_number (c0scm) ? scm_to_int (c0scm) : 0; + int c0 = scm_is_number (c0scm) ? scm_to_int (c0scm) : 0; int pmax = INT_MIN; int pmin = INT_MAX; - + for (int i = 0; i get_property ("pitch")); - int p =( pit ? pit->steps () : 0) + c0; + int p = (pit ? pit->steps () : 0) + c0; pmax = pmax >? p; pmin = pmin self_scm ()); beacon_->set_property ("positions", - scm_cons (scm_int2num (pmin), - scm_int2num (pmax))); + scm_cons (scm_int2num (pmin), + scm_int2num (pmax))); } if (beacon_ && !spanner_) - { - spanner_ = make_spanner ("ClusterSpanner", cluster_notes_[0]->self_scm () ); + { + spanner_ = make_spanner ("ClusterSpanner", cluster_notes_[0]->self_scm ()); } - + if (beacon_ && spanner_) { add_bound_item (spanner_, beacon_); @@ -107,7 +107,6 @@ Cluster_spanner_engraver::process_music () } } - void Cluster_spanner_engraver::stop_translation_timestep () { @@ -126,10 +125,10 @@ Cluster_spanner_engraver::acknowledge_grob (Grob_info info) } ADD_TRANSLATOR (Cluster_spanner_engraver, -/* descr */ "Engraves a cluster using Spanner notation ", -/* creats*/ "ClusterSpanner ClusterSpannerBeacon", -/* accepts */ "cluster-note-event busy-playing-event", -/* acks */ "note-column-interface", -/* reads */ "", -/* write */ ""); + /* descr */ "Engraves a cluster using Spanner notation ", + /* creats*/ "ClusterSpanner ClusterSpannerBeacon", + /* accepts */ "cluster-note-event busy-playing-event", + /* acks */ "note-column-interface", + /* reads */ "", + /* write */ ""); diff --git a/lily/cluster.cc b/lily/cluster.cc index aec236de96..945a7ad51d 100644 --- a/lily/cluster.cc +++ b/lily/cluster.cc @@ -6,7 +6,6 @@ (c) 2002--2005 Juergen Reuter Han-Wen Nienhuys - */ #include "cluster.hh" @@ -21,17 +20,15 @@ #include "output-def.hh" #include "warn.hh" - /* - TODO: Add support for cubic spline segments. - - */ + TODO: Add support for cubic spline segments. +*/ Stencil brew_cluster_piece (Grob *me, Array bottom_points, Array top_points) { - Real blotdiameter = Staff_symbol_referencer::staff_space (me)/2; + Real blotdiameter = Staff_symbol_referencer::staff_space (me) / 2; - Real padding = robust_scm2double ( me->get_property ("padding"), 0.0); + Real padding = robust_scm2double (me->get_property ("padding"), 0.0); Offset vpadding = Offset (0, padding); Offset hpadding = Offset (0.5 * blotdiameter, 0); @@ -48,10 +45,9 @@ brew_cluster_piece (Grob *me, Array bottom_points, Array top_poi { programming_error ("#'style should be symbol."); me->suicide (); - return Stencil (); + return Stencil (); } - Stencil out; Array points; points.clear (); @@ -63,7 +59,7 @@ brew_cluster_piece (Grob *me, Array bottom_points, Array top_poi Box box; box.add_point (bottom_points[i] - hvpadding); box.add_point (Offset (top_points[i + 1][X_AXIS], - top_points[i][Y_AXIS]) + hvpadding); + top_points[i][Y_AXIS]) + hvpadding); out.add_stencil (Lookup::round_filled_box (box, blotdiameter)); } } @@ -73,7 +69,7 @@ brew_cluster_piece (Grob *me, Array bottom_points, Array top_poi { Box box; box.add_point (Offset (bottom_points[i][X_AXIS], - bottom_points[i + 1][Y_AXIS]) - hvpadding); + bottom_points[i + 1][Y_AXIS]) - hvpadding); box.add_point (top_points[i + 1] + hvpadding); out.add_stencil (Lookup::round_filled_box (box, blotdiameter)); } @@ -83,22 +79,22 @@ brew_cluster_piece (Grob *me, Array bottom_points, Array top_poi Real left_xmid = bottom_points[0][X_AXIS]; for (int i = 0; i < size - 1; i++) { - Real right_xmid = - 0.5 * (bottom_points[i][X_AXIS] + bottom_points[i + 1][X_AXIS]); + Real right_xmid + = 0.5 * (bottom_points[i][X_AXIS] + bottom_points[i + 1][X_AXIS]); Box box; - box.add_point (Offset (left_xmid, bottom_points[i][Y_AXIS]) - - hvpadding); - box.add_point (Offset (right_xmid, top_points[i][Y_AXIS]) + - hvpadding); + box.add_point (Offset (left_xmid, bottom_points[i][Y_AXIS]) + - hvpadding); + box.add_point (Offset (right_xmid, top_points[i][Y_AXIS]) + + hvpadding); out.add_stencil (Lookup::round_filled_box (box, blotdiameter)); left_xmid = right_xmid; } Real right_xmid = bottom_points[size - 1][X_AXIS]; Box box; - box.add_point (Offset (left_xmid, bottom_points[size - 1][Y_AXIS]) - - hvpadding); - box.add_point (Offset (right_xmid, top_points[size - 1][Y_AXIS]) + - hvpadding); + box.add_point (Offset (left_xmid, bottom_points[size - 1][Y_AXIS]) + - hvpadding); + box.add_point (Offset (right_xmid, top_points[size - 1][Y_AXIS]) + + hvpadding); out.add_stencil (Lookup::round_filled_box (box, blotdiameter)); } else if (String::compare (shape, "ramp") == 0) @@ -130,7 +126,7 @@ Cluster::print (SCM smob) { Grob *me = unsmob_grob (smob); - Spanner *spanner = dynamic_cast (me); + Spanner *spanner = dynamic_cast (me); if (!spanner) { me->programming_error ("Cluster::print (): not a spanner"); @@ -141,32 +137,31 @@ Cluster::print (SCM smob) Item *right_bound = spanner->get_bound (RIGHT); Grob *commonx = left_bound->common_refpoint (right_bound, X_AXIS); - SCM cols = me->get_property ("columns"); + SCM cols = me->get_property ("columns"); if (!scm_is_pair (cols)) { me->warning ("junking empty cluster"); me->suicide (); - + return SCM_EOL; } - + commonx = common_refpoint_of_list (cols, commonx, X_AXIS); - Grob * commony = common_refpoint_of_list (cols, me, Y_AXIS); + Grob *commony = common_refpoint_of_list (cols, me, Y_AXIS); Array bottom_points; Array top_points; - Real left_coord = left_bound->relative_coordinate (commonx, X_AXIS); /* TODO: should we move the cluster a little to the right to be in line with the center of the note heads? - - */ + + */ for (SCM s = cols; scm_is_pair (s); s = scm_cdr (s)) { - Grob * col = unsmob_grob (scm_car (s)); + Grob *col = unsmob_grob (scm_car (s)); Interval yext = col->extent (commony, Y_AXIS); Real x = col->relative_coordinate (commonx, X_AXIS) - left_coord; @@ -176,23 +171,23 @@ Cluster::print (SCM smob) /* Across a line break we anticipate on the next pitches. - */ + */ if (spanner->original_) { - Spanner *orig = dynamic_cast (spanner->original_); - - if (spanner->get_break_index () < orig->broken_intos_.size ()-1) + Spanner *orig = dynamic_cast (spanner->original_); + + if (spanner->get_break_index () < orig->broken_intos_.size () - 1) { - Spanner * next = orig->broken_intos_[spanner->get_break_index () + 1]; + Spanner *next = orig->broken_intos_[spanner->get_break_index () + 1]; SCM cols = next->get_property ("columns"); if (scm_is_pair (cols)) { Grob *next_commony = common_refpoint_of_list (cols, next, Y_AXIS); - Grob * col = unsmob_grob (scm_car (scm_last_pair (cols))); + Grob *col = unsmob_grob (scm_car (scm_last_pair (cols))); Interval v = col->extent (next_commony, Y_AXIS); Real x = right_bound->relative_coordinate (commonx, X_AXIS) - left_coord; - + bottom_points.insert (Offset (x, v[DOWN]), 0); top_points.insert (Offset (x, v[UP]), 0); } @@ -208,17 +203,14 @@ Cluster::print (SCM smob) } ADD_INTERFACE (Cluster, "cluster-interface", - "A graphically drawn musical cluster. " + "A graphically drawn musical cluster. " "\n\n" "@code{padding} adds to the vertical extent of the shape (top and " "bottom). \n\n" "The property @code{style} controls the shape of cluster segments. Valid values " "include @code{leftsided-stairs}, @code{rightsided-stairs}, @code{centered-stairs}, " - "and @code{ramp}.\n" -, - "style padding columns"); - - + "and @code{ramp}.\n", + "style padding columns"); struct Cluster_beacon { @@ -237,10 +229,8 @@ Cluster_beacon::height (SCM g, SCM) return ly_interval2scm (Staff_symbol_referencer::staff_space (me) * 0.5 * v); } - - -ADD_INTERFACE(Cluster_beacon, - "cluster-beacon-interface", - "A place holder for the cluster spanner to determine the vertical " - "extents of a cluster spanner at this X position.", - "positions"); +ADD_INTERFACE (Cluster_beacon, + "cluster-beacon-interface", + "A place holder for the cluster spanner to determine the vertical " + "extents of a cluster spanner at this X position.", + "positions"); diff --git a/lily/coherent-ligature-engraver.cc b/lily/coherent-ligature-engraver.cc index 6e4dbd80ad..d4ae786cb5 100644 --- a/lily/coherent-ligature-engraver.cc +++ b/lily/coherent-ligature-engraver.cc @@ -1,10 +1,10 @@ /* coherent-ligature-engraver.cc -- implement Coherent_ligature_engraver - + source file of the GNU LilyPond music typesetter - + (c) 2003--2005 Juergen Reuter - */ +*/ #include "coherent-ligature-engraver.hh" @@ -78,29 +78,29 @@ * add it to the spacing spanner code. */ #if 0 // experimental code to collapse spacing after ligature - SCM incr_scm = lc->get_property ("forced-spacing"); - if (incr_scm != SCM_EOL) /* (Paper_column::is_musical (l)) */ - { - me->warning (_f ("gotcha: ptr=%ul", lc));//debug - ly_display_scm (lc->self_scm ()); - Real distance; - if (incr_scm != SCM_EOL) - { - distance = scm_to_double (incr_scm); - } - else - { - me->warning ("distance undefined, assuming 0.1"); - distance = 0.1; - } - me->warning (_f ("distance=%f", distance));//debug - Real strength = 1.0; - Spaceable_grob::add_spring (lc, rc, distance, strength); - if (Item *rb = r->find_prebroken_piece (LEFT)) - Spaceable_grob::add_spring (lc, rb, distance, strength); +SCM incr_scm = lc->get_property ("forced-spacing"); +if (incr_scm != SCM_EOL) /* (Paper_column::is_musical (l)) */ + { + me->warning (_f ("gotcha: ptr=%ul", lc));//debug + ly_display_scm (lc->self_scm ()); + Real distance; + if (incr_scm != SCM_EOL) + { + distance = scm_to_double (incr_scm); + } + else + { + me->warning ("distance undefined, assuming 0.1"); + distance = 0.1; + } + me->warning (_f ("distance=%f", distance));//debug + Real strength = 1.0; + Spaceable_grob::add_spring (lc, rc, distance, strength); + if (Item *rb = r->find_prebroken_piece (LEFT)) + Spaceable_grob::add_spring (lc, rb, distance, strength); - continue; - } + continue; + } #endif Coherent_ligature_engraver::Coherent_ligature_engraver () @@ -113,7 +113,7 @@ Coherent_ligature_engraver::Coherent_ligature_engraver () void Coherent_ligature_engraver::get_set_column (Item *item, Paper_column *column) { - Item *parent = dynamic_cast (item->get_parent (X_AXIS)); + Item *parent = dynamic_cast (item->get_parent (X_AXIS)); if (!parent) { programming_error ("failed tweaking paper column in ligature"); @@ -131,8 +131,8 @@ Coherent_ligature_engraver::get_set_column (Item *item, Paper_column *column) tail = scm_cdr (tail)) { Item *sibling = unsmob_item (scm_car (tail)); - if ((sibling) && - (Staff_symbol_referencer::get_staff_symbol (sibling) == sl)) + if ((sibling) + && (Staff_symbol_referencer::get_staff_symbol (sibling) == sl)) { #if 0 // experimental code to collapse spacing after ligature Grob *sibling_parent = sibling->get_parent (X_AXIS); @@ -140,7 +140,7 @@ Coherent_ligature_engraver::get_set_column (Item *item, Paper_column *column) "setting `spacing-increment=" "0.01': ptr=%ul", parent)); sibling_parent->set_property ("forced-spacing", - scm_make_real (0.01)); + scm_make_real (0.01)); #endif sibling->set_parent (column, X_AXIS); } @@ -175,20 +175,21 @@ compute_delta_pitches (Array primitives) int prev_pitch = 0; int delta_pitch = 0; Item *prev_primitive = 0, *primitive = 0; - for (int i = 0; i < primitives.size (); i++) { - primitive = dynamic_cast (primitives[i].grob_); - Music *music_cause = primitives[i].music_cause (); - int pitch = - unsmob_pitch (music_cause->get_property ("pitch"))->steps (); - if (prev_primitive) - { - delta_pitch = pitch - prev_pitch; - prev_primitive->set_property ("delta-pitch", - scm_int2num (delta_pitch)); - } - prev_pitch = pitch; - prev_primitive = primitive; - } + for (int i = 0; i < primitives.size (); i++) + { + primitive = dynamic_cast (primitives[i].grob_); + Music *music_cause = primitives[i].music_cause (); + int pitch + = unsmob_pitch (music_cause->get_property ("pitch"))->steps (); + if (prev_primitive) + { + delta_pitch = pitch - prev_pitch; + prev_primitive->set_property ("delta-pitch", + scm_int2num (delta_pitch)); + } + prev_pitch = pitch; + prev_primitive = primitive; + } primitive->set_property ("delta-pitch", scm_int2num (0)); } @@ -214,9 +215,9 @@ Coherent_ligature_engraver::typeset_ligature (Spanner *ligature, } ADD_TRANSLATOR (Coherent_ligature_engraver, -/* descr */ "This is an abstract class. Subclasses such as Gregorian_ligature_engraver handle ligatures by glueing special ligature heads together.", -/* creats*/ "", -/* accepts */ "ligature-event", -/* acks */ "note-head-interface rest-interface", -/* reads */ "", -/* write */ ""); + /* descr */ "This is an abstract class. Subclasses such as Gregorian_ligature_engraver handle ligatures by glueing special ligature heads together.", + /* creats*/ "", + /* accepts */ "ligature-event", + /* acks */ "note-head-interface rest-interface", + /* reads */ "", + /* write */ ""); diff --git a/lily/collision-engraver.cc b/lily/collision-engraver.cc index 22cfd55171..a277540df3 100644 --- a/lily/collision-engraver.cc +++ b/lily/collision-engraver.cc @@ -14,7 +14,7 @@ class Collision_engraver : public Engraver { - Item * col_; + Item *col_; Link_array note_columns_; protected: @@ -25,18 +25,17 @@ public: TRANSLATOR_DECLARATIONS (Collision_engraver); }; - void Collision_engraver::process_acknowledged_grobs () { if (col_ || note_columns_.size () < 2) - return ; - if (!col_) + return; + if (!col_) { col_ = make_item ("NoteCollision", SCM_EOL); - + } - + for (int i = 0; i< note_columns_.size (); i++) Note_collision_interface::add_column (col_, note_columns_[i]); } @@ -48,7 +47,7 @@ Collision_engraver::acknowledge_grob (Grob_info i) { /*should check Y axis? */ if (Note_column::has_rests (i.grob_) || i.grob_->get_parent (X_AXIS)) - return ; + return; note_columns_.push (i.grob_); } @@ -67,12 +66,10 @@ Collision_engraver::Collision_engraver () } - - ADD_TRANSLATOR (Collision_engraver, -/* descr */ "Collect NoteColumns, and as soon as there are two or more, put them in a NoteCollision object.", -/* creats*/ "NoteCollision", -/* accepts */ "", -/* acks */ "note-column-interface", -/* reads */ "", -/* write */ ""); + /* descr */ "Collect NoteColumns, and as soon as there are two or more, put them in a NoteCollision object.", + /* creats*/ "NoteCollision", + /* accepts */ "", + /* acks */ "note-column-interface", + /* reads */ "", + /* write */ ""); diff --git a/lily/completion-note-heads-engraver.cc b/lily/completion-note-heads-engraver.cc index 9d17deaf62..0c9631afab 100644 --- a/lily/completion-note-heads-engraver.cc +++ b/lily/completion-note-heads-engraver.cc @@ -20,11 +20,10 @@ #include "global-context.hh" /* -TODO: make matching rest engraver. + TODO: make matching rest engraver. */ /* - How does this work? When we catch the note, we predict the end of the note. We keep the @@ -34,7 +33,7 @@ TODO: make matching rest engraver. figure out how long the note to typeset should be. It should be no longer than what's specified, than what is left to do and it should not cross barlines. - + We copy the reqs into scratch note reqs, to make sure that we get all durations exactly right. */ @@ -44,7 +43,7 @@ class Completion_heads_engraver : public Engraver Link_array notes_; Link_array prev_notes_; Link_array ties_; - + Link_array dots_; Link_array note_reqs_; Link_array scratch_note_reqs_; @@ -53,17 +52,17 @@ class Completion_heads_engraver : public Engraver bool is_first_; Rational left_to_do_; Rational do_nothing_until_; - + Moment next_barline_moment (); Duration find_nearest_duration (Rational length); - + public: TRANSLATOR_DECLARATIONS (Completion_heads_engraver); protected: virtual void initialize (); virtual void start_translation_timestep (); - virtual bool try_music (Music *req) ; + virtual bool try_music (Music *req); virtual void process_music (); virtual void stop_translation_timestep (); }; @@ -75,7 +74,7 @@ Completion_heads_engraver::initialize () } bool -Completion_heads_engraver::try_music (Music *m) +Completion_heads_engraver::try_music (Music *m) { if (m->is_mus_type ("note-event")) { @@ -87,28 +86,28 @@ Completion_heads_engraver::try_music (Music *m) if (now_mom ().grace_part_) { - musiclen.grace_part_ = musiclen.main_part_ ; + musiclen.grace_part_ = musiclen.main_part_; musiclen.main_part_ = Rational (0, 1); } - note_end_mom_ = note_end_mom_ >? (now + musiclen); + note_end_mom_ = note_end_mom_ >? (now + musiclen); do_nothing_until_ = Rational (0, 0); - + return true; } - else if (m->is_mus_type ("busy-playing-event")) + else if (m->is_mus_type ("busy-playing-event")) { - return note_reqs_.size() && is_first_; + return note_reqs_.size () && is_first_; } - + return false; - + } /* The duration _until_ the next barline. - */ +*/ Moment -Completion_heads_engraver::next_barline_moment ( ) +Completion_heads_engraver::next_barline_moment () { Moment *e = unsmob_moment (get_property ("measurePosition")); Moment *l = unsmob_moment (get_property ("measureLength")); @@ -121,7 +120,7 @@ Completion_heads_engraver::next_barline_moment ( ) return (*l - *e); } -Duration +Duration Completion_heads_engraver::find_nearest_duration (Rational length) { int log_limit = 6; @@ -152,7 +151,7 @@ Completion_heads_engraver::find_nearest_duration (Rational length) // scale up. d = d.compressed (length / d.get_length ()); } - + return d; } @@ -160,14 +159,14 @@ void Completion_heads_engraver::process_music () { if (!is_first_ && !left_to_do_) - return ; - + return; + is_first_ = false; - Moment now = now_mom (); + Moment now = now_mom (); if (do_nothing_until_ > now.main_part_) - return ; - + return; + Duration note_dur; Duration *orig = 0; if (left_to_do_) @@ -186,7 +185,7 @@ Completion_heads_engraver::process_music () Moment next = now; next.main_part_ += note_dur.get_length (); - + get_global_context ()->add_moment_to_process (next); do_nothing_until_ = next.main_part_; } @@ -201,37 +200,36 @@ Completion_heads_engraver::process_music () if (!scratch_note_reqs_.size ()) for (int i = 0; i < note_reqs_.size (); i++) { - Music * m = note_reqs_[i]->clone (); + Music *m = note_reqs_[i]->clone (); scratch_note_reqs_.push (m); } } - for (int i = 0; left_to_do_ && i < note_reqs_.size (); i++) { - Music * req = note_reqs_[i]; + Music *req = note_reqs_[i]; if (scratch_note_reqs_.size ()) { req = scratch_note_reqs_[i]; SCM pits = note_reqs_[i]->get_property ("pitch"); req->set_property ("pitch", pits); } - + req->set_property ("duration", note_dur.smobbed_copy ()); - Item *note = make_item ("NoteHead", req->self_scm ()); + Item *note = make_item ("NoteHead", req->self_scm ()); note->set_property ("duration-log", scm_int2num (note_dur.duration_log ())); - + int dots = note_dur.dot_count (); if (dots) { - Item * d = make_item ("Dots", SCM_EOL); + Item *d = make_item ("Dots", SCM_EOL); Rhythmic_head::set_dots (note, d); /* - measly attempt to save an eeny-weenie bit of memory. + measly attempt to save an eeny-weenie bit of memory. */ if (dots != scm_to_int (d->get_property ("dot-count"))) d->set_property ("dot-count", scm_int2num (dots)); @@ -247,22 +245,22 @@ Completion_heads_engraver::process_music () if (scm_is_number (c0)) pos += scm_to_int (c0); - note->set_property ("staff-position", scm_int2num (pos)); + note->set_property ("staff-position", scm_int2num (pos)); notes_.push (note); } - + if (prev_notes_.size () == notes_.size ()) { for (int i = 0; i < notes_.size (); i++) { - Grob * p = make_spanner ("Tie", SCM_EOL); + Grob *p = make_spanner ("Tie", SCM_EOL); Tie::set_interface (p); // cannot remove yet! - + Tie::set_head (p, LEFT, prev_notes_[i]); Tie::set_head (p, RIGHT, notes_[i]); - + ties_.push (p); - + } } @@ -270,30 +268,30 @@ Completion_heads_engraver::process_music () /* don't do complicated arithmetic with grace notes. - */ + */ if (orig - && now_mom ().grace_part_ ) + && now_mom ().grace_part_) { left_to_do_ = Rational (0, 0); } } - + void Completion_heads_engraver::stop_translation_timestep () { ties_.clear (); - + if (notes_.size ()) prev_notes_ = notes_; notes_.clear (); - + dots_.clear (); for (int i = scratch_note_reqs_.size (); i--;) { - scm_gc_unprotect_object (scratch_note_reqs_[i]->self_scm () ); + scm_gc_unprotect_object (scratch_note_reqs_[i]->self_scm ()); } - + scratch_note_reqs_.clear (); } @@ -313,11 +311,11 @@ Completion_heads_engraver::Completion_heads_engraver () } ADD_TRANSLATOR (Completion_heads_engraver, -/* descr */ "This engraver replaces " -"@code{Note_heads_engraver}. It plays some trickery to " -"break long notes and automatically tie them into the next measure.", -/* creats*/ "NoteHead Dots Tie", -/* accepts */ "busy-playing-event note-event", -/* acks */ "", -/* reads */ "middleCPosition measurePosition measureLength", -/* write */ ""); + /* descr */ "This engraver replaces " + "@code{Note_heads_engraver}. It plays some trickery to " + "break long notes and automatically tie them into the next measure.", + /* creats*/ "NoteHead Dots Tie", + /* accepts */ "busy-playing-event note-event", + /* acks */ "", + /* reads */ "middleCPosition measurePosition measureLength", + /* write */ ""); diff --git a/lily/context-def.cc b/lily/context-def.cc index cbab27ba57..b049215ddb 100644 --- a/lily/context-def.cc +++ b/lily/context-def.cc @@ -1,4 +1,4 @@ -/* +/* translator-def.cc -- implement Context_def source file of the GNU LilyPond music typesetter @@ -33,17 +33,17 @@ Context_def::Context_def () context_name_ = ly_symbol2scm (""); } -Context_def::Context_def (Context_def const & s) +Context_def::Context_def (Context_def const &s) : Input (s) { context_aliases_ = SCM_EOL; translator_group_type_ = SCM_EOL; - accept_mods_ = SCM_EOL; + accept_mods_ = SCM_EOL; translator_mods_ = SCM_EOL; property_ops_ = SCM_EOL; context_name_ = SCM_EOL; description_ = SCM_EOL; - + smobify_self (); description_ = s.description_; @@ -66,7 +66,7 @@ IMPLEMENT_DEFAULT_EQUAL_P (Context_def); int Context_def::print_smob (SCM smob, SCM port, scm_print_state*) { - Context_def* me = (Context_def*) SCM_CELL_WORD_1 (smob); + Context_def *me = (Context_def *) SCM_CELL_WORD_1 (smob); scm_puts ("#context_name_, port); @@ -77,13 +77,13 @@ Context_def::print_smob (SCM smob, SCM port, scm_print_state*) SCM Context_def::mark_smob (SCM smob) { - Context_def* me = (Context_def*) SCM_CELL_WORD_1 (smob); + Context_def *me = (Context_def *) SCM_CELL_WORD_1 (smob); scm_gc_mark (me->description_); scm_gc_mark (me->context_aliases_); scm_gc_mark (me->accept_mods_); scm_gc_mark (me->translator_mods_); - scm_gc_mark (me->property_ops_); + scm_gc_mark (me->property_ops_); scm_gc_mark (me->translator_group_type_); return me->context_name_; @@ -102,7 +102,7 @@ Context_def::add_context_mod (SCM mod) SCM sym = scm_cadr (mod); if (scm_is_string (sym)) sym = scm_string_to_symbol (sym); - + if (ly_symbol2scm ("consists") == tag || ly_symbol2scm ("consists-end") == tag || ly_symbol2scm ("remove") == tag) @@ -115,7 +115,7 @@ Context_def::add_context_mod (SCM mod) } else if (ly_symbol2scm ("accepts") == tag || ly_symbol2scm ("denies") == tag) - accept_mods_ = scm_cons (scm_list_2 (tag, sym), accept_mods_); + accept_mods_ = scm_cons (scm_list_2 (tag, sym), accept_mods_); else if (ly_symbol2scm ("poppush") == tag || ly_symbol2scm ("pop") == tag || ly_symbol2scm ("push") == tag @@ -124,9 +124,9 @@ Context_def::add_context_mod (SCM mod) property_ops_ = scm_cons (mod, property_ops_); else if (ly_symbol2scm ("alias") == tag) context_aliases_ = scm_cons (sym, context_aliases_); - else if (ly_symbol2scm ("translator-type") == tag) + else if (ly_symbol2scm ("translator-type") == tag) translator_group_type_ = sym; - else if (ly_symbol2scm ("context-name") == tag) + else if (ly_symbol2scm ("context-name") == tag) context_name_ = sym; else programming_error ("Unknown context mod tag."); @@ -159,7 +159,7 @@ Link_array Context_def::path_to_acceptable_context (SCM type_sym, Output_def *odef) const { assert (scm_is_symbol (type_sym)); - + SCM accepted = get_accepted (SCM_EOL); Link_array accepteds; @@ -183,7 +183,7 @@ Context_def::path_to_acceptable_context (SCM type_sym, Output_def *odef) const int best_depth = INT_MAX; for (int i = 0; i < accepteds.size (); i++) { - Context_def * g = accepteds[i]; + Context_def *g = accepteds[i]; Link_array result = g->path_to_acceptable_context (type_sym, odef); @@ -207,7 +207,7 @@ Context_def::get_translator_names (SCM user_mod) const SCM l1 = SCM_EOL; SCM mods = scm_reverse_x (scm_list_copy (translator_mods_), user_mod); - + for (SCM s = mods; scm_is_pair (s); s = scm_cdr (s)) { SCM tag = scm_caar (s); @@ -215,7 +215,7 @@ Context_def::get_translator_names (SCM user_mod) const if (scm_is_string (arg)) arg = scm_string_to_symbol (arg); - + if (ly_symbol2scm ("consists") == tag) l1 = scm_cons (arg, l1); else if (ly_symbol2scm ("remove") == tag) @@ -232,11 +232,11 @@ filter_performers (SCM ell) { for (SCM *tail = ℓ scm_is_pair (*tail); tail = SCM_CDRLOC (*tail)) { - if (dynamic_cast (unsmob_translator (scm_car (*tail)))) + if (dynamic_cast (unsmob_translator (scm_car (*tail)))) { *tail = scm_cdr (*tail); if (!scm_is_pair (*tail)) - break ; + break; } } return ell; @@ -245,24 +245,23 @@ filter_performers (SCM ell) SCM filter_engravers (SCM ell) { - SCM *tail = ℓ - for (; scm_is_pair (*tail) ; tail = SCM_CDRLOC (*tail)) + SCM *tail = ℓ + for (; scm_is_pair (*tail); tail = SCM_CDRLOC (*tail)) { - if (dynamic_cast (unsmob_translator (scm_car (*tail)))) + if (dynamic_cast (unsmob_translator (scm_car (*tail)))) { *tail = scm_cdr (*tail); if (!scm_is_pair (*tail)) - break ; + break; } } return ell; } - Context * Context_def::instantiate (SCM ops, Object_key const *key) { - Context *tg = 0; + Context *tg = 0; if (context_name_ == ly_symbol2scm ("Score")) tg = new Score_context (key); @@ -271,15 +270,15 @@ Context_def::instantiate (SCM ops, Object_key const *key) tg->definition_ = self_scm (); - SCM trans_names = get_translator_names (ops); + SCM trans_names = get_translator_names (ops); - Translator_group *g = dynamic_cast + Translator_group *g = dynamic_cast (get_translator (translator_group_type_)); - g = dynamic_cast (g->clone ()); + g = dynamic_cast (g->clone ()); SCM trans_list = SCM_EOL; - - for (SCM s = trans_names; scm_is_pair (s) ; s = scm_cdr (s)) + + for (SCM s = trans_names; scm_is_pair (s); s = scm_cdr (s)) { Translator *t = get_translator (scm_car (s)); if (!t) @@ -306,20 +305,20 @@ Context_def::instantiate (SCM ops, Object_key const *key) scm_gc_unprotect_object (str); } } - - g->simple_trans_list_ = trans_list; + + g->simple_trans_list_ = trans_list; tg->implementation_ = g->self_scm (); - if (dynamic_cast (g)) + if (dynamic_cast (g)) g->simple_trans_list_ = filter_performers (g->simple_trans_list_); - else if (dynamic_cast (g)) + else if (dynamic_cast (g)) g->simple_trans_list_ = filter_engravers (g->simple_trans_list_); - + g->daddy_context_ = tg; - tg->aliases_ = context_aliases_ ; - + tg->aliases_ = context_aliases_; + scm_gc_unprotect_object (g->self_scm ()); - + tg->accepts_list_ = get_accepted (ops); return tg; @@ -367,7 +366,7 @@ Context_def::to_alist () const if (scm_is_symbol (translator_group_type_)) ell = scm_cons (scm_cons (ly_symbol2scm ("group-type"), - translator_group_type_), ell); - return ell; + translator_group_type_), ell); + return ell; } diff --git a/lily/context-handle.cc b/lily/context-handle.cc index a4c7ecd70e..a649ef02f2 100644 --- a/lily/context-handle.cc +++ b/lily/context-handle.cc @@ -1,10 +1,10 @@ -/* +/* interpretation-context-handle.cc -- implement Interpretation_context_handle - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - */ +*/ #include "interpretation-context-handle.hh" #include "context.hh" @@ -14,37 +14,36 @@ Interpretation_context_handle::Interpretation_context_handle () outlet_ = 0; } -Interpretation_context_handle::Interpretation_context_handle (Interpretation_context_handle const&s) +Interpretation_context_handle::Interpretation_context_handle (Interpretation_context_handle const &s) { outlet_ = 0; if (s.outlet_) up (s.outlet_); } - Interpretation_context_handle::~Interpretation_context_handle () { /* Don't do if (outlet_) - down (); + down (); with GC, this is asynchronous. - */ + */ } void Interpretation_context_handle::up (Context *t) { outlet_ = t; - t->iterator_count_ ++; + t->iterator_count_++; } void Interpretation_context_handle::down () { - outlet_->iterator_count_ --; + outlet_->iterator_count_--; outlet_ = 0; } @@ -53,7 +52,7 @@ Interpretation_context_handle::quit () { if (outlet_) { - outlet_->iterator_count_ --; + outlet_->iterator_count_--; outlet_ = 0; } } @@ -65,7 +64,7 @@ Interpretation_context_handle::try_music (Music *m) } void -Interpretation_context_handle::operator = (Interpretation_context_handle const &s) +Interpretation_context_handle::operator= (Interpretation_context_handle const &s) { set_context (s.outlet_); } @@ -84,12 +83,12 @@ Interpretation_context_handle::set_context (Context *trans) Context * Interpretation_context_handle::get_outlet () const { - + return outlet_; } int Interpretation_context_handle::get_count () const { - return outlet_->iterator_count_ ; + return outlet_->iterator_count_; } diff --git a/lily/context-property.cc b/lily/context-property.cc index ee031b4b84..48418e5141 100644 --- a/lily/context-property.cc +++ b/lily/context-property.cc @@ -1,10 +1,10 @@ /* - context-property.cc -- implement manipulation of immutable Grob - property lists. + context-property.cc -- implement manipulation of immutable Grob + property lists. - source file of the GNU LilyPond music typesetter + source file of the GNU LilyPond music typesetter - (c) 2004--2005 Han-Wen Nienhuys + (c) 2004--2005 Han-Wen Nienhuys */ #include "context.hh" @@ -19,17 +19,15 @@ represented as a (ALIST . BASED-ON) pair, where BASED-ON is the alist defined in a parent context. BASED-ON should always be a tail of ALIST. - - */ +*/ /* Push or pop (depending on value of VAL) a single entry (ELTPROP . VAL) entry from a translator property list by name of PROP */ - void -execute_pushpop_property (Context * trg, +execute_pushpop_property (Context *trg, SCM prop, SCM eltprop, SCM val) { if (scm_is_symbol (prop) && scm_is_symbol (eltprop)) @@ -37,37 +35,37 @@ execute_pushpop_property (Context * trg, if (val != SCM_UNDEFINED) { SCM prev = SCM_EOL; - Context * where = trg->where_defined (prop); + Context *where = trg->where_defined (prop); /* Don't mess with MIDI. - */ + */ if (!where) - return ; - + return; + if (where != trg) { SCM base = updated_grob_properties (trg, prop); - prev = scm_cons (base, base); + prev = scm_cons (base, base); trg->internal_set_property (prop, prev); } else prev = trg->internal_get_property (prop); - + if (!scm_is_pair (prev)) { programming_error ("Grob definition should be cons."); - return ; + return; } SCM prev_alist = scm_car (prev); - + if (scm_is_pair (prev_alist) || prev_alist == SCM_EOL) { bool ok = type_check_assignment (eltprop, val, ly_symbol2scm ("backend-type?")); /* - tack onto alist: + tack onto alist: */ if (ok) scm_set_car_x (prev, scm_acons (eltprop, val, prev_alist)); @@ -82,7 +80,7 @@ execute_pushpop_property (Context * trg, SCM prev = trg->internal_get_property (prop); SCM prev_alist = scm_car (prev); SCM daddy = scm_cdr (prev); - + SCM new_alist = SCM_EOL; SCM *tail = &new_alist; @@ -91,10 +89,9 @@ execute_pushpop_property (Context * trg, if (ly_c_equal_p (scm_caar (prev_alist), eltprop)) { prev_alist = scm_cdr (prev_alist); - break ; + break; } - *tail = scm_cons (scm_car (prev_alist), SCM_EOL); tail = SCM_CDRLOC (*tail); prev_alist = scm_cdr (prev_alist); @@ -119,7 +116,7 @@ execute_pushpop_property (Context * trg, /* PRE_INIT_OPS is in the order specified, and hence must be reversed. - */ +*/ void apply_property_operations (Context *tg, SCM pre_init_ops) { @@ -128,8 +125,8 @@ apply_property_operations (Context *tg, SCM pre_init_ops) { SCM entry = scm_car (s); SCM type = scm_car (entry); - entry = scm_cdr (entry); - + entry = scm_cdr (entry); + if (type == ly_symbol2scm ("push") || type == ly_symbol2scm ("poppush")) { SCM val = scm_cddr (entry); @@ -146,23 +143,23 @@ apply_property_operations (Context *tg, SCM pre_init_ops) /* Return the object alist for SYM, checking if its base in enclosing - contexts has changed. The alist is updated if necessary. - */ + contexts has changed. The alist is updated if necessary. +*/ SCM -updated_grob_properties (Context * tg, SCM sym) +updated_grob_properties (Context *tg, SCM sym) { assert (scm_is_symbol (sym)); - + tg = tg->where_defined (sym); if (!tg) return SCM_EOL; - + SCM daddy_props = (tg->get_parent_context ()) ? updated_grob_properties (tg->get_parent_context (), sym) : SCM_EOL; - - SCM props = tg->internal_get_property (sym); + + SCM props = tg->internal_get_property (sym); if (!scm_is_pair (props)) { @@ -180,13 +177,13 @@ updated_grob_properties (Context * tg, SCM sym) SCM copy = daddy_props; SCM *tail = © SCM p = scm_car (props); - while (p != based_on) + while (p != based_on) { *tail = scm_cons (scm_car (p), daddy_props); tail = SCM_CDRLOC (*tail); p = scm_cdr (p); } - + scm_set_car_x (props, copy); scm_set_cdr_x (props, daddy_props); @@ -195,21 +192,21 @@ updated_grob_properties (Context * tg, SCM sym) } Item * -make_item_from_properties (Engraver *tr, SCM x, SCM cause, const char * name) +make_item_from_properties (Engraver *tr, SCM x, SCM cause, const char *name) { Context *context = tr->context (); - + SCM props = updated_grob_properties (context, x); - Object_key const*key = context->get_grob_key (name); + Object_key const *key = context->get_grob_key (name); Item *it = new Item (props, key); - dynamic_cast(tr)->announce_grob (it, cause); + dynamic_cast (tr)->announce_grob (it, cause); return it; } -Spanner* +Spanner * make_spanner_from_properties (Engraver *tr, SCM x, SCM cause, const char *name) { Context *context = tr->context (); @@ -217,7 +214,7 @@ make_spanner_from_properties (Engraver *tr, SCM x, SCM cause, const char *name) SCM props = updated_grob_properties (context, x); Spanner *it = new Spanner (props, context->get_grob_key (name)); - dynamic_cast(tr)->announce_grob (it, cause); + dynamic_cast (tr)->announce_grob (it, cause); return it; } diff --git a/lily/context-scheme.cc b/lily/context-scheme.cc index b7af85dd28..3d26ef368c 100644 --- a/lily/context-scheme.cc +++ b/lily/context-scheme.cc @@ -4,7 +4,7 @@ source file of the GNU LilyPond music typesetter (c) 1998--2005 Jan Nieuwenhuizen - Han-Wen Nienhuys + Han-Wen Nienhuys */ #include "context.hh" @@ -12,7 +12,7 @@ LY_DEFINE (ly_context_id, "ly:context-id", 1, 0, 0, (SCM context), - "Return the id string of @var{context}, " + "Return the id string of @var{context}, " "i.e. for @code{\\context Voice = one .. } " "return the string @code{one}.") { @@ -30,7 +30,7 @@ LY_DEFINE (ly_context_name, "ly:context-name", { Context *tr = unsmob_context (context); SCM_ASSERT_TYPE (tr, context, SCM_ARG1, __FUNCTION__, "Context"); - return ly_symbol2scm (tr->context_name ().to_str0 ()); + return ly_symbol2scm (tr->context_name ().to_str0 ()); } LY_DEFINE (ly_context_grob_definition, "ly:context-grob-definition", @@ -42,11 +42,9 @@ LY_DEFINE (ly_context_grob_definition, "ly:context-grob-definition", SCM_ASSERT_TYPE (tr, context, SCM_ARG1, __FUNCTION__, "Context"); SCM_ASSERT_TYPE (scm_is_symbol (name), name, SCM_ARG2, __FUNCTION__, "symbol"); - return updated_grob_properties (tr, name); } - LY_DEFINE (ly_context_pushpop_property, "ly:context-pushpop-property", 3, 1, 0, (SCM context, SCM grob, SCM eltprop, SCM val), "Do a single @code{\\override} or @code{\\revert} operation " @@ -66,10 +64,10 @@ LY_DEFINE (ly_context_pushpop_property, "ly:context-pushpop-property", LY_DEFINE (ly_context_property, "ly:context-property", 2, 0, 0, (SCM c, SCM name), - "Return the value of @var{name} from context @var{c}") + "Return the value of @var{name} from context @var{c}") { Context *t = unsmob_context (c); - Context * tr = (t); + Context *tr = (t); SCM_ASSERT_TYPE (tr, c, SCM_ARG1, __FUNCTION__, "Translator group"); SCM_ASSERT_TYPE (scm_is_symbol (name), name, SCM_ARG2, __FUNCTION__, "symbol"); @@ -125,7 +123,7 @@ LY_DEFINE (ly_context_parent, "ly:context-parent", Context *tr = unsmob_context (context); SCM_ASSERT_TYPE (tr, context, SCM_ARG1, __FUNCTION__, "Context"); - tr = tr->get_parent_context () ; + tr = tr->get_parent_context (); if (tr) return tr->self_scm (); else @@ -141,15 +139,14 @@ LY_DEFINE (ly_context_find, "ly:context-find", Context *tr = unsmob_context (context); SCM_ASSERT_TYPE (tr, context, SCM_ARG1, __FUNCTION__, "context"); SCM_ASSERT_TYPE (scm_is_symbol (name), name, SCM_ARG2, __FUNCTION__, "symbol"); - + while (tr) { if (tr->is_alias (name)) return tr->self_scm (); - tr = tr->get_parent_context () ; + tr = tr->get_parent_context (); } - + return SCM_BOOL_F; } - diff --git a/lily/context-specced-music-iterator.cc b/lily/context-specced-music-iterator.cc index 6fc2b4b5be..b639e3b7e4 100644 --- a/lily/context-specced-music-iterator.cc +++ b/lily/context-specced-music-iterator.cc @@ -1,11 +1,10 @@ -/* +/* context-specced-music-iterator.cc -- implement - Context_specced_music_iterator + Context_specced_music_iterator source file of the GNU LilyPond music typesetter (c) 2002--2005 Han-Wen Nienhuys - */ #include "music-wrapper-iterator.hh" @@ -28,8 +27,8 @@ Context_specced_music_iterator::construct_children () if (scm_is_string (ci)) c_id = ly_scm2string (ci); SCM ops = get_music ()->get_property ("property-operations"); - - Context * a = 0; + + Context *a = 0; if (c_id == "$uniqueContextId") a = get_outlet ()->create_unique_context (ct, ops); @@ -37,10 +36,10 @@ Context_specced_music_iterator::construct_children () a = get_outlet ()->find_create_context (ct, c_id, ops); if (a - && to_boolean (get_music ()->get_property ("descend-only")) + && to_boolean (get_music ()->get_property ("descend-only")) && !is_child_context (get_outlet (), a)) a = 0; - + if (a) set_context (a); diff --git a/lily/context.cc b/lily/context.cc index 96597c7e48..7d7eddfc19 100644 --- a/lily/context.cc +++ b/lily/context.cc @@ -1,10 +1,9 @@ -/* +/* context.cc -- implement Context source file of the GNU LilyPond music typesetter (c) 2004--2005 Han-Wen Nienhuys - */ #include "context.hh" @@ -22,8 +21,8 @@ bool Context::is_removable () const { - return context_list_ == SCM_EOL && ! iterator_count_ && - !dynamic_cast (this); + return context_list_ == SCM_EOL && ! iterator_count_ + && !dynamic_cast < Score_context const *> (this); } void @@ -42,7 +41,7 @@ Context::check_removal () } } -Context::Context (Context const&) +Context::Context (Context const &) { assert (false); } @@ -59,7 +58,7 @@ Context::add_context (Context *t) SCM ts = t->self_scm (); context_list_ = ly_append2 (context_list_, scm_cons (ts, SCM_EOL)); - + t->daddy_context_ = this; if (!t->init_) { @@ -78,25 +77,25 @@ Context::add_context (Context *t) } } -Object_key const* +Object_key const * Context::get_key () const { return key_; } -Context::Context (Object_key const* key) +Context::Context (Object_key const *key) { key_ = key; daddy_context_ = 0; init_ = false; aliases_ = SCM_EOL; - iterator_count_ = 0; + iterator_count_ = 0; implementation_ = SCM_EOL; properties_scm_ = SCM_EOL; accepts_list_ = SCM_EOL; context_list_ = SCM_EOL; definition_ = SCM_EOL; - + smobify_self (); properties_scm_ = (new Scheme_hash_table)->self_scm (); scm_gc_unprotect_object (properties_scm_); @@ -105,26 +104,26 @@ Context::Context (Object_key const* key) /* TODO: this shares code with find_create_context(). - */ -Context* +*/ +Context * Context::create_unique_context (SCM n, SCM operations) { /* Don't create multiple score contexts. - */ - if (dynamic_cast (this) - && dynamic_cast (this)->get_score_context ()) + */ + if (dynamic_cast (this) + && dynamic_cast (this)->get_score_context ()) return get_score_context ()->create_unique_context (n, operations); /* TODO: use accepts_list_. - */ + */ Link_array path = unsmob_context_def (definition_)->path_to_acceptable_context (n, get_output_def ()); if (path.size ()) { - Context * current = this; + Context *current = this; // start at 1. The first one (index 0) will be us. for (int i = 0; i < path.size (); i++) @@ -133,7 +132,7 @@ Context::create_unique_context (SCM n, SCM operations) current = current->create_context (path[i], "\\new", - ops); + ops); } return current; @@ -142,9 +141,9 @@ Context::create_unique_context (SCM n, SCM operations) /* Don't go up to Global_context, because global goes down to Score_context - */ + */ Context *ret = 0; - if (daddy_context_ && !dynamic_cast (daddy_context_)) + if (daddy_context_ && !dynamic_cast (daddy_context_)) ret = daddy_context_->create_unique_context (n, operations); else { @@ -155,15 +154,14 @@ Context::create_unique_context (SCM n, SCM operations) return ret; } - Context * Context::find_create_context (SCM n, String id, SCM operations) { /* Don't create multiple score contexts. - */ - if (dynamic_cast (this) - && dynamic_cast (this)->get_score_context ()) + */ + if (dynamic_cast (this) + && dynamic_cast (this)->get_score_context ()) return get_score_context ()->find_create_context (n, id, operations); if (Context *existing = find_context_below (this, n, id)) @@ -171,19 +169,19 @@ Context::find_create_context (SCM n, String id, SCM operations) if (n == ly_symbol2scm ("Bottom")) { - Context* tg = get_default_interpreter (); + Context *tg = get_default_interpreter (); return tg; } /* TODO: use accepts_list_. - */ + */ Link_array path = unsmob_context_def (definition_)->path_to_acceptable_context (n, get_output_def ()); if (path.size ()) { - Context * current = this; + Context *current = this; // start at 1. The first one (index 0) will be us. for (int i = 0; i < path.size (); i++) @@ -196,10 +194,9 @@ Context::find_create_context (SCM n, String id, SCM operations) this_id = id; } - current = current->create_context (path[i], this_id, - ops); + ops); } return current; @@ -208,9 +205,9 @@ Context::find_create_context (SCM n, String id, SCM operations) /* Don't go up to Global_context, because global goes down to Score_context - */ + */ Context *ret = 0; - if (daddy_context_ && !dynamic_cast (daddy_context_)) + if (daddy_context_ && !dynamic_cast (daddy_context_)) ret = daddy_context_->find_create_context (n, id, operations); else { @@ -221,17 +218,16 @@ Context::find_create_context (SCM n, String id, SCM operations) return ret; } - -Context* -Context::create_context (Context_def * cdef, +Context * +Context::create_context (Context_def *cdef, String id, SCM ops) { - String type = ly_symbol2string (cdef->get_context_name()); + String type = ly_symbol2string (cdef->get_context_name ()); Object_key const *key = get_context_key (type, id); - Context * new_group + Context *new_group = cdef->instantiate (ops, key); - + new_group->id_string_ = id; add_context (new_group); apply_property_operations (new_group, ops); @@ -239,9 +235,7 @@ Context::create_context (Context_def * cdef, return new_group; } - - -Object_key const* +Object_key const * Context::get_context_key (String type, String id) { String now_key = type + "@" + id; @@ -253,16 +247,15 @@ Context::get_context_key (String type, String id) } context_counts_[now_key] = disambiguation_count + 1; - - + return new Lilypond_context_key (get_key (), - now_mom(), + now_mom (), type, id, disambiguation_count); } -Object_key const* -Context::get_grob_key (String name) +Object_key const * +Context::get_grob_key (String name) { int disambiguation_count = 0; if (grob_counts_.find (name) != grob_counts_.end ()) @@ -271,16 +264,14 @@ Context::get_grob_key (String name) } grob_counts_[name] = disambiguation_count + 1; - Object_key * k = new Lilypond_grob_key (get_key(), - now_mom(), - name, - disambiguation_count); + Object_key *k = new Lilypond_grob_key (get_key (), + now_mom (), + name, + disambiguation_count); - return k; + return k; } - - /* Default child context as a SCM string, or something else if there is none. @@ -293,14 +284,13 @@ Context::default_child_context_name () const : SCM_EOL; } - bool Context::is_bottom_context () const { return !scm_is_symbol (default_child_context_name ()); } -Context* +Context * Context::get_default_interpreter () { if (!is_bottom_context ()) @@ -327,13 +317,13 @@ Context::get_default_interpreter () /* PROPERTIES - */ -Context* +*/ +Context * Context::where_defined (SCM sym) const { if (properties_dict ()->contains (sym)) { - return (Context*)this; + return (Context *)this; } return (daddy_context_) ? daddy_context_->where_defined (sym) : 0; @@ -351,7 +341,7 @@ Context::internal_get_property (SCM sym) const if (daddy_context_) return daddy_context_->internal_get_property (sym); - + return val; } @@ -363,7 +353,7 @@ Context::is_alias (SCM sym) const return true; if (sym == unsmob_context_def (definition_)->get_context_name ()) return true; - + return scm_c_memq (sym, aliases_) != SCM_BOOL_F; } @@ -373,8 +363,6 @@ Context::add_alias (SCM sym) aliases_ = scm_cons (sym, aliases_); } - - void Context::internal_set_property (SCM sym, SCM val) { @@ -382,13 +370,13 @@ Context::internal_set_property (SCM sym, SCM val) if (do_internal_type_checking_global) assert (type_check_assignment (sym, val, ly_symbol2scm ("translation-type?"))); #endif - + properties_dict ()->set (sym, val); } /* - TODO: look up to check whether we have inherited var? - */ + TODO: look up to check whether we have inherited var? +*/ void Context::unset_property (SCM sym) { @@ -397,9 +385,9 @@ Context::unset_property (SCM sym) /** Remove a context from the hierarchy. - */ +*/ Context * -Context::remove_context (Context*trans) +Context::remove_context (Context *trans) { assert (trans); @@ -410,9 +398,9 @@ Context::remove_context (Context*trans) /* ID == "" means accept any ID. - */ +*/ Context * -find_context_below (Context * where, +find_context_below (Context *where, SCM type, String id) { if (where->is_alias (type)) @@ -420,7 +408,7 @@ find_context_below (Context * where, if (id == "" || where->id_string () == id) return where; } - + Context *found = 0; for (SCM s = where->children_contexts (); !found && scm_is_pair (s); s = scm_cdr (s)) @@ -430,7 +418,7 @@ find_context_below (Context * where, found = find_context_below (tr, type, id); } - return found; + return found; } SCM @@ -452,10 +440,10 @@ Context::context_name () const return ly_symbol2string (context_name_symbol ()); } -Score_context* +Score_context * Context::get_score_context () const { - if (Score_context *sc = dynamic_cast ((Context*) this)) + if (Score_context *sc = dynamic_cast ((Context *) this)) return sc; else if (daddy_context_) return daddy_context_->get_score_context (); @@ -471,7 +459,7 @@ Context::get_output_def () const Context::~Context () { - + } Moment @@ -484,7 +472,7 @@ int Context::print_smob (SCM s, SCM port, scm_print_state *) { Context *sc = (Context *) SCM_CELL_WORD_1 (s); - + scm_puts ("#<", port); scm_puts (classname (sc), port); if (Context_def *d = unsmob_context_def (sc->definition_)) @@ -498,25 +486,24 @@ Context::print_smob (SCM s, SCM port, scm_print_state *) scm_puts ("=", port); scm_puts (td->id_string_.to_str0 (), port); } - scm_puts (" ", port); scm_display (sc->context_list_, port); scm_puts (" >", port); - + return 1; } SCM Context::mark_smob (SCM sm) { - Context *me = (Context*) SCM_CELL_WORD_1 (sm); - scm_gc_mark (me->key_->self_scm ()); + Context *me = (Context *) SCM_CELL_WORD_1 (sm); + scm_gc_mark (me->key_->self_scm ()); scm_gc_mark (me->context_list_); scm_gc_mark (me->aliases_); - scm_gc_mark (me->definition_); - scm_gc_mark (me->properties_scm_); + scm_gc_mark (me->definition_); + scm_gc_mark (me->properties_scm_); scm_gc_mark (me->accepts_list_); scm_gc_mark (me->implementation_); @@ -528,12 +515,12 @@ IMPLEMENT_DEFAULT_EQUAL_P (Context); IMPLEMENT_TYPE_P (Context, "ly:context?"); bool -Context::try_music (Music* m) +Context::try_music (Music *m) { - Translator* t = implementation (); + Translator *t = implementation (); if (!t) return false; - + bool b = t->try_music (m); if (!b && daddy_context_) b = daddy_context_->try_music (m); @@ -541,12 +528,11 @@ Context::try_music (Music* m) return b; } - -Global_context* +Global_context * Context::get_global_context () const { - if (dynamic_cast((Context*) this)) - return dynamic_cast ((Context*) this); + if (dynamic_cast ((Context *) this)) + return dynamic_cast ((Context *) this); if (daddy_context_) return daddy_context_->get_global_context (); @@ -555,25 +541,25 @@ Context::get_global_context () const return 0; } -Context* +Context * Context::get_parent_context () const { return daddy_context_; } -Translator_group* +Translator_group * Context::implementation () const { - return dynamic_cast (unsmob_translator (implementation_)); + return dynamic_cast (unsmob_translator (implementation_)); } void Context::clear_key_disambiguations () { - grob_counts_.clear(); - context_counts_.clear(); + grob_counts_.clear (); + context_counts_.clear (); for (SCM s = context_list_; scm_is_pair (s); s = scm_cdr (s)) { - unsmob_context (scm_car (s))->clear_key_disambiguations(); + unsmob_context (scm_car (s))->clear_key_disambiguations (); } } diff --git a/lily/custos-engraver.cc b/lily/custos-engraver.cc index 78342bbfed..70b5bb9265 100644 --- a/lily/custos-engraver.cc +++ b/lily/custos-engraver.cc @@ -4,7 +4,7 @@ source file of the GNU LilyPond music typesetter (c) 2000--2005 Juergen Reuter , - Han-Wen Nienhuys + Han-Wen Nienhuys */ #include "engraver.hh" @@ -30,9 +30,8 @@ public: virtual void stop_translation_timestep (); virtual void finalize (); - private: - Item * create_custos (); + Item *create_custos (); bool custos_permitted; Link_array custodes_; Array pitches_; @@ -43,13 +42,12 @@ Custos_engraver::Custos_engraver () custos_permitted = false; } - void Custos_engraver::stop_translation_timestep () { /* delay typeset until we're at the next moment, so we can silence custodes at the end of the piece. - */ + */ pitches_.clear (); custos_permitted = false; @@ -61,14 +59,13 @@ Custos_engraver::start_translation_timestep () custodes_.clear (); } - void Custos_engraver::acknowledge_grob (Grob_info info) { - Item *item = dynamic_cast (info.grob_); + Item *item = dynamic_cast (info.grob_); if (item) { - Music * m = info.music_cause (); + Music *m = info.music_cause (); if (Bar_line::has_interface (info.grob_)) custos_permitted = true; else if (Note_head::has_interface (info.grob_) @@ -84,7 +81,7 @@ Custos_engraver::acknowledge_grob (Grob_info info) don't look at the staff-position, since we can't be sure whether Clef_engraver already applied a vertical shift. */ - pitches_.push (*unsmob_pitch (m->get_property ("pitch"))); + pitches_.push (*unsmob_pitch (m->get_property ("pitch"))); } } } @@ -94,7 +91,7 @@ Custos_engraver::process_acknowledged_grobs () { if (scm_is_string (get_property ("whichBar"))) custos_permitted = true; - + if (custos_permitted) { for (int i = pitches_.size (); i--;) @@ -106,24 +103,22 @@ Custos_engraver::process_acknowledged_grobs () if (scm_is_number (c0)) p += scm_to_int (c0); - c->set_property ("staff-position", - scm_int2num (p)); - + scm_int2num (p)); + } pitches_.clear (); } } -Item* +Item * Custos_engraver::create_custos () { - Item* custos = make_item ("Custos", SCM_EOL); - - + Item *custos = make_item ("Custos", SCM_EOL); + custodes_.push (custos); - + return custos; } @@ -137,12 +132,10 @@ Custos_engraver::finalize () custodes_.clear (); } - - ADD_TRANSLATOR (Custos_engraver, -/* descr */ "", -/* creats*/ "Custos", -/* accepts */ "", -/* acks */ "bar-line-interface note-head-interface", -/* reads */ "", -/* write */ ""); + /* descr */ "", + /* creats*/ "Custos", + /* accepts */ "", + /* acks */ "bar-line-interface note-head-interface", + /* reads */ "", + /* write */ ""); diff --git a/lily/custos.cc b/lily/custos.cc index d45974f9e2..55bad6226b 100644 --- a/lily/custos.cc +++ b/lily/custos.cc @@ -8,10 +8,9 @@ /* TODO: - - do not show if a clef change immediately follows in the next line - - - decide: do or do not print custos if the next line starts with a rest +- do not show if a clef change immediately follows in the next line +- decide: do or do not print custos if the next line starts with a rest */ #include @@ -47,14 +46,14 @@ Custos::print (SCM smob) * staffline or not, or shall we use individual font characters * for both cases? */ - bool adjust = true; + bool adjust = true; int neutral_pos = robust_scm2int (me->get_property ("neutral-position"), 0); - Direction neutral_direction = - to_dir (me->get_property ("neutral-direction")); + Direction neutral_direction + = to_dir (me->get_property ("neutral-direction")); int pos = Staff_symbol_referencer::get_rounded_position (me); - int sz = Staff_symbol_referencer::line_count (me)-1; + int sz = Staff_symbol_referencer::line_count (me) - 1; String font_char = "custodes." + style + "."; if (pos < neutral_pos) @@ -89,5 +88,5 @@ Custos::print (SCM smob) } ADD_INTERFACE (Custos, "custos-interface", - "A custos object.", - "style neutral-position neutral-direction"); + "A custos object.", + "style neutral-position neutral-direction"); diff --git a/lily/dimension-cache.cc b/lily/dimension-cache.cc index eeb363c34d..1102d91893 100644 --- a/lily/dimension-cache.cc +++ b/lily/dimension-cache.cc @@ -1,11 +1,10 @@ -/* +/* dimension-cache.cc -- implement Dimension_cache - + source file of the GNU LilyPond music typesetter - - (c) 1998--2005 Han-Wen Nienhuys - */ + (c) 1998--2005 Han-Wen Nienhuys +*/ #include @@ -21,7 +20,7 @@ Dimension_cache::Dimension_cache (Dimension_cache const &d) offset_ = d.offset_; offset_callbacks_ = d.offset_callbacks_; offsets_left_ = d.offsets_left_; - parent_ = d.parent_; + parent_ = d.parent_; } Dimension_cache::Dimension_cache () @@ -33,18 +32,14 @@ void Dimension_cache::init () { dimension_ = SCM_EOL; - dimension_callback_ = SCM_EOL; + dimension_callback_ = SCM_EOL; offsets_left_ = 0; offset_callbacks_ = SCM_EOL; offset_ = 0.0; - + parent_ = 0; } - - - - diff --git a/lily/dimensions.cc b/lily/dimensions.cc index 1979e576f0..451bf5ef3b 100644 --- a/lily/dimensions.cc +++ b/lily/dimensions.cc @@ -4,7 +4,6 @@ source file of the GNU LilyPond music typesetter (c) 1997--2005 Han-Wen Nienhuys - */ #include "lily-guile.hh" @@ -12,51 +11,51 @@ #include "warn.hh" LY_DEFINE (ly_pt, "ly:pt", - 1, 0, 0, (SCM num), - "@var{num} printer points") + 1, 0, 0, (SCM num), + "@var{num} printer points") { - SCM_ASSERT_TYPE(scm_is_number (num), num, SCM_ARG1, __FUNCTION__, - "number"); + SCM_ASSERT_TYPE (scm_is_number (num), num, SCM_ARG1, __FUNCTION__, + "number"); return scm_from_double (point_constant * scm_to_double (num)); } LY_DEFINE (ly_cm, "ly:cm", - 1, 0, 0, (SCM num), - "@var{num} cm") + 1, 0, 0, (SCM num), + "@var{num} cm") { - SCM_ASSERT_TYPE(scm_is_number (num), num, SCM_ARG1, __FUNCTION__, - "number"); + SCM_ASSERT_TYPE (scm_is_number (num), num, SCM_ARG1, __FUNCTION__, + "number"); return scm_from_double (cm_constant * scm_to_double (num)); } LY_DEFINE (ly_inch, "ly:inch", - 1, 0, 0, (SCM num), - "@var{num} inches") + 1, 0, 0, (SCM num), + "@var{num} inches") { - SCM_ASSERT_TYPE(scm_is_number (num), num, SCM_ARG1, __FUNCTION__, - "number"); + SCM_ASSERT_TYPE (scm_is_number (num), num, SCM_ARG1, __FUNCTION__, + "number"); return scm_from_double (inch_constant * scm_to_double (num)); } LY_DEFINE (ly_mm, "ly:mm", - 1, 0, 0, (SCM num), - "@var{num} mm") + 1, 0, 0, (SCM num), + "@var{num} mm") { - SCM_ASSERT_TYPE(scm_is_number (num), num, SCM_ARG1, __FUNCTION__, - "number"); + SCM_ASSERT_TYPE (scm_is_number (num), num, SCM_ARG1, __FUNCTION__, + "number"); return scm_from_double (mm_constant * scm_to_double (num)); } LY_DEFINE (ly_bp, "ly:bp", - 1, 0, 0, (SCM num), - "@var{num} bigpoints (1/72th inch)") + 1, 0, 0, (SCM num), + "@var{num} bigpoints (1/72th inch)") { - SCM_ASSERT_TYPE(scm_is_number (num), num, SCM_ARG1, __FUNCTION__, - "number"); + SCM_ASSERT_TYPE (scm_is_number (num), num, SCM_ARG1, __FUNCTION__, + "number"); return scm_from_double (bigpoint_constant * scm_to_double (num)); } diff --git a/lily/directional-element-interface.cc b/lily/directional-element-interface.cc index bd8a43119c..5ab19596a7 100644 --- a/lily/directional-element-interface.cc +++ b/lily/directional-element-interface.cc @@ -1,26 +1,25 @@ -/* +/* directional-element-interface.cc -- implement Directional_element - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - - */ +*/ #include "directional-element-interface.hh" Direction -get_grob_direction (Grob*me) +get_grob_direction (Grob *me) { SCM d = me->get_property ("direction"); if (!is_direction (d)) return CENTER; - + return to_dir (d); } void -set_grob_direction (Grob*me, Direction d) +set_grob_direction (Grob *me, Direction d) { SCM sd = scm_int2num (d); me->set_property ("direction", sd); diff --git a/lily/dot-column-engraver.cc b/lily/dot-column-engraver.cc index 53f1bdc62e..79f3a27686 100644 --- a/lily/dot-column-engraver.cc +++ b/lily/dot-column-engraver.cc @@ -1,11 +1,10 @@ -/* +/* dot-column-engraver.cc -- implement Dot_column_engraver - + source file of the GNU LilyPond music typesetter - + (c) 1998--2005 Han-Wen Nienhuys - - */ +*/ #include "rhythmic-head.hh" #include "dot-column.hh" @@ -15,18 +14,17 @@ class Dot_column_engraver : public Engraver { - Grob *dotcol_ ; - Grob * stem_; + Grob *dotcol_; + Grob *stem_; Link_array heads_; public: - TRANSLATOR_DECLARATIONS (Dot_column_engraver ); - + TRANSLATOR_DECLARATIONS (Dot_column_engraver); + protected: virtual void acknowledge_grob (Grob_info); - virtual void stop_translation_timestep (); + virtual void stop_translation_timestep (); }; - Dot_column_engraver::Dot_column_engraver () { dotcol_ = 0; @@ -43,7 +41,7 @@ Dot_column_engraver::stop_translation_timestep () */ if (stem_ && dotcol_) dotcol_->set_property ("stem", stem_->self_scm ()); - + dotcol_ = 0; heads_.clear (); stem_ = 0; @@ -58,7 +56,7 @@ Dot_column_engraver::acknowledge_grob (Grob_info info) if (!dotcol_) { dotcol_ = make_item ("DotColumn", SCM_EOL); - + } Dot_column::add_head (dotcol_, info.grob_); @@ -70,13 +68,11 @@ Dot_column_engraver::acknowledge_grob (Grob_info info) } - - ADD_TRANSLATOR (Dot_column_engraver, -/* descr */ "Engraves dots on dotted notes shifted to the right of the note.\n" -"If omitted, then dots appear on top of the notes.", -/* creats*/ "DotColumn", -/* accepts */ "", -/* acks */ "rhythmic-head-interface dot-column-interface stem-interface", -/* reads */ "", -/* write */ ""); + /* descr */ "Engraves dots on dotted notes shifted to the right of the note.\n" + "If omitted, then dots appear on top of the notes.", + /* creats*/ "DotColumn", + /* accepts */ "", + /* acks */ "rhythmic-head-interface dot-column-interface stem-interface", + /* reads */ "", + /* write */ ""); diff --git a/lily/dot-column.cc b/lily/dot-column.cc index 48e325e133..ec981b63bc 100644 --- a/lily/dot-column.cc +++ b/lily/dot-column.cc @@ -22,7 +22,7 @@ /* TODO: let Dot_column communicate with stem via Note_column. - */ +*/ MAKE_SCHEME_CALLBACK (Dot_column, force_shift_callback, 2); SCM @@ -36,7 +36,7 @@ Dot_column::force_shift_callback (SCM element_smob, SCM axis) if (!to_boolean (me->get_property ("positioning-done"))) { me->set_property ("positioning-done", SCM_BOOL_T); - + do_shifts (me); } return scm_make_real (0.0); @@ -50,25 +50,22 @@ Dot_column::side_position (SCM element_smob, SCM axis) Axis a = (Axis) scm_to_int (axis); assert (a == X_AXIS); - Grob * stem = unsmob_grob (me->get_property ("stem")); + Grob *stem = unsmob_grob (me->get_property ("stem")); if (stem && !Stem::get_beam (stem) && Stem::duration_log (stem) > 2 - && !Stem::is_invisible (stem) - ) + && !Stem::is_invisible (stem)) { /* trigger stem end & direction calculation. This will add the stem to the support if a flag collision happens. - */ - Stem::stem_end_position (stem); + */ + Stem::stem_end_position (stem); } return Side_position_interface::aligned_side (element_smob, axis); } - - struct Dot_position { int pos_; @@ -76,7 +73,6 @@ struct Dot_position Grob *dot_; bool extremal_head_; - Dot_position () { dot_ = 0; @@ -85,15 +81,13 @@ struct Dot_position } }; - -typedef std::map Dot_configuration; +typedef std::map < int, Dot_position> Dot_configuration; /* Value CFG according. - */ int -dot_config_badness (Dot_configuration const &cfg) +dot_config_badness (Dot_configuration const &cfg) { int t = 0; for (Dot_configuration::const_iterator i (cfg.begin ()); @@ -106,18 +100,18 @@ dot_config_badness (Dot_configuration const &cfg) if (i->second.extremal_head_) { if (i->second.dir_ - && dot_move_dir != i->second.dir_) + && dot_move_dir != i->second.dir_) demerit += 3; else if (dot_move_dir != UP) demerit += 2; } else if (dot_move_dir != UP) demerit += 1; - + t += demerit; } - return t; + return t; } void @@ -126,7 +120,7 @@ print_dot_configuration (Dot_configuration const &cfg) printf ("dotconf { "); for (Dot_configuration::const_iterator i (cfg.begin ()); i != cfg.end (); i++) - printf ("%d, " , i->first); + printf ("%d, ", i->first); printf ("} \n"); } @@ -134,7 +128,7 @@ print_dot_configuration (Dot_configuration const &cfg) Shift K and following (preceding) entries up (down) as necessary to prevent staffline collisions if D is up (down). - If K is in CFG, then do nothing. + If K is in CFG, then do nothing. */ Dot_configuration @@ -143,7 +137,7 @@ shift_one (Dot_configuration const &cfg, { Dot_configuration new_cfg; int offset = 0; - + if (d > 0) { for (Dot_configuration::const_iterator i (cfg.begin ()); @@ -153,13 +147,13 @@ shift_one (Dot_configuration const &cfg, if (p == k) { if (Staff_symbol_referencer::on_staffline (i->second.dot_, p)) - p += d ; + p += d; else p += 2* d; offset = 2*d; - new_cfg[p] = i->second; + new_cfg[p] = i->second; } else { @@ -176,19 +170,19 @@ shift_one (Dot_configuration const &cfg, Dot_configuration::const_iterator i (cfg.end ()); do { - i --; + i--; int p = i->first; if (p == k) { if (Staff_symbol_referencer::on_staffline (i->second.dot_, p)) - p += d ; + p += d; else p += 2* d; offset = 2*d; - new_cfg[p] = i->second; + new_cfg[p] = i->second; } else { @@ -202,14 +196,14 @@ shift_one (Dot_configuration const &cfg, } while (i != cfg.begin ()); } - + return new_cfg; } /* Remove the collision in CFG either by shifting up or down, whichever is best. - */ +*/ void remove_collision (Dot_configuration &cfg, int p) { @@ -219,64 +213,64 @@ remove_collision (Dot_configuration &cfg, int p) { Dot_configuration cfg_up = shift_one (cfg, p, UP); Dot_configuration cfg_down = shift_one (cfg, p, DOWN); - - int b_up = dot_config_badness (cfg_up); + + int b_up = dot_config_badness (cfg_up); int b_down = dot_config_badness (cfg_down); - cfg = (b_up < b_down) ? cfg_up : cfg_down; + cfg = (b_up < b_down) ? cfg_up : cfg_down; } } SCM -Dot_column::do_shifts (Grob*me) +Dot_column::do_shifts (Grob *me) { - Link_array dots = - extract_grob_array (me, ly_symbol2scm ("dots")); + Link_array dots + = extract_grob_array (me, ly_symbol2scm ("dots")); { /* Trigger note collision resolution first, since that may kill off dots when merging. - */ - Grob * c = 0; - for (int i = dots.size (); i-- ; ) + */ + Grob *c = 0; + for (int i = dots.size (); i--;) { - Grob * n = dots[i]->get_parent (Y_AXIS); + Grob *n = dots[i]->get_parent (Y_AXIS); if (c) c = n->common_refpoint (c, X_AXIS); else c = n; } - for (int i = dots.size (); i-- ; ) + for (int i = dots.size (); i--;) { - Grob * n = dots[i]->get_parent (Y_AXIS); - n->relative_coordinate (c , X_AXIS); + Grob *n = dots[i]->get_parent (Y_AXIS); + n->relative_coordinate (c, X_AXIS); } } - + dots.sort (compare_position); for (int i = dots.size (); i--;) if (!dots[i]->is_live ()) dots.del (i); - + Dot_configuration cfg; for (int i = 0;i < dots.size (); i++) { Dot_position dp; dp.dot_ = dots[i]; - Grob * note = dots[i]->get_parent (Y_AXIS); + Grob *note = dots[i]->get_parent (Y_AXIS); if (note) { Grob *stem = unsmob_grob (note->get_property ("stem")); if (stem) dp.extremal_head_ = Stem::first_head (stem) == note; } - + int p = Staff_symbol_referencer::get_rounded_position (dp.dot_); dp.pos_ = p; if (dp.extremal_head_) - dp.dir_ = to_dir (dp.dot_->get_property ("direction")); + dp.dir_ = to_dir (dp.dot_->get_property ("direction")); remove_collision (cfg, p); cfg[p] = dp; @@ -287,32 +281,29 @@ Dot_column::do_shifts (Grob*me) for (Dot_configuration::const_iterator i (cfg.begin ()); i != cfg.end (); i++) { - Staff_symbol_referencer::set_position (i->second.dot_, i->first); + Staff_symbol_referencer::set_position (i->second.dot_, i->first); } return SCM_UNSPECIFIED; } void -Dot_column::add_head (Grob * me, Grob *rh) +Dot_column::add_head (Grob *me, Grob *rh) { - Grob * d = unsmob_grob (rh->get_property ("dot")); + Grob *d = unsmob_grob (rh->get_property ("dot")); if (d) { Side_position_interface::add_support (me, rh); Pointer_group_interface::add_grob (me, ly_symbol2scm ("dots"), d); - d->add_offset_callback (Dot_column::force_shift_callback_proc , Y_AXIS); + d->add_offset_callback (Dot_column::force_shift_callback_proc, Y_AXIS); Axis_group_interface::add_element (me, d); } } - - ADD_INTERFACE (Dot_column, "dot-column-interface", "Groups dot objects so they form a column, and position dots so they do not " - "clash with staff lines " - , + "clash with staff lines ", "positioning-done direction stem"); diff --git a/lily/dots.cc b/lily/dots.cc index cb5bfdd487..44eb51802f 100644 --- a/lily/dots.cc +++ b/lily/dots.cc @@ -16,19 +16,18 @@ #include "directional-element-interface.hh" MAKE_SCHEME_CALLBACK (Dots, print, 1); -SCM +SCM Dots::print (SCM d) { Grob *sc = unsmob_grob (d); Stencil mol; - + SCM c = sc->get_property ("dot-count"); if (scm_is_number (c)) { Stencil d = Font_interface::get_default_font (sc)->find_by_name (String ("dots.dot")); Real dw = d.extent (X_AXIS).length (); - /* we need to add a real blank box, to assure that @@ -36,10 +35,10 @@ Dots::print (SCM d) /* TODO: this should be handled by side-position padding. - */ + */ mol = Lookup::blank (Box (Interval (0, 0), Interval (0, 0))); - + for (int i = scm_to_int (c); i--;) { d.translate_axis (2*dw, X_AXIS); @@ -50,12 +49,9 @@ Dots::print (SCM d) } - - ADD_INTERFACE (Dots, "dots-interface", "The dots to go with a notehead or rest." "@code{direction} sets the preferred direction to move in case of staff " "line collisions.", "direction dot-count"); - diff --git a/lily/drum-note-engraver.cc b/lily/drum-note-engraver.cc index a526088c3a..d58a889d9d 100644 --- a/lily/drum-note-engraver.cc +++ b/lily/drum-note-engraver.cc @@ -1,6 +1,6 @@ /* drum-note-engraver.cc - + (c) 1997--2005 Han-Wen Nienhuys */ @@ -25,9 +25,9 @@ public: TRANSLATOR_DECLARATIONS (Drum_notes_engraver); protected: - virtual bool try_music (Music *ev) ; + virtual bool try_music (Music *ev); virtual void process_music (); - virtual void acknowledge_grob (Grob_info); + virtual void acknowledge_grob (Grob_info); virtual void stop_translation_timestep (); }; @@ -36,7 +36,7 @@ Drum_notes_engraver::Drum_notes_engraver () } bool -Drum_notes_engraver::try_music (Music *m) +Drum_notes_engraver::try_music (Music *m) { if (m->is_mus_type ("note-event")) { @@ -45,11 +45,10 @@ Drum_notes_engraver::try_music (Music *m) } else if (m->is_mus_type ("busy-playing-event")) return events_.size (); - + return false; } - void Drum_notes_engraver::process_music () { @@ -58,41 +57,41 @@ Drum_notes_engraver::process_music () { if (!tab) tab = get_property ("drumStyleTable"); - - Music * ev = events_[i]; + + Music *ev = events_[i]; Item *note = make_item ("NoteHead", ev->self_scm ()); - + Duration dur = *unsmob_duration (ev->get_property ("duration")); note->set_property ("duration-log", scm_int2num (dur.duration_log ())); if (dur.dot_count ()) { - Item * d = make_item ("Dots", ev->self_scm ()); + Item *d = make_item ("Dots", ev->self_scm ()); Rhythmic_head::set_dots (note, d); - + if (dur.dot_count () != robust_scm2int (d->get_property ("dot-count"), 0)) d->set_property ("dot-count", scm_int2num (dur.dot_count ())); d->set_parent (note, Y_AXIS); - + dots_.push (d); } - SCM drum_type = ev->get_property ("drum-type"); + SCM drum_type = ev->get_property ("drum-type"); SCM defn = SCM_EOL; if (scm_hash_table_p (tab) == SCM_BOOL_T) defn = scm_hashq_ref (tab, drum_type, SCM_EOL); - + if (scm_is_pair (defn)) { SCM pos = scm_caddr (defn); SCM style = scm_car (defn); SCM script = scm_cadr (defn); - + if (scm_integer_p (pos) == SCM_BOOL_T) note->set_property ("staff-position", pos); if (scm_is_symbol (style)) @@ -100,7 +99,7 @@ Drum_notes_engraver::process_music () if (scm_is_string (script)) { - Item *p = make_item ("Script", ev->self_scm ()); + Item *p = make_item ("Script", ev->self_scm ()); bool follow; make_script_from_event (p, &follow, context (), script, @@ -108,10 +107,9 @@ Drum_notes_engraver::process_music () if (p->get_property ("follow-into-staff")) p->set_property ("staff-padding", SCM_EOL); - p->set_parent (note, Y_AXIS); - Side_position_interface::add_support (p, note); + Side_position_interface::add_support (p, note); scripts_.push (p); } } @@ -127,26 +125,26 @@ Drum_notes_engraver::acknowledge_grob (Grob_info inf) { for (int i = 0; i < scripts_.size (); i++) { - Grob*e = scripts_[i]; + Grob *e = scripts_[i]; if (to_dir (e->get_property ("side-relative-direction"))) e->set_property ("direction-source", inf.grob_->self_scm ()); /* - add dep ? - */ + add dep ? + */ e->add_dependency (inf.grob_); Side_position_interface::add_support (e, inf.grob_); } } - else if (Note_column::has_interface (inf.grob_)) + else if (Note_column::has_interface (inf.grob_)) { for (int i = 0; i < scripts_.size (); i++) { Grob *e = scripts_[i]; - - if (!e->get_parent (X_AXIS) && - Side_position_interface::get_axis (e) == Y_AXIS) + + if (!e->get_parent (X_AXIS) + && Side_position_interface::get_axis (e) == Y_AXIS) { e->set_parent (inf.grob_, X_AXIS); } @@ -155,24 +153,21 @@ Drum_notes_engraver::acknowledge_grob (Grob_info inf) } - void Drum_notes_engraver::stop_translation_timestep () { notes_.clear (); dots_.clear (); scripts_.clear (); - + events_.clear (); } - - ADD_TRANSLATOR (Drum_notes_engraver, -/* descr */ "Generate noteheads.", -/* creats*/ "NoteHead Dots Script", -/* accepts */ "note-event busy-playing-event", -/* acks */ "stem-interface note-column-interface", -/* reads */ "drumStyleTable", -/* write */ ""); + /* descr */ "Generate noteheads.", + /* creats*/ "NoteHead Dots Script", + /* accepts */ "note-event busy-playing-event", + /* acks */ "stem-interface note-column-interface", + /* reads */ "drumStyleTable", + /* write */ ""); diff --git a/lily/drum-note-performer.cc b/lily/drum-note-performer.cc index e2f8c697ed..aa867c44e7 100644 --- a/lily/drum-note-performer.cc +++ b/lily/drum-note-performer.cc @@ -4,7 +4,7 @@ source file of the GNU LilyPond music typesetter (c) 1996--2005 Jan Nieuwenhuizen - */ +*/ #include "performer.hh" #include "audio-item.hh" @@ -12,12 +12,13 @@ #include "global-context.hh" #include "warn.hh" -class Drum_note_performer : public Performer { +class Drum_note_performer : public Performer +{ public: TRANSLATOR_DECLARATIONS (Drum_note_performer); - + protected: - virtual bool try_music (Music *ev) ; + virtual bool try_music (Music *ev); virtual void stop_translation_timestep (); virtual void create_audio_elements (); @@ -26,31 +27,31 @@ private: Link_array notes_; }; -void +void Drum_note_performer::create_audio_elements () { SCM tab = 0; if (!tab) tab = get_property ("drumPitchTable"); - + while (note_evs_.size ()) { - Music* n = note_evs_.pop (); + Music *n = note_evs_.pop (); SCM sym = n->get_property ("drum-type"); SCM defn = SCM_EOL; if (scm_is_symbol (sym) - && (scm_hash_table_p (tab) == SCM_BOOL_T)) + && (scm_hash_table_p (tab) == SCM_BOOL_T)) defn = scm_hashq_ref (tab, sym, SCM_EOL); - - if (Pitch * pit = unsmob_pitch (defn)) + + if (Pitch *pit = unsmob_pitch (defn)) { - Audio_note* p = new Audio_note (*pit, n->get_length (), 0); + Audio_note *p = new Audio_note (*pit, n->get_length (), 0); Audio_element_info info (p, n); announce_element (info); notes_.push (p); } } - + note_evs_.clear (); } @@ -67,9 +68,9 @@ Drum_note_performer::stop_translation_timestep () notes_.clear (); note_evs_.clear (); } - + bool -Drum_note_performer::try_music (Music* ev) +Drum_note_performer::try_music (Music *ev) { if (ev->is_mus_type ("note-event")) { @@ -78,13 +79,13 @@ Drum_note_performer::try_music (Music* ev) } else if (ev->is_mus_type ("busy-playing-event")) return note_evs_.size (); - + return false; } ADD_TRANSLATOR (Drum_note_performer, - "Play drum notes.", "", - "note-event busy-playing-event", "", "", ""); + "Play drum notes.", "", + "note-event busy-playing-event", "", "", ""); Drum_note_performer::Drum_note_performer () { diff --git a/lily/duration-scheme.cc b/lily/duration-scheme.cc index 0ecf130acf..1d840a753e 100644 --- a/lily/duration-scheme.cc +++ b/lily/duration-scheme.cc @@ -4,8 +4,7 @@ source file of the LilyPond music typesetter (c) 1997--2005 Jan Nieuwenhuizen - Han-Wen Nienhuys - + Han-Wen Nienhuys */ #include "duration.hh" @@ -26,7 +25,7 @@ Duration::less_p (SCM p1, SCM p2) LY_DEFINE (ly_duration_less_p, "ly:durationduration_log ()); @@ -99,7 +98,7 @@ LY_DEFINE (ly_duration_log, "ly:duration-log", LY_DEFINE (ly_duration_dot_count, "ly:duration-dot-count", 1, 0, 0, (SCM dur), - "Extract the dot count from @var{dur}") + "Extract the dot count from @var{dur}") { SCM_ASSERT_TYPE (unsmob_duration (dur), dur, SCM_ARG1, __FUNCTION__, "duration"); return scm_int2num (unsmob_duration (dur)->dot_count ()); @@ -107,7 +106,7 @@ LY_DEFINE (ly_duration_dot_count, "ly:duration-dot-count", LY_DEFINE (ly_intlog2, "ly:intlog2", 1, 0, 0, (SCM d), - "The 2-logarithm of 1/@var{d}.") + "The 2-logarithm of 1/@var{d}.") { SCM_ASSERT_TYPE (scm_is_number (d), d, SCM_ARG1, __FUNCTION__, "integer"); int log = intlog2 (scm_to_int (d)); @@ -116,7 +115,7 @@ LY_DEFINE (ly_intlog2, "ly:intlog2", LY_DEFINE (ly_duration_factor, "ly:duration-factor", 1, 0, 0, (SCM dur), - "Extract the compression factor from @var{dur}. Return as a pair.") + "Extract the compression factor from @var{dur}. Return as a pair.") { SCM_ASSERT_TYPE (unsmob_duration (dur), dur, SCM_ARG1, __FUNCTION__, "duration"); Rational r = unsmob_duration (dur)->factor (); diff --git a/lily/duration.cc b/lily/duration.cc index 80ba74e84c..08a5bbb78c 100644 --- a/lily/duration.cc +++ b/lily/duration.cc @@ -4,8 +4,7 @@ source file of the LilyPond music typesetter (c) 1997--2005 Jan Nieuwenhuizen - Han-Wen Nienhuys - + Han-Wen Nienhuys */ #include "duration.hh" @@ -66,8 +65,8 @@ Duration::to_string () const { String s; - if (durlog_ < 0 ) - s = "log = " + ::to_string (durlog_); + if (durlog_ < 0) + s = "log = " + ::to_string (durlog_); else s = ::to_string (1 << durlog_); @@ -77,7 +76,6 @@ Duration::to_string () const return s; } - IMPLEMENT_TYPE_P (Duration, "ly:duration?"); SCM @@ -90,7 +88,7 @@ IMPLEMENT_SIMPLE_SMOBS (Duration); int Duration::print_smob (SCM s, SCM port, scm_print_state *) { - Duration *r = (Duration *) SCM_CELL_WORD_1 (s); + Duration *r = (Duration *) SCM_CELL_WORD_1 (s); scm_puts ("#to_string ().to_str0 ()), port); @@ -100,10 +98,10 @@ Duration::print_smob (SCM s, SCM port, scm_print_state *) } SCM -Duration::equal_p (SCM a , SCM b) +Duration::equal_p (SCM a, SCM b) { - Duration *p = (Duration *) SCM_CELL_WORD_1 (a); - Duration *q = (Duration *) SCM_CELL_WORD_1 (b); + Duration *p = (Duration *) SCM_CELL_WORD_1 (a); + Duration *q = (Duration *) SCM_CELL_WORD_1 (b); bool eq = p->dots_ == q->dots_ && p->durlog_ == q->durlog_ @@ -112,7 +110,6 @@ Duration::equal_p (SCM a , SCM b) return eq ? SCM_BOOL_T : SCM_BOOL_F; } - int Duration::duration_log () const { diff --git a/lily/dynamic-engraver.cc b/lily/dynamic-engraver.cc index 45c9c355c5..9396c97f9a 100644 --- a/lily/dynamic-engraver.cc +++ b/lily/dynamic-engraver.cc @@ -31,12 +31,11 @@ - TODO: the line-spanner is not killed after the (de)crescs are finished. - */ /** print text & hairpin dynamics. - */ +*/ class Dynamic_engraver : public Engraver { Item *script_; @@ -48,27 +47,25 @@ class Dynamic_engraver : public Engraver Music *script_ev_; Music *current_cresc_ev_; - - Drul_array accepted_spanreqs_drul_; + + Drul_array accepted_spanreqs_drul_; Link_array pending_columns_; Link_array pending_elements_; - + void typeset_all (); TRANSLATOR_DECLARATIONS (Dynamic_engraver); - + protected: virtual void finalize (); virtual void acknowledge_grob (Grob_info); virtual bool try_music (Music *req); virtual void stop_translation_timestep (); - virtual void process_music (); + virtual void process_music (); }; - - Dynamic_engraver::Dynamic_engraver () { script_ = 0; @@ -114,14 +111,14 @@ Dynamic_engraver::process_music () { if (!line_spanner_) { - Music * rq = accepted_spanreqs_drul_[START]; - line_spanner_ = make_spanner ("DynamicLineSpanner", rq ? rq->self_scm (): SCM_EOL ); + Music *rq = accepted_spanreqs_drul_[START]; + line_spanner_ = make_spanner ("DynamicLineSpanner", rq ? rq->self_scm (): SCM_EOL); if (script_ev_) - rq = script_ev_; + rq = script_ev_; } } - + /* During a (de)crescendo, pending event will not be cleared, and a line-spanner will always be created, as \< \! are already @@ -130,7 +127,6 @@ Dynamic_engraver::process_music () Note: line-spanner must always have at least same duration as (de)crecsendo, b.o. line-breaking. */ - /* maybe we should leave dynamic texts to the text-engraver and @@ -142,7 +138,6 @@ Dynamic_engraver::process_music () script_->set_property ("text", script_ev_->get_property ("text")); - if (Direction d = to_dir (script_ev_->get_property ("direction"))) set_grob_direction (line_spanner_, d); @@ -157,18 +152,16 @@ Dynamic_engraver::process_music () /* finish side position alignment if the (de)cresc ends here, and there are no new dynamics. - */ - + */ if (cresc_) { assert (!finished_cresc_ && cresc_); cresc_->set_bound (RIGHT, script_ - ? script_ - : unsmob_grob (get_property ("currentMusicalColumn"))); + ? script_ + : unsmob_grob (get_property ("currentMusicalColumn"))); add_bound_item (line_spanner_, cresc_->get_bound (RIGHT)); - finished_cresc_ = cresc_; cresc_ = 0; @@ -179,9 +172,9 @@ Dynamic_engraver::process_music () accepted_spanreqs_drul_[STOP]->origin ()->warning (_ ("can't find start of (de)crescendo")); stop_ev = 0; } - + } - + if (accepted_spanreqs_drul_[START]) { if (current_cresc_ev_) @@ -191,7 +184,7 @@ Dynamic_engraver::process_music () msg = _ ("already have a crescendo"); accepted_spanreqs_drul_[START]->origin ()->warning (msg); - current_cresc_ev_->origin ()->warning (_("Cresc started here")); + current_cresc_ev_->origin ()->warning (_ ("Cresc started here")); } else { @@ -204,8 +197,8 @@ Dynamic_engraver::process_music () TODO: Use symbols. */ - String start_type = - ly_symbol2string (current_cresc_ev_->get_property ("name")); + String start_type + = ly_symbol2string (current_cresc_ev_->get_property ("name")); /* ugh. Use push/pop? @@ -214,17 +207,17 @@ Dynamic_engraver::process_music () start_type = "decrescendo"; else if (start_type == "CrescendoEvent") start_type = "crescendo"; - + SCM s = get_property ((start_type + "Spanner").to_str0 ()); if (!scm_is_symbol (s) || s == ly_symbol2scm ("hairpin")) { - cresc_ = make_spanner ("Hairpin", accepted_spanreqs_drul_[START]->self_scm ()); + cresc_ = make_spanner ("Hairpin", accepted_spanreqs_drul_[START]->self_scm ()); if (finished_cresc_) { Pointer_group_interface::add_grob (finished_cresc_, ly_symbol2scm ("adjacent-hairpins"), cresc_); - + Pointer_group_interface::add_grob (cresc_, ly_symbol2scm ("adjacent-hairpins"), finished_cresc_); @@ -232,10 +225,9 @@ Dynamic_engraver::process_music () cresc_->set_property ("grow-direction", scm_int2num ((start_type == "crescendo") ? BIGGER : SMALLER)); - + } - /* This is a convenient (and legacy) interface to TextSpanners for use in (de)crescendi. @@ -243,7 +235,7 @@ Dynamic_engraver::process_music () */ else { - cresc_ = make_spanner ("DynamicTextSpanner", accepted_spanreqs_drul_[START]->self_scm ()); + cresc_ = make_spanner ("DynamicTextSpanner", accepted_spanreqs_drul_[START]->self_scm ()); cresc_->set_property ("style", s); context ()->set_property ((start_type + "Spanner").to_str0 (), SCM_EOL); @@ -265,7 +257,7 @@ Dynamic_engraver::process_music () cresc_->set_bound (LEFT, script_); add_bound_item (line_spanner_, cresc_->get_bound (LEFT)); } - + Axis_group_interface::add_element (line_spanner_, cresc_); } } @@ -287,7 +279,7 @@ Dynamic_engraver::stop_translation_timestep () cresc_->set_bound (LEFT, unsmob_grob (get_property ("currentMusicalColumn"))); add_bound_item (line_spanner_, cresc_->get_bound (LEFT)); } - + script_ev_ = 0; accepted_spanreqs_drul_[START] = 0; accepted_spanreqs_drul_[STOP] = 0; @@ -297,7 +289,7 @@ void Dynamic_engraver::finalize () { typeset_all (); - + if (line_spanner_ && !line_spanner_->is_live ()) line_spanner_ = 0; @@ -328,21 +320,21 @@ Dynamic_engraver::typeset_all () finished_cresc_->set_bound (RIGHT, script_ ? script_ : unsmob_grob (get_property ("currentMusicalColumn"))); - + if (finished_line_spanner_) add_bound_item (finished_line_spanner_, finished_cresc_->get_bound (RIGHT)); } finished_cresc_ = 0; } - + script_ = 0; if (finished_line_spanner_) { /* We used to have - - extend-spanner-over-elements (finished_line_spanner_); + + extend-spanner-over-elements (finished_line_spanner_); but this is rather kludgy, since finished_line_spanner_ typically has a staff-symbol field set , extending it over the @@ -350,8 +342,8 @@ Dynamic_engraver::typeset_all () */ - Grob * l = finished_line_spanner_->get_bound (LEFT); - Grob * r = finished_line_spanner_->get_bound (RIGHT); + Grob *l = finished_line_spanner_->get_bound (LEFT); + Grob *r = finished_line_spanner_->get_bound (RIGHT); if (!r && l) finished_line_spanner_->set_bound (RIGHT, l); else if (!l && r) @@ -361,13 +353,13 @@ Dynamic_engraver::typeset_all () /* This is a isolated dynamic apparently, and does not even have any interesting support item. - */ - Grob * cc = unsmob_grob (get_property ("currentMusicalColumn")); - Item * ci = dynamic_cast(cc); + */ + Grob *cc = unsmob_grob (get_property ("currentMusicalColumn")); + Item *ci = dynamic_cast (cc); finished_line_spanner_->set_bound (RIGHT, ci); - finished_line_spanner_->set_bound (LEFT, ci); + finished_line_spanner_->set_bound (LEFT, ci); } - + finished_line_spanner_ = 0; } } @@ -385,24 +377,22 @@ Dynamic_engraver::acknowledge_grob (Grob_info info) && line_spanner_->is_live ()) { Side_position_interface::add_support (line_spanner_, info.grob_); - add_bound_item (line_spanner_, dynamic_cast (info.grob_)); + add_bound_item (line_spanner_, dynamic_cast (info.grob_)); } if (script_ && !script_->get_parent (X_AXIS)) { SCM head = scm_last_pair (info.grob_->get_property ("note-heads")); if (scm_is_pair (head)) - script_->set_parent (unsmob_grob (scm_car (head)), X_AXIS); + script_->set_parent (unsmob_grob (scm_car (head)), X_AXIS); } - - if (cresc_ && !cresc_->get_bound (LEFT)) { cresc_->set_bound (LEFT, info.grob_); add_bound_item (line_spanner_, cresc_->get_bound (LEFT)); } - + } else if (Script_interface::has_interface (info.grob_) && script_) { @@ -412,7 +402,7 @@ Dynamic_engraver::acknowledge_grob (Grob_info info) UGH. DynamicText doesn't really have a script-priority field. - */ + */ if (scm_is_number (p) && scm_to_int (p) < scm_to_int (script_->get_property ("script-priority"))) @@ -421,14 +411,13 @@ Dynamic_engraver::acknowledge_grob (Grob_info info) } ADD_TRANSLATOR (Dynamic_engraver, -/* descr */ -"This engraver creates hairpins, dynamic texts, and their vertical\n" -"alignments. The symbols are collected onto a DynamicLineSpanner grob\n" -"which takes care of vertical positioning. " -, - -/* creats*/ "DynamicLineSpanner DynamicText Hairpin TextSpanner", -/* accepts */ "absolute-dynamic-event crescendo-event decrescendo-event", -/* acks */ "note-column-interface script-interface", -/* reads */ "", -/* write */ ""); + /* descr */ + "This engraver creates hairpins, dynamic texts, and their vertical\n" + "alignments. The symbols are collected onto a DynamicLineSpanner grob\n" + "which takes care of vertical positioning. ", + + /* creats*/ "DynamicLineSpanner DynamicText Hairpin TextSpanner", + /* accepts */ "absolute-dynamic-event crescendo-event decrescendo-event", + /* acks */ "note-column-interface script-interface", + /* reads */ "", + /* write */ ""); diff --git a/lily/dynamic-performer.cc b/lily/dynamic-performer.cc index 93f3144b04..71ce23fb74 100644 --- a/lily/dynamic-performer.cc +++ b/lily/dynamic-performer.cc @@ -11,23 +11,23 @@ /* TODO: - - handle multiple events - perform absolute (text) dynamics - */ + handle multiple events + + perform absolute (text) dynamics +*/ class Dynamic_performer : public Performer { public: TRANSLATOR_DECLARATIONS (Dynamic_performer); protected: - virtual bool try_music (Music* req); + virtual bool try_music (Music *req); virtual void stop_translation_timestep (); virtual void create_audio_elements (); private: - Music* script_req_; - Audio_dynamic* audio_; + Music *script_req_; + Audio_dynamic *audio_; }; Dynamic_performer::Dynamic_performer () @@ -43,18 +43,18 @@ Dynamic_performer::create_audio_elements () { SCM proc = get_property ("dynamicAbsoluteVolumeFunction"); - SCM svolume = SCM_EOL; + SCM svolume = SCM_EOL; if (ly_c_procedure_p (proc)) { // urg svolume = scm_call_1 (proc, script_req_->get_property ("text")); } - Real volume = robust_scm2double (svolume, 0.5); + Real volume = robust_scm2double (svolume, 0.5); /* properties override default equaliser setting - */ + */ SCM min = get_property ("midiMinimumVolume"); SCM max = get_property ("midiMaximumVolume"); if (scm_is_number (min) || scm_is_number (max)) @@ -72,14 +72,13 @@ Dynamic_performer::create_audio_elements () urg, code duplication:: staff_performer */ SCM s = get_property ("midiInstrument"); - + if (!scm_is_string (s)) s = get_property ("instrument"); - + if (!scm_is_string (s)) s = scm_makfrom0str ("piano"); - - + SCM eq = get_property ("instrumentEqualizer"); if (ly_c_procedure_p (eq)) { @@ -92,7 +91,7 @@ Dynamic_performer::create_audio_elements () volume = iv[MIN] + iv.length () * volume; } } - + audio_ = new Audio_dynamic (volume); Audio_element_info info (audio_, script_req_); announce_element (info); @@ -111,7 +110,7 @@ Dynamic_performer::stop_translation_timestep () } bool -Dynamic_performer::try_music (Music* r) +Dynamic_performer::try_music (Music *r) { if (!script_req_) { @@ -125,9 +124,9 @@ Dynamic_performer::try_music (Music* r) } ADD_TRANSLATOR (Dynamic_performer, - /*descr*/ "", - /* creats*/ "", - /* accepts */ "absolute-dynamic-event", - /* acks */ "", - /*reads */"dynamicAbsoluteVolumeFunction midiMaximumVolume midiMinimumVolume midiInstrument instrumentEqualizer", - /*writes*/""); + /*descr*/ "", + /* creats*/ "", + /* accepts */ "absolute-dynamic-event", + /* acks */ "", + /*reads */"dynamicAbsoluteVolumeFunction midiMaximumVolume midiMinimumVolume midiInstrument instrumentEqualizer", + /*writes*/""); diff --git a/lily/dynamic-text-spanner.cc b/lily/dynamic-text-spanner.cc index 11de092ab3..8466dbde7d 100644 --- a/lily/dynamic-text-spanner.cc +++ b/lily/dynamic-text-spanner.cc @@ -1,4 +1,3 @@ - /* crescendo-text-spanner.cc -- implement Text_spanner @@ -6,7 +5,7 @@ (c) 2000--2005 Jan Nieuwenhuizen - Revised over good by Han-Wen. + Revised over good by Han-Wen. */ #include "text-item.hh" @@ -20,16 +19,14 @@ #include "paper-column.hh" - class Dynamic_text_spanner { public: DECLARE_SCHEME_CALLBACK (print, (SCM)); - static bool has_interface (Grob*); + static bool has_interface (Grob *); }; - /* This is a partial C&P from text-spanner.cc @@ -38,28 +35,26 @@ public: * does not require bracket functionality. * should make room for spanning points (mf/f/mp texts). - + * In the future, we should support - cresc - - - - poco - - - a - - - - poco - - - + cresc - - - - poco - - - a - - - - poco - - - as well The cut & paste is rather inelegant, but text-spanner was a failed and buggy attempt at being generic. - - */ MAKE_SCHEME_CALLBACK (Dynamic_text_spanner, print, 1); SCM -Dynamic_text_spanner::print (SCM smob) +Dynamic_text_spanner::print (SCM smob) { Grob *me = unsmob_grob (smob); - Spanner *spanner = dynamic_cast (me); + Spanner *spanner = dynamic_cast (me); Grob *common = spanner->get_bound (LEFT)->common_refpoint (spanner->get_bound (RIGHT), X_AXIS); - Output_def * layout = me->get_layout (); + Output_def *layout = me->get_layout (); Interval span_points; Drul_array broken; @@ -86,15 +81,14 @@ Dynamic_text_spanner::print (SCM smob) encl = -d; } - Interval ext = b->extent (common, X_AXIS); - span_points[d] = -d * pad + Interval ext = b->extent (common, X_AXIS); + span_points[d] = -d * pad + robust_relative_extent (b, common, X_AXIS) .linear_combination (encl); } } while (flip (&d) != LEFT); - Stencil m; SCM properties = Font_interface::text_font_alist_chain (me); SCM edge_text = me->get_property ("edge-text"); @@ -106,12 +100,12 @@ Dynamic_text_spanner::print (SCM smob) { if (broken[d]) continue; - + SCM text = index_get_cell (edge_text, d); - if (Text_interface::markup_p (text)) + if (Text_interface::markup_p (text)) edge[d] = *unsmob_stencil (Text_interface::interpret_markup (layout->self_scm (), properties, text)); - + if (!edge[d].is_empty ()) edge[d].align_to (Y_AXIS, CENTER); } @@ -121,22 +115,21 @@ Dynamic_text_spanner::print (SCM smob) do { Interval ext = edge[d].extent (X_AXIS); - Real pad = robust_scm2double (me->get_property ("bound-padding"), 0.0); + Real pad = robust_scm2double (me->get_property ("bound-padding"), 0.0); if (!ext.is_empty ()) { edge[d].translate_axis (span_points[d], X_AXIS); m.add_stencil (edge[d]); - span_points[d] += -d * (ext[-d] + pad); + span_points[d] += -d * (ext[-d] + pad); } } while (flip (&d) != LEFT); - if (!span_points.is_empty ()) { Stencil l = Line_spanner::line_stencil (me, - Offset (span_points[LEFT], 0), - Offset (span_points[RIGHT], 0)); + Offset (span_points[LEFT], 0), + Offset (span_points[RIGHT], 0)); m.add_stencil (l); } m.translate_axis (- me->relative_coordinate (common, X_AXIS), X_AXIS); diff --git a/lily/engraver-group-engraver.cc b/lily/engraver-group-engraver.cc index 1994e42df8..2f204cec18 100644 --- a/lily/engraver-group-engraver.cc +++ b/lily/engraver-group-engraver.cc @@ -1,6 +1,6 @@ /* engraver-group-engraver.cc -- implement Engraver_group_engraver - + source file of the GNU LilyPond music typesetter (c) 1997--2005 Han-Wen Nienhuys @@ -21,7 +21,6 @@ Engraver_group_engraver::announce_grob (Grob_info info) get_daddy_engraver ()->announce_grob (info); } - SCM find_acknowledge_engravers (SCM gravlist, SCM meta); SCM find_accept_engravers (SCM gravlist, SCM music_descr); @@ -29,17 +28,16 @@ void Engraver_group_engraver::acknowledge_grobs () { if (!announce_infos_.size ()) - return ; - + return; + SCM tab = get_property ("acknowledgeHashTable"); SCM name_sym = ly_symbol2scm ("name"); - SCM meta_sym = ly_symbol2scm ("meta"); + SCM meta_sym = ly_symbol2scm ("meta"); - for (int j = 0; j < announce_infos_.size (); j++) { Grob_info info = announce_infos_[j]; - + SCM meta = info.grob_->internal_get_property (meta_sym); SCM nm = scm_assoc (name_sym, meta); if (scm_is_pair (nm)) @@ -54,10 +52,10 @@ Engraver_group_engraver::acknowledge_grobs () We ignore the grob anyway. He who has no name, shall not be helped. */ - + continue; } - + SCM acklist = scm_hashq_ref (tab, nm, SCM_UNDEFINED); if (acklist == SCM_BOOL_F) { @@ -67,19 +65,18 @@ Engraver_group_engraver::acknowledge_grobs () for (SCM p = acklist; scm_is_pair (p); p = scm_cdr (p)) { - Translator * t = unsmob_translator (scm_car (p)); - Engraver * eng = dynamic_cast (t); + Translator *t = unsmob_translator (scm_car (p)); + Engraver *eng = dynamic_cast (t); if (eng && eng != info.origin_trans_) eng->acknowledge_grob (info); } } } - /* Ugh. This is slightly expensive. We could/should cache the value of the group count? - */ +*/ int Engraver_group_engraver::pending_grob_count () const { @@ -88,47 +85,47 @@ Engraver_group_engraver::pending_grob_count () const scm_is_pair (s); s = scm_cdr (s)) { Context *c = unsmob_context (scm_car (s)); - Engraver_group_engraver * group - = dynamic_cast (c->implementation ()); + Engraver_group_engraver *group + = dynamic_cast (c->implementation ()); if (group) - count += group->pending_grob_count (); + count += group->pending_grob_count (); } - return count; + return count; } void Engraver_group_engraver::do_announces () { - do { - for (SCM s = context ()->children_contexts (); - scm_is_pair (s); s = scm_cdr (s)) - { - Context *c = unsmob_context (scm_car (s)); - Engraver_group_engraver * group - = dynamic_cast (c->implementation ()); - if (group) - group->do_announces (); - } - - do - { - engraver_each (get_simple_trans_list (), - &Engraver::process_acknowledged_grobs); - - - if (announce_infos_.size () == 0) - break; - - acknowledge_grobs (); - announce_infos_.clear (); - } - while (1); - - } while (pending_grob_count () > 0); -} + do + { + for (SCM s = context ()->children_contexts (); + scm_is_pair (s); s = scm_cdr (s)) + { + Context *c = unsmob_context (scm_car (s)); + Engraver_group_engraver *group + = dynamic_cast (c->implementation ()); + if (group) + group->do_announces (); + } + do + { + engraver_each (get_simple_trans_list (), + &Engraver::process_acknowledged_grobs); + if (announce_infos_.size () == 0) + break; + + acknowledge_grobs (); + announce_infos_.clear (); + } + while (1); + + } + while (pending_grob_count () > 0); + +} void Engraver_group_engraver::initialize () @@ -142,20 +139,17 @@ Engraver_group_engraver::initialize () Engraver_group_engraver::Engraver_group_engraver () {} ADD_TRANSLATOR (Engraver_group_engraver, -/* descr */ "A group of engravers taken together", -/* creats*/ "", -/* accepts */ "", -/* acks */ "", -/* reads */ "", -/* write */ ""); - - + /* descr */ "A group of engravers taken together", + /* creats*/ "", + /* accepts */ "", + /* acks */ "", + /* reads */ "", + /* write */ ""); /*****************/ - bool -engraver_valid (Translator*tr, SCM ifaces) +engraver_valid (Translator *tr, SCM ifaces) { SCM ack_ifs = scm_assoc (ly_symbol2scm ("interfaces-acked"), tr->translator_description ()); ack_ifs = scm_cdr (ack_ifs); @@ -165,33 +159,29 @@ engraver_valid (Translator*tr, SCM ifaces) return false; } - - SCM find_acknowledge_engravers (SCM gravlist, SCM meta_alist) { SCM ifaces = scm_cdr (scm_assoc (ly_symbol2scm ("interfaces"), meta_alist)); SCM l = SCM_EOL; - for (SCM s = gravlist; scm_is_pair (s); s = scm_cdr (s)) + for (SCM s = gravlist; scm_is_pair (s); s = scm_cdr (s)) { - Translator* tr = unsmob_translator (scm_car (s)); + Translator *tr = unsmob_translator (scm_car (s)); if (engraver_valid (tr, ifaces)) - l = scm_cons (tr->self_scm (), l); + l = scm_cons (tr->self_scm (), l); } l = scm_reverse_x (l, SCM_EOL); return l; } - /* c&p engraver-group.cc */ void -recurse_down_engravers (Context * c, Engraver_method ptr, bool context_first) +recurse_down_engravers (Context *c, Engraver_method ptr, bool context_first) { - Engraver_group_engraver * tg - = dynamic_cast (c->implementation ()); - + Engraver_group_engraver *tg + = dynamic_cast (c->implementation ()); if (!context_first) { @@ -201,7 +191,7 @@ recurse_down_engravers (Context * c, Engraver_method ptr, bool context_first) (tg->*ptr) (); } - for (SCM s = c->children_contexts () ; scm_is_pair (s); + for (SCM s = c->children_contexts (); scm_is_pair (s); s = scm_cdr (s)) { recurse_down_engravers (unsmob_context (scm_car (s)), ptr, context_first); @@ -215,13 +205,12 @@ recurse_down_engravers (Context * c, Engraver_method ptr, bool context_first) } } - void engraver_each (SCM list, Engraver_method method) { for (SCM p = list; scm_is_pair (p); p = scm_cdr (p)) { - Engraver * e = dynamic_cast(unsmob_translator (scm_car (p))); + Engraver *e = dynamic_cast (unsmob_translator (scm_car (p))); if (e) (e->*method) (); } diff --git a/lily/engraver.cc b/lily/engraver.cc index 952afbf110..bfd30de898 100644 --- a/lily/engraver.cc +++ b/lily/engraver.cc @@ -17,10 +17,10 @@ #include "score-context.hh" #include "lilypond-key.hh" -Engraver_group_engraver* +Engraver_group_engraver * Engraver::get_daddy_engraver () const { - return dynamic_cast (get_daddy_translator ()); + return dynamic_cast (get_daddy_translator ()); } void @@ -29,13 +29,12 @@ Engraver::announce_grob (Grob_info inf) get_daddy_engraver ()->announce_grob (inf); } - /* CAUSE is the object (typically a Music object) that was the reason for making E. - */ +*/ void -Engraver::announce_grob (Grob* e, SCM cause) +Engraver::announce_grob (Grob *e, SCM cause) { if (unsmob_music (cause) || unsmob_grob (cause)) e->set_property ("cause", cause); @@ -45,29 +44,24 @@ Engraver::announce_grob (Grob* e, SCM cause) if (!i.origin_trans_) i.origin_trans_ = this; - Engraver * g = get_daddy_engraver (); + Engraver *g = get_daddy_engraver (); if (g) g->announce_grob (i); } - - - Engraver::Engraver () { } - -Score_engraver* +Score_engraver * Engraver::get_score_engraver () const { - return dynamic_cast (get_score_context ()->implementation ()); + return dynamic_cast (get_score_context ()->implementation ()); } - ADD_TRANSLATOR (Engraver, - "", "", - "", - "", "", ""); + "", "", + "", + "", "", ""); diff --git a/lily/event-chord-iterator.cc b/lily/event-chord-iterator.cc index d65ce82507..b48074905c 100644 --- a/lily/event-chord-iterator.cc +++ b/lily/event-chord-iterator.cc @@ -34,20 +34,19 @@ Event_chord_iterator::construct_children () get_req_translator (); } -Event_chord* +Event_chord * Event_chord_iterator::get_elt () const { - return (Event_chord*) get_music (); + return (Event_chord *) get_music (); } - void Event_chord_iterator::process (Moment m) { if (last_processed_mom_ < Moment (0)) { for (SCM s = get_music ()->get_property ("elements"); - scm_is_pair (s); s = scm_cdr (s)) + scm_is_pair (s); s = scm_cdr (s)) { Music *mus = unsmob_music (scm_car (s)); diff --git a/lily/event.cc b/lily/event.cc index bdadc3283c..314ed194d6 100644 --- a/lily/event.cc +++ b/lily/event.cc @@ -9,11 +9,11 @@ #include "event.hh" #include "warn.hh" -MAKE_SCHEME_CALLBACK(Event, length_callback, 1); +MAKE_SCHEME_CALLBACK (Event, length_callback, 1); SCM Event::length_callback (SCM m) { - Music* me = unsmob_music (m); + Music *me = unsmob_music (m); Duration *d = unsmob_duration (me->get_property ("duration")); Moment mom; @@ -21,9 +21,9 @@ Event::length_callback (SCM m) { mom = d->get_length (); } - return mom.smobbed_copy(); + return mom.smobbed_copy (); } - + Event::Event (SCM i) : Music (i) { @@ -35,5 +35,3 @@ Event::Event (SCM i) ADD_MUSIC (Event); - - diff --git a/lily/extender-engraver.cc b/lily/extender-engraver.cc index 6ec00234b7..6058843e87 100644 --- a/lily/extender-engraver.cc +++ b/lily/extender-engraver.cc @@ -2,10 +2,10 @@ extender-engraver.cc -- implement Extender_engraver source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Glen Prideaux , - Han-Wen Nienhuys , - Jan Nieuwenhuizen + Han-Wen Nienhuys , + Jan Nieuwenhuizen */ #include "context.hh" @@ -30,12 +30,11 @@ public: protected: virtual void acknowledge_grob (Grob_info); virtual void finalize (); - virtual bool try_music (Music*); + virtual bool try_music (Music *); virtual void stop_translation_timestep (); virtual void process_music (); }; - Extender_engraver::Extender_engraver () { extender_ = 0; @@ -64,7 +63,7 @@ Extender_engraver::process_music () void Extender_engraver::acknowledge_grob (Grob_info i) { - Item *item = dynamic_cast (i.grob_); + Item *item = dynamic_cast (i.grob_); if (item && item->internal_has_interface (ly_symbol2scm ("lyric-syllable-interface"))) @@ -96,14 +95,14 @@ Extender_engraver::stop_translation_timestep () Pointer_group_interface::add_grob (extender_, ly_symbol2scm ("heads"), h); } - + if (pending_extender_) { Pointer_group_interface::add_grob (pending_extender_, ly_symbol2scm ("heads"), h); } } - + if (extender_) { pending_extender_ = extender_; @@ -122,7 +121,7 @@ completize_extender (Spanner *sp) SCM heads = sp->get_property ("heads"); if (scm_is_pair (heads)) { - Item *it = dynamic_cast (unsmob_grob (scm_car (heads))); + Item *it = dynamic_cast (unsmob_grob (scm_car (heads))); if (it) sp->set_bound (RIGHT, it); } @@ -151,11 +150,10 @@ Extender_engraver::finalize () } } - ADD_TRANSLATOR (Extender_engraver, -/* descr */ "Create lyric extenders", -/* creats*/ "LyricExtender", -/* accepts */ "extender-event", -/* acks */ "lyric-syllable-interface", -/* reads */ "", -/* write */ ""); + /* descr */ "Create lyric extenders", + /* creats*/ "LyricExtender", + /* accepts */ "extender-event", + /* acks */ "lyric-syllable-interface", + /* reads */ "", + /* write */ ""); diff --git a/lily/figured-bass-engraver.cc b/lily/figured-bass-engraver.cc index f2b849f132..8c001bb4db 100644 --- a/lily/figured-bass-engraver.cc +++ b/lily/figured-bass-engraver.cc @@ -1,11 +1,10 @@ -/* -figured-bass-engraver.cc -- implement Figured_bass_engraver +/* + figured-bass-engraver.cc -- implement Figured_bass_engraver -source file of the GNU LilyPond music typesetter + source file of the GNU LilyPond music typesetter -(c) 2002--2005 Han-Wen Nienhuys - - */ + (c) 2002--2005 Han-Wen Nienhuys +*/ #include "engraver.hh" #include "text-item.hh" @@ -17,16 +16,15 @@ class Figured_bass_engraver : public Engraver TRANSLATOR_DECLARATIONS (Figured_bass_engraver); protected: Link_array figures_; - Music * rest_req_; + Music *rest_req_; + + Grob *figure_; - Grob * figure_; - - virtual bool try_music (Music*); + virtual bool try_music (Music *); virtual void stop_translation_timestep (); virtual void process_music (); }; - Figured_bass_engraver::Figured_bass_engraver () { figure_ = 0; @@ -43,7 +41,7 @@ Figured_bass_engraver::stop_translation_timestep () } bool -Figured_bass_engraver::try_music (Music*m) +Figured_bass_engraver::try_music (Music *m) { if (m->is_mus_type ("bass-figure-event")) { @@ -64,15 +62,15 @@ Figured_bass_engraver::process_music () if (rest_req_) { figure_ = make_item ("BassFigure", rest_req_->self_scm ()); - figure_->set_property ("text" , scm_makfrom0str ("-")); + figure_->set_property ("text", scm_makfrom0str ("-")); } else if (figures_.size ()) { SCM proc = get_property ("bassFigureFormatFunction"); - if (ly_c_procedure_p (proc)) + if (ly_c_procedure_p (proc)) { SCM l = SCM_EOL; - SCM * t = &l; + SCM *t = &l; for (int i = 0; i < figures_.size (); i++) { *t = scm_cons (figures_[i]->self_scm (), SCM_EOL); @@ -85,11 +83,10 @@ Figured_bass_engraver::process_music () } } - ADD_TRANSLATOR (Figured_bass_engraver, -/* descr */ "Make figured bass numbers.", -/* creats*/ "BassFigure", -/* accepts */ "rest-event bass-figure-event", -/* acks */ "", -/* reads */ "bassFigureFormatFunction", -/* write */ ""); + /* descr */ "Make figured bass numbers.", + /* creats*/ "BassFigure", + /* accepts */ "rest-event bass-figure-event", + /* acks */ "", + /* reads */ "bassFigureFormatFunction", + /* write */ ""); diff --git a/lily/fingering-engraver.cc b/lily/fingering-engraver.cc index 503138b3e0..bcfb63a711 100644 --- a/lily/fingering-engraver.cc +++ b/lily/fingering-engraver.cc @@ -1,11 +1,10 @@ -/* +/* fingering-engraver.cc -- implement Fingering_engraver - + source file of the GNU LilyPond music typesetter - + (c) 1998--2005 Han-Wen Nienhuys - - */ +*/ #include "engraver.hh" #include "side-position-interface.hh" @@ -21,14 +20,14 @@ class Fingering_engraver : public Engraver public: TRANSLATOR_DECLARATIONS (Fingering_engraver); protected: - virtual bool try_music (Music* m); + virtual bool try_music (Music *m); virtual void stop_translation_timestep (); virtual void start_translation_timestep (); virtual void process_music (); virtual void acknowledge_grob (Grob_info); private: - void make_script (Direction, Music*, int); + void make_script (Direction, Music *, int); }; bool @@ -56,7 +55,7 @@ Fingering_engraver::acknowledge_grob (Grob_info inf) { for (int i = 0; i < fingerings_.size (); i++) { - Grob*t = fingerings_[i]; + Grob *t = fingerings_[i]; Side_position_interface::add_support (t, inf.grob_); if (!t->get_parent (X_AXIS)) t->set_parent (inf.grob_, X_AXIS); @@ -74,7 +73,6 @@ Fingering_engraver::process_music () } } - void Fingering_engraver::make_script (Direction d, Music *r, int i) { @@ -86,14 +84,14 @@ Fingering_engraver::make_script (Direction d, Music *r, int i) Huh, what's this for? --hwn. junkme. - */ + */ SCM pitch = r->get_property ("pitch"); if (unsmob_pitch (pitch)) fingering->set_property ("pitch", pitch); /* We can't fold these definitions into define-grobs since - fingerings for chords need different settings. + fingerings for chords need different settings. */ Side_position_interface::set_axis (fingering, a); fingering->add_offset_callback (Self_alignment_interface::aligned_on_self_proc, other); @@ -104,22 +102,21 @@ Fingering_engraver::make_script (Direction d, Music *r, int i) SCM s = fingering->get_property ("script-priority"); if (scm_is_number (s)) priority = scm_to_int (s); - + /* See script-engraver.cc */ priority += i; fingering->set_property ("script-priority", scm_int2num (priority)); - if (!is_direction (fingering->get_property ("direction"))) { if (d) fingering->set_property ("direction", scm_int2num (d)); else - fingering->set_property ("direction", scm_int2num (RIGHT)); + fingering->set_property ("direction", scm_int2num (RIGHT)); } - SCM dig = r->get_property ("digit"); + SCM dig = r->get_property ("digit"); fingering->set_property ("text", scm_number_to_string (dig, scm_int2num (10))); fingerings_.push (fingering); @@ -130,7 +127,7 @@ Fingering_engraver::stop_translation_timestep () { if (!fingerings_.size ()) return; - + fingerings_.clear (); } @@ -146,9 +143,9 @@ Fingering_engraver::Fingering_engraver () } ADD_TRANSLATOR (Fingering_engraver, -/* descr */ "Create fingering-scripts", -/* creats*/ "Fingering", -/* accepts */ "fingering-event", -/* acks */ "rhythmic-head-interface stem-interface", -/* reads */ "", -/* write */ ""); + /* descr */ "Create fingering-scripts", + /* creats*/ "Fingering", + /* accepts */ "fingering-event", + /* acks */ "rhythmic-head-interface stem-interface", + /* reads */ "", + /* write */ ""); diff --git a/lily/folded-repeat-iterator.cc b/lily/folded-repeat-iterator.cc index fd1aaa6770..3963c5dd4b 100644 --- a/lily/folded-repeat-iterator.cc +++ b/lily/folded-repeat-iterator.cc @@ -1,11 +1,10 @@ -/* - folded-repeat-iterator.cc -- implement Folded_repeat_iterator - +/* + folded-repeat-iterator.cc -- implement Folded_repeat_iterator + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - - */ +*/ #include "folded-repeat-iterator.hh" @@ -46,7 +45,7 @@ Folded_repeat_iterator::pending_moment () const void Folded_repeat_iterator::construct_children () { - Music *mus = get_music (); + Music *mus = get_music (); main_iter_ = unsmob_iterator (get_iterator (Repeated_music::body (mus))); if (!main_iter_->ok ()) { @@ -58,13 +57,13 @@ Folded_repeat_iterator::construct_children () void Folded_repeat_iterator::process (Moment m) { - if (!m.to_bool () ) + if (!m.to_bool ()) { bool success = try_music (get_music ()); if (!success) get_music ()->origin ()->warning (_ ("no one to print a repeat brace")); } - + if (main_iter_) { main_iter_->process (m); @@ -76,7 +75,7 @@ Folded_repeat_iterator::process (Moment m) { enter_alternative (); } - + if (alternative_iter_) { alternative_iter_->process (m - main_length_mom_); @@ -95,22 +94,22 @@ Folded_repeat_iterator::leave_body () main_iter_->quit (); main_iter_ = 0; - main_length_mom_ += Repeated_music::body (mus)->get_length (); + main_length_mom_ += Repeated_music::body (mus)->get_length (); } void Folded_repeat_iterator::enter_alternative () { - Music *mus = get_music (); + Music *mus = get_music (); if (scm_is_pair (Repeated_music::alternatives (mus))) { /* ugh. - */ - Simultaneous_music_iterator * s = new Simultaneous_music_iterator; + */ + Simultaneous_music_iterator *s = new Simultaneous_music_iterator; s->create_separate_contexts_ = true; s->init_translator (mus, get_outlet ()); - + alternative_iter_ = s; alternative_iter_->construct_children (); @@ -118,9 +117,8 @@ Folded_repeat_iterator::enter_alternative () } } - -Music_iterator* -Folded_repeat_iterator::try_music_in_children (Music * m) const +Music_iterator * +Folded_repeat_iterator::try_music_in_children (Music *m) const { if (main_iter_) { @@ -140,7 +138,7 @@ Folded_repeat_iterator::derived_mark () const } void -Folded_repeat_iterator::derived_substitute (Context *f, Context *t) +Folded_repeat_iterator::derived_substitute (Context *f, Context *t) { if (main_iter_) main_iter_->substitute_outlet (f, t); diff --git a/lily/font-config.cc b/lily/font-config.cc index f46beaffd2..ca6253fc99 100644 --- a/lily/font-config.cc +++ b/lily/font-config.cc @@ -4,7 +4,6 @@ source file of the GNU LilyPond music typesetter (c) 2005 Han-Wen Nienhuys - */ #include "config.hh" @@ -30,13 +29,13 @@ init_fontconfig () dirs.push (prefix_directory + "/mf/out/"); dirs.push (prefix_directory + "/fonts/type1/"); dirs.push (prefix_directory + "/fonts/cff/"); - + for (int i = 0; i < dirs.size (); i++) { String dir = dirs[i]; - if (!FcConfigAppFontAddDir (fcc, (FcChar8*)dir.to_str0 ())) + if (!FcConfigAppFontAddDir (fcc, (FcChar8 *)dir.to_str0 ())) error (_f ("Failed to add lilypond directory %s", dir)); - } + } } #else diff --git a/lily/font-interface.cc b/lily/font-interface.cc index e48f8e0116..878c3031a4 100644 --- a/lily/font-interface.cc +++ b/lily/font-interface.cc @@ -1,6 +1,6 @@ /* font-interface.cc -- implement Font_interface - + source file of the GNU LilyPond music typesetter (c) 2000--2005 Han-Wen Nienhuys @@ -21,17 +21,17 @@ Font_interface::get_default_font (Grob *me) if (!fm) { SCM chain = music_font_alist_chain (me); - + fm = select_font (me->get_layout (), chain); me->set_property ("font", fm->self_scm ()); } - + return fm; } LY_DEFINE (ly_font_interface_get_default_font, "ly:get-default-font", - 1 , 0, 0, (SCM grob), - "Return the default font for grob @var{gr}.") + 1, 0, 0, (SCM grob), + "Return the default font for grob @var{gr}.") { Grob *gr = unsmob_grob (grob); SCM_ASSERT_TYPE (gr, grob, SCM_ARG1, __FUNCTION__, "grob"); @@ -39,7 +39,6 @@ LY_DEFINE (ly_font_interface_get_default_font, "ly:get-default-font", return Font_interface::get_default_font (gr)->self_scm (); } - SCM Font_interface::music_font_alist_chain (Grob *g) { diff --git a/lily/font-metric-scheme.cc b/lily/font-metric-scheme.cc index fa1d9be03b..6b7c606423 100644 --- a/lily/font-metric-scheme.cc +++ b/lily/font-metric-scheme.cc @@ -4,7 +4,6 @@ source file of the GNU LilyPond music typesetter (c) 2005 Han-Wen Nienhuys - */ #include "stencil.hh" @@ -13,7 +12,7 @@ LY_DEFINE (ly_font_get_glyph, "ly:font-get-glyph", 2, 0, 0, - (SCM font, SCM name), + (SCM font, SCM name), "Return a Stencil from @var{font} for the glyph named @var{name}. " "@var{font} must be available as an AFM file. If the glyph " "is not available, return @code{#f}.") @@ -30,7 +29,7 @@ LY_DEFINE (ly_font_get_glyph, "ly:font-get-glyph", LY_DEFINE (ly_get_glyph, "ly:get-glyph", 2, 0, 0, - (SCM font, SCM index), + (SCM font, SCM index), "Retrieve a Stencil for the glyph numbered @var{index} " "in @var{font}.") { @@ -43,7 +42,7 @@ LY_DEFINE (ly_get_glyph, "ly:get-glyph", LY_DEFINE (ly_font_glyph_name_to_index, "ly:font-glyph-name-to-index", 2, 0, 0, - (SCM font, SCM name), + (SCM font, SCM name), "Return the index for @var{name} in @var{font}.") { Font_metric *fm = unsmob_metrics (font); @@ -55,7 +54,7 @@ LY_DEFINE (ly_font_glyph_name_to_index, "ly:font-glyph-name-to-index", LY_DEFINE (ly_font_index_to_charcode, "ly:font-index-to-charcode", 2, 0, 0, - (SCM font, SCM index), + (SCM font, SCM index), "Return the character code for @var{index} @var{font}.") { Font_metric *fm = unsmob_metrics (font); @@ -67,7 +66,7 @@ LY_DEFINE (ly_font_index_to_charcode, "ly:font-index-to-charcode", LY_DEFINE (ly_font_glyph_name_to_charcode, "ly:font-glyph-name-to-charcode", 2, 0, 0, - (SCM font, SCM name), + (SCM font, SCM name), "Return the character code for glyph @var{name} in @var{font}.") { Font_metric *fm = unsmob_metrics (font); @@ -82,15 +81,15 @@ LY_DEFINE (ly_font_glyph_name_to_charcode, "ly:font-glyph-name-to-charcode", LY_DEFINE (ly_text_dimension, "ly:text-dimension", 2, 0, 0, - (SCM font, SCM text), - "Given the font metric in @var{font} and the string @var{text}, " + (SCM font, SCM text), + "Given the font metric in @var{font} and the string @var{text}, " "compute the extents of that text in that font. " "The return value is a pair of number-pairs.") { Box b; - Modified_font_metric*fm = dynamic_cast + Modified_font_metric *fm = dynamic_cast (unsmob_metrics (font)); - + SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "modified font metric"); SCM_ASSERT_TYPE (scm_is_string (text), text, SCM_ARG2, __FUNCTION__, "string"); Stencil stc (fm->text_stencil (ly_scm2string (text))); @@ -106,10 +105,9 @@ LY_DEFINE (ly_font_file_name, "ly:font-file-name", { Font_metric *fm = unsmob_metrics (font); SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "font-metric"); - return fm->font_file_name(); + return fm->font_file_name (); } - LY_DEFINE (ly_font_name, "ly:font-name", 1, 0, 0, (SCM font), @@ -117,13 +115,13 @@ LY_DEFINE (ly_font_name, "ly:font-name", "return the corresponding name.") { Font_metric *fm = unsmob_metrics (font); - + SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "font-metric"); - return scm_makfrom0str (fm->font_name().to_str0 ()); + return scm_makfrom0str (fm->font_name ().to_str0 ()); } LY_DEFINE (ly_font_magnification, "ly:font-magnification", 1, 0, 0, - (SCM font), + (SCM font), "Given the font metric @var{font}, return the " "magnification, relative to the current outputscale.") { @@ -133,7 +131,7 @@ LY_DEFINE (ly_font_magnification, "ly:font-magnification", 1, 0, 0, } LY_DEFINE (ly_font_design_size, "ly:font-design-size", 1, 0, 0, - (SCM font), + (SCM font), "Given the font metric @var{font}, return the " "design size, relative to the current outputscale.") { diff --git a/lily/font-metric.cc b/lily/font-metric.cc index 73743ab5b2..a08589fe81 100644 --- a/lily/font-metric.cc +++ b/lily/font-metric.cc @@ -1,11 +1,11 @@ -/* +/* font-metric.cc -- implement Font_metric - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - Mats Bengtsson (the ugly TeX parsing in text_dimension) + Mats Bengtsson (the ugly TeX parsing in text_dimension) */ #include "font-metric.hh" @@ -28,24 +28,22 @@ Font_metric::design_size () const return 1.0 * point_constant; } - Stencil Font_metric::find_by_name (String s) const { s.substitute_char ('-', "M"); int idx = name_to_index (s); Box b; - + SCM expr = SCM_EOL; if (idx >= 0) { expr = scm_list_3 (ly_symbol2scm ("named-glyph"), self_scm (), - scm_makfrom0str (s.to_str0 ()) - ); + scm_makfrom0str (s.to_str0 ())); b = get_indexed_char (idx); } - + Stencil q (b, expr); return q; } @@ -61,7 +59,6 @@ Font_metric::Font_metric (Font_metric const &) { } - Font_metric::~Font_metric () { } @@ -72,13 +69,13 @@ Font_metric::count () const return 0; } -Box +Box Font_metric::get_ascii_char (int) const { return Box (Interval (0, 0), Interval (0, 0)); } -Box +Box Font_metric::get_indexed_char (int k) const { return get_ascii_char (k); @@ -104,7 +101,7 @@ Font_metric::derived_mark () const SCM Font_metric::mark_smob (SCM s) { - Font_metric *m = (Font_metric*) SCM_CELL_WORD_1 (s); + Font_metric *m = (Font_metric *) SCM_CELL_WORD_1 (s); m->derived_mark (); return m->description_; } @@ -121,14 +118,11 @@ Font_metric::print_smob (SCM s, SCM port, scm_print_state *) return 1; } - - IMPLEMENT_SMOBS (Font_metric); IMPLEMENT_DEFAULT_EQUAL_P (Font_metric); IMPLEMENT_TYPE_P (Font_metric, "ly:font-metric?"); - -SCM +SCM Font_metric::font_file_name () const { return scm_car (description_); @@ -143,7 +137,6 @@ Font_metric::font_name () const #include "afm.hh" - int Font_metric::index_to_ascii (int i) const { @@ -174,7 +167,6 @@ Font_metric::get_indexed_char_stencil (int code) const return Stencil (b, at); } - Offset Font_metric::attachment_point (String) const { @@ -193,7 +185,7 @@ Font_metric::text_stencil (String str) const SCM lst = scm_list_3 (ly_symbol2scm ("text"), this->self_scm (), scm_makfrom0str (str.to_str0 ())); - + Box b = text_dimension (str); return Stencil (b, lst); } diff --git a/lily/font-select.cc b/lily/font-select.cc index 262930983e..9b5257c9c1 100644 --- a/lily/font-select.cc +++ b/lily/font-select.cc @@ -1,5 +1,5 @@ /* - font-select.cc -- implement property -> font_metric routines. + font-select.cc -- implement property -> font_metric routines. source file of the GNU LilyPond music typesetter @@ -16,7 +16,6 @@ #include "pango-font.hh" #include "main.hh" - Font_metric * get_font_by_design_size (Output_def *layout, Real requested, SCM font_vector) @@ -31,7 +30,7 @@ get_font_by_design_size (Output_def *layout, Real requested, for (; i < n; i++) { SCM entry = scm_c_vector_ref (font_vector, i); - + if (scm_promise_p (entry) == SCM_BOOL_T) { Font_metric *fm = unsmob_metrics (scm_force (entry)); @@ -47,7 +46,7 @@ get_font_by_design_size (Output_def *layout, Real requested, = scm_cdr (entry); } #endif - + if (size > requested) break; last_size = size; @@ -65,7 +64,7 @@ get_font_by_design_size (Output_def *layout, Real requested, pango_description_string = last_pango_description_string; } } - + Font_metric *fm = 0; if (scm_is_string (pango_description_string)) { @@ -74,7 +73,7 @@ get_font_by_design_size (Output_def *layout, Real requested, pango_description_string, requested / size); #else - error ("Trying to retrieve pango font without HAVE_PANGO_FT2."); + error ("Trying to retrieve pango font without HAVE_PANGO_FT2."); #endif } else @@ -128,12 +127,12 @@ select_encoded_font (Output_def *layout, SCM chain) ? robust_scm2double (scm_cdr (mag), 1.0) : 1); Font_metric *fm = all_fonts_global->find_font (ly_scm2string (name)); - + return find_scaled_font (layout, fm, rmag); } else if (scm_instance_p (name)) { - SCM base_size = scm_slot_ref (name, ly_symbol2scm ("default-size")); + SCM base_size = scm_slot_ref (name, ly_symbol2scm ("default-size")); SCM vec = scm_slot_ref (name, ly_symbol2scm ("size-vector")); SCM font_size = ly_chain_assoc (ly_symbol2scm ("font-size"), chain); diff --git a/lily/font-size-engraver.cc b/lily/font-size-engraver.cc index 2b09d6087d..6d02eab213 100644 --- a/lily/font-size-engraver.cc +++ b/lily/font-size-engraver.cc @@ -1,25 +1,23 @@ -/* +/* font-size-engraver.cc -- implement Font_size_engraver - + source file of the GNU LilyPond music typesetter - + (c) 2001--2005 Han-Wen Nienhuys - - */ +*/ #include "grob.hh" #include "engraver.hh" class Font_size_engraver : public Engraver { - + TRANSLATOR_DECLARATIONS (Font_size_engraver); protected: virtual void acknowledge_grob (Grob_info gi); private: }; - Font_size_engraver::Font_size_engraver () { @@ -32,24 +30,23 @@ Font_size_engraver::acknowledge_grob (Grob_info gi) /* We only want to process a grob once. - */ + */ if (gi.origin_trans_->context () != context ()) - return ; - + return; + if (scm_is_number (sz) && scm_to_double (sz)) { Real font_size = scm_to_double (sz); - - font_size += robust_scm2double (gi.grob_->get_property ("font-size"), 0); + + font_size += robust_scm2double (gi.grob_->get_property ("font-size"), 0); gi.grob_->set_property ("font-size", scm_make_real (font_size)); } } - ADD_TRANSLATOR (Font_size_engraver, -/* descr */ "Puts fontSize into font-relative-size grob property.", -/* creats*/ "", -/* accepts */ "", -/* acks */ "font-interface", -/* reads */ "fontSize", -/* write */ ""); + /* descr */ "Puts fontSize into font-relative-size grob property.", + /* creats*/ "", + /* accepts */ "", + /* acks */ "font-interface", + /* reads */ "fontSize", + /* write */ ""); diff --git a/lily/forbid-break-engraver.cc b/lily/forbid-break-engraver.cc index 66d78a6660..fa4138bc48 100644 --- a/lily/forbid-break-engraver.cc +++ b/lily/forbid-break-engraver.cc @@ -4,7 +4,6 @@ source file of the GNU LilyPond music typesetter (c) 2002--_2005 Han-Wen Nienhuys - */ #include "rhythmic-head.hh" #include "grob.hh" @@ -24,14 +23,13 @@ Forbid_line_break_engraver::start_translation_timestep () { /* Check for running note heads. This should probably be done elsewhere. - */ + */ SCM busy = get_property ("busyGrobs"); Moment now = now_mom (); while (scm_is_pair (busy) && unsmob_moment (scm_caar (busy))->main_part_ == now.main_part_) busy = scm_cdr (busy); - while (scm_is_pair (busy)) { Grob *g = unsmob_grob (scm_cdar (busy)); @@ -43,11 +41,10 @@ Forbid_line_break_engraver::start_translation_timestep () } } - ADD_TRANSLATOR (Forbid_line_break_engraver, -/* descr */ "Forbid line breaks when note heads are still playing at some point.", -/* creats*/ "", -/* accepts */ "", -/* acks */ "", -/* reads */ "busyGrobs", -/* write */ ""); + /* descr */ "Forbid line breaks when note heads are still playing at some point.", + /* creats*/ "", + /* accepts */ "", + /* acks */ "", + /* reads */ "busyGrobs", + /* write */ ""); diff --git a/lily/freetype.cc b/lily/freetype.cc index 57db56909c..d8a0029ba1 100644 --- a/lily/freetype.cc +++ b/lily/freetype.cc @@ -4,7 +4,6 @@ source file of the GNU LilyPond music typesetter (c) 2004--2005 Han-Wen Nienhuys - */ #include "freetype.hh" @@ -12,14 +11,13 @@ FT_Library freetype2_library; - void -init_freetype() +init_freetype () { - int errorcode = FT_Init_FreeType( &freetype2_library ); + int errorcode = FT_Init_FreeType (&freetype2_library); if (errorcode) { - error("Could not initialize freetype"); + error ("Could not initialize freetype"); } } diff --git a/lily/function-documentation.cc b/lily/function-documentation.cc index 5e57203fc2..8daf4baf0c 100644 --- a/lily/function-documentation.cc +++ b/lily/function-documentation.cc @@ -1,10 +1,9 @@ -/* +/* function-documentation.cc -- Scheme doc strings. source file of the GNU LilyPond music typesetter (c) 2004--2005 Han-Wen Nienhuys - */ #include @@ -12,21 +11,21 @@ #include "protected-scm.hh" #include "string.hh" -static Protected_scm doc_hash_table ; +static Protected_scm doc_hash_table; void ly_add_function_documentation (SCM func, - char const * fname, - char const * varlist, - char const * doc) + char const *fname, + char const *varlist, + char const *doc) { if (!strlen (doc)) return; - + if (!scm_is_vector (doc_hash_table)) doc_hash_table = scm_make_vector (scm_int2num (59), SCM_EOL); String s = String (" - ") + "LilyPond procedure: " + fname + " " + varlist - + "\n" + doc ; + + "\n" + doc; scm_set_procedure_property_x (func, ly_symbol2scm ("documentation"), scm_makfrom0str (s.to_str0 ())); @@ -34,10 +33,9 @@ void ly_add_function_documentation (SCM func, scm_hashq_set_x (doc_hash_table, ly_symbol2scm (fname), entry); } - LY_DEFINE (ly_get_all_function_documentation, "ly:get-all-function-documentation", - 0, 0, 0, (), - "Get a hash table with all lilypond Scheme extension functions.") + 0, 0, 0, (), + "Get a hash table with all lilypond Scheme extension functions.") { return doc_hash_table; } diff --git a/lily/gdb.cc b/lily/gdb.cc index c47934c7ba..d019619852 100644 --- a/lily/gdb.cc +++ b/lily/gdb.cc @@ -2,21 +2,21 @@ #include "paper-column.hh" extern "C" { -// thanks to GDBs wonderful casting abilities, we need these: -Item* -to_item (Grob* g) -{ - return dynamic_cast (g); -} -Spanner* -to_spanner (Grob*g) -{ - return dynamic_cast (g); -} + // thanks to GDBs wonderful casting abilities, we need these: + Item * + to_item (Grob *g) + { + return dynamic_cast (g); + } + Spanner * + to_spanner (Grob *g) + { + return dynamic_cast (g); + } -Paper_column* -to_pc (Grob* g) -{ - return dynamic_cast (g); -} + Paper_column * + to_pc (Grob *g) + { + return dynamic_cast (g); + } } diff --git a/lily/general-scheme.cc b/lily/general-scheme.cc index eab9d896de..ba66ad8715 100644 --- a/lily/general-scheme.cc +++ b/lily/general-scheme.cc @@ -4,7 +4,7 @@ source file of the GNU LilyPond music typesetter (c) 1998--2005 Jan Nieuwenhuizen - Han-Wen Nienhuys + Han-Wen Nienhuys */ #include "config.hh" @@ -33,8 +33,6 @@ inline int my_isinf (Real r) { return isinf (r); } inline int my_isnan (Real r) { return isnan (r); } #endif - - LY_DEFINE (ly_find_file, "ly:find-file", 1, 0, 0, (SCM name), "Return the absolute file name of @var{name}, " @@ -46,14 +44,14 @@ LY_DEFINE (ly_find_file, "ly:find-file", String file_name = global_path.find (nm); if (file_name.is_empty ()) return SCM_BOOL_F; - + return scm_makfrom0str (file_name.to_str0 ()); } /* Ugh. Gulped file is copied twice. (maybe thrice if you count stdio buffering.) - */ +*/ LY_DEFINE (ly_gulp_file, "ly:gulp-file", 1, 0, 0, (SCM name), "Read the file @var{name}, and return its contents in a string. " @@ -92,14 +90,14 @@ LY_DEFINE (ly_programming_error, "ly:programming-error", LY_DEFINE (ly_dir_p, "ly:dir?", 1, 0, 0, (SCM s), - "type predicate. A direction is @code{-1}, @code{0} or " + "type predicate. A direction is @code{-1}, @code{0} or " "@code{1}, where @code{-1} represents " - "left or down and @code{1} represents right or up.") + "left or down and @code{1} represents right or up.") { if (scm_is_number (s)) { int i = scm_to_int (s); - return (i>= -1 && i <= 1) ? SCM_BOOL_T : SCM_BOOL_F; + return (i>= -1 && i <= 1) ? SCM_BOOL_T : SCM_BOOL_F; } return SCM_BOOL_F; } @@ -114,7 +112,7 @@ LY_DEFINE (ly_assoc_get, "ly:assoc-get", if (default_value == SCM_UNDEFINED) default_value = SCM_BOOL_F; - + if (scm_is_pair (handle)) return scm_cdr (handle); else @@ -135,12 +133,12 @@ LY_DEFINE (ly_number2string, "ly:number->string", #ifdef __APPLE__ if (my_isinf (r) || my_isnan (r)) #else - if (isinf (r) || isnan (r)) + if (isinf (r) || isnan (r)) #endif - { - programming_error ("Infinity or NaN encountered while converting Real number; setting to zero."); - r = 0.0; - } + { + programming_error ("Infinity or NaN encountered while converting Real number; setting to zero."); + r = 0.0; + } snprintf (str, sizeof (str), "%08.4f", r); } @@ -151,32 +149,32 @@ LY_DEFINE (ly_number2string, "ly:number->string", } LY_DEFINE (ly_version, "ly:version", 0, 0, 0, (), - "Return the current lilypond version as a list, e.g. @code{(1 3 127 uu1)}. ") + "Return the current lilypond version as a list, e.g. @code{(1 3 127 uu1)}. ") { - char const* vs = "\'(" MAJOR_VERSION " " MINOR_VERSION " " PATCH_LEVEL " " MY_PATCH_LEVEL ")" ; - - return scm_c_eval_string ((char*)vs); + char const *vs = "\'(" MAJOR_VERSION " " MINOR_VERSION " " PATCH_LEVEL " " MY_PATCH_LEVEL ")"; + + return scm_c_eval_string ((char *)vs); } LY_DEFINE (ly_unit, "ly:unit", 0, 0, 0, (), - "Return the unit used for lengths as a string.") + "Return the unit used for lengths as a string.") { return scm_makfrom0str (INTERNAL_UNIT); } LY_DEFINE (ly_dimension_p, "ly:dimension?", 1, 0, 0, (SCM d), - "Return @var{d} is a number. Used to distinguish length " - "variables from normal numbers.") + "Return @var{d} is a number. Used to distinguish length " + "variables from normal numbers.") { return scm_number_p (d); } /* Debugging mem leaks: - */ +*/ LY_DEFINE (ly_protects, "ly:protects", 0, 0, 0, (), - "Return hash of protected objects.") + "Return hash of protected objects.") { return scm_protects; } @@ -191,16 +189,16 @@ LY_DEFINE (ly_gettext, "ly:gettext", } LY_DEFINE (ly_output_backend, "ly:output-backend", - 0, 0, 0, (), - "Return name of output backend.") + 0, 0, 0, (), + "Return name of output backend.") { return scm_makfrom0str (output_backend_global.to_str0 ()); } LY_DEFINE (ly_output_formats, "ly:output-formats", - 0, 0, 0, (), - "Formats passed to --format as a list of strings, " - "used for the output.") + 0, 0, 0, (), + "Formats passed to --format as a list of strings, " + "used for the output.") { Array output_formats = split_string (output_format_global, ','); diff --git a/lily/glissando-engraver.cc b/lily/glissando-engraver.cc index 5f2a295ba7..5c339149b3 100644 --- a/lily/glissando-engraver.cc +++ b/lily/glissando-engraver.cc @@ -1,10 +1,10 @@ -/* +/* note-head-line-engraver.cc -- implement Note_head_line_engraver - + source file of the GNU LilyPond music typesetter - + (c) 2000--2005 Jan Nieuwenhuizen - */ +*/ #include "warn.hh" #include "spanner.hh" @@ -27,9 +27,9 @@ protected: virtual bool try_music (Music *); virtual void process_music (); private: - Spanner *line_; - Spanner *last_line_; - Music* event_; + Spanner *line_; + Spanner *last_line_; + Music *event_; }; Glissando_engraver::Glissando_engraver () @@ -39,7 +39,7 @@ Glissando_engraver::Glissando_engraver () } bool -Glissando_engraver::try_music (Music* m) +Glissando_engraver::try_music (Music *m) { if (!event_) { @@ -58,22 +58,20 @@ Glissando_engraver::process_music () } } - void Glissando_engraver::acknowledge_grob (Grob_info info) { if (Rhythmic_head::has_interface (info.grob_)) { - Grob * g = info.grob_; + Grob *g = info.grob_; if (line_) line_->set_bound (LEFT, g); if (last_line_) last_line_->set_bound (RIGHT, g); - } + } } - void Glissando_engraver::stop_translation_timestep () { @@ -83,7 +81,7 @@ Glissando_engraver::stop_translation_timestep () } if (line_) { - if ( last_line_) + if (last_line_) programming_error ("Overwriting glissando."); last_line_ = line_; } @@ -96,24 +94,22 @@ Glissando_engraver::finalize () { if (line_) { - String msg = _("Unterminated glissando."); - + String msg = _ ("Unterminated glissando."); + if (event_) event_->origin ()->warning (msg); else warning (msg); - + line_->suicide (); line_ = 0; } } - - ADD_TRANSLATOR (Glissando_engraver, -/* descr */ "Engrave a glissandi", -/* creats*/ "Glissando", -/* accepts */ "glissando-event", -/* acks */ "rhythmic-head-interface", -/* reads */ "followVoice", -/* write */ ""); + /* descr */ "Engrave a glissandi", + /* creats*/ "Glissando", + /* accepts */ "glissando-event", + /* acks */ "rhythmic-head-interface", + /* reads */ "followVoice", + /* write */ ""); diff --git a/lily/global-context-scheme.cc b/lily/global-context-scheme.cc index c543d73648..bf633f5460 100644 --- a/lily/global-context-scheme.cc +++ b/lily/global-context-scheme.cc @@ -4,7 +4,6 @@ source file of the GNU LilyPond music typesetter (c) 2005 Han-Wen Nienhuys - */ #include "warn.hh" @@ -20,9 +19,9 @@ LY_DEFINE (ly_format_output, "ly:format-output", 2, 0, 0, (SCM context, SCM outname), "Given a Global context in its final state, " - "process it and return the (rendered) result.") + "process it and return the (rendered) result.") { - Global_context *g = dynamic_cast (unsmob_context (context)); + Global_context *g = dynamic_cast (unsmob_context (context)); SCM_ASSERT_TYPE (g, context, SCM_ARG1, __FUNCTION__, "Global context"); SCM_ASSERT_TYPE (scm_is_string (outname), outname, SCM_ARG2, __FUNCTION__, "output file name"); @@ -32,8 +31,7 @@ LY_DEFINE (ly_format_output, "ly:format-output", return output->process (ly_scm2string (outname)); } - -LY_DEFINE (ly_run_translator, "ly:run-translator", +LY_DEFINE (ly_run_translator, "ly:run-translator", 2, 1, 0, (SCM mus, SCM output_def, SCM key), "Process @var{mus} according to @var{output_def}. \n" "An interpretation context is set up,\n" @@ -52,15 +50,15 @@ LY_DEFINE (ly_run_translator, "ly:run-translator", warning (_ ("Need music in a score")); return SCM_BOOL_F; } - + SCM_ASSERT_TYPE (music, mus, SCM_ARG1, __FUNCTION__, "Music"); SCM_ASSERT_TYPE (odef, output_def, SCM_ARG2, __FUNCTION__, "Output definition"); - + Cpu_timer timer; - - Global_context *trans = new Global_context (odef, music->get_length (), unsmob_key (key) ); + + Global_context *trans = new Global_context (odef, music->get_length (), unsmob_key (key)); if (!trans) { programming_error ("no toplevel translator"); @@ -68,9 +66,9 @@ LY_DEFINE (ly_run_translator, "ly:run-translator", } progress_indication (_ ("Interpreting music... ")); - + SCM protected_iter = Music_iterator::get_static_get_iterator (music); - Music_iterator * iter = unsmob_iterator (protected_iter); + Music_iterator *iter = unsmob_iterator (protected_iter); iter->init_translator (music, trans); iter->construct_children (); @@ -88,7 +86,7 @@ LY_DEFINE (ly_run_translator, "ly:run-translator", trans->finish (); if (be_verbose_global) - progress_indication (_f ("elapsed time: %.2f seconds", timer.read ())); - + progress_indication (_f ("elapsed time: %.2f seconds", timer.read ())); + return scm_gc_unprotect_object (trans->self_scm ()); } diff --git a/lily/global-context.cc b/lily/global-context.cc index 37e9612a0d..ceafb4672c 100644 --- a/lily/global-context.cc +++ b/lily/global-context.cc @@ -19,15 +19,15 @@ #include "lilypond-key.hh" Global_context::Global_context (Output_def *o, Moment final, Object_key *key) - : Context (new Lilypond_context_key(key, - Moment(0), - "Global", "", 0)) + : Context (new Lilypond_context_key (key, + Moment (0), + "Global", "", 0)) { output_def_ = o; final_mom_ = final; definition_ = find_context_def (o, ly_symbol2scm ("Global")); - Context_def *globaldef = unsmob_context_def (definition_); + Context_def *globaldef = unsmob_context_def (definition_); if (!globaldef) { programming_error ("No `Global' context found."); @@ -37,7 +37,7 @@ Global_context::Global_context (Output_def *o, Moment final, Object_key *key) accepts_list_ = scm_list_1 (ly_symbol2scm ("Score")); } -Output_def* +Output_def * Global_context::get_output_def () const { return output_def_; @@ -51,8 +51,8 @@ Global_context::add_moment_to_process (Moment m) if (m < now_mom_) programming_error ("Trying to freeze in time."); - - for (int i = 0; i < extra_mom_pq_.size (); i++) + + for (int i = 0; i < extra_mom_pq_.size (); i++) if (extra_mom_pq_[i] == m) return; extra_mom_pq_.insert (m); @@ -75,13 +75,13 @@ Global_context::get_moments_left () const void Global_context::prepare (Moment m) { - prev_mom_ = now_mom_; + prev_mom_ = now_mom_; now_mom_ = m; clear_key_disambiguations (); if (get_score_context ()) get_score_context ()->prepare (m); - + } Moment @@ -90,15 +90,15 @@ Global_context::now_mom () const return now_mom_; } -Score_context* +Score_context * Global_context::get_score_context () const { return (scm_is_pair (context_list_)) - ? dynamic_cast (unsmob_context (scm_car (context_list_))) + ? dynamic_cast (unsmob_context (scm_car (context_list_))) : 0; } -Music_output* +Music_output * Global_context::get_output () { return get_score_context ()->get_output (); @@ -120,7 +120,7 @@ Global_context::finish () } void -Global_context::run_iterator_on_me (Music_iterator * iter) +Global_context::run_iterator_on_me (Music_iterator *iter) { if (iter-> ok ()) prev_mom_ = now_mom_ = iter->pending_moment (); @@ -137,27 +137,26 @@ Global_context::run_iterator_on_me (Music_iterator * iter) w = sneaky_insert_extra_moment (w); if (w.main_part_.is_infinity ()) - break ; - + break; + if (first) - { + { /* Need this to get grace notes at start of a piece correct. - */ - first = false; - set_property ("measurePosition", w.smobbed_copy ()); - } - + */ + first = false; + set_property ("measurePosition", w.smobbed_copy ()); + } prepare (w); if (iter->ok ()) iter->process (w); - if (!get_score_context ()) + if (!get_score_context ()) { SCM sym = ly_symbol2scm ("Score"); - Context_def * t = unsmob_context_def (find_context_def (get_output_def (), sym)); + Context_def *t = unsmob_context_def (find_context_def (get_output_def (), sym)); if (!t) error (_f ("can't find `%s' context", "Score")); @@ -165,10 +164,10 @@ Global_context::run_iterator_on_me (Music_iterator * iter) Context *c = t->instantiate (SCM_EOL, key); add_context (c); - Score_context *sc = dynamic_cast (c); + Score_context *sc = dynamic_cast (c); sc->prepare (w); } - + one_time_step (); } } @@ -189,7 +188,7 @@ Global_context::add_finalization (SCM x) { SCM lst = get_property ("finalizations"); lst = scm_cons (x, lst); - set_property ("finalizations", lst); + set_property ("finalizations", lst); } Moment diff --git a/lily/global-ctor.cc b/lily/global-ctor.cc index eef6cbfd97..d621427556 100644 --- a/lily/global-ctor.cc +++ b/lily/global-ctor.cc @@ -1,11 +1,10 @@ -/* +/* global-ctor.cc -- implement global constructors - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - - */ +*/ #include "global-ctor.hh" diff --git a/lily/gourlay-breaking.cc b/lily/gourlay-breaking.cc index 531c870145..3c988c6e0f 100644 --- a/lily/gourlay-breaking.cc +++ b/lily/gourlay-breaking.cc @@ -23,23 +23,24 @@ const int HAPPY_DOTS_I = 3; /** - Helper to trace back an optimal path - */ -struct Break_node { + Helper to trace back an optimal path +*/ +struct Break_node +{ /** this was the previous. If negative, this break should not be - considered: this path has infinite energy - - */ + considered: this path has infinite energy + + */ int prev_break_; /** Which system number so far? - */ + */ int line_; Real demerits_; Column_x_positions line_config_; - - Break_node () + + Break_node () { prev_break_ = -1; line_ = 0; @@ -54,76 +55,75 @@ struct Break_node { }; void -print_break_nodes (Array const & arr) +print_break_nodes (Array const &arr) { for (int i = 0; i < arr.size (); i++) { - printf ( "node %d: ", i); + printf ("node %d: ", i); arr[i].print (); - } + } } /** - This algorithms is adapted from the OSU Tech report on breaking lines. + This algorithms is adapted from the OSU Tech report on breaking lines. - this function is longish, but not very complicated. + this function is longish, but not very complicated. - TODO: should rewrite. See the function in scm/page-layout.scm for - inspiration. - - */ + TODO: should rewrite. See the function in scm/page-layout.scm for + inspiration. +*/ Array Gourlay_breaking::do_solve () const { Array optimal_paths; - Link_array all = - pscore_->system_->columns (); - + Link_array all + = pscore_->system_->columns (); + Array breaks = find_break_indices (); - - Break_node first_node ; + + Break_node first_node; optimal_paths.push (first_node); bool ragged_right = to_boolean (pscore_->layout_->c_variable ("raggedright")); bool ragged_last = to_boolean (pscore_->layout_->c_variable ("raggedlast")); Real worst_force = 0.0; - for (int break_idx = 1; break_idx< breaks.size (); break_idx++) + for (int break_idx = 1; break_idx< breaks.size (); break_idx++) { /* - start with a short line, add measures. At some point - the line becomes infeasible. Then we don't try to add more - */ + start with a short line, add measures. At some point + the line becomes infeasible. Then we don't try to add more + */ int minimal_start_idx = -1; Column_x_positions minimal_sol; Column_x_positions backup_sol; - + Real minimal_demerits = infinity_f; for (int start_idx = break_idx; start_idx--;) { - Link_array line = all.slice (breaks[start_idx], breaks[break_idx]+1); - - line[0] = dynamic_cast (line[0])->find_prebroken_piece (RIGHT); - line.top () = dynamic_cast (line.top ())->find_prebroken_piece (LEFT); - + Link_array line = all.slice (breaks[start_idx], breaks[break_idx] + 1); + + line[0] = dynamic_cast (line[0])->find_prebroken_piece (RIGHT); + line.top () = dynamic_cast (line.top ())->find_prebroken_piece (LEFT); + Column_x_positions cp; cp.cols_ = line; Interval line_dims = line_dimensions_int (pscore_->layout_, optimal_paths[start_idx].line_); - Simple_spacer_wrapper * sp = generate_spacing_problem (line, line_dims); - bool last_line = break_idx == breaks.size ()-1; + Simple_spacer_wrapper *sp = generate_spacing_problem (line, line_dims); + bool last_line = break_idx == breaks.size () - 1; bool ragged = ragged_right || (last_line && ragged_last); - + sp->solve (&cp, ragged); - + delete sp; if (ragged && last_line) cp.force_ = 0.0; - + if (fabs (cp.force_) > worst_force) worst_force = fabs (cp.force_); @@ -132,7 +132,7 @@ Gourlay_breaking::do_solve () const solution", in case everything fucks up. */ if (start_idx == break_idx - 1) backup_sol = cp; - + Real this_demerits; if (optimal_paths[start_idx].demerits_ >= infinity_f) @@ -141,7 +141,7 @@ Gourlay_breaking::do_solve () const this_demerits = combine_demerits (optimal_paths[start_idx].line_config_, cp) + optimal_paths[start_idx].demerits_; - if (this_demerits < minimal_demerits) + if (this_demerits < minimal_demerits) { minimal_start_idx = start_idx; minimal_sol = cp; @@ -153,18 +153,17 @@ Gourlay_breaking::do_solve () const if we add more columns, so we get on with the next one */ if (!cp.satisfies_constraints_) - break ; + break; } - Break_node bnod; - if (minimal_start_idx < 0) + if (minimal_start_idx < 0) { bnod.demerits_ = infinity_f; bnod.line_config_ = backup_sol; - bnod.prev_break_ = break_idx - 1; + bnod.prev_break_ = break_idx - 1; } - else + else { bnod.prev_break_ = minimal_start_idx; bnod.demerits_ = minimal_demerits; @@ -172,14 +171,14 @@ Gourlay_breaking::do_solve () const } bnod.line_ = optimal_paths[bnod.prev_break_].line_ + 1; optimal_paths.push (bnod); - + if (! (break_idx % HAPPY_DOTS_I)) progress_indication (String ("[") + to_string (break_idx) + "]"); } /* do the last one */ if (breaks.size () % HAPPY_DOTS_I) - progress_indication (String ("[") + to_string (breaks.size ()) + "]"); + progress_indication (String ("[") + to_string (breaks.size ()) + "]"); progress_indication ("\n"); @@ -187,7 +186,7 @@ Gourlay_breaking::do_solve () const Array lines; /* skip 0-th element, since it is a "dummy" elt*/ - for (int i = optimal_paths.size ()-1; i> 0;) + for (int i = optimal_paths.size () - 1; i> 0;) { final_breaks.push (i); int prev = optimal_paths[i].prev_break_; @@ -200,14 +199,14 @@ Gourlay_breaking::do_solve () const progress_indication (_f ("Optimal demerits: %f", optimal_paths.top ().demerits_) + "\n"); } - + if (optimal_paths.top ().demerits_ >= infinity_f) warning (_ ("No feasible line breaking found")); - + for (int i = final_breaks.size (); i--;) { Column_x_positions cp (optimal_paths[final_breaks[i]].line_config_); - + lines.push (cp); if (!cp.satisfies_constraints_) warning ("Could not find line breaking that satisfies constraints."); @@ -215,26 +214,23 @@ Gourlay_breaking::do_solve () const return lines; } - Gourlay_breaking::Gourlay_breaking () { } - - /* TODO: uniformity parameter to control rel. importance of spacing differences. TODO: mixing break penalties and constraint-failing solutions is confusing. - */ +*/ Real Gourlay_breaking::combine_demerits (Column_x_positions const &prev, Column_x_positions const &this_one) const { Real break_penalties = 0.0; - Grob * pc = this_one.cols_.top (); + Grob *pc = this_one.cols_.top (); if (pc->original_) { SCM pen = pc->get_property ("penalty"); @@ -253,25 +249,25 @@ Gourlay_breaking::combine_demerits (Column_x_positions const &prev, becoming denser, the uniformity requirement makes lines go from cramped to even more cramped (because going from cramped 3meas/line to relatively loose 2meas/line is such a big step. - - */ - Real demerit = abs (this_one.force_) + abs (prev.force_ - this_one.force_) + */ + + Real demerit = abs (this_one.force_) + abs (prev.force_ - this_one.force_) + break_penalties; - + if (!this_one.satisfies_constraints_) - { - /* - If it doesn't satisfy constraints, we make this one - really unattractive. - - add 20000 to the demerits, so that a break penalty - of -10000 won't change the result */ - demerit = (demerit + 20000) >? 2000; - - demerit *= 10; - } - - return demerit; + { + /* + If it doesn't satisfy constraints, we make this one + really unattractive. + + add 20000 to the demerits, so that a break penalty + of -10000 won't change the result */ + demerit = (demerit + 20000) >? 2000; + + demerit *= 10; + } + + return demerit; } diff --git a/lily/grace-engraver.cc b/lily/grace-engraver.cc index d820ff5924..be09cb4fe5 100644 --- a/lily/grace-engraver.cc +++ b/lily/grace-engraver.cc @@ -1,10 +1,9 @@ -/* +/* grace-engraver.cc -- implement Grace_engraver - + source file of the GNU LilyPond music typesetter - + (c) 2004--2005 Han-Wen Nienhuys - */ #include "engraver.hh" @@ -16,15 +15,14 @@ class Grace_engraver : public Engraver protected: virtual void start_translation_timestep (); virtual void derived_mark (); - + TRANSLATOR_DECLARATIONS (Grace_engraver); Moment last_moment_; SCM grace_settings_; public: }; - -Grace_engraver::Grace_engraver() +Grace_engraver::Grace_engraver () { grace_settings_ = SCM_EOL; } @@ -68,23 +66,23 @@ Grace_engraver::start_translation_timestep () SCM val = scm_cadr (scm_cddr (entry)); Context *c = context (); - while (c + while (c && c->context_name_symbol () != context_name) { - c = c->get_parent_context (); + c = c->get_parent_context (); } - if (c) + if (c) { execute_pushpop_property (c, grob, sym, val); grace_settings_ - = scm_cons (scm_cons (c->self_scm(), entry), grace_settings_); + = scm_cons (scm_cons (c->self_scm (), entry), grace_settings_); } else { programming_error ("Cannot find context"); - scm_display (context_name, scm_current_error_port()); + scm_display (context_name, scm_current_error_port ()); } } } @@ -92,11 +90,10 @@ Grace_engraver::start_translation_timestep () last_moment_ = now; } - ADD_TRANSLATOR (Grace_engraver, - /* descr */ "Set font size and other properties for grace notes.", - /* creats*/ "", - /* accepts */ "", - /* acks */ "", - /* reads */ "graceSettings", - /* write */ ""); + /* descr */ "Set font size and other properties for grace notes.", + /* creats*/ "", + /* accepts */ "", + /* acks */ "", + /* reads */ "graceSettings", + /* write */ ""); diff --git a/lily/grace-iterator.cc b/lily/grace-iterator.cc index 8ef15c7cf9..35961f4a07 100644 --- a/lily/grace-iterator.cc +++ b/lily/grace-iterator.cc @@ -1,11 +1,10 @@ -/* +/* grace-music.cc -- implement Grace_music - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - - */ +*/ #include "grace-iterator.hh" #include "global-context.hh" @@ -15,7 +14,7 @@ void Grace_iterator::process (Moment m) { Moment main; - main.main_part_ = - start_mom_.grace_part_ + m.grace_part_; + main.main_part_ = -start_mom_.grace_part_ + m.grace_part_; Music_wrapper_iterator::process (main); /* We can safely do this, since \grace should always be inside @@ -29,10 +28,9 @@ Grace_iterator::pending_moment () const Moment cp = Music_wrapper_iterator::pending_moment (); Moment pending; - pending.grace_part_ = start_mom_.grace_part_ + cp.main_part_; + pending.grace_part_ = start_mom_.grace_part_ + cp.main_part_; return pending; } - IMPLEMENT_CTOR_CALLBACK (Grace_iterator); diff --git a/lily/grace-music.cc b/lily/grace-music.cc index 382efcf8bc..b6ae587881 100644 --- a/lily/grace-music.cc +++ b/lily/grace-music.cc @@ -1,10 +1,9 @@ -/* - grace-music.cc -- implement Grace_music - - source file of the GNU LilyPond music typesetter - - (c) 1999--2005 Han-Wen Nienhuys - +/* + grace-music.cc -- implement Grace_music + + source file of the GNU LilyPond music typesetter + + (c) 1999--2005 Han-Wen Nienhuys */ #include "music.hh" @@ -13,15 +12,15 @@ class Grace_music { public: - DECLARE_SCHEME_CALLBACK(start_callback, (SCM)); + DECLARE_SCHEME_CALLBACK (start_callback, (SCM)); }; -MAKE_SCHEME_CALLBACK(Grace_music, start_callback, 1); +MAKE_SCHEME_CALLBACK (Grace_music, start_callback, 1); SCM -Grace_music::start_callback (SCM m) +Grace_music::start_callback (SCM m) { Moment *l = unsmob_moment (Music_wrapper::length_callback (m)); Moment gl; - gl.grace_part_ = -(l->main_part_ + l->grace_part_ ); + gl.grace_part_ = -(l->main_part_ + l->grace_part_); return gl.smobbed_copy (); } diff --git a/lily/gregorian-ligature-engraver.cc b/lily/gregorian-ligature-engraver.cc index 9a9ac434f9..96c960b1c4 100644 --- a/lily/gregorian-ligature-engraver.cc +++ b/lily/gregorian-ligature-engraver.cc @@ -1,10 +1,10 @@ /* gregorian-ligature-engraver.cc -- implement Gregorian_ligature_engraver - + source file of the GNU LilyPond music typesetter - + (c) 2003--2005 Juergen Reuter - */ +*/ #include "gregorian-ligature-engraver.hh" @@ -87,107 +87,106 @@ void check_and_fix_all_prefixes (Array primitives) /* Check for illegal head modifier combinations */ for (int i = 0; i < primitives.size (); i++) { - Grob *primitive = primitives[i].grob_; + Grob *primitive = primitives[i].grob_; - /* compute head prefix set by inspecting primitive grob properties */ - int prefix_set = - (VIRGA * to_boolean (primitive->get_property ("virga"))) | - (STROPHA * to_boolean (primitive->get_property ("stropha"))) | - (INCLINATUM * to_boolean (primitive->get_property ("inclinatum"))) | - (AUCTUM * to_boolean (primitive->get_property ("auctum"))) | - (DESCENDENS * to_boolean (primitive->get_property ("descendens"))) | - (ASCENDENS * to_boolean (primitive->get_property ("ascendens"))) | - (ORISCUS * to_boolean (primitive->get_property ("oriscus"))) | - (QUILISMA * to_boolean (primitive->get_property ("quilisma"))) | - (DEMINUTUM * to_boolean (primitive->get_property ("deminutum"))) | - (CAVUM * to_boolean (primitive->get_property ("cavum"))) | - (LINEA * to_boolean (primitive->get_property ("linea"))) | - (PES_OR_FLEXA * to_boolean (primitive->get_property ("pes-or-flexa"))); + /* compute head prefix set by inspecting primitive grob properties */ + int prefix_set + = (VIRGA *to_boolean (primitive->get_property ("virga"))) | + (STROPHA *to_boolean (primitive->get_property ("stropha"))) | + (INCLINATUM *to_boolean (primitive->get_property ("inclinatum"))) | + (AUCTUM *to_boolean (primitive->get_property ("auctum"))) | + (DESCENDENS *to_boolean (primitive->get_property ("descendens"))) | + (ASCENDENS *to_boolean (primitive->get_property ("ascendens"))) | + (ORISCUS *to_boolean (primitive->get_property ("oriscus"))) | + (QUILISMA *to_boolean (primitive->get_property ("quilisma"))) | + (DEMINUTUM *to_boolean (primitive->get_property ("deminutum"))) | + (CAVUM *to_boolean (primitive->get_property ("cavum"))) | + (LINEA *to_boolean (primitive->get_property ("linea"))) | + (PES_OR_FLEXA *to_boolean (primitive->get_property ("pes-or-flexa"))); - /* check: ascendens and descendens exclude each other; same with - auctum and deminutum */ - if (prefix_set & DESCENDENS) - { - fix_prefix_set (&prefix_set, - prefix_set & ~ASCENDENS, - prefix_set & ~ASCENDENS, - primitive); - } - if (prefix_set & AUCTUM) - { - fix_prefix_set (&prefix_set, - prefix_set & ~DEMINUTUM, - prefix_set & ~DEMINUTUM, - primitive); - } - - /* check: virga, quilisma and oriscus can not be combined with any - other prefix, but may be part of a pes or flexa */ - if (prefix_set & VIRGA) - { - fix_prefix_set (&prefix_set, - VIRGA, - VIRGA | PES_OR_FLEXA, - primitive); - } - if (prefix_set & QUILISMA) - { - fix_prefix_set (&prefix_set, - QUILISMA, - QUILISMA | PES_OR_FLEXA, - primitive); - } - if (prefix_set & ORISCUS) - { - fix_prefix_set (&prefix_set, - ORISCUS, - ORISCUS | PES_OR_FLEXA, - primitive); - } + /* check: ascendens and descendens exclude each other; same with + auctum and deminutum */ + if (prefix_set & DESCENDENS) + { + fix_prefix_set (&prefix_set, + prefix_set & ~ASCENDENS, + prefix_set & ~ASCENDENS, + primitive); + } + if (prefix_set & AUCTUM) + { + fix_prefix_set (&prefix_set, + prefix_set & ~DEMINUTUM, + prefix_set & ~DEMINUTUM, + primitive); + } - /* check: auctum is the only valid optional prefix for stropha */ - if (prefix_set & STROPHA) - { - fix_prefix_set (&prefix_set, - STROPHA, - STROPHA | AUCTUM, - primitive); - } + /* check: virga, quilisma and oriscus can not be combined with any + other prefix, but may be part of a pes or flexa */ + if (prefix_set & VIRGA) + { + fix_prefix_set (&prefix_set, + VIRGA, + VIRGA | PES_OR_FLEXA, + primitive); + } + if (prefix_set & QUILISMA) + { + fix_prefix_set (&prefix_set, + QUILISMA, + QUILISMA | PES_OR_FLEXA, + primitive); + } + if (prefix_set & ORISCUS) + { + fix_prefix_set (&prefix_set, + ORISCUS, + ORISCUS | PES_OR_FLEXA, + primitive); + } + /* check: auctum is the only valid optional prefix for stropha */ + if (prefix_set & STROPHA) + { + fix_prefix_set (&prefix_set, + STROPHA, + STROPHA | AUCTUM, + primitive); + } - /* check: inclinatum may be prefixed with auctum or deminutum only */ - if (prefix_set & INCLINATUM) - { - fix_prefix_set (&prefix_set, - INCLINATUM, - INCLINATUM | AUCTUM | DEMINUTUM, - primitive); - } - /* check: semivocalis (deminutum but not inclinatum) must occur in - combination with and only with pes or flexa */ - else if (prefix_set & DEMINUTUM) - { - fix_prefix_set (&prefix_set, - DEMINUTUM | PES_OR_FLEXA, - DEMINUTUM | PES_OR_FLEXA, - primitive); - } + /* check: inclinatum may be prefixed with auctum or deminutum only */ + if (prefix_set & INCLINATUM) + { + fix_prefix_set (&prefix_set, + INCLINATUM, + INCLINATUM | AUCTUM | DEMINUTUM, + primitive); + } + /* check: semivocalis (deminutum but not inclinatum) must occur in + combination with and only with pes or flexa */ + else if (prefix_set & DEMINUTUM) + { + fix_prefix_set (&prefix_set, + DEMINUTUM | PES_OR_FLEXA, + DEMINUTUM | PES_OR_FLEXA, + primitive); + } - /* check: cavum and linea (either or both) may be applied only - upon core punctum */ - if (prefix_set & (CAVUM | LINEA)) - { - fix_prefix_set (&prefix_set, - 0, - CAVUM | LINEA, - primitive); - } + /* check: cavum and linea (either or both) may be applied only + upon core punctum */ + if (prefix_set & (CAVUM | LINEA)) + { + fix_prefix_set (&prefix_set, + 0, + CAVUM | LINEA, + primitive); + } - /* all other combinations should be valid (unless I made a - mistake) */ + /* all other combinations should be valid (unless I made a + mistake) */ - primitive->set_property ("prefix-set", scm_int2num (prefix_set)); - } + primitive->set_property ("prefix-set", scm_int2num (prefix_set)); + } } /* @@ -200,50 +199,51 @@ provide_context_info (Array primitives) int prev_prefix_set = 0; int prev_context_info = 0; int prev_pitch = 0; - for (int i = 0; i < primitives.size (); i++) { - Grob *primitive = primitives[i].grob_; - Music *music_cause = primitives[i].music_cause (); - int context_info = 0; - int pitch = unsmob_pitch (music_cause->get_property ("pitch"))->steps (); - int prefix_set = scm_to_int (primitive->get_property ("prefix-set")); + for (int i = 0; i < primitives.size (); i++) + { + Grob *primitive = primitives[i].grob_; + Music *music_cause = primitives[i].music_cause (); + int context_info = 0; + int pitch = unsmob_pitch (music_cause->get_property ("pitch"))->steps (); + int prefix_set = scm_to_int (primitive->get_property ("prefix-set")); - if (prefix_set & PES_OR_FLEXA) - if (!i) // ligature may not start with 2nd head of pes or flexa + if (prefix_set & PES_OR_FLEXA) + if (!i) // ligature may not start with 2nd head of pes or flexa { primitive->warning ("may not apply `\\~' on first head of " "ligature; ignoring `\\~'"); } - else if (pitch > prev_pitch) // pes - { - prev_context_info |= PES_LOWER; - context_info |= PES_UPPER; - } - else if (pitch < prev_pitch) // flexa - { - prev_context_info |= FLEXA_LEFT; - context_info |= FLEXA_RIGHT; - } - else // (pitch == prev_pitch) + else if (pitch > prev_pitch) // pes + { + prev_context_info |= PES_LOWER; + context_info |= PES_UPPER; + } + else if (pitch < prev_pitch) // flexa + { + prev_context_info |= FLEXA_LEFT; + context_info |= FLEXA_RIGHT; + } + else // (pitch == prev_pitch) + { + primitive->warning ("may not apply `\\~' on heads with " + "identical pitch; ignoring `\\~'"); + } + if (prev_prefix_set & DEMINUTUM) { - primitive->warning ("may not apply `\\~' on heads with " - "identical pitch; ignoring `\\~'"); + context_info |= AFTER_DEMINUTUM; } - if (prev_prefix_set & DEMINUTUM) - { - context_info |= AFTER_DEMINUTUM; - } - if (prev_primitive) - prev_primitive->set_property ("context-info", - scm_int2num (prev_context_info)); - prev_primitive = primitive; - prev_prefix_set = prefix_set; - prev_context_info = context_info; - prev_pitch = pitch; - } + if (prev_primitive) + prev_primitive->set_property ("context-info", + scm_int2num (prev_context_info)); + prev_primitive = primitive; + prev_prefix_set = prefix_set; + prev_context_info = context_info; + prev_pitch = pitch; + } if (prev_primitive) prev_primitive->set_property ("context-info", - scm_int2num (prev_context_info)); + scm_int2num (prev_context_info)); } void @@ -275,9 +275,9 @@ Gregorian_ligature_engraver::stop_translation_timestep () } ADD_TRANSLATOR (Gregorian_ligature_engraver, -/* descr */ "This is an abstract class. Subclasses such as Vaticana_ligature_engraver handle ligatures by glueing special ligature heads together.", -/* creats*/ "", -/* accepts */ "ligature-event", -/* acks */ "note-head-interface rest-interface", -/* reads */ "", -/* write */ ""); + /* descr */ "This is an abstract class. Subclasses such as Vaticana_ligature_engraver handle ligatures by glueing special ligature heads together.", + /* creats*/ "", + /* accepts */ "ligature-event", + /* acks */ "note-head-interface rest-interface", + /* reads */ "", + /* write */ ""); diff --git a/lily/gregorian-ligature.cc b/lily/gregorian-ligature.cc index 3adfe2045e..82a2110bc5 100644 --- a/lily/gregorian-ligature.cc +++ b/lily/gregorian-ligature.cc @@ -1,4 +1,4 @@ -/* +/* gregorian-ligature.cc -- implement Gregorian_ligature source file of the GNU LilyPond music typesetter @@ -25,8 +25,8 @@ String Gregorian_ligature::prefixes_to_str (Grob *primitive) { String str; - int prefix_set = - scm_to_int (primitive->get_property ("prefix-set")); + int prefix_set + = scm_to_int (primitive->get_property ("prefix-set")); check_prefix ("virga", VIRGA, prefix_set, &str); check_prefix ("stropha", STROPHA, prefix_set, &str); check_prefix ("inclinatum", INCLINATUM, prefix_set, &str); @@ -48,7 +48,7 @@ Gregorian_ligature::prefixes_to_str (Grob *primitive) by code of GregorianLigatureEngraver that is virtually invoked by a subclass like VaticanaLigatureEngraver. The property is lateron read by the associated item class, such as VaticanaLigature.--jr - */ +*/ ADD_INTERFACE (Gregorian_ligature, "gregorian-ligature-interface", "A gregorian ligature", "virga stropha inclinatum auctum descendens ascendens " diff --git a/lily/grob-info.cc b/lily/grob-info.cc index d4a0acc0ce..38d074dde6 100644 --- a/lily/grob-info.cc +++ b/lily/grob-info.cc @@ -19,23 +19,25 @@ Grob_info::Grob_info () origin_trans_ = 0; } -Music* +Music * Grob_info::music_cause () { - SCM cause = grob_->get_property ("cause"); + SCM cause = grob_->get_property ("cause"); return unsmob_music (cause); } Link_array -Grob_info::origin_contexts (Translator* end) const +Grob_info::origin_contexts (Translator *end) const { - Context * t = origin_trans_->context (); + Context *t = origin_trans_->context (); Link_array r; - do { - r.push (t); - t = t->get_parent_context (); - } while (t && t != end->context ()); - + do + { + r.push (t); + t = t->get_parent_context (); + } + while (t && t != end->context ()); + return r; } - + diff --git a/lily/grob-interface-scheme.cc b/lily/grob-interface-scheme.cc index 44829c0fac..b586995209 100644 --- a/lily/grob-interface-scheme.cc +++ b/lily/grob-interface-scheme.cc @@ -4,7 +4,6 @@ source file of the GNU LilyPond music typesetter (c) 2005 Han-Wen Nienhuys - */ #include "lily-guile.hh" @@ -14,10 +13,10 @@ Protected_scm all_ifaces; LY_DEFINE (ly_add_interface, "ly:add-interface", 3, 0, 0, (SCM a, SCM b, SCM c), - "Add an interface description.") + "Add an interface description.") { SCM_ASSERT_TYPE (scm_is_symbol (a), a, SCM_ARG1, __FUNCTION__, "symbol"); - SCM_ASSERT_TYPE (scm_is_string (b), b, SCM_ARG2, __FUNCTION__, "string"); + SCM_ASSERT_TYPE (scm_is_string (b), b, SCM_ARG2, __FUNCTION__, "string"); SCM_ASSERT_TYPE (ly_c_list_p (c), c, SCM_ARG3, __FUNCTION__, "list of syms"); if (!scm_is_vector (all_ifaces)) all_ifaces = scm_make_vector (scm_int2num (40), SCM_EOL); @@ -29,10 +28,9 @@ LY_DEFINE (ly_add_interface, "ly:add-interface", 3, 0, 0, (SCM a, SCM b, SCM c), return SCM_UNSPECIFIED; } - LY_DEFINE (ly_all_grob_interfaces, "ly:all-grob-interfaces", - 0, 0, 0, (), - "Get a hash table with all interface descriptions.") + 0, 0, 0, (), + "Get a hash table with all interface descriptions.") { return all_ifaces; } diff --git a/lily/grob-interface.cc b/lily/grob-interface.cc index 7e16410163..6e155aa68b 100644 --- a/lily/grob-interface.cc +++ b/lily/grob-interface.cc @@ -12,9 +12,9 @@ #include "grob.hh" #include "warn.hh" -void add_interface (const char * symbol, - const char * descr, - const char * vars) +void add_interface (const char *symbol, + const char *descr, + const char *vars) { SCM s = ly_symbol2scm (symbol); SCM d = scm_makfrom0str (descr); @@ -23,8 +23,6 @@ void add_interface (const char * symbol, ly_add_interface (s, d, l); } - - void check_interfaces_for_property (Grob const *me, SCM sym) { @@ -32,8 +30,8 @@ check_interfaces_for_property (Grob const *me, SCM sym) { /* otherwise we get in a nasty recursion loop. - */ - return ; + */ + return; } SCM ifs = me->get_property ("interfaces"); @@ -42,7 +40,7 @@ check_interfaces_for_property (Grob const *me, SCM sym) bool found = false; for (; !found && scm_is_pair (ifs); ifs = scm_cdr (ifs)) { - SCM iface = scm_hashq_ref (all_ifaces , scm_car (ifs), SCM_BOOL_F); + SCM iface = scm_hashq_ref (all_ifaces, scm_car (ifs), SCM_BOOL_F); if (iface == SCM_BOOL_F) { String msg = to_string (_f ("Unknown interface `%s'", diff --git a/lily/grob-pitch-tuple.cc b/lily/grob-pitch-tuple.cc index 7aa301dfd9..6f175b9cf5 100644 --- a/lily/grob-pitch-tuple.cc +++ b/lily/grob-pitch-tuple.cc @@ -1,11 +1,10 @@ -/* -grob-pitch-tuple.cc -- implement Grob_pitch_tuple - -source file of the GNU LilyPond music typesetter +/* + grob-pitch-tuple.cc -- implement Grob_pitch_tuple -(c) 2001--2005 Han-Wen Nienhuys + source file of the GNU LilyPond music typesetter - */ + (c) 2001--2005 Han-Wen Nienhuys +*/ #include "grob-pitch-tuple.hh" @@ -17,8 +16,6 @@ int compare (Grob_pitch_tuple const &a, Grob_pitch_tuple const &b) } - - Grob_pitch_tuple::Grob_pitch_tuple () { head_ = 0; @@ -33,18 +30,18 @@ Grob_pitch_tuple::Grob_pitch_tuple (Grob *h, Music *m, Moment mom) } /* - signed compare, should use pitchset_property ("busyGrobs", SCM_EOL); + context ()->set_property ("busyGrobs", SCM_EOL); } LY_DEFINE (ly_grob_pq_less_p, "ly:grob-pq-less?", - 2, 0 , 0, (SCM a, SCM b), - "Compare 2 grob priority queue entries. Internal") + 2, 0, 0, (SCM a, SCM b), + "Compare 2 grob priority queue entries. Internal") { if (Moment::compare (*unsmob_moment (scm_car (a)), *unsmob_moment (scm_car (b))) < 0) @@ -43,11 +42,11 @@ LY_DEFINE (ly_grob_pq_less_p, "ly:grob-pq-less?", else return SCM_BOOL_F; } - + void Grob_pq_engraver::acknowledge_grob (Grob_info gi) { - Music * m = gi.music_cause (); + Music *m = gi.music_cause (); if (m && !gi.grob_->internal_has_interface (ly_symbol2scm ("multi-measure-interface"))) @@ -56,8 +55,8 @@ Grob_pq_engraver::acknowledge_grob (Grob_info gi) Moment l = m->get_length (); if (!l.to_bool ()) - return ; - + return; + if (n.grace_part_) { l.grace_part_ = l.main_part_; @@ -66,8 +65,8 @@ Grob_pq_engraver::acknowledge_grob (Grob_info gi) Moment end = n + l; SCM lst = scm_acons (end.smobbed_copy (), - gi.grob_->self_scm (), - SCM_EOL); + gi.grob_->self_scm (), + SCM_EOL); SCM busy = get_property ("busyGrobs"); busy = scm_merge_x (lst, busy, ly_grob_pq_less_p_proc); @@ -75,7 +74,6 @@ Grob_pq_engraver::acknowledge_grob (Grob_info gi) } } - void Grob_pq_engraver::stop_translation_timestep () { @@ -103,7 +101,7 @@ Grob_pq_engraver::start_translation_timestep () /* The grob-pq-engraver is not water tight, and stuff like tupletSpannerDuration confuses it. - */ + */ busy = scm_cdr (busy); } @@ -111,16 +109,15 @@ Grob_pq_engraver::start_translation_timestep () context ()->set_property ("busyGrobs", busy); } - ADD_TRANSLATOR (Grob_pq_engraver, -/* descr */ "Administrate when certain grobs (eg. note heads) stop playing; this \ + /* descr */ "Administrate when certain grobs (eg. note heads) stop playing; this \ engraver is a sort-of a failure, since it doesn't handle all sorts of \ borderline cases very well. \ -", \ - -/* creats*/ "", \ -/* accepts */ "", \ -/* acks */ "grob-interface", \ -/* reads */ "busyGrobs", \ -/* write */ "busyGrobs"); +", + + /* creats*/ "",\ + /* accepts */ "",\ + /* acks */ "grob-interface",\ + /* reads */ "busyGrobs",\ + /* write */ "busyGrobs"); diff --git a/lily/grob-property.cc b/lily/grob-property.cc index d912621dac..67401f226e 100644 --- a/lily/grob-property.cc +++ b/lily/grob-property.cc @@ -1,6 +1,6 @@ /* Implement storage and manipulation of grob properties. - */ +*/ #include #include @@ -16,7 +16,6 @@ #include "misc.hh" #include "item.hh" - SCM Grob::get_property_alist_chain (SCM def) const { @@ -26,21 +25,18 @@ Grob::get_property_alist_chain (SCM def) const SCM_UNDEFINED); } - - /* This special add_thing routine is slightly more efficient than - set_prop (name, cons (thing, get_prop (name))) + set_prop (name, cons (thing, get_prop (name))) since it can reuse the handle returned by scm_assq (). */ void -Grob::add_to_list_property (SCM sym, SCM thing) +Grob::add_to_list_property (SCM sym, SCM thing) { SCM handle - = scm_sloppy_assq (sym, mutable_property_alist_) - ; + = scm_sloppy_assq (sym, mutable_property_alist_); if (handle != SCM_BOOL_F) { @@ -57,11 +53,10 @@ Grob::add_to_list_property (SCM sym, SCM thing) SCM val = scm_cons (thing, tail); mutable_property_alist_ = scm_cons (scm_cons (sym, val), - mutable_property_alist_); + mutable_property_alist_); } } - extern void check_interfaces_for_property (Grob const *me, SCM sym); void @@ -81,7 +76,6 @@ Grob::internal_set_property (SCM s, SCM v) mutable_property_alist_ = scm_assq_set_x (mutable_property_alist_, s, v); } - SCM Grob::internal_get_property (SCM sym) const { @@ -90,7 +84,7 @@ Grob::internal_get_property (SCM sym) const return scm_cdr (s); s = scm_sloppy_assq (sym, immutable_property_alist_); - + if (do_internal_type_checking_global && scm_is_pair (s)) { if (!type_check_assignment (sym, scm_cdr (s), @@ -100,7 +94,7 @@ Grob::internal_get_property (SCM sym) const check_interfaces_for_property (this, sym); } - return (s == SCM_BOOL_F) ? SCM_EOL : scm_cdr (s); + return (s == SCM_BOOL_F) ? SCM_EOL : scm_cdr (s); } void @@ -110,7 +104,6 @@ Grob::substitute_mutable_properties (SCM crit, SCM orig) mutable_property_alist_ = substitute_mutable_property_alist (orig); } - bool Grob::is_live () const { diff --git a/lily/grob-scheme.cc b/lily/grob-scheme.cc index 309f086dac..d892e6c443 100644 --- a/lily/grob-scheme.cc +++ b/lily/grob-scheme.cc @@ -4,7 +4,7 @@ source file of the GNU LilyPond music typesetter (c) 1998--2005 Jan Nieuwenhuizen - Han-Wen Nienhuys + Han-Wen Nienhuys */ #include "warn.hh" @@ -29,11 +29,10 @@ LY_DEFINE (ly_grob_set_property_x, "ly:grob-set-property!", LY_DEFINE (ly_grob_property, "ly:grob-property", 2, 0, 0, (SCM grob, SCM sym), - "Return the value of a value in grob @var{g} of property @var{sym}. " + "Return the value of a value in grob @var{g} of property @var{sym}. " "It will return @code{' ()} (end-of-list) " "if @var{sym} is undefined in @var{g}." - "\n\n" - ) + "\n\n") { Grob *sc = unsmob_grob (grob); SCM_ASSERT_TYPE (sc, grob, SCM_ARG1, __FUNCTION__, "grob"); @@ -47,7 +46,7 @@ LY_DEFINE (ly_spanner_get_bound, "ly:spanner-get-bound", "Get one of the bounds of @var{spanner}. @var{dir} is @code{-1} " "for left, and @code{1} for right.") { - Spanner * sl = dynamic_cast (unsmob_grob (slur)); + Spanner *sl = dynamic_cast (unsmob_grob (slur)); SCM_ASSERT_TYPE (sl, slur, SCM_ARG1, __FUNCTION__, "spanner grob"); SCM_ASSERT_TYPE (is_direction (dir), slur, SCM_ARG2, __FUNCTION__, "dir"); return sl->get_bound (to_dir (dir))->self_scm (); @@ -59,7 +58,7 @@ LY_DEFINE (ly_grob_layout, "ly:grob-layout", 1, 0, 0, (SCM g), "Get @code{\\layout} definition from grob @var{g}.") { - Grob * sc = unsmob_grob (g); + Grob *sc = unsmob_grob (g); SCM_ASSERT_TYPE (sc, g, SCM_ARG1, __FUNCTION__, "grob"); return sc->get_layout ()->self_scm (); @@ -92,7 +91,7 @@ LY_DEFINE (ly_get_extent, "ly:grob-extent", SCM_ASSERT_TYPE (ref, refp, SCM_ARG2, __FUNCTION__, "grob"); SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG3, __FUNCTION__, "axis"); - return ly_interval2scm ( sc->extent (ref, Axis (scm_to_int (axis)))); + return ly_interval2scm (sc->extent (ref, Axis (scm_to_int (axis)))); } LY_DEFINE (ly_grob_parent, "ly:grob-parent", @@ -158,7 +157,7 @@ LY_DEFINE (ly_spanner_broken_into, "ly:spanner-broken-into", 1, 0, 0, (SCM spanner), "Return broken-into list for @var{spanner}.") { - Spanner *me = dynamic_cast (unsmob_grob (spanner)); + Spanner *me = dynamic_cast (unsmob_grob (spanner)); SCM_ASSERT_TYPE (me, spanner, SCM_ARG1, __FUNCTION__, "spanner"); SCM s = SCM_EOL; @@ -196,7 +195,7 @@ LY_DEFINE (ly_spanner_p, "ly:spanner?", "Is @var{g} a spanner object?") { Grob *me = unsmob_grob (g); - bool b = dynamic_cast (me); + bool b = dynamic_cast (me); return ly_bool2scm (b); } @@ -206,7 +205,7 @@ LY_DEFINE (ly_item_p, "ly:item?", "Is @var{g} an @code{Item} object?") { Grob *me = unsmob_grob (g); - bool b = dynamic_cast (me); + bool b = dynamic_cast (me); return ly_bool2scm (b); } @@ -215,17 +214,15 @@ LY_DEFINE (ly_item_break_dir, "ly:item-break-dir", "The break status dir of item @var{it}. @code{-1} is end of " "line, @code{0} unbroken, and @code{1} begin of line.") { - Item *me = dynamic_cast (unsmob_grob (it)); + Item *me = dynamic_cast (unsmob_grob (it)); SCM_ASSERT_TYPE (me, it, SCM_ARG1, __FUNCTION__, "Item"); return scm_int2num (me->break_status_dir ()); } - -LY_DEFINE(ly_grob_key, "ly:grob-key", - 1, 0, 0, - (SCM grob), - "Return the object-key for @var{grob}." - ) +LY_DEFINE (ly_grob_key, "ly:grob-key", + 1, 0, 0, + (SCM grob), + "Return the object-key for @var{grob}.") { Grob *me = unsmob_grob (grob); SCM_ASSERT_TYPE (me, grob, SCM_ARG1, __FUNCTION__, "Grob"); diff --git a/lily/grob.cc b/lily/grob.cc index 2ca648430c..0594582d79 100644 --- a/lily/grob.cc +++ b/lily/grob.cc @@ -28,7 +28,7 @@ #include "ly-smobs.icc" -Grob * +Grob * Grob::clone (int count) const { return new Grob (*this, count); @@ -36,14 +36,14 @@ Grob::clone (int count) const /* TODO: - - remove dynamic_cast and put this code into respective - subclass. */ +- remove dynamic_cast and put this code into respective +subclass. */ #define HASH_SIZE 3 #define INFINITY_MSG "Infinity or NaN encountered" Grob::Grob (SCM basicprops, - Object_key const* key) + Object_key const *key) { key_ = key; /* FIXME: default should be no callback. */ @@ -51,7 +51,7 @@ Grob::Grob (SCM basicprops, pscore_ = 0; status_ = 0; original_ = 0; - immutable_property_alist_ = basicprops; + immutable_property_alist_ = basicprops; mutable_property_alist_ = SCM_EOL; /* We do smobify_self () as the first step. Since the object lives @@ -61,7 +61,7 @@ Grob::Grob (SCM basicprops, /* We always get a new key object for a new grob. - */ + */ scm_gc_unprotect_object (key_->self_scm ()); SCM meta = get_property ("meta"); if (scm_is_pair (meta)) @@ -77,14 +77,14 @@ Grob::Grob (SCM basicprops, /* TODO: - - destill this into a function, so we can re-init the immutable - properties with a new BASICPROPS value after - creation. Convenient eg. when using \override with - StaffSymbol. */ + - destill this into a function, so we can re-init the immutable + properties with a new BASICPROPS value after + creation. Convenient eg. when using \override with + StaffSymbol. */ - char const*onames[] = {"X-offset-callbacks", "Y-offset-callbacks"}; - char const*xnames[] = {"X-extent", "Y-extent"}; - char const*enames[] = {"X-extent-callback", "Y-extent-callback"}; + char const *onames[] = {"X-offset-callbacks", "Y-offset-callbacks"}; + char const *xnames[] = {"X-extent", "Y-extent"}; + char const *enames[] = {"X-extent-callback", "Y-extent-callback"}; for (int a = X_AXIS; a <= Y_AXIS; a++) { @@ -103,7 +103,7 @@ Grob::Grob (SCM basicprops, { dim_cache_[a].dimension_ = SCM_BOOL_F; } - + SCM xt = get_property (xnames[a]); if (is_number_pair (xt)) { @@ -120,10 +120,10 @@ Grob::Grob (SCM basicprops, } Grob::Grob (Grob const &s, int copy_index) - : dim_cache_ (s.dim_cache_) + : dim_cache_ (s.dim_cache_) { key_ = new Copied_key (s.key_, copy_index); - original_ = (Grob*) &s; + original_ = (Grob *) &s; self_scm_ = SCM_EOL; immutable_property_alist_ = s.immutable_property_alist_; @@ -156,26 +156,24 @@ Grob::stencil_extent (SCM element_smob, SCM scm_axis) return ly_interval2scm (e); } - Interval -robust_relative_extent (Grob*me, Grob*refp, Axis a) +robust_relative_extent (Grob *me, Grob *refp, Axis a) { - Interval ext = me->extent (refp, a); - if (ext.is_empty()) + Interval ext = me->extent (refp, a); + if (ext.is_empty ()) { ext.add_point (me->relative_coordinate (refp, a)); } - return ext; + return ext; } Output_def * Grob::get_layout () const { - return pscore_ ? pscore_->layout_ : 0; + return pscore_ ? pscore_->layout_ : 0; } - /* Recursively track all dependencies of this Grob. The status_ field is used as a mark-field. It is marked with BUSY during execution of this function, and marked with FINAL when finished. @@ -207,7 +205,7 @@ Grob::calculate_dependencies (int final, int busy, SCM funcname) } Stencil * -Grob::get_stencil () const +Grob::get_stencil () const { if (!is_live ()) return 0; @@ -219,7 +217,7 @@ Grob::get_stencil () const stil = get_uncached_stencil (); if (is_live ()) { - Grob *me = (Grob*) this; + Grob *me = (Grob *) this; me->set_property ("stencil", stil); } @@ -236,12 +234,12 @@ Grob::get_uncached_stencil () const stil = scm_apply_0 (proc, scm_list_n (this->self_scm (), SCM_UNDEFINED)); if (Stencil *m = unsmob_stencil (stil)) - { + { if (to_boolean (get_property ("transparent"))) stil = Stencil (m->extent_box (), SCM_EOL).smobbed_copy (); else { - SCM expr = scm_list_3 (ly_symbol2scm ("grob-cause"), self_scm(), + SCM expr = scm_list_3 (ly_symbol2scm ("grob-cause"), self_scm (), m->expr ()); stil = Stencil (m->extent_box (), expr). smobbed_copy (); } @@ -255,16 +253,16 @@ Grob::get_uncached_stencil () const color, m->expr ()); - stil = Stencil (m->extent_box (), expr).smobbed_copy(); + stil = Stencil (m->extent_box (), expr).smobbed_copy (); } - } + } return stil; } /* VIRTUAL STUBS - */ +*/ void Grob::do_break_processing () { @@ -289,7 +287,7 @@ Grob::add_dependency (Grob *e) void Grob::handle_broken_dependencies () { - Spanner *sp = dynamic_cast (this); + Spanner *sp = dynamic_cast (this); if (original_ && sp) return; @@ -308,7 +306,7 @@ Grob::handle_broken_dependencies () substitute_mutable_properties (system ? system->self_scm () : SCM_UNDEFINED, mutable_property_alist_); - else if (dynamic_cast (this)) + else if (dynamic_cast (this)) substitute_mutable_properties (SCM_UNDEFINED, mutable_property_alist_); else /* THIS element is `invalid'; it has been removed from all @@ -353,7 +351,7 @@ Grob::handle_prebroken_dependencies () mutable_property_alist_ centralized. */ if (original_) { - Item *it = dynamic_cast (this); + Item *it = dynamic_cast (this); substitute_mutable_properties (scm_int2num (it->break_status_dir ()), original_->mutable_property_alist_); } @@ -375,7 +373,6 @@ Grob::translate_axis (Real y, Axis a) dim_cache_[a].offset_ += y; } - /* Find the offset relative to D. If D equals THIS, then it is 0. Otherwise, it recursively defd as @@ -398,14 +395,14 @@ Grob::relative_coordinate (Grob const *refp, Axis a) const Real Grob::get_offset (Axis a) const { - Grob *me = (Grob*) this; + Grob *me = (Grob *) this; while (dim_cache_[a].offsets_left_) { int l = --me->dim_cache_[a].offsets_left_; SCM cb = scm_list_ref (dim_cache_[a].offset_callbacks_, scm_int2num (l)); SCM retval = scm_call_2 (cb, self_scm (), scm_int2num (a)); - Real r = scm_to_double (retval); + Real r = scm_to_double (retval); if (isinf (r) || isnan (r)) { programming_error (INFINITY_MSG); @@ -426,15 +423,14 @@ Grob::is_empty (Axis a) const void Grob::flush_extent_cache (Axis axis) { - Dimension_cache * d = &dim_cache_[axis]; + Dimension_cache *d = &dim_cache_[axis]; if (ly_c_procedure_p (d->dimension_callback_) && scm_is_pair (d->dimension_)) { d->dimension_ = SCM_EOL; - if (get_parent (axis)) - get_parent(axis)->flush_extent_cache (axis); + get_parent (axis)->flush_extent_cache (axis); } } @@ -447,8 +443,7 @@ Grob::extent (Grob *refp, Axis a) const Interval ext; SCM dimpair = d->dimension_; - if (scm_is_pair (dimpair)) - ; + if (scm_is_pair (dimpair)); else if (ly_c_procedure_p (d->dimension_callback_) && d->dimension_ == SCM_EOL) d->dimension_ = scm_call_2 (d->dimension_callback_, self_scm (), scm_int2num (a)); @@ -493,7 +488,7 @@ Grob::common_refpoint (Grob const *s, Axis a) const for (Grob const *c = this; c; c = c->dim_cache_[a].parent_) for (Grob const *d = s; d; d = d->dim_cache_[a].parent_) if (d == c) - return (Grob*) d; + return (Grob *) d; return 0; } @@ -516,7 +511,7 @@ common_refpoint_of_list (SCM elist, Grob *common, Axis a) Grob * common_refpoint_of_array (Link_array const &arr, Grob *common, Axis a) { - for (int i = arr.size (); i--; ) + for (int i = arr.size (); i--;) if (Grob *s = arr[i]) { if (common) @@ -541,11 +536,11 @@ void Grob::add_offset_callback (SCM cb, Axis a) { if (!has_offset_callback (cb, a)) - { - dim_cache_[a].offset_callbacks_ - = scm_cons (cb, dim_cache_[a].offset_callbacks_); - dim_cache_[a].offsets_left_ ++; - } + { + dim_cache_[a].offset_callbacks_ + = scm_cons (cb, dim_cache_[a].offset_callbacks_); + dim_cache_[a].offsets_left_++; + } } bool @@ -583,7 +578,7 @@ SCM Grob::fixup_refpoint (SCM smob) { Grob *me = unsmob_grob (smob); - for (int a = X_AXIS; a < NO_AXES; a ++) + for (int a = X_AXIS; a < NO_AXES; a++) { Axis ax = (Axis)a; Grob *parent = me->get_parent (ax); @@ -597,13 +592,13 @@ Grob::fixup_refpoint (SCM smob) me->set_parent (newparent, ax); } - if (Item *i = dynamic_cast (me)) + if (Item *i = dynamic_cast (me)) { - Item *parenti = dynamic_cast (parent); + Item *parenti = dynamic_cast (parent); if (parenti && i) { - Direction my_dir = i->break_status_dir () ; + Direction my_dir = i->break_status_dir (); if (my_dir!= parenti->break_status_dir ()) { Item *newparent = parenti->find_prebroken_piece (my_dir); @@ -635,10 +630,9 @@ Grob::programming_error (String s) const warning (s); } - /**************************************************** SMOB funcs - ****************************************************/ +****************************************************/ IMPLEMENT_SMOBS (Grob); IMPLEMENT_DEFAULT_EQUAL_P (Grob); @@ -646,10 +640,10 @@ IMPLEMENT_DEFAULT_EQUAL_P (Grob); SCM Grob::mark_smob (SCM ses) { - Grob *s = (Grob*) SCM_CELL_WORD_1 (ses); + Grob *s = (Grob *) SCM_CELL_WORD_1 (ses); scm_gc_mark (s->immutable_property_alist_); scm_gc_mark (s->key_->self_scm ()); - for (int a = 0 ; a < 2; a++) + for (int a = 0; a < 2; a++) { scm_gc_mark (s->dim_cache_[a].offset_callbacks_); scm_gc_mark (s->dim_cache_[a].dimension_); @@ -702,13 +696,12 @@ Grob::internal_has_interface (SCM k) return scm_c_memq (k, ifs) != SCM_BOOL_F; } -Grob* +Grob * Grob::get_parent (Axis a) const { return dim_cache_[a].parent_; } - /** Return Array of Grobs in SCM list LST */ Link_array ly_scm2grobs (SCM lst) @@ -737,34 +730,33 @@ ly_grobs2scm (Link_array a) { SCM s = SCM_EOL; for (int i = a.size (); i; i--) - s = scm_cons (a[i-1]->self_scm (), s); + s = scm_cons (a[i - 1]->self_scm (), s); return s; } - IMPLEMENT_TYPE_P (Grob, "ly:grob?"); ADD_INTERFACE (Grob, "grob-interface", "A grob represents a piece of music notation\n" "\n" -"All grobs have an X and Y-position on the page. These X and Y positions\n" -"are stored in a relative format, so they can easily be combined by\n" -"stacking them, hanging one grob to the side of another, and coupling\n" -"them into a grouping objects.\n" -"\n" -"Each grob has a reference point (a.k.a. parent): the position of a grob\n" -"is stored relative to that reference point. For example the X-reference\n" -"point of a staccato dot usually is the note head that it applies\n" -"to. When the note head is moved, the staccato dot moves along\n" -"automatically.\n" -"\n" -"A grob is often associated with a symbol, but some grobs do not print\n" -"any symbols. They take care of grouping objects. For example, there is a\n" -"separate grob that stacks staves vertically. The @ref{NoteCollision}\n" -"is also an abstract grob: it only moves around chords, but doesn't print\n" -"anything.\n" -"\n" + "All grobs have an X and Y-position on the page. These X and Y positions\n" + "are stored in a relative format, so they can easily be combined by\n" + "stacking them, hanging one grob to the side of another, and coupling\n" + "them into a grouping objects.\n" + "\n" + "Each grob has a reference point (a.k.a. parent): the position of a grob\n" + "is stored relative to that reference point. For example the X-reference\n" + "point of a staccato dot usually is the note head that it applies\n" + "to. When the note head is moved, the staccato dot moves along\n" + "automatically.\n" + "\n" + "A grob is often associated with a symbol, but some grobs do not print\n" + "any symbols. They take care of grouping objects. For example, there is a\n" + "separate grob that stacks staves vertically. The @ref{NoteCollision}\n" + "is also an abstract grob: it only moves around chords, but doesn't print\n" + "anything.\n" + "\n" "Grobs have a properties: Scheme variables, that can be read and set. " "They have two types. Immutable variables " "define the default style and behavior. They are shared between many objects. " @@ -773,9 +765,7 @@ ADD_INTERFACE (Grob, "grob-interface", "Mutable properties are variables that are specific to one grob. Typically, " "lists of other objects, or results from computations are stored in" "mutable properties: every call to set-grob-property (or its C++ equivalent) " - "sets a mutable property. " - -, + "sets a mutable property. ", "X-offset-callbacks Y-offset-callbacks X-extent-callback stencil cause " "Y-extent-callback print-function extra-offset spacing-procedure " "context staff-symbol interfaces dependencies X-extent Y-extent extra-X-extent " @@ -784,8 +774,5 @@ ADD_INTERFACE (Grob, "grob-interface", "axis-group-parent-X " "axis-group-parent-Y " "after-line-breaking-callback extra-Y-extent minimum-X-extent " - "minimum-Y-extent transparent tweak-count tweak-rank" - ); - - + "minimum-Y-extent transparent tweak-count tweak-rank"); diff --git a/lily/group-interface.cc b/lily/group-interface.cc index eccb1210da..9fbd329e7c 100644 --- a/lily/group-interface.cc +++ b/lily/group-interface.cc @@ -1,37 +1,32 @@ -/* +/* group-interface.cc -- implement Group_interface - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - - */ +*/ #include "group-interface.hh" #include "item.hh" void -Group_interface::add_thing (Grob*me, SCM sym, SCM thing) +Group_interface::add_thing (Grob *me, SCM sym, SCM thing) { me->add_to_list_property (sym, thing); } - int Group_interface::count (Grob *me, SCM sym) { return scm_ilength (me->internal_get_property (sym)); } - void -Pointer_group_interface::add_grob (Grob*me, SCM name, Grob*p) +Pointer_group_interface::add_grob (Grob *me, SCM name, Grob *p) { Group_interface::add_thing (me, name, p->self_scm ()); } - - Link_array extract_grob_array (Grob const *elt, SCM symbol) { @@ -47,7 +42,6 @@ extract_grob_array (Grob const *elt, SCM symbol) return arr; } - Link_array extract_item_array (Grob const *elt, SCM symbol) { @@ -55,7 +49,7 @@ extract_item_array (Grob const *elt, SCM symbol) for (SCM s = elt->internal_get_property (symbol); scm_is_pair (s); s = scm_cdr (s)) { SCM e = scm_car (s); - arr.push (dynamic_cast (unsmob_grob (e))); + arr.push (dynamic_cast (unsmob_grob (e))); } arr.reverse (); diff --git a/lily/hairpin.cc b/lily/hairpin.cc index 5e7aa98720..b3e5c6edce 100644 --- a/lily/hairpin.cc +++ b/lily/hairpin.cc @@ -22,10 +22,10 @@ MAKE_SCHEME_CALLBACK (Hairpin, print, 1); SCM -Hairpin::print (SCM smob) +Hairpin::print (SCM smob) { Grob *me = unsmob_grob (smob); - Spanner *spanner = dynamic_cast (me); + Spanner *spanner = dynamic_cast (me); SCM s = me->get_property ("grow-direction"); if (!is_direction (s)) @@ -33,12 +33,12 @@ Hairpin::print (SCM smob) me->suicide (); return SCM_EOL; } - + Direction grow_dir = to_dir (s); Real padding = robust_scm2double (me->get_property ("bound-padding"), 0.5); Drul_array broken; - Drul_array bounds ; + Drul_array bounds; Direction d = LEFT; do { @@ -48,8 +48,8 @@ Hairpin::print (SCM smob) while (flip (&d) != LEFT); Grob *common = bounds[LEFT]->common_refpoint (bounds[RIGHT], X_AXIS); - Drul_array x_points ; - + Drul_array x_points; + do { Item *b = bounds[d]; @@ -57,7 +57,7 @@ Hairpin::print (SCM smob) if (broken [d]) { if (d == LEFT) - x_points[d] = b->extent (common, X_AXIS)[RIGHT] ; + x_points[d] = b->extent (common, X_AXIS)[RIGHT]; } else { @@ -70,7 +70,7 @@ Hairpin::print (SCM smob) else { bool neighbor_found = false; - for (SCM adj = me->get_property ("adjacent-hairpins"); + for (SCM adj = me->get_property ("adjacent-hairpins"); scm_is_pair (adj); adj = scm_cdr (adj)) { /* @@ -78,28 +78,27 @@ Hairpin::print (SCM smob) notes in other voices. Need to look at note-columns in the current staff/voice. */ - + Spanner *pin = unsmob_spanner (scm_car (adj)); if (pin - && (pin->get_bound (LEFT)->get_column() == b->get_column () - || pin->get_bound (RIGHT)->get_column() == b->get_column() )) - neighbor_found = true; + && (pin->get_bound (LEFT)->get_column () == b->get_column () + || pin->get_bound (RIGHT)->get_column () == b->get_column ())) + neighbor_found = true; } - + /* If we're hung on a paper column, that means we're not adjacent to a text-dynamic, and we may move closer. We make the padding a little smaller, here. */ Interval e = robust_relative_extent (b, common, X_AXIS); - x_points[d] = - neighbor_found ? e.center() - d * padding / 3 : e[d]; + x_points[d] + = neighbor_found ? e.center () - d * padding / 3 : e[d]; } } } while (flip (&d) != LEFT); - Real width = x_points[RIGHT] - x_points[LEFT]; if (width < 0) { @@ -116,11 +115,11 @@ Hairpin::print (SCM smob) if (grow_dir < 0) { starth = height; - endh = continued ? height/2 : 0.0; + endh = continued ? height / 2 : 0.0; } else { - starth = continued ? height/2 : 0.0; + starth = continued ? height / 2 : 0.0; endh = height; } @@ -129,7 +128,7 @@ Hairpin::print (SCM smob) */ Stencil mol; - mol = Line_interface::line (me, Offset (0, starth), Offset (width, endh)); + mol = Line_interface::line (me, Offset (0, starth), Offset (width, endh)); mol.add_stencil (Line_interface::line (me, Offset (0, -starth), Offset (width, -endh))); @@ -140,9 +139,7 @@ Hairpin::print (SCM smob) return mol.smobbed_copy (); } - - ADD_INTERFACE (Hairpin, "hairpin-interface", - "A hairpin (de)crescendo.", - "grow-direction height bound-padding adjacent-hairpins"); + "A hairpin (de)crescendo.", + "grow-direction height bound-padding adjacent-hairpins"); diff --git a/lily/hara-kiri-group-spanner.cc b/lily/hara-kiri-group-spanner.cc index e5e778b9d2..c3b4d5cd98 100644 --- a/lily/hara-kiri-group-spanner.cc +++ b/lily/hara-kiri-group-spanner.cc @@ -23,37 +23,33 @@ Hara_kiri_group_spanner::y_extent (SCM element_smob, SCM scm_axis) assert (a == Y_AXIS); consider_suicide (me); - return Axis_group_interface::group_extent_callback (me->self_scm (), scm_axis); + return Axis_group_interface::group_extent_callback (me->self_scm (), scm_axis); } - void -Hara_kiri_group_spanner::consider_suicide (Grob*me) +Hara_kiri_group_spanner::consider_suicide (Grob *me) { - Spanner*sp = dynamic_cast (me); + Spanner *sp = dynamic_cast (me); SCM worth = me->get_property ("items-worth-living"); if (scm_is_pair (worth)) - return ; + return; if (!to_boolean (me->get_property ("remove-first")) && broken_spanner_index (sp) == 0) { - return ; + return; } - + Link_array childs = Axis_group_interface::get_children (me); for (int i = 0; i < childs.size (); i++) childs[i]->suicide (); - /* very appropriate name here :-) - */ + */ me->suicide (); } - - /* We can't rely on offsets and dimensions of elements in a hara-kiri group. Use a callback to make sure that hara-kiri has been done @@ -69,7 +65,6 @@ Hara_kiri_group_spanner::force_hara_kiri_callback (SCM element_smob, SCM axis) return scm_make_real (0.0); } - MAKE_SCHEME_CALLBACK (Hara_kiri_group_spanner, force_hara_kiri_in_parent_callback, 2); SCM Hara_kiri_group_spanner::force_hara_kiri_in_parent_callback (SCM element_smob, SCM axis) @@ -82,28 +77,23 @@ Hara_kiri_group_spanner::force_hara_kiri_in_parent_callback (SCM element_smob, S } void -Hara_kiri_group_spanner::add_element (Grob * me, Grob *e) +Hara_kiri_group_spanner::add_element (Grob *me, Grob *e) { // e->add_offset_callback (force_hara_kiri_in_parent_callback, Y_AXIS); Axis_group_interface::add_element (me, e); } - - - -void -Hara_kiri_group_spanner::add_interesting_item (Grob* me, Grob* n) +void +Hara_kiri_group_spanner::add_interesting_item (Grob *me, Grob *n) { me->add_dependency (n); Pointer_group_interface::add_grob (me, ly_symbol2scm ("items-worth-living"), n); } - ADD_INTERFACE (Hara_kiri_group_spanner, "hara-kiri-group-interface", "A group spanner that keeps track of interesting items. If it " "doesn't contain any after linebreaking, then it " - "will remove itself and all its children." - , + "will remove itself and all its children.", "items-worth-living remove-first"); diff --git a/lily/horizontal-bracket-engraver.cc b/lily/horizontal-bracket-engraver.cc index 748871f583..232c3e9aec 100644 --- a/lily/horizontal-bracket-engraver.cc +++ b/lily/horizontal-bracket-engraver.cc @@ -1,12 +1,11 @@ -/* +/* horizontal-bracket-engraver.cc -- implement - Horizontal_bracket_engraver + Horizontal_bracket_engraver -source file of the GNU LilyPond music typesetter + source file of the GNU LilyPond music typesetter -(c) 2002--2005 Han-Wen Nienhuys - - */ + (c) 2002--2005 Han-Wen Nienhuys +*/ #include "engraver.hh" #include "side-position-interface.hh" @@ -22,19 +21,19 @@ public: int pop_count_; int push_count_; - virtual bool try_music (Music*); + virtual bool try_music (Music *); virtual void stop_translation_timestep (); - virtual void process_music (); - virtual void acknowledge_grob (Grob_info); + virtual void process_music (); + virtual void acknowledge_grob (Grob_info); }; ADD_TRANSLATOR (Horizontal_bracket_engraver, - "Create horizontal brackets over notes for musical analysis purposes.", - "HorizontalBracket", - "note-grouping-event", - "note-column-interface", - "", - ""); + "Create horizontal brackets over notes for musical analysis purposes.", + "HorizontalBracket", + "note-grouping-event", + "note-column-interface", + "", + ""); Horizontal_bracket_engraver::Horizontal_bracket_engraver () { @@ -42,28 +41,27 @@ Horizontal_bracket_engraver::Horizontal_bracket_engraver () push_count_ = 0; } - bool Horizontal_bracket_engraver::try_music (Music *m) { if (m->is_mus_type ("note-grouping-event")) { Direction d = to_dir (m->get_property ("span-direction")); - + if (d == STOP) { - pop_count_ ++; + pop_count_++; if (pop_count_ > bracket_stack_.size ()) - m->origin ()->warning (_("Don't have that many brackets.")); + m->origin ()->warning (_ ("Don't have that many brackets.")); } else { push_count_++; events_.push (m); } - + if (pop_count_ && push_count_) - m->origin ()->warning (_("Conflicting note group events.")); + m->origin ()->warning (_ ("Conflicting note group events.")); return true; } @@ -75,13 +73,13 @@ Horizontal_bracket_engraver::acknowledge_grob (Grob_info gi) { if (Note_column::has_interface (gi.grob_)) { - for (int i = 0; i < bracket_stack_.size (); i++) + for (int i = 0; i < bracket_stack_.size (); i++) { Side_position_interface::add_support (bracket_stack_[i], gi.grob_); Pointer_group_interface::add_grob (bracket_stack_[i], ly_symbol2scm ("columns"), gi.grob_); add_bound_item (bracket_stack_[i], - gi.grob_); + gi.grob_); } } } @@ -89,22 +87,21 @@ Horizontal_bracket_engraver::acknowledge_grob (Grob_info gi) void Horizontal_bracket_engraver::process_music () { - for (int k = 0; k < push_count_; k++) + for (int k = 0; k < push_count_; k++) { - Spanner * sp = make_spanner ("HorizontalBracket", events_[k]->self_scm ()); + Spanner *sp = make_spanner ("HorizontalBracket", events_[k]->self_scm ()); for (int i = 0; i < bracket_stack_.size (); i++) { /* sp is the smallest, it should be added to the bigger brackets. - */ + */ Side_position_interface::add_support (bracket_stack_[i], sp); } bracket_stack_.push (sp); } } - void Horizontal_bracket_engraver::stop_translation_timestep () { @@ -117,4 +114,3 @@ Horizontal_bracket_engraver::stop_translation_timestep () push_count_ = 0; } - diff --git a/lily/horizontal-bracket.cc b/lily/horizontal-bracket.cc index 1abe992ae4..654a1e0015 100644 --- a/lily/horizontal-bracket.cc +++ b/lily/horizontal-bracket.cc @@ -1,11 +1,10 @@ -/* +/* horizontal-bracket.cc -- implement Horizontal_bracket source file of the GNU LilyPond music typesetter -(c) 2002--2005 Han-Wen Nienhuys - - */ + (c) 2002--2005 Han-Wen Nienhuys +*/ #include "side-position-interface.hh" #include "lookup.hh" @@ -18,10 +17,9 @@ struct Horizontal_bracket { DECLARE_SCHEME_CALLBACK (print, (SCM)); - static bool has_interface (Grob*); + static bool has_interface (Grob *); }; - /* TODO: @@ -34,8 +32,8 @@ MAKE_SCHEME_CALLBACK (Horizontal_bracket, print, 1); SCM Horizontal_bracket::print (SCM smob) { - Grob * me = unsmob_grob (smob); - Spanner *sp = dynamic_cast (me); + Grob *me = unsmob_grob (smob); + Spanner *sp = dynamic_cast (me); Link_array gs = extract_grob_array (me, ly_symbol2scm ("columns")); if (!gs.size ()) @@ -43,7 +41,7 @@ Horizontal_bracket::print (SCM smob) me->suicide (); return SCM_EOL; } - Grob * cx = common_refpoint_of_array (gs, me, X_AXIS); + Grob *cx = common_refpoint_of_array (gs, me, X_AXIS); cx = cx->common_refpoint (sp->get_bound (LEFT), X_AXIS); cx = cx->common_refpoint (sp->get_bound (RIGHT), X_AXIS); @@ -53,7 +51,6 @@ Horizontal_bracket::print (SCM smob) Drul_array edge_height = robust_scm2interval (me->get_property ("edge-height"), Interval (1.0, 1.0)); - Drul_array flare = robust_scm2interval (me->get_property ("bracket-flare"), Interval (0, 0)); @@ -64,13 +61,13 @@ Horizontal_bracket::print (SCM smob) Stencil b = Tuplet_bracket::make_bracket (me, Y_AXIS, Offset (ext.length (), 0), edge_height, empty, flare, shorten); - + b.translate_axis (ext[LEFT] - sp->get_bound (LEFT)->relative_coordinate (cx, X_AXIS), X_AXIS); - return b.smobbed_copy (); + return b.smobbed_copy (); } ADD_INTERFACE (Horizontal_bracket, "horizontal-bracket-interface", - "A horizontal bracket encompassing notes.", - "columns bracket-flare shorten-pair edge-height"); + "A horizontal bracket encompassing notes.", + "columns bracket-flare shorten-pair edge-height"); diff --git a/lily/hyphen-engraver.cc b/lily/hyphen-engraver.cc index 4e12f6d533..aa647816ba 100644 --- a/lily/hyphen-engraver.cc +++ b/lily/hyphen-engraver.cc @@ -2,10 +2,10 @@ hyphen-engraver.cc -- implement Hyphen_engraver source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Glen Prideaux , - Han-Wen Nienhuys , - Jan Nieuwenhuizen + Han-Wen Nienhuys , + Jan Nieuwenhuizen */ #include "warn.hh" @@ -17,14 +17,14 @@ class Hyphen_engraver : public Engraver { Music *ev_; Spanner *hyphen_; - Spanner *finished_hyphen_; + Spanner *finished_hyphen_; public: TRANSLATOR_DECLARATIONS (Hyphen_engraver); protected: virtual void acknowledge_grob (Grob_info); virtual void finalize (); - virtual bool try_music (Music*); + virtual bool try_music (Music *); virtual void stop_translation_timestep (); virtual void process_music (); private: @@ -32,8 +32,6 @@ private: }; - - Hyphen_engraver::Hyphen_engraver () { hyphen_ = 0; @@ -44,7 +42,7 @@ Hyphen_engraver::Hyphen_engraver () void Hyphen_engraver::acknowledge_grob (Grob_info i) { - Item * item = dynamic_cast (i.grob_); + Item *item = dynamic_cast (i.grob_); // -> Text_item if (item && item->internal_has_interface (ly_symbol2scm ("lyric-syllable-interface"))) { @@ -56,9 +54,8 @@ Hyphen_engraver::acknowledge_grob (Grob_info i) } } - bool -Hyphen_engraver::try_music (Music* r) +Hyphen_engraver::try_music (Music *r) { if (ev_) return false; @@ -68,22 +65,20 @@ Hyphen_engraver::try_music (Music* r) } void -completize_hyphen (Spanner* sp) +completize_hyphen (Spanner *sp) { if (!sp->get_bound (RIGHT)) { SCM heads = sp->get_property ("heads"); if (scm_is_pair (heads)) { - Item* it = dynamic_cast (unsmob_grob (scm_car (heads))); + Item *it = dynamic_cast (unsmob_grob (scm_car (heads))); if (it) sp->set_bound (RIGHT, it); } } } - - void Hyphen_engraver::finalize () { @@ -106,7 +101,7 @@ Hyphen_engraver::finalize () if (!finished_hyphen_->get_bound (RIGHT)) { - finished_hyphen_->warning (_("unterminated hyphen; removing")); + finished_hyphen_->warning (_ ("unterminated hyphen; removing")); finished_hyphen_->suicide (); } finished_hyphen_ = 0; @@ -118,12 +113,10 @@ Hyphen_engraver::process_music () { if (ev_) { - hyphen_ = make_spanner ("LyricHyphen", ev_->self_scm () -); + hyphen_ = make_spanner ("LyricHyphen", ev_->self_scm ()); } } - void Hyphen_engraver::stop_translation_timestep () { @@ -137,7 +130,7 @@ Hyphen_engraver::stop_translation_timestep () programming_error ("Haven't finished hyphen yet."); finished_hyphen_ = 0; } - + if (hyphen_) finished_hyphen_ = hyphen_; hyphen_ = 0; @@ -146,12 +139,10 @@ Hyphen_engraver::stop_translation_timestep () } - - ADD_TRANSLATOR (Hyphen_engraver, -/* descr */ "Create lyric hyphens", -/* creats*/ "LyricHyphen", -/* accepts */ "hyphen-event", -/* acks */ "lyric-syllable-interface", -/* reads */ "", -/* write */ ""); + /* descr */ "Create lyric hyphens", + /* creats*/ "LyricHyphen", + /* accepts */ "hyphen-event", + /* acks */ "lyric-syllable-interface", + /* reads */ "", + /* write */ ""); diff --git a/lily/identifier-smob.cc b/lily/identifier-smob.cc index 51803ce10f..fc5fb17f4f 100644 --- a/lily/identifier-smob.cc +++ b/lily/identifier-smob.cc @@ -39,7 +39,7 @@ unpack_identifier (SCM box) { if (SCM_IMP (box) || SCM_CELL_TYPE (box) != package_tag) return SCM_UNDEFINED; - + return SCM_CELL_OBJECT_1 (box); } @@ -51,4 +51,4 @@ init_box_type (void) scm_set_smob_print (package_tag, print_box); } -ADD_SCM_INIT_FUNC (package, init_box_type); +ADD_SCM_INIT_FUNC (package, init_box_type); diff --git a/lily/includable-lexer.cc b/lily/includable-lexer.cc index 73fe726ee4..2f5280de61 100644 --- a/lily/includable-lexer.cc +++ b/lily/includable-lexer.cc @@ -22,14 +22,14 @@ #endif #ifndef YY_START -#define YY_START\ - ((yy_start - 1) / 2) +#define YY_START \ + ((yy_start - 1) / 2) #define YYSTATE YY_START #endif /* Flex >= 2.5.29 has include stack; but we don't use that yet. */ #if !HAVE_FLEXLEXER_YY_CURRENT_BUFFER -#define yy_current_buffer \ +#define yy_current_buffer \ (yy_buffer_stack != 0 ? yy_buffer_stack[yy_buffer_stack_top] : 0) #endif @@ -50,7 +50,7 @@ Includable_lexer::new_input (String name, Sources *sources) LexerError (_ ("include files are not allowed in safe mode").to_str0 ()); return; } - + Source_file *file = sources->get_file (name); if (!file) { @@ -70,13 +70,13 @@ Includable_lexer::new_input (String name, Sources *sources) if (be_verbose_global) progress_indication (String ("[") + name); - + include_stack_.push (file); /* Ugh. We'd want to create a buffer from the bytes directly. - Whoops. The size argument to yy_create_buffer is not the - filelength but a BUFFERSIZE. Maybe this is why reading stdin fucks up. */ + Whoops. The size argument to yy_create_buffer is not the + filelength but a BUFFERSIZE. Maybe this is why reading stdin fucks up. */ yy_switch_to_buffer (yy_create_buffer (file->get_istream (), YY_BUF_SIZE)); } @@ -99,8 +99,8 @@ Includable_lexer::new_input (String name, String data, Sources *sources) } /** pop the inputstack. conceptually this is a destructor, but it - does not destruct the Source_file that Includable_lexer::new_input - creates. */ + does not destruct the Source_file that Includable_lexer::new_input + creates. */ bool Includable_lexer::close_input () { @@ -109,21 +109,21 @@ Includable_lexer::close_input () if (be_verbose_global) progress_indication ("]"); yy_delete_buffer (yy_current_buffer); -#if HAVE_FLEXLEXER_YY_CURRENT_BUFFER +#if HAVE_FLEXLEXER_YY_CURRENT_BUFFER yy_current_buffer = 0; -#endif +#endif if (state_stack_.is_empty ()) { -#if HAVE_FLEXLEXER_YY_CURRENT_BUFFER +#if HAVE_FLEXLEXER_YY_CURRENT_BUFFER yy_current_buffer = 0; -#endif +#endif return false; } yy_switch_to_buffer (state_stack_.pop ()); return true; } -char const* +char const * Includable_lexer::here_str0 () const { if (include_stack_.is_empty ()) @@ -139,7 +139,7 @@ Includable_lexer::~Includable_lexer () } } -Source_file* +Source_file * Includable_lexer::get_source_file () const { if (include_stack_.is_empty ()) diff --git a/lily/include/accidental-interface.hh b/lily/include/accidental-interface.hh index 2b8aabfc12..835762d320 100644 --- a/lily/include/accidental-interface.hh +++ b/lily/include/accidental-interface.hh @@ -1,8 +1,8 @@ /* accidental-interface.hh -- declare Accidental_interface - + source file of the GNU LilyPond music typesetter - + (c) 2002--2005 Han-Wen Nienhuys */ @@ -13,17 +13,15 @@ #include "lily-guile.hh" #include "lily-proto.hh" - class Accidental_interface { public: DECLARE_SCHEME_CALLBACK (print, (SCM)); - DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM)); - static bool has_interface (Grob*); - - static String get_fontcharname(String style, int alteration); - static Array Accidental_interface::accurate_boxes (Grob *me, Grob**common); -}; + DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM)); + static bool has_interface (Grob *); + static String get_fontcharname (String style, int alteration); + static Array Accidental_interface::accurate_boxes (Grob *me, Grob **common); +}; #endif diff --git a/lily/include/accidental-placement.hh b/lily/include/accidental-placement.hh index a288aeb391..3e75259af4 100644 --- a/lily/include/accidental-placement.hh +++ b/lily/include/accidental-placement.hh @@ -1,11 +1,10 @@ -/* -accidental-placement.hh -- declare Accidental_placement +/* + accidental-placement.hh -- declare Accidental_placement -source file of the GNU LilyPond music typesetter + source file of the GNU LilyPond music typesetter -(c) 2002--2005 Han-Wen Nienhuys - - */ + (c) 2002--2005 Han-Wen Nienhuys +*/ #ifndef ACCIDENTAL_PLACEMENT_HH #define ACCIDENTAL_PLACEMENT_HH @@ -16,17 +15,17 @@ class Accidental_placement { public: DECLARE_SCHEME_CALLBACK (alignment_callback, (SCM element, SCM axis)); - static void add_accidental (Grob *, Grob* ); + static void add_accidental (Grob *, Grob *); static Interval get_relevant_accidental_extent (Grob *me, Item *item_col, Grob *acc); - static void split_accidentals (Grob * accs, - Link_array *break_reminder, - Link_array *real_acc); - - static SCM position_accidentals (Grob* ); - static bool has_interface (Grob*); + static void split_accidentals (Grob *accs, + Link_array *break_reminder, + Link_array *real_acc); + + static SCM position_accidentals (Grob *); + static bool has_interface (Grob *); }; #endif /* ACCIDENTAL_PLACEMENT_HH */ diff --git a/lily/include/afm.hh b/lily/include/afm.hh index adafed8d6d..7db3cbcf37 100644 --- a/lily/include/afm.hh +++ b/lily/include/afm.hh @@ -1,12 +1,11 @@ -/* +/* afm.hh -- declare Adobe_font_metric - + source file of the GNU LilyPond music typesetter - + (c) 1998--2005 Han-Wen Nienhuys - - */ +*/ #ifndef AFM_HH #define AFM_HH @@ -32,22 +31,22 @@ public: virtual Box get_ascii_char (int) const; virtual Box get_indexed_char (int) const; virtual Offset get_indexed_wxwy (int) const; - static SCM make_afm (AFM_Font_info*, unsigned, Real); + static SCM make_afm (AFM_Font_info *, unsigned, Real); virtual Real design_size () const; - virtual String font_name () const; + virtual String font_name () const; protected: AFM_CharMetricInfo const *find_char_metric (String name) const; - AFM_CharMetricInfo const *find_ascii_metric (int) const; + AFM_CharMetricInfo const *find_ascii_metric (int) const; Array ascii_to_metric_idx_; - std::map name_to_metric_dict_; + std::map < String, int> name_to_metric_dict_; - Adobe_font_metric (AFM_Font_info*); + Adobe_font_metric (AFM_Font_info *); }; SCM read_afm_file (String); Box afm_bbox_to_box (AFM_BBox); - + #endif /* AFM_HH */ diff --git a/lily/include/align-interface.hh b/lily/include/align-interface.hh index 279c1b6a3d..8ac3503a4b 100644 --- a/lily/include/align-interface.hh +++ b/lily/include/align-interface.hh @@ -1,11 +1,10 @@ /* align-interface.hh -- declare Align_interface - + source file of the GNU LilyPond music typesetter - + (c) 2000--2005 Han-Wen Nienhuys - - */ +*/ #ifndef ALIGN_INTERFACE_HH #define ALIGN_INTERFACE_HH @@ -13,21 +12,21 @@ #include "lily-proto.hh" #include "lily-guile.hh" -struct Align_interface { +struct Align_interface +{ DECLARE_SCHEME_CALLBACK (alignment_callback, (SCM element, SCM axis)); DECLARE_SCHEME_CALLBACK (fixed_distance_alignment_callback, (SCM element, SCM axis)); - static void align_to_fixed_distance (Grob*, Axis a); - static void align_elements_to_extents (Grob*, Axis a); - static void set_axis (Grob*, Axis); - static Axis axis (Grob*) ; - static void add_element (Grob*, Grob*, SCM callback); - static int get_count (Grob*, Grob*); - - static bool has_interface (Grob*); + static void align_to_fixed_distance (Grob *, Axis a); + static void align_elements_to_extents (Grob *, Axis a); + static void set_axis (Grob *, Axis); + static Axis axis (Grob *); + static void add_element (Grob *, Grob *, SCM callback); + static int get_count (Grob *, Grob *); + + static bool has_interface (Grob *); }; -Grob *find_fixed_alignment_parent (Grob *g); - +Grob *find_fixed_alignment_parent (Grob *g); #endif /* ALIGN_INTERFACE_HH */ diff --git a/lily/include/all-font-metrics.hh b/lily/include/all-font-metrics.hh index 5f027fbe01..f7af1bb4b9 100644 --- a/lily/include/all-font-metrics.hh +++ b/lily/include/all-font-metrics.hh @@ -1,11 +1,10 @@ -/* +/* all-fonts.hh -- declare All_font_metrics - + source file of the GNU LilyPond music typesetter - + (c) 1998--2005 Han-Wen Nienhuys - - */ +*/ #ifndef ALL_FONTS_HH #define ALL_FONTS_HH @@ -21,7 +20,7 @@ /** Interface to all .afm files living in the filesystem. - */ +*/ class All_font_metrics { Scheme_hash_table *afm_dict_; @@ -34,22 +33,22 @@ class All_font_metrics Scheme_hash_table *pango_dict_; int pango_dpi_; #endif - - All_font_metrics (All_font_metrics const&); + + All_font_metrics (All_font_metrics const &); public: All_font_metrics (String search_path); ~All_font_metrics (); - + #ifdef HAVE_PANGO_FT2 - Pango_font *find_pango_font (PangoFontDescription*description, + Pango_font *find_pango_font (PangoFontDescription *description, Real magnification, Real scale); #endif - + Adobe_font_metric *find_afm (String name); Tex_font_metric *find_tfm (String); - Font_metric *find_font (String name); - Open_type_font *find_otf (String name); + Font_metric *find_font (String name); + Open_type_font *find_otf (String name); SCM font_descriptions () const; }; diff --git a/lily/include/ambitus.hh b/lily/include/ambitus.hh index 924b3e87ee..ea80b28621 100644 --- a/lily/include/ambitus.hh +++ b/lily/include/ambitus.hh @@ -16,9 +16,9 @@ class Grob; struct Ambitus { DECLARE_SCHEME_CALLBACK (print, (SCM smob)); - static bool has_interface (Grob*); - static Slice get_positions (Grob*); - static Interval head_width (Grob* me, Grob * common); + static bool has_interface (Grob *); + static Slice get_positions (Grob *); + static Interval head_width (Grob *me, Grob *common); }; #endif // AMBITUS_HH diff --git a/lily/include/arpeggio.hh b/lily/include/arpeggio.hh index 2eb368bba8..aa2e36260e 100644 --- a/lily/include/arpeggio.hh +++ b/lily/include/arpeggio.hh @@ -1,6 +1,6 @@ /* arpegio.hh -- declare Arpeggio - + source file of the GNU LilyPond music typesetter (c) 2000--2005 Jan Nieuwenhuizen @@ -18,7 +18,7 @@ public: DECLARE_SCHEME_CALLBACK (print, (SCM)); DECLARE_SCHEME_CALLBACK (brew_chord_bracket, (SCM)); DECLARE_SCHEME_CALLBACK (width_callback, (SCM, SCM)); - static bool has_interface (Grob*); + static bool has_interface (Grob *); }; #endif /* ARPEGGIO_HH */ diff --git a/lily/include/audio-column.hh b/lily/include/audio-column.hh index 75a5bcfeb5..3f99af98d6 100644 --- a/lily/include/audio-column.hh +++ b/lily/include/audio-column.hh @@ -2,7 +2,7 @@ audio-column.hh -- declare Audio_column (c) 1997--2005 Jan Nieuwenhuizen - */ +*/ #ifndef AUDIO_COLUMN_HH #define AUDIO_COLUMN_HH @@ -13,23 +13,23 @@ #include "audio-element.hh" /** - generic audio grouped vertically. - */ + generic audio grouped vertically. +*/ -class Audio_column : public Audio_element { +class Audio_column : public Audio_element +{ public: Audio_column (Moment at_mom); - void add_audio_item (Audio_item* i); + void add_audio_item (Audio_item *i); Moment at_mom () const; Link_array audio_items_; private: - Audio_column (Audio_column const&); + Audio_column (Audio_column const &); Moment at_mom_; }; - #endif // AUDIO_COLUMN_HH diff --git a/lily/include/audio-element-info.hh b/lily/include/audio-element-info.hh index 4ab9feb891..54604a330e 100644 --- a/lily/include/audio-element-info.hh +++ b/lily/include/audio-element-info.hh @@ -1,11 +1,10 @@ -/* +/* audio-item-info.hh -- declare Audio_item_info - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - - */ +*/ #ifndef AUDIO_ITEM_INFO_HH #define AUDIO_ITEM_INFO_HH @@ -14,19 +13,19 @@ #include "parray.hh" /** - Data container for broadcasts - */ -class Audio_element_info { + Data container for broadcasts +*/ +class Audio_element_info +{ public: - Audio_element * elem_; + Audio_element *elem_; Music *event_; Translator *origin_trans_; - Link_array origin_contexts (Translator*) const; + Link_array origin_contexts (Translator *) const; - Audio_element_info (Audio_element*, Music*); + Audio_element_info (Audio_element *, Music *); Audio_element_info (); }; - #endif diff --git a/lily/include/audio-element.hh b/lily/include/audio-element.hh index 2ebcee4291..39cd369d38 100644 --- a/lily/include/audio-element.hh +++ b/lily/include/audio-element.hh @@ -6,7 +6,6 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef AUDIO_ELEMENT_HH #define AUDIO_ELEMENT_HH @@ -17,7 +16,7 @@ class Audio_element public: Audio_element (); virtual ~Audio_element (); - virtual const char* name () const; + virtual const char *name () const; protected: }; diff --git a/lily/include/audio-item.hh b/lily/include/audio-item.hh index 2dae497bdc..1ab00fd915 100644 --- a/lily/include/audio-item.hh +++ b/lily/include/audio-item.hh @@ -2,7 +2,7 @@ audio-item.hh -- declare Audio_items (c) 1996--2005 Jan Nieuwenhuizen - */ +*/ #ifndef AUDIO_ITEM_HH #define AUDIO_ITEM_HH @@ -12,19 +12,19 @@ #include "pitch.hh" /** - - Any piece of audio information. We need virtual constructors, let's - try decentralised factory for specific audio implemenations. - */ + +Any piece of audio information. We need virtual constructors, let's +try decentralised factory for specific audio implemenations. +*/ class Audio_item : public Audio_element { public: Audio_item (); - Audio_column* audio_column_; - + Audio_column *audio_column_; + private: - Audio_item (Audio_item const&); - Audio_item& operator = ( Audio_item const&); + Audio_item (Audio_item const &); + Audio_item &operator= (Audio_item const &); }; class Audio_dynamic : public Audio_item @@ -51,18 +51,18 @@ public: String str_; }; - + class Audio_note : public Audio_item { -public: +public: Audio_note (Pitch p, Moment m, int transposing_i = 0); - void tie_to (Audio_note*); + void tie_to (Audio_note *); Pitch pitch_; Moment length_mom_; int transposing_; - Audio_note* tied_; + Audio_note *tied_; }; class Audio_piano_pedal : public Audio_item @@ -75,11 +75,12 @@ public: class Audio_text : public Audio_item { public: - enum Type { - TEXT = 1, COPYRIGHT, TRACK_NAME, INSTRUMENT_NAME, LYRIC, - MARKER, CUE_POINT - }; - + enum Type + { + TEXT = 1, COPYRIGHT, TRACK_NAME, INSTRUMENT_NAME, LYRIC, + MARKER, CUE_POINT + }; + Audio_text (Audio_text::Type type, String text_string); Type type_; diff --git a/lily/include/audio-staff.hh b/lily/include/audio-staff.hh index 64152e8ada..a8823ba120 100644 --- a/lily/include/audio-staff.hh +++ b/lily/include/audio-staff.hh @@ -2,7 +2,7 @@ audio-staff.hh -- declare Audio_staff (c) 1996--2005 Jan Nieuwenhuizen - */ +*/ #ifndef AUDIO_STAFF_HH #define AUDIO_STAFF_HH @@ -13,8 +13,8 @@ struct Audio_staff : public Audio_element { - void add_audio_item (Audio_item* l); - void output (Midi_stream& midi_stream_r, int track_i); + void add_audio_item (Audio_item *l); + void output (Midi_stream &midi_stream_r, int track_i); Link_array audio_items_; int channel_; diff --git a/lily/include/axis-group-interface.hh b/lily/include/axis-group-interface.hh index aee7739017..6792372c09 100644 --- a/lily/include/axis-group-interface.hh +++ b/lily/include/axis-group-interface.hh @@ -1,11 +1,10 @@ -/* +/* axis-group-interface.hh -- declare Axis_group_interface - + source file of the GNU LilyPond music typesetter - + (c) 2000--2005 Han-Wen Nienhuys - - */ +*/ #ifndef AXIS_GROUP_INTERFACE_HH #define AXIS_GROUP_INTERFACE_HH @@ -13,20 +12,18 @@ #include "group-interface.hh" /** - -*/ -struct Axis_group_interface + */ +struct Axis_group_interface { DECLARE_SCHEME_CALLBACK (group_extent_callback, (SCM smob, SCM axis)); - static Interval relative_group_extent (Axis, Grob * common, SCM list); - - static void add_element (Grob* me, Grob*); - static void set_axes (Grob*, Axis, Axis); - static bool has_axis (Grob*, Axis); - static Link_array get_children (Grob*); - static bool has_interface (Grob*); - - + static Interval relative_group_extent (Axis, Grob *common, SCM list); + + static void add_element (Grob *me, Grob *); + static void set_axes (Grob *, Axis, Axis); + static bool has_axis (Grob *, Axis); + static Link_array get_children (Grob *); + static bool has_interface (Grob *); + }; #endif /* AXIS_GROUP_INTERFACE_HH */ diff --git a/lily/include/bar-line.hh b/lily/include/bar-line.hh index 57b0a4c525..657d95a493 100644 --- a/lily/include/bar-line.hh +++ b/lily/include/bar-line.hh @@ -11,18 +11,18 @@ #include "lily-proto.hh" /** - A vertical bar. - */ + A vertical bar. +*/ class Bar_line { public: - static bool has_interface (Grob*); - - static Stencil compound_barline (Grob*, String, Real height) ; - static Stencil simple_barline (Grob*, Real wid, Real height) ; - DECLARE_SCHEME_CALLBACK (get_staff_bar_size, (SCM )); - DECLARE_SCHEME_CALLBACK (print, (SCM )); - DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM )); + static bool has_interface (Grob *); + + static Stencil compound_barline (Grob *, String, Real height); + static Stencil simple_barline (Grob *, Real wid, Real height); + DECLARE_SCHEME_CALLBACK (get_staff_bar_size, (SCM)); + DECLARE_SCHEME_CALLBACK (print, (SCM)); + DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM)); }; #endif // BAR_HH diff --git a/lily/include/bar.hh b/lily/include/bar.hh index d455d2f16c..96be5257a4 100644 --- a/lily/include/bar.hh +++ b/lily/include/bar.hh @@ -11,18 +11,18 @@ #include "lily-proto.hh" /** - A vertical bar. - */ + A vertical bar. +*/ class Bar { public: - static bool has_interface (Grob*); - - static Stencil compound_barline (Grob*, String, Real height) ; - static Stencil simple_barline (Grob*, Real wid, Real height) ; - DECLARE_SCHEME_CALLBACK (get_staff_bar_size, (SCM )); - DECLARE_SCHEME_CALLBACK (print, (SCM )); - DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM )); + static bool has_interface (Grob *); + + static Stencil compound_barline (Grob *, String, Real height); + static Stencil simple_barline (Grob *, Real wid, Real height); + DECLARE_SCHEME_CALLBACK (get_staff_bar_size, (SCM)); + DECLARE_SCHEME_CALLBACK (print, (SCM)); + DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM)); }; #endif // BAR_HH diff --git a/lily/include/beam.hh b/lily/include/beam.hh index 94c4a64fd1..746d7e1458 100644 --- a/lily/include/beam.hh +++ b/lily/include/beam.hh @@ -14,36 +14,35 @@ #include "lily-guile.hh" #include "stem-info.hh" - class Beam { public: - static int visible_stem_count (Grob*); - static Grob* first_visible_stem (Grob*); - static Grob* last_visible_stem (Grob*); - static bool has_interface (Grob*); + static int visible_stem_count (Grob *); + static Grob *first_visible_stem (Grob *); + static Grob *last_visible_stem (Grob *); + static bool has_interface (Grob *); DECLARE_SCHEME_CALLBACK (rest_collision_callback, (SCM element, SCM axis)); Beam (SCM); - static void add_stem (Grob*, Grob*); - static bool is_knee (Grob*); - static void set_beaming (Grob*, Beaming_info_list *); - static void set_stemlens (Grob*); - static int get_beam_count (Grob*me); - static void position_beam (Grob* me); - static Real get_beam_translation (Grob*me); - static Real get_thickness (Grob*me); + static void add_stem (Grob *, Grob *); + static bool is_knee (Grob *); + static void set_beaming (Grob *, Beaming_info_list *); + static void set_stemlens (Grob *); + static int get_beam_count (Grob *me); + static void position_beam (Grob *me); + static Real get_beam_translation (Grob *me); + static Real get_thickness (Grob *me); - static void connect_beams (Grob*me); + static void connect_beams (Grob *me); DECLARE_SCHEME_CALLBACK (space_function, (SCM, SCM)); DECLARE_SCHEME_CALLBACK (print, (SCM)); DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM)); DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM)); - + /* position callbacks */ DECLARE_SCHEME_CALLBACK (least_squares, (SCM)); DECLARE_SCHEME_CALLBACK (check_concave, (SCM)); DECLARE_SCHEME_CALLBACK (slope_damping, (SCM)); - DECLARE_SCHEME_CALLBACK (shift_region_to_valid, (SCM)); + DECLARE_SCHEME_CALLBACK (shift_region_to_valid, (SCM)); DECLARE_SCHEME_CALLBACK (quanting, (SCM)); static Real score_slopes_dy (Real, Real, Real, Real, Real, bool); @@ -51,25 +50,24 @@ public: Array const &stem_infos, Array const &base_stem_ys, Array const &stem_xs, - Real xl, Real xr, - bool knee, + Real xl, Real xr, + bool knee, Real yl, Real yr); static Real score_forbidden_quants (Real, Real, Real, Real, Real, Real, Drul_array, Direction, Direction); - static int get_direction_beam_count (Grob *me, Direction d); private: - static Direction get_default_dir (Grob*); - static void set_stem_directions (Grob*, Direction ); - static void consider_auto_knees (Grob*); - static void set_stem_shorten (Grob*); - static Real calc_stem_y (Grob*, Grob* s, Grob**c, + static Direction get_default_dir (Grob *); + static void set_stem_directions (Grob *, Direction); + static void consider_auto_knees (Grob *); + static void set_stem_shorten (Grob *); + static Real calc_stem_y (Grob *, Grob *s, Grob **c, Real, Real, Drul_array pos, bool french); - static void set_stem_lengths (Grob*); - static int forced_stem_count (Grob*); + static void set_stem_lengths (Grob *); + static int forced_stem_count (Grob *); }; const int REGION_SIZE = 2; diff --git a/lily/include/beaming.hh b/lily/include/beaming.hh index 44b7df2a59..0200d55a68 100644 --- a/lily/include/beaming.hh +++ b/lily/include/beaming.hh @@ -1,11 +1,10 @@ -/* +/* beaming.hh -- declare beaming.hh - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - - */ +*/ #ifndef BEAMING_HH #define BEAMING_HH @@ -37,5 +36,4 @@ struct Beaming_info_list void add_stem (Moment d, int beams); }; - #endif /* BEAMING_HH */ diff --git a/lily/include/bezier.hh b/lily/include/bezier.hh index 4b449c6b42..a564dbeb1f 100644 --- a/lily/include/bezier.hh +++ b/lily/include/bezier.hh @@ -7,14 +7,13 @@ #ifndef BEZIER_HH #define BEZIER_HH - #include "interval.hh" #include "offset.hh" #include "polynomial.hh" /** - Simple bezier curve - */ + Simple bezier curve +*/ class Bezier { public: @@ -38,7 +37,6 @@ public: Array<> gives unnecessary overhead, and makes debugging a royal pain. */ - Offset control_[4]; }; @@ -46,12 +44,10 @@ void scale (Array* array, Real xscale, Real yscale); void rotate (Array* array, Real phi); void translate (Array* array, Offset o); - - Bezier slur_shape (Real width, Real height_limit, Real height_proportion); -Real slur_height (Real width, Real height_limit, Real height_proportion); -void get_slur_indent_height (Real * indent, Real *height, Real width, Real h_inf, Real r_0); +Real slur_height (Real width, Real height_limit, Real height_proportion); +void get_slur_indent_height (Real *indent, Real *height, Real width, Real h_inf, Real r_0); #endif // BEZIER_HH diff --git a/lily/include/binary-source-file.hh b/lily/include/binary-source-file.hh index 4d1dd197de..b47caf9270 100644 --- a/lily/include/binary-source-file.hh +++ b/lily/include/binary-source-file.hh @@ -11,17 +11,17 @@ class Binary_source_file : public Source_file { public: - Binary_source_file (String& file_name_string ); + Binary_source_file (String &file_name_string); virtual ~Binary_source_file (); - U8 get_U8 (); + U8 get_U8 (); U16 get_U16 (); U32 get_U32 (); Byte get_Byte () {return get_U8 (); } int get_int () { return get_U32 (); } - - virtual String error_string (char const* pos_str0 ) const; - virtual int get_line (char const* pos_str0 ) const; + + virtual String error_string (char const *pos_str0) const; + virtual int get_line (char const *pos_str0) const; }; #endif // BINARY_SOURCE_FILE_HH diff --git a/lily/include/book.hh b/lily/include/book.hh index 0d4fa66147..88b9207c3e 100644 --- a/lily/include/book.hh +++ b/lily/include/book.hh @@ -27,7 +27,7 @@ public: Book (); void add_score (SCM); - Paper_book* process (String, Output_def*); + Paper_book *process (String, Output_def *); void set_keys (); }; diff --git a/lily/include/box.hh b/lily/include/box.hh index 901987f1ad..85173e0b52 100644 --- a/lily/include/box.hh +++ b/lily/include/box.hh @@ -1,5 +1,5 @@ /* - some 2D geometrical concepts + some 2D geometrical concepts */ #ifndef BOXES_HH @@ -11,7 +11,7 @@ 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]; } @@ -20,7 +20,7 @@ struct Box Interval &operator[] (Axis a); Offset center () const; - + void translate (Offset o); /// smallest box enclosing #b# void set_empty (); @@ -32,5 +32,4 @@ struct Box Box (Interval ix, Interval iy); }; - #endif diff --git a/lily/include/break-algorithm.hh b/lily/include/break-algorithm.hh index 82d648cd61..a891c7c140 100644 --- a/lily/include/break-algorithm.hh +++ b/lily/include/break-algorithm.hh @@ -6,38 +6,36 @@ (c) 1996--2005 Han-Wen Nienhuys */ - #ifndef BREAK_HH #define BREAK_HH #include "interval.hh" #include "column-x-positions.hh" - /** Class representation of an algorithm which decides where to put - the column, and where to break lines. + the column, and where to break lines. - JUNKME. - - */ -class Break_algorithm { + JUNKME. +*/ +class Break_algorithm +{ protected: Paper_score *pscore_; Real linewidth_; Link_array find_breaks () const; Array find_break_indices () const; - void solve_line (Column_x_positions*) const; + void solve_line (Column_x_positions *) const; bool feasible (Link_array const &) const; - Simple_spacer_wrapper* generate_spacing_problem (Link_array const &, Interval) const; + Simple_spacer_wrapper *generate_spacing_problem (Link_array const &, Interval) const; virtual Array do_solve () const = 0; public: - Simple_spacer* (*get_line_spacer) (); + Simple_spacer *(*get_line_spacer) (); Break_algorithm (); - void set_pscore (Paper_score*); + void set_pscore (Paper_score *); Array solve () const; }; diff --git a/lily/include/break-align-interface.hh b/lily/include/break-align-interface.hh index 0d20385b9a..96aec1122d 100644 --- a/lily/include/break-align-interface.hh +++ b/lily/include/break-align-interface.hh @@ -6,7 +6,6 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef BREAK_ALIGN_INTERFACE_HH #define BREAK_ALIGN_INTERFACE_HH @@ -15,18 +14,17 @@ class Break_align_interface { public: - static void do_alignment (Grob*); + static void do_alignment (Grob *); static Link_array ordered_elements (Grob *me); - static bool has_interface (Grob*); - static void add_element (Grob*me, Grob*add); + static bool has_interface (Grob *); + static void add_element (Grob *me, Grob *add); DECLARE_SCHEME_CALLBACK (alignment_callback, (SCM element, SCM axis)); DECLARE_SCHEME_CALLBACK (self_align_callback, (SCM element, SCM axis)); - + }; struct Break_aligned_interface { - static bool has_interface (Grob*); + static bool has_interface (Grob *); }; - #endif // BREAK_ALIGN_INTERFACE_HH diff --git a/lily/include/breathing-sign.hh b/lily/include/breathing-sign.hh index f29069ab63..acff1ea3cb 100644 --- a/lily/include/breathing-sign.hh +++ b/lily/include/breathing-sign.hh @@ -4,7 +4,6 @@ Copyright (c) 1999--2005 Michael Krause written for the GNU LilyPond music typesetter - */ #ifndef BREATHING_SIGN_HH @@ -21,15 +20,15 @@ class Grob; class Breathing_sign { public: - DECLARE_SCHEME_CALLBACK (print, (SCM )); - DECLARE_SCHEME_CALLBACK (railtracks, (SCM )); - DECLARE_SCHEME_CALLBACK (divisio_minima, (SCM )); - DECLARE_SCHEME_CALLBACK (divisio_maior, (SCM )); - DECLARE_SCHEME_CALLBACK (divisio_maxima, (SCM )); - DECLARE_SCHEME_CALLBACK (finalis, (SCM )); + DECLARE_SCHEME_CALLBACK (print, (SCM)); + DECLARE_SCHEME_CALLBACK (railtracks, (SCM)); + DECLARE_SCHEME_CALLBACK (divisio_minima, (SCM)); + DECLARE_SCHEME_CALLBACK (divisio_maior, (SCM)); + DECLARE_SCHEME_CALLBACK (divisio_maxima, (SCM)); + DECLARE_SCHEME_CALLBACK (finalis, (SCM)); DECLARE_SCHEME_CALLBACK (offset_callback, (SCM element, SCM axis)); - - static bool has_interface (Grob*); + + static bool has_interface (Grob *); }; #endif // BREATHING_SIGN_HH diff --git a/lily/include/change-iterator.hh b/lily/include/change-iterator.hh index 12de3af076..1a6cd21728 100644 --- a/lily/include/change-iterator.hh +++ b/lily/include/change-iterator.hh @@ -6,22 +6,20 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef CHANGE_ITERATOR_HH #define CHANGE_ITERATOR_HH #include "simple-music-iterator.hh" - class Change_iterator : public Simple_music_iterator { public: /* constructor is public */ virtual void process (Moment); - DECLARE_SCHEME_CALLBACK(constructor, ()); + DECLARE_SCHEME_CALLBACK (constructor, ()); private: - void error (String); + void error (String); }; #endif diff --git a/lily/include/chord-name.hh b/lily/include/chord-name.hh index b0cd786ef5..966db88c91 100644 --- a/lily/include/chord-name.hh +++ b/lily/include/chord-name.hh @@ -11,12 +11,11 @@ #include "stencil.hh" - class Chord_name { public: - DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM )); - static bool has_interface (Grob*); + DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM)); + static bool has_interface (Grob *); }; #endif // CHORD_NAME_HH diff --git a/lily/include/chord-tremolo-iterator.hh b/lily/include/chord-tremolo-iterator.hh index bf89996398..5cc0513971 100644 --- a/lily/include/chord-tremolo-iterator.hh +++ b/lily/include/chord-tremolo-iterator.hh @@ -1,11 +1,10 @@ -/* +/* chord-tremolo-iterator.hh -- declare Chord_tremolo_iterator - + source file of the GNU LilyPond music typesetter - + (c) 2000--2005 Han-Wen Nienhuys - - */ +*/ #ifndef CHORD_TREMOLO_ITERATOR_HH #define CHORD_TREMOLO_ITERATOR_HH @@ -15,24 +14,23 @@ class Chord_tremolo_iterator : public Music_iterator { public: - DECLARE_SCHEME_CALLBACK(constructor, ()); + DECLARE_SCHEME_CALLBACK (constructor, ()); Chord_tremolo_iterator (); - Chord_tremolo_iterator (Chord_tremolo_iterator const & ); + Chord_tremolo_iterator (Chord_tremolo_iterator const &); protected: - virtual void derived_substitute (Context *f, Context *t) ; + virtual void derived_substitute (Context *f, Context *t); virtual void derived_mark () const; virtual Moment pending_moment () const; - virtual void do_quit(); - virtual void construct_children () ; + virtual void do_quit (); + virtual void construct_children (); virtual bool ok () const; - virtual void process (Moment) ; + virtual void process (Moment); virtual Music_iterator *try_music_in_children (Music *) const; private: Moment factor_; - Music_iterator * child_iter_; + Music_iterator *child_iter_; }; - #endif /* CHORD_TREMOLO_ITERATOR_HH */ diff --git a/lily/include/clef.hh b/lily/include/clef.hh index 4abc16a1ed..ec80108af6 100644 --- a/lily/include/clef.hh +++ b/lily/include/clef.hh @@ -1,24 +1,22 @@ -/* +/* clef.hh -- declare Clef - + source file of the GNU LilyPond music typesetter - + (c) 2000--2005 Han-Wen Nienhuys - - */ +*/ #ifndef CLEF_HH #define CLEF_HH #include "lily-guile.hh" #include "lily-proto.hh" -struct Clef +struct Clef { - DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM )); - DECLARE_SCHEME_CALLBACK (print, (SCM )); - static bool has_interface (Grob*); + DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM)); + DECLARE_SCHEME_CALLBACK (print, (SCM)); + static bool has_interface (Grob *); }; - #endif /* CLEF_HH */ diff --git a/lily/include/cluster.hh b/lily/include/cluster.hh index f300c1bc18..c44f74c7ea 100644 --- a/lily/include/cluster.hh +++ b/lily/include/cluster.hh @@ -14,7 +14,7 @@ class Cluster { public: - DECLARE_SCHEME_CALLBACK (print, (SCM )); + DECLARE_SCHEME_CALLBACK (print, (SCM)); // DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM)); static bool has_interface (Grob *); // DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM )); diff --git a/lily/include/coherent-ligature-engraver.hh b/lily/include/coherent-ligature-engraver.hh index 11e647608f..c90677aac7 100644 --- a/lily/include/coherent-ligature-engraver.hh +++ b/lily/include/coherent-ligature-engraver.hh @@ -1,11 +1,10 @@ -/* +/* coherent-ligature-engraver.hh -- declare Coherent_ligature_engraver - + source file of the GNU LilyPond music typesetter - + (c) 2003--2005 Juergen Reuter - - */ +*/ #ifndef COHERENT_LIGATURE_ENGRAVER_HH #define COHERENT_LIGATURE_ENGRAVER_HH @@ -14,7 +13,7 @@ class Coherent_ligature_engraver : public Ligature_engraver { public: - TRANSLATOR_DECLARATIONS(Coherent_ligature_engraver); + TRANSLATOR_DECLARATIONS (Coherent_ligature_engraver); protected: virtual void build_ligature (Spanner *ligature, diff --git a/lily/include/column-x-positions.hh b/lily/include/column-x-positions.hh index 60f85cfc34..4d0fd6b9b0 100644 --- a/lily/include/column-x-positions.hh +++ b/lily/include/column-x-positions.hh @@ -10,12 +10,11 @@ #include "parray.hh" #include "lily-proto.hh" - struct Column_x_positions { Link_array cols_; Link_array loose_cols_; - + Array config_; Real force_; bool satisfies_constraints_; @@ -23,6 +22,5 @@ struct Column_x_positions Column_x_positions (); }; - #endif // COLUMN_X_POSITIONS_HH diff --git a/lily/include/context-def.hh b/lily/include/context-def.hh index 744cd1f8ac..5d45e6c088 100644 --- a/lily/include/context-def.hh +++ b/lily/include/context-def.hh @@ -1,11 +1,10 @@ -/* +/* context-def.hh -- declare Context_def - + source file of the GNU LilyPond music typesetter - + (c) 2000--2005 Han-Wen Nienhuys - - */ +*/ #ifndef CONTEXT_DEF_HH #define CONTEXT_DEF_HH @@ -31,7 +30,7 @@ private: SCM context_name_; SCM context_aliases_; SCM translator_group_type_; - + public: void add_context_mod (SCM); SCM default_child_context_name (); @@ -42,19 +41,19 @@ public: void set_acceptor (SCM accepts, bool add); Link_array path_to_acceptable_context (SCM type_string, - Output_def*) const; - Context * instantiate (SCM extra_ops, Object_key const*); + Output_def *) const; + Context *instantiate (SCM extra_ops, Object_key const *); SCM to_alist () const; static SCM make_scm (); SCM clone_scm () const; - void apply_default_property_operations (Context*); + void apply_default_property_operations (Context *); private: DECLARE_SMOBS (Context_def, foo); Context_def (); - Context_def (Context_def const&); + Context_def (Context_def const &); }; DECLARE_UNSMOB (Context_def, context_def); diff --git a/lily/include/context.hh b/lily/include/context.hh index f6a29923e2..0981bc536a 100644 --- a/lily/include/context.hh +++ b/lily/include/context.hh @@ -1,8 +1,8 @@ /* context.hh -- declare Context - + source file of the GNU LilyPond music typesetter - + (c) 2004--2005 Han-Wen Nienhuys */ @@ -14,12 +14,11 @@ #include "moment.hh" #include "lily-proto.hh" - class Context { Scheme_hash_table *properties_dict () const; Context (Context const &src); - + DECLARE_SMOBS (Context, dummy); void terminate (); @@ -29,12 +28,12 @@ private: int iterator_count_; bool init_; - std::map grob_counts_; - std::map context_counts_; + std::map < String, int> grob_counts_; + std::map < String, int> context_counts_; protected: - Object_key const * key_; - Context * daddy_context_; + Object_key const *key_; + Context *daddy_context_; SCM definition_; SCM properties_scm_; SCM context_list_; @@ -51,37 +50,36 @@ public: Object_key const *get_grob_key (String); Object_key const *get_context_key (String, String); - Context *create_context (Context_def*, String, SCM); - String id_string () const { return id_string_; } + Context *create_context (Context_def *, String, SCM); + String id_string () const { return id_string_; } SCM children_contexts () const { return context_list_; } SCM default_child_context_name () const; - Translator_group* implementation () const; + Translator_group *implementation () const; Context *get_parent_context () const; - Context (Object_key const*); - + Context (Object_key const *); + /* properties: */ void execute_pushpop_property (SCM prop, SCM sym, SCM val); SCM internal_get_property (SCM name_sym) const; SCM properties_as_alist () const; - void internal_set_property (SCM var_sym, SCM value); + void internal_set_property (SCM var_sym, SCM value); Context *where_defined (SCM name_sym) const; void unset_property (SCM var_sym); - Context *remove_context (Context *trans); void check_removal (); String context_name () const; SCM context_name_symbol () const; Global_context *get_global_context () const; - - virtual Score_context * get_score_context () const; + + virtual Score_context *get_score_context () const; virtual Output_def *get_output_def () const; virtual Moment now_mom () const; virtual Context *get_default_interpreter (); bool is_alias (SCM) const; - void add_alias (SCM); + void add_alias (SCM); void add_context (Context *trans); bool is_bottom_context () const; bool is_removable () const; @@ -90,27 +88,27 @@ public: Context *find_create_context (SCM context_name, String id, SCM ops); Context *create_unique_context (SCM context_name, - SCM ops); + SCM ops); Link_array path_to_acceptable_context (SCM alias, - Output_def*) const; + Output_def *) const; }; /* - Context arg? - */ + Context arg? +*/ void apply_property_operations (Context *tg, SCM pre_init_ops); void execute_pushpop_property (Context *trg, SCM prop, SCM eltprop, SCM val); SCM updated_grob_properties (Context *tg, SCM sym); Context *find_context_below (Context *where, - SCM type_sym, String id); + SCM type_sym, String id); bool melisma_busy (Context *); Context *get_voice_to_lyrics (Context *lyrics); Grob *get_current_note_head (Context *voice); Grob *get_current_rest (Context *voice); -DECLARE_UNSMOB(Context, context); +DECLARE_UNSMOB (Context, context); #endif /* CONTEXT_HH */ diff --git a/lily/include/custos.hh b/lily/include/custos.hh index 1844c752c1..5c706e8154 100644 --- a/lily/include/custos.hh +++ b/lily/include/custos.hh @@ -16,12 +16,12 @@ class Stencil; struct Custos { - DECLARE_SCHEME_CALLBACK (print, (SCM )); - static bool has_interface (Grob*); + DECLARE_SCHEME_CALLBACK (print, (SCM)); + static bool has_interface (Grob *); private: - static void add_streepjes (Grob* me, int pos, int interspaces, Stencil* custos_); - static Stencil create_ledger_line (Interval x_extent, Grob *me) ; + static void add_streepjes (Grob *me, int pos, int interspaces, Stencil *custos_); + static Stencil create_ledger_line (Interval x_extent, Grob *me); }; diff --git a/lily/include/dimension-cache-callback.hh b/lily/include/dimension-cache-callback.hh index ff9ea00c60..40ef912844 100644 --- a/lily/include/dimension-cache-callback.hh +++ b/lily/include/dimension-cache-callback.hh @@ -1,11 +1,10 @@ -/* - dimension-cache-callback.hh -- declare - +/* + dimension-cache-callback.hh -- declare + source file of the GNU LilyPond music typesetter - + (c) 2000--2005 Han-Wen Nienhuys - - */ +*/ #ifndef DIMENSION_CACHE_CALLBACK_HH #define DIMENSION_CACHE_CALLBACK_HH diff --git a/lily/include/dimension-cache.hh b/lily/include/dimension-cache.hh index 0abb7f6c37..86c3a663d0 100644 --- a/lily/include/dimension-cache.hh +++ b/lily/include/dimension-cache.hh @@ -1,11 +1,10 @@ -/* +/* dimension-cache.hh -- declare Dimension_cache - + source file of the GNU LilyPond music typesetter - + (c) 1998--2005 Han-Wen Nienhuys - - */ +*/ #ifndef DIMENSION_CACHE_HH #define DIMENSION_CACHE_HH @@ -16,39 +15,38 @@ #include "lily-guile.hh" /** - Adminstration of offset dimension info. + Adminstration of offset dimension info. */ struct Dimension_cache { /* Multi typed: - - cons: interval - - procedure: callback - - else: empty - */ + - cons: interval + - procedure: callback + - else: empty + */ SCM dimension_; SCM dimension_callback_; /** - The offset wrt. to the center of #parent_# - */ + The offset wrt. to the center of #parent_# + */ Real offset_; SCM offset_callbacks_; - + char offsets_left_; /** - What to call to find extent. Nil means empty. - */ - Grob * parent_; + What to call to find extent. Nil means empty. + */ + Grob *parent_; - Dimension_cache (Dimension_cache const&); + Dimension_cache (Dimension_cache const &); Dimension_cache (); void init (); }; - #endif /* DIMENSION_CACHE_HH */ diff --git a/lily/include/dimensions.hh b/lily/include/dimensions.hh index bc93a975ae..84f8c2884b 100644 --- a/lily/include/dimensions.hh +++ b/lily/include/dimensions.hh @@ -4,7 +4,6 @@ #include "real.hh" class String; - const Real INCH_TO_PT = 72.270; const Real CM_TO_PT = (INCH_TO_PT / 2.54); const Real MM_TO_PT = (CM_TO_PT / 10); @@ -18,23 +17,23 @@ const Real PT_TO_MM = (1.0 / MM_TO_PT); #define INTERNAL_UNIT "pt" -#define PT * (PT_TO_PT) -#define MM * (MM_TO_PT) -#define CM * (CM_TO_PT) -#define INCH * (INCH_TO_PT) -#define BIGPOINT * (BIGPOINT_TO_POINT) -#define CHAR * (CHAR_TO_PT) +#define PT *(PT_TO_PT) +#define MM *(MM_TO_PT) +#define CM *(CM_TO_PT) +#define INCH *(INCH_TO_PT) +#define BIGPOINT *(BIGPOINT_TO_POINT) +#define CHAR *(CHAR_TO_PT) -#else // mm +#else // mm #define INTERNAL_UNIT "mm" -#define PT * (PT_TO_PT * PT_TO_MM) -#define MM * (MM_TO_PT * PT_TO_MM) -#define CM * (CM_TO_PT *PT_TO_MM) -#define INCH * (INCH_TO_PT * PT_TO_MM) -#define BIGPOINT * (BIGPOINT_TO_POINT * PT_TO_MM) -#define CHAR * (CHAR_TO_PT * PT_TO_MM) +#define PT *(PT_TO_PT *PT_TO_MM) +#define MM *(MM_TO_PT *PT_TO_MM) +#define CM *(CM_TO_PT *PT_TO_MM) +#define INCH *(INCH_TO_PT *PT_TO_MM) +#define BIGPOINT *(BIGPOINT_TO_POINT *PT_TO_MM) +#define CHAR *(CHAR_TO_PT *PT_TO_MM) #endif diff --git a/lily/include/directional-element-interface.hh b/lily/include/directional-element-interface.hh index 23d8e9e399..67a5ea74c1 100644 --- a/lily/include/directional-element-interface.hh +++ b/lily/include/directional-element-interface.hh @@ -1,11 +1,10 @@ -/* +/* directional-element.hh -- declare Directional_element - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - - */ +*/ #ifndef DIRECTIONAL_ELEMENT_HH #define DIRECTIONAL_ELEMENT_HH @@ -13,8 +12,8 @@ #include "grob.hh" // what is the advantage not having these two as STATICs of GROB -- jcn -void set_grob_direction (Grob*, Direction); -Direction get_grob_direction (Grob*); +void set_grob_direction (Grob *, Direction); +Direction get_grob_direction (Grob *); #endif /* DIRECTIONAL_ELEMENT_HH */ diff --git a/lily/include/dot-column.hh b/lily/include/dot-column.hh index 81a373edf2..ac9bbc488c 100644 --- a/lily/include/dot-column.hh +++ b/lily/include/dot-column.hh @@ -6,7 +6,6 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef DOT_COLUMN_HH #define DOT_COLUMN_HH @@ -15,17 +14,17 @@ class Grob; /** - Group dots. This is needed because, the dots have to be aligned per voice - */ -class Dot_column // interface + Group dots. This is needed because, the dots have to be aligned per voice +*/ +class Dot_column // interface { public: - static int compare (Grob * const&, Grob * const&); - static void add_head (Grob * dotcol, Grob* rh ); + static int compare (Grob *const &, Grob *const &); + static void add_head (Grob *dotcol, Grob *rh); - static bool has_interface (Grob*); - DECLARE_SCHEME_CALLBACK (force_shift_callback, (SCM , SCM)); - DECLARE_SCHEME_CALLBACK (side_position, (SCM , SCM)); - static SCM do_shifts (Grob*); + static bool has_interface (Grob *); + DECLARE_SCHEME_CALLBACK (force_shift_callback, (SCM, SCM)); + DECLARE_SCHEME_CALLBACK (side_position, (SCM, SCM)); + static SCM do_shifts (Grob *); }; #endif // DOT_COLUMN_HH diff --git a/lily/include/dots.hh b/lily/include/dots.hh index 0d298f0571..a6b1029871 100644 --- a/lily/include/dots.hh +++ b/lily/include/dots.hh @@ -6,20 +6,17 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef DOTS_HH #define DOTS_HH #include "lily-proto.hh" #include "lily-guile.hh" - - class Dots { public: - DECLARE_SCHEME_CALLBACK (print, (SCM )); - bool has_interface (Grob*); + DECLARE_SCHEME_CALLBACK (print, (SCM)); + bool has_interface (Grob *); }; #endif // DOTS_HH diff --git a/lily/include/duration.hh b/lily/include/duration.hh index 931fdab7c9..4b7926d7a7 100644 --- a/lily/include/duration.hh +++ b/lily/include/duration.hh @@ -1,10 +1,9 @@ /* duration.hh -- declare Duration - + source file of the LilyPond music typesetter (c) 1997--2005 Jan Nieuwenhuizen - */ #ifndef DURATION_HH @@ -14,24 +13,25 @@ /** A musical duration. - */ -struct Duration { +*/ +struct Duration +{ public: - + Duration (); Duration (int, int); String to_string () const; Duration compressed (Rational) const; - Rational get_length () const ; + Rational get_length () const; Rational factor () const { return factor_; } int duration_log () const; int dot_count () const; - static int compare (Duration const&, Duration const&); + static int compare (Duration const &, Duration const &); DECLARE_SCHEME_CALLBACK (less_p, (SCM a, SCM b)); - DECLARE_SIMPLE_SMOBS (Duration, ); + DECLARE_SIMPLE_SMOBS (Duration,); private: /// Logarithm of the base duration. diff --git a/lily/include/engraver-group-engraver.hh b/lily/include/engraver-group-engraver.hh index be4e7d9a30..7d58562c3a 100644 --- a/lily/include/engraver-group-engraver.hh +++ b/lily/include/engraver-group-engraver.hh @@ -7,22 +7,20 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef ENGRAVERGROUP_HH #define ENGRAVERGROUP_HH #include "engraver.hh" #include "translator-group.hh" - class Engraver_group_engraver : public virtual Engraver, public virtual Translator_group { protected: Array announce_infos_; - + public: - TRANSLATOR_DECLARATIONS(Engraver_group_engraver); + TRANSLATOR_DECLARATIONS (Engraver_group_engraver); virtual void initialize (); virtual void do_announces (); diff --git a/lily/include/engraver.hh b/lily/include/engraver.hh index 9b89eea5f1..3a44301b3e 100644 --- a/lily/include/engraver.hh +++ b/lily/include/engraver.hh @@ -6,7 +6,6 @@ (c) 1996--2005 Han-Wen Nienhuys */ - #ifndef ENGRAVER_HH #define ENGRAVER_HH @@ -15,11 +14,12 @@ #include "translator.hh" /** - a struct which processes events, and creates the #Grob#s. - It may use derived classes. - */ -class Engraver : public virtual Translator { - + a struct which processes events, and creates the #Grob#s. + It may use derived classes. +*/ +class Engraver : public virtual Translator +{ + friend class Engraver_group_engraver; protected: /* @@ -27,37 +27,35 @@ protected: put item in spanner. Adjust local key; etc. Default: ignore the info - */ + */ virtual void acknowledge_grob (Grob_info) {} /** Do things with stuff found in acknowledge_grob. Ugh. Should - be looped with acknowledge_grob. - - */ + be looped with acknowledge_grob. + + */ virtual void process_acknowledged_grobs () {} virtual void announce_grob (Grob_info); - Engraver_group_engraver*get_daddy_engraver () const; - + Engraver_group_engraver *get_daddy_engraver () const; + public: /** - Announce element. Default: pass on to daddy. Utility - */ - void announce_grob (Grob*, SCM cause); - - Score_engraver * get_score_engraver () const; + Announce element. Default: pass on to daddy. Utility + */ + void announce_grob (Grob *, SCM cause); + + Score_engraver *get_score_engraver () const; /** - override other ctor - */ - TRANSLATOR_DECLARATIONS(Engraver); + override other ctor + */ + TRANSLATOR_DECLARATIONS (Engraver); }; #define make_item(x, cause) make_item_from_properties (this, ly_symbol2scm (x), cause, x) #define make_spanner(x, cause) make_spanner_from_properties (this, ly_symbol2scm (x), cause, x) -Item* make_item_from_properties (Engraver * tg, SCM x, SCM cause, const char *name); -Spanner* make_spanner_from_properties (Engraver * tg, SCM x, SCM cause, const char*name); - - +Item *make_item_from_properties (Engraver *tg, SCM x, SCM cause, const char *name); +Spanner *make_spanner_from_properties (Engraver *tg, SCM x, SCM cause, const char *name); #endif // ENGRAVER_HH diff --git a/lily/include/event-chord-iterator.hh b/lily/include/event-chord-iterator.hh index 461c4f79b7..e0f2635923 100644 --- a/lily/include/event-chord-iterator.hh +++ b/lily/include/event-chord-iterator.hh @@ -6,7 +6,6 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef EVENT_ITER_HH #define EVENT_ITER_HH @@ -14,30 +13,30 @@ /** Walk through a Event_chord - */ +*/ class Event_chord_iterator : public Simple_music_iterator { - Event_chord * get_elt () const; + Event_chord *get_elt () const; /** Find a bottom notation context to deliver events to. - */ - virtual Context * get_req_translator (); - + */ + virtual Context *get_req_translator (); /* Since Event_chord_iterator has no list-cursor internally, we must use a status variable to adminstrate where we are */ - - enum { NONE_DONE, START_DONE, END_DONE } status_; + + enum { NONE_DONE, START_DONE, END_DONE } + status_; + public: - DECLARE_SCHEME_CALLBACK(constructor, ()); + DECLARE_SCHEME_CALLBACK (constructor, ()); Event_chord_iterator (); - Event_chord_iterator (Event_chord_iterator const&); + Event_chord_iterator (Event_chord_iterator const &); protected: virtual void process (Moment); virtual void construct_children (); }; - #endif // EVENT_ITER_HH diff --git a/lily/include/event.hh b/lily/include/event.hh index 4f981fb01a..6878eb4e61 100644 --- a/lily/include/event.hh +++ b/lily/include/event.hh @@ -9,24 +9,20 @@ #ifndef EVENT_HH #define EVENT_HH - #include "input.hh" #include "music.hh" #include "duration.hh" #include "pitch.hh" /* An atom of musical information. This is an abstract class for any - piece of music that does not contain other Music. */ + piece of music that does not contain other Music. */ class Event : public Music { public: Event (SCM); VIRTUAL_COPY_CONSTRUCTOR (Music, Event); - DECLARE_SCHEME_CALLBACK(length_callback, (SCM)); + DECLARE_SCHEME_CALLBACK (length_callback, (SCM)); }; - - - #endif diff --git a/lily/include/folded-repeat-iterator.hh b/lily/include/folded-repeat-iterator.hh index ab9217f0af..12b904f759 100644 --- a/lily/include/folded-repeat-iterator.hh +++ b/lily/include/folded-repeat-iterator.hh @@ -1,11 +1,10 @@ -/* +/* folded-repeat-iterator.hh -- declare Folded_repeat_iterator - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - - */ +*/ #ifndef FOLDED_REPEAT_ITERATOR_HH #define FOLDED_REPEAT_ITERATOR_HH @@ -15,33 +14,32 @@ /** Iterate through a repeated section: first do the body, then all alternatives in parallel. - */ +*/ class Folded_repeat_iterator : public Music_iterator { public: - DECLARE_SCHEME_CALLBACK(constructor, ()); + DECLARE_SCHEME_CALLBACK (constructor, ()); Folded_repeat_iterator (Folded_repeat_iterator const &src); Folded_repeat_iterator (); virtual void derived_mark () const; - virtual void derived_substitute (Context *f, Context *t) ; - + virtual void derived_substitute (Context *f, Context *t); virtual void construct_children (); virtual Moment pending_moment () const; - virtual void do_quit(); + virtual void do_quit (); virtual bool ok () const; protected: void enter_alternative (); void leave_body (); - + virtual void process (Moment); virtual Music_iterator *try_music_in_children (Music *) const; private: - Music_iterator * main_iter_; - Music_iterator * alternative_iter_; + Music_iterator *main_iter_; + Music_iterator *alternative_iter_; Moment main_length_mom_; }; diff --git a/lily/include/font-interface.hh b/lily/include/font-interface.hh index 28ac73349e..fce817ba87 100644 --- a/lily/include/font-interface.hh +++ b/lily/include/font-interface.hh @@ -1,11 +1,10 @@ -/* +/* font-interface.hh -- declare Font_interface - + source file of the GNU LilyPond music typesetter - + (c) 2000--2005 Han-Wen Nienhuys - - */ +*/ #ifndef FONT_INTERFACE_HH #define FONT_INTERFACE_HH @@ -14,10 +13,10 @@ struct Font_interface { - static SCM text_font_alist_chain (Grob*); - static SCM music_font_alist_chain (Grob*); - static Font_metric * get_default_font (Grob*); - static bool has_interface (Grob*); + static SCM text_font_alist_chain (Grob *); + static SCM music_font_alist_chain (Grob *); + static Font_metric *get_default_font (Grob *); + static bool has_interface (Grob *); }; #endif /* FONT_INTERFACE_HH */ diff --git a/lily/include/font-metric.hh b/lily/include/font-metric.hh index c94fa2bb98..48d16b8316 100644 --- a/lily/include/font-metric.hh +++ b/lily/include/font-metric.hh @@ -1,11 +1,9 @@ /* - font-metric.hh -- declare Font_metric - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - */ #ifndef FONT_METRIC_HH @@ -37,12 +35,12 @@ public: virtual Stencil get_indexed_char_stencil (int k) const; virtual Stencil get_ascii_char_stencil (int k) const; virtual SCM sub_fonts () const; - virtual SCM font_file_name () const; - DECLARE_SMOBS (Font_metric, ); + virtual SCM font_file_name () const; + DECLARE_SMOBS (Font_metric,); private: /* No copying, no implicit copy constructor. */ - Font_metric (Font_metric const&); + Font_metric (Font_metric const &); protected: virtual void derived_mark () const; diff --git a/lily/include/freetype.hh b/lily/include/freetype.hh index d23bba1f7d..ec20ab932d 100644 --- a/lily/include/freetype.hh +++ b/lily/include/freetype.hh @@ -4,16 +4,15 @@ source file of the GNU LilyPond music typesetter (c) 2004--2005 Han-Wen Nienhuys - */ #ifndef FREETYPE_HH #define FREETYPE_HH #include -#include FT_FREETYPE_H +#include FT_FREETYPE_H -void init_freetype(); +void init_freetype (); extern FT_Library freetype2_library; #endif /* FREETYPE_HH */ diff --git a/lily/include/global-context.hh b/lily/include/global-context.hh index 181ee87703..a51859f3a5 100644 --- a/lily/include/global-context.hh +++ b/lily/include/global-context.hh @@ -6,7 +6,6 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef GLOBAL_CONTEXT_HH #define GLOBAL_CONTEXT_HH @@ -16,29 +15,28 @@ class Global_context : public virtual Context { PQueue extra_mom_pq_; - Output_def* output_def_; - + Output_def *output_def_; + friend class Output_def; public: - Global_context (Output_def*, Moment final, Object_key *key); + Global_context (Output_def *, Moment final, Object_key *key); int get_moments_left () const; Moment sneaky_insert_extra_moment (Moment); void add_moment_to_process (Moment); - void run_iterator_on_me (Music_iterator*); - virtual Score_context*get_score_context () const; - + void run_iterator_on_me (Music_iterator *); + virtual Score_context *get_score_context () const; + void apply_finalizations (); void add_finalization (SCM); - virtual Music_output *get_output (); + virtual Music_output *get_output (); virtual void prepare (Moment); virtual void one_time_step (); virtual void finish (); - virtual Output_def* get_output_def () const; + virtual Output_def *get_output_def () const; virtual Moment now_mom () const; virtual Context *get_default_interpreter (); - Moment previous_moment () const; protected: Moment final_mom_; diff --git a/lily/include/global-ctor.hh b/lily/include/global-ctor.hh index ed56a38edf..c187ac8f84 100644 --- a/lily/include/global-ctor.hh +++ b/lily/include/global-ctor.hh @@ -1,30 +1,28 @@ -/* +/* global-ctor.hh -- declare Global construction stuff. - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - - */ +*/ #ifndef GLOBAL_CTOR_HH #define GLOBAL_CTOR_HH - -#define ADD_GLOBAL_CTOR_WITHNAME(y, x)\ -class Global_ctor_ ## y \ -{\ -public: \ - Global_ctor_ ## y () { \ - add_constructor (x); \ - } \ -} _ ## y ## _ctor_init; \ - +#define ADD_GLOBAL_CTOR_WITHNAME(y, x) \ + class Global_ctor_ ## y \ + { \ + public: \ + Global_ctor_ ## y () \ + { \ + add_constructor (x); \ + } \ + } \ + _ ## y ## _ctor_init; #define ADD_GLOBAL_CTOR(x) ADD_GLOBAL_CTOR_WITHNAME (x, x); - -typedef void (* Global_ctor ) (); +typedef void (* Global_ctor) (); void add_constructor (Global_ctor ctor); void call_constructors (); diff --git a/lily/include/gourlay-breaking.hh b/lily/include/gourlay-breaking.hh index c35174cdc0..b019e3dc72 100644 --- a/lily/include/gourlay-breaking.hh +++ b/lily/include/gourlay-breaking.hh @@ -6,19 +6,18 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef GOURLAY_BREAKING_HH #define GOURLAY_BREAKING_HH #include "break-algorithm.hh" /** - A dynamic programming solution to breaking scores into lines - */ + A dynamic programming solution to breaking scores into lines +*/ struct Gourlay_breaking : public Break_algorithm { Array do_solve () const; Gourlay_breaking (); - Real combine_demerits (Column_x_positions const&, Column_x_positions const&) const; + Real combine_demerits (Column_x_positions const &, Column_x_positions const &) const; }; #endif // GOURLAY_BREAKING_HH diff --git a/lily/include/grace-fixup.hh b/lily/include/grace-fixup.hh index 180fc4f2c2..571a5d4bfc 100644 --- a/lily/include/grace-fixup.hh +++ b/lily/include/grace-fixup.hh @@ -1,10 +1,9 @@ -/* - grace-fixup.hh -- declare Grace_fixup - - source file of the GNU LilyPond music typesetter +/* + grace-fixup.hh -- declare Grace_fixup - (c) 2004--2005 Han-Wen Nienhuys + source file of the GNU LilyPond music typesetter + (c) 2004--2005 Han-Wen Nienhuys */ #ifndef GRACE_FIXUP_HH @@ -13,15 +12,14 @@ #include "moment.hh" /* - This is a lookahead list for grace notes. - { ... X \grace Y Z ... } + { ... X \grace Y Z ... } - normally, the ending of X is the start of Z. In case of a grace - note, we take off a little at the end of X. What is stored: START - (start point of X), LENGTH (length of X), GRACE_START (start_music - of Y), and the next fixup element. + normally, the ending of X is the start of Z. In case of a grace + note, we take off a little at the end of X. What is stored: START + (start point of X), LENGTH (length of X), GRACE_START (start_music + of Y), and the next fixup element. This is also done for nested musics, i.e. @@ -29,20 +27,19 @@ voiceB = \notes { c'2 \voiceA } the iterator for voiceB will contain a fixup entry with (START = 0/1, - LENGTH =2/1, GRACE_START =(0G-1/16) ) - + LENGTH =2/1, GRACE_START =(0G-1/16) ) + Graces at the start of a sequential music iterator are handled by initting here_mom_ with Music::start_music (); no fixups are needed. - */ -struct Grace_fixup +struct Grace_fixup { Moment start_; Moment length_; Rational grace_start_; - Grace_fixup * next_; + Grace_fixup *next_; }; #endif /* GRACE_FIXUP_HH */ diff --git a/lily/include/grace-iterator.hh b/lily/include/grace-iterator.hh index 7e966dc71c..cb7ace32df 100644 --- a/lily/include/grace-iterator.hh +++ b/lily/include/grace-iterator.hh @@ -1,11 +1,10 @@ -/* +/* grace-iterator.hh -- declare Grace_iterator - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - - */ +*/ #ifndef NEWGRACE_ITERATOR_HH #define NEWGRACE_ITERATOR_HH @@ -16,12 +15,9 @@ class Grace_iterator : public Music_wrapper_iterator { public: virtual void process (Moment); - DECLARE_SCHEME_CALLBACK(constructor, ()); + DECLARE_SCHEME_CALLBACK (constructor, ()); Moment pending_moment () const; }; - - #endif /* GRACE_ITERATOR_HH */ - diff --git a/lily/include/gregorian-ligature-engraver.hh b/lily/include/gregorian-ligature-engraver.hh index 01e4c6053a..5ac0dd4e91 100644 --- a/lily/include/gregorian-ligature-engraver.hh +++ b/lily/include/gregorian-ligature-engraver.hh @@ -1,11 +1,10 @@ -/* +/* gregorian-ligature-engraver.hh -- declare Gregorian_ligature_engraver - + source file of the GNU LilyPond music typesetter - + (c) 2003--2005 Juergen Reuter - - */ +*/ #ifndef GREGORIAN_LIGATURE_ENGRAVER_HH #define GREGORIAN_LIGATURE_ENGRAVER_HH @@ -16,7 +15,7 @@ class Gregorian_ligature_engraver : public Coherent_ligature_engraver Music *pes_or_flexa_req_; public: - TRANSLATOR_DECLARATIONS(Gregorian_ligature_engraver); + TRANSLATOR_DECLARATIONS (Gregorian_ligature_engraver); protected: virtual bool try_music (Music *); diff --git a/lily/include/gregorian-ligature.hh b/lily/include/gregorian-ligature.hh index 7243ea3bb3..80f123e2e2 100644 --- a/lily/include/gregorian-ligature.hh +++ b/lily/include/gregorian-ligature.hh @@ -2,7 +2,7 @@ gregorian-ligature.hh -- part of GNU LilyPond source file of the GNU LilyPond music typesetter - + (c) 2003--2005 Juergen Reuter */ @@ -12,7 +12,8 @@ class Grob; class String; -class Gregorian_ligature { +class Gregorian_ligature +{ public: static bool has_interface (Grob *); static String prefixes_to_str (Grob *); @@ -27,17 +28,17 @@ public: * treated like a prefix for the head that follows the operator, but * does not affect the head that precedes the operator, if any. */ -#define VIRGA 0x0001 // attribute "\virga" -#define STROPHA 0x0002 // attribute "\stropha" -#define INCLINATUM 0x0004 // attribute "\inclinatum" -#define AUCTUM 0x0008 // attribute "\auctum" -#define DESCENDENS 0x0010 // attribute "\descendens" -#define ASCENDENS 0x0020 // attribute "\ascendens" -#define ORISCUS 0x0040 // attribute "\oriscus" -#define QUILISMA 0x0080 // attribute "\quilisma" -#define DEMINUTUM 0x0100 // attribute "\deminutum" -#define CAVUM 0x0200 // attribute "\cavum" -#define LINEA 0x0400 // attribute "\linea" +#define VIRGA 0x0001 // attribute "\virga" +#define STROPHA 0x0002 // attribute "\stropha" +#define INCLINATUM 0x0004 // attribute "\inclinatum" +#define AUCTUM 0x0008 // attribute "\auctum" +#define DESCENDENS 0x0010 // attribute "\descendens" +#define ASCENDENS 0x0020 // attribute "\ascendens" +#define ORISCUS 0x0040 // attribute "\oriscus" +#define QUILISMA 0x0080 // attribute "\quilisma" +#define DEMINUTUM 0x0100 // attribute "\deminutum" +#define CAVUM 0x0200 // attribute "\cavum" +#define LINEA 0x0400 // attribute "\linea" #define PES_OR_FLEXA 0x0800 // operator "\~" /* @@ -47,14 +48,14 @@ public: * These definitions may be extended by more specific Gregorian * ligatures such as vaticana-ligature.hh. */ -#define PES_LOWER 0x0001 // this is a head before "\~" in an - // ascending melody -#define PES_UPPER 0x0002 // this is a head after "\~" in an - // ascending melody -#define FLEXA_LEFT 0x0004 // this is a head before "\~" in a - // descending melody -#define FLEXA_RIGHT 0x0008 // this is a head after "\~" in a - // descending melody +#define PES_LOWER 0x0001 // this is a head before "\~" in an + // ascending melody +#define PES_UPPER 0x0002 // this is a head after "\~" in an + // ascending melody +#define FLEXA_LEFT 0x0004 // this is a head before "\~" in a +// descending melody +#define FLEXA_RIGHT 0x0008 // this is a head after "\~" in a +// descending melody #define AFTER_DEMINUTUM 0x0020 // previous head was a deminutum #endif /* GREGORIAN_LIGATURE_HH */ diff --git a/lily/include/grob-info.hh b/lily/include/grob-info.hh index 4b8b700ef2..4ebc0b2999 100644 --- a/lily/include/grob-info.hh +++ b/lily/include/grob-info.hh @@ -6,7 +6,6 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef STAFFELEMINFO_HH #define STAFFELEMINFO_HH @@ -16,16 +15,17 @@ /* Data container for broadcasts. - */ -struct Grob_info { - Translator * origin_trans_; +*/ +struct Grob_info +{ + Translator *origin_trans_; friend class Engraver; - Grob * grob_; + Grob *grob_; public: - Music * music_cause (); - Link_array origin_contexts (Translator*) const; + Music *music_cause (); + Link_array origin_contexts (Translator *) const; Grob_info (); }; diff --git a/lily/include/grob-interface.hh b/lily/include/grob-interface.hh index 3f4bcfdbe1..82121e7b7f 100644 --- a/lily/include/grob-interface.hh +++ b/lily/include/grob-interface.hh @@ -1,37 +1,33 @@ -/* - interface.hh -- declare Interface +/* + interface.hh -- declare Interface source file of the GNU LilyPond music typesetter (c) 2002--2005 Han-Wen Nienhuys - - */ +*/ #ifndef INTERFACE_HH #define INTERFACE_HH #include /* SCM */ - - -#define ADD_INTERFACE(cl, a, b, c) \ -bool cl::has_interface(Grob*me)\ -{\ - return me->internal_has_interface (ly_symbol2scm (a));\ -}\ -void cl ## _init_ifaces() {\ - add_interface(a, b, c);\ -}\ -ADD_SCM_INIT_FUNC(cl ## ifaces, cl ## _init_ifaces);\ - - - -void add_interface (const char * symbol, - const char * descr, - const char * vars); - -SCM ly_add_interface (SCM, SCM, SCM); -SCM ly_all_grob_interfaces(); +#define ADD_INTERFACE(cl, a, b, c) \ + bool cl::has_interface (Grob *me) \ + { \ + return me->internal_has_interface (ly_symbol2scm (a)); \ + } \ + void cl ## _init_ifaces () \ + { \ + add_interface (a, b, c); \ + } \ + ADD_SCM_INIT_FUNC (cl ## ifaces, cl ## _init_ifaces); + +void add_interface (const char *symbol, + const char *descr, + const char *vars); + +SCM ly_add_interface (SCM, SCM, SCM); +SCM ly_all_grob_interfaces (); #endif /* INTERFACE_HH */ diff --git a/lily/include/grob-pitch-tuple.hh b/lily/include/grob-pitch-tuple.hh index d9a824ad1f..89a2e7df65 100644 --- a/lily/include/grob-pitch-tuple.hh +++ b/lily/include/grob-pitch-tuple.hh @@ -1,11 +1,10 @@ -/* -grob-pitch-tuple.hh -- declare Grob_pitch_tuple +/* + grob-pitch-tuple.hh -- declare Grob_pitch_tuple -source file of the GNU LilyPond music typesetter + source file of the GNU LilyPond music typesetter -(c) 2001--2005 Han-Wen Nienhuys - - */ + (c) 2001--2005 Han-Wen Nienhuys +*/ #ifndef GROB_PITCH_TUPLE_HH #define GROB_PITCH_TUPLE_HH @@ -13,19 +12,19 @@ source file of the GNU LilyPond music typesetter #include "pitch.hh" #include "moment.hh" -struct Grob_pitch_tuple { +struct Grob_pitch_tuple +{ Pitch pitch_; Grob *head_; Moment end_; Grob_pitch_tuple (); - Grob_pitch_tuple (Grob*, Music*, Moment); + Grob_pitch_tuple (Grob *, Music *, Moment); static int pitch_compare (Grob_pitch_tuple const &, Grob_pitch_tuple const &); - static int time_compare (Grob_pitch_tuple const &, Grob_pitch_tuple const &); + static int time_compare (Grob_pitch_tuple const &, Grob_pitch_tuple const &); }; -int compare (Grob_pitch_tuple const &, Grob_pitch_tuple const&); - +int compare (Grob_pitch_tuple const &, Grob_pitch_tuple const &); #endif /* GROB_PITCH_TUPLE_HH */ diff --git a/lily/include/grob.hh b/lily/include/grob.hh index 150325bf2d..6511dc7565 100644 --- a/lily/include/grob.hh +++ b/lily/include/grob.hh @@ -2,7 +2,7 @@ grob.hh -- declare Grob source file of the LilyPond music typesetter - + (c) 1996--2005 Han-Wen Nienhuys */ @@ -17,13 +17,14 @@ /** for administration of what was done already */ -enum Grob_status { - ORPHAN = 0, // not yet added to Paper_score - PRECALCING, - PRECALCED, // calcs before spacing done - POSTCALCING, // busy calculating. This is used to trap cyclic deps. - POSTCALCED, // after spacing calcs done -}; +enum Grob_status + { + ORPHAN = 0, // not yet added to Paper_score + PRECALCING, + PRECALCED, // calcs before spacing done + POSTCALCING, // busy calculating. This is used to trap cyclic deps. + POSTCALCED, // after spacing calcs done + }; typedef void (Grob::*Grob_method_pointer) (void); @@ -37,25 +38,25 @@ typedef void (Grob::*Grob_method_pointer) (void); **/ class Grob { -private: +private: DECLARE_SMOBS (Grob, foo); void init (); protected: - Object_key const * key_; + Object_key const *key_; SCM immutable_property_alist_; SCM mutable_property_alist_; - + /* BARF */ friend class Spanner; friend SCM ly_grob_properties (SCM); friend SCM ly_grob_basic_properties (SCM); - + void substitute_mutable_properties (SCM, SCM); char status_; - + public: Object_key const *get_key () const; - + Grob *original_; /* TODO: junk this member. */ @@ -64,35 +65,34 @@ public: Dimension_cache dim_cache_[NO_AXES]; Grob (SCM basic_props, Object_key const *); - Grob (Grob const&, int copy_count); + Grob (Grob const &, int copy_count); virtual Grob *clone (int count) const; DECLARE_SCHEME_CALLBACK (stencil_extent, (SCM smob, SCM axis)); - + String name () const; /* Properties - */ + */ SCM internal_get_property (SCM) const; void internal_set_property (SCM, SCM val); void add_to_list_property (SCM, SCM); SCM get_property_alist_chain (SCM) const; static SCM ly_grob_set_property (SCM, SCM, SCM); - static SCM ly_grob_property (SCM, SCM); + static SCM ly_grob_property (SCM, SCM); void warning (String) const; void programming_error (String) const; - + Output_def *get_layout () const; - void add_dependency (Grob*); + void add_dependency (Grob *); virtual System *get_system () const; void calculate_dependencies (int final, int busy, SCM funcname); - virtual void do_break_processing (); - virtual Grob *find_broken_piece (System*) const; + virtual Grob *find_broken_piece (System *) const; virtual void discretionary_processing (); virtual SCM do_derived_mark () const; @@ -102,15 +102,15 @@ public: void suicide (); bool is_live () const; bool is_empty (Axis a) const; - + bool internal_has_interface (SCM intf); static bool has_interface (Grob *me); virtual void handle_broken_dependencies (); virtual void handle_prebroken_dependencies (); - Interval extent (Grob * refpoint, Axis) const; - + Interval extent (Grob *refpoint, Axis) const; + void translate_axis (Real, Axis); Real relative_coordinate (Grob const *refp, Axis) const; Grob *common_refpoint (Grob const *s, Axis a) const; @@ -123,8 +123,8 @@ public: void set_extent (SCM, Axis); void set_extent_callback (SCM, Axis); Real get_offset (Axis a) const; - - void set_parent (Grob* e, Axis); + + void set_parent (Grob *e, Axis); // URG Grob *get_parent (Axis a) const; @@ -136,7 +136,7 @@ Spanner *unsmob_spanner (SCM); Item *unsmob_item (SCM); Grob *common_refpoint_of_list (SCM elt_list, Grob *, Axis a); -Grob *common_refpoint_of_array (Link_array const&, Grob *, Axis a); +Grob *common_refpoint_of_array (Link_array const &, Grob *, Axis a); void set_break_subsititution (SCM criterion); SCM substitute_mutable_property_alist (SCM alist); @@ -144,6 +144,6 @@ SCM substitute_mutable_property_alist (SCM alist); Link_array ly_scm2grobs (SCM ell); SCM ly_grobs2scm (Link_array a); -Interval robust_relative_extent (Grob*, Grob*, Axis); +Interval robust_relative_extent (Grob *, Grob *, Axis); #endif /* GROB_HH */ diff --git a/lily/include/group-interface.hh b/lily/include/group-interface.hh index 6471007845..55e541755d 100644 --- a/lily/include/group-interface.hh +++ b/lily/include/group-interface.hh @@ -1,11 +1,10 @@ -/* +/* group-interface.hh -- declare Group_interface - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - - */ +*/ #ifndef GROUP_INTERFACE_HH #define GROUP_INTERFACE_HH @@ -23,20 +22,19 @@ struct Group_interface { public: - static int count (Grob*, SCM); - static void add_thing (Grob*, SCM, SCM); + static int count (Grob *, SCM); + static void add_thing (Grob *, SCM, SCM); }; -struct Pointer_group_interface : public Group_interface { +struct Pointer_group_interface : public Group_interface +{ public: - static void add_grob (Grob*, SCM nm, Grob*e); + static void add_grob (Grob *, SCM nm, Grob *e); }; Link_array extract_grob_array (Grob const *elt, SCM symbol); Link_array extract_item_array (Grob const *elt, SCM symbol); - - #endif /* GROUP_INTERFACE_HH */ diff --git a/lily/include/hairpin.hh b/lily/include/hairpin.hh index 6053375355..66c41193e3 100644 --- a/lily/include/hairpin.hh +++ b/lily/include/hairpin.hh @@ -6,20 +6,19 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef HAIRPIN_HH #define HAIRPIN_HH #include "lily-guile.hh" #include "lily-proto.hh" /** - The hairpin symbol. - */ + The hairpin symbol. +*/ struct Hairpin { public: DECLARE_SCHEME_CALLBACK (print, (SCM)); - static bool has_interface (Grob*); + static bool has_interface (Grob *); }; #endif // HAIRPIN_HH diff --git a/lily/include/hara-kiri-group-spanner.hh b/lily/include/hara-kiri-group-spanner.hh index efaf83f65b..5baed0f3b0 100644 --- a/lily/include/hara-kiri-group-spanner.hh +++ b/lily/include/hara-kiri-group-spanner.hh @@ -6,24 +6,22 @@ (c) 1998--2005 Jan Nieuwenhuizen */ - #ifndef HARA_KIRI_VERTICAL_GROUP_SPANNER_HH #define HARA_KIRI_VERTICAL_GROUP_SPANNER_HH #include "lily-guile.hh" #include "lily-proto.hh" -class Hara_kiri_group_spanner +class Hara_kiri_group_spanner { public: - DECLARE_SCHEME_CALLBACK (force_hara_kiri_callback, (SCM , SCM)); + DECLARE_SCHEME_CALLBACK (force_hara_kiri_callback, (SCM, SCM)); DECLARE_SCHEME_CALLBACK (y_extent, (SCM smob, SCM axis)); - DECLARE_SCHEME_CALLBACK (force_hara_kiri_in_parent_callback, (SCM , SCM)); + DECLARE_SCHEME_CALLBACK (force_hara_kiri_in_parent_callback, (SCM, SCM)); static void add_element (Grob *me, Grob *e); - static bool has_interface (Grob*); - static void consider_suicide (Grob*me); - static void add_interesting_item (Grob * me , Grob* n); + static bool has_interface (Grob *); + static void consider_suicide (Grob *me); + static void add_interesting_item (Grob *me, Grob *n); }; - #endif // HARA_KIRI_VERTICAL_GROUP_SPANNER_HH diff --git a/lily/include/identifier-smob.hh b/lily/include/identifier-smob.hh index c4a53b62e6..76085fd7c8 100644 --- a/lily/include/identifier-smob.hh +++ b/lily/include/identifier-smob.hh @@ -1,18 +1,16 @@ -/* -identifier-smob.hh -- declare identifier smob. +/* + identifier-smob.hh -- declare identifier smob. -source file of the GNU LilyPond music typesetter + source file of the GNU LilyPond music typesetter -(c) 2002--2005 Han-Wen Nienhuys - - */ + (c) 2002--2005 Han-Wen Nienhuys +*/ #ifndef IDENTIFIER_SMOB_HH #define IDENTIFIER_SMOB_HH #include "lily-guile.hh" - SCM package_identifier (SCM); bool identifier_smob_p (SCM); SCM unpack_identifier (SCM); diff --git a/lily/include/includable-lexer.hh b/lily/include/includable-lexer.hh index 82a557016c..b7edcbb29e 100644 --- a/lily/include/includable-lexer.hh +++ b/lily/include/includable-lexer.hh @@ -22,32 +22,31 @@ using namespace std; typedef struct yy_buffer_state *YY_BUFFER_STATE; /** - an yyFlexLexer child with provisions for inclusion. - */ -class Includable_lexer : public yyFlexLexer + an yyFlexLexer child with provisions for inclusion. +*/ +class Includable_lexer : public yyFlexLexer { Array state_stack_; protected: - bool close_input (); + bool close_input (); Link_array include_stack_; Array char_count_stack_; public: bool allow_includes_b_; - + Includable_lexer (); ~Includable_lexer (); /// store dependencies for Makefile stuff. Array file_name_strings_; - Source_file* get_source_file () const; - void new_input (String s, Sources*); - void new_input (String name, String data, Sources*); + Source_file *get_source_file () const; + void new_input (String s, Sources *); + void new_input (String name, String data, Sources *); - char const * here_str0 () const; + char const *here_str0 () const; }; - #endif // INCLUDABLE_LEXER_HH diff --git a/lily/include/input-smob.hh b/lily/include/input-smob.hh index 1dc5cb9700..1ccb8575d9 100644 --- a/lily/include/input-smob.hh +++ b/lily/include/input-smob.hh @@ -1,11 +1,10 @@ -/* +/* input-smob.hh -- declare input smob - + source file of the GNU LilyPond music typesetter - + (c) 2000--2005 Han-Wen Nienhuys - - */ +*/ #ifndef INPUT_SMOB_HH #define INPUT_SMOB_HH @@ -14,7 +13,7 @@ #include "smobs.hh" SCM make_input (Input spot); -Input *unsmob_input(SCM); +Input *unsmob_input (SCM); extern Input dummy_input_global; diff --git a/lily/include/input.hh b/lily/include/input.hh index efb358a8fb..75bc07249d 100644 --- a/lily/include/input.hh +++ b/lily/include/input.hh @@ -12,14 +12,15 @@ #include "flower-proto.hh" /** - Base class for anything that records its poisition in the parse file. - */ -class Input { + Base class for anything that records its poisition in the parse file. +*/ +class Input +{ public: char const *start_; char const *end_; - Source_file * source_file_; - + Source_file *source_file_; + void warning (String) const; // should use member func? void non_fatal_error (String) const; void error (String) const; @@ -31,14 +32,12 @@ public: String location_string () const; String line_number_string () const; - String file_string ()const; int line_number ()const; int column_number ()const; int end_line_number ()const; int end_column_number ()const; - Input (Input const &i); Input (); }; diff --git a/lily/include/interpretation-context-handle.hh b/lily/include/interpretation-context-handle.hh index 944b5127e7..86928e6324 100644 --- a/lily/include/interpretation-context-handle.hh +++ b/lily/include/interpretation-context-handle.hh @@ -1,20 +1,19 @@ -/* +/* interpretation-context-handle.hh -- declare Interpretation_context_handle - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - - */ +*/ #ifndef INTERPRETATION_CONTEXT_HANDLE_HH #define INTERPRETATION_CONTEXT_HANDLE_HH #include "lily-proto.hh" /* -RENAME ME to Context_handle. + RENAME ME to Context_handle. */ - + class Interpretation_context_handle { public: @@ -23,14 +22,14 @@ public: void set_context (Context *); bool try_music (Music *); - void operator = (Interpretation_context_handle const&); - Interpretation_context_handle (Interpretation_context_handle const&); - Context * get_outlet () const; + void operator= (Interpretation_context_handle const &); + Interpretation_context_handle (Interpretation_context_handle const &); + Context *get_outlet () const; int get_count () const; void quit (); private: - Context * outlet_; + Context *outlet_; void down (); void up (Context *); }; diff --git a/lily/include/item.hh b/lily/include/item.hh index 9749f85cd9..aa8bcb4b66 100644 --- a/lily/include/item.hh +++ b/lily/include/item.hh @@ -8,35 +8,32 @@ #ifndef ITEM_HH #define ITEM_HH - #include "box.hh" #include "grob.hh" - /** - A horizontally fixed size element of the score. - - Item is the datastructure for printables whose width is known - before the spacing is calculated + A horizontally fixed size element of the score. + Item is the datastructure for printables whose width is known + before the spacing is calculated */ class Item : public Grob { - Drul_array broken_to_drul_; + Drul_array broken_to_drul_; public: - Item (SCM, Object_key const*); + Item (SCM, Object_key const *); Item (Item const &, int count); - + virtual Grob *clone (int count) const; static bool is_breakable (Grob *); bool is_broken () const; - + Direction break_status_dir () const; - + Item *find_prebroken_piece (Direction) const; - Grob *find_broken_piece (System *) const; + Grob *find_broken_piece (System *) const; virtual System *get_system () const; virtual Paper_column *get_column () const; virtual void handle_prebroken_dependencies (); @@ -47,6 +44,4 @@ protected: virtual SCM do_derived_mark () const; }; - - #endif diff --git a/lily/include/keyword.hh b/lily/include/keyword.hh index 9725951936..98445d7a2d 100644 --- a/lily/include/keyword.hh +++ b/lily/include/keyword.hh @@ -13,20 +13,19 @@ struct Keyword_ent { char const *name_; - int tokcode_; + int tokcode_; }; /* junkme, use hash table. - */ +*/ struct Keyword_table { Array table_; Keyword_table (Keyword_ent *); - int lookup (char const *s) const; + int lookup (char const *s) const; }; - #endif // KEYWORD_HH diff --git a/lily/include/kpath.hh b/lily/include/kpath.hh index 1b91cac7d7..312a7f5fd2 100644 --- a/lily/include/kpath.hh +++ b/lily/include/kpath.hh @@ -1,11 +1,10 @@ -/* +/* kpath.hh -- declare kpathsea functions. source file of the GNU LilyPond music typesetter (c) 2000--2005 Han-Wen Nienhuys - - */ +*/ #ifndef KPATH_HH #define KPATH_HH diff --git a/lily/include/least-squares.hh b/lily/include/least-squares.hh index 96da7d5314..4e15632e04 100644 --- a/lily/include/least-squares.hh +++ b/lily/include/least-squares.hh @@ -9,11 +9,10 @@ #include "array.hh" #include "offset.hh" - /** - Least squares minimisation in 2 variables. - */ -void minimise_least_squares (Real * coef, Real * offset, Array const &); + Least squares minimisation in 2 variables. +*/ +void minimise_least_squares (Real *coef, Real *offset, Array const &); #endif // LEASTSQUARE_HH diff --git a/lily/include/ligature-engraver.hh b/lily/include/ligature-engraver.hh index 413f1fe833..fe3bcb052d 100644 --- a/lily/include/ligature-engraver.hh +++ b/lily/include/ligature-engraver.hh @@ -1,11 +1,10 @@ -/* +/* ligature-engraver.hh -- declare Ligature_engraver - + source file of the GNU LilyPond music typesetter - + (c) 2002--2005 Juergen Reuter - - */ +*/ #ifndef LIGATURE_ENGRAVER_HH #define LIGATURE_ENGRAVER_HH @@ -33,7 +32,7 @@ protected: virtual void finalize (); virtual void acknowledge_grob (Grob_info); - virtual bool try_music (Music*); + virtual bool try_music (Music *); virtual void process_music (); virtual Spanner *create_ligature_spanner (); /* abstract method */ virtual void typeset_ligature (Spanner *ligature, @@ -42,11 +41,11 @@ protected: SCM brew_ligature_primitive_proc; public: - TRANSLATOR_DECLARATIONS(Ligature_engraver); + TRANSLATOR_DECLARATIONS (Ligature_engraver); private: - Drul_array reqs_drul_; - + Drul_array reqs_drul_; + Spanner *ligature_; Array primitives_; diff --git a/lily/include/lily-guile-macros.hh b/lily/include/lily-guile-macros.hh index 221bcef76c..5bf69473ec 100644 --- a/lily/include/lily-guile-macros.hh +++ b/lily/include/lily-guile-macros.hh @@ -4,7 +4,6 @@ source file of the GNU LilyPond music typesetter (c) 2005 Han-Wen Nienhuys - */ #ifndef LILY_GUILE_MACROS_HH @@ -22,7 +21,6 @@ #define SCM_UNPACK(x) (x) #endif - #if (__GNUC__ > 2) /* Unreliable with gcc-2.x FIXME: should add check for x86 as well? */ @@ -32,120 +30,117 @@ #ifdef CACHE_SYMBOLS /* Using this trick we cache the value of scm_str2symbol ("fooo") where - "fooo" is a constant string. This is done at the cost of one static - variable per ly_symbol2scm() use, and one boolean evaluation for - every call. - - The overall speedup of lily is about 5% on a run of wtk1-fugue2. */ -#define ly_symbol2scm(x) \ -({ \ - static SCM cached; \ - /* We store this one locally, since G++ -O2 fucks up else */ \ - SCM value = cached; \ - if ( __builtin_constant_p ((x))) \ - { \ - if (!cached) \ - value = cached = scm_gc_protect_object (scm_str2symbol ((x))); \ - } \ - else \ - value = scm_str2symbol ((char*) (x)); \ - value; \ -}) + "fooo" is a constant string. This is done at the cost of one static + variable per ly_symbol2scm() use, and one boolean evaluation for + every call. + + The overall speedup of lily is about 5% on a run of wtk1-fugue2. */ +#define ly_symbol2scm(x) \ + ({ \ + static SCM cached; \ + /* We store this one locally, since G++ -O2 fucks up else */ \ + SCM value = cached; \ + if (__builtin_constant_p ((x))) \ + { \ + if (!cached) \ + value = cached = scm_gc_protect_object (scm_str2symbol ((x))); \ + } \ + else \ + value = scm_str2symbol ((char *) (x)); \ + value; \ + }) #else -inline SCM ly_symbol2scm(char const* x) { return scm_str2symbol ((x)); } +inline SCM ly_symbol2scm (char const *x) { return scm_str2symbol ((x)); } #endif - /* TODO: rename me to ly_c_lily_module_eval - */ -#define ly_lily_module_constant(x) \ -({ \ - static SCM cached; \ - /* We store this one locally, since G++ -O2 fucks up else */ \ - SCM value = cached; \ - if ( __builtin_constant_p ((x))) \ - { \ - if (!cached) \ - value = cached = scm_gc_protect_object (scm_eval (scm_str2symbol (x), \ - global_lily_module)); \ - } \ - else \ - value = scm_eval (scm_str2symbol (x), global_lily_module); \ - value; \ -}) - - +*/ +#define ly_lily_module_constant(x) \ + ({ \ + static SCM cached; \ + /* We store this one locally, since G++ -O2 fucks up else */ \ + SCM value = cached; \ + if (__builtin_constant_p ((x))) \ + { \ + if (!cached) \ + value = cached = scm_gc_protect_object (scm_eval (scm_str2symbol (x), \ + global_lily_module)); \ + } \ + else \ + value = scm_eval (scm_str2symbol (x), global_lily_module); \ + value; \ + }) /* Adds the NAME as a Scheme function, and a variable to store the SCM version of the function in the static variable NAME_proc - */ -#define DECLARE_SCHEME_CALLBACK(NAME, ARGS) \ - static SCM NAME ARGS; \ - static SCM NAME ## _proc +*/ +#define DECLARE_SCHEME_CALLBACK(NAME, ARGS) \ + static SCM NAME ARGS; \ + static SCM NAME ## _proc /* Make TYPE::FUNC available as a Scheme function. - */ -#define MAKE_SCHEME_CALLBACK(TYPE, FUNC, ARGCOUNT) \ -SCM TYPE :: FUNC ## _proc; \ -void \ -TYPE ## _ ## FUNC ## _init_functions () \ -{ \ - TYPE :: FUNC ## _proc = scm_c_define_gsubr (#TYPE "::" #FUNC, \ - (ARGCOUNT), 0, 0, \ - (Scheme_function_unknown)TYPE :: FUNC); \ - scm_c_export (#TYPE "::" #FUNC, NULL); \ -} \ - \ -ADD_SCM_INIT_FUNC (TYPE ## _ ## FUNC ## _callback, \ - TYPE ## _ ## FUNC ## _init_functions); - +*/ +#define MAKE_SCHEME_CALLBACK(TYPE, FUNC, ARGCOUNT) \ + SCM TYPE :: FUNC ## _proc; \ + void \ + TYPE ## _ ## FUNC ## _init_functions () \ + { \ + TYPE :: FUNC ## _proc = scm_c_define_gsubr (#TYPE "::" #FUNC, \ + (ARGCOUNT), 0, 0, \ + (Scheme_function_unknown)TYPE :: FUNC); \ + scm_c_export (#TYPE "::" #FUNC, NULL); \ + } \ + \ + ADD_SCM_INIT_FUNC (TYPE ## _ ## FUNC ## _callback, \ + TYPE ## _ ## FUNC ## _init_functions); void ly_add_function_documentation (SCM proc, char const *fname, char const *varlist, char const *doc); -#define ADD_SCM_INIT_FUNC(name, func) \ -class name ## _scm_initter \ -{ \ -public: \ - name ## _scm_initter () \ - { \ - add_scm_init_func (func); \ - } \ -} _ ## name ## _scm_initter; \ +#define ADD_SCM_INIT_FUNC(name, func) \ + class name ## _scm_initter \ + { \ + public: \ + name ## _scm_initter () \ + { \ + add_scm_init_func (func); \ + } \ + } \ + _ ## name ## _scm_initter; + /* end define */ #define LY_DEFINE_WITHOUT_DECL(INITPREFIX, FNAME, PRIMNAME, REQ, OPT, VAR, \ - ARGLIST, DOCSTRING) \ -SCM FNAME ## _proc; \ -void \ -INITPREFIX ## init () \ -{ \ - FNAME ## _proc = scm_c_define_gsubr (PRIMNAME, REQ, OPT, VAR, \ - (Scheme_function_unknown) FNAME); \ - ly_add_function_documentation (FNAME ## _proc, PRIMNAME, #ARGLIST, \ - DOCSTRING); \ - scm_c_export (PRIMNAME, NULL); \ -} \ -ADD_SCM_INIT_FUNC (INITPREFIX ## init_unique_prefix, INITPREFIX ## init); \ -SCM \ -FNAME ARGLIST - - -#define LY_DEFINE(FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, DOCSTRING) \ -SCM FNAME ARGLIST; \ -LY_DEFINE_WITHOUT_DECL (FNAME, FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, \ - DOCSTRING) + ARGLIST, DOCSTRING) \ + SCM FNAME ## _proc; \ + void \ + INITPREFIX ## init () \ + { \ + FNAME ## _proc = scm_c_define_gsubr (PRIMNAME, REQ, OPT, VAR, \ + (Scheme_function_unknown) FNAME); \ + ly_add_function_documentation (FNAME ## _proc, PRIMNAME, #ARGLIST, \ + DOCSTRING); \ + scm_c_export (PRIMNAME, NULL); \ + } \ + ADD_SCM_INIT_FUNC (INITPREFIX ## init_unique_prefix, INITPREFIX ## init); \ + SCM \ + FNAME ARGLIST + +#define LY_DEFINE(FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, DOCSTRING) \ + SCM FNAME ARGLIST; \ + LY_DEFINE_WITHOUT_DECL (FNAME, FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, \ + DOCSTRING) #define LY_DEFINE_MEMBER_FUNCTION(CLASS, FNAME, PRIMNAME, REQ, OPT, VAR, \ - ARGLIST, DOCSTRING) \ -SCM FNAME ARGLIST; \ -LY_DEFINE_WITHOUT_DECL (CLASS ## FNAME, CLASS::FNAME, PRIMNAME, REQ, OPT, \ - VAR, ARGLIST, DOCSTRING) + ARGLIST, DOCSTRING) \ + SCM FNAME ARGLIST; \ + LY_DEFINE_WITHOUT_DECL (CLASS ## FNAME, CLASS::FNAME, PRIMNAME, REQ, OPT, \ + VAR, ARGLIST, DOCSTRING) #define get_property(x) internal_get_property (ly_symbol2scm (x)) #define set_property(x, y) internal_set_property (ly_symbol2scm (x), y) diff --git a/lily/include/lily-guile.hh b/lily/include/lily-guile.hh index b71535aa1d..ec63fdcce8 100644 --- a/lily/include/lily-guile.hh +++ b/lily/include/lily-guile.hh @@ -16,7 +16,6 @@ #include "lily-guile-macros.hh" #include "ly-module.hh" - /** Conversion functions follow the GUILE naming convention, i.e. A ly_B2A (B b); */ @@ -53,51 +52,55 @@ Interval robust_scm2interval (SCM, Drul_array); Offset robust_scm2offset (SCM, Offset); SCM ly_quote_scm (SCM s); -bool type_check_assignment (SCM val, SCM sym, SCM type_symbol) ; +bool type_check_assignment (SCM val, SCM sym, SCM type_symbol); String print_scm_val (SCM val); SCM ly_number2string (SCM s); SCM parse_symbol_list (char const *); -SCM robust_list_ref(int i, SCM l); +SCM robust_list_ref (int i, SCM l); SCM alist_to_hashq (SCM); SCM ly_alist_vals (SCM alist); SCM ly_hash2alist (SCM tab); /* inserts at front, removing dublicates */ -inline SCM ly_assoc_front_x(SCM alist, SCM key, SCM val) +inline SCM ly_assoc_front_x (SCM alist, SCM key, SCM val) { - return scm_acons(key, val, scm_assoc_remove_x (alist, key)); + return scm_acons (key, val, scm_assoc_remove_x (alist, key)); } inline bool ly_c_list_p (SCM x) { return SCM_NFALSEP (scm_list_p (x)); } inline bool ly_c_procedure_p (SCM x) { return SCM_NFALSEP (scm_procedure_p (x)); } -inline bool ly_c_equal_p (SCM x, SCM y) { +inline bool ly_c_equal_p (SCM x, SCM y) +{ return SCM_NFALSEP (scm_equal_p (x, y)); } - inline bool ly_scm2bool (SCM x) { return SCM_NFALSEP (x); } -inline char ly_scm2char (SCM x) { return SCM_CHAR(x); } -inline unsigned long ly_length (SCM x) { +inline char ly_scm2char (SCM x) { return SCM_CHAR (x); } +inline unsigned long ly_length (SCM x) +{ return scm_num2ulong (scm_length (x), 0, "ly_length"); } inline SCM ly_bool2scm (bool x) { return SCM_BOOL (x); } -inline SCM ly_append2 (SCM x1, SCM x2) { +inline SCM ly_append2 (SCM x1, SCM x2) +{ return scm_append (scm_listify (x1, x2, SCM_UNDEFINED)); } -inline SCM ly_append3 (SCM x1, SCM x2, SCM x3) { +inline SCM ly_append3 (SCM x1, SCM x2, SCM x3) +{ return scm_append (scm_listify (x1, x2, x3, SCM_UNDEFINED)); } -inline SCM ly_append4 (SCM x1, SCM x2, SCM x3, SCM x4) { +inline SCM ly_append4 (SCM x1, SCM x2, SCM x3, SCM x4) +{ return scm_append (scm_listify (x1, x2, x3, x4, SCM_UNDEFINED)); } /* display and print newline. - */ +*/ extern "C" { -void ly_display_scm (SCM s); + void ly_display_scm (SCM s); } void read_lily_scm_file (String); @@ -126,23 +129,23 @@ SCM ly_split_list (SCM s, SCM lst); SCM ly_unique (SCM lst); SCM ly_list_qsort_uniq_x (SCM lst); -SCM ly_output_formats(); +SCM ly_output_formats (); SCM ly_kpathsea_find_file (SCM); /* snarfing. - */ +*/ void add_scm_init_func (void (*) ()); extern "C" { -typedef SCM (*Scheme_function_unknown) (); + typedef SCM (*Scheme_function_unknown) (); } #if __GNUC__ > 2 || __GNUC_MINOR__ >= 96 typedef SCM (*Scheme_function_0) (); typedef SCM (*Scheme_function_1) (SCM); -typedef SCM (*Scheme_function_2) (SCM, SCM); -typedef SCM (*Scheme_function_3) (SCM, SCM, SCM); +typedef SCM (*Scheme_function_2) (SCM, SCM); +typedef SCM (*Scheme_function_3) (SCM, SCM, SCM); #else typedef SCM (*Scheme_function_0) (...); typedef SCM (*Scheme_function_1) (...); diff --git a/lily/include/lily-lexer.hh b/lily/include/lily-lexer.hh index fbc06b6367..37e25fa101 100644 --- a/lily/include/lily-lexer.hh +++ b/lily/include/lily-lexer.hh @@ -19,12 +19,12 @@ bool busy_parsing (); void kill_lexer (); void set_lexer (); -class Lily_lexer : public Includable_lexer +class Lily_lexer : public Includable_lexer { - DECLARE_SMOBS(Lily_lexer, ); + DECLARE_SMOBS (Lily_lexer,); public: SCM scopes_; - + private: int lookup_keyword (String); int scan_bare_word (String); @@ -40,8 +40,8 @@ public: void *lexval; Input *lexloc; bool is_main_input_; - - Sources *sources_; + + Sources *sources_; /* Scheme hash tables with (oct name acc) values, and symbol keys. */ SCM chordmodifier_tab_; @@ -50,19 +50,19 @@ public: int error_level_; Input last_input_; - Lily_lexer (Sources*); - Lily_lexer (Lily_lexer const&); + Lily_lexer (Sources *); + Lily_lexer (Lily_lexer const &); int yylex (); void add_lexed_char (int); void prepare_for_next_token (); - int try_special_identifiers (SCM* , SCM); + int try_special_identifiers (SCM *, SCM); Input here_input () const; - + void add_scope (SCM); SCM remove_scope (); - + void start_main_input (); SCM lookup_identifier (String s); diff --git a/lily/include/lily-parser.hh b/lily/include/lily-parser.hh index c6833fd87c..2f8810b37b 100644 --- a/lily/include/lily-parser.hh +++ b/lily/include/lily-parser.hh @@ -20,17 +20,17 @@ TODO: interface is too complicated */ -class Lily_parser +class Lily_parser { - DECLARE_SMOBS (Lily_parser, ); - friend int yyparse (void*); + DECLARE_SMOBS (Lily_parser,); + friend int yyparse (void *); Array define_spots_; - char const* here_str0 () const; + char const *here_str0 () const; Simultaneous_music *get_chord (Pitch tonic, Array *adds, Array *subs, - Pitch *inversion, Pitch* bass, Duration d); + Pitch *inversion, Pitch *bass, Duration d); void set_chord_tremolo (int type_i); void set_last_duration (Duration const *); void set_last_pitch (Pitch const *); @@ -50,17 +50,17 @@ public: SCM last_beam_start_; Lily_parser (Sources *sources); - Lily_parser (Lily_parser const&); + Lily_parser (Lily_parser const &); DECLARE_SCHEME_CALLBACK (layout_description, ()); - void beam_check (SCM); + void beam_check (SCM); void do_init_file (); void do_yyparse (); void parse_file (String init, String name, String out_name); void parse_string (String ly_code); void parser_error (String); - void parser_error (Input const&, String); + void parser_error (Input const &, String); void set_yydebug (bool); }; diff --git a/lily/include/lily-proto.hh b/lily/include/lily-proto.hh index 4b222a9346..c71d7c53ee 100644 --- a/lily/include/lily-proto.hh +++ b/lily/include/lily-proto.hh @@ -1,7 +1,7 @@ /* - lily-proto.hh -- declare class names. + lily-proto.hh -- declare class names. - source file of the GNU LilyPond music typesetter + source file of the GNU LilyPond music typesetter (c) 1997--2005 Han-Wen Nienhuys */ @@ -11,8 +11,6 @@ #include "flower-proto.hh" - - class Adobe_font_metric; class All_font_metrics; class Audio_column; diff --git a/lily/include/lily-version.hh b/lily/include/lily-version.hh index a949c752c8..1fc8becb15 100644 --- a/lily/include/lily-version.hh +++ b/lily/include/lily-version.hh @@ -1,11 +1,10 @@ -/* +/* lily-version.hh -- declare version strings - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Jan Nieuwenhuizen - - */ +*/ #ifndef LILY_VERSION_HH #define LILY_VERSION_HH diff --git a/lily/include/lilypond-input-version.hh b/lily/include/lilypond-input-version.hh index 4e22ae3a33..4fb1bc547d 100644 --- a/lily/include/lilypond-input-version.hh +++ b/lily/include/lilypond-input-version.hh @@ -4,7 +4,6 @@ source file of the GNU LilyPond music typesetter (c) 1998--2005 Jan Nieuwenhuizen - */ #ifndef LILYPOND_VERSION_HH @@ -12,7 +11,7 @@ #include "string.hh" -struct Lilypond_version +struct Lilypond_version { Lilypond_version (int major, int minor, int patch); Lilypond_version (String str); diff --git a/lily/include/lilypond-key.hh b/lily/include/lilypond-key.hh index 24d0a3f36b..2b8ad9ddf9 100644 --- a/lily/include/lilypond-key.hh +++ b/lily/include/lilypond-key.hh @@ -4,7 +4,6 @@ source file of the GNU LilyPond music typesetter (c) 2004--2005 Han-Wen Nienhuys - */ #ifndef LILYPOND_KEY_HH @@ -29,8 +28,8 @@ public: static Object_key *from_scheme (SCM); protected: virtual int get_type () const; - virtual void derived_mark () const; - virtual int do_compare (Object_key const* a) const; + virtual void derived_mark () const; + virtual int do_compare (Object_key const *a) const; virtual SCM as_scheme () const; }; @@ -43,17 +42,17 @@ class Lilypond_context_key : public Object_key int disambiguation_count_; public: - Lilypond_context_key (Object_key const * parent, + Lilypond_context_key (Object_key const *parent, Moment start, String type, String id, - int count); + int count); static Object_key *from_scheme (SCM); protected: virtual int get_type () const; - virtual int do_compare (Object_key const* a) const; - virtual void derived_mark () const; + virtual int do_compare (Object_key const *a) const; + virtual void derived_mark () const; virtual SCM as_scheme () const; }; @@ -69,8 +68,8 @@ public: static Object_key *from_scheme (SCM); protected: virtual int get_type () const; - virtual int do_compare (Object_key const* a) const; - virtual void derived_mark () const; + virtual int do_compare (Object_key const *a) const; + virtual void derived_mark () const; virtual SCM as_scheme () const; }; diff --git a/lily/include/line-group-group-engraver.hh b/lily/include/line-group-group-engraver.hh index 5b2b9d4e36..92b6f8a269 100644 --- a/lily/include/line-group-group-engraver.hh +++ b/lily/include/line-group-group-engraver.hh @@ -6,29 +6,27 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef LINE_GROUP_GRAV_HH #define LINE_GROUP_GRAV_HH #include "engraver-group-engraver.hh" /** - Engravers put elements on the same or lowel level in a line. + Engravers put elements on the same or lowel level in a line. - DEPRECATED. - */ + DEPRECATED. +*/ class Line_group_engraver_group : public Engraver_group_engraver { protected: - Spanner *staffline_; + Spanner *staffline_; virtual void create_line_spanner (); virtual void initialize (); virtual void finalize (); public: - TRANSLATOR_DECLARATIONS(Line_group_engraver_group); + TRANSLATOR_DECLARATIONS (Line_group_engraver_group); }; - #endif // LINE_GROUP_GRAV_HH diff --git a/lily/include/line-interface.hh b/lily/include/line-interface.hh index f763b7c42c..bb4a763b14 100644 --- a/lily/include/line-interface.hh +++ b/lily/include/line-interface.hh @@ -1,11 +1,10 @@ -/* -line-interface.hh -- declare +/* + line-interface.hh -- declare -source file of the GNU LilyPond music typesetter + source file of the GNU LilyPond music typesetter -(c) 2004--2005 Han-Wen Nienhuys - - */ + (c) 2004--2005 Han-Wen Nienhuys +*/ #ifndef LINE_INTERFACE_HH #define LINE_INTERFACE_HH @@ -15,11 +14,10 @@ source file of the GNU LilyPond music typesetter struct Line_interface { static Stencil line (Grob *me, Offset from, Offset to); - static bool has_interface (Grob*); + static bool has_interface (Grob *); static Stencil make_dashed_line (Real th, Offset from, Offset to, Real, Real); static Stencil make_line (Real th, Offset from, Offset to); }; #endif /* LINE_INTERFACE_HH */ - diff --git a/lily/include/line-spanner.hh b/lily/include/line-spanner.hh index 3ae31c1a1b..6bd7e630d9 100644 --- a/lily/include/line-spanner.hh +++ b/lily/include/line-spanner.hh @@ -6,7 +6,6 @@ (c) 2000--2005 Jan Nieuwenhuizen */ - #ifndef LINE_SPANNER_HH #define LINE_SPANNER_HH @@ -19,9 +18,9 @@ class Line_spanner { public: DECLARE_SCHEME_CALLBACK (print, (SCM)); - DECLARE_SCHEME_CALLBACK(after_line_breaking, (SCM)); - static Stencil line_stencil (Grob* me, Offset f, Offset t); - static bool has_interface (Grob*); + DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM)); + static Stencil line_stencil (Grob *me, Offset f, Offset t); + static bool has_interface (Grob *); private: static Offset get_broken_offset (Grob *me, Direction dir); diff --git a/lily/include/lookup.hh b/lily/include/lookup.hh index bf53592937..b4aab56817 100644 --- a/lily/include/lookup.hh +++ b/lily/include/lookup.hh @@ -16,7 +16,7 @@ struct Lookup { static Stencil dot (Offset p, Real radius); static Stencil bracket (Axis a, Interval iv, Real thick, Real protude, Real blot); - static Stencil accordion (SCM arg, Real interline_f, Font_metric*fm); + static Stencil accordion (SCM arg, Real interline_f, Font_metric *fm); static Stencil round_filled_polygon (Array points, Real blotdiameter); static Stencil frame (Box b, Real thick, Real blot); static Stencil slur (Bezier controls, Real cthick, Real thick); diff --git a/lily/include/ly-module.hh b/lily/include/ly-module.hh index fbfa7c3500..5237160576 100644 --- a/lily/include/ly-module.hh +++ b/lily/include/ly-module.hh @@ -1,10 +1,10 @@ /* - ly-module.hh -- declare module related helper functions + ly-module.hh -- declare module related helper functions source file of the GNU LilyPond music typesetter - (c) 2002--2005 Han-Wen Nienhuys - */ + (c) 2002--2005 Han-Wen Nienhuys +*/ #ifndef LY_MODULE_HH #define LY_MODULE_HH @@ -16,8 +16,8 @@ SCM ly_module2alist (SCM mod); SCM ly_module_lookup (SCM module, SCM sym); SCM ly_modules_lookup (SCM modules, SCM sym, SCM); SCM ly_module_symbols (SCM mod); -void ly_reexport_module (SCM mod); -inline bool ly_c_module_p (SCM x) { return SCM_MODULEP(x); } +void ly_reexport_module (SCM mod); +inline bool ly_c_module_p (SCM x) { return SCM_MODULEP (x); } void ly_clear_anonymous_modules (); SCM ly_use_module (SCM mod, SCM used); diff --git a/lily/include/ly-smobs.icc b/lily/include/ly-smobs.icc index d134564495..45ba7ebf2d 100644 --- a/lily/include/ly-smobs.icc +++ b/lily/include/ly-smobs.icc @@ -4,108 +4,104 @@ source file of the GNU LilyPond music typesetter (c) 1999--2005 Han-Wen Nienhuys - */ +*/ #ifndef LY_SMOBS_ICC #define LY_SMOBS_ICC #include "smobs.hh" -#define IMPLEMENT_TYPE_P(CL, FUNCNAME) \ -SCM CL ## _type_p_proc; \ -void init_type_ ## CL () \ -{ \ - SCM subr = scm_c_define_gsubr (FUNCNAME, 1, 0, 0, \ - (Scheme_function_unknown) CL::smob_p); \ - CL ## _type_p_proc = subr; \ - ly_add_function_documentation (subr, FUNCNAME, "(SCM x)", \ - "Is @var{x} a @code{" #CL "} object?"); \ - scm_c_export (FUNCNAME, NULL); \ -} \ -ADD_SCM_INIT_FUNC (init_type_ ## CL, init_type_ ## CL) +#define IMPLEMENT_TYPE_P(CL, FUNCNAME) \ + SCM CL ## _type_p_proc; \ + void init_type_ ## CL () \ + { \ + SCM subr = scm_c_define_gsubr (FUNCNAME, 1, 0, 0, \ + (Scheme_function_unknown) CL::smob_p); \ + CL ## _type_p_proc = subr; \ + ly_add_function_documentation (subr, FUNCNAME, "(SCM x)", \ + "Is @var{x} a @code{" #CL "} object?"); \ + scm_c_export (FUNCNAME, NULL); \ + } \ + ADD_SCM_INIT_FUNC (init_type_ ## CL, init_type_ ## CL) +#define IMPLEMENT_BASE_SMOBS(CL) \ + scm_t_bits CL::smob_tag_; \ + SCM \ + CL::smob_p (SCM s) \ + { \ + if (SCM_NIMP (s) && SCM_CELL_TYPE (s) == smob_tag_) \ + return SCM_BOOL_T; \ + else \ + return SCM_BOOL_F; \ + \ + } \ + \ + void \ + CL::init_smobs () \ + { \ + smob_tag_ = scm_make_smob_type (#CL, 0); \ + scm_set_smob_mark (smob_tag_, CL::mark_smob); \ + scm_set_smob_free (smob_tag_, CL::free_smob); \ + scm_set_smob_print (smob_tag_, CL::print_smob); \ + scm_set_smob_equalp (smob_tag_, CL::equal_p); \ + } \ + \ + size_t \ + CL::free_smob (SCM ses) \ + { \ + CL *s = (CL *) SCM_CELL_WORD_1 (ses); \ + delete s; \ + scm_gc_unregister_collectable_memory (s, sizeof (CL), #CL " smob"); \ + return SMOB_FREE_RETURN_VAL (CL); \ + } \ + \ + ADD_SCM_INIT_FUNC (CL, CL::init_smobs) -#define IMPLEMENT_BASE_SMOBS(CL) \ -scm_t_bits CL::smob_tag_; \ -SCM \ -CL::smob_p (SCM s) \ -{ \ - if (SCM_NIMP (s) && SCM_CELL_TYPE (s) == smob_tag_) \ - return SCM_BOOL_T; \ - else \ - return SCM_BOOL_F; \ - \ -} \ - \ -void \ -CL::init_smobs () \ -{ \ - smob_tag_ = scm_make_smob_type (#CL, 0); \ - scm_set_smob_mark (smob_tag_, CL::mark_smob); \ - scm_set_smob_free (smob_tag_, CL::free_smob); \ - scm_set_smob_print (smob_tag_, CL::print_smob); \ - scm_set_smob_equalp (smob_tag_, CL::equal_p); \ -} \ - \ -size_t \ -CL::free_smob (SCM ses) \ -{ \ - CL *s = (CL*) SCM_CELL_WORD_1 (ses); \ - delete s; \ - scm_gc_unregister_collectable_memory (s, sizeof (CL), #CL " smob"); \ - return SMOB_FREE_RETURN_VAL(CL); \ -} \ - \ -ADD_SCM_INIT_FUNC (CL, CL::init_smobs) +#define IMPLEMENT_SIMPLE_SMOBS(CL) \ + IMPLEMENT_BASE_SMOBS (CL); \ + SCM CL::smobbed_copy () const \ + { \ + CL *ptr = new CL (*this); \ + SCM s; \ + s = scm_cons (SCM_PACK (CL::smob_tag_), SCM_PACK (ptr)); \ + scm_gc_register_collectable_memory ((CL *)this, sizeof (CL), #CL " smob"); \ + \ + return s; \ + } -#define IMPLEMENT_SIMPLE_SMOBS(CL) \ -IMPLEMENT_BASE_SMOBS(CL); \ -SCM CL::smobbed_copy () const \ -{ \ - CL *ptr = new CL (*this); \ - SCM s; \ - s = scm_cons (SCM_PACK (CL::smob_tag_), SCM_PACK (ptr)); \ - scm_gc_register_collectable_memory ((CL*)this, sizeof (CL), #CL " smob"); \ - \ - return s; \ -} \ - - -#define IMPLEMENT_SMOBS(CL) \ -IMPLEMENT_BASE_SMOBS (CL) \ -void \ -CL::smobify_self () \ -{ \ - SCM s = unprotected_smobify_self (); \ - scm_gc_protect_object (s); \ -} \ - \ -SCM \ -CL::unprotected_smobify_self () \ -{ \ - /* \ - This is local. We don't assign to self_scm_ directly, to assure \ - that S isn't GC-ed from under us. \ - \ - We don't use smobbed_self () to ensure that mark_smob () doesn't have to \ - deal half-initialized objects: scm_done_malloc ( ) might trigger GC. \ - the warning in smobs.hh is just to be doubleplus goodly sure \ - */ \ - SCM s; \ - SCM_NEWSMOB (s, CL::smob_tag_, this); \ - self_scm_ = s; \ - scm_gc_register_collectable_memory (this, sizeof (CL), #CL " smob"); \ - return s; \ -} - -#define IMPLEMENT_DEFAULT_EQUAL_P(CL) \ -SCM \ -CL::equal_p (SCM a , SCM b) \ -{ \ - return a == b ? SCM_BOOL_T : SCM_BOOL_F; \ -} \ +#define IMPLEMENT_SMOBS(CL) \ + IMPLEMENT_BASE_SMOBS (CL) \ + void \ + CL::smobify_self () \ + { \ + SCM s = unprotected_smobify_self (); \ + scm_gc_protect_object (s); \ + } \ + \ + SCM \ + CL::unprotected_smobify_self () \ + { \ + /* \ + This is local. We don't assign to self_scm_ directly, to assure \ + that S isn't GC-ed from under us. \ + \ + We don't use smobbed_self () to ensure that mark_smob () doesn't have to \ + deal half-initialized objects: scm_done_malloc ( ) might trigger GC. \ + the warning in smobs.hh is just to be doubleplus goodly sure \ + */ \ + SCM s; \ + SCM_NEWSMOB (s, CL::smob_tag_, this); \ + self_scm_ = s; \ + scm_gc_register_collectable_memory (this, sizeof (CL), #CL " smob"); \ + return s; \ + } +#define IMPLEMENT_DEFAULT_EQUAL_P(CL) \ + SCM \ + CL::equal_p (SCM a, SCM b) \ + { \ + return a == b ? SCM_BOOL_T : SCM_BOOL_F; \ + } #endif /* LY_SMOBS_ICC */ - diff --git a/lily/include/lyric-extender.hh b/lily/include/lyric-extender.hh index 63284cb42a..361afa81f3 100644 --- a/lily/include/lyric-extender.hh +++ b/lily/include/lyric-extender.hh @@ -11,7 +11,6 @@ #include "spanner.hh" /* - Extenders must be entered manually for now. Although it would be possible for Lily to determine where to @@ -22,14 +21,13 @@ for on a word's last syllable. The extender should be aligned with the left side of the last note of the melissima, and not extend beond, lasting the whole duration of the melissima - - */ +*/ class Lyric_extender { public: - static bool has_interface (Grob*); - DECLARE_SCHEME_CALLBACK (print, (SCM )); + static bool has_interface (Grob *); + DECLARE_SCHEME_CALLBACK (print, (SCM)); }; #endif // EXTENDER_SPANNER_HH diff --git a/lily/include/lyric-hyphen.hh b/lily/include/lyric-hyphen.hh index ba3cb67a88..c060471563 100644 --- a/lily/include/lyric-hyphen.hh +++ b/lily/include/lyric-hyphen.hh @@ -9,12 +9,12 @@ #include "spanner.hh" -struct Hyphen_spanner +struct Hyphen_spanner { public: - DECLARE_SCHEME_CALLBACK(set_spacing_rods, (SCM)); - bool has_interface (Grob*); - DECLARE_SCHEME_CALLBACK (print, (SCM )); + DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM)); + bool has_interface (Grob *); + DECLARE_SCHEME_CALLBACK (print, (SCM)); }; #endif // HYPHEN_SPANNER_HH diff --git a/lily/include/main.hh b/lily/include/main.hh index 8d12c49adb..c7fcad21d0 100644 --- a/lily/include/main.hh +++ b/lily/include/main.hh @@ -15,14 +15,13 @@ void debug_init (); void set_debug (bool); void do_scores (); void clear_scores (); -void add_score (Score* s); +void add_score (Score *s); void set_default_output (String s); String find_file (String); void call_constructors (); Array get_inclusion_names (); void set_inclusion_names (Array); - extern String init_name_global; /* options */ @@ -37,8 +36,8 @@ extern bool is_TeX_format_global; extern String prefix_directory; /* - todo: collect in Output_option struct? - */ + todo: collect in Output_option struct? +*/ extern String output_format_global; extern bool make_preview; @@ -51,7 +50,7 @@ extern File_path global_path; /* Debugging options - */ +*/ #ifndef NDEBUG #define DEBUG_SLUR_SCORING 1 diff --git a/lily/include/measure-grouping-spanner.hh b/lily/include/measure-grouping-spanner.hh index e0e3740335..a98f833c53 100644 --- a/lily/include/measure-grouping-spanner.hh +++ b/lily/include/measure-grouping-spanner.hh @@ -1,11 +1,10 @@ -/* -measure-grouping-spanner.hh -- declare +/* + measure-grouping-spanner.hh -- declare -source file of the GNU LilyPond music typesetter + source file of the GNU LilyPond music typesetter -(c) 2002--2005 Han-Wen Nienhuys - - */ + (c) 2002--2005 Han-Wen Nienhuys +*/ #ifndef MEASURE_GROUPING_SPANNER_HH #define MEASURE_GROUPING_SPANNER_HH @@ -15,11 +14,10 @@ source file of the GNU LilyPond music typesetter class Measure_grouping { public: - DECLARE_SCHEME_CALLBACK (print, (SCM )); - - static bool has_interface (Grob*); -}; + DECLARE_SCHEME_CALLBACK (print, (SCM)); + static bool has_interface (Grob *); +}; #endif /* MEASURE_GROUPING_SPANNER_HH */ diff --git a/lily/include/mensural-ligature.hh b/lily/include/mensural-ligature.hh index 2626134ecd..55c0625667 100644 --- a/lily/include/mensural-ligature.hh +++ b/lily/include/mensural-ligature.hh @@ -2,9 +2,9 @@ mensural-ligature.hh -- part of GNU LilyPond source file of the GNU LilyPond music typesetter - + (c) 2002--2005 Juergen Reuter , - Pal Benko + Pal Benko */ #ifndef MENSURAL_LIGATURE_HH @@ -17,23 +17,23 @@ * These are all possible mensural ligature primitives. */ -#define MLP_NONE 0x00 // no output -#define MLP_UP 0x01 // ligatura ascendens -#define MLP_DOWN 0x02 // ligatura descendens -#define MLP_BREVIS 0x04 // mensural brevis head -#define MLP_LONGA 0x08 // mensural brevis head with right cauda -#define MLP_MAXIMA 0x10 // mensural maxima head without stem -#define MLP_FLEXA 0x20 +#define MLP_NONE 0x00 // no output +#define MLP_UP 0x01 // ligatura ascendens +#define MLP_DOWN 0x02 // ligatura descendens +#define MLP_BREVIS 0x04 // mensural brevis head +#define MLP_LONGA 0x08 // mensural brevis head with right cauda +#define MLP_MAXIMA 0x10 // mensural maxima head without stem +#define MLP_FLEXA 0x20 -#define MLP_STEM (MLP_UP | MLP_DOWN) -#define MLP_SINGLE_HEAD (MLP_BREVIS | MLP_LONGA | MLP_MAXIMA) -#define MLP_ANY (MLP_FLEXA | MLP_SINGLE_HEAD) +#define MLP_STEM (MLP_UP | MLP_DOWN) +#define MLP_SINGLE_HEAD (MLP_BREVIS | MLP_LONGA | MLP_MAXIMA) +#define MLP_ANY (MLP_FLEXA | MLP_SINGLE_HEAD) struct Mensural_ligature { - DECLARE_SCHEME_CALLBACK (brew_ligature_primitive, (SCM )); - DECLARE_SCHEME_CALLBACK (print, (SCM )); - static bool has_interface (Grob*); + DECLARE_SCHEME_CALLBACK (brew_ligature_primitive, (SCM)); + DECLARE_SCHEME_CALLBACK (print, (SCM)); + static bool has_interface (Grob *); }; #endif /* MENSURAL_LIGATURE_HH */ diff --git a/lily/include/midi-item.hh b/lily/include/midi-item.hh index ec5964c785..6c10232918 100644 --- a/lily/include/midi-item.hh +++ b/lily/include/midi-item.hh @@ -2,7 +2,7 @@ midi-item.hh -- declare Midi items (c) 1997--2005 Jan Nieuwenhuizen - */ +*/ #ifndef MIDI_ITEM_HH #define MIDI_ITEM_HH @@ -11,10 +11,10 @@ #include "audio-item.hh" /** - Any piece of midi information. + Any piece of midi information. - Maybe use base classes for RIFF files? - */ + Maybe use base classes for RIFF files? +*/ class Midi_item { public: @@ -22,7 +22,7 @@ public: virtual ~Midi_item (); /// factory - static Midi_item* get_midi (Audio_item* a); + static Midi_item *get_midi (Audio_item *a); static String i2varint_string (int i); @@ -32,21 +32,21 @@ public: }; /** - timed MIDI event - */ + timed MIDI event +*/ class Midi_event { public: - Midi_event (Moment delta_mom, Midi_item* midi); + Midi_event (Moment delta_mom, Midi_item *midi); Moment delta_mom_; - Midi_item* midi_; + Midi_item *midi_; String to_string () const; }; /** - variable sized MIDI data - */ + variable sized MIDI data +*/ class Midi_chunk : public Midi_item { public: @@ -76,116 +76,116 @@ public: }; /** - Change instrument event - */ + Change instrument event +*/ class Midi_instrument : public Midi_item { public: - Midi_instrument (Audio_instrument*); + Midi_instrument (Audio_instrument *); virtual String to_string () const; - Audio_instrument* audio_; + Audio_instrument *audio_; }; - class Midi_key : public Midi_item { public: - Midi_key (Audio_key*); - + Midi_key (Audio_key *); + virtual String to_string () const; - Audio_key* audio_; + Audio_key *audio_; }; class Midi_time_signature : public Midi_item { public: - Midi_time_signature (Audio_time_signature*); - + Midi_time_signature (Audio_time_signature *); + virtual String to_string () const; - Audio_time_signature* audio_; + Audio_time_signature *audio_; int clocks_per_1_; }; /** - Turn a note on. - */ + Turn a note on. +*/ class Midi_note : public Midi_item { public: - Midi_note (Audio_note*); + Midi_note (Audio_note *); Moment get_length () const; int get_pitch () const; int get_fine_tuning () const; virtual String to_string () const; - Audio_note* audio_; + Audio_note *audio_; static int const c0_pitch_i_ = 60; Byte dynamic_byte_; }; /** - Turn a note off - */ + Turn a note off +*/ class Midi_note_off : public Midi_note { public: - Midi_note_off (Midi_note*); + Midi_note_off (Midi_note *); virtual String to_string () const; - Midi_note* on_; + Midi_note *on_; Byte aftertouch_byte_; }; class Midi_text : public Midi_item { public: - enum Type { - TEXT = 1, COPYRIGHT, TRACK_NAME, INSTRUMENT_NAME, LYRIC, - MARKER, CUE_POINT - }; + enum Type + { + TEXT = 1, COPYRIGHT, TRACK_NAME, INSTRUMENT_NAME, LYRIC, + MARKER, CUE_POINT + }; + + Midi_text (Audio_text *); - Midi_text (Audio_text*); - virtual String to_string () const; - Audio_text* audio_; + Audio_text *audio_; }; class Midi_dynamic : public Midi_item { public: - Midi_dynamic (Audio_dynamic*); - + Midi_dynamic (Audio_dynamic *); + virtual String to_string () const; - Audio_dynamic* audio_; + Audio_dynamic *audio_; }; class Midi_piano_pedal : public Midi_item { public: - Midi_piano_pedal (Audio_piano_pedal*); - + Midi_piano_pedal (Audio_piano_pedal *); + virtual String to_string () const; - Audio_piano_pedal* audio_; + Audio_piano_pedal *audio_; }; class Midi_tempo : public Midi_item { public: - Midi_tempo (Audio_tempo*); - + Midi_tempo (Audio_tempo *); + virtual String to_string () const; - Audio_tempo* audio_; + Audio_tempo *audio_; }; class Midi_track : public Midi_chunk @@ -195,12 +195,12 @@ public: /* Compensate for starting grace notes. - */ + */ Cons_list event_p_list_; - + Midi_track (); - void add (Moment delta_time_mom, Midi_item* midi); + void add (Moment delta_time_mom, Midi_item *midi); virtual String data_string () const; }; diff --git a/lily/include/midi-stream.hh b/lily/include/midi-stream.hh index 06de819877..c4512f82ec 100644 --- a/lily/include/midi-stream.hh +++ b/lily/include/midi-stream.hh @@ -2,7 +2,7 @@ midi-stream.hh -- declare Midi_stream (c) 1997--2005 Jan Nieuwenhuizen - */ +*/ #ifndef MIDI_STREAM_HH #define MIDI_STREAM_HH @@ -14,13 +14,14 @@ class Midi_item; /// Midi outputfile -struct Midi_stream { +struct Midi_stream +{ Midi_stream (String file_name_string); ~Midi_stream (); - Midi_stream& operator << ( String str); - Midi_stream& operator << ( Midi_item const& midi_c_r); - Midi_stream& operator << ( int i); + Midi_stream &operator<< (String str); + Midi_stream &operator<< (Midi_item const &midi_c_r); + Midi_stream &operator<< (int i); void open (); diff --git a/lily/include/midi-walker.hh b/lily/include/midi-walker.hh index 7a2c7d5be9..5f9e9e602f 100644 --- a/lily/include/midi-walker.hh +++ b/lily/include/midi-walker.hh @@ -2,8 +2,8 @@ midi-walker.hh -- declare Midi_walker (c) 1996--2005 Han-Wen Nienhuys - Jan Nieuwenhuizen - */ + Jan Nieuwenhuizen +*/ #ifndef MIDI_WALKER_HH #define MIDI_WALKER_HH @@ -12,39 +12,38 @@ #include "lily-proto.hh" #include "moment.hh" -struct Midi_note_event : PQueue_ent +struct Midi_note_event : PQueue_ent < Moment, Midi_note *> { bool ignore_b_; Midi_note_event (); }; -int compare (Midi_note_event const& left, Midi_note_event const& right); +int compare (Midi_note_event const &left, Midi_note_event const &right); /** - walk audio and output midi - */ + walk audio and output midi +*/ class Midi_walker { public: - Midi_walker (Audio_staff* audio_staff, Midi_track* midi_track); + Midi_walker (Audio_staff *audio_staff, Midi_track *midi_track); ~Midi_walker (); void process (); - void operator ++ (int); + void operator++ (int); bool ok () const; private: - void do_start_note (Midi_note* note); + void do_start_note (Midi_note *note); void do_stop_notes (Moment now_mom); - void output_event (Moment now_mom, Midi_item* l); - - Midi_track* track_; - Audio_staff* staff_; + void output_event (Moment now_mom, Midi_item *l); + + Midi_track *track_; + Audio_staff *staff_; int index_; Link_array * items_; PQueue stop_note_queue; Moment last_mom_; }; - #endif // MIDI_WALKER_HH diff --git a/lily/include/minterval.hh b/lily/include/minterval.hh index ef9f58f4ed..5476f10af9 100644 --- a/lily/include/minterval.hh +++ b/lily/include/minterval.hh @@ -6,7 +6,6 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef MINTERVAL_HH #define MINTERVAL_HH diff --git a/lily/include/misc.hh b/lily/include/misc.hh index 72da2c90e9..b40e936e9e 100644 --- a/lily/include/misc.hh +++ b/lily/include/misc.hh @@ -4,7 +4,6 @@ source file of the GNU LilyPond music typesetter (c) 2005 Han-Wen Nienhuys - */ #ifndef MISC_HH @@ -15,13 +14,13 @@ #include "array.hh" #include "interval.hh" -double log_2 (double x) ; +double log_2 (double x); int intlog2 (int d); inline int sign (int i) { - if (i<0) + if (i < 0) return -1; else if (i) return 1; @@ -31,10 +30,10 @@ sign (int i) Array split_string (String s, char c); inline Real -linear_interpolate (Real x, Real x1, Real x2, Real y1, Real y2) +linear_interpolate (Real x, Real x1, Real x2, Real y1, Real y2) { - return (x2 - x) / (x2 - x1) * y1 + - (x - x1) / (x2 - x1) * y2 ; + return (x2 - x) / (x2 - x1) * y1 + + (x - x1) / (x2 - x1) * y2; } #endif diff --git a/lily/include/modified-font-metric.hh b/lily/include/modified-font-metric.hh index 1f3b380aee..66a0ab9e3d 100644 --- a/lily/include/modified-font-metric.hh +++ b/lily/include/modified-font-metric.hh @@ -1,8 +1,8 @@ -/* +/* modified-font-metric.hh -- declare Font_metric - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys */ @@ -17,24 +17,24 @@ struct Modified_font_metric : public Font_metric public: virtual Box text_dimension (String) const; virtual Stencil text_stencil (String) const; - + static SCM make_scaled_font_metric (Font_metric *fm, Real magnification); virtual int count () const; virtual Offset get_indexed_wxwy (int) const; virtual Offset attachment_point (String) const; virtual int name_to_index (String) const; virtual unsigned index_to_charcode (int) const; - Font_metric*original_font () const; - + Font_metric *original_font () const; + protected: Font_metric *orig_; Real magnification_; - + Modified_font_metric (Font_metric *fm, Real magnification); virtual SCM sub_fonts () const; virtual String font_name () const; virtual Real design_size () const; - virtual void derived_mark () const; + virtual void derived_mark () const; virtual Box get_indexed_char (int) const; virtual int index_to_ascii (int) const; virtual Box get_ascii_char (int) const; diff --git a/lily/include/moment.hh b/lily/include/moment.hh index 953a89a008..e7f5499646 100644 --- a/lily/include/moment.hh +++ b/lily/include/moment.hh @@ -1,11 +1,10 @@ -/* +/* moment.hh -- declare Moment - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - - */ +*/ #ifndef MOMENT_HH #define MOMENT_HH @@ -19,7 +18,7 @@ */ class Moment { - DECLARE_SIMPLE_SMOBS (Moment, ); + DECLARE_SIMPLE_SMOBS (Moment,); public: Moment (); Moment (int m); @@ -27,13 +26,13 @@ public: Moment (Rational, Rational); Moment (Rational m); - Moment operator - () const; - - void operator += (Moment const &m); - void operator -= (Moment const &m); + Moment operator- () const; - void operator *= (Moment const &m); - void operator /= (Moment const &m); + void operator+= (Moment const &m); + void operator-= (Moment const &m); + + void operator*= (Moment const &m); + void operator/= (Moment const &m); Rational main_part_; Rational grace_part_; @@ -45,25 +44,24 @@ public: int num () const; /* Deliver a copy of THIS as a smobified SCM - */ + */ String to_string () const; - static int compare (Moment const&, Moment const&); + static int compare (Moment const &, Moment const &); SCM as_scheme () const; }; -IMPLEMENT_ARITHMETIC_OPERATOR (Moment, + ); -IMPLEMENT_ARITHMETIC_OPERATOR (Moment, - ); -IMPLEMENT_ARITHMETIC_OPERATOR (Moment, / ); -IMPLEMENT_ARITHMETIC_OPERATOR (Moment, * ); - +IMPLEMENT_ARITHMETIC_OPERATOR (Moment, +); +IMPLEMENT_ARITHMETIC_OPERATOR (Moment, -); +IMPLEMENT_ARITHMETIC_OPERATOR (Moment, /); +IMPLEMENT_ARITHMETIC_OPERATOR (Moment, *); -DECLARE_UNSMOB(Moment, moment); -int compare (Moment const&, Moment const&); -INSTANTIATE_COMPARE (Moment const&, Moment::compare); +DECLARE_UNSMOB (Moment, moment); +int compare (Moment const &, Moment const &); +INSTANTIATE_COMPARE (Moment const &, Moment::compare); Moment robust_scm2moment (SCM, Moment); #ifdef STREAM_SUPPORT -std::ostream & operator << (std::ostream &, Moment const &); +std::ostream & operator<< (std::ostream &, Moment const &); #endif bool moment_less (SCM a, SCM b); diff --git a/lily/include/multi-measure-rest.hh b/lily/include/multi-measure-rest.hh index e277539be1..4492945b06 100644 --- a/lily/include/multi-measure-rest.hh +++ b/lily/include/multi-measure-rest.hh @@ -1,11 +1,10 @@ -/* +/* multi-measure-rest.hh -- declare Multi_measure_rest - + source file of the GNU LilyPond music typesetter - + (c) 1998--2005 Jan Nieuwenhuizen - - */ +*/ #ifndef MULTI_MEASURE_REST_HH #define MULTI_MEASURE_REST_HH @@ -16,16 +15,16 @@ class Multi_measure_rest { public: - static bool has_interface (Grob*); - DECLARE_SCHEME_CALLBACK (print, (SCM )); + static bool has_interface (Grob *); + DECLARE_SCHEME_CALLBACK (print, (SCM)); DECLARE_SCHEME_CALLBACK (percent, (SCM)); - static void add_column (Grob*, Item*); - DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM )); - DECLARE_SCHEME_CALLBACK (centered_stencil, (SCM )); - - static Stencil big_rest (Grob*, Real); - static Stencil symbol_stencil (Grob*, Real); - static Stencil church_rest (Grob*, Font_metric*, int, Real); + static void add_column (Grob *, Item *); + DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM)); + DECLARE_SCHEME_CALLBACK (centered_stencil, (SCM)); + + static Stencil big_rest (Grob *, Real); + static Stencil symbol_stencil (Grob *, Real); + static Stencil church_rest (Grob *, Font_metric *, int, Real); }; #endif /* MULTI_MEASURE_REST_HH */ diff --git a/lily/include/music-constructor.hh b/lily/include/music-constructor.hh index b646b2b6bb..efeb433232 100644 --- a/lily/include/music-constructor.hh +++ b/lily/include/music-constructor.hh @@ -1,11 +1,10 @@ -/* +/* music-constructor.hh -- declare Music_constructor - + source file of the GNU LilyPond music typesetter - + (c) 2001--2005 Han-Wen Nienhuys - - */ +*/ #ifndef MUSIC_CONSTRUCTOR_HH #define MUSIC_CONSTRUCTOR_HH @@ -15,22 +14,20 @@ #include "string.hh" #include "global-ctor.hh" -#define ADD_MUSIC(type) \ -Music * _ ## type ## _ctor (SCM init)\ -{\ - return new type (init);\ -}\ -static void _ ## type ## _adder () {\ - add_music_ctor (#type, & _ ## type ## _ctor);\ -}\ -ADD_SCM_INIT_FUNC( _ ## type ## _adder_prefix, _ ## type ## _adder); +#define ADD_MUSIC(type) \ + Music *_ ## type ## _ctor (SCM init) \ + { \ + return new type (init); \ + } \ + static void _ ## type ## _adder () \ + { \ + add_music_ctor (#type, & _ ## type ## _ctor); \ + } \ + ADD_SCM_INIT_FUNC (_ ## type ## _adder_prefix, _ ## type ## _adder); typedef Music *(*Music_ctor) (SCM); void add_music_ctor (String, Music_ctor); -Music*make_music (String, SCM); - - - +Music *make_music (String, SCM); #endif /* MUSIC_CONSTRUCTOR_HH */ diff --git a/lily/include/music-function.hh b/lily/include/music-function.hh index 3cd73d6558..66b91e7b97 100644 --- a/lily/include/music-function.hh +++ b/lily/include/music-function.hh @@ -1,10 +1,9 @@ -/* +/* music-head.hh -- declare music_function - + source file of the GNU LilyPond music typesetter - + (c) 2004--2005 Han-Wen Nienhuys - */ #ifndef MUSIC_FUNCTION_HH diff --git a/lily/include/music-iterator.hh b/lily/include/music-iterator.hh index cc5da19c39..7b395e8a2c 100644 --- a/lily/include/music-iterator.hh +++ b/lily/include/music-iterator.hh @@ -6,7 +6,6 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef MUSIC_ITERATOR_HH #define MUSIC_ITERATOR_HH @@ -24,30 +23,29 @@ --- - - Conceptually a music-iterator operates on a queue of musical events - that are pending. This queue does not actually exist, but it is a - way of viewing and traversing music-expressions. - - ok () -- events left ? + Conceptually a music-iterator operates on a queue of musical events + that are pending. This queue does not actually exist, but it is a + way of viewing and traversing music-expressions. + + + ok () -- events left ? + + pending_mom () -- time tag of the next event to be processed. + PRECONDITION: this->ok () holds. - pending_mom () -- time tag of the next event to be processed. - PRECONDITION: this->ok () holds. - - process (M) -- process all at M (Precondition: no events exist - before M, this->ok () holds). Side-effects: - - * This removes all events at M from the pending queue. + process (M) -- process all at M (Precondition: no events exist + before M, this->ok () holds). Side-effects: - * Typically this reports the music to an interpretation context, - thus changing the state of the interpretation context. + * This removes all events at M from the pending queue. + * Typically this reports the music to an interpretation context, + thus changing the state of the interpretation context. - TODO: - merge pending_moment and process? - + TODO: + + merge pending_moment and process? */ class Music_iterator { @@ -56,9 +54,9 @@ protected: Moment start_mom_; DECLARE_SMOBS (Music_iterator, dummy); - Music_iterator (Music_iterator const&); + Music_iterator (Music_iterator const &); public: - + Moment music_get_length () const; Moment music_start_mom () const; Music_iterator (); @@ -67,67 +65,67 @@ public: Do the reporting. Will try MUSIC_L_ in its own translator first, then its children. Returns the iterator that succeeded */ - Music_iterator * try_music (Music *) const; - + Music_iterator *try_music (Music *) const; + /** - The translation unit that we this iterator is reporting to now. - */ - Context * get_outlet () const; + The translation unit that we this iterator is reporting to now. + */ + Context *get_outlet () const; void set_context (Context *); - + /** Get an iterator matching the type of MUS, and use TRANS to find - an accompanying translation unit - */ - static SCM get_static_get_iterator (Music * mus); - void init_translator (Music *, Context *); + an accompanying translation unit + */ + static SCM get_static_get_iterator (Music *mus); + void init_translator (Music *, Context *); void quit (); - void substitute_outlet (Context * from, Context *to); + void substitute_outlet (Context *from, Context *to); virtual void derived_substitute (Context *, Context *); virtual Moment pending_moment () const; virtual bool ok () const; - virtual bool run_always () const; + virtual bool run_always () const; virtual void process (Moment until); virtual void derived_mark () const; virtual void construct_children (); - + /** - Construct sub-iterators, and set the translator to - report to. - */ + Construct sub-iterators, and set the translator to + report to. + */ + + DECLARE_SCHEME_CALLBACK (constructor, ()); - DECLARE_SCHEME_CALLBACK(constructor, ()); - /** - Get an iterator for MUS, inheriting the translation unit from THIS. - */ + Get an iterator for MUS, inheriting the translation unit from THIS. + */ SCM get_iterator (Music *) const; - virtual Music_iterator* try_music_in_children (Music *) const; + virtual Music_iterator *try_music_in_children (Music *) const; - Music * get_music () const; + Music *get_music () const; protected: - virtual void do_quit(); - void descend_to_child (Context*); + virtual void do_quit (); + void descend_to_child (Context *); private: Interpretation_context_handle handle_; - Music * music_; + Music *music_; }; bool is_child_context (Context *me, Context *child); -#define IMPLEMENT_CTOR_CALLBACK(Class) \ -LY_DEFINE_MEMBER_FUNCTION(Class, constructor, #Class "::constructor", \ - 0, 0, 0, \ - (), \ - "")\ -{ \ - SCM val = (new Class)->self_scm(); \ - scm_gc_unprotect_object (val);\ - return val ; \ -} \ - -DECLARE_UNSMOB(Music_iterator, iterator); +#define IMPLEMENT_CTOR_CALLBACK(Class) \ + LY_DEFINE_MEMBER_FUNCTION (Class, constructor, #Class "::constructor", \ + 0, 0, 0, \ + (), \ + "") \ + { \ + SCM val = (new Class)->self_scm (); \ + scm_gc_unprotect_object (val); \ + return val; \ + } + +DECLARE_UNSMOB (Music_iterator, iterator); #endif // MUSIC_ITERATOR_HH diff --git a/lily/include/music-output.hh b/lily/include/music-output.hh index 250893c919..db8619f21d 100644 --- a/lily/include/music-output.hh +++ b/lily/include/music-output.hh @@ -6,7 +6,6 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef MUSIC_OUTPUT_HH #define MUSIC_OUTPUT_HH @@ -14,7 +13,7 @@ #include "lily-proto.hh" #include "protected-scm.hh" -class Music_output +class Music_output { public: virtual SCM process (String) {return SCM_EOL;} diff --git a/lily/include/music-sequence.hh b/lily/include/music-sequence.hh index 28d99eb022..6ea7711555 100644 --- a/lily/include/music-sequence.hh +++ b/lily/include/music-sequence.hh @@ -1,11 +1,10 @@ -/* +/* music-sequence.hh -- declare Music_sequence - + source file of the GNU LilyPond music typesetter - + (c) 2000--2005 Han-Wen Nienhuys - - */ +*/ #ifndef MUSIC_SEQUENCE_HH #define MUSIC_SEQUENCE_HH @@ -15,24 +14,24 @@ struct Music_sequence { public: - DECLARE_SCHEME_CALLBACK(cumulative_length_callback, (SCM)); - DECLARE_SCHEME_CALLBACK(maximum_length_callback, (SCM)); - DECLARE_SCHEME_CALLBACK(minimum_start_callback, (SCM)); - DECLARE_SCHEME_CALLBACK(first_start_callback, (SCM)); - DECLARE_SCHEME_CALLBACK(simultaneous_relative_callback, (SCM, SCM)); - DECLARE_SCHEME_CALLBACK(event_chord_relative_callback, (SCM, SCM)); - + DECLARE_SCHEME_CALLBACK (cumulative_length_callback, (SCM)); + DECLARE_SCHEME_CALLBACK (maximum_length_callback, (SCM)); + DECLARE_SCHEME_CALLBACK (minimum_start_callback, (SCM)); + DECLARE_SCHEME_CALLBACK (first_start_callback, (SCM)); + DECLARE_SCHEME_CALLBACK (simultaneous_relative_callback, (SCM, SCM)); + DECLARE_SCHEME_CALLBACK (event_chord_relative_callback, (SCM, SCM)); + Pitch do_relative_octave (Pitch p, bool b); - - static Moment cumulative_length (SCM) ; - static Moment maximum_length (SCM) ; - static Moment first_start (SCM list) ; + + static Moment cumulative_length (SCM); + static Moment maximum_length (SCM); + static Moment first_start (SCM list); static Moment minimum_start (SCM list); }; SCM ly_transpose_key_alist (SCM l, SCM pit); Pitch music_list_to_relative (SCM l, Pitch p, bool ret_first); -void transpose_music_list (SCM , Pitch); +void transpose_music_list (SCM, Pitch); void compress_music_list (SCM, Moment); #endif diff --git a/lily/include/music-wrapper-iterator.hh b/lily/include/music-wrapper-iterator.hh index db9fff1afe..660ab140ab 100644 --- a/lily/include/music-wrapper-iterator.hh +++ b/lily/include/music-wrapper-iterator.hh @@ -1,11 +1,10 @@ -/* +/* music-wrapper-iterator.hh -- declare Music_wrapper_iterator - + source file of the GNU LilyPond music typesetter - + (c) 1998--2005 Han-Wen Nienhuys - - */ +*/ #ifndef MUSIC_WRAPPER_ITERATOR_HH #define MUSIC_WRAPPER_ITERATOR_HH @@ -13,22 +12,22 @@ #include "music.hh" #include "music-iterator.hh" -/** - The iterator for a #Music_wrapper#. Since #Music_wrapper# essentially - does nothing, this iterator creates a child iterator and delegates - all work to that child. - */ +/** + The iterator for a #Music_wrapper#. Since #Music_wrapper# essentially + does nothing, this iterator creates a child iterator and delegates + all work to that child. +*/ class Music_wrapper_iterator : public Music_iterator { public: - DECLARE_SCHEME_CALLBACK(constructor, ()); + DECLARE_SCHEME_CALLBACK (constructor, ()); Music_wrapper_iterator (); - virtual void derived_substitute (Context *f, Context *t) ; + virtual void derived_substitute (Context *f, Context *t); virtual void derived_mark () const; - virtual void construct_children () ; + virtual void construct_children (); virtual Moment pending_moment () const; - virtual void do_quit(); + virtual void do_quit (); virtual bool ok () const; virtual bool run_always () const; protected: @@ -40,5 +39,3 @@ protected: #endif /* MUSIC_WRAPPER_ITERATOR_HH */ - - diff --git a/lily/include/music-wrapper.hh b/lily/include/music-wrapper.hh index 0d41c41d28..05ba1ae390 100644 --- a/lily/include/music-wrapper.hh +++ b/lily/include/music-wrapper.hh @@ -1,11 +1,10 @@ -/* +/* music-wrapper.hh -- declare Music_wrapper - + source file of the GNU LilyPond music typesetter - + (c) 1998--2005 Han-Wen Nienhuys - - */ +*/ #ifndef MUSIC_WRAPPER_HH #define MUSIC_WRAPPER_HH @@ -14,19 +13,18 @@ #include "pitch.hh" /** A Music that modifies an existing Music. This data structure - corresponds to a production that takes a single Music argument, - - Music: STUFF Music + corresponds to a production that takes a single Music argument, - */ + Music: STUFF Music +*/ class Music_wrapper : public Music { public: Music_wrapper (SCM); VIRTUAL_COPY_CONSTRUCTOR (Music, Music_wrapper); - DECLARE_SCHEME_CALLBACK(length_callback, (SCM)); - DECLARE_SCHEME_CALLBACK(start_callback, (SCM)); - + DECLARE_SCHEME_CALLBACK (length_callback, (SCM)); + DECLARE_SCHEME_CALLBACK (start_callback, (SCM)); + Music *element () const; }; diff --git a/lily/include/music.hh b/lily/include/music.hh index 973b65ac87..aeb36a40c7 100644 --- a/lily/include/music.hh +++ b/lily/include/music.hh @@ -15,7 +15,6 @@ #define is_mus_type(x) internal_is_music_type (ly_symbol2scm (x)) - class Music { public: @@ -23,18 +22,18 @@ public: Music (Music const &m); VIRTUAL_COPY_CONSTRUCTOR (Music, Music); - Input *origin () const; + Input *origin () const; void set_spot (Input); SCM internal_get_property (SCM) const; - void internal_set_property (SCM , SCM val); + void internal_set_property (SCM, SCM val); SCM get_property_alist (bool mutble) const; bool internal_is_music_type (SCM) const; int duration_log () const; - - DECLARE_SCHEME_CALLBACK(relative_callback, (SCM, SCM)); + + DECLARE_SCHEME_CALLBACK (relative_callback, (SCM, SCM)); Pitch to_relative_octave (Pitch); - Pitch generic_to_relative_octave (Pitch); + Pitch generic_to_relative_octave (Pitch); String name () const; Moment get_length () const; Moment start_mom () const; @@ -42,12 +41,12 @@ public: /// Transpose, with the interval central C to #p# void transpose (Pitch p); - + /// Scale the music in time by #factor#. void compress (Moment factor); - + protected: - DECLARE_SMOBS (Music, ); + DECLARE_SMOBS (Music,); SCM immutable_property_alist_; SCM mutable_property_alist_; protected: @@ -56,8 +55,8 @@ protected: friend SCM ly_extended_make_music (SCM, SCM); }; -DECLARE_TYPE_P(Music); -DECLARE_UNSMOB(Music, music); +DECLARE_TYPE_P (Music); +DECLARE_UNSMOB (Music, music); Music *make_music_by_name (SCM sym); SCM ly_music_deep_copy (SCM); diff --git a/lily/include/note-collision.hh b/lily/include/note-collision.hh index 82329d6328..de6d4dd290 100644 --- a/lily/include/note-collision.hh +++ b/lily/include/note-collision.hh @@ -6,7 +6,6 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef COLLISION_HH #define COLLISION_HH @@ -15,26 +14,25 @@ #include "parray.hh" /** - Resolve conflicts between various Note_columns (chords). - - TODO + Resolve conflicts between various Note_columns (chords). - * multistaff support (see Chlapik: equal noteheads should be on the - same hpos.) + TODO - * Make interface of this, similar to align-interface. - -*/ + * multistaff support (see Chlapik: equal noteheads should be on the + same hpos.) + + * Make interface of this, similar to align-interface. + */ class Note_collision_interface { public: - static SCM automatic_shift (Grob*, Drul_array< Link_array >); - static SCM forced_shift (Grob*); - - static Drul_array< Link_array > get_clash_groups (Grob *me); + static SCM automatic_shift (Grob *, Drul_array< Link_array >); + static SCM forced_shift (Grob *); + + static Drul_array< Link_array > get_clash_groups (Grob *me); DECLARE_SCHEME_CALLBACK (force_shift_callback, (SCM element, SCM axis)); - static void do_shifts (Grob*); - static void add_column (Grob*me, Grob*ncol); - static bool has_interface(Grob*); + static void do_shifts (Grob *); + static void add_column (Grob *me, Grob *ncol); + static bool has_interface (Grob *); }; #endif // COLLISION_HH diff --git a/lily/include/note-column.hh b/lily/include/note-column.hh index 32eec6af31..a6abdb3324 100644 --- a/lily/include/note-column.hh +++ b/lily/include/note-column.hh @@ -6,36 +6,34 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef NOTE_COLUMN_HH #define NOTE_COLUMN_HH #include "item.hh" /** a struct for treating a group of noteheads (noteheads, stem - (chord) and scripts) as a single entity. - - UGR. Junkme. refpoint should be the notehead, dir should come from stem. + (chord) and scripts) as a single entity. + UGR. Junkme. refpoint should be the notehead, dir should come from stem. */ class Note_column { public: - static int shift_compare (Grob *const &, Grob*const&); - static Direction dir (Grob*me); - static Grob * accidentals (Grob*me); - static Slice head_positions_interval (Grob* me); - static Direction static_dir (Grob*); - static void translate_rests (Grob*me, int dy); - static Grob *first_head (Grob*me); - static Grob *get_rest (Grob*me); - static void set_stem (Grob*me, Grob*); - static void set_dotcol (Grob*me, Grob*); - static void add_head (Grob*me, Grob*); - static bool has_rests (Grob*me); - static bool has_interface (Grob*); - - static Item *get_stem (Grob*); + static int shift_compare (Grob *const &, Grob *const &); + static Direction dir (Grob *me); + static Grob *accidentals (Grob *me); + static Slice head_positions_interval (Grob *me); + static Direction static_dir (Grob *); + static void translate_rests (Grob *me, int dy); + static Grob *first_head (Grob *me); + static Grob *get_rest (Grob *me); + static void set_stem (Grob *me, Grob *); + static void set_dotcol (Grob *me, Grob *); + static void add_head (Grob *me, Grob *); + static bool has_rests (Grob *me); + static bool has_interface (Grob *); + + static Item *get_stem (Grob *); }; #endif // NOTE_COLUMN_HH diff --git a/lily/include/note-head.hh b/lily/include/note-head.hh index 0033f7866e..1c7e12dd84 100644 --- a/lily/include/note-head.hh +++ b/lily/include/note-head.hh @@ -11,20 +11,20 @@ /** ball at the end of the stem. Also takes care of ledger lines. - NoteHead is a kind of RhythmicHead, see there. +NoteHead is a kind of RhythmicHead, see there. - Read-only: +Read-only: */ -class Note_head +class Note_head { public: - DECLARE_SCHEME_CALLBACK (print, (SCM )); + DECLARE_SCHEME_CALLBACK (print, (SCM)); DECLARE_SCHEME_CALLBACK (brew_ez_stencil, (SCM)); DECLARE_SCHEME_CALLBACK (extent, (SCM, SCM)); - static bool has_interface (Grob*); + static bool has_interface (Grob *); static Real stem_attachment_coordinate (Grob *, Axis a); - static int get_balltype (Grob*) ; + static int get_balltype (Grob *); }; #endif // NOTEHEAD_HH diff --git a/lily/include/note-spacing.hh b/lily/include/note-spacing.hh index c9bcf8c478..fdf358965e 100644 --- a/lily/include/note-spacing.hh +++ b/lily/include/note-spacing.hh @@ -1,11 +1,10 @@ -/* -note-spacing.hh -- declare Note_spacing +/* + note-spacing.hh -- declare Note_spacing -source file of the GNU LilyPond music typesetter + source file of the GNU LilyPond music typesetter -(c) 2001--2005 Han-Wen Nienhuys - - */ + (c) 2001--2005 Han-Wen Nienhuys +*/ #ifndef NOTE_SPACING_HH #define NOTE_SPACING_HH @@ -15,13 +14,13 @@ source file of the GNU LilyPond music typesetter class Note_spacing { public: - static bool has_interface (Grob*); + static bool has_interface (Grob *); - static void get_spacing (Grob *me, Item* , Real, Real, Real*, Real*); - static void stem_dir_correction (Grob *me, Item * next_col, Real incr, - Real*, Real*); - static Item * right_column (Grob*); - static Item * left_column (Grob*); + static void get_spacing (Grob *me, Item *, Real, Real, Real *, Real *); + static void stem_dir_correction (Grob *me, Item *next_col, Real incr, + Real *, Real *); + static Item *right_column (Grob *); + static Item *left_column (Grob *); }; #endif /* NOTE_SPACING_HH */ diff --git a/lily/include/object-key-dumper.hh b/lily/include/object-key-dumper.hh index 5ee61408e9..ad7507a04e 100644 --- a/lily/include/object-key-dumper.hh +++ b/lily/include/object-key-dumper.hh @@ -4,7 +4,6 @@ source file of the GNU LilyPond music typesetter (c) 2004--2005 Han-Wen Nienhuys - */ #ifndef OBJECT_KEY_DUMPER_HH @@ -14,9 +13,9 @@ #include "object-key.hh" -typedef std::map Key_to_key_map; -typedef std::map Pointer_to_int_map; -typedef std::map Int_to_key_map; +typedef std::map < Object_key const *, Object_key const *, Object_key_less> Key_to_key_map; +typedef std::map < Object_key const *, int> Pointer_to_int_map; +typedef std::map < int, Object_key const *> Int_to_key_map; class Object_key_dumper { @@ -24,17 +23,17 @@ class Object_key_dumper Key_to_key_map serialized_keys_; Pointer_to_int_map key_serial_numbers_; int next_available_; - + SCM key_serial (int); SCM serialize_key (Object_key const *); - DECLARE_SMOBS (Object_key_dumper, ); + DECLARE_SMOBS (Object_key_dumper,); public: - Object_key_dumper (); + Object_key_dumper (); SCM get_file_contents () const; SCM dump_key (Object_key const *); }; -DECLARE_UNSMOB(Object_key_dumper, key_dumper); +DECLARE_UNSMOB (Object_key_dumper, key_dumper); #endif /* OBJECT_KEY_DUMPER_HH */ diff --git a/lily/include/object-key-undumper.hh b/lily/include/object-key-undumper.hh index 95af156eec..e74976a898 100644 --- a/lily/include/object-key-undumper.hh +++ b/lily/include/object-key-undumper.hh @@ -4,26 +4,25 @@ source file of the GNU LilyPond music typesetter (c) 2004--2005 Han-Wen Nienhuys - */ #ifndef OBJECT_KEY_UNDUMPER_HH #define OBJECT_KEY_UNDUMPER_HH #include -#include "object-key.hh" +#include "object-key.hh" -typedef std::map Int_to_key_map; +typedef std::map < int, Object_key const *> Int_to_key_map; struct Object_key_undumper { - DECLARE_SMOBS(Object_key_undumper, ); + DECLARE_SMOBS (Object_key_undumper,); Int_to_key_map keys_; public: void parse_contents (SCM); Object_key_undumper (); Object_key const *get_key (int k); }; -DECLARE_UNSMOB(Object_key_undumper, key_undumper); +DECLARE_UNSMOB (Object_key_undumper, key_undumper); #endif diff --git a/lily/include/object-key.hh b/lily/include/object-key.hh index 755b72f122..d8ebf33eb6 100644 --- a/lily/include/object-key.hh +++ b/lily/include/object-key.hh @@ -4,7 +4,6 @@ source file of the GNU LilyPond music typesetter (c) 2004--2005 Han-Wen Nienhuys - */ #ifndef OBJECT_KEY_HH @@ -18,16 +17,16 @@ In the future, they might also act as handles for external processes requesting notation to be drawn. - */ +*/ class Object_key { - DECLARE_SMOBS(Object_key, ); + DECLARE_SMOBS (Object_key,); protected: - Object_key(); + Object_key (); virtual void derived_mark () const; virtual int get_type () const; - virtual int do_compare (Object_key const * other) const; + virtual int do_compare (Object_key const *other) const; virtual SCM as_scheme () const; public: static Object_key *from_scheme (SCM); @@ -36,40 +35,41 @@ public: SCM dump () const; }; -enum Object_key_type { - BASE_KEY, - COPIED_KEY, - GENERAL_KEY, - GROB_KEY, - CONTEXT_KEY, - KEY_COUNT, -}; +enum Object_key_type + { + BASE_KEY, + COPIED_KEY, + GENERAL_KEY, + GROB_KEY, + CONTEXT_KEY, + KEY_COUNT, + }; class Copied_key : public Object_key { private: - Object_key const * original_; + Object_key const *original_; int copy_count_; protected: virtual void derived_mark () const; virtual int get_type () const; - virtual int do_compare (Object_key const * other) const; + virtual int do_compare (Object_key const *other) const; virtual SCM as_scheme () const; public: static Object_key *from_scheme (SCM); - Copied_key (Object_key const*, int); + Copied_key (Object_key const *, int); }; -DECLARE_UNSMOB(Object_key, key); +DECLARE_UNSMOB (Object_key, key); -struct Object_key_less { - bool operator () (Object_key const *const &t1, Object_key const *const &t2) const +struct Object_key_less +{ + bool operator() (Object_key const *const &t1, Object_key const *const &t2) const { return t1->compare (t2); } }; - #endif /* OBJECT_KEY_HH */ diff --git a/lily/include/open-type-font.hh b/lily/include/open-type-font.hh index 7b9d05a1ac..b58f6dcf89 100644 --- a/lily/include/open-type-font.hh +++ b/lily/include/open-type-font.hh @@ -4,7 +4,6 @@ source file of the GNU LilyPond music typesetter (c) 2004--2005 Han-Wen Nienhuys - */ #ifndef OPEN_TYPE_FONT_HH @@ -14,16 +13,16 @@ #include "freetype.hh" #include "font-metric.hh" -typedef std::map Index_to_charcode_map; +typedef std::map < FT_UInt, FT_ULong> Index_to_charcode_map; Index_to_charcode_map make_index_to_charcode_map (FT_Face face); class Open_type_font : public Font_metric { - /* handle to face object */ + /* handle to face object */ FT_Face face_; - SCM lily_subfonts_; - SCM lily_character_table_; + SCM lily_subfonts_; + SCM lily_character_table_; SCM lily_global_table_; Index_to_charcode_map index_to_charcode_map_; Open_type_font (FT_Face); @@ -32,10 +31,10 @@ public: SCM get_subfonts () const; SCM get_global_table () const; SCM get_char_table () const; - + static SCM make_otf (String); virtual String font_name () const; - virtual ~Open_type_font(); + virtual ~Open_type_font (); virtual Offset attachment_point (String) const; virtual int count () const; virtual Box get_indexed_char (int) const; diff --git a/lily/include/pango-font.hh b/lily/include/pango-font.hh index 31b858f143..68a55f65b8 100644 --- a/lily/include/pango-font.hh +++ b/lily/include/pango-font.hh @@ -22,13 +22,13 @@ class Pango_font : public Font_metric { PangoContext *context_; - PangoFontDescription *pango_description_; + PangoFontDescription *pango_description_; PangoAttrList *attribute_list_; Real scale_; SCM physical_font_tab_; public: - SCM physical_font_tab () const; + SCM physical_font_tab () const; Pango_font (PangoFT2FontMap *, Direction leftright, PangoFontDescription *, @@ -38,7 +38,7 @@ public: SCM font_file_name () const; void register_font_file (String, String); Stencil text_stencil (String) const; - Stencil pango_item_string_stencil (PangoItem*, String, Real) const; + Stencil pango_item_string_stencil (PangoItem *, String, Real) const; virtual void derived_mark () const; }; diff --git a/lily/include/paper-book.hh b/lily/include/paper-book.hh index 1b783fd5fa..982d5f241f 100644 --- a/lily/include/paper-book.hh +++ b/lily/include/paper-book.hh @@ -21,7 +21,7 @@ class Stencil; class Paper_book { - DECLARE_SMOBS (Paper_book, ); + DECLARE_SMOBS (Paper_book,); SCM systems_; SCM pages_; @@ -31,7 +31,7 @@ public: SCM header_0_; SCM scores_; Output_def *paper_; - + Paper_book (); void add_score (SCM); diff --git a/lily/include/paper-column.hh b/lily/include/paper-column.hh index 630d0acaf9..bb9cdfefb1 100644 --- a/lily/include/paper-column.hh +++ b/lily/include/paper-column.hh @@ -6,42 +6,40 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef PAPER_COLUMN_HH #define PAPER_COLUMN_HH #include "item.hh" #include "rod.hh" - class Paper_column : public Item -{ +{ public: - int rank_; + int rank_; /// if lines are broken then this column is in #line# System *system_; - Paper_column (SCM, Object_key const*); - Paper_column (Paper_column const&, int count); - + Paper_column (SCM, Object_key const *); + Paper_column (Paper_column const &, int count); + virtual Grob *clone (int count) const; - static bool has_interface (Grob*); + static bool has_interface (Grob *); virtual void do_break_processing (); virtual Paper_column *get_column () const; virtual System *get_system () const; - - static int get_rank (Grob*); - + + static int get_rank (Grob *); + DECLARE_SCHEME_CALLBACK (print, (SCM)); DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM)); - + static bool is_musical (Grob *); - static Moment when_mom (Grob*); + static Moment when_mom (Grob *); - static bool is_used (Grob*) ; + static bool is_used (Grob *); void set_rank (int); }; - + #endif // PAPER_COLUMN_HH diff --git a/lily/include/paper-outputter.hh b/lily/include/paper-outputter.hh index 95b8fc038a..77963e8449 100644 --- a/lily/include/paper-outputter.hh +++ b/lily/include/paper-outputter.hh @@ -6,7 +6,6 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef PAPER_OUTPUTTER_HH #define PAPER_OUTPUTTER_HH @@ -26,9 +25,8 @@ class Paper_outputter String file_name_; SCM file_; - public: - DECLARE_SMOBS (Paper_outputter, ); + DECLARE_SMOBS (Paper_outputter,); public: SCM file (); @@ -37,7 +35,7 @@ public: Paper_outputter (String nm, String format); SCM scheme_to_string (SCM); void output_stencil (Stencil); - void close(); + void close (); }; Paper_outputter *get_paper_outputter (String, String); diff --git a/lily/include/paper-score.hh b/lily/include/paper-score.hh index f20b1b34ef..bd90ec1de2 100644 --- a/lily/include/paper-score.hh +++ b/lily/include/paper-score.hh @@ -22,8 +22,8 @@ public: Paper_score (); int find_col_idx (Paper_column const *) const; - Link_array broken_col_range (Item const*, Item const*) const; - void typeset_line (System*); + Link_array broken_col_range (Item const *, Item const *) const; + void typeset_line (System *); void output (); protected: diff --git a/lily/include/paper-system.hh b/lily/include/paper-system.hh index 5a7ff28446..2c4930b363 100644 --- a/lily/include/paper-system.hh +++ b/lily/include/paper-system.hh @@ -16,11 +16,10 @@ To save memory, we don't keep around the System grobs, but put the formatted content of the grob is put into a Paper_system. Page-breaking handles Paper_system objects. - - */ +*/ class Paper_system { - DECLARE_SMOBS (Paper_system, ); + DECLARE_SMOBS (Paper_system,); Stencil stencil_; bool is_title_; public: @@ -29,7 +28,7 @@ public: int number_; Paper_system (Stencil, bool); - + Stencil to_stencil () const; SCM stencils () const; bool is_title () const; diff --git a/lily/include/parse-scm.hh b/lily/include/parse-scm.hh index dc71ad7402..5489593189 100644 --- a/lily/include/parse-scm.hh +++ b/lily/include/parse-scm.hh @@ -4,7 +4,6 @@ source file of the GNU LilyPond music typesetter (c) 2004--2005 Han-Wen Nienhuys - */ #ifndef PARSE_SCM_HH @@ -17,7 +16,7 @@ extern bool parse_protect_global; struct Parse_start { - char const* str; + char const *str; int nchars; Input start_location_; bool safe_; diff --git a/lily/include/percent-repeat-item.hh b/lily/include/percent-repeat-item.hh index 6d6cf637c5..4983a20728 100644 --- a/lily/include/percent-repeat-item.hh +++ b/lily/include/percent-repeat-item.hh @@ -1,11 +1,10 @@ -/* +/* percent-repeat-item.hh -- declare Percent_repeat_item_interface - + source file of the GNU LilyPond music typesetter - + (c) 2001--2005 Han-Wen Nienhuys - - */ +*/ #ifndef PERCENT_REPEAT_ITEM_HH #define PERCENT_REPEAT_ITEM_HH @@ -15,11 +14,11 @@ class Percent_repeat_item_interface { public: - static bool has_interface (Grob*); - DECLARE_SCHEME_CALLBACK (beat_slash, (SCM )); - DECLARE_SCHEME_CALLBACK (double_percent, (SCM )); - static Stencil x_percent (Grob*, int, Real, Real ); - static Stencil brew_slash (Grob*); + static bool has_interface (Grob *); + DECLARE_SCHEME_CALLBACK (beat_slash, (SCM)); + DECLARE_SCHEME_CALLBACK (double_percent, (SCM)); + static Stencil x_percent (Grob *, int, Real, Real); + static Stencil brew_slash (Grob *); }; #endif /* PERCENT_REPEAT_ITEM_HH */ diff --git a/lily/include/percent-repeat-iterator.hh b/lily/include/percent-repeat-iterator.hh index 618b9fd33e..733ab0c537 100644 --- a/lily/include/percent-repeat-iterator.hh +++ b/lily/include/percent-repeat-iterator.hh @@ -1,11 +1,10 @@ -/* +/* percent-repeat-iterator.hh -- declare Percent_repeat_iterator - + source file of the GNU LilyPond music typesetter - + (c) 2001--2005 Han-Wen Nienhuys - - */ +*/ #ifndef PERCENT_REPEAT_ITERATOR_HH #define PERCENT_REPEAT_ITERATOR_HH @@ -15,23 +14,22 @@ class Percent_repeat_iterator : public Music_iterator { public: - DECLARE_SCHEME_CALLBACK(constructor, ()); + DECLARE_SCHEME_CALLBACK (constructor, ()); Percent_repeat_iterator (); protected: - virtual void derived_substitute (Context *f, Context *t) ; + virtual void derived_substitute (Context *f, Context *t); virtual void derived_mark () const; virtual Moment pending_moment () const; - virtual void do_quit(); - virtual void construct_children () ; + virtual void do_quit (); + virtual void construct_children (); virtual bool ok () const; - virtual void process (Moment) ; + virtual void process (Moment); virtual Music_iterator *try_music_in_children (Music *) const; private: - Music_iterator * child_iter_; + Music_iterator *child_iter_; Moment finish_mom_; }; - #endif /* PERCENT_REPEAT_ITERATOR_HH */ diff --git a/lily/include/performance.hh b/lily/include/performance.hh index 5d13dab3d3..596e877775 100644 --- a/lily/include/performance.hh +++ b/lily/include/performance.hh @@ -2,7 +2,7 @@ performance.hh -- declare Performance (c) 1997--2005 Jan Nieuwenhuizen - */ +*/ #ifndef PERFORMANCE_HH #define PERFORMANCE_HH @@ -18,10 +18,10 @@ public: Performance (); ~Performance (); - void add_element (Audio_element*p); - - void output (Midi_stream& midi_stream_r); - void output_header_track (Midi_stream& midi_stream_r); + void add_element (Audio_element *p); + + void output (Midi_stream &midi_stream_r); + void output_header_track (Midi_stream &midi_stream_r); void print () const; SCM process (String); diff --git a/lily/include/performer-group-performer.hh b/lily/include/performer-group-performer.hh index b12d91295d..f2e4d44922 100644 --- a/lily/include/performer-group-performer.hh +++ b/lily/include/performer-group-performer.hh @@ -2,8 +2,8 @@ performer-group-performer.hh -- declare Performer_group_performer (c) 1996--2005 Han-Wen Nienhuys - Jan Nieuwenhuizen - */ + Jan Nieuwenhuizen +*/ #ifndef PERFORMER_GROUP_PERFORMER_HH #define PERFORMER_GROUP_PERFORMER_HH @@ -13,10 +13,11 @@ typedef void (Performer::*Performer_method) (void); -class Performer_group_performer : public Performer, public virtual Translator_group { +class Performer_group_performer : public Performer, public virtual Translator_group +{ public: - TRANSLATOR_DECLARATIONS(Performer_group_performer); - + TRANSLATOR_DECLARATIONS (Performer_group_performer); + virtual void do_announces (); virtual void announce_element (Audio_element_info); protected: diff --git a/lily/include/performer.hh b/lily/include/performer.hh index b97d35e553..b912cd720c 100644 --- a/lily/include/performer.hh +++ b/lily/include/performer.hh @@ -2,8 +2,8 @@ performer.hh -- declare Performer (c) 1996--2005 Han-Wen Nienhuys - Jan Nieuwenhuizen - */ + Jan Nieuwenhuizen +*/ #ifndef PERFORMER_HH #define PERFORMER_HH @@ -19,17 +19,16 @@ class Performer : public virtual Translator { public: VIRTUAL_COPY_CONSTRUCTOR (Translator, Performer); - friend class Performer_group_performer; - Performer_group_performer* get_daddy_performer () const; + friend class Performer_group_performer; + Performer_group_performer *get_daddy_performer () const; protected: virtual void announce_element (Audio_element_info); virtual void acknowledge_audio_element (Audio_element_info); virtual void create_audio_elements (); virtual int get_tempo () const; - virtual void play_element (Audio_element * elem ); + virtual void play_element (Audio_element *elem); }; - #endif /* PERFORMER_HH */ diff --git a/lily/include/pitch-interval.hh b/lily/include/pitch-interval.hh index 0b621c3c5c..9a762d370d 100644 --- a/lily/include/pitch-interval.hh +++ b/lily/include/pitch-interval.hh @@ -1,10 +1,9 @@ -/* +/* pitch-interval.hh -- declare Pitch_interval - + source file of the GNU LilyPond music typesetter - + (c) 2004--2005 Han-Wen Nienhuys - */ #ifndef PITCH_INTERVAL_HH @@ -12,11 +11,11 @@ #include "pitch.hh" -class Pitch_interval : public Drul_array +class Pitch_interval : public Drul_array { public: - Pitch_interval(); - Pitch_interval(Pitch, Pitch); + Pitch_interval (); + Pitch_interval (Pitch, Pitch); void add_point (Pitch); bool is_empty () const; }; diff --git a/lily/include/pitch.hh b/lily/include/pitch.hh index 8be2dc3404..6c36392a9d 100644 --- a/lily/include/pitch.hh +++ b/lily/include/pitch.hh @@ -1,11 +1,10 @@ -/* +/* pitch.hh -- declare Pitch - + source file of the GNU LilyPond music typesetter - + (c) 1998--2005 Han-Wen Nienhuys - - */ +*/ #ifndef MUSICAL_PITCH_HH #define MUSICAL_PITCH_HH @@ -14,36 +13,35 @@ #include "smobs.hh" /** A "tonal" pitch. This is a pitch used in diatonal western music - (24 quartertones in an octave), as opposed to a frequency in Hz or a - integer number of semitones. + (24 quartertones in an octave), as opposed to a frequency in Hz or a + integer number of semitones. - Pitch is lexicographically ordered by (octave, notename, - alteration). - + Pitch is lexicographically ordered by (octave, notename, + alteration). - TODO: - - add indeterminate octaves, so it can be used as a key in keySigature + TODO: + - add indeterminate octaves, so it can be used as a key in keySigature */ class Pitch { private: // fixme /* TODO: use SCM - */ + */ int notename_; int alteration_; int octave_; - + void transpose (Pitch); void up_to (int); void down_to (int); void normalise (); public: - + int get_octave () const; int get_notename () const; int get_alteration () const; @@ -54,39 +52,39 @@ public: Pitch transposed (Pitch) const; Pitch to_relative_octave (Pitch) const; - static int compare (Pitch const&, Pitch const&); + static int compare (Pitch const &, Pitch const &); int steps () const; - int semitone_pitch () const; - int quartertone_pitch () const; + int semitone_pitch () const; + int quartertone_pitch () const; String to_string () const; DECLARE_SCHEME_CALLBACK (less_p, (SCM a, SCM b)); - DECLARE_SIMPLE_SMOBS (Pitch, ); -}; - -enum { - DOUBLE_FLAT = -4, - THREE_Q_FLAT, - FLAT , - SEMI_FLAT, - NATURAL, - SEMI_SHARP, - SHARP , - THREE_Q_SHARP, - DOUBLE_SHARP, + DECLARE_SIMPLE_SMOBS (Pitch,); }; -SCM ly_pitch_diff (SCM pitch, SCM root); +enum + { + DOUBLE_FLAT = -4, + THREE_Q_FLAT, + FLAT, + SEMI_FLAT, + NATURAL, + SEMI_SHARP, + SHARP, + THREE_Q_SHARP, + DOUBLE_SHARP, + }; + +SCM ly_pitch_diff (SCM pitch, SCM root); SCM ly_pitch_transpose (SCM p, SCM delta); -DECLARE_UNSMOB(Pitch, pitch); +DECLARE_UNSMOB (Pitch, pitch); INSTANTIATE_COMPARE (Pitch, Pitch::compare); int compare (Array*, Array*); extern SCM pitch_less_proc; -Pitch pitch_interval (Pitch const & from , Pitch const & to ); +Pitch pitch_interval (Pitch const &from, Pitch const &to); #endif /* MUSICAL_PITCH_HH */ - diff --git a/lily/include/property-iterator.hh b/lily/include/property-iterator.hh index ecd7eb3c40..81c4804229 100644 --- a/lily/include/property-iterator.hh +++ b/lily/include/property-iterator.hh @@ -6,39 +6,34 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef PROPERTY_ITERATOR_HH #define PROPERTY_ITERATOR_HH #include "simple-music-iterator.hh" - - /** - Iterate a property. - */ + Iterate a property. +*/ class Property_iterator : public Simple_music_iterator { public: - DECLARE_SCHEME_CALLBACK(constructor, ()); - DECLARE_SCHEME_CALLBACK(once_finalization, (SCM, SCM )); + DECLARE_SCHEME_CALLBACK (constructor, ()); + DECLARE_SCHEME_CALLBACK (once_finalization, (SCM, SCM)); protected: - virtual void do_quit(); + virtual void do_quit (); virtual void process (Moment); }; - - /** - Iterate a property. - */ + Iterate a property. +*/ class Property_unset_iterator : public Simple_music_iterator { public: - DECLARE_SCHEME_CALLBACK(constructor, ()); + DECLARE_SCHEME_CALLBACK (constructor, ()); protected: virtual void process (Moment); }; @@ -46,20 +41,19 @@ protected: class Push_property_iterator : public Simple_music_iterator { public: - DECLARE_SCHEME_CALLBACK(constructor, ()); - DECLARE_SCHEME_CALLBACK(once_finalization, (SCM, SCM)); + DECLARE_SCHEME_CALLBACK (constructor, ()); + DECLARE_SCHEME_CALLBACK (once_finalization, (SCM, SCM)); protected: virtual void process (Moment); - virtual void do_quit(); + virtual void do_quit (); }; class Pop_property_iterator : public Simple_music_iterator { public: - DECLARE_SCHEME_CALLBACK(constructor, ()); + DECLARE_SCHEME_CALLBACK (constructor, ()); protected: virtual void process (Moment); }; - #endif // PROPERTY_ITERATOR_HH diff --git a/lily/include/protected-scm.hh b/lily/include/protected-scm.hh index 81ff41f1da..0bb88dd237 100644 --- a/lily/include/protected-scm.hh +++ b/lily/include/protected-scm.hh @@ -1,21 +1,19 @@ -/* +/* protected-scm.hh -- declare Protected_scm - + source file of the GNU LilyPond music typesetter - + (c) 1998--2005 Han-Wen Nienhuys - - */ +*/ #ifndef PROTECTED_SCM_HH #define PROTECTED_SCM_HH - #include "lily-guile.hh" /* - Mix GUILE GC with C++ ctors and dtors. - */ + Mix GUILE GC with C++ ctors and dtors. +*/ class Protected_scm { SCM object_; @@ -24,8 +22,8 @@ public: Protected_scm (SCM); Protected_scm (Protected_scm const &); ~Protected_scm (); - Protected_scm &operator = (SCM); - Protected_scm &operator = ( Protected_scm const&); + Protected_scm &operator= (SCM); + Protected_scm &operator= (Protected_scm const &); operator SCM () const; SCM to_SCM () const; }; diff --git a/lily/include/repeated-music.hh b/lily/include/repeated-music.hh index ce702fa2af..d62042f0e4 100644 --- a/lily/include/repeated-music.hh +++ b/lily/include/repeated-music.hh @@ -1,18 +1,16 @@ -/* +/* repeated-music.hh -- declare Repeated_music - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - - */ +*/ #ifndef REPEATED_MUSIC_HH #define REPEATED_MUSIC_HH #include "music.hh" - /** Musical repeats. @@ -25,12 +23,12 @@ There are three modes of representing this music: BODY A - B - C + B + C is called "folded". Mostly used for lyrics. - + BODY A B C is called volta. This is common notation @@ -44,28 +42,26 @@ If the number of repeats is bigger than the number of alternatives, then the first alternative is assumed to be repeated. - */ class Repeated_music { public: - static Music *body (Music*); - static SCM alternatives (Music*); + static Music *body (Music *); + static SCM alternatives (Music *); /* How often do we repeat? */ - static int repeat_count (Music*); - DECLARE_SCHEME_CALLBACK(relative_callback, (SCM, SCM)); + static int repeat_count (Music *); + DECLARE_SCHEME_CALLBACK (relative_callback, (SCM, SCM)); - static Moment body_get_length (Music*); + static Moment body_get_length (Music *); static Moment alternatives_get_length (Music *, bool fold); - static Moment alternatives_volta_get_length (Music *); + static Moment alternatives_volta_get_length (Music *); DECLARE_SCHEME_CALLBACK (unfolded_music_length, (SCM)); DECLARE_SCHEME_CALLBACK (volta_music_length, (SCM)); - DECLARE_SCHEME_CALLBACK (folded_music_length, (SCM)); + DECLARE_SCHEME_CALLBACK (folded_music_length, (SCM)); DECLARE_SCHEME_CALLBACK (minimum_start, (SCM)); - DECLARE_SCHEME_CALLBACK (first_start, (SCM)); + DECLARE_SCHEME_CALLBACK (first_start, (SCM)); }; - #endif /* REPEATED_MUSIC_HH */ diff --git a/lily/include/rest-collision.hh b/lily/include/rest-collision.hh index a54a526a77..a0897dff64 100644 --- a/lily/include/rest-collision.hh +++ b/lily/include/rest-collision.hh @@ -6,7 +6,6 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef REST_COLLISION_HH #define REST_COLLISION_HH @@ -14,16 +13,14 @@ #include "lily-guile.hh" - - class Rest_collision { public: - static void add_column (Grob*me, Grob*); - - static bool has_interface (Grob*); + static void add_column (Grob *me, Grob *); + + static bool has_interface (Grob *); DECLARE_SCHEME_CALLBACK (force_shift_callback, (SCM element, SCM axis)); DECLARE_SCHEME_CALLBACK (force_shift_callback_rest, (SCM element, SCM axis)); - static SCM do_shift (Grob*); + static SCM do_shift (Grob *); }; #endif // REST_COLLISION_HH diff --git a/lily/include/rest.hh b/lily/include/rest.hh index 9513d8c82a..22be2d4b5b 100644 --- a/lily/include/rest.hh +++ b/lily/include/rest.hh @@ -6,7 +6,6 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef REST_HH #define REST_HH @@ -14,15 +13,15 @@ class Grob; -class Rest +class Rest { public: - DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM )); - static bool has_interface (Grob*); - static String glyph_name (Grob*, int, String, bool); + DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM)); + static bool has_interface (Grob *); + static String glyph_name (Grob *, int, String, bool); static SCM brew_internal_stencil (SCM, bool); DECLARE_SCHEME_CALLBACK (extent_callback, (SCM, SCM)); DECLARE_SCHEME_CALLBACK (polyphonic_offset_callback, (SCM, SCM)); - DECLARE_SCHEME_CALLBACK (print, (SCM )); + DECLARE_SCHEME_CALLBACK (print, (SCM)); }; #endif // REST_HH diff --git a/lily/include/rhythmic-head.hh b/lily/include/rhythmic-head.hh index 12cbf575a0..10b69b3ef9 100644 --- a/lily/include/rhythmic-head.hh +++ b/lily/include/rhythmic-head.hh @@ -6,7 +6,6 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef RHYTHMIC_HEAD_HH #define RHYTHMIC_HEAD_HH @@ -16,14 +15,14 @@ class Rhythmic_head { public: - static int duration_log (Grob*); - static void set_dots (Grob*, Item *); - static Item * get_stem (Grob*) ; - static Item * get_dots (Grob*) ; - static int dot_count (Grob*) ; - DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM )); - static bool has_interface (Grob*); - + static int duration_log (Grob *); + static void set_dots (Grob *, Item *); + static Item *get_stem (Grob *); + static Item *get_dots (Grob *); + static int dot_count (Grob *); + DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM)); + static bool has_interface (Grob *); + }; #endif // RHYTHMIC_HEAD_HH diff --git a/lily/include/rod.hh b/lily/include/rod.hh index d334db2a37..4916f1e444 100644 --- a/lily/include/rod.hh +++ b/lily/include/rod.hh @@ -1,11 +1,10 @@ -/* +/* rod.hh -- declare Rod, Column_rod - + source file of the GNU LilyPond music typesetter - + (c) 1998--2005 Han-Wen Nienhuys - - */ +*/ #ifndef ROD_HH #define ROD_HH @@ -15,14 +14,14 @@ struct Rod { - Drul_array item_drul_; + Drul_array item_drul_; Real distance_; /** - translate the rod so as to refer to Paper_columns - */ + translate the rod so as to refer to Paper_columns + */ void columnize (); - + void add_to_cols (); Rod (); diff --git a/lily/include/scm-hash.hh b/lily/include/scm-hash.hh index f3134127fa..8dd635f67d 100644 --- a/lily/include/scm-hash.hh +++ b/lily/include/scm-hash.hh @@ -1,43 +1,39 @@ -/* +/* scm-hash.hh -- declare Scheme hasher. - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - - */ +*/ #ifndef SCM_HASH_HH #define SCM_HASH_HH - #include "smobs.hh" - /** - auto resizing hash table. + auto resizing hash table. 1. ALWAYS USE THIS AS VIA A POINTER, i.e. class Foo { - Scheme_hash_table * tab; + Scheme_hash_table * tab; }; and NOT class Foo { - Scheme_hash_table tab; + Scheme_hash_table tab; } 2. UPON DESTRUCTION, DO scm_gc_unprotect_object (tab->self_scm_); - - */ +*/ class Scheme_hash_table -{ +{ public: bool try_retrieve (SCM key, SCM *val); bool contains (SCM key) const; @@ -46,10 +42,10 @@ public: WARNING: putting something in assumes responsibility for cleaning up. */ void set (SCM k, SCM v); - SCM get (SCM k) const; + SCM get (SCM k) const; void remove (SCM k); Scheme_hash_table (); - void operator = (Scheme_hash_table const &); + void operator= (Scheme_hash_table const &); Scheme_hash_table (Scheme_hash_table const &); SCM to_alist () const; @@ -57,10 +53,9 @@ public: private: SCM hash_tab_; unsigned elt_count_; - + DECLARE_SMOBS (Scheme_hash_table, foo); }; - #endif /* SCM_HASH_HH */ diff --git a/lily/include/score-context.hh b/lily/include/score-context.hh index 6fc57aa690..f22038a841 100644 --- a/lily/include/score-context.hh +++ b/lily/include/score-context.hh @@ -1,8 +1,8 @@ /* score-context.hh -- declare Score_context - + source file of the GNU LilyPond music typesetter - + (c) 2004--2005 Han-Wen Nienhuys */ #ifndef SCORE_CONTEXT_HH @@ -12,10 +12,10 @@ class Score_context : public Context { - public: - Score_context (Object_key const*); - - virtual Music_output *get_output (); +public: + Score_context (Object_key const *); + + virtual Music_output *get_output (); virtual void prepare (Moment); virtual void finish (); virtual void one_time_step (); diff --git a/lily/include/score-engraver.hh b/lily/include/score-engraver.hh index 0f8deada9c..a790b5f967 100644 --- a/lily/include/score-engraver.hh +++ b/lily/include/score-engraver.hh @@ -6,7 +6,6 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef SCORE_ENGRAVER_HH #define SCORE_ENGRAVER_HH @@ -18,33 +17,33 @@ class Score_engraver : public virtual Score_translator, { System *system_; int breaks_; // used for stat printing - + Link_array elems_; - Paper_column* command_column_; - Paper_column* musical_column_; - Paper_score * pscore_; + Paper_column *command_column_; + Paper_column *musical_column_; + Paper_score *pscore_; void make_columns (); - void set_columns (Paper_column*, Paper_column*); + void set_columns (Paper_column *, Paper_column *); void typeset_all (); protected: /* Score_translator */ virtual void finish (); virtual void prepare (Moment); virtual void one_time_step (); - + /* Engraver_group_engraver interface */ virtual void acknowledge_grob (Grob_info); - virtual bool try_music (Music*); + virtual bool try_music (Music *); virtual void initialize (); virtual void finalize (); virtual void announce_grob (Grob_info); virtual void stop_translation_timestep (); public: - TRANSLATOR_DECLARATIONS(Score_engraver); + TRANSLATOR_DECLARATIONS (Score_engraver); void forbid_breaks (); - virtual Music_output *get_output (); + virtual Music_output *get_output (); }; #endif /* SCORE_ENGRAVER_HH */ diff --git a/lily/include/score-performer.hh b/lily/include/score-performer.hh index 9b4303e5c2..9c36525db8 100644 --- a/lily/include/score-performer.hh +++ b/lily/include/score-performer.hh @@ -2,8 +2,8 @@ score-performer.hh -- declare Score_performer (c) 1996--2005 Han-Wen Nienhuys - Jan Nieuwenhuizen - */ + Jan Nieuwenhuizen +*/ #ifndef SCORE_PERFORMER_HH #define SCORE_PERFORMER_HH @@ -12,15 +12,15 @@ #include "score-translator.hh" /** - Top level performer. Completely takes care of MIDI output - */ + Top level performer. Completely takes care of MIDI output +*/ class Score_performer : public Score_translator, public virtual Performer_group_performer { public: - TRANSLATOR_DECLARATIONS(Score_performer); + TRANSLATOR_DECLARATIONS (Score_performer); ~Score_performer (); Performance *performance_; - + protected: virtual void prepare (Moment mom); virtual void finish (); @@ -28,12 +28,12 @@ protected: virtual void initialize (); virtual void announce_element (Audio_element_info); virtual int get_tempo () const; - virtual void play_element (Audio_element* p); + virtual void play_element (Audio_element *p); virtual Music_output *get_output (); private: - void header (Midi_stream&); + void header (Midi_stream &); - Audio_column* audio_column_; + Audio_column *audio_column_; }; #endif // SCORE_PERFORMER_HH diff --git a/lily/include/score-translator.hh b/lily/include/score-translator.hh index 39823bf13d..532ef94348 100644 --- a/lily/include/score-translator.hh +++ b/lily/include/score-translator.hh @@ -1,28 +1,25 @@ -/* +/* score-translator.hh -- declare Score_translator -source file of the GNU LilyPond music typesetter + source file of the GNU LilyPond music typesetter -(c) 2004--2005 Han-Wen Nienhuys - - */ + (c) 2004--2005 Han-Wen Nienhuys +*/ #ifndef SCORE_TRANSLATOR_HH #define SCORE_TRANSLATOR_HH -#include "translator-group.hh" +#include "translator-group.hh" -class Score_translator : public virtual Translator_group +class Score_translator : public virtual Translator_group { friend class Score_context; - protected: - virtual Music_output* get_output (); +protected: + virtual Music_output *get_output (); virtual void prepare (Moment); virtual void finish (); virtual void one_time_step (); }; - #endif /* SCORE_TRANSLATOR_HH */ - diff --git a/lily/include/score.hh b/lily/include/score.hh index bb879e9841..f1c42fb1a6 100644 --- a/lily/include/score.hh +++ b/lily/include/score.hh @@ -29,13 +29,13 @@ public: SCM header_; SCM texts_; bool error_found_; - + Score (); - Score (Score const&); + Score (Score const &); SCM get_music () const; void set_music (SCM music, SCM parser); - SCM book_rendering (String, Output_def*, Output_def*, Object_key*); + SCM book_rendering (String, Output_def *, Output_def *, Object_key *); }; DECLARE_UNSMOB (Score, score); diff --git a/lily/include/script-column.hh b/lily/include/script-column.hh index 0d8417fb8d..0bbb662566 100644 --- a/lily/include/script-column.hh +++ b/lily/include/script-column.hh @@ -1,11 +1,10 @@ -/* +/* g-script-column.hh -- declare Script_column - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - - */ +*/ #ifndef Script_COLUMN_HH #define Script_COLUMN_HH @@ -16,13 +15,11 @@ class Script_column { public: - static void add_staff_sided (Grob*, Item*); - DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM )); - static bool has_interface (Grob*); + static void add_staff_sided (Grob *, Item *); + DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM)); + static bool has_interface (Grob *); }; - #endif /* Script_COLUMN_HH */ - diff --git a/lily/include/script-interface.hh b/lily/include/script-interface.hh index 4f2defdb23..74efaaf06c 100644 --- a/lily/include/script-interface.hh +++ b/lily/include/script-interface.hh @@ -1,5 +1,5 @@ -/* - script-interface.hh -- +/* + script-interface.hh -- source file of the GNU LilyPond music typesetter @@ -22,7 +22,7 @@ class Script_interface public: static Stencil get_stencil (Grob *, Direction d); static bool has_interface (Grob *); - DECLARE_SCHEME_CALLBACK (print, (SCM )); + DECLARE_SCHEME_CALLBACK (print, (SCM)); DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM)); }; diff --git a/lily/include/self-alignment-interface.hh b/lily/include/self-alignment-interface.hh index 6f3d63de9c..aa47c7af76 100644 --- a/lily/include/self-alignment-interface.hh +++ b/lily/include/self-alignment-interface.hh @@ -1,11 +1,10 @@ -/* +/* side-position-interface.hh -- declare Side_position_interface - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - - */ +*/ #ifndef SELF_ALIGNMENT_INTERFACE_HH #define SELF_ALIGNMENT_INTERFACE_HH @@ -14,7 +13,7 @@ struct Self_alignment_interface { - static bool has_interface (Grob*); + static bool has_interface (Grob *); DECLARE_SCHEME_CALLBACK (aligned_on_self, (SCM element, SCM axis)); DECLARE_SCHEME_CALLBACK (centered_on_parent, (SCM element, SCM axis)); DECLARE_SCHEME_CALLBACK (aligned_on_parent, (SCM element, SCM axis)); diff --git a/lily/include/separating-group-spanner.hh b/lily/include/separating-group-spanner.hh index 40c1489218..8a082b8f4e 100644 --- a/lily/include/separating-group-spanner.hh +++ b/lily/include/separating-group-spanner.hh @@ -1,11 +1,10 @@ -/* +/* separating-group-spanner.hh -- declare Separating_group_spanner - + source file of the GNU LilyPond music typesetter - + (c) 1998--2005 Han-Wen Nienhuys - - */ +*/ #ifndef SEPARATING_GROUP_SPANNER_HH #define SEPARATING_GROUP_SPANNER_HH @@ -14,12 +13,12 @@ class Separating_group_spanner { - static void find_rods (Item*, SCM, Real); + static void find_rods (Item *, SCM, Real); public: - static void add_spacing_unit (Grob*me, Item*); - - static bool has_interface (Grob*); - DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM )); + static void add_spacing_unit (Grob *me, Item *); + + static bool has_interface (Grob *); + DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM)); }; #endif /* SEPARATING_GROUP_SPANNER_HH */ diff --git a/lily/include/separation-item.hh b/lily/include/separation-item.hh index 5573e13368..882bf5d934 100644 --- a/lily/include/separation-item.hh +++ b/lily/include/separation-item.hh @@ -1,11 +1,10 @@ -/* +/* single-malt-grouping-item.hh -- declare Separation_item - + source file of the GNU LilyPond music typesetter - + (c) 1997--2005 Han-Wen Nienhuys - - */ +*/ #ifndef SINGLE_MALT_GROUPING_ITEM_HH #define SINGLE_MALT_GROUPING_ITEM_HH @@ -15,13 +14,13 @@ struct Separation_item { - static bool has_interface (Grob*); - static Interval conditional_width (Grob*, Grob*) ; - static Interval width (Grob*) ; - static Interval relative_width (Grob*, Grob*) ; - static Grob*extremal_break_aligned_grob (Grob*, Direction, Interval*); - static void add_item (Grob*, Item*); - static void add_conditional_item (Grob*, Grob*); + static bool has_interface (Grob *); + static Interval conditional_width (Grob *, Grob *); + static Interval width (Grob *); + static Interval relative_width (Grob *, Grob *); + static Grob *extremal_break_aligned_grob (Grob *, Direction, Interval *); + static void add_item (Grob *, Item *); + static void add_conditional_item (Grob *, Grob *); }; #endif /* SINGLE_MALT_GROUPING_ITEM_HH */ diff --git a/lily/include/sequential-iterator.hh b/lily/include/sequential-iterator.hh index aceb925936..b1e6d45c29 100644 --- a/lily/include/sequential-iterator.hh +++ b/lily/include/sequential-iterator.hh @@ -1,4 +1,4 @@ -/* +/* sequential-iterator.hh -- declare Sequential_iterator source file of the GNU LilyPond music typesetter @@ -12,24 +12,22 @@ #include "music-iterator.hh" #include "protected-scm.hh" - /** Sequential_music iteration: walk each element in turn, and - construct an iterator for every element. - - */ -class Sequential_iterator : public Music_iterator + construct an iterator for every element. +*/ +class Sequential_iterator : public Music_iterator { public: - DECLARE_SCHEME_CALLBACK(constructor, ()); + DECLARE_SCHEME_CALLBACK (constructor, ()); Sequential_iterator (); - Sequential_iterator (Sequential_iterator const&); - virtual void derived_substitute (Context *f, Context *t) ; + Sequential_iterator (Sequential_iterator const &); + virtual void derived_substitute (Context *f, Context *t); virtual void derived_mark () const; virtual void construct_children (); virtual Moment pending_moment () const; - virtual void do_quit(); + virtual void do_quit (); virtual bool ok () const; protected: @@ -37,20 +35,19 @@ protected: virtual Music_iterator *try_music_in_children (Music *) const; virtual bool run_always () const; protected: - Music_iterator * iter_; + Music_iterator *iter_; virtual SCM get_music_list ()const; virtual void next_element (bool side_effect); - Grace_fixup *get_grace_fixup () const; void next_grace_fixup (); - + private: Moment last_mom_; Moment here_mom_; SCM cursor_; - Grace_fixup * grace_fixups_; - + Grace_fixup *grace_fixups_; + }; #endif /* SEQUENTIAL_ITERATOR_HH */ diff --git a/lily/include/sequential-music-iterator.hh b/lily/include/sequential-music-iterator.hh index c84b24906c..f43c5a6a59 100644 --- a/lily/include/sequential-music-iterator.hh +++ b/lily/include/sequential-music-iterator.hh @@ -12,15 +12,14 @@ #include "sequential-iterator.hh" /** Sequential_music iteration: walk each element in turn, and - construct an iterator for every element. - - */ -class Sequential_music_iterator : public Sequential_iterator + construct an iterator for every element. +*/ +class Sequential_music_iterator : public Sequential_iterator { public: - DECLARE_SCHEME_CALLBACK(constructor, ()); + DECLARE_SCHEME_CALLBACK (constructor, ()); private: - virtual SCM get_music_list()const; + virtual SCM get_music_list ()const; }; #endif // SEQUENTIAL_MUSIC_ITERATOR_HH diff --git a/lily/include/side-position-interface.hh b/lily/include/side-position-interface.hh index 5bf8c02f82..ff16b0c386 100644 --- a/lily/include/side-position-interface.hh +++ b/lily/include/side-position-interface.hh @@ -1,11 +1,10 @@ -/* +/* side-position-interface.hh -- declare Side_position_interface - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - - */ +*/ #ifndef SIDE_POSITION_INTERFACE_HH #define SIDE_POSITION_INTERFACE_HH @@ -23,21 +22,19 @@ struct Side_position_interface public: DECLARE_SCHEME_CALLBACK (aligned_on_support_extents, (SCM element, SCM axis)); DECLARE_SCHEME_CALLBACK (aligned_on_support_refpoints, (SCM element, SCM axis)); - - DECLARE_SCHEME_CALLBACK (aligned_side, (SCM element, SCM axis)); + + DECLARE_SCHEME_CALLBACK (aligned_side, (SCM element, SCM axis)); DECLARE_SCHEME_CALLBACK (quantised_position, (SCM element, SCM axis)); - static SCM general_side_position (Grob*, Axis, bool); - static Axis get_axis (Grob*) ; - static void set_axis (Grob*, Axis) ; - static bool has_interface (Grob*) ; - static void add_support (Grob*, Grob*); - static void add_staff_support (Grob*); - static Direction get_direction (Grob*); + static SCM general_side_position (Grob *, Axis, bool); + static Axis get_axis (Grob *); + static void set_axis (Grob *, Axis); + static bool has_interface (Grob *); + static void add_support (Grob *, Grob *); + static void add_staff_support (Grob *); + static Direction get_direction (Grob *); }; - - #endif /* SIDE_POSITION_INTERFACE_HH */ diff --git a/lily/include/simple-music-iterator.hh b/lily/include/simple-music-iterator.hh index 92d275bb37..29710cfa86 100644 --- a/lily/include/simple-music-iterator.hh +++ b/lily/include/simple-music-iterator.hh @@ -1,10 +1,10 @@ -/* +/* simple-music-iterator.hh -- declare Simple_music_iterator - + source file of the GNU LilyPond music typesetter - + (c) 2000--2005 Han-Wen Nienhuys - */ +*/ #ifndef SIMPLE_MUSIC_ITERATOR_HH #define SIMPLE_MUSIC_ITERATOR_HH @@ -14,15 +14,14 @@ /* Iterator for atomic music objects: events are generated at the beginning and at the end of the music. - - */ +*/ class Simple_music_iterator : public Music_iterator { protected: Moment last_processed_mom_; public: - DECLARE_SCHEME_CALLBACK(constructor, ()); + DECLARE_SCHEME_CALLBACK (constructor, ()); Simple_music_iterator (); virtual void process (Moment); virtual bool ok ()const; diff --git a/lily/include/simple-spacer.hh b/lily/include/simple-spacer.hh index 55795dc715..9ffdc175fa 100644 --- a/lily/include/simple-spacer.hh +++ b/lily/include/simple-spacer.hh @@ -1,11 +1,10 @@ -/* +/* simple-spacer.hh -- declare Simple_spacer - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - - */ +*/ #ifndef SIMPLE_SPACER_HH #define SIMPLE_SPACER_HH @@ -38,8 +37,7 @@ public: int active_count_; Simple_spacer (); - - + void my_solve_linelen (); void my_solve_natural_len (); Real active_springs_stiffness () const; @@ -52,10 +50,9 @@ public: void set_active_states (); bool is_active () const; - DECLARE_SIMPLE_SMOBS(Simple_spacer, ); + DECLARE_SIMPLE_SMOBS (Simple_spacer,); }; - struct Simple_spacer_wrapper { Simple_spacer *spacer_; @@ -65,9 +62,9 @@ struct Simple_spacer_wrapper Simple_spacer_wrapper (); void add_columns (Link_array const &); void solve (Column_x_positions *, bool); - ~Simple_spacer_wrapper(); + ~Simple_spacer_wrapper (); private: - Simple_spacer_wrapper(Simple_spacer_wrapper const&); + Simple_spacer_wrapper (Simple_spacer_wrapper const &); }; #endif /* SIMPLE_SPACER_HH */ diff --git a/lily/include/simultaneous-music-iterator.hh b/lily/include/simultaneous-music-iterator.hh index f1b70b6da6..7e8118bc52 100644 --- a/lily/include/simultaneous-music-iterator.hh +++ b/lily/include/simultaneous-music-iterator.hh @@ -6,7 +6,6 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef SIMULTANEOUS_MUSIC_ITERATOR_HH #define SIMULTANEOUS_MUSIC_ITERATOR_HH @@ -16,20 +15,20 @@ class Simultaneous_music_iterator : public Music_iterator { public: Simultaneous_music_iterator (); - Simultaneous_music_iterator (Simultaneous_music_iterator const&); - virtual void derived_substitute (Context *f, Context *t) ; + Simultaneous_music_iterator (Simultaneous_music_iterator const &); + virtual void derived_substitute (Context *f, Context *t); virtual void derived_mark () const; - DECLARE_SCHEME_CALLBACK(constructor, ()); - + DECLARE_SCHEME_CALLBACK (constructor, ()); + /// make a new context for every child. bool create_separate_contexts_; virtual void construct_children (); virtual Moment pending_moment () const; - virtual void do_quit(); + virtual void do_quit (); virtual bool ok () const; virtual bool run_always () const; - + protected: virtual void process (Moment); virtual Music_iterator *try_music_in_children (Music *) const; diff --git a/lily/include/skyline.hh b/lily/include/skyline.hh index c8077e3cd1..458a2f7cb0 100644 --- a/lily/include/skyline.hh +++ b/lily/include/skyline.hh @@ -1,4 +1,4 @@ -/* +/* skyline.hh -- declare Skyline_entry and funcbs. source file of the GNU LilyPond music typesetter @@ -16,25 +16,22 @@ struct Skyline_entry { Interval width_; Real height_; - Skyline_entry(); + Skyline_entry (); Skyline_entry (Interval, Real); }; - - void -merge_skyline (Array *a1, Array const & a2, +merge_skyline (Array *a1, Array const &a2, Direction); void insert_extent_into_skyline (Array *line, Box b, Axis line_axis, Direction d); Array -extents_to_skyline (Array const & extents, Axis a, Direction d); +extents_to_skyline (Array const &extents, Axis a, Direction d); Array empty_skyline (Direction d); void heighten_skyline (Array *buildings, Real ground); Real skyline_meshing_distance (Array const &buildings, Array const &clouds); - #endif /* SKYLINE_HH */ diff --git a/lily/include/slur-configuration.hh b/lily/include/slur-configuration.hh index 23f9cd5586..81854868bb 100644 --- a/lily/include/slur-configuration.hh +++ b/lily/include/slur-configuration.hh @@ -1,10 +1,9 @@ -/* +/* slur-configuration.hh -- declare Slur_configuration - + source file of the GNU LilyPond music typesetter - + (c) 2004--2005 Han-Wen Nienhuys - */ #ifndef SLUR_CONFIGURATION_HH @@ -21,9 +20,9 @@ public: Real score_; Bezier curve_; Real height_; - + int index_; - + #if DEBUG_SLUR_SCORING String score_card_; #endif @@ -31,12 +30,12 @@ public: Slur_configuration (); void generate_curve (Slur_score_state const &state, Real r0, Real h_inf); - void score (Slur_score_state const&); + void score (Slur_score_state const &); protected: - void score_extra_encompass (Slur_score_state const&); - void score_slopes (Slur_score_state const&); - void score_edges (Slur_score_state const&); - void score_encompass (Slur_score_state const&); + void score_extra_encompass (Slur_score_state const &); + void score_slopes (Slur_score_state const &); + void score_edges (Slur_score_state const &); + void score_encompass (Slur_score_state const &); }; #endif /* SLUR_CONFIGURATION_HH */ diff --git a/lily/include/slur-scoring.hh b/lily/include/slur-scoring.hh index ca0f114282..5b4634115e 100644 --- a/lily/include/slur-scoring.hh +++ b/lily/include/slur-scoring.hh @@ -1,10 +1,9 @@ -/* +/* slur-scoring.hh -- declare Slur_score_parameters - + source file of the GNU LilyPond music typesetter - + (c) 2004--2005 Han-Wen Nienhuys - */ #ifndef SLUR_SCORING_HH @@ -40,14 +39,12 @@ struct Slur_score_parameters void fill (Grob *him); }; - - struct Extra_collision_info { Real idx_; Box extents_; Real penalty_; - Grob * grob_; + Grob *grob_; Extra_collision_info (Grob *g, Real idx, Interval x, Interval y, Real p) { @@ -65,7 +62,6 @@ struct Extra_collision_info } }; - struct Encompass_info { Real x_; @@ -116,12 +112,12 @@ struct Slur_score_state bool edge_has_beams_; bool is_broken_; bool has_same_beam_; - + Real musical_dy_; Link_array columns_; Array encompass_infos_; Array extra_encompass_infos_; - + Direction dir_; Slur_score_parameters parameters_; Drul_array extremes_; @@ -129,26 +125,25 @@ struct Slur_score_state Link_array configurations_; Real staff_space_; Real thickness_; - - Slur_score_state(); - ~Slur_score_state(); + + Slur_score_state (); + ~Slur_score_state (); Bezier get_best_curve (); - void fill (Grob*); + void fill (Grob *); void set_next_direction (); - + Drul_array get_bound_info () const; - void generate_curves () const; + void generate_curves () const; Link_array enumerate_attachments (Drul_array end_ys) const; - Drul_array get_base_attachments() const; - Drul_array get_y_attachment_range() const; + Drul_array get_base_attachments () const; + Drul_array get_y_attachment_range () const; Encompass_info get_encompass_info (Grob *col) const; Array get_extra_encompass_infos () const; Real move_away_from_staffline (Real y, Grob *on_staff) const; int get_closest_index (SCM inspect_quants) const; }; - void set_slur_control_points (Grob *me); #endif /* SLUR_SCORING_HH */ diff --git a/lily/include/slur.hh b/lily/include/slur.hh index 242251c1b8..6fe85ccd0d 100644 --- a/lily/include/slur.hh +++ b/lily/include/slur.hh @@ -1,8 +1,8 @@ /* slur.hh -- declare Slur - + source file of the GNU LilyPond music typesetter - + (c) 2004--2005 Han-Wen Nienhuys */ @@ -22,7 +22,7 @@ public: DECLARE_SCHEME_CALLBACK (height, (SCM, SCM)); DECLARE_SCHEME_CALLBACK (outside_slur_callback, (SCM, SCM)); static bool has_interface (Grob *); - static Bezier get_curve (Grob*me); + static Bezier get_curve (Grob *me); }; #endif /* SLUR_HH */ diff --git a/lily/include/smobs.hh b/lily/include/smobs.hh index b091bc3800..c563f6df19 100644 --- a/lily/include/smobs.hh +++ b/lily/include/smobs.hh @@ -1,18 +1,16 @@ -/* +/* smobs.hh -- declare smob related stuff. - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - - */ +*/ #ifndef SMOBS_HH #define SMOBS_HH #include "lily-guile.hh" - /* Smobs are GUILEs mechanism of exporting C(++) objects to the Scheme world. They are documented in the GUILE manual. @@ -22,117 +20,116 @@ There are two types of smob objects. 1. Simple smobs are intended for simple objects like numbers: - immutable objects that can be copied without change of meaning. + immutable objects that can be copied without change of meaning. - To obtain an SCM version of a simple smob, use the member function - SCM smobbed_copy (). + To obtain an SCM version of a simple smob, use the member function + SCM smobbed_copy (). - Simple smobs are created by adding the - DECLARE_SIMPLE_SMOBS(Classname, ) to the declaration + Simple smobs are created by adding the + DECLARE_SIMPLE_SMOBS(Classname, ) to the declaration 2. Complex smobs are objects that have an identity. These objects - carry this identity in the form of a self_scm () method, which is a - SCM pointer to the object itself. + carry this identity in the form of a self_scm () method, which is a + SCM pointer to the object itself. + + The constructor for a complex smob should have 3 steps: + + * initialize all SCM members to a non-immediate value (like SCM_EOL) + + * call smobify_self () + + * initialize SCM members - The constructor for a complex smob should have 3 steps: + For example, - * initialize all SCM members to a non-immediate value (like SCM_EOL) + Complex_smob::Complex_smob () { + scm_member_ = SCM_EOL; + smobify_self (); + scm_member_ = <..what you want to store..> + } - * call smobify_self () + after construction, the self_scm () field of a complex smob is + protected from Garbage Collection. This protection should be + removed once the object is put into another (reachable) Scheme data + structure, i.e. - * initialize SCM members + Complex_smob *p = new Complex_smob; + list = scm_cons (p->self_scm (), list); + scm_gc_unprotect_object (p->self_scm ()); - For example, + Complex smobs are made with DECLARE_SMOBS (Classname, ) in the class + declaration. - Complex_smob::Complex_smob () { - scm_member_ = SCM_EOL; - smobify_self (); - scm_member_ = <..what you want to store..> - } - - after construction, the self_scm () field of a complex smob is - protected from Garbage Collection. This protection should be - removed once the object is put into another (reachable) Scheme data - structure, i.e. + CALLING INTERFACE - Complex_smob *p = new Complex_smob; - list = scm_cons (p->self_scm (), list); - scm_gc_unprotect_object (p->self_scm ()); + Common public methods to C++ smob objects: - Complex smobs are made with DECLARE_SMOBS (Classname, ) in the class - declaration. + unsmob (SCM x) - unpacks X and returns pointer to the C++ object, or 0 + if it has the wrong type. - CALLING INTERFACE - - Common public methods to C++ smob objects: + SCM equal_p (SCM a, SCM b) - compare A and B. Returns a Scheme boolean - unsmob (SCM x) - unpacks X and returns pointer to the C++ object, or 0 - if it has the wrong type. - SCM equal_p (SCM a, SCM b) - compare A and B. Returns a Scheme boolean + IMPLEMENTATION - - IMPLEMENTATION - - For implementating a class, the following should be provided + For implementating a class, the following should be provided - - an equal_p () function (a default is in the - IMPLEMENT_DEFAULT_EQUAL_P macro in ly-smobs.icc) + - an equal_p () function (a default is in the + IMPLEMENT_DEFAULT_EQUAL_P macro in ly-smobs.icc) - - mark_smob () function, that calls scm_gc_mark () on all Scheme - objects in the class + - mark_smob () function, that calls scm_gc_mark () on all Scheme + objects in the class - - a print_smob () function, that displays a representation for - debugging purposes + - a print_smob () function, that displays a representation for + debugging purposes - - A call to one of the IMPLEMENT_SMOBS or IMPLEMENT_SIMPLE_SMOBS macros - from file "ly-smobs.icc" + - A call to one of the IMPLEMENT_SMOBS or IMPLEMENT_SIMPLE_SMOBS macros + from file "ly-smobs.icc" */ -#define DECLARE_SIMPLE_SMOBS(CL, dummy) \ -public: \ - SCM smobbed_copy () const; \ -DECLARE_BASE_SMOBS(CL) - - -#define DECLARE_BASE_SMOBS(CL) \ - friend class Non_existent_class; \ -private: \ - static scm_t_bits smob_tag_; \ - static SCM mark_smob (SCM); \ - static size_t free_smob (SCM s); \ - static int print_smob (SCM s, SCM p, scm_print_state*); \ -public: \ - static SCM equal_p (SCM a, SCM b);\ - static CL * unsmob (SCM s){\ - if (SCM_NIMP (s) && SCM_CELL_TYPE (s) == smob_tag_) \ - return (CL*) SCM_CELL_WORD_1 (s); \ - else \ - return 0; \ -} \ - static SCM smob_p (SCM);\ - static void init_smobs (); \ -private: - - -#define DECLARE_SMOBS(CL, dummy) \ - DECLARE_BASE_SMOBS (CL) \ -protected:\ - virtual ~CL ();\ - SCM unprotected_smobify_self ();\ -private: \ - void smobify_self (); \ - SCM self_scm_; \ -public: \ - SCM self_scm () const { return self_scm_; } \ -private: - -#define DECLARE_UNSMOB(CL, name) \ -inline CL * \ -unsmob_ ## name (SCM s) \ -{ \ -return CL::unsmob (s); \ -} +#define DECLARE_SIMPLE_SMOBS(CL, dummy) \ + public: \ + SCM smobbed_copy () const; \ + DECLARE_BASE_SMOBS (CL) + +#define DECLARE_BASE_SMOBS(CL) \ + friend class Non_existent_class; \ + private: \ + static scm_t_bits smob_tag_; \ + static SCM mark_smob (SCM); \ + static size_t free_smob (SCM s); \ + static int print_smob (SCM s, SCM p, scm_print_state*); \ + public: \ + static SCM equal_p (SCM a, SCM b); \ + static CL *unsmob (SCM s) \ + { \ + if (SCM_NIMP (s) && SCM_CELL_TYPE (s) == smob_tag_) \ + return (CL *) SCM_CELL_WORD_1 (s); \ + else \ + return 0; \ + } \ + static SCM smob_p (SCM); \ + static void init_smobs (); \ + private: + +#define DECLARE_SMOBS(CL, dummy) \ + DECLARE_BASE_SMOBS (CL) \ + protected: \ + virtual ~CL (); \ + SCM unprotected_smobify_self (); \ + private: \ + void smobify_self (); \ + SCM self_scm_; \ + public: \ + SCM self_scm () const { return self_scm_; } \ + private: + +#define DECLARE_UNSMOB(CL, name) \ + inline CL * \ + unsmob_ ## name (SCM s) \ + { \ + return CL::unsmob (s); \ + } #define DECLARE_TYPE_P(CL) extern SCM CL ## _type_p_proc diff --git a/lily/include/source-file.hh b/lily/include/source-file.hh index 7f13b9b492..759bb78425 100644 --- a/lily/include/source-file.hh +++ b/lily/include/source-file.hh @@ -1,8 +1,8 @@ -/* +/* source-file.hh -- declare Source_file - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Jan Nieuwenhuizen */ @@ -16,63 +16,63 @@ #include "parray.hh" /** - class for reading and mapping a file. + class for reading and mapping a file. - duplicates a lot of Data_file and Text_stream. - should look at including Data_file's functionality: - get_line (), get_word () here. + duplicates a lot of Data_file and Text_stream. + should look at including Data_file's functionality: + get_line (), get_word () here. */ class Source_file { public: Source_file (String fn); - Source_file (String, String ); + Source_file (String, String); virtual ~Source_file (); - char const* to_str0 () const; - virtual String error_string (char const* pos_str0 ) const; + char const *to_str0 () const; + virtual String error_string (char const *pos_str0) const; std::istream * get_istream (); - bool contains (char const* pos_str0 ) const; + bool contains (char const *pos_str0) const; int length () const; - virtual int get_line (char const* pos_str0 ) const; + virtual int get_line (char const *pos_str0) const; String name_string () const; - String file_line_column_string (char const* str0 ) const; + String file_line_column_string (char const *str0) const; // return start + n - char const* seek_str0 (int n); + char const *seek_str0 (int n); int tell () const; // return here + n bytes - char const* forward_str0 (int n); - char const* pos_str0 () { return pos_str0_; } + char const *forward_str0 (int n); + char const *pos_str0 () { return pos_str0_; } String get_string (int n); - void set_pos (char const * pos_str0); + void set_pos (char const *pos_str0); public: - Slice line_slice (char const* pos_str0) const; - String line_string (char const* pos_str0) const; - int get_column (char const* pos_str0) const; - int get_char (char const* pos_str0) const; + Slice line_slice (char const *pos_str0) const; + String line_string (char const *pos_str0) const; + int get_column (char const *pos_str0) const; + int get_char (char const *pos_str0) const; /* JUNKME. This thing doubles as a file-storage/file-iterator object. - */ - char const* pos_str0_; + */ + char const *pos_str0_; SCM get_port () const { return str_port_; } String name_; private: - Link_array newline_locations_; + Link_array newline_locations_; std::istream* istream_; - char * contents_str0_; + char *contents_str0_; int length_; void load_stdin (); void init_port (); - + Protected_scm str_port_; }; diff --git a/lily/include/source.hh b/lily/include/source.hh index 6420ca9165..ffc1f0f83b 100644 --- a/lily/include/source.hh +++ b/lily/include/source.hh @@ -10,9 +10,9 @@ #include "flower-proto.hh" /* A set of sourcefiles. */ -class Sources +class Sources { - Sources (Sources const&) {} + Sources (Sources const &) {} Cons *sourcefile_list_; bool is_binary_; @@ -20,15 +20,13 @@ public: Sources (); ~Sources (); - Source_file *get_file (String &file_name ); - Source_file *get_sourcefile (char const*); - void add (Source_file* sourcefile ); - void set_path (File_path*); + Source_file *get_file (String &file_name); + Source_file *get_sourcefile (char const *); + void add (Source_file *sourcefile); + void set_path (File_path *); void set_binary (bool); const File_path *path_; }; - - #endif /* SOURCE_HH */ diff --git a/lily/include/spaceable-grob.hh b/lily/include/spaceable-grob.hh index a338921710..0fa6356cd0 100644 --- a/lily/include/spaceable-grob.hh +++ b/lily/include/spaceable-grob.hh @@ -1,11 +1,10 @@ -/* +/* spaceable-grob.hh -- declare Spaceable_grob - + source file of the GNU LilyPond music typesetter - + (c) 2000--2005 Han-Wen Nienhuys - - */ +*/ #ifndef SPACEABLE_GROB_HH #define SPACEABLE_GROB_HH @@ -16,12 +15,12 @@ struct Spaceable_grob { /// set a minimum distance - static void add_rod (Grob*me, Grob * to, Real distance); - static void add_spring (Grob*me, Grob * to, Real dist, Real strength); - static bool has_interface (Grob*); - static void remove_interface (Grob*); - static SCM get_minimum_distances (Grob*); - static SCM get_ideal_distances (Grob*); + static void add_rod (Grob *me, Grob *to, Real distance); + static void add_spring (Grob *me, Grob *to, Real dist, Real strength); + static bool has_interface (Grob *); + static void remove_interface (Grob *); + static SCM get_minimum_distances (Grob *); + static SCM get_ideal_distances (Grob *); }; #endif /* SPACEABLE_GROB_HH */ diff --git a/lily/include/spacing-interface.hh b/lily/include/spacing-interface.hh index 96bcfbcccb..13bd018cad 100644 --- a/lily/include/spacing-interface.hh +++ b/lily/include/spacing-interface.hh @@ -1,13 +1,13 @@ -/* +/* spacing-interface.hh -- declare Spacing_interface - + source file of the GNU LilyPond music typesetter - + (c) 2002--2005 Han-Wen Nienhuys - - */ +*/ -struct Spacing_interface { - static bool has_interface (Grob*); +struct Spacing_interface +{ + static bool has_interface (Grob *); }; diff --git a/lily/include/span-bar.hh b/lily/include/span-bar.hh index 4b3f0b3d24..7154f30365 100644 --- a/lily/include/span-bar.hh +++ b/lily/include/span-bar.hh @@ -6,7 +6,6 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef SPAN_BAR_HH #define SPAN_BAR_HH @@ -21,16 +20,16 @@ class Span_bar { public: - - static bool has_interface (Grob*); - static Interval get_spanned_interval (Grob*); - static void add_bar (Grob*, Grob*); - static void evaluate_glyph (Grob*); - static void evaluate_empty (Grob*); + + static bool has_interface (Grob *); + static Interval get_spanned_interval (Grob *); + static void add_bar (Grob *, Grob *); + static void evaluate_glyph (Grob *); + static void evaluate_empty (Grob *); DECLARE_SCHEME_CALLBACK (width_callback, (SCM smob, SCM axis)); - DECLARE_SCHEME_CALLBACK (get_bar_size, (SCM )); - DECLARE_SCHEME_CALLBACK (print, (SCM )); - DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM )); + DECLARE_SCHEME_CALLBACK (get_bar_size, (SCM)); + DECLARE_SCHEME_CALLBACK (print, (SCM)); + DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM)); DECLARE_SCHEME_CALLBACK (center_on_spanned_callback, (SCM element, SCM axis)); }; diff --git a/lily/include/spanner.hh b/lily/include/spanner.hh index e7745cb528..6c0fc1cbed 100644 --- a/lily/include/spanner.hh +++ b/lily/include/spanner.hh @@ -11,51 +11,51 @@ #include "rod.hh" /** A symbol which is attached between two columns. A spanner is a - symbol which spans across several columns, so its final appearance - can only be calculated after the breaking problem is solved. + symbol which spans across several columns, so its final appearance + can only be calculated after the breaking problem is solved. - Examples + Examples - * (de)crescendo - * slur - * beam - * bracket + * (de)crescendo + * slur + * beam + * bracket - Spanner should know about the items which it should consider: - e.g. slurs should be steep enough to "enclose" all those items. This - is absolutely necessary for beams, since they have to adjust the - length of stems of notes they encompass. - - */ -class Spanner : public Grob { - Drul_array spanned_drul_; + Spanner should know about the items which it should consider: + e.g. slurs should be steep enough to "enclose" all those items. This + is absolutely necessary for beams, since they have to adjust the + length of stems of notes they encompass. +*/ +class Spanner : public Grob +{ + Drul_array spanned_drul_; int break_index_; - + public: DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM)); - + Link_array broken_intos_; int get_break_index () const; // todo: move to somewhere else. Real get_broken_left_end_align () const; - void substitute_one_mutable_property (SCM sym, SCM val) ; + void substitute_one_mutable_property (SCM sym, SCM val); bool fast_fubstitute_grob_list (SCM sym, SCM grob_list); // TODO: make virtual and do this for Items as well. Interval_t spanned_rank_iv (); - void set_bound (Direction d, Grob*); + void set_bound (Direction d, Grob *); Item *get_bound (Direction d) const; - - Spanner (SCM, Object_key const*); + + Spanner (SCM, Object_key const *); Spanner (Spanner const &, int copy_count); bool is_broken () const; void do_break (); Real spanner_length () const; - static int compare (Spanner * const &, Spanner * const &); - virtual Grob* find_broken_piece (System*) const; + static int compare (Spanner *const &, Spanner *const &); + virtual Grob *find_broken_piece (System *) const; virtual SCM do_derived_mark () const; - static bool has_interface (Grob*); + static bool has_interface (Grob *); virtual System *get_system () const; protected: @@ -64,8 +64,8 @@ protected: virtual void do_break_processing (); }; -void add_bound_item (Spanner*, Grob*); +void add_bound_item (Spanner *, Grob *); -bool spanner_less ( Spanner *s1, Spanner* s2); -int broken_spanner_index (Spanner * sp); +bool spanner_less (Spanner *s1, Spanner *s2); +int broken_spanner_index (Spanner *sp); #endif diff --git a/lily/include/spring.hh b/lily/include/spring.hh index 2efb1105fd..c3ef5bd027 100644 --- a/lily/include/spring.hh +++ b/lily/include/spring.hh @@ -1,11 +1,10 @@ -/* +/* spring.hh -- declare Spring, Column_spring - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - - */ +*/ #ifndef SPRING_HH #define SPRING_HH @@ -19,16 +18,16 @@ struct Spring_smob Real distance_; bool expand_only_b_; Real strength_; - - DECLARE_SIMPLE_SMOBS(Spring_smob, dummy); + + DECLARE_SIMPLE_SMOBS (Spring_smob, dummy); public: - Spring_smob(); + Spring_smob (); }; -DECLARE_UNSMOB(Spring_smob, spring); +DECLARE_UNSMOB (Spring_smob, spring); struct Spring { - Drul_array item_drul_; + Drul_array item_drul_; Real distance_; bool expand_only_b_; @@ -41,6 +40,5 @@ struct Spring Spring (); }; - #endif /* SPRING_HH */ diff --git a/lily/include/staff-spacing.hh b/lily/include/staff-spacing.hh index 1c90670de8..eb271be156 100644 --- a/lily/include/staff-spacing.hh +++ b/lily/include/staff-spacing.hh @@ -1,11 +1,10 @@ -/* -staff-spacing.hh -- declare Staff_spacing +/* + staff-spacing.hh -- declare Staff_spacing -source file of the GNU LilyPond music typesetter + source file of the GNU LilyPond music typesetter -(c) 2001--2005 Han-Wen Nienhuys - - */ + (c) 2001--2005 Han-Wen Nienhuys +*/ #ifndef STAFF_SPACING_HH #define STAFF_SPACING_HH @@ -15,12 +14,12 @@ source file of the GNU LilyPond music typesetter class Staff_spacing { public: - static Real next_notes_correction (Grob*, Grob*); - static Real next_note_correction (Grob*, Grob*, Interval); - static bool has_interface (Grob*); - static void get_spacing_params (Grob*, Real*, Real*); + static Real next_notes_correction (Grob *, Grob *); + static Real next_note_correction (Grob *, Grob *, Interval); + static bool has_interface (Grob *); + static void get_spacing_params (Grob *, Real *, Real *); - static Interval bar_y_positions (Grob*); + static Interval bar_y_positions (Grob *); }; #endif /* STAFF_SPACING_HH */ diff --git a/lily/include/staff-symbol-referencer.hh b/lily/include/staff-symbol-referencer.hh index 6b5ec9e8c3..2502f50baa 100644 --- a/lily/include/staff-symbol-referencer.hh +++ b/lily/include/staff-symbol-referencer.hh @@ -1,46 +1,43 @@ -/* - staff-sym-referencer.hh -- declare staff_symbol_referencer - - source file of the GNU LilyPond music typesetter - +/* + staff-sym-referencer.hh -- declare staff_symbol_referencer + + source file of the GNU LilyPond music typesetter + (c) 1999--2005 Han-Wen Nienhuys - - */ +*/ #ifndef STAFF_SYMBOL_REFERENCER_HH #define STAFF_SYMBOL_REFERENCER_HH #include "grob.hh" - /** - A notation object that needs access to variables of the staff (no - lines, leading). - - */ -class Staff_symbol_referencer + A notation object that needs access to variables of the staff (no + lines, leading). +*/ +class Staff_symbol_referencer { public: - static bool has_interface (Grob*); - static bool ugly_hack (Grob*); - static void set_position (Grob*, Real); + static bool has_interface (Grob *); + static bool ugly_hack (Grob *); + static void set_position (Grob *, Real); DECLARE_SCHEME_CALLBACK (callback, (SCM element, SCM axis)); /** Leading are the lead strips between the sticks (lines) of typeface. ie. leading is vertical space. */ - static Real line_thickness (Grob*); - static Real staff_space (Grob*); - static Grob *get_staff_symbol (Grob*); - static bool on_staffline (Grob*); - static bool on_staffline (Grob*, int); - static int line_count (Grob*); - static Real get_position (Grob*); - static Real staff_radius (Grob*); - static int get_rounded_position (Grob*); + static Real line_thickness (Grob *); + static Real staff_space (Grob *); + static Grob *get_staff_symbol (Grob *); + static bool on_staffline (Grob *); + static bool on_staffline (Grob *, int); + static int line_count (Grob *); + static Real get_position (Grob *); + static Real staff_radius (Grob *); + static int get_rounded_position (Grob *); }; -int compare_position (Grob *const&, Grob *const&); +int compare_position (Grob *const &, Grob *const &); #endif /* STAFF_SYMBOL_REFERENCER_HH */ diff --git a/lily/include/staff-symbol.hh b/lily/include/staff-symbol.hh index 4289fada49..5e67b668b2 100644 --- a/lily/include/staff-symbol.hh +++ b/lily/include/staff-symbol.hh @@ -6,7 +6,6 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef STAFF_SYMBOL_HH #define STAFF_SYMBOL_HH @@ -14,19 +13,19 @@ #include "lily-proto.hh" /** - TODO: add linethickness as parameter. - */ -class Staff_symbol + TODO: add linethickness as parameter. +*/ +class Staff_symbol { public: - static Real staff_space (Grob*) ; - static Real get_line_thickness (Grob*); - static Real get_ledger_line_thickness (Grob*); - - static int get_steps (Grob*) ; - static int line_count (Grob*); - DECLARE_SCHEME_CALLBACK (print, (SCM )); - static bool has_interface (Grob*); - + static Real staff_space (Grob *); + static Real get_line_thickness (Grob *); + static Real get_ledger_line_thickness (Grob *); + + static int get_steps (Grob *); + static int line_count (Grob *); + DECLARE_SCHEME_CALLBACK (print, (SCM)); + static bool has_interface (Grob *); + }; #endif // STAFF_SYMBOL_HH diff --git a/lily/include/stem-info.hh b/lily/include/stem-info.hh index 3a47067455..0240c65d77 100644 --- a/lily/include/stem-info.hh +++ b/lily/include/stem-info.hh @@ -6,7 +6,6 @@ (c) 1997--2005 Jan Nieuwenhuizen */ - #ifndef STEM_INFO_HH #define STEM_INFO_HH @@ -15,14 +14,14 @@ /* Parameters for a stem, (multiply with stemdirection, to get real values for a downstem.) - */ -struct Stem_info +*/ +struct Stem_info { Direction dir_; Real ideal_y_; Real shortest_y_; - Stem_info(); -void scale (Real); + Stem_info (); + void scale (Real); }; #endif // STEM_INFO_HH diff --git a/lily/include/stem-tremolo.hh b/lily/include/stem-tremolo.hh index 8c68e3b823..d143bd08cb 100644 --- a/lily/include/stem-tremolo.hh +++ b/lily/include/stem-tremolo.hh @@ -1,11 +1,10 @@ -/* +/* stem-tremolo.hh -- declare Abbreviation - + source file of the GNU LilyPond music typesetter - + (c) 1997--2005 Han-Wen Nienhuys - - */ +*/ #ifndef ABBREV_HH #define ABBREV_HH @@ -16,12 +15,12 @@ class Stem_tremolo { public: - - static bool has_interface (Grob*); + + static bool has_interface (Grob *); DECLARE_SCHEME_CALLBACK (dim_callback, (SCM smob, SCM axis)); - DECLARE_SCHEME_CALLBACK (print, (SCM )); + DECLARE_SCHEME_CALLBACK (print, (SCM)); DECLARE_SCHEME_CALLBACK (height, (SCM, SCM)); - static Stencil raw_stencil (Grob*); + static Stencil raw_stencil (Grob *); }; #endif /* ABBREV_HH */ diff --git a/lily/include/stem.hh b/lily/include/stem.hh index 1c0616d2ae..6c97b11311 100644 --- a/lily/include/stem.hh +++ b/lily/include/stem.hh @@ -11,7 +11,7 @@ #include "lily-guile.hh" #include "stem-info.hh" -class Stem +class Stem { public: static Array note_head_positions (Grob *); @@ -21,8 +21,8 @@ public: static Spanner *get_beam (Grob *); static Grob *first_head (Grob *); static Grob *last_head (Grob *); - static Drul_array extremal_heads (Grob *); - static Grob *support_head (Grob *) ; + static Drul_array extremal_heads (Grob *); + static Grob *support_head (Grob *); static void add_head (Grob *me, Grob *n); static Stem_info get_stem_info (Grob *); static Real chord_start_y (Grob *); @@ -30,17 +30,17 @@ public: static void set_stemend (Grob *, Real); static Direction get_default_dir (Grob *); static Slice Stem::beam_multiplicity (Grob *); - static Real thickness (Grob*); + static Real thickness (Grob *); static int head_count (Grob *); - static bool is_invisible (Grob *) ; + static bool is_invisible (Grob *); static Interval head_positions (Grob *); - static Real get_default_stem_end_position (Grob*me); + static Real get_default_stem_end_position (Grob *me); static void position_noteheads (Grob *); static Real stem_end_position (Grob *); static Stencil flag (Grob *); static bool has_interface (Grob *); static void set_spacing_hints (Grob *); - + DECLARE_SCHEME_CALLBACK (print, (SCM)); DECLARE_SCHEME_CALLBACK (offset_callback, (SCM element, SCM axis)); DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM)); diff --git a/lily/include/stencil.hh b/lily/include/stencil.hh index 23621ecf8f..29abe4e2bb 100644 --- a/lily/include/stencil.hh +++ b/lily/include/stencil.hh @@ -19,29 +19,29 @@ It is implemented as a "tree" of scheme expressions, as in - Expr = combine Expr-list - | translate Offset Expr - | origin (ORIGIN) Expr - | no-origin Expr - | (SCHEME) - ; + Expr = combine Expr-list + | translate Offset Expr + | origin (ORIGIN) Expr + | no-origin Expr + | (SCHEME) + ; SCHEME is a Scheme expression that --when eval'd-- produces the - desired output. + desired output. Notes: - + * Because of the way that Stencil is implemented, it is the most efficient to add "fresh" stencils to what you're going to build. * Do not create Stencil objects on the heap. That includes passing around Stencil* which are produced by unsmob_stencil(). Either copy Stencil objects, or use SCM references. - + * Empty stencils have empty dimensions. If add_at_edge is used to init the stencil, we assume that - DIMENSIONS = (Interval (0, 0), Interval (0, 0) + DIMENSIONS = (Interval (0, 0), Interval (0, 0) */ class Stencil { @@ -51,16 +51,16 @@ class Stencil This provides the reference point of the symbol, for example with characters, it is on the base line of the character. Usually, ORIGIN is inside DIM_ - */ + */ Offset origin_; Box dim_; SCM expr_; - - DECLARE_SIMPLE_SMOBS (Stencil, ); + + DECLARE_SIMPLE_SMOBS (Stencil,); public: Stencil (Box, SCM s); Stencil (); - + Offset origin () const; SCM expr () const; @@ -76,7 +76,7 @@ public: void translate (Offset); void align_to (Axis a, Real x); void translate_axis (Real, Axis); - + Interval extent (Axis) const; Box extent_box () const; bool is_empty () const; @@ -86,14 +86,13 @@ public: static SCM ly_stencil_combined_at_edge (SCM, SCM, SCM, SCM, SCM); }; - -DECLARE_UNSMOB(Stencil, stencil); -SCM fontify_atom (Font_metric const*, SCM atom); +DECLARE_UNSMOB (Stencil, stencil); +SCM fontify_atom (Font_metric const *, SCM atom); void interpret_stencil_expression (SCM expr, - void (*func) (void*, SCM), - void *func_arg, - Offset o); + void (*func) (void *, SCM), + void *func_arg, + Offset o); Stencil create_stencil (SCM print); SCM find_expression_fonts (SCM expr); diff --git a/lily/include/stream.hh b/lily/include/stream.hh index 5c58945936..c3a26f108c 100644 --- a/lily/include/stream.hh +++ b/lily/include/stream.hh @@ -1,11 +1,10 @@ -/* -stream.hh -- declare compatibility glue for gcc 3. +/* + stream.hh -- declare compatibility glue for gcc 3. -source file of the GNU LilyPond music typesetter + source file of the GNU LilyPond music typesetter -(c) 2001--2005 Han-Wen Nienhuys - - */ + (c) 2001--2005 Han-Wen Nienhuys +*/ #ifndef STREAM_HH #define STREAM_HH @@ -23,6 +22,5 @@ std::ostream *open_file_stream (String file_name, int mode = ios::out); #endif void close_file_stream (std::ostream *os); - #endif /* STREAM_HH */ diff --git a/lily/include/swallow-perf.hh b/lily/include/swallow-perf.hh index 5b2d6ebfab..ff6c1b7612 100644 --- a/lily/include/swallow-perf.hh +++ b/lily/include/swallow-perf.hh @@ -6,7 +6,6 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef SWALLOW_PERF_HH #define SWALLOW_PERF_HH @@ -16,9 +15,9 @@ class Swallow_performer : public Performer { public: VIRTUAL_COPY_CONS (Translator); - + protected: - virtual bool try_music (Music*) { return true; } + virtual bool try_music (Music *) { return true; } }; #endif // SWALLOW_PERF_HH diff --git a/lily/include/system-start-delimiter.hh b/lily/include/system-start-delimiter.hh index dfa2c60a57..8468de947b 100644 --- a/lily/include/system-start-delimiter.hh +++ b/lily/include/system-start-delimiter.hh @@ -1,11 +1,10 @@ -/* +/* System-start-delimiter.hh -- declare System_start_delimiter - + source file of the GNU LilyPond music typesetter - + (c) 2000--2005 Han-Wen Nienhuys - - */ +*/ #ifndef SYSTEM_START_DELIMITER_HH #define SYSTEM_START_DELIMITER_HH @@ -15,19 +14,18 @@ /* Braces/brackets across staves. - */ +*/ class System_start_delimiter { public: - DECLARE_SCHEME_CALLBACK (print, (SCM )); - - - static bool has_interface (Grob*); - DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM )); - static void try_collapse (Grob*); - static Stencil staff_bracket (Grob*, Real) ; - static Stencil staff_brace (Grob*, Real) ; - static Stencil simple_bar (Grob*, Real) ; + DECLARE_SCHEME_CALLBACK (print, (SCM)); + + static bool has_interface (Grob *); + DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM)); + static void try_collapse (Grob *); + static Stencil staff_bracket (Grob *, Real); + static Stencil staff_brace (Grob *, Real); + static Stencil simple_bar (Grob *, Real); }; #endif /* SYSTEM_START_DELIMITER_HH */ diff --git a/lily/include/system.hh b/lily/include/system.hh index d8aa5a087f..5eaa2bed66 100644 --- a/lily/include/system.hh +++ b/lily/include/system.hh @@ -8,17 +8,14 @@ #ifndef SYSTEM_HH #define SYSTEM_HH - #include "column-x-positions.hh" #include "spanner.hh" /* If you keep following offset reference points, you will always end -up at the root object. This root object is called @ref{System}, and it -represents a system (i.e. a line of music). - - - */ + up at the root object. This root object is called @ref{System}, and it + represents a system (i.e. a line of music). +*/ class System : public Spanner { public: @@ -27,27 +24,26 @@ public: SCM get_line (); SCM get_lines (); - System (SCM, Object_key const*); - System (System const&, int); + System (SCM, Object_key const *); + System (System const &, int); virtual Grob *clone (int count) const; - + int element_count () const; int spanner_count () const; - void break_into_pieces (Array const&); - static bool has_interface (Grob*); - - Link_array broken_col_range (Item const*, Item const*) const; + void break_into_pieces (Array const &); + static bool has_interface (Grob *); + + Link_array broken_col_range (Item const *, Item const *) const; Link_array columns () const; - - void add_column (Paper_column*); - void typeset_grob (Grob*); + + void add_column (Paper_column *); + void typeset_grob (Grob *); void pre_processing (); protected: }; - -void set_loose_columns (System* which, Column_x_positions const *posns); +void set_loose_columns (System *which, Column_x_positions const *posns); #endif /* SYSTEM_HH */ diff --git a/lily/include/text-item.hh b/lily/include/text-item.hh index b66a63b7bb..4f442b59cc 100644 --- a/lily/include/text-item.hh +++ b/lily/include/text-item.hh @@ -1,16 +1,15 @@ -/* +/* text-item.hh -- declare markup functions source file of the GNU LilyPond music typesetter - + (c) 1998--2005 Han-Wen Nienhuys Jan Nieuwenhuizen - */ +*/ #ifndef TEXT_ITEM #define TEXT_ITEM - #include "stencil.hh" class Text_interface @@ -19,8 +18,8 @@ public: DECLARE_SCHEME_CALLBACK (print, (SCM)); DECLARE_SCHEME_CALLBACK (interpret_markup, (SCM, SCM, SCM)); DECLARE_SCHEME_CALLBACK (interpret_string, (SCM, SCM, SCM)); - static bool has_interface (Grob*); - static bool markup_p (SCM) ; + static bool has_interface (Grob *); + static bool markup_p (SCM); }; #endif /* TEXT_ITEM */ diff --git a/lily/include/text-metrics.hh b/lily/include/text-metrics.hh index 1a334880a6..b353e2880e 100644 --- a/lily/include/text-metrics.hh +++ b/lily/include/text-metrics.hh @@ -4,7 +4,6 @@ source file of the GNU LilyPond music typesetter (c) 2004--2005 Han-Wen Nienhuys - */ #ifndef TEXT_METRICS_HH @@ -16,7 +15,7 @@ void try_load_text_metrics (String); SCM ly_load_text_dimensions (SCM); Box lookup_tex_text_dimension (Font_metric *font, - SCM text); + SCM text); #endif /* TEXT_METRICS_HH */ diff --git a/lily/include/text-spanner.hh b/lily/include/text-spanner.hh index e8b66dcf0e..d4dcad8548 100644 --- a/lily/include/text-spanner.hh +++ b/lily/include/text-spanner.hh @@ -6,7 +6,6 @@ (c) 2000--2005 Jan Nieuwenhuizen */ - #ifndef TEXT_SPANNER_HH #define TEXT_SPANNER_HH @@ -18,7 +17,7 @@ class Text_spanner { public: DECLARE_SCHEME_CALLBACK (print, (SCM)); - static bool has_interface (Grob*); + static bool has_interface (Grob *); }; #endif /* TEXT_SPANNER_HH */ diff --git a/lily/include/tfm-reader.hh b/lily/include/tfm-reader.hh index 099e6184bc..4c826d162e 100644 --- a/lily/include/tfm-reader.hh +++ b/lily/include/tfm-reader.hh @@ -1,14 +1,13 @@ -/* +/* tfm-reader.hh -- declare Tex_font_metric_reader - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Jan Nieuwenhuizen revamped code from GNU Fontutils-0.6 - - */ +*/ #ifndef TFM_READER_HH #define TFM_READER_HH @@ -28,12 +27,12 @@ private: Tex_font_char_metric read_char_metric (Char_code code); Tex_font_char_metric read_char (); void read_lig_kern_program (Array* ligatures, - Array * kerns); + Array* kerns); Binary_source_file input_; public: - Tex_font_metric_reader ( String name); + Tex_font_metric_reader (String name); Tfm_info info_; Tfm_header header_; diff --git a/lily/include/tfm.hh b/lily/include/tfm.hh index 8dba46d3e5..32f1222589 100644 --- a/lily/include/tfm.hh +++ b/lily/include/tfm.hh @@ -1,14 +1,13 @@ -/* +/* tfm.hh -- declare Tex_font_metric - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Jan Nieuwenhuizen revamped code from GNU Fontutils-0.6 - - */ +*/ /* TODO: aren't there standard libs? Ideally it is better to just link @@ -138,10 +137,9 @@ struct Tex_font_char_metric Tex_font_char_metric (); - Box dimensions () const; + Box dimensions () const; }; - class Tex_font_metric : public Simple_font_metric { public: @@ -155,7 +153,7 @@ public: virtual String font_name () const; Tfm_info const &info () const; - + protected: Tfm_info info_; Tfm_header header_; @@ -168,6 +166,5 @@ private: Tex_font_metric (); }; - #endif /* TFM_HH */ diff --git a/lily/include/tie-column.hh b/lily/include/tie-column.hh index 9bce382846..17797e9d96 100644 --- a/lily/include/tie-column.hh +++ b/lily/include/tie-column.hh @@ -1,12 +1,11 @@ -/* +/* tie-column.hh -- declare Tie_column - + source file of the GNU LilyPond music typesetter - + (c) 2000--2005 Han-Wen Nienhuys - - */ +*/ #ifndef TIE_COLUMN_HH #define TIE_COLUMN_HH @@ -17,12 +16,12 @@ class Tie_column { public: - static bool has_interface (Grob*); - static void add_tie (Grob*me, Grob*); + static bool has_interface (Grob *); + static void add_tie (Grob *me, Grob *); DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM)); DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM)); - static void set_directions (Grob*me); - static void werner_directions (Grob*me); + static void set_directions (Grob *me); + static void werner_directions (Grob *me); }; #endif /* TIE_COLUMN_HH */ diff --git a/lily/include/tie.hh b/lily/include/tie.hh index 06fba20065..d7c4312e7b 100644 --- a/lily/include/tie.hh +++ b/lily/include/tie.hh @@ -6,28 +6,26 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef TIE_HH #define TIE_HH #include "lily-guile.hh" #include "lily-proto.hh" - class Tie { public: - static void set_head (Grob*, Direction, Grob*head); - static void set_interface (Grob*); - static bool has_interface (Grob*); - static void set_direction (Grob*); - static Grob *head (Grob*, Direction) ; - static int get_column_rank (Grob*, Direction); - static Real get_position (Grob*) ; - static Direction get_default_dir (Grob*) ; + static void set_head (Grob *, Direction, Grob *head); + static void set_interface (Grob *); + static bool has_interface (Grob *); + static void set_direction (Grob *); + static Grob *head (Grob *, Direction); + static int get_column_rank (Grob *, Direction); + static Real get_position (Grob *); + static Direction get_default_dir (Grob *); static SCM get_control_points (SCM); - DECLARE_SCHEME_CALLBACK (print, (SCM )); - DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM )); + DECLARE_SCHEME_CALLBACK (print, (SCM)); + DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM)); }; #endif // TIE_HH diff --git a/lily/include/time-scaled-music-iterator.hh b/lily/include/time-scaled-music-iterator.hh index d22f928168..5d0224861d 100644 --- a/lily/include/time-scaled-music-iterator.hh +++ b/lily/include/time-scaled-music-iterator.hh @@ -1,11 +1,10 @@ -/* +/* compressed-music-iterator.hh -- declare Time_scaled_music_iterator - + source file of the GNU LilyPond music typesetter - + (c) 1998--2005 Han-Wen Nienhuys - - */ +*/ #ifndef Time_scaled_music_ITERATOR_HH #define Time_scaled_music_ITERATOR_HH @@ -14,13 +13,12 @@ class Time_scaled_music_iterator : public Music_wrapper_iterator { -public: - DECLARE_SCHEME_CALLBACK(constructor, ()); +public: + DECLARE_SCHEME_CALLBACK (constructor, ()); /* construction */ protected: virtual void process (Moment); }; - #endif /* Time_scaled_music_ITERATOR_HH */ diff --git a/lily/include/time-signature.hh b/lily/include/time-signature.hh index 449d1ece1e..b41672364a 100644 --- a/lily/include/time-signature.hh +++ b/lily/include/time-signature.hh @@ -15,14 +15,13 @@ TODO: 2+3+2/8 time_signatures - - */ +*/ struct Time_signature { - static bool has_interface (Grob*); - static Stencil special_time_signature (Grob*, SCM, int, int) ; - static Stencil numbered_time_signature (Grob*, int, int); - DECLARE_SCHEME_CALLBACK (print, (SCM )); + static bool has_interface (Grob *); + static Stencil special_time_signature (Grob *, SCM, int, int); + static Stencil numbered_time_signature (Grob *, int, int); + DECLARE_SCHEME_CALLBACK (print, (SCM)); }; #endif // METER_HH diff --git a/lily/include/timing-translator.hh b/lily/include/timing-translator.hh index ee67f93d2b..f58489ea48 100644 --- a/lily/include/timing-translator.hh +++ b/lily/include/timing-translator.hh @@ -6,7 +6,6 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef TIMING_TRANSLATOR_HH #define TIMING_TRANSLATOR_HH @@ -18,16 +17,15 @@ class Timing_translator : public virtual Translator { public: - TRANSLATOR_DECLARATIONS(Timing_translator); - + TRANSLATOR_DECLARATIONS (Timing_translator); -protected: +protected: virtual void initialize (); virtual void stop_translation_timestep (); virtual void start_translation_timestep (); public: Moment measure_position () const; - Rational measure_length () const; + Rational measure_length () const; }; #endif // TIMING_TRANSLATOR_HH diff --git a/lily/include/translator-group.hh b/lily/include/translator-group.hh index 7a41f6e2ed..e31766ad2e 100644 --- a/lily/include/translator-group.hh +++ b/lily/include/translator-group.hh @@ -6,7 +6,6 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef TRANSLATOR_GROUP_HH #define TRANSLATOR_GROUP_HH @@ -19,9 +18,9 @@ class Translator_group : public virtual Translator { public: VIRTUAL_COPY_CONSTRUCTOR (Translator, Translator_group); - virtual Translator_group* get_daddy_translator ()const; + virtual Translator_group *get_daddy_translator ()const; virtual SCM get_simple_trans_list (); - virtual bool try_music (Music* req); + virtual bool try_music (Music *req); virtual void initialize (); Translator_group (); @@ -31,9 +30,8 @@ protected: virtual void derived_mark () const; }; -SCM names_to_translators (SCM namelist, Context*tg); -void recurse_over_translators (Context * c, Translator_method ptr, Direction); +SCM names_to_translators (SCM namelist, Context *tg); +void recurse_over_translators (Context *c, Translator_method ptr, Direction); void translator_each (SCM list, Translator_method method); - #endif // TRANSLATOR_GROUP_HH diff --git a/lily/include/translator.hh b/lily/include/translator.hh index f7dcdf8e7f..6173536b46 100644 --- a/lily/include/translator.hh +++ b/lily/include/translator.hh @@ -6,7 +6,6 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef TRANSLATOR_HH #define TRANSLATOR_HH @@ -23,7 +22,7 @@ #endif #define TRANSLATOR_DECLARATIONS(NAME) \ -public: \ + public: \ NAME (); \ VIRTUAL_COPY_CONSTRUCTOR (Translator, NAME); \ static SCM static_description_; \ @@ -42,91 +41,87 @@ protected: public: bool must_be_last () const; - - Context * context () const { return daddy_context_; } - + + Context *context () const { return daddy_context_; } + Translator (Translator const &); SCM internal_get_property (SCM symbol) const; - + virtual Output_def *get_output_def () const; - virtual Translator_group* get_daddy_translator ()const; - virtual Moment now_mom () const; + virtual Translator_group *get_daddy_translator ()const; + virtual Moment now_mom () const; virtual bool try_music (Music *req); virtual void stop_translation_timestep (); virtual void start_translation_timestep (); - virtual void initialize () ; + virtual void initialize (); virtual void process_music (); virtual void do_announces (); virtual void finalize (); - - Score_context * get_score_context () const; - Global_context * get_global_context () const; - - TRANSLATOR_DECLARATIONS(Translator); + Score_context *get_score_context () const; + Global_context *get_global_context () const; + + TRANSLATOR_DECLARATIONS (Translator); DECLARE_SMOBS (Translator, dummy); protected: // should be private. - Context * daddy_context_ ; + Context *daddy_context_; virtual void derived_mark () const; - + friend class Context_def; friend class Context; }; /** - A macro to automate administration of translators. - */ -#define ADD_THIS_TRANSLATOR(T) \ -SCM T::static_description_ = SCM_EOL;\ -static void _ ## T ## _adder () {\ - T *t = new T;\ - T::static_description_ = t->static_translator_description ();\ - scm_permanent_object (T::static_description_);\ - add_translator (t);\ -}\ -SCM T::translator_description() const\ -{ \ - return static_description_;\ -}\ -ADD_GLOBAL_CTOR (_ ## T ## _adder); - - - - -#define ADD_TRANSLATOR(classname, desc, grobs, accepted, acked, read, write) \ -ADD_THIS_TRANSLATOR (classname);\ -SCM \ -classname::static_translator_description () const \ -{ \ - SCM static_properties = SCM_EOL; \ - /* static_properties = acons (name , gh_str02scm (Translator::name (self_scm ())), \ - static_properties_); \ - */ \ - static_properties = scm_acons (ly_symbol2scm ("grobs-created"), \ - parse_symbol_list (grobs), static_properties); \ - \ - static_properties = scm_acons (ly_symbol2scm ("description"), \ - scm_makfrom0str (desc), static_properties); \ - \ - static_properties = scm_acons (ly_symbol2scm ("interfaces-acked"), \ - parse_symbol_list (acked), static_properties); \ - static_properties = scm_acons (ly_symbol2scm ("events-accepted"), \ - parse_symbol_list (accepted), static_properties); \ - \ - static_properties = scm_acons (ly_symbol2scm ("properties-read"), \ - parse_symbol_list (read), static_properties); \ - \ - static_properties = scm_acons (ly_symbol2scm ("properties-written"), \ - parse_symbol_list (write), static_properties); \ - \ - return static_properties; \ -} - - - -void add_translator (Translator*trans); - -Translator*get_translator (SCM s); -DECLARE_UNSMOB(Translator, translator); + A macro to automate administration of translators. +*/ +#define ADD_THIS_TRANSLATOR(T) \ + SCM T::static_description_ = SCM_EOL; \ + static void _ ## T ## _adder () \ + { \ + T *t = new T; \ + T::static_description_ = t->static_translator_description (); \ + scm_permanent_object (T::static_description_); \ + add_translator (t); \ + } \ + SCM T::translator_description () const \ + { \ + return static_description_; \ + } \ + ADD_GLOBAL_CTOR (_ ## T ## _adder); + + +#define ADD_TRANSLATOR(classname, desc, grobs, accepted, acked, read, write) \ + ADD_THIS_TRANSLATOR (classname); \ + SCM \ + classname::static_translator_description () const \ + { \ + SCM static_properties = SCM_EOL; \ + /* static_properties = acons (name , gh_str02scm (Translator::name (self_scm ())), \ + static_properties_); \ + */ \ + static_properties = scm_acons (ly_symbol2scm ("grobs-created"), \ + parse_symbol_list (grobs), static_properties); \ + \ + static_properties = scm_acons (ly_symbol2scm ("description"), \ + scm_makfrom0str (desc), static_properties); \ + \ + static_properties = scm_acons (ly_symbol2scm ("interfaces-acked"), \ + parse_symbol_list (acked), static_properties); \ + static_properties = scm_acons (ly_symbol2scm ("events-accepted"), \ + parse_symbol_list (accepted), static_properties); \ + \ + static_properties = scm_acons (ly_symbol2scm ("properties-read"), \ + parse_symbol_list (read), static_properties); \ + \ + static_properties = scm_acons (ly_symbol2scm ("properties-written"), \ + parse_symbol_list (write), static_properties); \ + \ + return static_properties; \ + } + +void add_translator (Translator *trans); + +Translator *get_translator (SCM s); +DECLARE_UNSMOB (Translator, translator); #endif // TRANSLATOR_HH diff --git a/lily/include/tuplet-bracket.hh b/lily/include/tuplet-bracket.hh index ebedc328e0..4d1963b761 100644 --- a/lily/include/tuplet-bracket.hh +++ b/lily/include/tuplet-bracket.hh @@ -13,20 +13,20 @@ class Tuplet_bracket { public: - DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM )); - DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM )); - DECLARE_SCHEME_CALLBACK (print, (SCM )); - - static bool has_interface (Grob*); - static void add_column (Grob*me, Item*); - static void add_beam (Grob*me, Grob*); - static Grob *parallel_beam (Grob *me, Link_array const&cols, bool *equally_long); - static void calc_position_and_height (Grob*, Real*, Real *dy); - static Stencil make_bracket (Grob *me, Axis protusion_axis, - Offset dz, Drul_array height, - Interval gap, Drul_array widen, - Drul_array shorten); - static Direction get_default_dir (Grob*); + DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM)); + DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM)); + DECLARE_SCHEME_CALLBACK (print, (SCM)); + + static bool has_interface (Grob *); + static void add_column (Grob *me, Item *); + static void add_beam (Grob *me, Grob *); + static Grob *parallel_beam (Grob *me, Link_array const &cols, bool *equally_long); + static void calc_position_and_height (Grob *, Real *, Real *dy); + static Stencil make_bracket (Grob *me, Axis protusion_axis, + Offset dz, Drul_array height, + Interval gap, Drul_array widen, + Drul_array shorten); + static Direction get_default_dir (Grob *); }; #endif // Tuplet_bracket_HH diff --git a/lily/include/tweak-registration.hh b/lily/include/tweak-registration.hh index 8846c54332..77a154c695 100644 --- a/lily/include/tweak-registration.hh +++ b/lily/include/tweak-registration.hh @@ -4,33 +4,32 @@ source file of the GNU LilyPond music typesetter (c) 2004--2005 Han-Wen Nienhuys - */ #ifndef TWEAK_REGISTRATION_HH #define TWEAK_REGISTRATION_HH -#include +#include #include "lily-proto.hh" #include "object-key.hh" -typedef std::map Tweak_map; +typedef std::map < Object_key const *, SCM, Object_key_less> Tweak_map; class Tweak_registry { Tweak_map tweaks_; Object_key_undumper *undumper_; - DECLARE_SMOBS(Tweak_registry, ); - + DECLARE_SMOBS (Tweak_registry,); + public: Tweak_registry (); - Object_key_undumper *undumper() const; + Object_key_undumper *undumper () const; void clear (); - void insert_grob_tweak (Grob*, SCM); - void replace_grob_tweak (Grob*, SCM); + void insert_grob_tweak (Grob *, SCM); + void replace_grob_tweak (Grob *, SCM); SCM get_tweaks (Grob *); SCM list_tweaks (); void insert_tweak_from_file (SCM); diff --git a/lily/include/type-swallow-translator.hh b/lily/include/type-swallow-translator.hh index 55a520d91a..83b9506c2f 100644 --- a/lily/include/type-swallow-translator.hh +++ b/lily/include/type-swallow-translator.hh @@ -6,37 +6,38 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef TYPESWALLOW_GRAV_HH #define TYPESWALLOW_GRAV_HH #include "translator.hh" /** eat a certain type of event - (Duh, it's good for your skin) - */ + (Duh, it's good for your skin) +*/ class Type_swallow_translator : public virtual Translator { protected: String swallow_string_; - bool try_music (Music*); -public: + bool try_music (Music *); +public: VIRTUAL_COPY_CONS (Translator); }; #define DECLARE_EVENT_SWALLOWER(TYPE) \ -struct TYPE ## _swallow_translator : public Type_swallow_translator { \ - TRANSLATOR_DECLARATIONS (TYPE ## _swallow_translator); \ -}; \ - TYPE ## _swallow_translator :: TYPE ## _swallow_translator() {\ - swallow_string_ = #TYPE; \ + struct TYPE ## _swallow_translator : public Type_swallow_translator \ + { \ + TRANSLATOR_DECLARATIONS (TYPE ## _swallow_translator); \ + }; \ + TYPE ## _swallow_translator :: TYPE ## _swallow_translator () \ + { \ + swallow_string_ = #TYPE; \ } \ -ADD_TRANSLATOR(TYPE ## _swallow_translator, \ - "Swallow events of " #TYPE " type.", \ - "", \ - "general-music", \ - "", \ - "", \ + ADD_TRANSLATOR (TYPE ## _swallow_translator, \ + "Swallow events of " #TYPE " type.", \ + "", \ + "general-music", \ + "", \ + "", \ ""); #endif // TYPESWALLOW_GRAV_HH diff --git a/lily/include/vaticana-ligature.hh b/lily/include/vaticana-ligature.hh index cfc5f4b3af..235fa1e1ea 100644 --- a/lily/include/vaticana-ligature.hh +++ b/lily/include/vaticana-ligature.hh @@ -3,7 +3,7 @@ source file of the GNU LilyPond music typesetter - (c) 2003--2005 Juergen Reuter + (c) 2003--2005 Juergen Reuter */ #ifndef VATICANA_LIGATURE_HH @@ -13,8 +13,8 @@ struct Vaticana_ligature { - DECLARE_SCHEME_CALLBACK (brew_ligature_primitive, (SCM )); - DECLARE_SCHEME_CALLBACK (print, (SCM )); + DECLARE_SCHEME_CALLBACK (brew_ligature_primitive, (SCM)); + DECLARE_SCHEME_CALLBACK (print, (SCM)); static bool has_interface (Grob *); }; @@ -24,6 +24,6 @@ struct Vaticana_ligature * * The below definition extends those in gregorian-ligature.hh. */ -#define STACKED_HEAD 0x0100 // this head is stacked on the previous one +#define STACKED_HEAD 0x0100 // this head is stacked on the previous one #endif // VATICANA_LIGATURE_HH diff --git a/lily/include/volta-bracket.hh b/lily/include/volta-bracket.hh index 0a41ef30dd..227c09dce6 100644 --- a/lily/include/volta-bracket.hh +++ b/lily/include/volta-bracket.hh @@ -7,16 +7,15 @@ #ifndef VOLTA_SPANNER_HH #define VOLTA_SPANNER_HH - #include "spanner.hh" class Volta_bracket_interface { public: - static bool has_interface (Grob*); - DECLARE_SCHEME_CALLBACK (print, (SCM )); - static void add_column (Grob*, Grob*col); - static void add_bar (Grob*me, Item*bar); + static bool has_interface (Grob *); + DECLARE_SCHEME_CALLBACK (print, (SCM)); + static void add_column (Grob *, Grob *col); + static void add_bar (Grob *me, Item *bar); }; #endif // VOLTA_SPANNER_HH diff --git a/lily/input-scheme.cc b/lily/input-scheme.cc index 58c4eb338f..4c771f0049 100644 --- a/lily/input-scheme.cc +++ b/lily/input-scheme.cc @@ -4,7 +4,6 @@ source file of the GNU LilyPond music typesetter (c) 2005 Han-Wen Nienhuys - */ #include "string.hh" @@ -20,7 +19,7 @@ LY_DEFINE (ly_input, "ly:input-location?", 1, 0, 0, } LY_DEFINE (ly_input_message, "ly:input-message", 2, 0, 0, (SCM sip, SCM msg), - "Print @var{msg} as a GNU compliant error message, pointing to the" + "Print @var{msg} as a GNU compliant error message, pointing to the" "location in @var{sip}.\n") { Input *ip = unsmob_input (sip); @@ -34,7 +33,7 @@ LY_DEFINE (ly_input_message, "ly:input-message", 2, 0, 0, (SCM sip, SCM msg), } LY_DEFINE (ly_input_file_line_column, "ly:input-file-line-column", 1, 0, 0, (SCM sip), - "Return input location in @var{sip} as (file-name line column).") + "Return input location in @var{sip} as (file-name line column).") { Input *ip = unsmob_input (sip); SCM_ASSERT_TYPE (ip, sip, SCM_ARG1, __FUNCTION__, "input location"); @@ -44,7 +43,7 @@ LY_DEFINE (ly_input_file_line_column, "ly:input-file-line-column", 1, 0, 0, (SCM } LY_DEFINE (ly_input_both_locations, "ly:input-both-locations", 1, 0, 0, (SCM sip), - "Return input location in @var{sip} as (file-name first-line first-column last-line last-column).") + "Return input location in @var{sip} as (file-name first-line first-column last-line last-column).") { Input *ip = unsmob_input (sip); SCM_ASSERT_TYPE (ip, sip, SCM_ARG1, __FUNCTION__, "input location"); diff --git a/lily/input-smob.cc b/lily/input-smob.cc index cd4c468637..a543f52a9b 100644 --- a/lily/input-smob.cc +++ b/lily/input-smob.cc @@ -1,11 +1,10 @@ -/* +/* input-smob.cc -- implement Input smob - + source file of the GNU LilyPond music typesetter - + (c) 2000--2005 Han-Wen Nienhuys - - */ +*/ #include "input-smob.hh" @@ -27,7 +26,7 @@ SCM mark_smob (SCM) static int print_smob (SCM s, SCM port, scm_print_state *) { - String str = "#location_string () + ">"; + String str = "#location_string () + ">"; scm_puts (str.to_str0 (), port); return 1; } @@ -39,7 +38,6 @@ free_smob (SCM s) return 0; } - static void start_input_smobs () { @@ -55,22 +53,21 @@ make_input (Input ip) { Input *nip = new Input (ip); SCM z; - + SCM_NEWSMOB (z, input_tag, nip); return z; } -Input * +Input * unsmob_input (SCM s) { if (SCM_IMP (s)) return 0; if (SCM_CAR (s) == (SCM)input_tag) // ugh. - return (Input*) SCM_CDR (s); - else - return 0; + return (Input *) SCM_CDR (s); + else + return 0; } - ADD_SCM_INIT_FUNC (input, start_input_smobs); diff --git a/lily/input.cc b/lily/input.cc index 83ae50a43c..f833937a18 100644 --- a/lily/input.cc +++ b/lily/input.cc @@ -1,7 +1,7 @@ /* - input.cc -- implement Input + input.cc -- implement Input - source file of the LilyPond music typesetter + source file of the LilyPond music typesetter (c) 1997--2005 Han-Wen Nienhuys */ @@ -43,8 +43,8 @@ void Input::step_forward () { if (end_ == start_) - end_ ++; - start_ ++; + end_++; + start_++; } void @@ -58,43 +58,42 @@ Input::set_location (Input const &i_start, Input const &i_end) /* Produce GNU-compliant error message. Correcting lilypond source is such a breeze if you ('re edidor) know (s) the error column too - - Format: - [file:line:column:][warning:]message + Format: - */ + [file:line:column:][warning:]message +*/ void Input::message (String message_string) const { String str; - + /* - marked "Work in prgress" in GNU iostream - libg++ 2.7.2.8 - libstdc++ 2.8.1 + marked "Work in prgress" in GNU iostream + libg++ 2.7.2.8 + libstdc++ 2.8.1 - why not just return always -1 (unknown), + why not just return always -1 (unknown), iso breaking the interface? - int col = cerr.rdbuf ()->column (); + int col = cerr.rdbuf ()->column (); - */ + */ // well, we don't want to loose first warning... int col = 1; if (col > 0) str += "\n"; - + if (source_file_) str += location_string () + String (": "); str += message_string; if (source_file_) - { - str += ":\n"; - str += source_file_->error_string (start_); - } + { + str += ":\n"; + str += source_file_->error_string (start_); + } fprintf (stderr, "%s\n", str.to_str0 ()); fflush (stderr); } @@ -142,7 +141,6 @@ Input::file_string () const return ""; } - int Input::line_number () const { diff --git a/lily/instrument-name-engraver.cc b/lily/instrument-name-engraver.cc index 74bb0b21a4..1ae35630c6 100644 --- a/lily/instrument-name-engraver.cc +++ b/lily/instrument-name-engraver.cc @@ -1,11 +1,10 @@ -/* +/* instrument-name-engraver.cc -- implement Instrument_name_engraver - + source file of the GNU LilyPond music typesetter - + (c) 2000--2005 Han-Wen Nienhuys - - */ +*/ #include "engraver.hh" #include "bar-line.hh" @@ -18,7 +17,7 @@ class Instrument_name_engraver : public Engraver { - + public: TRANSLATOR_DECLARATIONS (Instrument_name_engraver); @@ -40,7 +39,7 @@ Instrument_name_engraver::Instrument_name_engraver () void Instrument_name_engraver::initialize () { - context ()->set_property ("instrumentSupport", SCM_EOL); + context ()->set_property ("instrumentSupport", SCM_EOL); } void @@ -58,24 +57,23 @@ void Instrument_name_engraver::create_text () { if (text_) - return ; - + return; + SCM txt = get_property ("instrument"); - + if (now_mom () > Moment (0)) txt = get_property ("instr"); /* UGH. */ if (txt == SCM_EOL) - return ; + return; - text_ = make_item ("InstrumentName", SCM_EOL); - + if (text_->get_property ("text") != txt) text_->set_property ("text", txt); - + } void @@ -88,11 +86,10 @@ Instrument_name_engraver::acknowledge_grob (Grob_info i) /* Ugh - typechecking for pedal and dynamic sucks. - */ - if (dynamic_cast (i.grob_) + */ + if (dynamic_cast (i.grob_) && (i.grob_->internal_has_interface (ly_symbol2scm ("dynamic-interface")) - || i.grob_->internal_has_interface (ly_symbol2scm ("piano-pedal-interface"))) - ) + || i.grob_->internal_has_interface (ly_symbol2scm ("piano-pedal-interface")))) return; /* @@ -104,13 +101,13 @@ Instrument_name_engraver::acknowledge_grob (Grob_info i) We could also just use stavesFound, but lets keep this working without staffs as well. */ - if (dynamic_cast (i.grob_) + if (dynamic_cast (i.grob_) && ((Axis_group_interface::has_interface (i.grob_) && Axis_group_interface::has_axis (i.grob_, Y_AXIS))) && !Align_interface::has_interface (i.grob_)) { SCM nl = scm_cons (i.grob_->self_scm (), - get_property ("instrumentSupport")); + get_property ("instrumentSupport")); context ()->set_property ("instrumentSupport", nl); } @@ -121,25 +118,24 @@ Instrument_name_engraver::process_music () { /* Also create text if barlines in other groups. This allows - a name to be attached to lyrics or chords. - */ + a name to be attached to lyrics or chords. + */ if (scm_is_string (get_property ("whichBar"))) create_text (); } ADD_TRANSLATOR (Instrument_name_engraver, -/* descr */ " Prints the name of the instrument (specified by " -" @code{Staff.instrument} and @code{Staff.instr}) " -"at the left of the staff. ", -/* creats*/ "InstrumentName", -/* accepts */ "", -/* acks */ "bar-line-interface axis-group-interface", -/* reads */ "instrument instr", -/* write */ ""); + /* descr */ " Prints the name of the instrument (specified by " + " @code{Staff.instrument} and @code{Staff.instr}) " + "at the left of the staff. ", + /* creats*/ "InstrumentName", + /* accepts */ "", + /* acks */ "bar-line-interface axis-group-interface", + /* reads */ "instrument instr", + /* write */ ""); /****************************************************************/ - class Vocal_name_engraver : public Instrument_name_engraver { public: @@ -147,20 +143,18 @@ public: virtual void create_text (); }; - Vocal_name_engraver::Vocal_name_engraver () { } - void Vocal_name_engraver::create_text () { if (text_) - return ; - + return; + SCM txt = get_property ("vocalName"); - + if (now_mom () > Moment (0)) txt = get_property ("vocNam"); @@ -168,23 +162,21 @@ Vocal_name_engraver::create_text () UGH. */ if (txt == SCM_EOL) - return ; - + return; + text_ = make_item ("VocalName", SCM_EOL); - + if (text_->get_property ("text") != txt) text_->set_property ("text", txt); - -} - +} ADD_TRANSLATOR (Vocal_name_engraver, -/* descr */ " Prints the name of the a lyric voice (specified by " -" @code{Staff.vocalName} and @code{Staff.vocNam}) " -"at the left of the staff. ", -/* creats*/ "VocalName", -/* accepts */ "", -/* acks */ "bar-line-interface axis-group-interface", -/* reads */ "vocNam vocalName", -/* write */ ""); + /* descr */ " Prints the name of the a lyric voice (specified by " + " @code{Staff.vocalName} and @code{Staff.vocNam}) " + "at the left of the staff. ", + /* creats*/ "VocalName", + /* accepts */ "", + /* acks */ "bar-line-interface axis-group-interface", + /* reads */ "vocNam vocalName", + /* write */ ""); diff --git a/lily/item.cc b/lily/item.cc index a6c3577a6f..e94b5bc267 100644 --- a/lily/item.cc +++ b/lily/item.cc @@ -15,13 +15,12 @@ #include "system.hh" #include "group-interface.hh" -Grob * +Grob * Item::clone (int count) const { return new Item (*this, count); } - Item::Item (SCM s, Object_key const *key) : Grob (s, key) { @@ -38,24 +37,23 @@ Item::Item (Item const &s, int copy_count) broken_to_drul_[LEFT] = broken_to_drul_[RIGHT] = 0; } - bool -Item::is_breakable (Grob*me) +Item::is_breakable (Grob *me) { if (me->original_) return false; - if (!dynamic_cast (me)) + if (!dynamic_cast (me)) me->programming_error ("only items can be breakable."); - - Item * i = dynamic_cast (me->get_parent (X_AXIS)); + + Item *i = dynamic_cast (me->get_parent (X_AXIS)); return (i) ? Item::is_breakable (i) : to_boolean (me->get_property ("breakable")); } Paper_column * Item::get_column () const { - Item *parent = dynamic_cast (get_parent (X_AXIS)); + Item *parent = dynamic_cast (get_parent (X_AXIS)); return parent ? parent->get_column () : 0; } @@ -63,20 +61,19 @@ System * Item::get_system () const { Grob *g = get_parent (X_AXIS); - return g ? g->get_system () : 0; + return g ? g->get_system () : 0; } - void Item::copy_breakable_items () { Drul_array new_copies; Direction i = LEFT; int count = 0; - do + do { - Grob * dolly = clone (count ++); - Item * item = dynamic_cast (dolly); + Grob *dolly = clone (count++); + Item *item = dynamic_cast (dolly); pscore_->system_->typeset_grob (item); new_copies[i] = item; } @@ -84,17 +81,15 @@ Item::copy_breakable_items () broken_to_drul_ = new_copies; } - bool Item::is_broken () const { return broken_to_drul_[LEFT] || broken_to_drul_[RIGHT]; } - /* Generate items for begin and end-of line. - */ +*/ void Item::discretionary_processing () { @@ -105,40 +100,39 @@ Item::discretionary_processing () copy_breakable_items (); } -Grob* -Item::find_broken_piece (System*l) const +Grob * +Item::find_broken_piece (System *l) const { - if (get_system () == l) - return (Item*) (this); + if (get_system () == l) + return (Item *) (this); Direction d = LEFT; - do { - Grob *s = broken_to_drul_[d]; - if (s && s->get_system () == l) - return s; - } + do + { + Grob *s = broken_to_drul_[d]; + if (s && s->get_system () == l) + return s; + } while (flip (&d) != LEFT); return 0; } - -Item* +Item * Item::find_prebroken_piece (Direction d) const { - Item * me = (Item *) (this); + Item *me = (Item *) (this); if (!d) return me; - return dynamic_cast (broken_to_drul_[d]); + return dynamic_cast (broken_to_drul_[d]); } - Direction Item::break_status_dir () const { if (original_) { - Item * i = dynamic_cast (original_); + Item *i = dynamic_cast (original_); return (i->broken_to_drul_[LEFT] == this) ? LEFT : RIGHT; } @@ -150,7 +144,7 @@ void Item::handle_prebroken_dependencies () { Grob::handle_prebroken_dependencies (); - + /* Can't do this earlier, because try_visibility_lambda () might set the elt property transparent, which would then be copied. @@ -167,7 +161,7 @@ Item::handle_prebroken_dependencies () SCM result = scm_apply_0 (vis, args); bool trans = ly_scm2bool (scm_car (result)); bool empty = ly_scm2bool (scm_cdr (result)); - + if (empty && trans) suicide (); else if (empty) @@ -190,47 +184,45 @@ Item::do_derived_mark () const return SCM_EOL; } -Item* -unsmob_item (SCM s ) +Item * +unsmob_item (SCM s) { - return dynamic_cast (unsmob_grob (s)); + return dynamic_cast (unsmob_grob (s)); } - ADD_INTERFACE (Item, - "item-interface", - "\n" - "\n" - "Grobs can be distinguished in their role in the horizontal spacing.\n" - "Many grobs define constraints on the spacing by their sizes. For\n" - "example, note heads, clefs, stems, and all other symbols with a fixed\n" - "shape. These grobs form a subtype called @code{Item}.\n" - "\n" - "\n" - "Some items need special treatment for line breaking. For example, a\n" - "clef is normally only printed at the start of a line (i.e. after a\n" - "line break). To model this, `breakable' items (clef, key signature,\n" - "bar lines, etc.) are copied twice. Then we have three versions of each\n" - "breakable item: one version if there is no line break, one version\n" - "that is printed before the line break (at the end of a system), one\n" - "version that is printed after the line break.\n" - "\n" - "Whether these versions are visible and take up space, is determined by\n" - "the outcome of the @code{break-visibility}. This grob property is a\n" - "function taking a direction (-1, 0 or 1) as argument. It returns a\n" - "cons of booleans, signifying whether this grob should be transparent\n" - "and have no extent.\n" - "\n" - "The following variables for break-visibility are predefined:\n" - "@example\n" - " grob will show: before no after\n" - " break break break\n" - " all-invisible no no no\n" - " begin-of-line-visible no no yes\n" - " end-of-line-visible yes no no\n" - " all-visible yes yes yes\n" - " begin-of-line-invisible yes yes no\n" - " end-of-line-invisible no yes yes\n" - "@end example\n" - , - "no-spacing-rods break-visibility breakable") + "item-interface", + "\n" + "\n" + "Grobs can be distinguished in their role in the horizontal spacing.\n" + "Many grobs define constraints on the spacing by their sizes. For\n" + "example, note heads, clefs, stems, and all other symbols with a fixed\n" + "shape. These grobs form a subtype called @code{Item}.\n" + "\n" + "\n" + "Some items need special treatment for line breaking. For example, a\n" + "clef is normally only printed at the start of a line (i.e. after a\n" + "line break). To model this, `breakable' items (clef, key signature,\n" + "bar lines, etc.) are copied twice. Then we have three versions of each\n" + "breakable item: one version if there is no line break, one version\n" + "that is printed before the line break (at the end of a system), one\n" + "version that is printed after the line break.\n" + "\n" + "Whether these versions are visible and take up space, is determined by\n" + "the outcome of the @code{break-visibility}. This grob property is a\n" + "function taking a direction (-1, 0 or 1) as argument. It returns a\n" + "cons of booleans, signifying whether this grob should be transparent\n" + "and have no extent.\n" + "\n" + "The following variables for break-visibility are predefined:\n" + "@example\n" + " grob will show: before no after\n" + " break break break\n" + " all-invisible no no no\n" + " begin-of-line-visible no no yes\n" + " end-of-line-visible yes no no\n" + " all-visible yes yes yes\n" + " begin-of-line-invisible yes yes no\n" + " end-of-line-invisible no yes yes\n" + "@end example\n", + "no-spacing-rods break-visibility breakable") diff --git a/lily/key-engraver.cc b/lily/key-engraver.cc index 531eb9b346..3f5d722c0b 100644 --- a/lily/key-engraver.cc +++ b/lily/key-engraver.cc @@ -4,7 +4,7 @@ source file of the GNU LilyPond music typesetter (c) 1997--2005 Han-Wen Nienhuys - */ +*/ #include "item.hh" #include "bar-line.hh" @@ -16,15 +16,15 @@ /* TODO: The representation of key sigs is all fucked. - */ +*/ /** - Make the key signature. - */ + Make the key signature. +*/ class Key_engraver : public Engraver { void create_key (bool); - void read_ev (Music const * r); + void read_ev (Music const *r); Music *key_ev_; Item *item_; @@ -42,13 +42,11 @@ protected: virtual void acknowledge_grob (Grob_info); }; - void Key_engraver::finalize () { } - Key_engraver::Key_engraver () { key_ev_ = 0; @@ -56,11 +54,10 @@ Key_engraver::Key_engraver () cancellation_ = 0; } - void Key_engraver::create_key (bool def) { - if (!item_) + if (!item_) { item_ = make_item ("KeySignature", key_ev_ ? key_ev_->self_scm () : SCM_EOL); @@ -75,23 +72,22 @@ Key_engraver::create_key (bool def) cancellation_ = make_item ("KeyCancellation", key_ev_ ? key_ev_->self_scm () : SCM_EOL); cancellation_->set_property ("old-accidentals", last); cancellation_->set_property ("c0-position", - get_property ("middleCPosition")); - + get_property ("middleCPosition")); + } item_->set_property ("new-accidentals", key); } if (!def) { - SCM vis = get_property ("explicitKeySignatureVisibility"); + SCM vis = get_property ("explicitKeySignatureVisibility"); if (ly_c_procedure_p (vis)) item_->set_property ("break-visibility", vis); } -} - +} bool -Key_engraver::try_music (Music * ev) +Key_engraver::try_music (Music *ev) { if (ev->is_mus_type ("key-change-event")) { @@ -102,17 +98,16 @@ Key_engraver::try_music (Music * ev) read_ev (key_ev_); } return true; - } - return false; + } + return false; } - void Key_engraver::acknowledge_grob (Grob_info info) { if (Clef::has_interface (info.grob_)) { - SCM c = get_property ("createKeyOnClefChange"); + SCM c = get_property ("createKeyOnClefChange"); if (to_boolean (c)) { create_key (false); @@ -125,27 +120,24 @@ Key_engraver::acknowledge_grob (Grob_info info) } } - void Key_engraver::process_music () { - if (key_ev_ || - get_property ("lastKeySignature") != get_property ("keySignature")) + if (key_ev_ + || get_property ("lastKeySignature") != get_property ("keySignature")) create_key (false); } - void Key_engraver::stop_translation_timestep () { item_ = 0; context ()->set_property ("lastKeySignature", get_property ("keySignature")); - cancellation_ = 0; + cancellation_ = 0; } - void -Key_engraver::read_ev (Music const * r) +Key_engraver::read_ev (Music const *r) { SCM p = r->get_property ("pitch-alist"); if (!scm_is_pair (p)) @@ -162,24 +154,22 @@ Key_engraver::read_ev (Music const * r) n = scm_delete_x (scm_car (s), n); } } - - for (SCM s = n ; scm_is_pair (s); s = scm_cdr (s)) + + for (SCM s = n; scm_is_pair (s); s = scm_cdr (s)) if (scm_to_int (scm_cdar (s))) accs = scm_cons (scm_car (s), accs); context ()->set_property ("keySignature", accs); - context ()->set_property ("tonic" , + context ()->set_property ("tonic", r->get_property ("tonic")); } - void Key_engraver::start_translation_timestep () { key_ev_ = 0; } - void Key_engraver::initialize () { @@ -191,11 +181,10 @@ Key_engraver::initialize () } - ADD_TRANSLATOR (Key_engraver, -/* descr */ "", -/* creats*/ "KeySignature", -/* accepts */ "key-change-event", -/* acks */ "bar-line-interface clef-interface", -/* reads */ "keySignature printKeyCancellation lastKeySignature explicitKeySignatureVisibility createKeyOnClefChange keyAccidentalOrder keySignature", -/* write */ "lastKeySignature tonic keySignature"); + /* descr */ "", + /* creats*/ "KeySignature", + /* accepts */ "key-change-event", + /* acks */ "bar-line-interface clef-interface", + /* reads */ "keySignature printKeyCancellation lastKeySignature explicitKeySignatureVisibility createKeyOnClefChange keyAccidentalOrder keySignature", + /* write */ "lastKeySignature tonic keySignature"); diff --git a/lily/key-performer.cc b/lily/key-performer.cc index e96c713ca2..9c05a1bb4d 100644 --- a/lily/key-performer.cc +++ b/lily/key-performer.cc @@ -18,13 +18,13 @@ public: ~Key_performer (); protected: - virtual bool try_music (Music* ev); + virtual bool try_music (Music *ev); virtual void create_audio_elements (); virtual void stop_translation_timestep (); private: - Event* key_ev_; - Audio_key* audio_; + Event *key_ev_; + Audio_key *audio_; }; Key_performer::Key_performer () @@ -40,19 +40,19 @@ Key_performer::~Key_performer () void Key_performer::create_audio_elements () { - if (key_ev_) + if (key_ev_) { SCM pitchlist = key_ev_->get_property ("pitch-alist"); SCM proc = ly_lily_module_constant ("alterations-in-key"); - + SCM acc = scm_call_1 (proc, pitchlist); - - Pitch key_do (0, + + Pitch key_do (0, scm_to_int (scm_caar (pitchlist)), scm_to_int (scm_cdar (pitchlist))); Pitch c_do (0, 0, 0); - + SCM c_pitchlist = ly_transpose_key_alist (pitchlist, pitch_interval (key_do, c_do).smobbed_copy ()); @@ -80,9 +80,9 @@ Key_performer::stop_translation_timestep () } bool -Key_performer::try_music (Music* ev) +Key_performer::try_music (Music *ev) { - if (Event *kc = dynamic_cast (ev)) + if (Event *kc = dynamic_cast (ev)) { if (key_ev_) warning (_ ("FIXME: key change merge")); @@ -95,6 +95,6 @@ Key_performer::try_music (Music* ev) } ADD_TRANSLATOR (Key_performer, - "", "", - "key-change-event", - "", "", ""); + "", "", + "key-change-event", + "", "", ""); diff --git a/lily/key-signature-interface.cc b/lily/key-signature-interface.cc index 8c4ca9134a..9d776d9dce 100644 --- a/lily/key-signature-interface.cc +++ b/lily/key-signature-interface.cc @@ -17,24 +17,21 @@ struct Key_signature_interface { - DECLARE_SCHEME_CALLBACK (print, (SCM )); + DECLARE_SCHEME_CALLBACK (print, (SCM)); - static bool has_interface (Grob*); + static bool has_interface (Grob *); }; - /* FIXME: too much hardcoding here. - */ +*/ const int FLAT_TOP_PITCH =2; /* fes, ges, as and bes typeset in lower octave */ const int SHARP_TOP_PITCH =4; /* ais and bis typeset in lower octave */ /* - TODO: look this up. I'm not sure where the naturals ought to go. - */ -const int NATURAL_TOP_PITCH = 4; - - + TODO: look this up. I'm not sure where the naturals ought to go. +*/ +const int NATURAL_TOP_PITCH = 4; /* @@ -43,11 +40,10 @@ const int NATURAL_TOP_PITCH = 4; - TODO: put this in Scheme - TODO: can we do without c0pos? it's partly musical. - + TODO: can we do without c0pos? it's partly musical. */ int -alteration_pos (SCM what, int alter, int c0p) +alteration_pos (SCM what, int alter, int c0p) { if (scm_is_pair (what)) return scm_to_int (scm_car (what)) * 7 + scm_to_int (scm_cdr (what)) + c0p; @@ -60,41 +56,40 @@ alteration_pos (SCM what, int alter, int c0p) from_bottom_pos = (from_bottom_pos + 7)%7; // Precaution to get positive. int c0 = from_bottom_pos - 4; - - if ((alter <0 && ((p>FLAT_TOP_PITCH) || (p+c0>4)) && (p+c0>1)) - || (alter >0 && ((p > SHARP_TOP_PITCH) || (p+c0>5)) && (p+c0>2)) - || (alter == 0 && ((p > NATURAL_TOP_PITCH) || (p + c0>5)) && (p + c0>2))) + if ((alter <0 && ((p > FLAT_TOP_PITCH) || (p + c0 > 4)) && (p + c0 > 1)) + || (alter >0 && ((p > SHARP_TOP_PITCH) || (p + c0 > 5)) && (p + c0 > 2)) + || (alter == 0 && ((p > NATURAL_TOP_PITCH) || (p + c0 > 5)) && (p + c0 > 2))) { p -= 7; /* Typeset below c_position */ } - - /* Provide for the four cases in which there's a glitch - it's a hack, but probably not worth - the effort of finding a nicer solution. - --dl. */ - if (c0==2 && alter >0 && p ==3) + + /* Provide for the four cases in which there's a glitch + it's a hack, but probably not worth + the effort of finding a nicer solution. + --dl. */ + if (c0 == 2 && alter >0 && p ==3) p -= 7; - if (c0==-3 && alter>0 && p ==-1) + if (c0==-3 && alter > 0 && p ==-1) p += 7; - if (c0==-4 && alter<0 && p ==-1) + if (c0==-4 && alter < 0 && p ==-1) p += 7; - if (c0==-2 && alter<0 && p ==-3) + if (c0==-2 && alter < 0 && p ==-3) p += 7; - + return p + c0; } /* TODO - space the `natural' signs wider - */ +*/ MAKE_SCHEME_CALLBACK (Key_signature_interface, print, 1); SCM Key_signature_interface::print (SCM smob) { - Grob*me = unsmob_grob (smob); + Grob *me = unsmob_grob (smob); - Real inter = Staff_symbol_referencer::staff_space (me)/2.0; + Real inter = Staff_symbol_referencer::staff_space (me) / 2.0; SCM scm_style = me->get_property ("style"); String style; @@ -107,7 +102,7 @@ Key_signature_interface::print (SCM smob) style = ""; } - SCM newas = me->get_property ("new-accidentals"); + SCM newas = me->get_property ("new-accidentals"); Stencil mol; SCM c0s = me->get_property ("c0-position"); @@ -124,8 +119,8 @@ Key_signature_interface::print (SCM smob) for (SCM s = newas; scm_is_pair (s); s = scm_cdr (s)) { int alteration = scm_to_int (scm_cdar (s)); - String font_char = - Accidental_interface::get_fontcharname (style, alteration); + String font_char + = Accidental_interface::get_fontcharname (style, alteration); Stencil acc (fm->find_by_name ("accidentals." + font_char)); if (acc.is_empty ()) @@ -141,20 +136,19 @@ Key_signature_interface::print (SCM smob) } } - Item *it = dynamic_cast (me) ; + Item *it = dynamic_cast (me); if (it->break_status_dir () != RIGHT) { SCM old = me->get_property ("old-accidentals"); - + Stencil natural; if (scm_is_pair (old)) natural = Font_interface::get_default_font (me)-> - find_by_name (String ("accidentals.") + style + String ("0")); - + find_by_name (String ("accidentals.") + style + String ("0")); int last_pos = -100; for (; scm_is_pair (old); old = scm_cdr (old)) - { + { SCM found = scm_assoc (scm_caar (old), newas); if (found == SCM_BOOL_F || scm_cdr (found) != scm_cdar (old)) @@ -164,29 +158,29 @@ Key_signature_interface::print (SCM smob) int pos = alteration_pos (what, alteration, c0p); Stencil m = natural; - m.translate_axis (pos* inter, Y_AXIS); + m.translate_axis (pos* inter, Y_AXIS); /* The natural sign (unlike flat & sharp) has vertical edges on both sides. A little padding is needed to prevent collisions. - */ + */ Real padding = 0.0; if (last_pos < pos + 2 - && last_pos> pos - 6) + && last_pos> pos - 6) padding = 0.3; - + mol.add_at_edge (X_AXIS, LEFT, m, padding, 0); last_pos = pos; - } - } + } + } } mol.align_to (X_AXIS, LEFT); - + return mol.smobbed_copy (); } ADD_INTERFACE (Key_signature_interface, "key-signature-interface", - "A group of accidentals, to be printed as signature sign.", - "style c0-position old-accidentals new-accidentals"); + "A group of accidentals, to be printed as signature sign.", + "style c0-position old-accidentals new-accidentals"); diff --git a/lily/keyword.cc b/lily/keyword.cc index 418542cd25..378ad4e168 100644 --- a/lily/keyword.cc +++ b/lily/keyword.cc @@ -1,6 +1,6 @@ /* keyword.cc -- keywords and identifiers - */ +*/ #include "keyword.hh" @@ -8,7 +8,7 @@ #include /* for qsort */ -int tabcmp (Keyword_ent const &p1, Keyword_ent const &p2) +int tabcmp (Keyword_ent const &p1, Keyword_ent const &p2) { return strcmp (p1.name_, p2.name_); } @@ -26,8 +26,8 @@ Keyword_table::Keyword_table (Keyword_ent *tab) int Keyword_table::lookup (char const *s) const { - Keyword_ent e ; - e.name_ = s; + Keyword_ent e; + e.name_ = s; int idx = binary_search (table_, e, tabcmp); if (idx >= 0) return table_[idx].tokcode_; diff --git a/lily/least-squares.cc b/lily/least-squares.cc index d589ea06fc..e7f6b30584 100644 --- a/lily/least-squares.cc +++ b/lily/least-squares.cc @@ -1,18 +1,17 @@ -/* +/* least-squares.cc -- implement minimise_least_squares - + source file of the GNU LilyPond music typesetter - + (c) 1996--2005 Han-Wen Nienhuys - - */ +*/ #include "least-squares.hh" #include "warn.hh" void -minimise_least_squares (Real * coef, Real * offset, +minimise_least_squares (Real *coef, Real *offset, Array const &input) { Real sx = 0.0; @@ -20,7 +19,7 @@ minimise_least_squares (Real * coef, Real * offset, Real sqx = 0.0; Real sxy = 0.0; - for (int i = 0; i < input.size ();i++) + for (int i = 0; i < input.size ();i++) { Real x = input[i][X_AXIS]; Real y = input[i][Y_AXIS]; @@ -33,18 +32,18 @@ minimise_least_squares (Real * coef, Real * offset, *coef = 0.0; *offset = 0.; - - Real den = (N*sqx - sqr (sx)); + + Real den = (N *sqx - sqr (sx)); if (!N || !den) { programming_error ("minimise_least_squares (): Nothing to minimise"); *coef = 0.0; - *offset = N ? sy/N : 0.0; + *offset = N ? sy / N : 0.0; } else { - *coef = (N * sxy - sx*sy)/den; - *offset = (sy - (*coef) * sx)/N; + *coef = (N *sxy - sx*sy) / den; + *offset = (sy - (*coef) * sx) / N; } } diff --git a/lily/ledger-line-engraver.cc b/lily/ledger-line-engraver.cc index 9cd1741fab..b077ff3379 100644 --- a/lily/ledger-line-engraver.cc +++ b/lily/ledger-line-engraver.cc @@ -1,10 +1,9 @@ -/* +/* ledger-line-engraver.cc -- implement Ledger_line_engraver - + source file of the GNU LilyPond music typesetter - + (c) 2004--2005 Han-Wen Nienhuys - */ #include "group-interface.hh" @@ -13,7 +12,7 @@ class Ledger_line_engraver : public Engraver { - Spanner * span_; + Spanner *span_; public: TRANSLATOR_DECLARATIONS (Ledger_line_engraver); @@ -24,7 +23,7 @@ protected: virtual void acknowledge_grob (Grob_info); }; -Ledger_line_engraver::Ledger_line_engraver() +Ledger_line_engraver::Ledger_line_engraver () { span_ = 0; } @@ -34,8 +33,8 @@ Ledger_line_engraver::process_music () { if (!span_) { - span_ = make_spanner("LedgerLineSpanner", SCM_EOL); - + span_ = make_spanner ("LedgerLineSpanner", SCM_EOL); + span_->set_bound (LEFT, unsmob_grob (get_property ("currentCommandColumn"))); } } @@ -47,7 +46,6 @@ Ledger_line_engraver::finalize () span_->set_bound (RIGHT, unsmob_grob (get_property ("currentCommandColumn"))); } - void Ledger_line_engraver::acknowledge_grob (Grob_info s) { @@ -56,9 +54,9 @@ Ledger_line_engraver::acknowledge_grob (Grob_info s) s.grob_); } ADD_TRANSLATOR (Ledger_line_engraver, - "Creates the spanner to draw ledger lines, and notices objects that need ledger lines", - /* creats*/ "LedgerLineSpanner", - /* accepts */ "", - /* acks */ "ledgered-interface", // ledgered-interface? - /* reads */ "", - /* write */ "") + "Creates the spanner to draw ledger lines, and notices objects that need ledger lines", + /* creats*/ "LedgerLineSpanner", + /* accepts */ "", + /* acks */ "ledgered-interface", // ledgered-interface? + /* reads */ "", + /* write */ "") diff --git a/lily/ledger-line-spanner.cc b/lily/ledger-line-spanner.cc index 903a97bb1f..186f976fd7 100644 --- a/lily/ledger-line-spanner.cc +++ b/lily/ledger-line-spanner.cc @@ -1,28 +1,27 @@ -/* +/* ledger-line-spanner.cc -- implement Ledger_line_spanner - + source file of the GNU LilyPond music typesetter - + (c) 2004--2005 Han-Wen Nienhuys - */ #include #include #include "item.hh" -#include "note-head.hh" -#include "staff-symbol-referencer.hh" -#include "staff-symbol.hh" -#include "lookup.hh" -#include "spanner.hh" -#include "group-interface.hh" +#include "note-head.hh" +#include "staff-symbol-referencer.hh" +#include "staff-symbol.hh" +#include "lookup.hh" +#include "spanner.hh" +#include "group-interface.hh" #include "paper-column.hh" struct Ledger_line_spanner { - DECLARE_SCHEME_CALLBACK (print, (SCM )); - DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM )); + DECLARE_SCHEME_CALLBACK (print, (SCM)); + DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM)); static Stencil brew_ledger_lines (Grob *me, int pos, int interspaces, @@ -30,10 +29,9 @@ struct Ledger_line_spanner Interval x_extent, Real left_shorten); - static bool has_interface (Grob*); + static bool has_interface (Grob *); }; - Stencil Ledger_line_spanner::brew_ledger_lines (Grob *staff, int pos, @@ -50,68 +48,65 @@ Ledger_line_spanner::brew_ledger_lines (Grob *staff, if (line_count) { Real blotdiameter = ledgerlinethickness; - Interval y_extent = - Interval (-0.5*(ledgerlinethickness), - +0.5*(ledgerlinethickness)); - Stencil proto_ledger_line = - Lookup::round_filled_box (Box (x_extent, y_extent), blotdiameter); + Interval y_extent + = Interval (-0.5* (ledgerlinethickness), + +0.5* (ledgerlinethickness)); + Stencil proto_ledger_line + = Lookup::round_filled_box (Box (x_extent, y_extent), blotdiameter); x_extent[LEFT] += left_shorten; - Stencil proto_first_line = - Lookup::round_filled_box (Box (x_extent, y_extent), blotdiameter); + Stencil proto_first_line + = Lookup::round_filled_box (Box (x_extent, y_extent), blotdiameter); Direction dir = (Direction)sign (pos); Real offs = (Staff_symbol_referencer::on_staffline (staff, pos)) - ? 0.0 - : -dir * halfspace; - + ? 0.0 + : -dir * halfspace; offs += pos * halfspace; for (int i = 0; i < line_count; i++) - { - Stencil ledger_line ((i == 0) - ? proto_first_line - : proto_ledger_line - ); - ledger_line.translate_axis (-dir * halfspace * i * 2 + offs, Y_AXIS); - stencil.add_stencil (ledger_line); - } + { + Stencil ledger_line ((i == 0) + ? proto_first_line + : proto_ledger_line); + ledger_line.translate_axis (-dir * halfspace * i * 2 + offs, Y_AXIS); + stencil.add_stencil (ledger_line); + } } return stencil; } - -typedef std::map > Head_extents_map; -typedef std::map Column_map; +typedef std::map < int, Drul_array > Head_extents_map; +typedef std::map < int, Grob *> Column_map; MAKE_SCHEME_CALLBACK (Ledger_line_spanner, set_spacing_rods, 1); SCM Ledger_line_spanner::set_spacing_rods (SCM smob) { - Spanner *me = dynamic_cast (unsmob_grob (smob)); + Spanner *me = dynamic_cast (unsmob_grob (smob)); // find size of note heads. - Grob * staff = Staff_symbol_referencer::get_staff_symbol (me); + Grob *staff = Staff_symbol_referencer::get_staff_symbol (me); if (!staff) return SCM_EOL; Link_array heads (extract_grob_array (me, ly_symbol2scm ("note-heads"))); - + if (heads.is_empty ()) return SCM_EOL; - + Real min_length_fraction = robust_scm2double (me->get_property ("minimum-length-fraction"), 0.15); - + Head_extents_map head_extents; Column_map columns; - - int interspaces = Staff_symbol::line_count (staff)-1; - for (int i = heads.size (); i--; ) + + int interspaces = Staff_symbol::line_count (staff) - 1; + for (int i = heads.size (); i--;) { - Item *h = dynamic_cast (heads[i]); - + Item *h = dynamic_cast (heads[i]); + int pos = Staff_symbol_referencer::get_rounded_position (h); if (pos && abs (pos) > interspaces) @@ -123,47 +118,47 @@ Ledger_line_spanner::set_spacing_rods (SCM smob) Direction vdir = Direction (sign (pos)); if (!vdir) continue; - - Interval prev_extent; + + Interval prev_extent; Head_extents_map::iterator j = head_extents.find (rank); if (j != head_extents.end ()) prev_extent = (*j).second[vdir]; else columns[rank] = column; - + prev_extent.unite (head_extent); head_extents[rank][vdir] = prev_extent; } } - for (Column_map::const_iterator c (columns.begin()); c != columns.end(); c++) + for (Column_map::const_iterator c (columns.begin ()); c != columns.end (); c++) { Grob *column = (*c).second; int rank = (*c).first; int next_rank = rank + 2; - + if (head_extents.find (next_rank) != head_extents.end ()) { - Drul_array extents_left = head_extents[rank]; - Drul_array extents_right = head_extents[next_rank]; + Drul_array extents_left = head_extents[rank]; + Drul_array extents_right = head_extents[next_rank]; Direction d = DOWN; do { if (!extents_right[d].is_empty () && !extents_right[d].is_empty ()) { - Real l1 = extents_right[d].length() * min_length_fraction; - Real l2 = extents_left[d].length() * min_length_fraction; + Real l1 = extents_right[d].length () * min_length_fraction; + Real l2 = extents_left[d].length () * min_length_fraction; Rod rod; - rod.distance_ = l1 + l2 + (l1+ l2)/2.0 + rod.distance_ = l1 + l2 + (l1+ l2) / 2.0 + extents_left[d][RIGHT] - extents_right[d][LEFT]; - - rod.item_drul_[LEFT] = dynamic_cast (column); - rod.item_drul_[RIGHT] = dynamic_cast (columns[next_rank]); + + rod.item_drul_[LEFT] = dynamic_cast (column); + rod.item_drul_[RIGHT] = dynamic_cast (columns[next_rank]); rod.add_to_cols (); } } @@ -174,66 +169,64 @@ Ledger_line_spanner::set_spacing_rods (SCM smob) return SCM_UNSPECIFIED; } - struct Ledger_request { Interval ledger_extent_; Interval head_extent_; int position_; bool excentric_; - Ledger_request () { + Ledger_request () + { ledger_extent_.set_empty (); head_extent_.set_empty (); position_ = 0; } }; -typedef std::map > Ledger_requests; - +typedef std::map < int, Drul_array > Ledger_requests; /* TODO: ledger share a lot of info. Lots of room to optimize away common use of objects/variables. - */ +*/ MAKE_SCHEME_CALLBACK (Ledger_line_spanner, print, 1); SCM Ledger_line_spanner::print (SCM smob) { - Spanner *me = dynamic_cast (unsmob_grob (smob)); + Spanner *me = dynamic_cast (unsmob_grob (smob)); Link_array heads (extract_grob_array (me, ly_symbol2scm ("note-heads"))); if (heads.is_empty ()) return SCM_EOL; - + // find size of note heads. - Grob * staff = Staff_symbol_referencer::get_staff_symbol (me); + Grob *staff = Staff_symbol_referencer::get_staff_symbol (me); if (!staff) return SCM_EOL; - - + Real length_fraction = robust_scm2double (me->get_property ("length-fraction"), 0.25); Stencil ledgers; Stencil default_ledger; - Grob * common[NO_AXES]; - - for (int i = X_AXIS; i < NO_AXES; i++) + Grob *common[NO_AXES]; + + for (int i = X_AXIS; i < NO_AXES; i++) { Axis a = Axis (i); common[a] = common_refpoint_of_array (heads, me, a); - for (int i = heads.size (); i--; ) - if (Grob * g = unsmob_grob (me->get_property ("accidental-grob"))) + for (int i = heads.size (); i--;) + if (Grob *g = unsmob_grob (me->get_property ("accidental-grob"))) common[a] = common[a]->common_refpoint (g, a); } - int interspaces = Staff_symbol::line_count (staff)-1; + int interspaces = Staff_symbol::line_count (staff) - 1; Ledger_requests reqs; - for (int i = heads.size (); i--; ) + for (int i = heads.size (); i--;) { - Item *h = dynamic_cast (heads[i]); - + Item *h = dynamic_cast (heads[i]); + int pos = Staff_symbol_referencer::get_rounded_position (h); if (pos && abs (pos) > interspaces) @@ -244,11 +237,11 @@ Ledger_line_spanner::print (SCM smob) Direction vdir = Direction (sign (pos)); int rank = Paper_column::get_rank (h->get_column ()); - + reqs[rank][vdir].ledger_extent_.unite (ledger_extent); reqs[rank][vdir].head_extent_.unite (head_extent); - reqs[rank][vdir].position_ = - vdir * ((vdir* reqs[rank][vdir].position_) >? (vdir *pos)); + reqs[rank][vdir].position_ + = vdir * ((vdir* reqs[rank][vdir].position_) >? (vdir *pos)); } } @@ -262,16 +255,16 @@ Ledger_line_spanner::print (SCM smob) { continue; } - + Direction d = DOWN; do { if (abs (last->second[d].position_) > interspaces && abs (i->second[d].position_) > interspaces) { - Real center = - (last->second[d].head_extent_[RIGHT] - + i->second[d].head_extent_[LEFT] )/2; + Real center + = (last->second[d].head_extent_[RIGHT] + + i->second[d].head_extent_[LEFT]) / 2; Direction which = LEFT; do @@ -279,28 +272,28 @@ Ledger_line_spanner::print (SCM smob) Ledger_request &lr = ((which == LEFT) ? *last : *i).second[d]; // due tilt of quarter note-heads - bool both = - (abs (last->second[d].position_) > interspaces + 1 - && abs (i->second[d].position_) > interspaces + 1); + bool both + = (abs (last->second[d].position_) > interspaces + 1 + && abs (i->second[d].position_) > interspaces + 1); - Real limit = (center + (both? which * gap/2 : 0)); + Real limit = (center + (both? which * gap / 2 : 0)); lr.ledger_extent_.elem_ref (-which) - = which * (which * lr.ledger_extent_[-which] >? which * limit); + = which * (which * lr.ledger_extent_[-which] >? which * limit); } - while (flip (&which) != LEFT); + while (flip (&which) != LEFT); } } - while (flip (&d) != DOWN); + while (flip (&d) != DOWN); } // create ledgers for note heads - Real ledgerlinethickness = - Staff_symbol::get_ledger_line_thickness (staff); - Real halfspace = Staff_symbol::staff_space (staff)/2; - for (int i = heads.size (); i--; ) + Real ledgerlinethickness + = Staff_symbol::get_ledger_line_thickness (staff); + Real halfspace = Staff_symbol::staff_space (staff) / 2; + for (int i = heads.size (); i--;) { - Item *h = dynamic_cast (heads[i]); - + Item *h = dynamic_cast (heads[i]); + int pos = Staff_symbol_referencer::get_rounded_position (h); if (abs (pos) > interspaces + 1) { @@ -308,25 +301,25 @@ Ledger_line_spanner::print (SCM smob) Interval ledger_size = head_size; ledger_size.widen (ledger_size.length ()* length_fraction); - Interval max_size = reqs[Paper_column::get_rank (h->get_column ())][Direction (sign(pos))].ledger_extent_; + Interval max_size = reqs[Paper_column::get_rank (h->get_column ())][Direction (sign (pos))].ledger_extent_; ledger_size.intersect (max_size); Real left_shorten = 0.0; - if (Grob * g = unsmob_grob (h->get_property ("accidental-grob"))) + if (Grob *g = unsmob_grob (h->get_property ("accidental-grob"))) { Interval accidental_size = g->extent (common[X_AXIS], X_AXIS); - Real d = - linear_combination (Drul_array (accidental_size[RIGHT], - head_size[LEFT]), - 0.0); + Real d + = linear_combination (Drul_array (accidental_size[RIGHT], + head_size[LEFT]), + 0.0); - left_shorten = (-ledger_size[LEFT] + d) >? 0 ; + left_shorten = (-ledger_size[LEFT] + d) >? 0; /* TODO: shorten 2 ledger lines for the case natural + downstem. */ - + } ledgers.add_stencil (brew_ledger_lines (staff, pos, interspaces, @@ -339,7 +332,7 @@ Ledger_line_spanner::print (SCM smob) ledgers.translate_axis (-me->relative_coordinate (common[X_AXIS], X_AXIS), X_AXIS); - + return ledgers.smobbed_copy (); } @@ -348,9 +341,9 @@ ADD_INTERFACE (Ledger_line_spanner, "This spanner draws the ledger lines of a staff, for note heads that stick out. ", "note-heads thickness minimum-length-fraction length-fraction gap"); - -struct Ledgered_interface { - static bool has_interface (Grob*); +struct Ledgered_interface +{ + static bool has_interface (Grob *); }; ADD_INTERFACE (Ledgered_interface, diff --git a/lily/ligature-bracket-engraver.cc b/lily/ligature-bracket-engraver.cc index 1cd4591224..eec8ff0cfa 100644 --- a/lily/ligature-bracket-engraver.cc +++ b/lily/ligature-bracket-engraver.cc @@ -1,11 +1,10 @@ -/* +/* ligature-bracket-engraver.cc -- implement Ligature_bracket_engraver - + source file of the GNU LilyPond music typesetter - + (c) 2002--2005 Juergen Reuter - - */ +*/ #include "ligature-engraver.hh" #include "note-column.hh" @@ -27,7 +26,6 @@ public: TRANSLATOR_DECLARATIONS (Ligature_bracket_engraver); }; - Ligature_bracket_engraver::Ligature_bracket_engraver () { } @@ -38,7 +36,6 @@ Ligature_bracket_engraver::create_ligature_spanner () return make_spanner ("LigatureBracket", SCM_EOL); } - void Ligature_bracket_engraver::acknowledge_grob (Grob_info info) { @@ -47,16 +44,16 @@ Ligature_bracket_engraver::acknowledge_grob (Grob_info info) if (Note_column::has_interface (info.grob_)) { Tuplet_bracket::add_column (current_ligature (), - dynamic_cast (info.grob_)); + dynamic_cast (info.grob_)); } else Ligature_engraver::acknowledge_grob (info); } } ADD_TRANSLATOR (Ligature_bracket_engraver, -/* descr */ "Handles Ligature_events by engraving Ligature brackets.", -/* creats*/ "TupletBracket", -/* accepts */ "ligature-event", -/* acks */ "rest-interface note-column-interface", -/* reads */ "", -/* write */ ""); + /* descr */ "Handles Ligature_events by engraving Ligature brackets.", + /* creats*/ "TupletBracket", + /* accepts */ "ligature-event", + /* acks */ "rest-interface note-column-interface", + /* reads */ "", + /* write */ ""); diff --git a/lily/ligature-engraver.cc b/lily/ligature-engraver.cc index 29d177d6a5..666c01cf11 100644 --- a/lily/ligature-engraver.cc +++ b/lily/ligature-engraver.cc @@ -1,11 +1,10 @@ -/* +/* ligature-engraver.cc -- implement Ligature_engraver - + source file of the GNU LilyPond music typesetter - + (c) 2002--2005 Juergen Reuter - - */ +*/ #include "ligature-engraver.hh" @@ -188,8 +187,8 @@ Ligature_engraver::process_music () prev_start_req_ = reqs_drul_[START]; ligature_ = create_ligature_spanner (); - brew_ligature_primitive_proc = - ligature_->get_property ("ligature-primitive-callback"); + brew_ligature_primitive_proc + = ligature_->get_property ("ligature-primitive-callback"); if (brew_ligature_primitive_proc == SCM_EOL) { warning ("Ligature_engraver: ligature-primitive-callback undefined"); @@ -274,7 +273,7 @@ Ligature_engraver::acknowledge_grob (Grob_info info) { primitives_.push (info); info.grob_->set_property ("print-function", - brew_ligature_primitive_proc); + brew_ligature_primitive_proc); } if (Rest::has_interface (info.grob_)) { @@ -287,9 +286,9 @@ Ligature_engraver::acknowledge_grob (Grob_info info) } ADD_TRANSLATOR (Ligature_engraver, -/* descr */ "Abstract class; a concrete subclass handles Ligature_events by engraving Ligatures in a concrete style.", -/* creats */ "", -/* accepts */ "ligature-event", -/* acks */ "note-head-interface rest-interface", -/* reads */ "", -/* write */ ""); + /* descr */ "Abstract class; a concrete subclass handles Ligature_events by engraving Ligatures in a concrete style.", + /* creats */ "", + /* accepts */ "ligature-event", + /* acks */ "note-head-interface rest-interface", + /* reads */ "", + /* write */ ""); diff --git a/lily/lily-guile.cc b/lily/lily-guile.cc index 9cb3f082c4..0547aef254 100644 --- a/lily/lily-guile.cc +++ b/lily/lily-guile.cc @@ -4,10 +4,9 @@ source file of the GNU LilyPond music typesetter (c) 1998--2005 Jan Nieuwenhuizen - Han-Wen Nienhuys + Han-Wen Nienhuys */ - #include #include #include /* strdup, strchr */ @@ -52,13 +51,13 @@ ly_last (SCM list) SCM ly_write2scm (SCM s) { - SCM port = scm_mkstrport (SCM_INUM0, + SCM port = scm_mkstrport (SCM_INUM0, scm_make_string (SCM_INUM0, SCM_UNDEFINED), SCM_OPN | SCM_WRTNG, "ly_write2string"); // SCM write = scm_eval_3 (ly_symbol2scm ("write"), s, SCM_EOL); SCM write = scm_primitive_eval (ly_symbol2scm ("write")); - + // scm_apply (write, port, SCM_EOL); scm_call_2 (write, s, port); return scm_strport_to_string (port); @@ -75,7 +74,7 @@ ly_symbol2string (SCM s) { /* Ugh. this is not very efficient. - */ + */ SCM str = scm_symbol_to_string (s); return ly_scm2string (str); } @@ -102,32 +101,30 @@ gulp_file_to_string (String fn, bool must_exist) int n; char *str = gulp_file (s, &n); - String result ((Byte*) str, n); + String result ((Byte *) str, n); delete[] str; - + if (be_verbose_global) progress_indication ("]"); return result; } - - extern "C" { // maybe gdb 5.0 becomes quicker if it doesn't do fancy C++ typing? -void -ly_display_scm (SCM s) -{ - scm_display (s, scm_current_output_port ()); - scm_newline (scm_current_output_port ()); -} + void + ly_display_scm (SCM s) + { + scm_display (s, scm_current_output_port ()); + scm_newline (scm_current_output_port ()); + } }; String ly_scm2string (SCM str) { assert (scm_is_string (str)); - return String ((Byte*)scm_i_string_chars (str), + return String ((Byte *)scm_i_string_chars (str), (int) scm_i_string_length (str)); } @@ -191,13 +188,13 @@ extern "C" { void initialize_kpathsea (); } #endif - + void ly_init_ly_module (void *) { - for (int i = scm_init_funcs_->size () ; i--;) + for (int i = scm_init_funcs_->size (); i--;) (scm_init_funcs_->elem (i)) (); - + if (be_verbose_global) progress_indication ("\n"); @@ -207,7 +204,7 @@ ly_init_ly_module (void *) initialize_kpathsea (); } #endif - + scm_primitive_load_path (scm_makfrom0str ("lily.scm")); } @@ -232,7 +229,7 @@ is_direction (SCM s) if (scm_is_number (s)) { int i = scm_to_int (s); - return i>= -1 && i <= 1; + return i>= -1 && i <= 1; } return false; } @@ -286,7 +283,7 @@ appendable_list () { SCM s = scm_cons (SCM_EOL, SCM_EOL); scm_set_car_x (s, s); - + return s; } @@ -294,8 +291,8 @@ void appendable_list_append (SCM l, SCM elt) { SCM newcons = scm_cons (elt, SCM_EOL); - - scm_set_cdr_x (scm_car (l), newcons); + + scm_set_cdr_x (scm_car (l), newcons); scm_set_car_x (l, newcons); } @@ -321,10 +318,10 @@ ly_deep_copy (SCM src) { int len = scm_c_vector_length (src); SCM nv = scm_c_make_vector (len, SCM_UNDEFINED); - for (int i = 0 ;i < len ; i++) + for (int i = 0;i < len; i++) { SCM si = scm_int2num (i); - scm_vector_set_x (nv, si, ly_deep_copy (scm_vector_ref (src, si))); + scm_vector_set_x (nv, si, ly_deep_copy (scm_vector_ref (src, si))); } } return src; @@ -365,19 +362,16 @@ ly_chain_assoc (SCM key, SCM achain) Returns first match found, i.e. alist = ((1 . 10) - ((1 . 2) . 11) - ((2 . 1) . 12) - ((3 . 0) . 13) - ((4 . 1) . 14) ) - -I would like (ly_assoc_cdr 1) to return 12 - because it's the first -element with the cdr of the key = 1. In other words (alloc_cdr key) -corresponds to call - -(alloc (anything . key)) - + ((1 . 2) . 11) + ((2 . 1) . 12) + ((3 . 0) . 13) + ((4 . 1) . 14) ) + I would like (ly_assoc_cdr 1) to return 12 - because it's the first + element with the cdr of the key = 1. In other words (alloc_cdr key) + corresponds to call + (alloc (anything . key)) */ SCM ly_assoc_cdr (SCM key, SCM alist) @@ -402,11 +396,11 @@ parse_symbol_list (char const *lst) char *orig = s; SCM create_list = SCM_EOL; - char * e = s + strlen (s) - 1; + char *e = s + strlen (s) - 1; while (e >= s && isspace (*e)) *e-- = 0; - for (char * p = s; *p; p++) + for (char *p = s; *p; p++) if (*p == '\n') *p = ' '; @@ -453,11 +447,11 @@ print_scm_val (SCM val) realval = realval.left_string (100) + "\n :\n :\n" + realval.right_string (100); - return realval; + return realval; } bool -type_check_assignment (SCM sym, SCM val, SCM type_symbol) +type_check_assignment (SCM sym, SCM val, SCM type_symbol) { bool ok = true; @@ -466,7 +460,7 @@ type_check_assignment (SCM sym, SCM val, SCM type_symbol) TODO: should remove #f from allowed vals? - */ + */ if (val == SCM_EOL || val == SCM_BOOL_F) return ok; @@ -480,26 +474,26 @@ type_check_assignment (SCM sym, SCM val, SCM type_symbol) TODO: deprecate the use of \override and \revert for autoBeamSettings? - or use a symbol autoBeamSettingS? - */ - return true; + or use a symbol autoBeamSettingS? + */ + return true; #endif - + SCM type = scm_object_property (sym, type_symbol); if (type != SCM_EOL && !ly_c_procedure_p (type)) - { - warning (_f ("Can't find property type-check for `%s' (%s).", - ly_symbol2string (sym).to_str0 (), - ly_symbol2string (type_symbol).to_str0 ()) - + " " + _ ("Perhaps you made a typing error?")); - - /* Be strict when being anal :) */ - if (do_internal_type_checking_global) - abort (); - - warning (_ ("Doing assignment anyway.")); - } + { + warning (_f ("Can't find property type-check for `%s' (%s).", + ly_symbol2string (sym).to_str0 (), + ly_symbol2string (type_symbol).to_str0 ()) + + " " + _ ("Perhaps you made a typing error?")); + + /* Be strict when being anal :) */ + if (do_internal_type_checking_global) + abort (); + + warning (_ ("Doing assignment anyway.")); + } else { if (val != SCM_EOL @@ -511,24 +505,21 @@ type_check_assignment (SCM sym, SCM val, SCM type_symbol) SCM typefunc = ly_lily_module_constant ("type-name"); SCM type_name = scm_call_1 (typefunc, type); - scm_puts (_f ("Type check for `%s' failed; value `%s' must be of type `%s'", ly_symbol2string (sym).to_str0 (), print_scm_val (val), ly_scm2string (type_name).to_str0 ()).to_str0 (), errport); - scm_puts ("\n", errport); + scm_puts ("\n", errport); } } return ok; } - /* some SCM abbrevs - zijn deze nou handig? - zijn ze er al in scheme, maar heten ze anders? */ - +zijn deze nou handig? +zijn ze er al in scheme, maar heten ze anders? */ /* Remove doubles from (sorted) list */ SCM @@ -544,12 +535,11 @@ ly_unique (SCM list) return scm_reverse_x (unique, SCM_EOL); } - static int scm_default_compare (void const *a, void const *b) { - SCM pa = *(SCM*) a; - SCM pb = *(SCM*) b; + SCM pa = *(SCM *) a; + SCM pb = *(SCM *) b; if (pa == pb) return 0; return pa < pb ? -1 : 1; @@ -579,10 +569,9 @@ ly_list_qsort_uniq_x (SCM lst) *tail = SCM_EOL; delete[] arr; - return lst; + return lst; } - /* tail add */ SCM ly_snoc (SCM s, SCM list) @@ -605,22 +594,21 @@ ly_split_list (SCM s, SCM list) break; before = scm_cons (i, before); } - return scm_cons ( scm_reverse_x (before, SCM_EOL), after); - -} + return scm_cons (scm_reverse_x (before, SCM_EOL), after); +} void taint (SCM *) { /* nop. - */ + */ } /* display stuff without using stack - */ +*/ SCM display_list (SCM s) { @@ -630,7 +618,7 @@ display_list (SCM s) for (; scm_is_pair (s); s = scm_cdr (s)) { scm_display (scm_car (s), p); - scm_puts (" ", p); + scm_puts (" ", p); } scm_puts (")", p); return SCM_UNSPECIFIED; @@ -643,13 +631,13 @@ int_list_to_slice (SCM l) s.set_empty (); for (; scm_is_pair (l); l = scm_cdr (l)) if (scm_is_number (scm_car (l))) - s.add_point (scm_to_int (scm_car (l))); + s.add_point (scm_to_int (scm_car (l))); return s; } /* Return I-th element, or last elt L. If I < 0, then we take the first element. - + PRE: length (L) > 0 */ SCM robust_list_ref (int i, SCM l) @@ -708,17 +696,16 @@ alist_to_hashq (SCM alist) int i = scm_ilength (alist); if (i < 0) return scm_c_make_hash_table (0); - + SCM tab = scm_c_make_hash_table (i); for (SCM s = alist; scm_is_pair (s); s = scm_cdr (s)) { SCM pt = scm_cdar (s); scm_hashq_set_x (tab, scm_caar (s), pt); } - return tab; + return tab; } - bool alist_equal_p (SCM a, SCM b) { @@ -730,15 +717,13 @@ alist_equal_p (SCM a, SCM b) SCM l = scm_assoc (key, b); if (l == SCM_BOOL_F - || !ly_c_equal_p ( scm_cdr (l), val)) + || !ly_c_equal_p (scm_cdr (l), val)) return false; } return true; } - - SCM ly_alist_vals (SCM alist) { @@ -757,5 +742,3 @@ ly_hash2alist (SCM tab) return scm_call_1 (func, tab); } - - diff --git a/lily/lily-lexer.cc b/lily/lily-lexer.cc index bc748f1f2d..1840e54f17 100644 --- a/lily/lily-lexer.cc +++ b/lily/lily-lexer.cc @@ -20,7 +20,8 @@ #include "main.hh" #include "moment.hh" -static Keyword_ent the_key_tab[] = { +static Keyword_ent the_key_tab[] += { {"accepts", ACCEPTS}, {"addquote", ADDQUOTE}, {"addlyrics", ADDLYRICS}, @@ -82,19 +83,18 @@ static Keyword_ent the_key_tab[] = { {0, 0} }; - Lily_lexer::Lily_lexer (Sources *sources) { keytable_ = new Keyword_table (the_key_tab); chordmodifier_tab_ = SCM_EOL; - pitchname_tab_stack_ = SCM_EOL; + pitchname_tab_stack_ = SCM_EOL; sources_ = sources; scopes_ = SCM_EOL; - error_level_ = 0; + error_level_ = 0; is_main_input_ = false; smobify_self (); - + add_scope (ly_make_anonymous_module (false)); push_note_state (scm_c_make_hash_table (0)); chordmodifier_tab_ = scm_make_vector (scm_int2num (1), SCM_EOL); @@ -107,14 +107,14 @@ Lily_lexer::Lily_lexer (Lily_lexer const &src) chordmodifier_tab_ = src.chordmodifier_tab_; pitchname_tab_stack_ = src.pitchname_tab_stack_; sources_ = src.sources_; - - error_level_ = src.error_level_; + + error_level_ = src.error_level_; is_main_input_ = src.is_main_input_; scopes_ = SCM_EOL; - + smobify_self (); - + SCM scopes = SCM_EOL; SCM *tail = &scopes; for (SCM s = src.scopes_; scm_is_pair (s); s = scm_cdr (s)) @@ -124,8 +124,8 @@ Lily_lexer::Lily_lexer (Lily_lexer const &src) *tail = scm_cons (newmod, SCM_EOL); tail = SCM_CDRLOC (*tail); } - - scopes_ = scopes; + + scopes_ = scopes; push_note_state (scm_c_make_hash_table (0)); } @@ -156,7 +156,6 @@ Lily_lexer::remove_scope () return sc; } - int Lily_lexer::lookup_keyword (String s) { @@ -187,7 +186,7 @@ Lily_lexer::start_main_input () { // yy_flex_debug = 1; new_input (main_input_name_, sources_); - + /* Do not allow \include in --safe-mode */ allow_includes_b_ = allow_includes_b_ && !be_safe_global; @@ -201,14 +200,14 @@ Lily_lexer::set_identifier (SCM name, SCM s) { SCM sym = name; if (scm_is_string (name)) - sym = scm_string_to_symbol (name); - + sym = scm_string_to_symbol (name); + if (scm_is_symbol (sym)) { if (lookup_keyword (ly_symbol2string (sym)) >= 0) { - String symstr = ly_symbol2string (sym); - warning (_f ("Identifier name is a keyword: `%s'", symstr.to_str0())); + String symstr = ly_symbol2string (sym); + warning (_f ("Identifier name is a keyword: `%s'", symstr.to_str0 ())); } SCM mod = scm_car (scopes_); @@ -264,9 +263,9 @@ Lily_lexer::prepare_for_next_token () } /** - Since we don't create the buffer state from the bytes directly, we - don't know about the location of the lexer. Add this as a - YY_USER_ACTION */ + Since we don't create the buffer state from the bytes directly, we + don't know about the location of the lexer. Add this as a + YY_USER_ACTION */ void Lily_lexer::add_lexed_char (int count) { @@ -276,7 +275,6 @@ Lily_lexer::add_lexed_char (int count) char_count_stack_.top () += count; } - #include "ly-smobs.icc" IMPLEMENT_SMOBS (Lily_lexer); @@ -286,7 +284,7 @@ IMPLEMENT_DEFAULT_EQUAL_P (Lily_lexer); SCM Lily_lexer::mark_smob (SCM s) { - Lily_lexer *lexer = (Lily_lexer*) SCM_CELL_WORD_1 (s); + Lily_lexer *lexer = (Lily_lexer *) SCM_CELL_WORD_1 (s); scm_gc_mark (lexer->chordmodifier_tab_); scm_gc_mark (lexer->pitchname_tab_stack_); diff --git a/lily/lily-parser-scheme.cc b/lily/lily-parser-scheme.cc index 69c90478b1..4a46421089 100644 --- a/lily/lily-parser-scheme.cc +++ b/lily/lily-parser-scheme.cc @@ -4,7 +4,6 @@ source file of the GNU LilyPond music typesetter (c) 2005 Han-Wen Nienhuys - */ #include "file-name.hh" @@ -13,7 +12,7 @@ #include "lily-parser.hh" #include "warn.hh" #include "source.hh" -#include "lily-lexer.hh" +#include "lily-lexer.hh" #include "score.hh" #include "lilypond-key.hh" #include "ly-module.hh" @@ -48,14 +47,14 @@ LY_DEFINE (ly_parse_file, "ly:parse-file", File_name out_file_name (file_name); global_path.append (out_file_name.dir_); - + out_file_name.ext_ = ""; out_file_name.root_ = ""; out_file_name.dir_ = ""; if (!output_name_global.is_empty ()) out_file_name = File_name (output_name_global); - + String init; if (!init_name_global.is_empty ()) init = init_name_global; @@ -82,7 +81,7 @@ LY_DEFINE (ly_parse_file, "ly:parse-file", { Sources sources; sources.set_path (&global_path); - + progress_indication (_f ("Processing `%s'", file_name.to_str0 ())); progress_indication ("\n"); @@ -107,7 +106,7 @@ LY_DEFINE (ly_parse_string, "ly:parse-string", "Upon failure, throw @code{ly-file-failed} key.") { SCM_ASSERT_TYPE (scm_is_string (ly_code), ly_code, SCM_ARG1, __FUNCTION__, "string"); - + Sources sources; sources.set_path (&global_path); Lily_parser *parser = new Lily_parser (&sources); @@ -116,13 +115,13 @@ LY_DEFINE (ly_parse_string, "ly:parse-string", parser->parse_string (ly_scm2string (ly_code)); scm_gc_unprotect_object (parser->self_scm ()); parser = 0; - + return SCM_UNSPECIFIED; } LY_DEFINE (ly_clone_parser, "ly:clone-parser", - 1, 0, 0, (SCM parser_smob), - "Return a clone of PARSER_SMOB.") + 1, 0, 0, (SCM parser_smob), + "Return a clone of PARSER_SMOB.") { Lily_parser *parser = unsmob_my_lily_parser (parser_smob); Lily_parser *clone = new Lily_parser (*parser); @@ -137,7 +136,7 @@ LY_DEFINE (ly_parser_define, "ly:parser-define", { Lily_parser *parser = unsmob_my_lily_parser (parser_smob); SCM_ASSERT_TYPE (scm_is_symbol (symbol), symbol, SCM_ARG2, __FUNCTION__, "symbol"); - SCM_ASSERT_TYPE (parser, parser_smob, SCM_ARG2, __FUNCTION__, "parser"); + SCM_ASSERT_TYPE (parser, parser_smob, SCM_ARG2, __FUNCTION__, "parser"); parser->lexer_->set_identifier (scm_symbol_to_string (symbol), val); return SCM_UNSPECIFIED; @@ -151,7 +150,7 @@ LY_DEFINE (ly_parser_lookup, "ly:parser-lookup", Lily_parser *parser = unsmob_my_lily_parser (parser_smob); SCM_ASSERT_TYPE (scm_is_symbol (symbol), symbol, SCM_ARG2, __FUNCTION__, "symbol"); - SCM_ASSERT_TYPE (parser, parser_smob, SCM_ARG2, __FUNCTION__, "parser"); + SCM_ASSERT_TYPE (parser, parser_smob, SCM_ARG2, __FUNCTION__, "parser"); SCM val = parser->lexer_->lookup_identifier (ly_scm2string (scm_symbol_to_string (symbol))); if (val != SCM_UNDEFINED) @@ -169,9 +168,9 @@ LY_DEFINE (ly_parser_parse_string, "ly:parser-parse-string", SCM_ASSERT_TYPE (parser, parser_smob, SCM_ARG1, __FUNCTION__, "parser"); SCM_ASSERT_TYPE (scm_is_string (ly_code), ly_code, SCM_ARG2, __FUNCTION__, "string"); - + parser->parse_string (ly_scm2string (ly_code)); - + return SCM_UNSPECIFIED; } @@ -185,17 +184,17 @@ LY_DEFINE (ly_parser_print_score, "ly:parser-print-score", Lily_parser *parser = unsmob_my_lily_parser (parser_smob); Score *score = unsmob_score (score_smob); - Object_key * key = new Lilypond_general_key (0, score->user_key_, 0); - + Object_key *key = new Lilypond_general_key (0, score->user_key_, 0); + if (score->error_found_) return SCM_UNSPECIFIED; - + SCM_ASSERT_TYPE (parser, parser_smob, SCM_ARG1, __FUNCTION__, "parser"); SCM_ASSERT_TYPE (score, score_smob, SCM_ARG2, __FUNCTION__, "score"); SCM header = ly_c_module_p (score->header_) ? score->header_ : parser->lexer_->lookup_identifier ("$globalheader"); - + File_name outname (parser->output_basename_); int *c = &parser->book_count_; if (*c) @@ -211,7 +210,7 @@ LY_DEFINE (ly_parser_print_score, "ly:parser-print-score", if (score->defs_.is_empty ()) { Output_def *layout = get_layout (parser); - default_rendering (score->get_music(), layout->self_scm (), + default_rendering (score->get_music (), layout->self_scm (), get_paper (parser)->self_scm (), header, os, key->self_scm ()); scm_gc_unprotect_object (layout->self_scm ()); @@ -221,8 +220,6 @@ LY_DEFINE (ly_parser_print_score, "ly:parser-print-score", return SCM_UNSPECIFIED; } - - LY_DEFINE (ly_parser_set_note_names, "ly:parser-set-note-names", 2, 0, 0, (SCM parser, SCM names), "Replace current note names in @var{parser}. " @@ -230,7 +227,7 @@ LY_DEFINE (ly_parser_set_note_names, "ly:parser-set-note-names", "This only has effect if the current mode is notes.") { Lily_parser *p = unsmob_my_lily_parser (parser); - SCM_ASSERT_TYPE(p, parser, SCM_ARG1, __FUNCTION__, "Lilypond parser"); + SCM_ASSERT_TYPE (p, parser, SCM_ARG1, __FUNCTION__, "Lilypond parser"); if (p->lexer_->is_note_state ()) { @@ -248,13 +245,13 @@ LY_DEFINE (ly_parser_print_book, "ly:parser-print-book", Lily_parser *parser = unsmob_my_lily_parser (parser_smob); Book *book = unsmob_book (book_smob); Output_def *bp = unsmob_output_def (parser->lexer_->lookup_identifier ("$defaultpaper")); - + SCM_ASSERT_TYPE (parser, parser_smob, SCM_ARG1, __FUNCTION__, "Lilypond parser"); SCM_ASSERT_TYPE (book, book_smob, SCM_ARG2, __FUNCTION__, "Book"); - + /* ugh. changing argument.*/ book->paper_ = bp; - + File_name outname (parser->output_basename_); int *c = &parser->book_count_; if (*c) @@ -262,8 +259,8 @@ LY_DEFINE (ly_parser_print_book, "ly:parser-print-book", (*c)++; Output_def *layout = get_layout (parser); - Paper_book* pb = book->process (outname.to_string (), layout); - + Paper_book *pb = book->process (outname.to_string (), layout); + if (pb) { pb->output (outname.to_string ()); diff --git a/lily/lily-parser.cc b/lily/lily-parser.cc index 2a7a43e3c7..2ef34f43d5 100644 --- a/lily/lily-parser.cc +++ b/lily/lily-parser.cc @@ -4,7 +4,7 @@ source file of the GNU LilyPond music typesetter (c) 1997--2005 Han-Wen Nienhuys - Jan Nieuwenhuizen + Jan Nieuwenhuizen */ #include "lily-parser.hh" @@ -66,7 +66,7 @@ IMPLEMENT_DEFAULT_EQUAL_P (Lily_parser); SCM Lily_parser::mark_smob (SCM s) { - Lily_parser *parser = (Lily_parser*) SCM_CELL_WORD_1 (s); + Lily_parser *parser = (Lily_parser *) SCM_CELL_WORD_1 (s); return (parser->lexer_) ? parser->lexer_->self_scm () : SCM_EOL; } @@ -74,29 +74,28 @@ int Lily_parser::print_smob (SCM s, SCM port, scm_print_state*) { scm_puts ("#", port); return 1; } - /* Process one .ly file, or book. */ void Lily_parser::parse_file (String init, String name, String out_name) { if (output_backend_global == "tex") { - try_load_text_metrics (out_name); + try_load_text_metrics (out_name); } - + lexer_ = new Lily_lexer (sources_); scm_gc_unprotect_object (lexer_->self_scm ()); // TODO: use $parser lexer_->set_identifier (ly_symbol2scm ("parser"), self_scm ()); output_basename_ = out_name; - + lexer_->main_input_name_ = name; progress_indication (_ ("Parsing...")); @@ -128,30 +127,29 @@ Lily_parser::parse_file (String init, String name, String out_name) void Lily_parser::parse_string (String ly_code) { - Lily_lexer * parent = lexer_; + Lily_lexer *parent = lexer_; lexer_ = (parent == 0 ? new Lily_lexer (sources_) : new Lily_lexer (*parent)); scm_gc_unprotect_object (lexer_->self_scm ()); - SCM oldmod = scm_current_module (); scm_set_current_module (scm_car (lexer_->scopes_)); - + // TODO: use $parser lexer_->set_identifier (ly_symbol2scm ("parser"), self_scm ()); - + lexer_->main_input_name_ = ""; lexer_->is_main_input_ = true; set_yydebug (0); lexer_->new_input (lexer_->main_input_name_, ly_code, sources_); do_yyparse (); - + if (!define_spots_.is_empty ()) { - if (define_spots_.is_empty() - && !error_level_ ) + if (define_spots_.is_empty () + && !error_level_) programming_error ("define_spots_ don't match, but error_level_ not set."); } @@ -175,7 +173,7 @@ Lily_parser::parser_error (String s) } void -Lily_parser::parser_error (Input const& i, String s) +Lily_parser::parser_error (Input const &i, String s) { i.error (s); error_level_ = 1; @@ -183,8 +181,7 @@ Lily_parser::parser_error (Input const& i, String s) /****************************************************************/ - -Output_def* +Output_def * get_layout (Lily_parser *parser) { SCM id = parser->lexer_->lookup_identifier ("$defaultlayout"); @@ -195,8 +192,7 @@ get_layout (Lily_parser *parser) return layout; } - -Output_def* +Output_def * get_midi (Lily_parser *parser) { SCM id = parser->lexer_->lookup_identifier ("$defaultmidi"); @@ -206,14 +202,13 @@ get_midi (Lily_parser *parser) return layout; } - -Output_def* +Output_def * get_paper (Lily_parser *parser) { SCM id = parser->lexer_->lookup_identifier ("$defaultpaper"); Output_def *layout = unsmob_output_def (id); - layout = layout ? dynamic_cast (layout->clone ()) : new Output_def; + layout = layout ? dynamic_cast (layout->clone ()) : new Output_def; layout->set_variable (ly_symbol2scm ("is-paper"), SCM_BOOL_T); return layout; } diff --git a/lily/lily-version.cc b/lily/lily-version.cc index 98fbb27e38..2524e9bb5e 100644 --- a/lily/lily-version.cc +++ b/lily/lily-version.cc @@ -14,21 +14,21 @@ String version_string () { - String str = MAJOR_VERSION "." MINOR_VERSION "." PATCH_LEVEL; + String str = MAJOR_VERSION "." MINOR_VERSION "." PATCH_LEVEL; String mpl ("." MY_PATCH_LEVEL); if (mpl != ".") str += mpl; return str; } -String +String gnu_lilypond_string () { String str = "GNU LilyPond"; return str; } -String +String gnu_lilypond_version_string () { String str = gnu_lilypond_string () + " " + version_string (); diff --git a/lily/lilypond-key.cc b/lily/lilypond-key.cc index cfe6a06caf..af4a521880 100644 --- a/lily/lilypond-key.cc +++ b/lily/lilypond-key.cc @@ -4,7 +4,6 @@ source file of the GNU LilyPond music typesetter (c) 2004--2005 Han-Wen Nienhuys - */ #include "lilypond-key.hh" @@ -28,15 +27,15 @@ Lilypond_grob_key::derived_mark () const // todo: reverse order of comparison for efficiency reasons. int -Lilypond_grob_key::do_compare (Object_key const* key) const +Lilypond_grob_key::do_compare (Object_key const *key) const { - Lilypond_grob_key const * other = dynamic_cast (key); + Lilypond_grob_key const *other = dynamic_cast < Lilypond_grob_key const *> (key); int c; c = context_->compare (other->context_); if (c) return c; - + c = Moment::compare (creation_moment_, other->creation_moment_); if (c) return c; @@ -45,41 +44,37 @@ Lilypond_grob_key::do_compare (Object_key const* key) const if (c) return c; - c = sign (disambiguation_count_ - other->disambiguation_count_); + c = sign (disambiguation_count_ - other->disambiguation_count_); if (c) return c; - + return 0; } - int Lilypond_grob_key::get_type () const { return GROB_KEY; } - SCM Lilypond_grob_key::as_scheme () const { - return scm_list_4 (context_ ? context_->self_scm() : SCM_BOOL_F, - creation_moment_.smobbed_copy(), - scm_makfrom0str (grob_name_.to_str0()), - scm_from_int (disambiguation_count_)); + return scm_list_4 (context_ ? context_->self_scm () : SCM_BOOL_F, + creation_moment_.smobbed_copy (), + scm_makfrom0str (grob_name_.to_str0 ()), + scm_from_int (disambiguation_count_)); } - Object_key * -Lilypond_grob_key::from_scheme (SCM a) +Lilypond_grob_key::from_scheme (SCM a) { return new Lilypond_grob_key (unsmob_key (scm_car (a)), *unsmob_moment (scm_cadr (a)), - ly_scm2string (scm_caddr (a)), - scm_to_int (scm_list_ref (a, scm_from_int (3)))); + ly_scm2string (scm_caddr (a)), + scm_to_int (scm_list_ref (a, scm_from_int (3)))); } - /****************************************************************/ void @@ -102,12 +97,11 @@ Lilypond_context_key::Lilypond_context_key (Object_key const *parent, id_ = id; } - int Lilypond_context_key::do_compare (Object_key const *key) const { - Lilypond_context_key const * other - = dynamic_cast (key); + Lilypond_context_key const *other + = dynamic_cast < Lilypond_context_key const *> (key); int c; if (parent_context_ && other->parent_context_) @@ -117,11 +111,10 @@ Lilypond_context_key::do_compare (Object_key const *key) const return c; } else if (parent_context_) - return -1 ; + return -1; else if (other->parent_context_) return 1; - - + c = Moment::compare (start_moment_, other->start_moment_); if (c) return c; @@ -137,7 +130,7 @@ Lilypond_context_key::do_compare (Object_key const *key) const c = sign (disambiguation_count_ - other->disambiguation_count_); if (c) return c; - + return 0; } @@ -147,28 +140,26 @@ Lilypond_context_key::get_type () const return CONTEXT_KEY; } - SCM Lilypond_context_key::as_scheme () const { - return scm_list_5 (parent_context_ ? parent_context_->self_scm() : SCM_BOOL_F, - start_moment_.smobbed_copy(), - scm_makfrom0str (context_name_.to_str0()), - scm_makfrom0str (id_.to_str0()), - scm_from_int (disambiguation_count_)); + return scm_list_5 (parent_context_ ? parent_context_->self_scm () : SCM_BOOL_F, + start_moment_.smobbed_copy (), + scm_makfrom0str (context_name_.to_str0 ()), + scm_makfrom0str (id_.to_str0 ()), + scm_from_int (disambiguation_count_)); } Object_key * -Lilypond_context_key::from_scheme (SCM a) +Lilypond_context_key::from_scheme (SCM a) { return new Lilypond_context_key (unsmob_key (scm_car (a)), *unsmob_moment (scm_cadr (a)), - ly_scm2string (scm_list_ref (a, scm_from_int (2))), - ly_scm2string (scm_list_ref (a, scm_from_int (3))), - scm_to_int (scm_list_ref (a, scm_from_int (4)))); + ly_scm2string (scm_list_ref (a, scm_from_int (2))), + ly_scm2string (scm_list_ref (a, scm_from_int (3))), + scm_to_int (scm_list_ref (a, scm_from_int (4)))); } - /****************************************************************/ int @@ -184,26 +175,25 @@ Lilypond_general_key::derived_mark () const scm_gc_mark (parent_->self_scm ()); } -Lilypond_general_key::Lilypond_general_key (Object_key const*parent, +Lilypond_general_key::Lilypond_general_key (Object_key const *parent, String name, int count) { parent_ = parent; name_ = name; - disambiguation_count_ = count; + disambiguation_count_ = count; } - int -Lilypond_general_key::do_compare (Object_key const* key)const +Lilypond_general_key::do_compare (Object_key const *key)const { - Lilypond_general_key const* other - = dynamic_cast (key); + Lilypond_general_key const *other + = dynamic_cast < Lilypond_general_key const *> (key); if (parent_ && other->parent_) parent_->compare (other->parent_); else if (parent_) - return -1 ; + return -1; else if (other->parent_) return 1; @@ -215,21 +205,21 @@ Lilypond_general_key::do_compare (Object_key const* key)const if (c) return c; - return 0; + return 0; } SCM Lilypond_general_key::as_scheme () const { - return scm_list_3 (parent_ ? parent_->self_scm() : SCM_BOOL_F, - scm_makfrom0str (name_.to_str0()), - scm_from_int (disambiguation_count_)); + return scm_list_3 (parent_ ? parent_->self_scm () : SCM_BOOL_F, + scm_makfrom0str (name_.to_str0 ()), + scm_from_int (disambiguation_count_)); } Object_key * -Lilypond_general_key::from_scheme (SCM a) +Lilypond_general_key::from_scheme (SCM a) { return new Lilypond_general_key (unsmob_key (scm_car (a)), - ly_scm2string (scm_list_ref (a, scm_from_int (1))), - scm_to_int (scm_list_ref (a, scm_from_int (2)))); + ly_scm2string (scm_list_ref (a, scm_from_int (1))), + scm_to_int (scm_list_ref (a, scm_from_int (2)))); } diff --git a/lily/lilypond-version.cc b/lily/lilypond-version.cc index 95d4c083af..3996b42c5e 100644 --- a/lily/lilypond-version.cc +++ b/lily/lilypond-version.cc @@ -4,7 +4,6 @@ source file of the GNU LilyPond music typesetter (c) 1998--2005 Jan Nieuwenhuizen - */ #include "lilypond-input-version.hh" @@ -41,7 +40,7 @@ Lilypond_version::to_string () const Lilypond_version::operator int () const { - // ugh + // ugh return 100000 * major_ + 1000 * minor_ + patch_; } diff --git a/lily/line-interface.cc b/lily/line-interface.cc index 82843d912c..a5c17c5ce9 100644 --- a/lily/line-interface.cc +++ b/lily/line-interface.cc @@ -1,11 +1,10 @@ -/* -line-interface.cc -- implement Line_interface +/* + line-interface.cc -- implement Line_interface -source file of the GNU LilyPond music typesetter + source file of the GNU LilyPond music typesetter -(c) 2004--2005 Han-Wen Nienhuys - - */ + (c) 2004--2005 Han-Wen Nienhuys +*/ #include "line-interface.hh" @@ -15,26 +14,26 @@ source file of the GNU LilyPond music typesetter Stencil Line_interface::make_dashed_line (Real thick, Offset from, Offset to, - Real dash_period, Real dash_fraction) + Real dash_period, Real dash_fraction) { dash_fraction = (dash_fraction >? 0) get_property ("thickness"), 1); - + SCM type = me->get_property ("style"); SCM dash_fraction = me->get_property ("dash-fraction"); if (scm_is_number (dash_fraction) || type == ly_symbol2scm ("dotted-line")) { - + Real fraction = type == ly_symbol2scm ("dotted-line") ? 0.0 : robust_scm2double (dash_fraction, 0.4); - + fraction = (fraction >? 0) get_property ("dash-period"), 1.0); if (period < 0) return Stencil (); - + return make_dashed_line (thick, from, to, period, fraction); } else @@ -95,11 +94,11 @@ Line_interface::line (Grob *me, Offset from, Offset to) } ADD_INTERFACE (Line_interface, "line-interface", - "Generic line objects. Any object using lines supports this. Normally, " - "you get a straight line. If @code{dash-period} is defined, a dashed line is " - "produced; the length of the dashes is tuned with " - "@code{dash-fraction}. If the latter is set to 0, a dotted line is " - "produced. If @code{dash-fraction} is negative, the line is made " - "transparent.", - - "dash-period dash-fraction thickness style") + "Generic line objects. Any object using lines supports this. Normally, " + "you get a straight line. If @code{dash-period} is defined, a dashed line is " + "produced; the length of the dashes is tuned with " + "@code{dash-fraction}. If the latter is set to 0, a dotted line is " + "produced. If @code{dash-fraction} is negative, the line is made " + "transparent.", + + "dash-period dash-fraction thickness style") diff --git a/lily/line-spanner.cc b/lily/line-spanner.cc index fe5dd3e127..c7b2677f5d 100644 --- a/lily/line-spanner.cc +++ b/lily/line-spanner.cc @@ -21,9 +21,9 @@ #include "line-interface.hh" Stencil -zigzag_stencil (Grob *me, - Offset from, - Offset to) +zigzag_stencil (Grob *me, + Offset from, + Offset to) { Offset dz = to -from; Real dx = dz[X_AXIS]; @@ -31,36 +31,36 @@ zigzag_stencil (Grob *me, Real thick = Staff_symbol_referencer::line_thickness (me); thick *= robust_scm2double (me->get_property ("thickness"), 1.0); // todo: staff sym referencer? - + Real staff_space = Staff_symbol_referencer::staff_space (me); double w = robust_scm2double (me->get_property ("zigzag-width"), 1)*staff_space; - double l = robust_scm2double ( me->get_property ("zigzag-length"), 1)* w; - double h = l>w/2 ? sqrt (l*l-w*w/4) : 0; - + double l = robust_scm2double (me->get_property ("zigzag-length"), 1)* w; + double h = l > w / 2 ? sqrt (l*l - w*w / 4) : 0; + SCM list = scm_list_n (ly_symbol2scm ("zigzag-line"), - ly_bool2scm (true), - scm_make_real (w), - scm_make_real (h), - scm_make_real (thick), - scm_make_real (dx), - scm_make_real (dy), - SCM_UNDEFINED); + ly_bool2scm (true), + scm_make_real (w), + scm_make_real (h), + scm_make_real (thick), + scm_make_real (dx), + scm_make_real (dy), + SCM_UNDEFINED); Box b; b.add_point (Offset (0, 0)); b.add_point (dz); - b[X_AXIS].widen (thick/2); - b[Y_AXIS].widen (thick/2); - + b[X_AXIS].widen (thick / 2); + b[Y_AXIS].widen (thick / 2); + return Stencil (b, list); } MAKE_SCHEME_CALLBACK (Line_spanner, after_line_breaking, 1); SCM -Line_spanner::after_line_breaking (SCM g) +Line_spanner::after_line_breaking (SCM g) { - Grob *me = unsmob_grob (g); - Spanner*sp = dynamic_cast (me); + Grob *me = unsmob_grob (g); + Spanner *sp = dynamic_cast (me); /* We remove the line at the start of the line. For piano voice @@ -75,36 +75,35 @@ Line_spanner::after_line_breaking (SCM g) space left of a note at the start of a line is very small. --hwn. - - */ + + */ if (sp->get_bound (LEFT)->break_status_dir () && !sp->get_bound (RIGHT)->break_status_dir ()) { /* Can't do suicide, since this mucks up finding the trend. - */ + */ me->set_property ("print-function", SCM_EOL); - + } return SCM_EOL; } - Stencil -Line_spanner::line_stencil (Grob *me, - Offset from, - Offset to) +Line_spanner::line_stencil (Grob *me, + Offset from, + Offset to) { - Offset dz = to -from ; + Offset dz = to -from; SCM type = me->get_property ("style"); if (scm_is_symbol (type) && (type == ly_symbol2scm ("line") || type == ly_symbol2scm ("dashed-line") || type == ly_symbol2scm ("dotted-line") - || type == ly_symbol2scm ("zigzag") + || type == ly_symbol2scm ("zigzag") || (type == ly_symbol2scm ("trill") && dz[Y_AXIS] != 0))) { - return (type == ly_symbol2scm ("zigzag")) + return (type == ly_symbol2scm ("zigzag")) ? zigzag_stencil (me, from, to) : Line_interface::line (me, from, to); } @@ -113,12 +112,12 @@ Line_spanner::line_stencil (Grob *me, { SCM alist_chain = Font_interface::text_font_alist_chain (me); SCM style_alist = scm_list_n (scm_cons (ly_symbol2scm ("font-encoding"), - ly_symbol2scm ("fetaMusic")), + ly_symbol2scm ("fetaMusic")), SCM_UNDEFINED); - + Font_metric *fm = select_font (me->get_layout (), scm_cons (style_alist, - alist_chain)); + alist_chain)); Stencil m = fm->find_by_name ("scripts.trill_element"); Stencil mol; @@ -130,10 +129,10 @@ Line_spanner::line_stencil (Grob *me, /* FIXME: should center element on x/y - */ + */ mol.translate_axis (m.extent (X_AXIS).length () / 2, X_AXIS); - mol.translate_axis (-(mol.extent (Y_AXIS)[DOWN] - + mol.extent (Y_AXIS).length ())/2, Y_AXIS); + mol.translate_axis (- (mol.extent (Y_AXIS)[DOWN] + + mol.extent (Y_AXIS).length ()) / 2, Y_AXIS); mol.translate (from); return mol; @@ -144,11 +143,11 @@ Line_spanner::line_stencil (Grob *me, /* Find a common Y parent, which --if found-- should be the fixed-distance alignment. - */ +*/ Grob * line_spanner_common_parent (Grob *me) { - Grob * common = find_fixed_alignment_parent (me); + Grob *common = find_fixed_alignment_parent (me); if (!common) { common = Staff_symbol_referencer::get_staff_symbol (me); @@ -164,33 +163,28 @@ line_spanner_common_parent (Grob *me) /* Warning: this thing is a cross-staff object, so it should have empty Y-dimensions. - (If not, you risk that this is called from the staff-alignment + (If not, you risk that this is called from the staff-alignment routine, via stencil_extent. At this point, the staves aren't separated yet, so it doesn't work cross-staff. (huh? crossable staves have fixed distance? --hwn) - */ - - MAKE_SCHEME_CALLBACK (Line_spanner, print, 1); SCM -Line_spanner::print (SCM smob) +Line_spanner::print (SCM smob) { - Spanner *me = dynamic_cast (unsmob_grob (smob)); + Spanner *me = dynamic_cast (unsmob_grob (smob)); - Drul_array bound (me->get_bound (LEFT), + Drul_array bound (me->get_bound (LEFT), me->get_bound (RIGHT)); - - + Real gap = robust_scm2double (me->get_property ("gap"), 0.0); Offset ofxy (gap, 0); /*offset from start point to start of line*/ - Offset dxy ; + Offset dxy; Offset my_off; Offset his_off; - if (bound[RIGHT]->break_status_dir ()) { @@ -208,10 +202,10 @@ Line_spanner::print (SCM smob) heads are on different systems, there is no common parent anymore. We have to find the piano-staff object. */ - + int k = broken_spanner_index (me); - Spanner *parent_sp = dynamic_cast (me->original_); - Spanner *next_sp = parent_sp->broken_intos_ [k+1]; + Spanner *parent_sp = dynamic_cast (me->original_); + Spanner *next_sp = parent_sp->broken_intos_ [k + 1]; Item *next_bound = next_sp->get_bound (RIGHT); if (next_bound->break_status_dir ()) @@ -221,83 +215,79 @@ Line_spanner::print (SCM smob) me->suicide (); return SCM_EOL; } - + Grob *commonx = bound[LEFT]->common_refpoint (bound[RIGHT], X_AXIS); commonx = me->common_refpoint (commonx, X_AXIS); - + Grob *next_common_y = line_spanner_common_parent (next_bound); Grob *this_common_y = line_spanner_common_parent (bound[LEFT]); Grob *all_common_y = me->common_refpoint (this_common_y, Y_AXIS); - - Interval next_ext = next_bound->extent (next_common_y, Y_AXIS); - Interval this_ext = bound[LEFT]->extent (this_common_y, Y_AXIS); + + Interval next_ext = next_bound->extent (next_common_y, Y_AXIS); + Interval this_ext = bound[LEFT]->extent (this_common_y, Y_AXIS); Real yoff = this_common_y->relative_coordinate (all_common_y, Y_AXIS); - + Offset p1 (bound[LEFT]->extent (commonx, X_AXIS)[RIGHT], - this_ext.center () + yoff); + this_ext.center () + yoff); Offset p2 (bound[RIGHT]->extent (commonx, X_AXIS)[LEFT], next_ext.center () + yoff); - + Offset dz (p2 -p1); Real len = dz.length (); - Offset dir = dz *(1/ len); + Offset dir = dz * (1/ len); dz = (dz.length () - 2*gap) *dir; - - + Stencil l (line_stencil (me, Offset (0, 0), dz)); - l.translate (dir * gap + p1 + l.translate (dir * gap + p1 - Offset (me->relative_coordinate (commonx, X_AXIS), me->relative_coordinate (all_common_y, Y_AXIS))); - return l.smobbed_copy (); + return l.smobbed_copy (); } else { Grob *common[] = { me, me }; - for (int a = X_AXIS; a < NO_AXES; a++) + for (int a = X_AXIS; a < NO_AXES; a++) { common[a] = me->common_refpoint (bound[RIGHT], Axis (a)); common[a] = common[a]->common_refpoint (bound[LEFT], Axis (a)); } // distance from center to start of line - Real off = gap + ((bound[LEFT]->extent (bound[LEFT], X_AXIS).length ()*3)/4); + Real off = gap + ((bound[LEFT]->extent (bound[LEFT], X_AXIS).length ()*3) / 4); for (int a = X_AXIS; a < NO_AXES; a++) { Axis ax = (Axis)a; - dxy[ax] = - + bound[RIGHT]->extent (common[X_AXIS], ax).center () + dxy[ax] + = + bound[RIGHT]->extent (common[X_AXIS], ax).center () - bound[LEFT]->extent (common[X_AXIS], ax).center (); my_off[ax] = me->relative_coordinate (common[a], ax); his_off[ax] = bound[LEFT]->relative_coordinate (common[a], ax); - + } - ofxy = dxy * (off/dxy.length ()); + ofxy = dxy * (off / dxy.length ()); dxy -= 2*ofxy; - + Stencil line = line_stencil (me, Offset (0, 0), dxy); - line.translate_axis (bound[LEFT]->extent (bound[LEFT], X_AXIS).length ()/2, X_AXIS); + line.translate_axis (bound[LEFT]->extent (bound[LEFT], X_AXIS).length () / 2, X_AXIS); line.translate (ofxy - my_off + his_off); return line.smobbed_copy (); } } - ADD_INTERFACE (Line_spanner, "line-spanner-interface", "Generic line drawn between two objects, e.g. for use with glissandi.\n" "The property @code{style} can be @code{line}, " "@code{dashed-line}, @code{trill}, \n" "@code{dotted-line} or @code{zigzag}.\n" - "\n" - , + "\n", "gap zigzag-width zigzag-length thickness"); - diff --git a/lily/lookup.cc b/lily/lookup.cc index f012ca6930..df15d3d1ed 100644 --- a/lily/lookup.cc +++ b/lily/lookup.cc @@ -37,8 +37,6 @@ Lookup::dot (Offset p, Real radius) return Stencil (box, at); } - - /* * Horizontal Slope: * @@ -56,85 +54,80 @@ Lookup::dot (Offset p, Real radius) * <-----> * width */ -Stencil -Lookup::beam (Real slope, Real width, Real thick, Real blot) +Stencil +Lookup::beam (Real slope, Real width, Real thick, Real blot) { - Real height = slope * width; - Real min_y = (0 ? height) + thick/2; + Real height = slope * width; + Real min_y = (0 ? height) + thick / 2; Box b (Interval (0, width), Interval (min_y, max_y)); - + SCM at = scm_list_n (ly_symbol2scm ("beam"), - scm_make_real (width), - scm_make_real (slope), - scm_make_real (thick), - scm_make_real (blot), - SCM_UNDEFINED); + scm_make_real (width), + scm_make_real (slope), + scm_make_real (thick), + scm_make_real (blot), + SCM_UNDEFINED); return Stencil (b, at); } - Stencil Lookup::dashed_slur (Bezier b, Real thick, Real dash_period, Real dash_fraction) { SCM l = SCM_EOL; - - Real on = dash_fraction * dash_period; - Real off = dash_period - on; - - for (int i = 4; i -- ;) + + Real on = dash_fraction * dash_period; + Real off = dash_period - on; + + for (int i = 4; i--;) { l = scm_cons (ly_offset2scm (b.control_[i]), l); } SCM at = (scm_list_n (ly_symbol2scm ("dashed-slur"), - scm_make_real (thick), + scm_make_real (thick), scm_make_real (on), scm_make_real (off), ly_quote_scm (l), SCM_UNDEFINED)); Box box (Interval (0, 0), Interval (0, 0)); - return Stencil (box, at); + return Stencil (box, at); } - - Stencil Lookup::horizontal_line (Interval w, Real th) { SCM at = scm_list_n (ly_symbol2scm ("horizontal-line"), - scm_make_real (w[LEFT]), + scm_make_real (w[LEFT]), scm_make_real (w[RIGHT]), scm_make_real (th), SCM_UNDEFINED); - - Box box ; + Box box; box[X_AXIS] = w; - box[Y_AXIS] = Interval (-th/2, th/2); + box[Y_AXIS] = Interval (-th / 2, th / 2); return Stencil (box, at); } - Stencil -Lookup::blank (Box b) +Lookup::blank (Box b) { return Stencil (b, scm_makfrom0str ("")); } Stencil -Lookup::filled_box (Box b) +Lookup::filled_box (Box b) { - SCM at = (scm_list_n (ly_symbol2scm ("filledbox"), - scm_make_real (-b[X_AXIS][LEFT]), - scm_make_real (b[X_AXIS][RIGHT]), - scm_make_real (-b[Y_AXIS][DOWN]), - scm_make_real (b[Y_AXIS][UP]), - SCM_UNDEFINED)); + SCM at = (scm_list_n (ly_symbol2scm ("filledbox"), + scm_make_real (-b[X_AXIS][LEFT]), + scm_make_real (b[X_AXIS][RIGHT]), + scm_make_real (-b[Y_AXIS][DOWN]), + scm_make_real (b[Y_AXIS][UP]), + SCM_UNDEFINED)); return Stencil (b, at); } @@ -189,8 +182,6 @@ Lookup::round_filled_box (Box b, Real blotdiameter) return Stencil (b, at); } - - /* * Create Stencil that represents a filled polygon with round edges. * @@ -324,10 +315,9 @@ Lookup::round_filled_polygon (Array points, Real blotdiameter) return polygon; } - /* TODO: deprecate? - */ +*/ Stencil Lookup::frame (Box b, Real thick, Real blot) { @@ -335,14 +325,14 @@ Lookup::frame (Box b, Real thick, Real blot) Direction d = LEFT; for (Axis a = X_AXIS; a < NO_AXES; a = Axis (a + 1)) { - Axis o = Axis ((a+1)%NO_AXES); + Axis o = Axis ((a + 1)%NO_AXES); do { Box edges; edges[a] = b[a][d] + 0.5 * thick * Interval (-1, 1); - edges[o][DOWN] = b[o][DOWN] - thick/2; - edges[o][UP] = b[o][UP] + thick/2; - + edges[o][DOWN] = b[o][DOWN] - thick / 2; + edges[o][UP] = b[o][UP] + thick / 2; + m.add_stencil (round_filled_box (edges, blot)); } while (flip (&d) != LEFT); @@ -351,45 +341,44 @@ Lookup::frame (Box b, Real thick, Real blot) } /* - Make a smooth curve along the points - */ + Make a smooth curve along the points +*/ Stencil -Lookup::slur (Bezier curve, Real curvethick, Real linethick) +Lookup::slur (Bezier curve, Real curvethick, Real linethick) { Real alpha = (curve.control_[3] - curve.control_[0]).arg (); Bezier back = curve; - Offset perp = curvethick * complex_exp (Offset (0, alpha + M_PI/2)) * 0.5; + Offset perp = curvethick * complex_exp (Offset (0, alpha + M_PI / 2)) * 0.5; back.reverse (); back.control_[1] += perp; back.control_[2] += perp; curve.control_[1] -= perp; curve.control_[2] -= perp; - + SCM scontrols[8]; for (int i =4; i--;) scontrols[ i ] = ly_offset2scm (back.control_[i]); - for (int i =4 ; i--;) - scontrols[i+4] = ly_offset2scm (curve.control_[i]); + for (int i =4; i--;) + scontrols[i + 4] = ly_offset2scm (curve.control_[i]); /* - Need the weird order b.o. the way PS want its arguments - */ + Need the weird order b.o. the way PS want its arguments + */ int indices[]= {5, 6, 7, 4, 1, 2, 3, 0}; SCM list = SCM_EOL; for (int i = 8; i--;) { list = scm_cons (scontrols[indices[i]], list); } - - + SCM at = (scm_list_n (ly_symbol2scm ("bezier-sandwich"), - ly_quote_scm (list), - scm_make_real (linethick), - SCM_UNDEFINED)); + ly_quote_scm (list), + scm_make_real (linethick), + SCM_UNDEFINED)); Box b (curve.extent (X_AXIS), - curve.extent (Y_AXIS)); + curve.extent (Y_AXIS)); b[X_AXIS].unite (back.extent (X_AXIS)); b[Y_AXIS].unite (back.extent (Y_AXIS)); @@ -424,8 +413,8 @@ Stencil Lookup::bezier_sandwich (Bezier top_curve, Bezier bottom_curve) { /* - Need the weird order b.o. the way PS want its arguments - */ + Need the weird order b.o. the way PS want its arguments + */ SCM list = SCM_EOL; list = scm_cons (ly_offset2scm (bottom_curve.control_[3]), list); list = scm_cons (ly_offset2scm (bottom_curve.control_[0]), list); @@ -452,9 +441,9 @@ Lookup::bezier_sandwich (Bezier top_curve, Bezier bottom_curve) /* TODO: junk me. - */ +*/ Stencil -Lookup::accordion (SCM s, Real staff_space, Font_metric *fm) +Lookup::accordion (SCM s, Real staff_space, Font_metric *fm) { Stencil m; String sym = ly_scm2string (scm_car (s)); @@ -469,28 +458,28 @@ Lookup::accordion (SCM s, Real staff_space, Font_metric *fm) Stencil d = fm->find_by_name ("accordion.accDot"); d.translate_axis (staff_space * 2.5 PT, Y_AXIS); m.add_stencil (d); - reg = reg.right_string (reg.length ()-1); + reg = reg.right_string (reg.length () - 1); } int eflag = 0x00; if (reg.left_string (3) == "EEE") { eflag = 0x07; - reg = reg.right_string (reg.length ()-3); + reg = reg.right_string (reg.length () - 3); } else if (reg.left_string (2) == "EE") { eflag = 0x05; - reg = reg.right_string (reg.length ()-2); + reg = reg.right_string (reg.length () - 2); } else if (reg.left_string (2) == "Eh") { eflag = 0x04; - reg = reg.right_string (reg.length ()-2); + reg = reg.right_string (reg.length () - 2); } else if (reg.left_string (1) == "E") { eflag = 0x02; - reg = reg.right_string (reg.length ()-1); + reg = reg.right_string (reg.length () - 1); } if (eflag & 0x02) { @@ -520,14 +509,14 @@ Lookup::accordion (SCM s, Real staff_space, Font_metric *fm) m.add_stencil (d); d.translate_axis (-0.8 * staff_space PT, X_AXIS); m.add_stencil (d); - reg = reg.right_string (reg.length ()-2); + reg = reg.right_string (reg.length () - 2); } if (reg.left_string (1) == "S") { Stencil d = fm->find_by_name ("accordion.accDot"); d.translate_axis (0.5 * staff_space PT, Y_AXIS); m.add_stencil (d); - reg = reg.right_string (reg.length ()-1); + reg = reg.right_string (reg.length () - 1); } } else if (sym == "Freebase") @@ -539,7 +528,7 @@ Lookup::accordion (SCM s, Real staff_space, Font_metric *fm) Stencil d = fm->find_by_name ("accordion.accDot"); d.translate_axis (staff_space * 1.5 PT, Y_AXIS); m.add_stencil (d); - reg = reg.right_string (reg.length ()-1); + reg = reg.right_string (reg.length () - 1); } if (reg == "E") { @@ -557,7 +546,7 @@ Lookup::accordion (SCM s, Real staff_space, Font_metric *fm) Stencil d = fm->find_by_name ("accordion.accDot"); d.translate_axis (staff_space * 2.5 PT, Y_AXIS); m.add_stencil (d); - reg = reg.right_string (reg.length ()-1); + reg = reg.right_string (reg.length () - 1); } /* include 4' reed just for completeness. You don't want to use this. */ if (reg.left_string (1) == "F") @@ -565,7 +554,7 @@ Lookup::accordion (SCM s, Real staff_space, Font_metric *fm) Stencil d = fm->find_by_name ("accordion.accDot"); d.translate_axis (staff_space * 1.5 PT, Y_AXIS); m.add_stencil (d); - reg = reg.right_string (reg.length ()-1); + reg = reg.right_string (reg.length () - 1); } if (reg.left_string (2) == "EE") { @@ -575,14 +564,14 @@ Lookup::accordion (SCM s, Real staff_space, Font_metric *fm) m.add_stencil (d); d.translate_axis (-0.8 * staff_space PT, X_AXIS); m.add_stencil (d); - reg = reg.right_string (reg.length ()-2); + reg = reg.right_string (reg.length () - 2); } if (reg.left_string (1) == "E") { Stencil d = fm->find_by_name ("accordion.accDot"); d.translate_axis (staff_space * 0.5 PT, Y_AXIS); m.add_stencil (d); - reg = reg.right_string (reg.length ()-1); + reg = reg.right_string (reg.length () - 1); } } else if (sym == "Stdbase") @@ -594,14 +583,14 @@ Lookup::accordion (SCM s, Real staff_space, Font_metric *fm) Stencil d = fm->find_by_name ("accordion.accDot"); d.translate_axis (staff_space * 3.5 PT, Y_AXIS); m.add_stencil (d); - reg = reg.right_string (reg.length ()-1); + reg = reg.right_string (reg.length () - 1); } if (reg.left_string (1) == "F") { Stencil d = fm->find_by_name ("accordion.accDot"); d.translate_axis (staff_space * 2.5 PT, Y_AXIS); m.add_stencil (d); - reg = reg.right_string (reg.length ()-1); + reg = reg.right_string (reg.length () - 1); } if (reg.left_string (1) == "M") { @@ -609,21 +598,21 @@ Lookup::accordion (SCM s, Real staff_space, Font_metric *fm) d.translate_axis (staff_space * 2 PT, Y_AXIS); d.translate_axis (staff_space PT, X_AXIS); m.add_stencil (d); - reg = reg.right_string (reg.length ()-1); + reg = reg.right_string (reg.length () - 1); } if (reg.left_string (1) == "E") { Stencil d = fm->find_by_name ("accordion.accDot"); d.translate_axis (staff_space * 1.5 PT, Y_AXIS); m.add_stencil (d); - reg = reg.right_string (reg.length ()-1); + reg = reg.right_string (reg.length () - 1); } if (reg.left_string (1) == "S") { Stencil d = fm->find_by_name ("accordion.accDot"); d.translate_axis (staff_space * 0.5 PT, Y_AXIS); m.add_stencil (d); - reg = reg.right_string (reg.length ()-1); + reg = reg.right_string (reg.length () - 1); } } /* ugh maybe try to use regular font for S.B. and B.B and only use one font @@ -648,7 +637,7 @@ Lookup::accordion (SCM s, Real staff_space, Font_metric *fm) Stencil r = fm->find_by_name ("accordion.accOldEES"); m.add_stencil (r); } - return m; + return m; } Stencil @@ -660,25 +649,24 @@ Lookup::repeat_slash (Real w, Real s, Real t) SCM slashnodot = scm_list_n (ly_symbol2scm ("repeat-slash"), wid, sl, thick, SCM_UNDEFINED); - Box b (Interval (0, w + sqrt (sqr (t/s) + sqr (t))), + Box b (Interval (0, w + sqrt (sqr (t / s) + sqr (t))), Interval (0, w * s)); return Stencil (b, slashnodot); // http://slashnodot.org } - Stencil Lookup::bracket (Axis a, Interval iv, Real thick, Real protude, Real blot) { Box b; - Axis other = Axis ((a+1)%2); + Axis other = Axis ((a + 1)%2); b[a] = iv; b[other] = Interval (-1, 1) * thick * 0.5; - + Stencil m = round_filled_box (b, blot); b[a] = Interval (iv[UP] - thick, iv[UP]); - Interval oi = Interval (-thick/2, thick/2 + fabs (protude)); + Interval oi = Interval (-thick / 2, thick / 2 + fabs (protude)); oi *= sign (protude); b[other] = oi; m.add_stencil (round_filled_box (b, blot)); @@ -691,18 +679,17 @@ Lookup::bracket (Axis a, Interval iv, Real thick, Real protude, Real blot) Stencil Lookup::triangle (Interval iv, Real thick, Real protude) { - Box b ; - b[X_AXIS] = Interval (0, iv.length()); - b[Y_AXIS] = Interval (0 ? protude); - + Box b; + b[X_AXIS] = Interval (0, iv.length ()); + b[Y_AXIS] = Interval (0 ? protude); - Offset z1(iv[LEFT], 0); - Offset z2(iv[RIGHT], 0); - Offset z3((z1 + z2)[X_AXIS]/2, protude); + Offset z1 (iv[LEFT], 0); + Offset z2 (iv[RIGHT], 0); + Offset z3 ((z1 + z2)[X_AXIS] / 2, protude); /* TODO: move Triangle to Line_interface ? - */ + */ Stencil tri = Line_interface::make_line (thick, z1, z2); tri.add_stencil (Line_interface::make_line (thick, z2, z3)); tri.add_stencil (Line_interface::make_line (thick, z3, z1)); diff --git a/lily/ly-module.cc b/lily/ly-module.cc index 082c7d04df..e3b876967f 100644 --- a/lily/ly-module.cc +++ b/lily/ly-module.cc @@ -27,7 +27,7 @@ ly_make_anonymous_module (bool safe) SCM mod = SCM_EOL; if (!safe) { - String s = "*anonymous-ly-" + to_string (module_count++) + "*"; + String s = "*anonymous-ly-" + to_string (module_count++) + "*"; mod = scm_c_define_module (s.to_str0 (), ly_init_anonymous_module, 0); ly_use_module (mod, global_lily_module); } @@ -47,7 +47,7 @@ ly_use_module (SCM mod, SCM used) mod, scm_list_2 (ly_symbol2scm ("module-public-interface"), used)); - + return scm_eval (expr, global_lily_module); } @@ -64,19 +64,19 @@ module_define_closure_func (void *closure, SCM key, SCM val, SCM result) } /* Ugh signature of scm_internal_hash_fold () is inaccurate. */ -typedef SCM (*Hash_cl_func)(); +typedef SCM (*Hash_cl_func) (); /* If a variable in changed in SRC, we DEST doesn't see the definitions. - */ +*/ LY_DEFINE (ly_module_copy, "ly:module-copy", 2, 0, 0, (SCM dest, SCM src), "Copy all bindings from module SRC into DEST.") { SCM_VALIDATE_MODULE (1, src); scm_internal_hash_fold ((Hash_cl_func) &module_define_closure_func, - (void*) dest, + (void *) dest, SCM_EOL, SCM_MODULE_OBARRAY (src)); return SCM_UNSPECIFIED; } @@ -93,23 +93,23 @@ SCM ly_module_symbols (SCM mod) { SCM_VALIDATE_MODULE (1, mod); - + SCM obarr = SCM_MODULE_OBARRAY (mod); return scm_internal_hash_fold ((Hash_cl_func) &accumulate_symbol, - NULL, SCM_EOL, obarr); + NULL, SCM_EOL, obarr); } static SCM entry_to_alist (void *closure, SCM key, SCM val, SCM result) { (void) closure; - if (scm_variable_bound_p (val) == SCM_BOOL_T) + if (scm_variable_bound_p (val) == SCM_BOOL_T) { return scm_cons (scm_cons (key, scm_variable_ref (val)), result); } else { - programming_error ("Unbound variable in module."); + programming_error ("Unbound variable in module."); return result; } } @@ -121,7 +121,7 @@ LY_DEFINE (ly_module2alist, "ly:module->alist", SCM_VALIDATE_MODULE (1, mod); SCM obarr = SCM_MODULE_OBARRAY (mod); - return scm_internal_hash_fold ((Hash_cl_func) &entry_to_alist, NULL, SCM_EOL, obarr); + return scm_internal_hash_fold ((Hash_cl_func) &entry_to_alist, NULL, SCM_EOL, obarr); } /* Lookup SYM, but don't give error when it is not defined. */ @@ -149,7 +149,7 @@ LY_DEFINE (ly_modules_lookup, "ly:modules-lookup", SCM mod = scm_car (s); SCM v = ly_module_lookup (mod, sym); if (SCM_VARIABLEP (v) && SCM_VARIABLE_REF (v) != SCM_UNDEFINED) - return scm_variable_ref(v); + return scm_variable_ref (v); } if (def != SCM_UNDEFINED) @@ -163,7 +163,7 @@ ly_export (SCM module, SCM namelist) static SCM export_function; if (!export_function) export_function = scm_permanent_object (scm_c_lookup ("module-export!")); - + scm_call_2 (SCM_VARIABLE_REF (export_function), module, namelist); } diff --git a/lily/lyric-combine-music-iterator.cc b/lily/lyric-combine-music-iterator.cc index 5855ebc8f8..09fe51c293 100644 --- a/lily/lyric-combine-music-iterator.cc +++ b/lily/lyric-combine-music-iterator.cc @@ -1,11 +1,10 @@ -/* +/* lyric-combine-music-iterator.cc -- implement Lyric_combine_music_iterator - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - - */ +*/ #include "context.hh" #include "event.hh" @@ -17,32 +16,30 @@ class Lyric_combine_music_iterator : public Music_iterator { public: Lyric_combine_music_iterator (); - Lyric_combine_music_iterator (Lyric_combine_music_iterator const&src); + Lyric_combine_music_iterator (Lyric_combine_music_iterator const &src); DECLARE_SCHEME_CALLBACK (constructor, ()); protected: virtual void construct_children (); virtual Moment pending_moment () const; - virtual void do_quit (); + virtual void do_quit (); virtual void process (Moment); virtual Music_iterator *try_music_in_children (Music *) const; virtual bool ok () const; virtual void derived_mark () const; - virtual void derived_substitute (Context *, Context *) ; + virtual void derived_substitute (Context *, Context *); private: - bool get_busy_status ()const ; - bool melisma_busy (); - Music* get_combine_lyrics () const; - Music* get_combine_music () const; - - - Music_iterator * music_iter_; - Music_iterator * lyric_iter_; -}; + bool get_busy_status ()const; + bool melisma_busy (); + Music *get_combine_lyrics () const; + Music *get_combine_music () const; + Music_iterator *music_iter_; + Music_iterator *lyric_iter_; +}; bool -melisma_busy (Context* tr) +melisma_busy (Context *tr) { SCM melisma_properties = tr->get_property ("melismaBusyProperties"); bool busy = false; @@ -54,11 +51,9 @@ melisma_busy (Context* tr) return busy; } - - /* Ugh, why static? - */ +*/ Music *busy_req; Music *melisma_playing_req; @@ -99,7 +94,7 @@ Lyric_combine_music_iterator::derived_mark ()const } void -Lyric_combine_music_iterator::derived_substitute (Context *f, Context * t) +Lyric_combine_music_iterator::derived_substitute (Context *f, Context *t) { if (music_iter_) music_iter_->substitute_outlet (f, t); @@ -107,7 +102,7 @@ Lyric_combine_music_iterator::derived_substitute (Context *f, Context * t) lyric_iter_->substitute_outlet (f, t); } -Music* +Music * Lyric_combine_music_iterator::get_combine_music () const { SCM l = get_music ()->get_property ("elements"); @@ -116,7 +111,7 @@ Lyric_combine_music_iterator::get_combine_music () const return unsmob_music (scm_car (l)); } -Music* +Music * Lyric_combine_music_iterator::get_combine_lyrics () const { SCM l = get_music ()->get_property ("elements"); @@ -128,7 +123,6 @@ Lyric_combine_music_iterator::get_combine_lyrics () const return unsmob_music (scm_car (l)); } - void Lyric_combine_music_iterator::construct_children () { @@ -145,17 +139,16 @@ Lyric_combine_music_iterator::get_busy_status () const instant. */ if (try_music (busy_req)) return true; - - Context * tr = music_iter_->get_outlet (); + + Context *tr = music_iter_->get_outlet (); SCM grobs = tr->get_property ("busyGrobs"); Moment now = tr->now_mom (); for (; scm_is_pair (grobs); grobs = scm_cdr (grobs)) { SCM grob = scm_cdar (grobs); - Moment end =*unsmob_moment (scm_caar (grobs)); + Moment end =*unsmob_moment (scm_caar (grobs)); - /* This is slightly ugh: we are now confunding the frontend (iterators) and the backend (note heads) */ @@ -167,7 +160,6 @@ Lyric_combine_music_iterator::get_busy_status () const return false; } - bool Lyric_combine_music_iterator::melisma_busy () { @@ -175,7 +167,7 @@ Lyric_combine_music_iterator::melisma_busy () We can not read the property, since music_iter_->get_outlet () might not be the context that sets the melisma properties, but rather a parent context. - */ + */ return music_iter_->try_music (melisma_playing_req); } @@ -185,7 +177,7 @@ Lyric_combine_music_iterator::process (Moment m) Moment my_next = music_iter_->pending_moment (); if (my_next > m) return; - + music_iter_->process (m); if (get_busy_status () && !melisma_busy () && lyric_iter_->ok ()) @@ -204,15 +196,14 @@ Lyric_combine_music_iterator::do_quit () lyric_iter_->quit (); } -Music_iterator* +Music_iterator * Lyric_combine_music_iterator::try_music_in_children (Music *m) const { - Music_iterator * i = music_iter_->try_music (m); + Music_iterator *i = music_iter_->try_music (m); if (i) return i; else return lyric_iter_->try_music (m); } - IMPLEMENT_CTOR_CALLBACK (Lyric_combine_music_iterator); diff --git a/lily/lyric-combine-music.cc b/lily/lyric-combine-music.cc index 440e0b2319..5b2764d894 100644 --- a/lily/lyric-combine-music.cc +++ b/lily/lyric-combine-music.cc @@ -1,11 +1,10 @@ -/* +/* lyric-combine-music.cc -- implement Lyric_combine_music - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - - */ +*/ #include "music.hh" #include "pitch.hh" @@ -13,15 +12,14 @@ struct Lyric_combine_music { public: - DECLARE_SCHEME_CALLBACK(length_callback, (SCM)); + DECLARE_SCHEME_CALLBACK (length_callback, (SCM)); }; - -MAKE_SCHEME_CALLBACK(Lyric_combine_music, length_callback, 1); +MAKE_SCHEME_CALLBACK (Lyric_combine_music, length_callback, 1); SCM Lyric_combine_music::length_callback (SCM m) { - Music * me = unsmob_music (m); + Music *me = unsmob_music (m); Music *melody = unsmob_music (scm_car (me->get_property ("elements"))); return melody->get_length ().smobbed_copy (); } diff --git a/lily/lyric-engraver.cc b/lily/lyric-engraver.cc index 8bf3a209e9..340a5d914c 100644 --- a/lily/lyric-engraver.cc +++ b/lily/lyric-engraver.cc @@ -18,7 +18,7 @@ /** Generate texts for lyric syllables. We only do one lyric at a time. Multiple copies of this engraver should be used to do multiple voices. - */ +*/ class Lyric_engraver : public Engraver { protected: @@ -43,7 +43,7 @@ Lyric_engraver::Lyric_engraver () } bool -Lyric_engraver::try_music (Music*r) +Lyric_engraver::try_music (Music *r) { if (!event_) { @@ -63,12 +63,11 @@ Lyric_engraver::process_music () } } - -Context* +Context * get_voice_to_lyrics (Context *lyrics) { SCM avc = lyrics->get_property ("associatedVoiceContext"); - if (Context *c = unsmob_context (avc)) + if (Context *c = unsmob_context (avc)) return c; SCM voice_name = lyrics->get_property ("associatedVoice"); @@ -111,13 +110,13 @@ get_current_note_head (Context *voice) for (SCM s = voice->get_property ("busyGrobs"); scm_is_pair (s); s = scm_cdr (s)) { - Item *g = dynamic_cast (unsmob_grob (scm_cdar (s))); - + Item *g = dynamic_cast (unsmob_grob (scm_cdar (s))); + if (g && !g->get_column () && Note_head::has_interface (g)) return g; } - + return 0; } @@ -145,11 +144,10 @@ Lyric_engraver::stop_translation_timestep () event_ = 0; } - ADD_TRANSLATOR (Lyric_engraver, -/* descr */ "", -/* creats*/ "LyricText", -/* accepts */ "lyric-event", -/* acks */ "", -/* reads */ "", -/* write */ ""); + /* descr */ "", + /* creats*/ "LyricText", + /* accepts */ "lyric-event", + /* acks */ "", + /* reads */ "", + /* write */ ""); diff --git a/lily/lyric-extender.cc b/lily/lyric-extender.cc index b71d4337c3..53090bcafb 100644 --- a/lily/lyric-extender.cc +++ b/lily/lyric-extender.cc @@ -18,27 +18,27 @@ #include "group-interface.hh" MAKE_SCHEME_CALLBACK (Lyric_extender, print, 1) -SCM -Lyric_extender::print (SCM smob) + SCM +Lyric_extender::print (SCM smob) { Spanner *me = unsmob_spanner (smob); Item *left_edge = me->get_bound (LEFT); Item *right_text = unsmob_item (me->get_property ("next")); - + Grob *common = left_edge; if (right_text) common = common->common_refpoint (right_text, X_AXIS); - + common = common->common_refpoint (me->get_bound (RIGHT), X_AXIS); - Real sl = me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness")); + Real sl = me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness")); Link_array heads (extract_grob_array (me, ly_symbol2scm ("heads"))); if (!heads.size ()) return SCM_EOL; common = common_refpoint_of_array (heads, common, X_AXIS); - + Real left_point = 0.0; if (left_edge->internal_has_interface (ly_symbol2scm ("lyric-syllable-interface"))) left_point = left_edge->extent (common, X_AXIS)[RIGHT]; @@ -54,7 +54,7 @@ Lyric_extender::print (SCM smob) note head, but haven't found a pattern in it yet. --hwn 1/1/04 */ SCM minlen = me->get_property ("minimum-length"); Real right_point - = left_point + (robust_scm2double (minlen, 0)); + = left_point + (robust_scm2double (minlen, 0)); if (heads.size ()) right_point = right_point >? heads.top ()->extent (common, X_AXIS)[RIGHT]; @@ -68,22 +68,21 @@ Lyric_extender::print (SCM smob) /* run to end of line. */ if (me->get_bound (RIGHT)->break_status_dir ()) right_point = right_point >? (robust_relative_extent (me->get_bound (RIGHT), common, X_AXIS)[LEFT] - pad); - + left_point += pad; Real w = right_point - left_point; if (w < 1.5 * h) return SCM_EOL; - - Stencil mol (Lookup::round_filled_box (Box (Interval (0, w), - Interval (0, h)), - 0.8 * h)); + + Stencil mol (Lookup::round_filled_box (Box (Interval (0, w), + Interval (0, h)), + 0.8 * h)); mol.translate_axis (left_point - me->relative_coordinate (common, X_AXIS), X_AXIS); return mol.smobbed_copy (); } - ADD_INTERFACE (Lyric_extender, "lyric-extender-interface", "The extender is a simple line at the baseline of the lyric " "that helps show the length of a melissima (tied/slurred note).", diff --git a/lily/lyric-hyphen.cc b/lily/lyric-hyphen.cc index 07a393e7d2..8dd88dc0c1 100644 --- a/lily/lyric-hyphen.cc +++ b/lily/lyric-hyphen.cc @@ -16,18 +16,18 @@ #include "moment.hh" MAKE_SCHEME_CALLBACK (Hyphen_spanner, print, 1) -SCM + SCM Hyphen_spanner::print (SCM smob) { - Spanner * me = unsmob_spanner (smob); - Drul_array bounds (me->get_bound (LEFT), - me->get_bound (RIGHT)); + Spanner *me = unsmob_spanner (smob); + Drul_array bounds (me->get_bound (LEFT), + me->get_bound (RIGHT)); if (bounds[LEFT]->break_status_dir () && Paper_column::when_mom (bounds[LEFT]) == Paper_column::when_mom (bounds[RIGHT]->get_column ())) return SCM_EOL; - - Grob * common = bounds[LEFT]->common_refpoint (bounds[RIGHT], X_AXIS); + + Grob *common = bounds[LEFT]->common_refpoint (bounds[RIGHT], X_AXIS); Interval span_points; Direction d = LEFT; @@ -40,37 +40,37 @@ Hyphen_spanner::print (SCM smob) : iv[-d]; } while (flip (&d) != LEFT); - + Real lt = me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness")); - Real th = robust_scm2double (me->get_property ("thickness"), 1) * lt ; + Real th = robust_scm2double (me->get_property ("thickness"), 1) * lt; Real h = robust_scm2double (me->get_property ("height"), 0.5); // interval? - + Real dp = robust_scm2double (me->get_property ("dash-period"), 1.0); - Real dl = robust_scm2double (me->get_property ("length"), .5 ); + Real dl = robust_scm2double (me->get_property ("length"), .5); if (dp < dl) dp = 1.5 * dl; Real l = span_points.length (); - int n = int (ceil (l/dp - 0.5)); + int n = int (ceil (l / dp - 0.5)); if (n <= 0) n = 1; - Real space_left = l - dl - (n-1)* dp; + Real space_left = l - dl - (n - 1)* dp; /* If there is not enough space, the hyphen should disappear, but not at the end of the line. - */ + */ if (space_left < 0.0 && !bounds[RIGHT]->break_status_dir ()) return SCM_EOL; space_left = space_left >? 0.0; - - Box b (Interval (0, dl), Interval (h, h+th)); + + Box b (Interval (0, dl), Interval (h, h + th)); Stencil dash_mol (Lookup::round_filled_box (b, 0.8 * lt)); Stencil total; @@ -81,21 +81,20 @@ Hyphen_spanner::print (SCM smob) total.add_stencil (m); } - total.translate_axis ( -me->relative_coordinate (common, X_AXIS), X_AXIS); + total.translate_axis (-me->relative_coordinate (common, X_AXIS), X_AXIS); return total.smobbed_copy (); } - MAKE_SCHEME_CALLBACK (Hyphen_spanner, set_spacing_rods, 1); SCM Hyphen_spanner::set_spacing_rods (SCM smob) { - Grob*me = unsmob_grob (smob); + Grob *me = unsmob_grob (smob); Rod r; - Spanner*sp = dynamic_cast (me); - r.distance_ = - robust_scm2double (me->get_property ("minimum-length"), 0); + Spanner *sp = dynamic_cast (me); + r.distance_ + = robust_scm2double (me->get_property ("minimum-length"), 0); Direction d = LEFT; do @@ -109,7 +108,7 @@ Hyphen_spanner::set_spacing_rods (SCM smob) if (r.item_drul_[LEFT] && r.item_drul_[RIGHT]) r.add_to_cols (); - + return SCM_UNSPECIFIED; } @@ -117,4 +116,3 @@ ADD_INTERFACE (Hyphen_spanner, "lyric-hyphen-interface", "A centred hyphen is a simple line between lyrics used to divide syllables", "thickness height dash-period minimum-length length"); - diff --git a/lily/lyric-performer.cc b/lily/lyric-performer.cc index 82e9ff6fdd..7c2aa33c9b 100644 --- a/lily/lyric-performer.cc +++ b/lily/lyric-performer.cc @@ -9,29 +9,27 @@ #include "audio-item.hh" #include "performer.hh" -class Lyric_performer : public Performer { +class Lyric_performer : public Performer +{ public: TRANSLATOR_DECLARATIONS (Lyric_performer); protected: - virtual bool try_music (Music* req); + virtual bool try_music (Music *req); virtual void stop_translation_timestep (); virtual void create_audio_elements (); private: Link_array lreqs_; - Audio_text* audio_; + Audio_text *audio_; }; - - Lyric_performer::Lyric_performer () { audio_ = 0; } - void Lyric_performer::create_audio_elements () { @@ -41,7 +39,7 @@ Lyric_performer::create_audio_elements () && ly_scm2string (lreqs_[0]->get_property ("text")).length ()) { audio_ = new Audio_text (Audio_text::LYRIC, - ly_scm2string (lreqs_[0]->get_property ("text"))); + ly_scm2string (lreqs_[0]->get_property ("text"))); Audio_element_info info (audio_, lreqs_[0]); announce_element (info); } @@ -60,7 +58,7 @@ Lyric_performer::stop_translation_timestep () } bool -Lyric_performer::try_music (Music* req) +Lyric_performer::try_music (Music *req) { if (req->is_mus_type ("lyric-event")) { diff --git a/lily/main.cc b/lily/main.cc index 2cd13eb5b0..a5a3d3afc9 100644 --- a/lily/main.cc +++ b/lily/main.cc @@ -5,7 +5,7 @@ (c) 1997--2005 Han-Wen Nienhuys */ - + #include "main.hh" #include @@ -72,44 +72,42 @@ String init_scheme_code_string = "(begin #t "; bool make_preview = false; bool make_pages = true; - /* * Miscellaneous global stuff. */ File_path global_path; - /* * File globals. */ -static char const *AUTHORS = -" Han-Wen Nienhuys \n" -" Jan Nieuwenhuizen \n"; +static char const *AUTHORS += " Han-Wen Nienhuys \n" + " Jan Nieuwenhuizen \n"; static char const *PROGRAM_NAME = "lilypond"; static char const *PROGRAM_URL = "http://lilypond.org"; -static char const *NOTICE = -_i("This program is free software. It is covered by the GNU General Public\n" - "License and you are welcome to change it and/or distribute copies of it\n" - "under certain conditions. Invoke as `%s --warranty' for more\n" - "information.\n"); - -static char const *WARRANTY = -_i(" This program is free software; you can redistribute it and/or\n" - "modify it under the terms of the GNU General Public License version 2\n" - "as published by the Free Software Foundation.\n" - "\n" - " This program is distributed in the hope that it will be useful,\n" - "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" - "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n" - "General Public License for more details.\n" - "\n" - " You should have received a copy (refer to the file COPYING) of the\n" - "GNU General Public License along with this program; if not, write to\n" - "the Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n" - "Boston, MA 02111-1307, USA.\n"); +static char const *NOTICE += _i ("This program is free software. It is covered by the GNU General Public\n" + "License and you are welcome to change it and/or distribute copies of it\n" + "under certain conditions. Invoke as `%s --warranty' for more\n" + "information.\n"); + +static char const *WARRANTY += _i (" This program is free software; you can redistribute it and/or\n" + "modify it under the terms of the GNU General Public License version 2\n" + "as published by the Free Software Foundation.\n" + "\n" + " This program is distributed in the hope that it will be useful,\n" + "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n" + "General Public License for more details.\n" + "\n" + " You should have received a copy (refer to the file COPYING) of the\n" + "GNU General Public License along with this program; if not, write to\n" + "the Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n" + "Boston, MA 02111-1307, USA.\n"); /* Where the init files live. Typically: LILYPOND_DATADIR = /usr/share/lilypond @@ -123,47 +121,47 @@ String jail_spec; static Getopt_long *option_parser = 0; /* Internationalisation kludge in two steps: - * use _i () to get entry in POT file - * call gettext () explicitely for actual "translation" */ - -static Long_option_init options_static[] = - { - {_i ("EXT"), "backend", 'b', _i ("select backend to use")}, - {_i ("EXPR"), "evaluate", 'e', - _i ("set option, use -e '(ly:option-usage)' for help")}, - /* Bug in option parser: --output =foe is taken as an abbreviation - for --output-format. */ - {_i ("EXTs"), "formats", 'f', _i ("list of formats to dump")}, - {0, "help", 'h', _i ("print this help")}, - {_i ("FIELD"), "header", 'H', _i ("write header field to BASENAME.FIELD")}, - {_i ("DIR"), "include", 'I', _i ("add DIR to search path")}, - {_i ("FILE"), "init", 'i', _i ("use FILE as init file")}, - {_i ("FILE"), "output", 'o', _i ("write output to FILE (suffix will be added)")}, - {_i ("USER,GROUP,JAIL,DIR"), "jail", 'j', _i ("chroot to JAIL, become USER:GROUP and cd into DIR")}, - {0, "preview", 'p', _i ("generate a preview")}, - {0, "no-pages", 0, _i ("don't generate full pages")}, - {0, "png", 0, _i ("generate PNG")}, - {0, "ps", 0, _i ("generate PostScript")}, - {0, "dvi", 0, _i ("generate DVI")}, - {0, "pdf", 0, _i ("generate PDF (default)")}, - {0, "tex", 0, _i ("generate TeX")}, - {0, "safe-mode", 's', _i ("run in safe mode")}, - {0, "version", 'v', _i ("print version number")}, - {0, "verbose", 'V', _i ("be verbose")}, - {0, "warranty", 'w', _i ("show warranty and copyright")}, - {0, 0, 0, 0} - }; + * use _i () to get entry in POT file + * call gettext () explicitely for actual "translation" */ + +static Long_option_init options_static[] += { + {_i ("EXT"), "backend", 'b', _i ("select backend to use")}, + {_i ("EXPR"), "evaluate", 'e', + _i ("set option, use -e '(ly:option-usage)' for help")}, + /* Bug in option parser: --output =foe is taken as an abbreviation + for --output-format. */ + {_i ("EXTs"), "formats", 'f', _i ("list of formats to dump")}, + {0, "help", 'h', _i ("print this help")}, + {_i ("FIELD"), "header", 'H', _i ("write header field to BASENAME.FIELD")}, + {_i ("DIR"), "include", 'I', _i ("add DIR to search path")}, + {_i ("FILE"), "init", 'i', _i ("use FILE as init file")}, + {_i ("FILE"), "output", 'o', _i ("write output to FILE (suffix will be added)")}, + {_i ("USER,GROUP,JAIL,DIR"), "jail", 'j', _i ("chroot to JAIL, become USER:GROUP and cd into DIR")}, + {0, "preview", 'p', _i ("generate a preview")}, + {0, "no-pages", 0, _i ("don't generate full pages")}, + {0, "png", 0, _i ("generate PNG")}, + {0, "ps", 0, _i ("generate PostScript")}, + {0, "dvi", 0, _i ("generate DVI")}, + {0, "pdf", 0, _i ("generate PDF (default)")}, + {0, "tex", 0, _i ("generate TeX")}, + {0, "safe-mode", 's', _i ("run in safe mode")}, + {0, "version", 'v', _i ("print version number")}, + {0, "verbose", 'V', _i ("be verbose")}, + {0, "warranty", 'w', _i ("show warranty and copyright")}, + {0, 0, 0, 0} +}; static void dir_info (FILE *out) { fputs ("\n", out); fprintf (out, "LILYPOND_DATADIR=\"%s\"\n", LILYPOND_DATADIR); - if (char const * env = getenv ("LILYPONDPREFIX")) - fprintf (out, "LILYPONDPREFIX=\"%s\"\n", env); + if (char const *env = getenv ("LILYPONDPREFIX")) + fprintf (out, "LILYPONDPREFIX=\"%s\"\n", env); fprintf (out, "LOCALEDIR=\"%s\"\n", LOCALEDIR); - fprintf (out, "\nEffective prefix: \"%s\"\n", prefix_directory.to_str0()); + fprintf (out, "\nEffective prefix: \"%s\"\n", prefix_directory.to_str0 ()); } static void @@ -181,7 +179,7 @@ identify (FILE *out) fputs (gnu_lilypond_version_string ().to_str0 (), out); fputs ("\n", out); } - + static void notice () { @@ -226,7 +224,7 @@ static void setup_paths () { prefix_directory = LILYPOND_DATADIR; - if (char const * env = getenv ("LILYPONDPREFIX")) + if (char const *env = getenv ("LILYPONDPREFIX")) prefix_directory = env; global_path.append (""); @@ -267,7 +265,7 @@ do_chroot_jail () { USER_NAME, GROUP_NAME, JAIL, DIR, JAIL_MAX }; - + Array components = String_convert::split (jail_spec, ','); if (components.size () != JAIL_MAX) { @@ -286,10 +284,10 @@ do_chroot_jail () { if (errno == 0) error (_f ("no such user: %s", components[USER_NAME])); - else - error(_f ("can't get user id from user name: %s: %s", - components[USER_NAME], - strerror (errno))); + else + error (_f ("can't get user id from user name: %s: %s", + components[USER_NAME], + strerror (errno))); exit (3); } @@ -301,9 +299,9 @@ do_chroot_jail () gid = group->gr_gid; else { - if (errno == 0) + if (errno == 0) error (_f ("no such group: %s", components[GROUP_NAME])); - else + else error (_f ("can't get group id from group name: %s: ", components[GROUP_NAME], strerror (errno))); @@ -337,7 +335,7 @@ do_chroot_jail () } } -void test_pango(); +void test_pango (); static void main_with_guile (void *, int, char **) @@ -354,19 +352,18 @@ main_with_guile (void *, int, char **) || output_backend_global == "texstr"); is_pango_format_global = !is_TeX_format_global; - ly_c_init_guile (); call_constructors (); init_global_tweak_registry (); init_fontconfig (); - + init_freetype (); all_fonts_global = new All_font_metrics (global_path.to_string ()); init_scheme_code_string += ")"; - scm_c_eval_string ((char*) init_scheme_code_string.to_str0 ()); + scm_c_eval_string ((char *) init_scheme_code_string.to_str0 ()); /* We accept multiple independent music files on the command line to reduce compile time when processing lots of small files. @@ -391,8 +388,8 @@ main_with_guile (void *, int, char **) exit (2); } - if (! jail_spec.is_empty ()) - do_chroot_jail (); + if (! jail_spec.is_empty ()) + do_chroot_jail (); SCM result = scm_call_1 (ly_lily_module_constant ("lilypond-main"), files); (void) result; @@ -407,11 +404,11 @@ setup_localisation () #if HAVE_GETTEXT /* Enable locales */ setlocale (LC_ALL, ""); - + /* FIXME: check if this is still true. - Disable localisation of float values. This breaks TeX output. */ + Disable localisation of float values. This breaks TeX output. */ setlocale (LC_NUMERIC, "C"); - + String name (PACKAGE); name.to_lower (); bindtextdomain (name.to_str0 (), LOCALEDIR); @@ -450,7 +447,7 @@ parse_argv (int argc, char **argv) else if (String (opt->longname_str0_) == "no-pages") make_pages = false; break; - + case 'v': notice (); exit (0); diff --git a/lily/mark-engraver.cc b/lily/mark-engraver.cc index 0213ff3440..cc62a17d7f 100644 --- a/lily/mark-engraver.cc +++ b/lily/mark-engraver.cc @@ -16,9 +16,9 @@ #include "text-item.hh" /** - put stuff over or next to bars. Examples: bar numbers, marginal notes, - rehearsal marks. - */ + put stuff over or next to bars. Examples: bar numbers, marginal notes, + rehearsal marks. +*/ class Mark_engraver : public Engraver { public: @@ -28,18 +28,15 @@ protected: protected: virtual void stop_translation_timestep (); virtual void acknowledge_grob (Grob_info); - void create_items (Music*); + void create_items (Music *); virtual bool try_music (Music *ev); virtual void process_music (); - + private: - Music * mark_ev_; + Music *mark_ev_; }; - - - Mark_engraver::Mark_engraver () { text_ = 0; @@ -49,31 +46,30 @@ Mark_engraver::Mark_engraver () void Mark_engraver::acknowledge_grob (Grob_info inf) { - Grob * s = inf.grob_; + Grob *s = inf.grob_; if (text_ && Bar_line::has_interface (s)) { /* - TODO: make this configurable. RehearsalMark cannot be - break-aligned, since the width of the object should not be taken - into alignment considerations. + TODO: make this configurable. RehearsalMark cannot be + break-aligned, since the width of the object should not be taken + into alignment considerations. */ text_->set_parent (s, X_AXIS); } } -void +void Mark_engraver::stop_translation_timestep () { if (text_) { SCM lst = get_property ("stavesFound"); - text_->set_property ("side-support-elements" , lst); + text_->set_property ("side-support-elements", lst); text_ = 0; } mark_ev_ = 0; } - void Mark_engraver::create_items (Music *ev) { @@ -83,15 +79,13 @@ Mark_engraver::create_items (Music *ev) text_ = make_item ("RehearsalMark", ev->self_scm ()); } - bool -Mark_engraver::try_music (Music* r) +Mark_engraver::try_music (Music *r) { mark_ev_ = r; return true; } - /* TODO: make the increment function in Scheme. */ @@ -104,24 +98,23 @@ Mark_engraver::process_music () /* automatic marks. - */ + */ - SCM m = mark_ev_->get_property ("label"); SCM proc = get_property ("markFormatter"); - if (!Text_interface::markup_p (m) && - ly_c_procedure_p (proc)) + if (!Text_interface::markup_p (m) + && ly_c_procedure_p (proc)) { - if (!scm_is_number (m)) - m = get_property ("rehearsalMark"); + if (!scm_is_number (m)) + m = get_property ("rehearsalMark"); if (scm_integer_p (m) == SCM_BOOL_T && scm_exact_p (m) == SCM_BOOL_T) { int mark_count = scm_to_int (m); - mark_count ++; + mark_count++; context ()->set_property ("rehearsalMark", - scm_int2num (mark_count)); + scm_int2num (mark_count)); } if (scm_is_number (m)) @@ -138,15 +131,14 @@ Mark_engraver::process_music () } ADD_TRANSLATOR (Mark_engraver, -/* descr */ "This engraver will create RehearsalMark objects. " - "It puts them on top of all staves (which is taken from " - "the property @code{stavesFound}). If moving this engraver " - "to a different context, " - "@ref{Staff_collecting_engraver} must move along, otherwise all marks" - "end up on the same Y-location" - , -/* creats*/ "RehearsalMark", -/* accepts */ "mark-event", -/* acks */ "bar-line-interface", -/* reads */ "rehearsalMark markFormatter stavesFound", -/* write */ ""); + /* descr */ "This engraver will create RehearsalMark objects. " + "It puts them on top of all staves (which is taken from " + "the property @code{stavesFound}). If moving this engraver " + "to a different context, " + "@ref{Staff_collecting_engraver} must move along, otherwise all marks" + "end up on the same Y-location", + /* creats*/ "RehearsalMark", + /* accepts */ "mark-event", + /* acks */ "bar-line-interface", + /* reads */ "rehearsalMark markFormatter stavesFound", + /* write */ ""); diff --git a/lily/measure-grouping-engraver.cc b/lily/measure-grouping-engraver.cc index 4dd57300a3..05ce7072a7 100644 --- a/lily/measure-grouping-engraver.cc +++ b/lily/measure-grouping-engraver.cc @@ -1,10 +1,10 @@ -/* +/* measure-grouping-engraver.cc -- implement Measure_grouping_engraver source file of the GNU LilyPond music typesetter (c) 2002--2005 Han-Wen Nienhuys - */ +*/ #include "warn.hh" #include "side-position-interface.hh" @@ -17,7 +17,7 @@ public: TRANSLATOR_DECLARATIONS (Measure_grouping_engraver); protected: - Spanner * grouping_; + Spanner *grouping_; Rational stop_grouping_mom_; virtual void process_music (); @@ -36,7 +36,6 @@ Measure_grouping_engraver::finalize () } } - void Measure_grouping_engraver::acknowledge_grob (Grob_info gi) { @@ -54,27 +53,26 @@ Measure_grouping_engraver::process_music () { grouping_->set_bound (RIGHT, unsmob_grob (get_property ("currentMusicalColumn"))); - + grouping_ = 0; } - + if (now.grace_part_) - return; - + return; + SCM grouping = get_property ("beatGrouping"); if (scm_is_pair (grouping)) { Moment *measpos = unsmob_moment (get_property ("measurePosition")); Rational mp = measpos->main_part_; - - Moment * beatlen = unsmob_moment (get_property ("beatLength")); + + Moment *beatlen = unsmob_moment (get_property ("beatLength")); Rational bl = beatlen->main_part_; - + Rational where (0); for (SCM s = grouping; scm_is_pair (s); where += Rational ((int) scm_to_int (scm_car (s))) * bl, - s = scm_cdr (s) - ) + s = scm_cdr (s)) { int grouplen = scm_to_int (scm_car (s)); if (where == mp) @@ -84,21 +82,19 @@ Measure_grouping_engraver::process_music () programming_error ("Huh, last grouping not finished yet."); continue; } - + grouping_ = make_spanner ("MeasureGrouping", SCM_EOL); grouping_->set_bound (LEFT, unsmob_grob (get_property ("currentMusicalColumn"))); - - - stop_grouping_mom_ = now.main_part_ + Rational (grouplen - 1) * bl ; + stop_grouping_mom_ = now.main_part_ + Rational (grouplen - 1) * bl; get_global_context ()->add_moment_to_process (Moment (stop_grouping_mom_)); if (grouplen == 3) grouping_->set_property ("style", ly_symbol2scm ("triangle")); else grouping_->set_property ("style", ly_symbol2scm ("bracket")); - - break ; + + break; } } } @@ -109,9 +105,9 @@ Measure_grouping_engraver::Measure_grouping_engraver () } ADD_TRANSLATOR (Measure_grouping_engraver, -/* descr */ "Creates MeasureGrouping to indicate beat subdivision.", -/* creats*/ "MeasureGrouping", -/* accepts */ "", -/* acks */ "note-column-interface", -/* reads */ "beatGrouping beatLength measurePosition currentMusicalColumn", -/* write */ ""); + /* descr */ "Creates MeasureGrouping to indicate beat subdivision.", + /* creats*/ "MeasureGrouping", + /* accepts */ "", + /* acks */ "note-column-interface", + /* reads */ "beatGrouping beatLength measurePosition currentMusicalColumn", + /* write */ ""); diff --git a/lily/measure-grouping-spanner.cc b/lily/measure-grouping-spanner.cc index cb23c7c68c..9918b5051b 100644 --- a/lily/measure-grouping-spanner.cc +++ b/lily/measure-grouping-spanner.cc @@ -1,45 +1,42 @@ -/* - measure-grouping-spanner.cc -- implement Measure_grouping +/* + measure-grouping-spanner.cc -- implement Measure_grouping - source file of the GNU LilyPond music typesetter + source file of the GNU LilyPond music typesetter - (c) 2002--2005 Han-Wen Nienhuys - - */ + (c) 2002--2005 Han-Wen Nienhuys +*/ #include "measure-grouping-spanner.hh" #include "output-def.hh" #include "spanner.hh" -#include "lookup.hh" +#include "lookup.hh" #include "item.hh" #include "staff-symbol-referencer.hh" MAKE_SCHEME_CALLBACK (Measure_grouping, print, 1); -SCM +SCM Measure_grouping::print (SCM grob) { - Spanner * me = dynamic_cast (unsmob_grob (grob)); + Spanner *me = dynamic_cast (unsmob_grob (grob)); SCM which = me->get_property ("style"); Real height = robust_scm2double (me->get_property ("height"), 1); Real t = Staff_symbol_referencer::line_thickness (me) * robust_scm2double (me->get_property ("thickness"), 1); Grob *common = me->get_bound (LEFT)->common_refpoint (me->get_bound (RIGHT), - X_AXIS); + X_AXIS); Real right_point = robust_relative_extent (me->get_bound (RIGHT), common, X_AXIS).linear_combination (CENTER); Real left_point = me->get_bound (LEFT)->relative_coordinate (common, X_AXIS); - - Interval iv (left_point, right_point); Stencil m; - + /* TODO: use line interface - */ + */ if (which == ly_symbol2scm ("bracket")) { m = Lookup::bracket (X_AXIS, iv, t, -height, t); @@ -59,4 +56,3 @@ ADD_INTERFACE (Measure_grouping, "measure-grouping-interface", "Valid choices for @code{style} are @code{bracket} and @code{triangle}.", "thickness style height"); - diff --git a/lily/melisma-translator.cc b/lily/melisma-translator.cc index 8ce5ef7cb7..9afeeabf8d 100644 --- a/lily/melisma-translator.cc +++ b/lily/melisma-translator.cc @@ -1,11 +1,10 @@ -/* +/* melisma-engraver.cc -- implement Melisma_engraver - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - - */ +*/ #include "engraver.hh" #include "grob.hh" @@ -13,7 +12,7 @@ /** Signal existence of melismas. - */ +*/ class Melisma_translator : public Translator { public: @@ -22,12 +21,11 @@ protected: virtual bool try_music (Music *); virtual void process_music (); virtual void start_translation_timestep (); - Music * event_; + Music *event_; }; - bool -Melisma_translator::try_music (Music *m) +Melisma_translator::try_music (Music *m) { if (m->is_mus_type ("melisma-playing-event")) { @@ -54,7 +52,7 @@ Melisma_translator::process_music () else context ()->unset_property (ly_symbol2scm ("melismaBusy")); } - + } void @@ -62,16 +60,16 @@ Melisma_translator::start_translation_timestep () { event_ = 0; } - + Melisma_translator::Melisma_translator () { event_ = 0; } ADD_TRANSLATOR (Melisma_translator, -/* descr */ "This translator collects melisma information about ties, beams, and user settings (@code{melismaBusy}, and signals it to the @code{\addlyrics} code. ", -/* creats*/ "", -/* accepts */ "melisma-playing-event melisma-span-event", -/* acks */ "", -/* reads */ "melismaBusy melismaBusyProperties slurMelismaBusy tieMelismaBusy beamMelismaBusy", -/* write */ ""); + /* descr */ "This translator collects melisma information about ties, beams, and user settings (@code{melismaBusy}, and signals it to the @code{\addlyrics} code. ", + /* creats*/ "", + /* accepts */ "melisma-playing-event melisma-span-event", + /* acks */ "", + /* reads */ "melismaBusy melismaBusyProperties slurMelismaBusy tieMelismaBusy beamMelismaBusy", + /* write */ ""); diff --git a/lily/mensural-ligature-engraver.cc b/lily/mensural-ligature-engraver.cc index 1fe6e0730e..4825d45b94 100644 --- a/lily/mensural-ligature-engraver.cc +++ b/lily/mensural-ligature-engraver.cc @@ -1,11 +1,11 @@ /* mensural-ligature-engraver.cc -- implement Mensural_ligature_engraver - + source file of the GNU LilyPond music typesetter - + (c) 2002--2005 Juergen Reuter , - Pal Benko - */ + Pal Benko +*/ #include "coherent-ligature-engraver.hh" #include "mensural-ligature.hh" @@ -56,7 +56,6 @@ private: void fold_up_primitives (Array primitives); }; - Mensural_ligature_engraver::Mensural_ligature_engraver () { } @@ -85,196 +84,197 @@ Mensural_ligature_engraver::transform_heads (Array primitives) bool prev_semibrevis = false; Item *prev_primitive = NULL; - for (int i = 0, s = primitives.size (); i < s; i++) { - Grob_info info = primitives[i]; - Item *primitive = dynamic_cast (info.grob_); - int duration_log = Note_head::get_balltype (primitive); - - Music *nr = info.music_cause (); - - /* - ugh. why not simply check for pitch? - */ - if (!nr->is_mus_type ("note-event")) - { - nr->origin ()->warning - (_f ("can not determine pitch of ligature primitive -> skipping")); - at_beginning = true; - continue; - } - - int pitch = unsmob_pitch (nr->get_property ("pitch"))->steps (); - int delta_pitch = 0; - - if (at_beginning) - { - if (i == s - 1) - { - // we can get here after invalid input - nr->origin ()->warning - (_f ("single note ligature - skipping")); - break; - } - prev_semibrevis = prev_brevis_shape = false; - prev_primitive = NULL; - } - else - { - delta_pitch = pitch - prev_pitch; - if (delta_pitch == 0) - { - nr->origin ()->warning - (_f ("prime interval within ligature -> skipping")); - at_beginning = true; - primitive->set_property ("primitive", - scm_int2num (MLP_NONE)); - continue; - } - } - - if (duration_log < -3 // is this possible at all??? - || duration_log > 0) - { - nr->origin ()->warning - (_f ("mensural ligature: duration none of Mx, L, B, S -> skipping")); - primitive->set_property ("primitive", - scm_int2num (MLP_NONE)); - at_beginning = true; - continue; - } - - // apply_transition replacement begins - bool general_case = true; - - // first check special cases - // 1. beginning - if (at_beginning) - { - // a. semibreves - if (duration_log == 0) - { - primitive->set_property ("primitive", - scm_int2num (MLP_UP | MLP_BREVIS)); - prev_semibrevis = prev_brevis_shape = true; - general_case = false; - } - // b. descendens longa or brevis - else if (i < s - 1 - && (unsmob_pitch (primitives[i + 1].music_cause () - ->get_property ("pitch"))->steps () < pitch) - && duration_log > -3) - { - int left_stem = duration_log == -1 ? MLP_DOWN : 0; - - primitive->set_property ("primitive", - scm_int2num (left_stem | MLP_BREVIS)); - prev_brevis_shape = true; - prev_semibrevis = general_case = false; - } - } - // 2. initial semibrevis must be followed by another one - else if (prev_semibrevis) - { - prev_semibrevis = false; - if (duration_log == 0) - { - primitive->set_property ("primitive", scm_int2num(MLP_BREVIS)); - general_case = false; - } - else - { - nr->origin ()->warning - (_f ("semibrevis must be followed by another one -> skipping")); - primitive->set_property ("primitive", - scm_int2num (MLP_NONE)); - at_beginning = true; - continue; - } - } - // 3. semibreves are otherwise not allowed - else if (duration_log == 0) - { - nr->origin ()->warning - (_f ("semibreves can only appear at the beginning of a ligature,\n" - "and there may be only zero or two of them")); - primitive->set_property ("primitive", - scm_int2num (MLP_NONE)); - at_beginning = true; - continue; - } - // 4. end, descendens - else if (i == s - 1 && delta_pitch < 0) - { - // brevis; previous note must be turned into flexa - if (duration_log == -1) - { - if (prev_brevis_shape) - { - prev_primitive->set_property - ("primitive", - scm_int2num - (MLP_FLEXA - | (scm_to_int (prev_primitive->get_property ("primitive")) - & MLP_DOWN))); - primitive->set_property ("primitive", scm_int2num (MLP_NONE)); - break; // no more notes, no join - } - else - { - nr->origin ()->warning - (_f ("invalid ligatura ending:\n" - "when the last note is a descending brevis,\n" - "the penultimate note must be another one,\n" - "or the ligatura must be LB or SSB")); - primitive->set_property ("primitive", scm_int2num (MLP_NONE)); - break; - } - } - // longa - else if (duration_log == -2) - { - primitive->set_property ("primitive", scm_int2num (MLP_BREVIS)); - general_case = false; - } - // else maxima; fall through regular case below - } - - if (general_case) - { - static int const shape[3] = {MLP_MAXIMA, MLP_LONGA, MLP_BREVIS}; - - primitive->set_property ("primitive", - scm_int2num (shape[duration_log + 3])); - prev_brevis_shape = duration_log == -1; - } - - // join_primitives replacement - if (!at_beginning) - { - /* - if the previous note is longa-shaped and this note is lower, - then the joining line may hide the stem, so it is made longer - to serve as stem as well - */ - if (delta_pitch < 0 - && (scm_to_int (prev_primitive->get_property ("primitive")) - & MLP_LONGA)) - { - delta_pitch -= 6; - // instead of number 6 - // the legth of the longa stem should be queried something like - // Font_interface::get_default_font (ligature)->find_by_name - // ("noteheads.s-2mensural").extent (Y_AXIS).length () - } - prev_primitive->set_property ("join-right-amount", - scm_int2num (delta_pitch)); - // perhaps set add-join as well - } - at_beginning = false; - prev_primitive = primitive; - prev_pitch = pitch; - // apply_transition replacement ends - } + for (int i = 0, s = primitives.size (); i < s; i++) + { + Grob_info info = primitives[i]; + Item *primitive = dynamic_cast (info.grob_); + int duration_log = Note_head::get_balltype (primitive); + + Music *nr = info.music_cause (); + + /* + ugh. why not simply check for pitch? + */ + if (!nr->is_mus_type ("note-event")) + { + nr->origin ()->warning + (_f ("can not determine pitch of ligature primitive -> skipping")); + at_beginning = true; + continue; + } + + int pitch = unsmob_pitch (nr->get_property ("pitch"))->steps (); + int delta_pitch = 0; + + if (at_beginning) + { + if (i == s - 1) + { + // we can get here after invalid input + nr->origin ()->warning + (_f ("single note ligature - skipping")); + break; + } + prev_semibrevis = prev_brevis_shape = false; + prev_primitive = NULL; + } + else + { + delta_pitch = pitch - prev_pitch; + if (delta_pitch == 0) + { + nr->origin ()->warning + (_f ("prime interval within ligature -> skipping")); + at_beginning = true; + primitive->set_property ("primitive", + scm_int2num (MLP_NONE)); + continue; + } + } + + if (duration_log < -3 // is this possible at all??? + || duration_log > 0) + { + nr->origin ()->warning + (_f ("mensural ligature: duration none of Mx, L, B, S -> skipping")); + primitive->set_property ("primitive", + scm_int2num (MLP_NONE)); + at_beginning = true; + continue; + } + + // apply_transition replacement begins + bool general_case = true; + + // first check special cases + // 1. beginning + if (at_beginning) + { + // a. semibreves + if (duration_log == 0) + { + primitive->set_property ("primitive", + scm_int2num (MLP_UP | MLP_BREVIS)); + prev_semibrevis = prev_brevis_shape = true; + general_case = false; + } + // b. descendens longa or brevis + else if (i < s - 1 + && (unsmob_pitch (primitives[i + 1].music_cause () + ->get_property ("pitch"))->steps () < pitch) + && duration_log > -3) + { + int left_stem = duration_log == -1 ? MLP_DOWN : 0; + + primitive->set_property ("primitive", + scm_int2num (left_stem | MLP_BREVIS)); + prev_brevis_shape = true; + prev_semibrevis = general_case = false; + } + } + // 2. initial semibrevis must be followed by another one + else if (prev_semibrevis) + { + prev_semibrevis = false; + if (duration_log == 0) + { + primitive->set_property ("primitive", scm_int2num (MLP_BREVIS)); + general_case = false; + } + else + { + nr->origin ()->warning + (_f ("semibrevis must be followed by another one -> skipping")); + primitive->set_property ("primitive", + scm_int2num (MLP_NONE)); + at_beginning = true; + continue; + } + } + // 3. semibreves are otherwise not allowed + else if (duration_log == 0) + { + nr->origin ()->warning + (_f ("semibreves can only appear at the beginning of a ligature,\n" + "and there may be only zero or two of them")); + primitive->set_property ("primitive", + scm_int2num (MLP_NONE)); + at_beginning = true; + continue; + } + // 4. end, descendens + else if (i == s - 1 && delta_pitch < 0) + { + // brevis; previous note must be turned into flexa + if (duration_log == -1) + { + if (prev_brevis_shape) + { + prev_primitive->set_property + ("primitive", + scm_int2num + (MLP_FLEXA + | (scm_to_int (prev_primitive->get_property ("primitive")) + & MLP_DOWN))); + primitive->set_property ("primitive", scm_int2num (MLP_NONE)); + break; // no more notes, no join + } + else + { + nr->origin ()->warning + (_f ("invalid ligatura ending:\n" + "when the last note is a descending brevis,\n" + "the penultimate note must be another one,\n" + "or the ligatura must be LB or SSB")); + primitive->set_property ("primitive", scm_int2num (MLP_NONE)); + break; + } + } + // longa + else if (duration_log == -2) + { + primitive->set_property ("primitive", scm_int2num (MLP_BREVIS)); + general_case = false; + } + // else maxima; fall through regular case below + } + + if (general_case) + { + static int const shape[3] = {MLP_MAXIMA, MLP_LONGA, MLP_BREVIS}; + + primitive->set_property ("primitive", + scm_int2num (shape[duration_log + 3])); + prev_brevis_shape = duration_log == -1; + } + + // join_primitives replacement + if (!at_beginning) + { + /* + if the previous note is longa-shaped and this note is lower, + then the joining line may hide the stem, so it is made longer + to serve as stem as well + */ + if (delta_pitch < 0 + && (scm_to_int (prev_primitive->get_property ("primitive")) + & MLP_LONGA)) + { + delta_pitch -= 6; + // instead of number 6 + // the legth of the longa stem should be queried something like + // Font_interface::get_default_font (ligature)->find_by_name + // ("noteheads.s-2mensural").extent (Y_AXIS).length () + } + prev_primitive->set_property ("join-right-amount", + scm_int2num (delta_pitch)); + // perhaps set add-join as well + } + at_beginning = false; + prev_primitive = primitive; + prev_pitch = pitch; + // apply_transition replacement ends + } } /* @@ -295,18 +295,18 @@ void Mensural_ligature_engraver::propagate_properties (Spanner *ligature, Array primitives) { - Real thickness = - robust_scm2double (ligature->get_property ("thickness"), 1.4); - thickness *= - ligature->get_layout ()->get_dimension (ly_symbol2scm ("linethickness")); + Real thickness + = robust_scm2double (ligature->get_property ("thickness"), 1.4); + thickness + *= ligature->get_layout ()->get_dimension (ly_symbol2scm ("linethickness")); - Real head_width = - Font_interface::get_default_font (ligature)-> + Real head_width + = Font_interface::get_default_font (ligature)-> find_by_name ("noteheads.s-1mensural").extent (X_AXIS).length (); - Real flexa_width = - robust_scm2double (ligature->get_property ("flexa-width"), 2); - Real maxima_head_width = - Font_interface::get_default_font (ligature)-> + Real flexa_width + = robust_scm2double (ligature->get_property ("flexa-width"), 2); + Real maxima_head_width + = Font_interface::get_default_font (ligature)-> find_by_name ("noteheads.s-1neomensural").extent (X_AXIS).length (); flexa_width *= Staff_symbol_referencer::staff_space (ligature); @@ -315,35 +315,36 @@ Mensural_ligature_engraver::propagate_properties (Spanner *ligature, for (int i = 0; i < primitives.size (); i++) { - Item *primitive = dynamic_cast (primitives[i].grob_); + Item *primitive = dynamic_cast (primitives[i].grob_); int output = scm_to_int (primitive->get_property ("primitive")); primitive->set_property ("thickness", scm_make_real (thickness)); - switch (output & MLP_ANY) { - case MLP_NONE: - primitive->set_property ("head-width", - scm_make_real (half_flexa_width)); - break; - case MLP_BREVIS: - case MLP_LONGA: - primitive->set_property ("head-width", - scm_make_real (head_width)); - break; - case MLP_MAXIMA: - primitive->set_property ("head-width", - scm_make_real (maxima_head_width)); - break; - case MLP_FLEXA: - primitive->set_property ("head-width", - scm_make_real (half_flexa_width)); - primitive->set_property ("flexa-width", - scm_make_real (flexa_width)); - break; - default: - programming_error (_f ("unexpected case fall-through")); - break; - } + switch (output & MLP_ANY) + { + case MLP_NONE: + primitive->set_property ("head-width", + scm_make_real (half_flexa_width)); + break; + case MLP_BREVIS: + case MLP_LONGA: + primitive->set_property ("head-width", + scm_make_real (head_width)); + break; + case MLP_MAXIMA: + primitive->set_property ("head-width", + scm_make_real (maxima_head_width)); + break; + case MLP_FLEXA: + primitive->set_property ("head-width", + scm_make_real (half_flexa_width)); + primitive->set_property ("flexa-width", + scm_make_real (flexa_width)); + break; + default: + programming_error (_f ("unexpected case fall-through")); + break; + } } } @@ -354,7 +355,7 @@ Mensural_ligature_engraver::fold_up_primitives (Array primitives) Real distance = 0; for (int i = 0; i < primitives.size (); i++) { - Item *current = dynamic_cast (primitives[i].grob_); + Item *current = dynamic_cast (primitives[i].grob_); if (i == 0) { first = current; @@ -367,9 +368,9 @@ Mensural_ligature_engraver::fold_up_primitives (Array primitives) current->translate_axis (distance, X_AXIS); } - distance += - scm_to_double (current->get_property ("head-width")) - - scm_to_double (current->get_property ("thickness")); + distance + += scm_to_double (current->get_property ("head-width")) + - scm_to_double (current->get_property ("thickness")); } } @@ -383,9 +384,9 @@ Mensural_ligature_engraver::build_ligature (Spanner *ligature, } ADD_TRANSLATOR (Mensural_ligature_engraver, -/* descr */ "Handles Mensural_ligature_events by glueing special ligature heads together.", -/* creats*/ "MensuralLigature", -/* accepts */ "ligature-event", -/* acks */ "note-head-interface rest-interface", -/* reads */ "", -/* write */ ""); + /* descr */ "Handles Mensural_ligature_events by glueing special ligature heads together.", + /* creats*/ "MensuralLigature", + /* accepts */ "ligature-event", + /* acks */ "note-head-interface rest-interface", + /* reads */ "", + /* write */ ""); diff --git a/lily/mensural-ligature.cc b/lily/mensural-ligature.cc index 22138e453c..0975ad7358 100644 --- a/lily/mensural-ligature.cc +++ b/lily/mensural-ligature.cc @@ -1,13 +1,12 @@ /* mensural-ligature.cc -- implement Mensural_ligature - + source file of the GNU LilyPond music typesetter - + (c) 2002--2005 Juergen Reuter , - Pal Benko + Pal Benko */ - #include #include "mensural-ligature.hh" @@ -41,33 +40,33 @@ brew_flexa (Grob *me, // and right endings due to slope. Real ypos_correction = -0.1*staff_space * sign (slope); Real slope_correction = 0.2*staff_space * sign (slope); - Real corrected_slope = slope + slope_correction/width; + Real corrected_slope = slope + slope_correction / width; if (solid) // this will come handy for colorated flexae { - Stencil solid_head = - Lookup::beam (corrected_slope, width, height, 0.0); + Stencil solid_head + = Lookup::beam (corrected_slope, width, height, 0.0); stencil.add_stencil (solid_head); } else // outline { - Stencil left_edge = - Lookup::beam (corrected_slope, thickness, height, 0.0); + Stencil left_edge + = Lookup::beam (corrected_slope, thickness, height, 0.0); stencil.add_stencil (left_edge); - Stencil right_edge = - Lookup::beam (corrected_slope, thickness, height, 0.0); - right_edge.translate_axis (width-thickness, X_AXIS); - right_edge.translate_axis (corrected_slope * (width-thickness), Y_AXIS); + Stencil right_edge + = Lookup::beam (corrected_slope, thickness, height, 0.0); + right_edge.translate_axis (width - thickness, X_AXIS); + right_edge.translate_axis (corrected_slope * (width - thickness), Y_AXIS); stencil.add_stencil (right_edge); - Stencil bottom_edge = - Lookup::beam (corrected_slope, width, thickness, 0.0); + Stencil bottom_edge + = Lookup::beam (corrected_slope, width, thickness, 0.0); bottom_edge.translate_axis (-0.5*height, Y_AXIS); stencil.add_stencil (bottom_edge); - Stencil top_edge = - Lookup::beam (corrected_slope, width, thickness, 0.0); + Stencil top_edge + = Lookup::beam (corrected_slope, width, thickness, 0.0); top_edge.translate_axis (+0.5*height, Y_AXIS); stencil.add_stencil (top_edge); } @@ -101,8 +100,8 @@ internal_brew_primitive (Grob *me) { delta_pitch = robust_scm2int (me->get_property ("delta-pitch"), 0); - width = - robust_scm2double (me->get_property ("flexa-width"), 2.0 * staff_space); + width + = robust_scm2double (me->get_property ("flexa-width"), 2.0 * staff_space); } if (primitive & MLP_SINGLE_HEAD) { @@ -134,8 +133,8 @@ internal_brew_primitive (Grob *me) return Stencil (); } - Real blotdiameter = - (me->get_layout ()->get_dimension (ly_symbol2scm ("blotdiameter"))); + Real blotdiameter + = (me->get_layout ()->get_dimension (ly_symbol2scm ("blotdiameter"))); if (primitive & MLP_STEM) { @@ -190,7 +189,7 @@ internal_brew_primitive (Grob *me) if (primitive & MLP_FLEXA) { pos += delta_pitch; - add_ledger_lines(me, &out, pos, 0.5*delta_pitch, ledger_take_space); + add_ledger_lines (me, &out, pos, 0.5*delta_pitch, ledger_take_space); } #endif diff --git a/lily/metronome-engraver.cc b/lily/metronome-engraver.cc index ea9b3893a5..b59d3c962f 100644 --- a/lily/metronome-engraver.cc +++ b/lily/metronome-engraver.cc @@ -15,9 +15,9 @@ #include "context.hh" /** - put stuff over or next to bars. Examples: bar numbers, marginal notes, - rehearsal marks. - */ + put stuff over or next to bars. Examples: bar numbers, marginal notes, + rehearsal marks. +*/ class Metronome_mark_engraver : public Engraver { public: @@ -26,8 +26,8 @@ protected: Item *text_; Grob *bar_line_; Music *mark_ev_; - - void create_items (Music*); + + void create_items (Music *); protected: virtual void stop_translation_timestep (); virtual bool try_music (Music *ev); @@ -40,34 +40,32 @@ Metronome_mark_engraver::Metronome_mark_engraver () mark_ev_ = 0; } -void +void Metronome_mark_engraver::stop_translation_timestep () { if (text_) { - Grob*mc = unsmob_grob (get_property( "currentMusicalColumn")); + Grob *mc = unsmob_grob (get_property ("currentMusicalColumn")); text_->set_parent (mc, X_AXIS); - text_->set_property ("side-support-elements" , get_property ("stavesFound")); - + text_->set_property ("side-support-elements", get_property ("stavesFound")); + text_ = 0; } mark_ev_ = 0; } - void Metronome_mark_engraver::create_items (Music *rq) { if (text_) return; - text_ = make_item ("MetronomeMark", rq->self_scm () ); + text_ = make_item ("MetronomeMark", rq->self_scm ()); } - bool -Metronome_mark_engraver::try_music (Music* r) +Metronome_mark_engraver::try_music (Music *r) { mark_ev_ = r; return true; @@ -82,22 +80,20 @@ Metronome_mark_engraver::process_music () SCM proc = get_property ("metronomeMarkFormatter"); SCM result = scm_call_2 (proc, mark_ev_->self_scm (), - context ()->self_scm ()); - + context ()->self_scm ()); + text_->set_property ("text", result); } } ADD_TRANSLATOR (Metronome_mark_engraver, -/* descr */ "Engrave metro nome marking. This delegates the formatting work " - "to the function in the metronomeMarkFormatter property. " - "The mark is put over all staves. " - "The staves are taken from the @code{stavesFound} property, " - "which is maintained by @code{@ref{Staff_collecting_engraver}}. " - - , -/* creats*/ "MetronomeMark", -/* accepts */ "metronome-change-event", - /* acks */ "", -/* reads */ "stavesFound metronomeMarkFormatter", -/* write */ ""); + /* descr */ "Engrave metro nome marking. This delegates the formatting work " + "to the function in the metronomeMarkFormatter property. " + "The mark is put over all staves. " + "The staves are taken from the @code{stavesFound} property, " + "which is maintained by @code{@ref{Staff_collecting_engraver}}. ", + /* creats*/ "MetronomeMark", + /* accepts */ "metronome-change-event", + /* acks */ "", + /* reads */ "stavesFound metronomeMarkFormatter", + /* write */ ""); diff --git a/lily/midi-def.cc b/lily/midi-def.cc index bc0bc0b4e0..4d712f7ed3 100644 --- a/lily/midi-def.cc +++ b/lily/midi-def.cc @@ -4,7 +4,6 @@ source file of the GNU LilyPond music typesetter (c) 1997--2005 Jan Nieuwenhuizen - */ #include @@ -16,35 +15,35 @@ #include "scm-hash.hh" int -get_tempo (Output_def * def, +get_tempo (Output_def *def, Moment one_beat_mom) { - SCM wis = ly_symbol2scm ("whole-in-seconds"); + SCM wis = ly_symbol2scm ("whole-in-seconds"); Moment *w = unsmob_moment (def->lookup_variable (wis)); Moment wholes_per_min = Moment (60); if (!w) { - programming_error ("wholes-in-seconds not set."); + programming_error ("wholes-in-seconds not set."); wholes_per_min /= 4; } else { - wholes_per_min /= *w; + wholes_per_min /= *w; } - - int beats_per_min = int ((wholes_per_min / one_beat_mom).main_part_); + + int beats_per_min = int ((wholes_per_min / one_beat_mom).main_part_); return int (beats_per_min); } void -set_tempo (Output_def * def, +set_tempo (Output_def *def, Moment one_beat_mom, int beats_per_minute_i) { Moment beats_per_second = Moment (beats_per_minute_i) / Moment (60); - Moment m = Moment (1)/Moment (beats_per_second * one_beat_mom); + Moment m = Moment (1) / Moment (beats_per_second * one_beat_mom); def->set_variable (ly_symbol2scm ("whole-in-seconds"), m.smobbed_copy ()); } diff --git a/lily/midi-item.cc b/lily/midi-item.cc index 60d711e11b..564b5057c0 100644 --- a/lily/midi-item.cc +++ b/lily/midi-item.cc @@ -4,7 +4,7 @@ source file of the GNU LilyPond music typesetter (c) 1997--2005 Jan Nieuwenhuizen - */ +*/ #include "midi-item.hh" @@ -17,29 +17,29 @@ #include "scm-option.hh" #include "killing-cons.tcc" -#define PITCH_WHEEL_TOP 0x3FFF +#define PITCH_WHEEL_TOP 0x3FFF #define PITCH_WHEEL_CENTER 0x2000 #define PITCH_WHEEL_BOTTOM 0x0000 -#define PITCH_WHEEL_RANGE (PITCH_WHEEL_TOP - PITCH_WHEEL_BOTTOM) +#define PITCH_WHEEL_RANGE (PITCH_WHEEL_TOP - PITCH_WHEEL_BOTTOM) -Midi_item* -Midi_item::get_midi (Audio_item* a) +Midi_item * +Midi_item::get_midi (Audio_item *a) { - if (Audio_key* i = dynamic_cast (a)) + if (Audio_key *i = dynamic_cast (a)) return new Midi_key (i); - else if (Audio_instrument* i = dynamic_cast (a)) + else if (Audio_instrument *i = dynamic_cast (a)) return i->str_.length () ? new Midi_instrument (i) : 0; - else if (Audio_note* i = dynamic_cast (a)) + else if (Audio_note *i = dynamic_cast (a)) return new Midi_note (i); - else if (Audio_dynamic* i = dynamic_cast (a)) + else if (Audio_dynamic *i = dynamic_cast (a)) return new Midi_dynamic (i); - else if (Audio_piano_pedal* i = dynamic_cast (a)) + else if (Audio_piano_pedal *i = dynamic_cast (a)) return new Midi_piano_pedal (i); - else if (Audio_tempo* i = dynamic_cast (a)) + else if (Audio_tempo *i = dynamic_cast (a)) return new Midi_tempo (i); - else if (Audio_time_signature* i = dynamic_cast (a)) + else if (Audio_time_signature *i = dynamic_cast (a)) return new Midi_time_signature (i); - else if (Audio_text* i = dynamic_cast (a)) + else if (Audio_text *i = dynamic_cast (a)) //return i->text_string_.length () ? new Midi_text (i) : 0; return new Midi_text (i); else @@ -56,7 +56,7 @@ Midi_chunk::set (String header_string, String data_string, String footer_string) footer_string_ = footer_string; header_string_ = header_string; } - + String Midi_chunk::data_string () const { @@ -68,8 +68,8 @@ Midi_chunk::to_string () const { String str = header_string_; String dat = data_string (); - String length_string = String_convert::int2hex (dat.length () - + footer_string_.length (), 8, '0'); + String length_string = String_convert::int2hex (dat.length () + + footer_string_.length (), 8, '0'); length_string = String_convert::hex2bin (length_string); str += length_string; str += dat; @@ -88,7 +88,7 @@ Midi_duration::to_string () const return String (""; } -Midi_event::Midi_event (Moment delta_mom, Midi_item* midi) +Midi_event::Midi_event (Moment delta_mom, Midi_item *midi) { delta_mom_ = delta_mom; midi_ = midi; @@ -96,12 +96,12 @@ Midi_event::Midi_event (Moment delta_mom, Midi_item* midi) /* ugh. midi output badly broken since grace note hackage. - */ +*/ String Midi_event::to_string () const { - Rational rat_dt = (delta_mom_.main_part_ * Rational (384) + - delta_mom_.grace_part_ * Rational (100))*Rational (4); + Rational rat_dt = (delta_mom_.main_part_ * Rational (384) + + delta_mom_.grace_part_ * Rational (100))*Rational (4); int delta_i = int (rat_dt); String delta_string = Midi_item::i2varint_string (delta_i); @@ -110,11 +110,10 @@ Midi_event::to_string () const return delta_string + midi_string; } - Midi_header::Midi_header (int format_i, int tracks_i, int clocks_per_4_i) { String str; - + String format_string = String_convert::int2hex (format_i, 4, '0'); str += String_convert::hex2bin (format_string); @@ -127,7 +126,7 @@ Midi_header::Midi_header (int format_i, int tracks_i, int clocks_per_4_i) set ("MThd", str, ""); } -Midi_instrument::Midi_instrument (Audio_instrument* a) +Midi_instrument::Midi_instrument (Audio_instrument *a) { audio_ = a; audio_->str_.to_lower (); @@ -141,14 +140,14 @@ Midi_instrument::to_string () const /* UGH. don't use eval. - */ + */ SCM proc = ly_lily_module_constant ("midi-program"); SCM program = scm_call_1 (proc, ly_symbol2scm (audio_->str_.to_str0 ())); found = (program != SCM_BOOL_F); if (found) program_byte = scm_to_int (program); else - warning (_f ("no such MIDI instrument: `%s'", audio_->str_.to_str0 ())); + warning (_f ("no such MIDI instrument: `%s'", audio_->str_.to_str0 ())); String str = ::to_string ((char) (0xc0 + channel_)); //YIKES! FIXME: Should be track. -rz str += ::to_string ((char)program_byte); @@ -168,7 +167,7 @@ String Midi_item::i2varint_string (int i) { int buffer_i = i & 0x7f; - while ((i >>= 7) > 0) + while ((i >>= 7) > 0) { buffer_i <<= 8; buffer_i |= 0x80; @@ -176,7 +175,7 @@ Midi_item::i2varint_string (int i) } String str; - while (1) + while (1) { str += ::to_string ((char)buffer_i); if (buffer_i & 0x80) @@ -187,7 +186,7 @@ Midi_item::i2varint_string (int i) return str; } -Midi_key::Midi_key (Audio_key*a) +Midi_key::Midi_key (Audio_key *a) { audio_ = a; } @@ -254,7 +253,7 @@ Midi_note::get_pitch () const { warning (_ ("silly pitch")); p = 0; - } + } return p; } @@ -268,13 +267,13 @@ Midi_note::to_string () const // print warning if fine tuning was needed, HJJ if (get_fine_tuning () != 0) { - warning (_f ("Experimental: temporarily fine tuning (of %d cents) a channel.", - get_fine_tuning ())); + warning (_f ("Experimental: temporarily fine tuning (of %d cents) a channel.", + get_fine_tuning ())); finetune = PITCH_WHEEL_CENTER; // Move pitch wheel to a shifted position. // The pitch wheel range (of 4 semitones) is multiplied by the cents. - finetune += (PITCH_WHEEL_RANGE * get_fine_tuning ()) / (4 * 100); + finetune += (PITCH_WHEEL_RANGE *get_fine_tuning ()) / (4 * 100); str += ::to_string ((char) (0xE0 + channel_)); str += ::to_string ((char) (finetune & 0x7F)); @@ -289,7 +288,7 @@ Midi_note::to_string () const return str; } -Midi_note_off::Midi_note_off (Midi_note* n) +Midi_note_off::Midi_note_off (Midi_note *n) : Midi_note (n->audio_) { on_ = n; @@ -298,7 +297,7 @@ Midi_note_off::Midi_note_off (Midi_note* n) // Anybody who hears any difference, or knows how this works? // 0 should definitely be avoided, notes stick on some sound cards. // 64 is supposed to be neutral - + aftertouch_byte_ = 64; } @@ -316,14 +315,14 @@ Midi_note_off::to_string () const // Move pitch wheel back to the central position. str += ::to_string ((char) 0x00); str += ::to_string ((char) (0xE0 + channel_)); - str += ::to_string ((char) (PITCH_WHEEL_CENTER & 0x7F)); + str += ::to_string ((char) (PITCH_WHEEL_CENTER &0x7F)); str += ::to_string ((char) (PITCH_WHEEL_CENTER >> 7)); } return str; } -Midi_dynamic::Midi_dynamic (Audio_dynamic* a) +Midi_dynamic::Midi_dynamic (Audio_dynamic *a) { audio_ = a; } @@ -338,9 +337,9 @@ Midi_dynamic::to_string () const Main volume controller (per channel): 07 MSB 27 LSB - */ + */ static Real const full_scale = 127; - + int volume = (int) (audio_->volume_*full_scale); if (volume <= 0) volume = 1; @@ -352,7 +351,7 @@ Midi_dynamic::to_string () const return str; } -Midi_piano_pedal::Midi_piano_pedal (Audio_piano_pedal* a) +Midi_piano_pedal::Midi_piano_pedal (Audio_piano_pedal *a) { audio_ = a; } @@ -375,7 +374,7 @@ Midi_piano_pedal::to_string () const return str; } -Midi_tempo::Midi_tempo (Audio_tempo* a) +Midi_tempo::Midi_tempo (Audio_tempo *a) { audio_ = a; } @@ -411,19 +410,19 @@ Midi_track::Midi_track () // 00 00 00 3B chunk length (59) // 00 FF 58 04 04 02 18 08 time signature // 00 FF 51 03 07 A1 20 tempo - -// FF 59 02 sf mi Key Signature -// sf = -7: 7 flats -// sf = -1: 1 flat -// sf = 0: key of C -// sf = 1: 1 sharp -// sf = 7: 7 sharps -// mi = 0: major key -// mi = 1: minor key + + // FF 59 02 sf mi Key Signature + // sf = -7: 7 flats + // sf = -1: 1 flat + // sf = 0: key of C + // sf = 1: 1 sharp + // sf = 7: 7 sharps + // mi = 0: major key + // mi = 1: minor key number_ = 0; - - char const* data_str0 = "" + + char const *data_str0 = "" // "00" "ff58" "0404" "0218" "08" // "00" "ff51" "0307" "a120" // why a key at all, in midi? @@ -431,24 +430,24 @@ Midi_track::Midi_track () // "00" "ff59" "02" "00" "00" // key: F (scsii-menuetto) // "00" "ff59" "02" "ff" "00" - ; + ; String data_string; // only for format 0 (currently using format 1)? data_string += String_convert::hex2bin (data_str0); - char const* footer_str0 = "00" "ff2f" "00"; + char const *footer_str0 = "00" "ff2f" "00"; String footer_string = String_convert::hex2bin (footer_str0); set ("MTrk", data_string, footer_string); } -void -Midi_track::add (Moment delta_time_mom, Midi_item* midi) +void +Midi_track::add (Moment delta_time_mom, Midi_item *midi) { assert (delta_time_mom >= Moment (0)); - Midi_event * e = new Midi_event (delta_time_mom, midi); + Midi_event *e = new Midi_event (delta_time_mom, midi); event_p_list_.append (new Killing_cons (e, 0)); } @@ -458,11 +457,11 @@ Midi_track::data_string () const String str = Midi_chunk::data_string (); if (midi_debug_global_b) str += "\n"; - for (Cons *i = event_p_list_.head_; i; i = i->next_) + for (Cons *i = event_p_list_.head_; i; i = i->next_) { str += i->car_->to_string (); if (midi_debug_global_b) - str += "\n"; + str += "\n"; } return str; } diff --git a/lily/midi-stream.cc b/lily/midi-stream.cc index bd385c0a4c..aa1619e2c4 100644 --- a/lily/midi-stream.cc +++ b/lily/midi-stream.cc @@ -19,7 +19,7 @@ Midi_stream::Midi_stream (String file_name) { file_name_string_ = file_name; - out_file_ = fopen (file_name.to_str0(), "wb"); + out_file_ = fopen (file_name.to_str0 (), "wb"); } Midi_stream::~Midi_stream () @@ -27,8 +27,8 @@ Midi_stream::~Midi_stream () fclose (out_file_); } -Midi_stream& -Midi_stream::operator << (String str) +Midi_stream & +Midi_stream::operator<< (String str) { size_t sz = sizeof (Byte); size_t n = str.length (); @@ -41,8 +41,8 @@ Midi_stream::operator << (String str) return *this; } -Midi_stream& -Midi_stream::operator << (Midi_item const& midi_c_r) +Midi_stream & +Midi_stream::operator<< (Midi_item const &midi_c_r) { String str = midi_c_r.to_string (); diff --git a/lily/midi-walker.cc b/lily/midi-walker.cc index 744230b36b..1223133d13 100644 --- a/lily/midi-walker.cc +++ b/lily/midi-walker.cc @@ -4,8 +4,8 @@ source file of the GNU LilyPond music typesetter (c) 1997--2005 Han-Wen Nienhuys - Jan Nieuwenhuizen - */ + Jan Nieuwenhuizen +*/ #include "midi-walker.hh" @@ -15,17 +15,17 @@ #include "midi-stream.hh" #include "warn.hh" -Midi_note_event::Midi_note_event () -{ +Midi_note_event::Midi_note_event () +{ ignore_b_ = false; } int -compare (Midi_note_event const& left, Midi_note_event const& right) +compare (Midi_note_event const &left, Midi_note_event const &right) { - Moment m = (left.key - right.key); + Moment m = (left.key - right.key); - if (m<0) + if (m < 0) return -1; else if (m > 0) return 1; @@ -33,7 +33,7 @@ compare (Midi_note_event const& left, Midi_note_event const& right) return 0; } -Midi_walker::Midi_walker (Audio_staff* audio_staff, Midi_track* track) +Midi_walker::Midi_walker (Audio_staff *audio_staff, Midi_track *track) { track_ = track; index_ = 0; @@ -43,30 +43,30 @@ Midi_walker::Midi_walker (Audio_staff* audio_staff, Midi_track* track) } Midi_walker::~Midi_walker () -{ +{ // ugh do_stop_notes (last_mom_ + Moment (Rational (10, 1))); } /** - Find out if start_note event is needed, and do it if needed. - */ -void -Midi_walker::do_start_note (Midi_note* note) + Find out if start_note event is needed, and do it if needed. +*/ +void +Midi_walker::do_start_note (Midi_note *note) { - Audio_item* ptr = (*items_)[index_]; + Audio_item *ptr = (*items_)[index_]; Moment stop_mom = note->get_length () + ptr->audio_column_->at_mom (); bool play_start = true; - for (int i = 0; i < stop_note_queue.size (); i++) + for (int i = 0; i < stop_note_queue.size (); i++) { /* if this pith already in queue */ - if (stop_note_queue[i].val->get_pitch () == note->get_pitch ()) + if (stop_note_queue[i].val->get_pitch () == note->get_pitch ()) { if (stop_note_queue[i].key < stop_mom) { /* let stopnote in queue be ignored, - new stop note wins */ + new stop note wins */ stop_note_queue[i].ignore_b_ = true; /* don't replay start note, */ play_start = false; @@ -79,7 +79,7 @@ Midi_walker::do_start_note (Midi_note* note) delete note; note = 0; break; - } + } } } @@ -96,12 +96,12 @@ Midi_walker::do_start_note (Midi_note* note) } /** - Output note events for all notes which end before #max_mom# - */ + Output note events for all notes which end before #max_mom# +*/ void Midi_walker::do_stop_notes (Moment max_mom) { - while (stop_note_queue.size () && stop_note_queue.front ().key <= max_mom) + while (stop_note_queue.size () && stop_note_queue.front ().key <= max_mom) { Midi_note_event e = stop_note_queue.get (); if (e.ignore_b_) @@ -109,47 +109,46 @@ Midi_walker::do_stop_notes (Moment max_mom) delete e.val; continue; } - + Moment stop_mom = e.key; - Midi_note* note = e.val; - + Midi_note *note = e.val; + output_event (stop_mom, note); } } -/** - Advance the track to #now#, output the item, and adjust current "moment". - */ +/** + Advance the track to #now#, output the item, and adjust current "moment". +*/ void -Midi_walker::output_event (Moment now_mom, Midi_item* l) +Midi_walker::output_event (Moment now_mom, Midi_item *l) { - Moment delta_t = now_mom - last_mom_ ; + Moment delta_t = now_mom - last_mom_; last_mom_ = now_mom; /* this is not correct, but at least it doesn't crash when you start with graces - */ + */ if (delta_t < Moment (0)) { delta_t = Moment (0); } - track_->add (delta_t, l); } void Midi_walker::process () { - Audio_item* audio = (*items_)[index_]; + Audio_item *audio = (*items_)[index_]; do_stop_notes (audio->audio_column_->at_mom ()); - if (Midi_item* midi = Midi_item::get_midi (audio)) + if (Midi_item *midi = Midi_item::get_midi (audio)) { midi->channel_ = track_->channel_; //midi->channel_ = track_->number_; - if (Midi_note* note = dynamic_cast (midi)) + if (Midi_note *note = dynamic_cast (midi)) { if (note->get_length ().to_bool ()) do_start_note (note); @@ -166,7 +165,7 @@ Midi_walker::ok () const } void -Midi_walker::operator ++ (int) +Midi_walker::operator++ (int) { assert (ok ()); index_++; diff --git a/lily/misc.cc b/lily/misc.cc index 7199cac197..0d1144ec13 100644 --- a/lily/misc.cc +++ b/lily/misc.cc @@ -4,7 +4,7 @@ source file of the GNU LilyPond music typesetter (c) 1997--2005 Han-Wen Nienhuys - Jan Nieuwenhuizen + Jan Nieuwenhuizen */ #include @@ -12,47 +12,46 @@ #include "misc.hh" #include "string.hh" - /* - Return the 2-log, rounded down - */ + Return the 2-log, rounded down +*/ int intlog2 (int d) { assert (d); int i = 0; - while ((d != 1)) + while ((d != 1)) { d /= 2; i++; } - - assert (! (d/2)); + + assert (! (d / 2)); return i; } double log_2 (double x) { - return log (x) /log (2.0); + return log (x) /log (2.0); } Array split_string (String s, char c) { - Array rv; + Array rv; while (s.length ()) { int i = s.index (c); - + if (i == 0) { s = s.nomid_string (0, 1); continue; } - + if (i < 0) - i = s.length () ; + i = s.length (); rv.push (s.cut_string (0, i)); s = s.nomid_string (0, i); diff --git a/lily/modified-font-metric.cc b/lily/modified-font-metric.cc index 79ff5ea2f1..3218a0ae8b 100644 --- a/lily/modified-font-metric.cc +++ b/lily/modified-font-metric.cc @@ -1,8 +1,8 @@ /* modified-font-metric.cc -- declare Modified_font_metric - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys */ #include @@ -19,12 +19,12 @@ Modified_font_metric::Modified_font_metric (Font_metric *fm, Real magnification) { magnification_ = magnification; - + SCM desc = fm->description_; Real total_mag = magnification * scm_to_double (scm_cdr (desc)); assert (total_mag); - + description_ = scm_cons (scm_car (desc), scm_make_real (total_mag)); orig_ = fm; } @@ -42,21 +42,20 @@ Modified_font_metric::design_size () const return orig_->design_size (); } - -Box +Box Modified_font_metric::get_indexed_char (int i) const { Box b = orig_->get_indexed_char (i); b.scale (magnification_); - return b; + return b; } -Box +Box Modified_font_metric::get_ascii_char (int i) const { Box b = orig_->get_ascii_char (i); b.scale (magnification_); - return b; + return b; } int @@ -102,30 +101,30 @@ Modified_font_metric::derived_mark () const { } -/* TODO: put this klutchness behind ly:option switch. */ +/* TODO: put this klutchness behind ly:option switch. */ Box Modified_font_metric::tex_kludge (String text) const { Interval ydims; Real w = 0; - for (int i = 0; i < text.length (); i++) + for (int i = 0; i < text.length (); i++) { - switch (text[i]) + switch (text[i]) { case '\\': /* Accent marks use width of base letter */ - if (i +1 < text.length ()) - { - if (text[i+1]=='\'' || text[i+1]=='`' || text[i+1]=='"' - || text[i+1]=='^') - { - i++; - break; - } - /* For string width \\ is a \ and \_ is a _. */ - if (text[i+1]=='\\' || text[i+1]=='_') - break; - } + if (i +1 < text.length ()) + { + if (text[i + 1]=='\'' || text[i + 1]=='`' || text[i+1]=='"' + || text[i+1]=='^') + { + i++; + break; + } + /* For string width \\ is a \ and \_ is a _. */ + if (text[i + 1]=='\\' || text[i+1]=='_') + break; + } for (i++; (i < text.length ()) && !isspace (text[i]) && text[i]!='{' && text[i]!='}'; i++) @@ -143,7 +142,7 @@ Modified_font_metric::tex_kludge (String text) const Box b = get_ascii_char ((unsigned char)text[i]); /* Use the width of 'x' for unknown characters */ - if (b[X_AXIS].length () == 0) + if (b[X_AXIS].length () == 0) b = get_ascii_char ((unsigned char)'x'); w += b[X_AXIS].length (); @@ -197,21 +196,21 @@ Modified_font_metric::text_dimension (String text) const Real w = 0.0; - for (int i = 0; i < text.length (); i++) + for (int i = 0; i < text.length (); i++) { Box b = get_ascii_char ((unsigned char)text[i]); - + w += b[X_AXIS].length (); - ydims.unite (b[Y_AXIS]); + ydims.unite (b[Y_AXIS]); } if (ydims.is_empty ()) ydims = Interval (0, 0); - b = Box(Interval(0, w), ydims); + b = Box (Interval (0, w), ydims); return b; } -Font_metric* +Font_metric * Modified_font_metric::original_font () const { return orig_; @@ -220,11 +219,11 @@ Modified_font_metric::original_font () const SCM Modified_font_metric::sub_fonts () const { - return orig_->sub_fonts(); + return orig_->sub_fonts (); } - + String Modified_font_metric::font_name () const { - return original_font ()->font_name(); + return original_font ()->font_name (); } diff --git a/lily/moment-scheme.cc b/lily/moment-scheme.cc index a9ba114ed8..865431c6da 100644 --- a/lily/moment-scheme.cc +++ b/lily/moment-scheme.cc @@ -1,4 +1,4 @@ -/* +/* moment.cc -- implement Moment bindings source file of the GNU LilyPond music typesetter @@ -8,7 +8,6 @@ #include "moment.hh" - /* TODO: add optional factor argument. */ LY_DEFINE (ly_make_moment, "ly:make-moment", 2, 2, 0, (SCM n, SCM d, SCM gn, SCM gd), @@ -83,7 +82,7 @@ LY_DEFINE (ly_moment_main_numerator, "ly:moment-main-numerator", Moment *ma = unsmob_moment (mom); SCM_ASSERT_TYPE (ma, mom, SCM_ARG1, __FUNCTION__, "moment"); - return scm_from_int (ma->main_part_.numerator ()); + return scm_from_int (ma->main_part_.numerator ()); } LY_DEFINE (ly_moment_main_denominator, "ly:moment-main-denominator", @@ -93,7 +92,7 @@ LY_DEFINE (ly_moment_main_denominator, "ly:moment-main-denominator", Moment *ma = unsmob_moment (mom); SCM_ASSERT_TYPE (ma, mom, SCM_ARG1, __FUNCTION__, "moment"); - return scm_from_int (ma->main_part_.denominator ()); + return scm_from_int (ma->main_part_.denominator ()); } LY_DEFINE (ly_moment_less_p, "ly:momentto_string (); scm_puts ((char *)str.to_str0 (), port); scm_puts (">", port); - + return 1; } @@ -59,19 +59,18 @@ SCM Moment::as_scheme () const { return scm_list_5 (ly_symbol2scm ("ly:make-moment"), - scm_from_int (main_part_.num()), - scm_from_int (main_part_.den()), - scm_from_int (grace_part_.num()), - scm_from_int (grace_part_.den())); + scm_from_int (main_part_.num ()), + scm_from_int (main_part_.den ()), + scm_from_int (grace_part_.num ()), + scm_from_int (grace_part_.den ())); } - SCM Moment::equal_p (SCM a, SCM b) { Moment *m1 = unsmob_moment (a); Moment *m2 = unsmob_moment (b); - + return (*m1 == *m2) ? SCM_BOOL_T : SCM_BOOL_F; } @@ -92,15 +91,15 @@ Moment::compare (Moment const &a, Moment const &b) } void -Moment::operator += (Moment const &src) +Moment::operator+= (Moment const &src) { - main_part_ += src.main_part_ ; + main_part_ += src.main_part_; grace_part_ += src.grace_part_; } void -Moment::operator -= (Moment const &src) +Moment::operator-= (Moment const &src) { - main_part_ -= src.main_part_ ; + main_part_ -= src.main_part_; grace_part_ -= src.grace_part_; } @@ -108,9 +107,9 @@ Moment::operator -= (Moment const &src) only take the main part of SRC for multiplication. */ void -Moment::operator *= (Moment const &src) +Moment::operator*= (Moment const &src) { - main_part_ *= src.main_part_ ; + main_part_ *= src.main_part_; grace_part_ *= src.main_part_; } @@ -118,9 +117,9 @@ Moment::operator *= (Moment const &src) only take the main part of SRC for multiplication. */ void -Moment::operator /= (Moment const &src) +Moment::operator/= (Moment const &src) { - main_part_ /= src.main_part_ ; + main_part_ /= src.main_part_; grace_part_ /= src.main_part_; } @@ -151,7 +150,7 @@ Moment::set_infinite (int k) String Moment::to_string () const { - String s = main_part_.to_string (); + String s = main_part_.to_string (); if (grace_part_) { s += "G" + grace_part_.to_string (); @@ -160,18 +159,17 @@ Moment::to_string () const } Moment -Moment::operator - () const +Moment::operator- () const { Moment m; - m.grace_part_ = - grace_part_; - m. main_part_ = - main_part_ ; + m.grace_part_ = -grace_part_; + m. main_part_ = -main_part_; return m; } - #ifdef STREAM_SUPPORT std::ostream & -operator << (std::ostream &os, Moment const &m) +operator<< (std::ostream &os, Moment const &m) { os << m.to_string (); return os; @@ -188,7 +186,6 @@ robust_scm2moment (SCM m, Moment d) return *p; } - bool moment_less (SCM a, SCM b) { diff --git a/lily/multi-measure-rest-engraver.cc b/lily/multi-measure-rest-engraver.cc index ab27e6cd06..a078e4db1e 100644 --- a/lily/multi-measure-rest-engraver.cc +++ b/lily/multi-measure-rest-engraver.cc @@ -2,7 +2,7 @@ multi_measure_rest-engraver.cc -- implement Multi_measure_rest_engraver (c) 1998--2005 Jan Nieuwenhuizen - Han-Wen Nienhuys + Han-Wen Nienhuys */ #include "multi-measure-rest.hh" @@ -13,7 +13,7 @@ #include "moment.hh" /** - The name says it all: make multi measure rests + The name says it all: make multi measure rests */ class Multi_measure_rest_engraver : public Engraver { @@ -21,21 +21,21 @@ public: TRANSLATOR_DECLARATIONS (Multi_measure_rest_engraver); protected: - virtual bool try_music (Music*); + virtual bool try_music (Music *); virtual void process_music (); virtual void stop_translation_timestep (); virtual void start_translation_timestep (); virtual void finalize (); private: - Music * rest_ev_; + Music *rest_ev_; Link_array text_events_; int start_measure_; Rational last_main_moment_; Moment stop_moment_; - + bool bar_seen_; - Item *last_command_item_ ; + Item *last_command_item_; Spanner *last_rest_; Spanner *mmrest_; @@ -54,13 +54,13 @@ Multi_measure_rest_engraver::Multi_measure_rest_engraver () } bool -Multi_measure_rest_engraver::try_music (Music* req) +Multi_measure_rest_engraver::try_music (Music *req) { if (req->is_mus_type ("multi-measure-rest-event")) { rest_ev_ = req; stop_moment_ = now_mom () + rest_ev_->get_length (); - + return true; } else if (req->is_mus_type ("multi-measure-text-event")) @@ -80,7 +80,7 @@ Multi_measure_rest_engraver::process_music () mmrest_ = make_spanner ("MultiMeasureRest", rest_ev_->self_scm ()); Spanner *sp - = make_spanner ("MultiMeasureRestNumber", rest_ev_->self_scm () ); + = make_spanner ("MultiMeasureRestNumber", rest_ev_->self_scm ()); numbers_.push (sp); if (text_events_.size ()) @@ -88,42 +88,45 @@ Multi_measure_rest_engraver::process_music () for (int i = 0; i < text_events_.size (); i++) { - Music* e = text_events_[i]; + Music *e = text_events_[i]; Spanner *sp - = make_spanner ("MultiMeasureRestText", e->self_scm () ); + = make_spanner ("MultiMeasureRestText", e->self_scm ()); SCM t = e->get_property ("text"); SCM dir = e->get_property ("direction"); sp->set_property ("text", t); if (is_direction (dir)) sp->set_property ("direction", dir); - + numbers_.push (sp); } /* Stack different scripts. - */ - Direction d = DOWN; - do { - Grob *last = 0; - for (int i = 0; i get_property ("direction")) - { - if (last) - Side_position_interface::add_support (numbers_[i], last); - last = numbers_[i]; - } - } - } while (flip (&d) != DOWN); + */ + Direction d = DOWN; + do + { + Grob *last = 0; + for (int i = 0; i get_property ("direction")) + { + if (last) + Side_position_interface::add_support (numbers_[i], last); + last = numbers_[i]; + } + } + } + while (flip (&d) != DOWN); + } - for (int i = 0 ; i < numbers_.size (); i++) + for (int i = 0; i < numbers_.size (); i++) { Side_position_interface::add_support (numbers_[i], mmrest_); numbers_[i]->set_parent (mmrest_, Y_AXIS); } - + start_measure_ = scm_to_int (get_property ("currentBarNumber")); } @@ -137,7 +140,7 @@ Multi_measure_rest_engraver::stop_translation_timestep () /* We can not do this earlier, as breakableSeparationItem is not yet there. */ - + if (bar_seen_) { Grob *cmc = unsmob_grob (get_property ("breakableSeparationItem")); @@ -146,11 +149,11 @@ Multi_measure_rest_engraver::stop_translation_timestep () /* Ugh, this is a kludge - need this for multi-measure-rest-grace.ly - */ - last_command_item_ = dynamic_cast (cmc); + */ + last_command_item_ = dynamic_cast (cmc); } - if (last_command_item_ && (mmrest_ || last_rest_)) + if (last_command_item_ && (mmrest_ || last_rest_)) { if (last_rest_) { @@ -168,8 +171,8 @@ Multi_measure_rest_engraver::stop_translation_timestep () last_command_item_ = 0; } } - - Moment mp(robust_scm2moment (get_property ("measurePosition"), Moment (0))); + + Moment mp (robust_scm2moment (get_property ("measurePosition"), Moment (0))); if (last_rest_) { last_rest_ = 0; @@ -189,7 +192,7 @@ Multi_measure_rest_engraver::start_translation_timestep () bar_seen_ = false; - Moment mp (robust_scm2moment (get_property ("measurePosition"), Moment (0))); + Moment mp (robust_scm2moment (get_property ("measurePosition"), Moment (0))); Moment now = now_mom (); if (mmrest_ @@ -198,7 +201,7 @@ Multi_measure_rest_engraver::start_translation_timestep () { last_rest_ = mmrest_; last_numbers_ = numbers_; - + int cur = scm_to_int (get_property ("currentBarNumber")); int num = cur - start_measure_; @@ -217,18 +220,18 @@ Multi_measure_rest_engraver::start_translation_timestep () mmrest_ = 0; numbers_.clear (); - - Grob * last = last_numbers_.size () ? last_numbers_[0] : 0; + + Grob *last = last_numbers_.size () ? last_numbers_[0] : 0; if (last && last->get_property ("text") == SCM_EOL) { SCM thres = get_property ("restNumberThreshold"); int t = 1; if (scm_is_number (thres)) t = scm_to_int (thres); - + if (num <= t) last->suicide (); - else + else { SCM text = scm_number_to_string (scm_int2num (num), scm_from_int (10)); @@ -246,14 +249,13 @@ Multi_measure_rest_engraver::finalize () } ADD_TRANSLATOR (Multi_measure_rest_engraver, -/* descr */ - "Engraves multi-measure rests that are produced with @code{R}. Reads " -"measurePosition and currentBarNumber to determine what number to print " -"over the MultiMeasureRest. Reads measureLength to determine if it " -"should use a whole rest or a breve rest to represent 1 measure " - , -/* creats*/ "MultiMeasureRest MultiMeasureRestNumber MultiMeasureRestText", -/* accepts */ "multi-measure-rest-event multi-measure-text-event", -/* acks */ "", -/* reads */ "currentBarNumber restNumberThreshold breakableSeparationItem currentCommandColumn measurePosition measureLength", -/* write */ ""); + /* descr */ + "Engraves multi-measure rests that are produced with @code{R}. Reads " + "measurePosition and currentBarNumber to determine what number to print " + "over the MultiMeasureRest. Reads measureLength to determine if it " + "should use a whole rest or a breve rest to represent 1 measure ", + /* creats*/ "MultiMeasureRest MultiMeasureRestNumber MultiMeasureRestText", + /* accepts */ "multi-measure-rest-event multi-measure-text-event", + /* acks */ "", + /* reads */ "currentBarNumber restNumberThreshold breakableSeparationItem currentCommandColumn measurePosition measureLength", + /* write */ ""); diff --git a/lily/multi-measure-rest.cc b/lily/multi-measure-rest.cc index f2298a92de..1cc6d2b031 100644 --- a/lily/multi-measure-rest.cc +++ b/lily/multi-measure-rest.cc @@ -1,11 +1,10 @@ -/* +/* multi-measure-rest.cc -- implement Multi_measure_rest - + source file of the GNU LilyPond music typesetter - + (c) 1998--2005 Jan Nieuwenhuizen - - */ +*/ #include "multi-measure-rest.hh" @@ -27,49 +26,48 @@ SCM Multi_measure_rest::percent (SCM smob) { Grob *me = unsmob_grob (smob); - Spanner *sp = dynamic_cast (me); - - Stencil r = Percent_repeat_item_interface::x_percent (me, 1, 0.75, 1.6); + Spanner *sp = dynamic_cast (me); + + Stencil r = Percent_repeat_item_interface::x_percent (me, 1, 0.75, 1.6); // ugh copy & paste. - + Interval sp_iv; Direction d = LEFT; do { - Item * col = sp->get_bound (d)->get_column (); + Item *col = sp->get_bound (d)->get_column (); Interval coldim = col->extent (0, X_AXIS); - sp_iv[d] = coldim[-d] ; + sp_iv[d] = coldim[-d]; } while ((flip (&d)) != LEFT); Real x_off = 0.0; - Real rx = sp->get_bound (LEFT)->relative_coordinate (0, X_AXIS); + Real rx = sp->get_bound (LEFT)->relative_coordinate (0, X_AXIS); /* we gotta stay clear of sp_iv, so move a bit to the right if needed. - */ - x_off += (sp_iv[LEFT] - rx) >? 0; + */ + x_off += (sp_iv[LEFT] - rx) >? 0; /* center between stuff. - */ + */ x_off += sp_iv.length ()/ 2; r.translate_axis (x_off, X_AXIS); - return r.smobbed_copy (); } MAKE_SCHEME_CALLBACK (Multi_measure_rest, print, 1); SCM -Multi_measure_rest::print (SCM smob) +Multi_measure_rest::print (SCM smob) { Grob *me = unsmob_grob (smob); - Spanner * sp = dynamic_cast (me); + Spanner *sp = dynamic_cast (me); Interval sp_iv; Direction d = LEFT; @@ -77,25 +75,24 @@ Multi_measure_rest::print (SCM smob) Grob *common = sp->get_bound (LEFT)->common_refpoint (sp->get_bound (RIGHT), X_AXIS); do { - Item * b = sp->get_bound (d); + Item *b = sp->get_bound (d); - Interval coldim = (Separation_item::has_interface (b)) + Interval coldim = (Separation_item::has_interface (b)) ? Separation_item::relative_width (b, common) : b->extent (common, X_AXIS); - sp_iv[d] = coldim.is_empty () ? b->relative_coordinate (common, X_AXIS) : coldim[-d]; + sp_iv[d] = coldim.is_empty () ? b->relative_coordinate (common, X_AXIS) : coldim[-d]; } while ((flip (&d)) != LEFT); Real space = sp_iv.length (); - Real rx = sp->get_bound (LEFT)->relative_coordinate (0, X_AXIS); + Real rx = sp->get_bound (LEFT)->relative_coordinate (0, X_AXIS); /* we gotta stay clear of sp_iv, so move a bit to the right if needed. - */ - Real x_off = (sp_iv[LEFT] - rx) >? 0; - + */ + Real x_off = (sp_iv[LEFT] - rx) >? 0; Stencil mol; mol.add_stencil (symbol_stencil (me, space)); @@ -111,8 +108,6 @@ Multi_measure_rest::print (SCM smob) return mol.smobbed_copy (); } - - Stencil Multi_measure_rest::symbol_stencil (Grob *me, Real space) { @@ -124,14 +119,13 @@ Multi_measure_rest::symbol_stencil (Grob *me, Real space) } if (measures <= 0) return Stencil (); - SCM limit = me->get_property ("expand-limit"); if (measures > scm_to_int (limit)) { - Real padding = 0.15; - Stencil s = big_rest (me, (1.0 - 2*padding) * space); - s.translate_axis (padding * space, X_AXIS); + Real padding = 0.15; + Stencil s = big_rest (me, (1.0 - 2*padding) * space); + s.translate_axis (padding * space, X_AXIS); return s; } @@ -148,8 +142,8 @@ Multi_measure_rest::symbol_stencil (Grob *me, Real space) { Stencil s = musfont->find_by_name (Rest::glyph_name (me, -1, "", false)); - s.translate_axis ((space - s.extent (X_AXIS).length ())/2, X_AXIS); - + s.translate_axis ((space - s.extent (X_AXIS).length ()) / 2, X_AXIS); + return s; } else @@ -158,59 +152,57 @@ Multi_measure_rest::symbol_stencil (Grob *me, Real space) /* ugh. - */ + */ if (Staff_symbol_referencer::get_position (me) == 0.0) s.translate_axis (staff_space, Y_AXIS); - s.translate_axis ((space - s.extent (X_AXIS).length ())/2, X_AXIS); - - return s ; - } + s.translate_axis ((space - s.extent (X_AXIS).length ()) / 2, X_AXIS); + + return s; + } } else { - return church_rest (me, musfont, measures, space); + return church_rest (me, musfont, measures, space); } } - /* WIDTH can also be 0 to determine the minimum size of the object. - */ +*/ Stencil Multi_measure_rest::big_rest (Grob *me, Real width) { Real thick_thick = robust_scm2double (me->get_property ("thick-thickness"), 1.0); Real hair_thick = robust_scm2double (me->get_property ("hair-thickness"), .1); - Real ss = Staff_symbol_referencer::staff_space (me); Real slt = me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness")); - Real y = slt * thick_thick/2 * ss; + Real y = slt * thick_thick / 2 * ss; Real ythick = hair_thick * slt * ss; - Box b (Interval (0, 0 >? (width - 2 * ythick)), Interval (-y, y)); - + Box b (Interval (0, 0 >? (width - 2 * ythick)), Interval (-y, y)); + Real blot = width ? (.8 * (y = 4) @@ -267,21 +259,20 @@ Multi_measure_rest::church_rest (Grob *me, Font_metric *musfont, int measures, symbols_width += r.extent (X_AXIS).length (); mols = scm_cons (r.smobbed_copy (), mols); } - count ++; + count++; } - - /* Make outer padding this much bigger. */ + /* Make outer padding this much bigger. */ Real outer_padding_factor = 1.5; Real inner_padding = (space - symbols_width) - / (2 * outer_padding_factor + (count-1)); + / (2 * outer_padding_factor + (count - 1)); if (inner_padding < 0) inner_padding = 1.0; - - Stencil mol; - for (SCM s = mols; scm_is_pair (s); s = scm_cdr (s)) - mol.add_at_edge (X_AXIS, LEFT, *unsmob_stencil (scm_car (s)), - inner_padding, 0); + + Stencil mol; + for (SCM s = mols; scm_is_pair (s); s = scm_cdr (s)) + mol.add_at_edge (X_AXIS, LEFT, *unsmob_stencil (scm_car (s)), + inner_padding, 0); mol.align_to (X_AXIS, LEFT); mol.translate_axis (outer_padding_factor * inner_padding, X_AXIS); @@ -291,7 +282,7 @@ Multi_measure_rest::church_rest (Grob *me, Font_metric *musfont, int measures, void Multi_measure_rest::add_column (Grob *me, Item *c) { - add_bound_item (dynamic_cast (me), c); + add_bound_item (dynamic_cast (me), c); } MAKE_SCHEME_CALLBACK (Multi_measure_rest, set_spacing_rods, 1); @@ -300,8 +291,8 @@ Multi_measure_rest::set_spacing_rods (SCM smob) { Grob *me = unsmob_grob (smob); - Spanner*sp = dynamic_cast (me); - if (!(sp->get_bound (LEFT) && sp->get_bound (RIGHT))) + Spanner *sp = dynamic_cast (me); + if (! (sp->get_bound (LEFT) && sp->get_bound (RIGHT))) { programming_error ("Multi_measure_rest::get_rods (): I am not spanned!"); return SCM_UNSPECIFIED; @@ -310,15 +301,15 @@ Multi_measure_rest::set_spacing_rods (SCM smob) Item *li = sp->get_bound (LEFT)->get_column (); Item *ri = sp->get_bound (RIGHT)->get_column (); Item *lb = li->find_prebroken_piece (RIGHT); - Item *rb = ri->find_prebroken_piece (LEFT); - + Item *rb = ri->find_prebroken_piece (LEFT); + Item *combinations[4][2] = {{li, ri}, {lb, ri}, {li, rb}, {lb, rb}}; Real sym_width = symbol_stencil (me, 0.0).extent (X_AXIS).length (); - + for (int i = 0; i < 4; i++) { Item *li = combinations[i][0]; @@ -334,8 +325,8 @@ Multi_measure_rest::set_spacing_rods (SCM smob) rod.distance_ = li->extent (li, X_AXIS)[BIGGER] - ri->extent (ri, X_AXIS)[SMALLER] /* 2.0 = magic! */ - + sym_width + 2.0; - + + sym_width + 2.0; + Real minlen = robust_scm2double (me->get_property ("minimum-length"), 0); rod.distance_ = max (rod.distance_, minlen); rod.add_to_cols (); diff --git a/lily/music-constructor.cc b/lily/music-constructor.cc index 3443cccfe1..c576580048 100644 --- a/lily/music-constructor.cc +++ b/lily/music-constructor.cc @@ -1,11 +1,10 @@ -/* +/* music-constructor.cc -- implement Music_constructor - + source file of the GNU LilyPond music typesetter - + (c) 2001--2005 Han-Wen Nienhuys - - */ +*/ #include "music-constructor.hh" @@ -14,15 +13,15 @@ #include "warn.hh" -static std::map *ctors_map_; +static std::map < String, Music_ctor> *ctors_map_; void add_music_ctor (String s, Music_ctor c) { if (!ctors_map_) - ctors_map_ = new std::map; - - (*ctors_map_)[s] = c; + ctors_map_ = new std::map < String, Music_ctor>; + + (*ctors_map_)[s] = c; } Music_ctor @@ -34,14 +33,14 @@ get_music_ctor (String s) return (*ctors_map_)[s]; } -Music * +Music * make_music (String s, SCM init) { Music_ctor c = get_music_ctor (s); if (!c) programming_error (String ("No constructor for music: ") + s); assert (c); - + return (*c) (init); } diff --git a/lily/music-function.cc b/lily/music-function.cc index 0113c6543c..b1b3bba0bb 100644 --- a/lily/music-function.cc +++ b/lily/music-function.cc @@ -1,10 +1,9 @@ -/* +/* music-function.cc -- implement music_function - + source file of the GNU LilyPond music typesetter - + (c) 2004--2005 Han-Wen Nienhuys - */ #include "music-function.hh" @@ -27,10 +26,9 @@ print_music_function (SCM b, SCM port, scm_print_state *) return 1; } - LY_DEFINE (ly_make_music_function, "ly:make-music-function", 2, 0, 0, (SCM signature, SCM func), - "Make a function to process music, to be used for the " + "Make a function to process music, to be used for the " "parser. @code{func} is the function, and @code{signature} describes " "Its arguments. @code{signature} is a list containing either " "@code{ly:music?} predicates or other type predicates.") @@ -40,10 +38,10 @@ LY_DEFINE (ly_make_music_function, "ly:make-music-function", 2, 0, 0, { if (str != "") str += "-"; - + if (scm_car (s) == Music_type_p_proc) str += "music"; - else if (scm_car (s) == ly_lily_module_constant("markup?")) + else if (scm_car (s) == ly_lily_module_constant ("markup?")) str += "markup"; else if (ly_c_procedure_p (scm_car (s))) str += "scm"; @@ -51,10 +49,10 @@ LY_DEFINE (ly_make_music_function, "ly:make-music-function", 2, 0, 0, if (str == "") str = "noarg"; scm_set_object_property_x (func, ly_symbol2scm ("music-function-signature"), signature); - + scm_set_object_property_x (func, ly_symbol2scm ("music-function-signature-keyword"), ly_symbol2scm (str.to_str0 ())); - + SCM_RETURN_NEWSMOB (music_function_tag, func); } @@ -64,13 +62,12 @@ is_music_function (SCM music_function) return (SCM_NIMP (music_function) && SCM_CELL_TYPE (music_function) == music_function_tag); } - SCM get_music_function_transform (SCM music_function) { if (!is_music_function (music_function)) return SCM_UNDEFINED; - + return SCM_CELL_OBJECT_1 (music_function); } @@ -82,4 +79,4 @@ init_music_function (void) scm_set_smob_print (music_function_tag, print_music_function); } -ADD_SCM_INIT_FUNC (music_function_tag, init_music_function); +ADD_SCM_INIT_FUNC (music_function_tag, init_music_function); diff --git a/lily/music-iterator.cc b/lily/music-iterator.cc index 58e8597905..6e836ea933 100644 --- a/lily/music-iterator.cc +++ b/lily/music-iterator.cc @@ -8,7 +8,7 @@ /* UGH. too many includes. - */ +*/ #include "music-iterator.hh" @@ -28,7 +28,7 @@ Music_iterator::Music_iterator () smobify_self (); } -Music_iterator::Music_iterator (Music_iterator const& ) +Music_iterator::Music_iterator (Music_iterator const &) { assert (false); } @@ -37,7 +37,7 @@ Music_iterator::~Music_iterator () { } -Context * +Context * Music_iterator::get_outlet () const { return handle_.get_outlet (); @@ -71,14 +71,12 @@ Music_iterator::ok () const return false; } - - SCM Music_iterator::get_static_get_iterator (Music *m) { - Music_iterator * p = 0; + Music_iterator *p = 0; - SCM ctor = m->get_property ("iterator-ctor") ; + SCM ctor = m->get_property ("iterator-ctor"); SCM iter = SCM_EOL; if (ly_c_procedure_p (ctor)) { @@ -100,11 +98,10 @@ Music_iterator::get_static_get_iterator (Music *m) assert (m); p->music_length_ = m->get_length (); p->start_mom_ = m->start_mom (); - + return iter; } - Moment Music_iterator::music_get_length () const { @@ -143,10 +140,10 @@ SCM Music_iterator::get_iterator (Music *m) const { SCM ip = get_static_get_iterator (m); - Music_iterator*p = unsmob_iterator (ip); - + Music_iterator *p = unsmob_iterator (ip); + p->init_translator (m, get_outlet ()); - + p->construct_children (); return ip; } @@ -154,19 +151,18 @@ Music_iterator::get_iterator (Music *m) const /* TODO: rename to prevent confusion between Context::try_music and Iterator::try_music - - */ -Music_iterator* +*/ +Music_iterator * Music_iterator::try_music (Music *m) const { - bool b = get_outlet ()->try_music ((Music*)m); // ugh - Music_iterator * it = b ? (Music_iterator*) this : 0; // ugh + bool b = get_outlet ()->try_music ((Music *)m); // ugh + Music_iterator *it = b ? (Music_iterator *) this : 0; // ugh if (!it) it = try_music_in_children (m); return it; } -Music_iterator* +Music_iterator * Music_iterator::try_music_in_children (Music *) const { return 0; @@ -189,24 +185,23 @@ IMPLEMENT_DEFAULT_EQUAL_P (Music_iterator); SCM Music_iterator::mark_smob (SCM smob) { - Music_iterator * mus = (Music_iterator *)SCM_CELL_WORD_1 (smob); + Music_iterator *mus = (Music_iterator *)SCM_CELL_WORD_1 (smob); mus->derived_mark (); /* Careful with GC, although we intend the following as pointers only, we _must_ mark them. - */ + */ if (mus->get_outlet ()) scm_gc_mark (mus->get_outlet ()->self_scm ()); if (mus->music_) scm_gc_mark (mus->music_->self_scm ()); - return SCM_EOL; } int -Music_iterator::print_smob (SCM sm , SCM port, scm_print_state*) +Music_iterator::print_smob (SCM sm, SCM port, scm_print_state*) { char s[1000]; @@ -239,7 +234,6 @@ Music_iterator::run_always ()const return false; } - bool is_child_context (Context *me, Context *child) { @@ -247,18 +241,18 @@ is_child_context (Context *me, Context *child) { child = child->get_parent_context (); } - + return child == me; } /* move to context of child iterator if it is deeper down in the hierarchy. - */ +*/ void -Music_iterator::descend_to_child (Context * child_report) +Music_iterator::descend_to_child (Context *child_report) { - Context * me_report = get_outlet (); + Context *me_report = get_outlet (); if (is_child_context (me_report, child_report)) set_context (child_report); } diff --git a/lily/music-scheme.cc b/lily/music-scheme.cc index dc01ff7e4c..a666c87aec 100644 --- a/lily/music-scheme.cc +++ b/lily/music-scheme.cc @@ -4,7 +4,6 @@ source file of the GNU LilyPond music typesetter (c) 2005 Han-Wen Nienhuys - */ #include "duration.hh" @@ -14,7 +13,7 @@ LY_DEFINE (ly_music_length, "ly:music-length", 1, 0, 0, (SCM mus), - "Get the length of music expression @var{mus}, and return as a @code{Moment} object.") + "Get the length of music expression @var{mus}, and return as a @code{Moment} object.") { Music *sc = unsmob_music (mus); SCM_ASSERT_TYPE (sc, mus, SCM_ARG1, __FUNCTION__, "music"); @@ -22,11 +21,11 @@ LY_DEFINE (ly_music_length, "ly:music-length", } LY_DEFINE (ly_music_property, - "ly:music-property", 2, 0, 0, (SCM mus, SCM sym), - "Get the property @var{sym} of music expression @var{mus}.\n" - "If @var{sym} is undefined, return @code{' ()}.\n" ) + "ly:music-property", 2, 0, 0, (SCM mus, SCM sym), + "Get the property @var{sym} of music expression @var{mus}.\n" + "If @var{sym} is undefined, return @code{' ()}.\n") { - Music * sc = unsmob_music (mus); + Music *sc = unsmob_music (mus); SCM_ASSERT_TYPE (sc, mus, SCM_ARG1, __FUNCTION__, "music"); SCM_ASSERT_TYPE (scm_is_symbol (sym), sym, SCM_ARG2, __FUNCTION__, "symbol"); @@ -34,10 +33,10 @@ LY_DEFINE (ly_music_property, } LY_DEFINE (ly_music_set_property, "ly:music-set-property!", - 3, 0, 0, (SCM mus, SCM sym, SCM val), - "Set property @var{sym} in music expression @var{mus} to @var{val}.") + 3, 0, 0, (SCM mus, SCM sym, SCM val), + "Set property @var{sym} in music expression @var{mus} to @var{val}.") { - Music * sc = unsmob_music (mus); + Music *sc = unsmob_music (mus); SCM_ASSERT_TYPE (sc, mus, SCM_ARG1, __FUNCTION__, "music"); SCM_ASSERT_TYPE (scm_is_symbol (sym), sym, SCM_ARG2, __FUNCTION__, "symbol"); @@ -55,7 +54,7 @@ LY_DEFINE (ly_music_name, "ly:music-name", "Return the name of @var{music}.") { Music *m = unsmob_music (mus); - SCM_ASSERT_TYPE (m, mus, SCM_ARG1, __FUNCTION__ , "music"); + SCM_ASSERT_TYPE (m, mus, SCM_ARG1, __FUNCTION__, "music"); char const *nm = classname (m); return scm_makfrom0str (nm); @@ -64,13 +63,12 @@ LY_DEFINE (ly_music_name, "ly:music-name", /* todo: property args */ LY_DEFINE (ly_extended_make_music, "ly:make-bare-music", 2, 0, 0, (SCM type, SCM props), - "Make a C++ music object of type @var{type}, initialize with\n" - "@var{props}. \n\n" - "" - "This function is for internal use, and is only called by " - "@code{make-music}, which is the preferred interface " - "for creating music objects. " - ) + "Make a C++ music object of type @var{type}, initialize with\n" + "@var{props}. \n\n" + "" + "This function is for internal use, and is only called by " + "@code{make-music}, which is the preferred interface " + "for creating music objects. ") { SCM_ASSERT_TYPE (scm_is_string (type), type, SCM_ARG1, __FUNCTION__, "string"); SCM s = make_music (ly_scm2string (type), props)->self_scm (); @@ -80,10 +78,10 @@ LY_DEFINE (ly_extended_make_music, "ly:make-bare-music", /* todo: property args */ LY_DEFINE (ly_music_mutable_properties, "ly:music-mutable-properties", - 1, 0, 0, (SCM mus), - "Return an alist containing the mutable properties of @var{mus}.\n" - "The immutable properties are not available, since " - "they are constant and initialized by the " + 1, 0, 0, (SCM mus), + "Return an alist containing the mutable properties of @var{mus}.\n" + "The immutable properties are not available, since " + "they are constant and initialized by the " "@code{make-music} function.\n") { Music *m = unsmob_music (mus); @@ -108,8 +106,8 @@ LY_DEFINE (ly_music_list_p, "ly:music-list?", } LY_DEFINE (ly_music_deep_copy, "ly:music-deep-copy", - 1, 0, 0, (SCM m), - "Copy @var{m} and all sub expressions of @var{m}") + 1, 0, 0, (SCM m), + "Copy @var{m} and all sub expressions of @var{m}") { SCM copy = m; if (unsmob_music (m)) @@ -119,17 +117,17 @@ LY_DEFINE (ly_music_deep_copy, "ly:music-deep-copy", } else if (scm_is_pair (m)) copy = scm_cons (ly_music_deep_copy (scm_car (m)), - ly_music_deep_copy (scm_cdr (m))); + ly_music_deep_copy (scm_cdr (m))); return copy; } LY_DEFINE (ly_music_transpose, "ly:music-transpose", - 2, 0, 0, (SCM m, SCM p), - "Transpose @var{m} such that central C is mapped to @var{p}. " - "Return @var{m}.") + 2, 0, 0, (SCM m, SCM p), + "Transpose @var{m} such that central C is mapped to @var{p}. " + "Return @var{m}.") { - Music * sc = unsmob_music (m); - Pitch * sp = unsmob_pitch (p); + Music *sc = unsmob_music (m); + Pitch *sp = unsmob_pitch (p); SCM_ASSERT_TYPE (sc, m, SCM_ARG1, __FUNCTION__, "music"); SCM_ASSERT_TYPE (sp, p, SCM_ARG2, __FUNCTION__, "pitch"); @@ -140,74 +138,70 @@ LY_DEFINE (ly_music_transpose, "ly:music-transpose", /* TODO: should take moment factor? - */ +*/ LY_DEFINE (ly_music_compress, "ly:music-compress", - 2, 0, 0, (SCM m, SCM factor), - "Compress music object @var{m} by moment @var{factor}." - ) + 2, 0, 0, (SCM m, SCM factor), + "Compress music object @var{m} by moment @var{factor}.") { - Music * sc = unsmob_music (m); + Music *sc = unsmob_music (m); SCM_ASSERT_TYPE (sc, m, SCM_ARG1, __FUNCTION__, "music"); SCM_ASSERT_TYPE (unsmob_moment (factor), factor, SCM_ARG2, __FUNCTION__, "moment"); - + sc->compress (*unsmob_moment (factor)); return sc->self_scm (); } LY_DEFINE (ly_music_duration_length, "ly:music-duration-length", 1, 0, 0, - (SCM mus), - "Extract the duration field from @var{mus}, and return the length.") + (SCM mus), + "Extract the duration field from @var{mus}, and return the length.") { - Music* m = unsmob_music (mus); + Music *m = unsmob_music (mus); SCM_ASSERT_TYPE (m, mus, SCM_ARG1, __FUNCTION__, "Music"); - + Duration *d = unsmob_duration (m->get_property ("duration")); - Moment l ; - + Moment l; + if (d) { - l = d->get_length (); + l = d->get_length (); } else programming_error ("Music has no duration"); return l.smobbed_copy (); - -} +} LY_DEFINE (ly_music_duration_compress, "ly:music-duration-compress", 2, 0, 0, - (SCM mus, SCM fact), - "Compress @var{mus} by factor @var{fact}, which is a @code{Moment}.") + (SCM mus, SCM fact), + "Compress @var{mus} by factor @var{fact}, which is a @code{Moment}.") { - Music* m = unsmob_music (mus); - Moment * f = unsmob_moment (fact); + Music *m = unsmob_music (mus); + Moment *f = unsmob_moment (fact); SCM_ASSERT_TYPE (m, mus, SCM_ARG1, __FUNCTION__, "Music"); SCM_ASSERT_TYPE (f, fact, SCM_ARG2, __FUNCTION__, "Moment"); - + Duration *d = unsmob_duration (m->get_property ("duration")); if (d) m->set_property ("duration", d->compressed (f->main_part_).smobbed_copy ()); return SCM_UNSPECIFIED; } - - /* This is hairy, since the scale in a key-change event may contain octaveless notes. - TODO: this should use ly:pitch. - */ + TODO: this should use ly:pitch. +*/ LY_DEFINE (ly_transpose_key_alist, "ly:transpose-key-alist", - 2, 0, 0, (SCM l, SCM pit), - "Make a new key alist of @var{l} transposed by pitch @var{pit}") + 2, 0, 0, (SCM l, SCM pit), + "Make a new key alist of @var{l} transposed by pitch @var{pit}") { SCM newlist = SCM_EOL; Pitch *p = unsmob_pitch (pit); - + for (SCM s = l; scm_is_pair (s); s = scm_cdr (s)) { SCM key = scm_caar (s); @@ -221,10 +215,10 @@ LY_DEFINE (ly_transpose_key_alist, "ly:transpose-key-alist", orig = orig.transposed (*p); SCM key = scm_cons (scm_int2num (orig.get_octave ()), - scm_int2num (orig.get_notename ())); + scm_int2num (orig.get_notename ())); newlist = scm_cons (scm_cons (key, scm_int2num (orig.get_alteration ())), - newlist); + newlist); } else if (scm_is_number (key)) { diff --git a/lily/music-sequence.cc b/lily/music-sequence.cc index 84a8c63a97..555e2e3afb 100644 --- a/lily/music-sequence.cc +++ b/lily/music-sequence.cc @@ -1,8 +1,8 @@ -/* +/* music-sequence.cc -- implement Music_sequence - + source file of the GNU LilyPond music typesetter - + (c) 1998--2005 Han-Wen Nienhuys */ @@ -15,17 +15,17 @@ void transpose_music_list (SCM lst, Pitch rq) { - for (SCM s = lst; scm_is_pair (s); s = scm_cdr (s)) - unsmob_music (scm_car (s))->transpose (rq); + for (SCM s = lst; scm_is_pair (s); s = scm_cdr (s)) + unsmob_music (scm_car (s))->transpose (rq); } Moment -Music_sequence::cumulative_length (SCM l) +Music_sequence::cumulative_length (SCM l) { Moment cumulative; - Moment last_len; + Moment last_len; - for (SCM s = l; scm_is_pair (s); s = scm_cdr (s)) + for (SCM s = l; scm_is_pair (s); s = scm_cdr (s)) { Moment l = unsmob_music (scm_car (s))->get_length (); if (last_len.grace_part_ && l.main_part_) @@ -39,16 +39,16 @@ Music_sequence::cumulative_length (SCM l) last_len.grace_part_ = Rational (0); cumulative += last_len; - return cumulative; + return cumulative; } Moment Music_sequence::maximum_length (SCM l) { Moment dur = 0; - for (SCM s = l; scm_is_pair (s); s = scm_cdr (s)) + for (SCM s = l; scm_is_pair (s); s = scm_cdr (s)) { - Music * m = unsmob_music (scm_car (s)); + Music *m = unsmob_music (scm_car (s)); Moment l = m->get_length (); dur = dur >? l; } @@ -56,37 +56,36 @@ Music_sequence::maximum_length (SCM l) return dur; } -MAKE_SCHEME_CALLBACK(Music_sequence, maximum_length_callback, 1); +MAKE_SCHEME_CALLBACK (Music_sequence, maximum_length_callback, 1); SCM Music_sequence::maximum_length_callback (SCM m) { - Music* me = unsmob_music (m); - return maximum_length (me->get_property ("elements")).smobbed_copy(); + Music *me = unsmob_music (m); + return maximum_length (me->get_property ("elements")).smobbed_copy (); } -MAKE_SCHEME_CALLBACK(Music_sequence, cumulative_length_callback, 1); +MAKE_SCHEME_CALLBACK (Music_sequence, cumulative_length_callback, 1); SCM Music_sequence::cumulative_length_callback (SCM m) { - Music* me = unsmob_music (m); - return cumulative_length (me->get_property ("elements")).smobbed_copy(); + Music *me = unsmob_music (m); + return cumulative_length (me->get_property ("elements")).smobbed_copy (); } - -MAKE_SCHEME_CALLBACK(Music_sequence, minimum_start_callback, 1); +MAKE_SCHEME_CALLBACK (Music_sequence, minimum_start_callback, 1); SCM Music_sequence::minimum_start_callback (SCM m) { - Music* me = unsmob_music (m); - return minimum_start (me->get_property ("elements")).smobbed_copy(); + Music *me = unsmob_music (m); + return minimum_start (me->get_property ("elements")).smobbed_copy (); } -MAKE_SCHEME_CALLBACK(Music_sequence, first_start_callback, 1); +MAKE_SCHEME_CALLBACK (Music_sequence, first_start_callback, 1); SCM Music_sequence::first_start_callback (SCM m) { - Music* me = unsmob_music (m); - return first_start (me->get_property ("elements")).smobbed_copy(); + Music *me = unsmob_music (m); + return first_start (me->get_property ("elements")).smobbed_copy (); } Pitch @@ -96,12 +95,12 @@ music_list_to_relative (SCM l, Pitch p, bool ret_first) int count = 0; Pitch last = p; - for (SCM s = l; scm_is_pair (s); s = scm_cdr (s)) + for (SCM s = l; scm_is_pair (s); s = scm_cdr (s)) { if (Music *m = unsmob_music (scm_car (s))) { last = m->to_relative_octave (last); - if (!count ++) + if (!count++) first = last; } } @@ -109,11 +108,10 @@ music_list_to_relative (SCM l, Pitch p, bool ret_first) return (ret_first) ? first : last; } - void compress_music_list (SCM l, Moment m) { - for (SCM s = l; scm_is_pair (s); s = scm_cdr (s)) + for (SCM s = l; scm_is_pair (s); s = scm_cdr (s)) unsmob_music (scm_car (s))->compress (m); } @@ -121,8 +119,8 @@ Moment Music_sequence::minimum_start (SCM l) { Moment m; - - for (SCM s = l; scm_is_pair (s); s = scm_cdr (s)) + + for (SCM s = l; scm_is_pair (s); s = scm_cdr (s)) { m = m start_mom (); } @@ -130,13 +128,13 @@ Music_sequence::minimum_start (SCM l) } Moment -Music_sequence::first_start (SCM l) +Music_sequence::first_start (SCM l) { Moment m; - - for (SCM s = l; scm_is_pair (s); s = scm_cdr (s)) + + for (SCM s = l; scm_is_pair (s); s = scm_cdr (s)) { - Music * mus = unsmob_music (scm_car (s)); + Music *mus = unsmob_music (scm_car (s)); Moment l = mus->get_length (); Moment s = mus->start_mom (); if (l.to_bool () || s.to_bool ()) @@ -145,7 +143,7 @@ Music_sequence::first_start (SCM l) return m; } -MAKE_SCHEME_CALLBACK(Music_sequence, simultaneous_relative_callback, 2); +MAKE_SCHEME_CALLBACK (Music_sequence, simultaneous_relative_callback, 2); SCM Music_sequence::simultaneous_relative_callback (SCM music, SCM pitch) { @@ -158,10 +156,10 @@ Music_sequence::simultaneous_relative_callback (SCM music, SCM pitch) copied = ly_music_deep_copy (elts); Pitch retval = music_list_to_relative (elts, p, false); - + if (lily_1_8_relative) { - + Pitch retval_1_8 = music_list_to_relative (copied, p, true); if (retval_1_8 != retval) lily_1_8_compatibility_used = true; @@ -172,8 +170,7 @@ Music_sequence::simultaneous_relative_callback (SCM music, SCM pitch) return retval.smobbed_copy (); } - -MAKE_SCHEME_CALLBACK(Music_sequence, event_chord_relative_callback, 2); +MAKE_SCHEME_CALLBACK (Music_sequence, event_chord_relative_callback, 2); SCM Music_sequence::event_chord_relative_callback (SCM music, SCM pitch) { @@ -182,4 +179,4 @@ Music_sequence::event_chord_relative_callback (SCM music, SCM pitch) return music_list_to_relative (me->get_property ("elements"), p, true).smobbed_copy (); } - + diff --git a/lily/music-wrapper-iterator.cc b/lily/music-wrapper-iterator.cc index 9af125955b..ed29db0fb0 100644 --- a/lily/music-wrapper-iterator.cc +++ b/lily/music-wrapper-iterator.cc @@ -1,11 +1,10 @@ -/* +/* music-wrapper-iterator.cc -- implement Music_wrapper_iterator - + source file of the GNU LilyPond music typesetter - - (c) 1998--2005 Han-Wen Nienhuys - */ + (c) 1998--2005 Han-Wen Nienhuys +*/ #include "music-wrapper-iterator.hh" @@ -30,7 +29,7 @@ Music_wrapper_iterator::derived_mark () const } void -Music_wrapper_iterator::derived_substitute (Context *f, Context *t) +Music_wrapper_iterator::derived_substitute (Context *f, Context *t) { if (child_iter_) child_iter_->substitute_outlet (f, t); @@ -39,7 +38,7 @@ Music_wrapper_iterator::derived_substitute (Context *f, Context *t) void Music_wrapper_iterator::construct_children () { - Music * m = dynamic_cast (get_music ())-> element (); + Music *m = dynamic_cast < Music_wrapper const *> (get_music ())-> element (); child_iter_ = unsmob_iterator (get_iterator (m)); } @@ -49,21 +48,19 @@ Music_wrapper_iterator::ok () const return child_iter_ && child_iter_->ok (); } - void Music_wrapper_iterator::process (Moment m) { child_iter_->process (m); } - Moment Music_wrapper_iterator::pending_moment () const { return child_iter_->pending_moment (); } -Music_iterator* +Music_iterator * Music_wrapper_iterator::try_music_in_children (Music *m) const { return child_iter_->try_music (m); diff --git a/lily/music-wrapper.cc b/lily/music-wrapper.cc index 0779476b0e..7106707d5a 100644 --- a/lily/music-wrapper.cc +++ b/lily/music-wrapper.cc @@ -1,11 +1,10 @@ -/* +/* music-wrapper.cc -- implement Music_wrapper - + source file of the GNU LilyPond music typesetter - + (c) 1998--2005 Han-Wen Nienhuys - - */ +*/ #include "music-wrapper.hh" @@ -13,12 +12,12 @@ Music_wrapper::Music_wrapper (SCM x) : Music (x) { if (!ly_c_procedure_p (length_callback_)) - length_callback_ = length_callback_proc; + length_callback_ = length_callback_proc; if (!ly_c_procedure_p (start_callback_)) - start_callback_ = length_callback_proc; + start_callback_ = length_callback_proc; } -MAKE_SCHEME_CALLBACK(Music_wrapper, start_callback, 1); +MAKE_SCHEME_CALLBACK (Music_wrapper, start_callback, 1); SCM Music_wrapper::start_callback (SCM m) { @@ -27,21 +26,20 @@ Music_wrapper::start_callback (SCM m) return elt->start_mom ().smobbed_copy (); } -MAKE_SCHEME_CALLBACK(Music_wrapper, length_callback, 1); +MAKE_SCHEME_CALLBACK (Music_wrapper, length_callback, 1); SCM Music_wrapper::length_callback (SCM m) { - Music * me = unsmob_music (m); + Music *me = unsmob_music (m); Music *elt = unsmob_music (me->get_property ("element")); return elt->get_length ().smobbed_copy (); } -Music* +Music * Music_wrapper::element () const { return unsmob_music (get_property ("element")); } - ADD_MUSIC (Music_wrapper); diff --git a/lily/music.cc b/lily/music.cc index d57a36bb1d..3317ba3c76 100644 --- a/lily/music.cc +++ b/lily/music.cc @@ -19,9 +19,9 @@ /* Music is anything that has duration and supports both time compression and transposition. - + In Lily, everything that can be thought to have a length and a pitch - (which has a duration which can be transposed) is considered "music", + (which has a duration which can be transposed) is considered "music", */ bool Music::internal_is_music_type (SCM k) const @@ -87,7 +87,7 @@ Music::get_property_alist (bool m) const SCM Music::mark_smob (SCM m) { - Music *mus = (Music*) SCM_CELL_WORD_1 (m); + Music *mus = (Music *) SCM_CELL_WORD_1 (m); scm_gc_mark (mus->immutable_property_alist_); scm_gc_mark (mus->mutable_property_alist_); return SCM_EOL; @@ -106,7 +106,7 @@ Music::get_length () const return *unsmob_moment (res); } - return Moment(0); + return Moment (0); } Moment @@ -140,7 +140,7 @@ int Music::print_smob (SCM s, SCM p, scm_print_state*) { scm_puts ("#get_property ("name"); if (scm_is_symbol (nm) || scm_is_string (nm)) @@ -167,8 +167,8 @@ Music::generic_to_relative_octave (Pitch last) new_pit = new_pit.to_relative_octave (last); SCM check = get_property ("absolute-octave"); - if (scm_is_number (check) && - new_pit.get_octave () != scm_to_int (check)) + if (scm_is_number (check) + && new_pit.get_octave () != scm_to_int (check)) { Pitch expected_pit (scm_to_int (check), new_pit.get_notename (), @@ -178,9 +178,9 @@ Music::generic_to_relative_octave (Pitch last) new_pit.to_string ())); new_pit = expected_pit; } - + set_property ("pitch", new_pit.smobbed_copy ()); - + last = new_pit; } @@ -197,7 +197,7 @@ Music::to_relative_octave (Pitch last) SCM callback = get_property ("to-relative-callback"); if (ly_c_procedure_p (callback)) { - Pitch * p = unsmob_pitch (scm_call_2 (callback, self_scm(), last.smobbed_copy ())); + Pitch *p = unsmob_pitch (scm_call_2 (callback, self_scm (), last.smobbed_copy ())); return *p; } @@ -213,7 +213,7 @@ Music::compress (Moment factor) m->compress (factor); compress_music_list (get_property ("elements"), factor); - Duration *d = unsmob_duration (get_property ("duration")); + Duration *d = unsmob_duration (get_property ("duration")); if (d) set_property ("duration", d ->compressed (factor.main_part_).smobbed_copy ()); } @@ -222,16 +222,16 @@ void Music::transpose (Pitch delta) { if (to_boolean (get_property ("untransposable"))) - return ; - + return; + for (SCM s = this->get_property_alist (true); scm_is_pair (s); s = scm_cdr (s)) { SCM entry = scm_car (s); SCM val = scm_cdr (entry); - if (Pitch * p = unsmob_pitch (val)) + if (Pitch *p = unsmob_pitch (val)) { - Pitch transposed = p->transposed (delta); + Pitch transposed = p->transposed (delta); scm_set_cdr_x (entry, transposed.smobbed_copy ()); if (abs (transposed.get_alteration ()) > DOUBLE_SHARP) @@ -241,16 +241,16 @@ Music::transpose (Pitch delta) } } } - + SCM elt = get_property ("element"); - if (Music* m = unsmob_music (elt)) + if (Music *m = unsmob_music (elt)) m->transpose (delta); transpose_music_list (get_property ("elements"), delta); /* - UGH - how do this more generically? + UGH - how do this more generically? */ SCM pa = get_property ("pitch-alist"); if (scm_is_pair (pa)) @@ -291,7 +291,7 @@ Music::set_spot (Input ip) set_property ("origin", make_input (ip)); } -Input* +Input * Music::origin () const { Input *ip = unsmob_input (get_property ("origin")); @@ -306,7 +306,7 @@ Music::duration_log () const return 0; } -Music* +Music * make_music_by_name (SCM sym) { SCM make_music_proc = ly_lily_module_constant ("make-music"); diff --git a/lily/new-fingering-engraver.cc b/lily/new-fingering-engraver.cc index a0641750c7..f1b02a3509 100644 --- a/lily/new-fingering-engraver.cc +++ b/lily/new-fingering-engraver.cc @@ -1,11 +1,10 @@ -/* +/* fingering-engraver.cc -- implement New_fingering_engraver - + source file of the GNU LilyPond music typesetter - + (c) 1998--2005 Han-Wen Nienhuys - - */ +*/ #include "warn.hh" #include "engraver.hh" @@ -32,11 +31,11 @@ struct Finger_tuple note_event_ = finger_event_ = 0; follow_into_staff_ = false; } - static int compare (Finger_tuple const & c1, Finger_tuple const & c2) + static int compare (Finger_tuple const &c1, Finger_tuple const &c2) { - return c1.position_- c2.position_; + return c1.position_- c2.position_; } - + }; class New_fingering_engraver : public Engraver @@ -45,14 +44,14 @@ class New_fingering_engraver : public Engraver Array articulations_; Link_array heads_; Grob *stem_; - + public: TRANSLATOR_DECLARATIONS (New_fingering_engraver); protected: virtual void stop_translation_timestep (); virtual void acknowledge_grob (Grob_info); - void add_fingering (Grob*, Music*, Music*); - void add_script (Grob*, Music*, Music*); + void add_fingering (Grob *, Music *, Music *); + void add_script (Grob *, Music *, Music *); void position_scripts (); }; @@ -61,23 +60,22 @@ New_fingering_engraver::acknowledge_grob (Grob_info inf) { if (Rhythmic_head::has_interface (inf.grob_)) { - Music * note_ev = inf.music_cause (); + Music *note_ev = inf.music_cause (); if (!note_ev) return; - + SCM arts = note_ev->get_property ("articulations"); - for (SCM s = arts; scm_is_pair (s); s = scm_cdr (s)) + for (SCM s = arts; scm_is_pair (s); s = scm_cdr (s)) { - Music * m = unsmob_music (scm_car (s)); + Music *m = unsmob_music (scm_car (s)); if (!m) continue; - if (m->is_mus_type ("fingering-event")) { - add_fingering (inf.grob_ , m, note_ev); + add_fingering (inf.grob_, m, note_ev); } else if (m->is_mus_type ("text-script-event")) { @@ -90,9 +88,9 @@ New_fingering_engraver::acknowledge_grob (Grob_info inf) else if (m->is_mus_type ("harmonic-event")) { inf.grob_->set_property ("style", ly_symbol2scm ("harmonic")); - Grob * d = unsmob_grob (inf.grob_->get_property ("dot")); + Grob *d = unsmob_grob (inf.grob_->get_property ("dot")); if (d) - d->suicide (); + d->suicide (); } } @@ -105,56 +103,55 @@ New_fingering_engraver::acknowledge_grob (Grob_info inf) } void -New_fingering_engraver::add_script (Grob * head, - Music * event, - Music * ) +New_fingering_engraver::add_script (Grob *head, + Music *event, + Music *) { - Finger_tuple ft ; + Finger_tuple ft; - Grob * g = make_item ("Script", event->self_scm () ); + Grob *g = make_item ("Script", event->self_scm ()); make_script_from_event (g, &ft.follow_into_staff_, context (), event->get_property ("articulation-type"), 0); if (g) { - ft.script_ = g ; - + ft.script_ = g; + articulations_.push (ft); - + ft.script_->set_parent (head, X_AXIS); } -} - +} void -New_fingering_engraver::add_fingering (Grob * head, - Music * event, +New_fingering_engraver::add_fingering (Grob *head, + Music *event, Music *hevent) { Finger_tuple ft; - ft.script_ = make_item ("Fingering", event->self_scm () ); - + ft.script_ = make_item ("Fingering", event->self_scm ()); + Side_position_interface::add_support (ft.script_, head); int d = scm_to_int (event->get_property ("digit")); - + /* TODO: - + Should add support for thumb. It's a little involved, since the thumb lives in a different font. Maybe it should be moved? - - */ + + */ if (d > 5) { /* - music for the softenon children? - */ - event->origin ()->warning (_("music for the martians.")); + music for the softenon children? + */ + event->origin ()->warning (_ ("music for the martians.")); } - SCM sstr = scm_number_to_string (scm_int2num (d), scm_int2num (10)) ; + SCM sstr = scm_number_to_string (scm_int2num (d), scm_int2num (10)); ft.script_->set_property ("text", sstr); - + ft.finger_event_ = event; ft.note_event_ = hevent; ft.head_ = head; @@ -176,25 +173,25 @@ New_fingering_engraver::position_scripts () positioning the fingerings, setting both X and Y coordinates. */ for (int i = 0; i < fingerings_.size (); i++) - { - fingerings_[i].position_ = scm_to_int (fingerings_[i].head_ -> get_property ( "staff-position")); + { + fingerings_[i].position_ = scm_to_int (fingerings_[i].head_ -> get_property ("staff-position")); } for (int i = fingerings_.size (); i--;) - for (int j = heads_.size () ; j--;) + for (int j = heads_.size (); j--;) Side_position_interface::add_support (fingerings_[i].script_, heads_[j]); - + Array up, down, horiz; for (int i = fingerings_.size (); i--;) { SCM d = fingerings_[i].finger_event_->get_property ("direction"); if (to_dir (d)) { - ((to_dir (d) == UP) ? up : down ).push (fingerings_[i]); + ((to_dir (d) == UP) ? up : down).push (fingerings_[i]); fingerings_.del (i); } } - + fingerings_.sort (&Finger_tuple::compare); SCM orientations = get_property ("fingeringOrientations"); @@ -234,11 +231,11 @@ New_fingering_engraver::position_scripts () down.concat (fingerings_); fingerings_.clear (); } - + for (int i = 0; i < horiz.size (); i++) { Finger_tuple ft = horiz[i]; - Grob* f = ft.script_; + Grob *f = ft.script_; f->set_parent (ft.head_, X_AXIS); f->set_parent (ft.head_, Y_AXIS); f->add_offset_callback (Self_alignment_interface::centered_on_parent_proc, Y_AXIS); @@ -252,25 +249,25 @@ New_fingering_engraver::position_scripts () for (int i = 0; i < up.size (); i++) { Finger_tuple ft = up[i]; - Grob* f = ft.script_; + Grob *f = ft.script_; f->set_parent (ft.head_, X_AXIS); f->set_property ("script-priority", - scm_int2num (finger_prio + i)); + scm_int2num (finger_prio + i)); f->add_offset_callback (Side_position_interface::aligned_side_proc, Y_AXIS); f->add_offset_callback (Self_alignment_interface::centered_on_parent_proc, X_AXIS); f->add_offset_callback (Self_alignment_interface::aligned_on_self_proc, X_AXIS); - + f->set_property ("direction", scm_int2num (UP)); } - + for (int i = 0; i < down.size (); i++) { Finger_tuple ft = down[i]; - Grob* f = ft.script_; + Grob *f = ft.script_; f->set_parent (ft.head_, X_AXIS); f->set_property ("script-priority", - scm_int2num (finger_prio + down.size () - i)); + scm_int2num (finger_prio + down.size () - i)); f->add_offset_callback (Self_alignment_interface::centered_on_parent_proc, X_AXIS); f->add_offset_callback (Self_alignment_interface::aligned_on_self_proc, X_AXIS); @@ -284,31 +281,30 @@ New_fingering_engraver::stop_translation_timestep () { if (fingerings_.size ()) { - for (int i = 0; i < fingerings_.size(); i++) + for (int i = 0; i < fingerings_.size (); i++) if (stem_ && to_boolean (fingerings_[i].script_->get_property ("add-stem-support"))) Side_position_interface::add_support (fingerings_[i].script_, stem_); position_scripts (); fingerings_.clear (); } - - for (int i = articulations_.size (); i--;) + + for (int i = articulations_.size (); i--;) { Grob *script = articulations_[i].script_; - - for (int j = heads_.size () ; j--;) + + for (int j = heads_.size (); j--;) Side_position_interface::add_support (script, heads_[j]); if (stem_ && to_dir (script->get_property ("side-relative-direction"))) script->set_property ("direction-source", stem_->self_scm ()); - if (stem_ && to_boolean (script->get_property ("add-stem-support"))) Side_position_interface::add_support (script, stem_); - + if (articulations_[i].follow_into_staff_) { script->add_offset_callback (Side_position_interface::quantised_position_proc, Y_AXIS); - script->set_property ("staff-padding" , SCM_EOL); + script->set_property ("staff-padding", SCM_EOL); } } @@ -317,18 +313,17 @@ New_fingering_engraver::stop_translation_timestep () articulations_.clear (); } - New_fingering_engraver::New_fingering_engraver () { - stem_ = 0; + stem_ = 0; } ADD_TRANSLATOR (New_fingering_engraver, -/* descr */ "Create fingering-scripts for notes in a new chord. " - "This engraver is ill-named, since it " - "also takes care of articulations and harmonic note heads", -/* creats*/ "Fingering", -/* accepts */ "", -/* acks */ "rhythmic-head-interface stem-interface", -/* reads */ "fingeringOrientations", -/* write */ ""); + /* descr */ "Create fingering-scripts for notes in a new chord. " + "This engraver is ill-named, since it " + "also takes care of articulations and harmonic note heads", + /* creats*/ "Fingering", + /* accepts */ "", + /* acks */ "rhythmic-head-interface stem-interface", + /* reads */ "fingeringOrientations", + /* write */ ""); diff --git a/lily/new-lyric-combine-music-iterator.cc b/lily/new-lyric-combine-music-iterator.cc index 105d78ef75..0144e9e5e1 100644 --- a/lily/new-lyric-combine-music-iterator.cc +++ b/lily/new-lyric-combine-music-iterator.cc @@ -1,8 +1,8 @@ /* new-lyric-combine-iterator.cc -- implement New_lyric_combine_music_iterator - + source file of the GNU LilyPond music typesetter - + (c) 2004--2005 Han-Wen Nienhuys */ @@ -15,12 +15,12 @@ class New_lyric_combine_music_iterator : public Music_iterator { public: New_lyric_combine_music_iterator (); - New_lyric_combine_music_iterator (New_lyric_combine_music_iterator const&src); + New_lyric_combine_music_iterator (New_lyric_combine_music_iterator const &src); DECLARE_SCHEME_CALLBACK (constructor, ()); protected: virtual void construct_children (); virtual Moment pending_moment () const; - virtual void do_quit (); + virtual void do_quit (); virtual void process (Moment); virtual Music_iterator *try_music_in_children (Music *) const; virtual bool run_always ()const; @@ -28,7 +28,7 @@ protected: virtual void derived_mark () const; virtual void derived_substitute (Context *, Context *); private: - bool start_new_syllable () ; + bool start_new_syllable (); void find_voice (); bool music_found_; @@ -36,13 +36,13 @@ private: Context *lyrics_context_; Context *music_context_; SCM lyricsto_voice_name_; - - Music_iterator * lyric_iter_; + + Music_iterator *lyric_iter_; }; /* Ugh, why static? - */ +*/ static Music *busy_ev; static Music *start_ev; static Music *melisma_playing_ev; @@ -57,7 +57,7 @@ New_lyric_combine_music_iterator::New_lyric_combine_music_iterator () /* Ugh. out of place here. - */ + */ if (!busy_ev) { busy_ev @@ -73,20 +73,20 @@ bool New_lyric_combine_music_iterator::start_new_syllable () { bool b = music_context_->try_music (busy_ev); - + if (!b) return false; if (!lyrics_context_) return false; - + if (!to_boolean (lyrics_context_->get_property ("ignoreMelismata"))) { bool m = music_context_->try_music (melisma_playing_ev); if (m) return false; } - + return true; } @@ -96,7 +96,7 @@ New_lyric_combine_music_iterator::pending_moment () const Moment m; m.set_infinite (1); - + return m; } @@ -131,10 +131,9 @@ New_lyric_combine_music_iterator::derived_substitute (Context *f, Context *t) if (lyrics_context_ && lyrics_context_ == f) lyrics_context_ = t; if (music_context_ && music_context_ == f) - music_context_ = t; + music_context_ = t; } - void New_lyric_combine_music_iterator::construct_children () { @@ -143,9 +142,8 @@ New_lyric_combine_music_iterator::construct_children () lyricsto_voice_name_ = get_music ()->get_property ("associated-context"); - find_voice (); - + if (lyric_iter_) lyrics_context_ = find_context_below (lyric_iter_->get_outlet (), ly_symbol2scm ("Lyrics"), ""); @@ -154,7 +152,7 @@ New_lyric_combine_music_iterator::construct_children () We do not create a Lyrics context, because the user might create one with a different name, and then we will not find that one. - */ + */ } void @@ -167,16 +165,16 @@ New_lyric_combine_music_iterator::find_voice () voice_name = running; if (scm_is_string (voice_name) - && (!music_context_ || ly_scm2string (voice_name) != music_context_->id_string ())) + && (!music_context_ || ly_scm2string (voice_name) != music_context_->id_string ())) { /* (spaghettini). - + Need to set associatedVoiceContext again - */ + */ if (music_context_) made_association_ = false; - + Context *t = get_outlet (); while (t && t->get_parent_context ()) t = t->get_parent_context (); @@ -184,7 +182,6 @@ New_lyric_combine_music_iterator::find_voice () String name = ly_scm2string (voice_name); Context *voice = find_context_below (t, ly_symbol2scm ("Voice"), name); - if (voice) music_context_ = voice; } @@ -193,7 +190,7 @@ New_lyric_combine_music_iterator::find_voice () { if (!made_association_) { - made_association_ = true; + made_association_ = true; lyrics_context_->set_property ("associatedVoiceContext", music_context_->self_scm ()); } @@ -201,31 +198,31 @@ New_lyric_combine_music_iterator::find_voice () } void -New_lyric_combine_music_iterator::process (Moment ) +New_lyric_combine_music_iterator::process (Moment) { find_voice (); if (!music_context_) - return ; - + return; + if (!music_context_->get_parent_context ()) { /* The melody has died. We die too. - */ + */ if (lyrics_context_) lyrics_context_->unset_property (ly_symbol2scm ("associatedVoiceContext")); lyric_iter_ = 0; music_context_ = 0; } - + if (music_context_ && start_new_syllable () && lyric_iter_->ok ()) { Moment m = lyric_iter_->pending_moment (); lyric_iter_->process (m); - music_found_ = true; + music_found_ = true; } } @@ -248,13 +245,10 @@ New_lyric_combine_music_iterator::do_quit () lyric_iter_->quit (); } - - -Music_iterator* +Music_iterator * New_lyric_combine_music_iterator::try_music_in_children (Music *m) const { return lyric_iter_->try_music (m); } - IMPLEMENT_CTOR_CALLBACK (New_lyric_combine_music_iterator); diff --git a/lily/note-collision.cc b/lily/note-collision.cc index 0354950a53..0eece029ae 100644 --- a/lily/note-collision.cc +++ b/lily/note-collision.cc @@ -28,29 +28,28 @@ Note_collision_interface::force_shift_callback (SCM element_smob, SCM axis) Grob *me = unsmob_grob (element_smob); Axis a = (Axis) scm_to_int (axis); assert (a == X_AXIS); - - me = me->get_parent (a); - if (! to_boolean (me->get_property ("positioning-done"))) + me = me->get_parent (a); + + if (! to_boolean (me->get_property ("positioning-done"))) { me->set_property ("positioning-done", SCM_BOOL_T); do_shifts (me); } - + return scm_make_real (0.0); } - void check_meshing_chords (Grob *me, - Drul_array< Array < Real > > *offsets, - Drul_array< Array < Slice > > const &extents, - Drul_array > const &clash_groups) - + Drul_array< Array > *offsets, + Drul_array< Array > const &extents, + Drul_array < Link_array > const &clash_groups) + { if (!extents[UP].size () || ! extents[DOWN].size ()) return; - + Grob *cu = clash_groups[UP][0]; Grob *cd = clash_groups[DOWN][0]; @@ -66,21 +65,19 @@ check_meshing_chords (Grob *me, /* Too far apart to collide. */ if (ups[0] > dps.top () + 1) - return; + return; // FIXME: what's this? bool merge_possible = (ups[0] >= dps[0]) && (ups.top () >= dps.top ()); - - /* Do not merge notes typeset in different style. */ - if ( !ly_c_equal_p (nu->get_property ("style"), - nd->get_property ("style") ) ) + if (!ly_c_equal_p (nu->get_property ("style"), + nd->get_property ("style"))) merge_possible = false; - + int upball_type = Note_head::get_balltype (nu); int dnball_type = Note_head::get_balltype (nd); - + /* Do not merge whole notes (or longer, like breve, longa, maxima). */ if (merge_possible && (upball_type <= 0 || dnball_type <= 0)) merge_possible = false; @@ -103,80 +100,78 @@ check_meshing_chords (Grob *me, && ((Rhythmic_head::duration_log (nu) == 1 && Rhythmic_head::duration_log (nd) == 2) || (Rhythmic_head::duration_log (nu) == 2 - && Rhythmic_head::duration_log (nd) == 1))) + && Rhythmic_head::duration_log (nd) == 1))) merge_possible = false; - /* - this case (distant half collide), - - | - x | - | x - | + this case (distant half collide), - the noteheads may be closer than this case (close half collide) + | + x | + | x + | + + the noteheads may be closer than this case (close half collide) - | - | - x - x | | - - */ - + x + x + | + | + + */ + /* TODO: filter out the 'o's in this configuration, since they're no - part in the collision. + part in the collision. | - x|o - x|o - x - - */ - + x|o + x|o + x + + */ + bool close_half_collide = false; - bool distant_half_collide = false; - bool full_collide = false; + bool distant_half_collide = false; + bool full_collide = false; int i = 0, j = 0; while (i < ups.size () && j < dps.size ()) - { - if (abs (ups[i] - dps[j]) == 1) - { + { + if (abs (ups[i] - dps[j]) == 1) + { + merge_possible = false; + if (ups[i] > dps[j]) + close_half_collide = true; + else + distant_half_collide = true; + } + else if (ups[i]== dps[j]) + full_collide = true; + else if (ups[i] >dps[0] && ups[i] < dps.top ()) + merge_possible = false; + else if (dps[j] >ups[0] && dps[j] < ups.top ()) merge_possible = false; - if (ups[i] > dps[j]) - close_half_collide = true; - else - distant_half_collide = true; - } - else if (ups[i]== dps[j]) - full_collide = true; - else if (ups[i] >dps[0] && ups[i] < dps.top ()) - merge_possible = false; - else if (dps[j] >ups[0] && dps[j] < ups.top ()) - merge_possible = false; - - if (ups[i] < dps[j]) - i++; - else if (ups[i] > dps[j]) - j++; - else - { + + if (ups[i] < dps[j]) i++; + else if (ups[i] > dps[j]) j++; - } - } + else + { + i++; + j++; + } + } full_collide = full_collide || (close_half_collide && distant_half_collide); - + Drul_array center_note_shifts; center_note_shifts[LEFT] = 0.0; center_note_shifts[RIGHT] = 0.0; - Real shift_amount = 1; bool touch = (ups[0] >= dps.top ()); @@ -191,18 +186,17 @@ check_meshing_chords (Grob *me, shift_amount = 1; else if (Rhythmic_head::dot_count (nu) < Rhythmic_head::dot_count (nd)) stem_to_stem = true; - + if (merge_possible) { shift_amount = 0; - /* If possible, don't wipe any heads. Else, wipe shortest head, or head with smallest amount of dots. Note: when merging different heads, dots on the smaller one disappear. */ Grob *wipe_ball = 0; Grob *dot_wipe_head = nu; - + if (upball_type == dnball_type) { if (Rhythmic_head::dot_count (nd) < Rhythmic_head::dot_count (nu)) @@ -236,7 +230,7 @@ check_meshing_chords (Grob *me, if (Grob *d = unsmob_grob (dot_wipe_head->get_property ("dot"))) d->suicide (); } - + if (wipe_ball && wipe_ball->is_live ()) { wipe_ball->set_property ("transparent", SCM_BOOL_T); @@ -246,14 +240,14 @@ check_meshing_chords (Grob *me, /* TODO: these numbers are magic; should devise a set of grob props to tune this behavior. */ else if (stem_to_stem) - shift_amount = -abs (shift_amount) * 0.65; + shift_amount = -abs (shift_amount) * 0.65; else if (close_half_collide && !touch) shift_amount *= 0.52; else if (distant_half_collide && !touch) shift_amount *= 0.4; else if (distant_half_collide || close_half_collide || full_collide) shift_amount *= 0.5; - + /* we're meshing. */ else if (Rhythmic_head::dot_count (nu) || Rhythmic_head::dot_count (nd)) shift_amount *= 0.1; @@ -269,15 +263,14 @@ check_meshing_chords (Grob *me, Grob *d = unsmob_grob (nd->get_property ("dot")); Grob *parent = d->get_parent (X_AXIS); - /* FIXME: - - | - x . o + + | + x . o | - + the . is put right of o which is erroneous o force-shifted far to the right. */ @@ -295,45 +288,45 @@ check_meshing_chords (Grob *me, } void -Note_collision_interface::do_shifts (Grob* me) +Note_collision_interface::do_shifts (Grob *me) { - Drul_array< Link_array > cg = get_clash_groups (me); + Drul_array< Link_array > cg = get_clash_groups (me); SCM autos (automatic_shift (me, cg)); SCM hand (forced_shift (me)); - + Direction d = UP; Real wid = 0.0; do { if (cg[d].size ()) { - Grob *h = cg[d][0]; - wid = Note_column::first_head (h)->extent (h, X_AXIS).length () ; + Grob *h = cg[d][0]; + wid = Note_column::first_head (h)->extent (h, X_AXIS).length (); } } while (flip (&d) != UP); - + Link_array done; Real left_most = 1e6; - + Array amounts; for (; scm_is_pair (hand); hand = scm_cdr (hand)) { - Grob * s = unsmob_grob (scm_caar (hand)); + Grob *s = unsmob_grob (scm_caar (hand)); Real amount = scm_to_double (scm_cdar (hand)) * wid; done.push (s); amounts.push (amount); if (amount < left_most) left_most = amount; - + } for (; scm_is_pair (autos); autos = scm_cdr (autos)) { - Grob * s = unsmob_grob (scm_caar (autos)); + Grob *s = unsmob_grob (scm_caar (autos)); Real amount = scm_to_double (scm_cdar (autos)) *wid; - + if (!done.find (s)) { done.push (s); @@ -343,27 +336,27 @@ Note_collision_interface::do_shifts (Grob* me) } } - for (int i = 0; i < amounts.size(); i++) + for (int i = 0; i < amounts.size (); i++) { done[i]->translate_axis (amounts[i] - left_most, X_AXIS); } } -Drul_array< Link_array > -Note_collision_interface::get_clash_groups (Grob *me) +Drul_array< Link_array +> Note_collision_interface::get_clash_groups (Grob *me) { - Drul_array > clash_groups; - + Drul_array < Link_array > clash_groups; + SCM s = me->get_property ("elements"); for (; scm_is_pair (s); s = scm_cdr (s)) { SCM car = scm_car (s); - Grob * se = unsmob_grob (car); + Grob *se = unsmob_grob (car); if (Note_column::has_interface (se)) clash_groups[Note_column::dir (se)].push (se); } - + Direction d = UP; do { @@ -376,19 +369,18 @@ Note_collision_interface::get_clash_groups (Grob *me) } /** This complicated routine moves note columns around horizontally to - ensure that notes don't clash. + ensure that notes don't clash. - This should be put into Scheme. - */ + This should be put into Scheme. +*/ SCM Note_collision_interface::automatic_shift (Grob *me, - Drul_array< Link_array > - clash_groups) + Drul_array< Link_array + > clash_groups) { - Drul_array > shifts; - SCM tups = SCM_EOL; + Drul_array < Array > shifts; + SCM tups = SCM_EOL; - Direction d = UP; do { @@ -405,10 +397,10 @@ Note_collision_interface::automatic_shift (Grob *me, else shift.push (0); } - + for (int i =1; i < shift.size (); i++) { - if (shift[i-1] == shift[i]) + if (shift[i - 1] == shift[i]) { clashes[0]->warning (_ ("Too many clashing notecolumns. Ignoring them.")); return tups; @@ -417,15 +409,15 @@ Note_collision_interface::automatic_shift (Grob *me, } while ((flip (&d))!= UP); - Drul_array< Array < Slice > > extents; - Drul_array< Array < Real > > offsets; + Drul_array< Array > extents; + Drul_array< Array > offsets; d = UP; do { for (int i = 0; i < clash_groups[d].size (); i++) { Slice s (Note_column::head_positions_interval (clash_groups[d][i])); - s[LEFT] --; + s[LEFT]--; s[RIGHT]++; extents[d].push (s); offsets[d].push (d * 0.5 * i); @@ -434,82 +426,77 @@ Note_collision_interface::automatic_shift (Grob *me, while ((flip (&d))!= UP); /* - do horizontal shifts of each direction - - | - x|| - x|| - x| - */ - + do horizontal shifts of each direction + + | + x|| + x|| + x| + */ + do { for (int i =1; i < clash_groups[d].size (); i++) { - Slice prev = extents[d][i-1]; + Slice prev = extents[d][i - 1]; prev.intersect (extents[d][i]); - if (prev.length ()> 0 || - (extents[-d].size () && d * (extents[d][i][-d] - extents[-d][0][d]) < 0)) - for (int j = i; j < clash_groups[d].size (); j++) + if (prev.length ()> 0 + || (extents[-d].size () && d * (extents[d][i][-d] - extents[-d][0][d]) < 0)) + for (int j = i; j < clash_groups[d].size (); j++) offsets[d][j] += d * 0.5; } - } + } while ((flip (&d))!= UP); - /* Check if chords are meshing - */ + */ check_meshing_chords (me, &offsets, extents, clash_groups); - + do { for (int i = 0; i < clash_groups[d].size (); i++) tups = scm_cons (scm_cons (clash_groups[d][i]->self_scm (), - scm_make_real (offsets[d][i])), - tups); + scm_make_real (offsets[d][i])), + tups); } while (flip (&d) != UP); return tups; } - SCM Note_collision_interface::forced_shift (Grob *me) { SCM tups = SCM_EOL; - + SCM s = me->get_property ("elements"); for (; scm_is_pair (s); s = scm_cdr (s)) { - Grob * se = unsmob_grob (scm_car (s)); + Grob *se = unsmob_grob (scm_car (s)); - SCM force = se->get_property ("force-hshift"); + SCM force = se->get_property ("force-hshift"); if (scm_is_number (force)) { tups = scm_cons (scm_cons (se->self_scm (), force), - tups); + tups); } } return tups; } void -Note_collision_interface::add_column (Grob*me, Grob* ncol) +Note_collision_interface::add_column (Grob *me, Grob *ncol) { ncol->add_offset_callback (Note_collision_interface::force_shift_callback_proc, X_AXIS); Axis_group_interface::add_element (me, ncol); me->add_dependency (ncol); } - ADD_INTERFACE (Note_collision_interface, "note-collision-interface", - "An object that handles collisions between notes with different stem " + "An object that handles collisions between notes with different stem " "directions and horizontal shifts. Most of the interesting properties " "are to be set in @ref{note-column-interface}: these are " - "@code{force-hshift} and @code{horizontal-shift}." + "@code{force-hshift} and @code{horizontal-shift}.", - , - "merge-differently-dotted merge-differently-headed positioning-done"); diff --git a/lily/note-column.cc b/lily/note-column.cc index 7e0b80d3f4..fa8e70768f 100644 --- a/lily/note-column.cc +++ b/lily/note-column.cc @@ -22,36 +22,36 @@ /* TODO: figure out if we can prune this class. This is just an annoying layer between (rest)collision & (note-head + stem) - */ +*/ bool -Note_column::has_rests (Grob*me) +Note_column::has_rests (Grob *me) { return unsmob_grob (me->get_property ("rest")); } int -Note_column::shift_compare (Grob *const &p1, Grob *const&p2) +Note_column::shift_compare (Grob *const &p1, Grob *const &p2) { SCM s1 = p1->get_property ("horizontal-shift"); SCM s2 = p2->get_property ("horizontal-shift"); - int h1 = (scm_is_number (s1))? scm_to_int (s1) :0; + int h1 = (scm_is_number (s1))? scm_to_int (s1) :0; int h2 = (scm_is_number (s2)) ? scm_to_int (s2):0; return h1 - h2; } Item * -Note_column::get_stem (Grob*me) +Note_column::get_stem (Grob *me) { SCM s = me->get_property ("stem"); - return unsmob_item (s); + return unsmob_item (s); } - + Slice Note_column::head_positions_interval (Grob *me) { - Slice iv; + Slice iv; iv.set_empty (); @@ -59,7 +59,7 @@ Note_column::head_positions_interval (Grob *me) for (; scm_is_pair (h); h = scm_cdr (h)) { Grob *se = unsmob_grob (scm_car (h)); - + int j = Staff_symbol_referencer::get_rounded_position (se); iv.unite (Slice (j, j)); } @@ -67,7 +67,7 @@ Note_column::head_positions_interval (Grob *me) } Direction -Note_column::dir (Grob* me) +Note_column::dir (Grob *me) { Grob *stem = unsmob_grob (me->get_property ("stem")); if (stem && Stem::has_interface (stem)) @@ -79,24 +79,22 @@ Note_column::dir (Grob* me) return CENTER; } - void -Note_column::set_stem (Grob*me, Grob * stem) +Note_column::set_stem (Grob *me, Grob *stem) { me->set_property ("stem", stem->self_scm ()); me->add_dependency (stem); Axis_group_interface::add_element (me, stem); } - -Grob* -Note_column::get_rest (Grob*me) +Grob * +Note_column::get_rest (Grob *me) { return unsmob_grob (me->get_property ("rest")); } - + void -Note_column::add_head (Grob*me, Grob *h) +Note_column::add_head (Grob *me, Grob *h) { bool both = false; if (Rest::has_interface (h)) @@ -120,50 +118,46 @@ Note_column::add_head (Grob*me, Grob *h) } /** - translate the rest symbols vertically by amount DY, but only if - they have no staff-position set. + translate the rest symbols vertically by amount DY, but only if + they have no staff-position set. */ void -Note_column::translate_rests (Grob*me, int dy) +Note_column::translate_rests (Grob *me, int dy) { - Grob * r = unsmob_grob (me->get_property ("rest")); + Grob *r = unsmob_grob (me->get_property ("rest")); if (r && !scm_is_number (r->get_property ("staff-position"))) { - r->translate_axis (dy * Staff_symbol_referencer::staff_space (r)/2.0, Y_AXIS); + r->translate_axis (dy * Staff_symbol_referencer::staff_space (r) / 2.0, Y_AXIS); Grob *p = r->get_parent (Y_AXIS); p->flush_extent_cache (Y_AXIS); } } - void -Note_column::set_dotcol (Grob*me, Grob *d) +Note_column::set_dotcol (Grob *me, Grob *d) { Axis_group_interface::add_element (me, d); } - - -Grob* -Note_column::first_head (Grob*me) +Grob * +Note_column::first_head (Grob *me) { - Grob * st = get_stem (me); - return st? Stem::first_head (st): 0; + Grob *st = get_stem (me); + return st? Stem::first_head (st): 0; } - /* - Return the first Accidentals grob that we find in a note-head. - */ -Grob* + Return the first Accidentals grob that we find in a note-head. +*/ +Grob * Note_column::accidentals (Grob *me) { SCM heads = me->get_property ("note-heads"); - Grob * acc = 0; + Grob *acc = 0; for (;scm_is_pair (heads); heads = scm_cdr (heads)) { - Grob * h = unsmob_grob (scm_car (heads)); + Grob *h = unsmob_grob (scm_car (heads)); acc = h ? unsmob_grob (h->get_property ("accidental-grob")) : 0; if (acc) break; @@ -171,17 +165,15 @@ Note_column::accidentals (Grob *me) if (!acc) return 0; - + if (Accidental_placement::has_interface (acc->get_parent (X_AXIS))) return acc->get_parent (X_AXIS); /* compatibility. */ - return acc; + return acc; } - - ADD_INTERFACE (Note_column, "note-column-interface", - "Stem and noteheads combined", - "arpeggio note-heads rest-collision rest horizontal-shift stem accidentals force-hshift"); + "Stem and noteheads combined", + "arpeggio note-heads rest-collision rest horizontal-shift stem accidentals force-hshift"); diff --git a/lily/note-head-line-engraver.cc b/lily/note-head-line-engraver.cc index 717c056ac9..cc9decc52a 100644 --- a/lily/note-head-line-engraver.cc +++ b/lily/note-head-line-engraver.cc @@ -1,10 +1,10 @@ -/* +/* note-head-line-engraver.cc -- implement Note_head_line_engraver - + source file of the GNU LilyPond music typesetter - + (c) 2000--2005 Jan Nieuwenhuizen - */ +*/ #include "engraver.hh" #include "group-interface.hh" @@ -19,7 +19,6 @@ TODO: have the line commit suicide if the notes are connected with either slur or beam. - */ class Note_head_line_engraver : public Engraver { @@ -32,11 +31,11 @@ protected: virtual void stop_translation_timestep (); private: - Spanner* line_; - Context* last_staff_; + Spanner *line_; + Context *last_staff_; bool follow_; - Grob* head_; - Grob* last_head_; + Grob *head_; + Grob *last_head_; }; Note_head_line_engraver::Note_head_line_engraver () @@ -56,9 +55,9 @@ Note_head_line_engraver::acknowledge_grob (Grob_info info) head_ = info.grob_; if (to_boolean (get_property ("followVoice"))) { - Context * tr = context (); - while (tr && !tr->is_alias (ly_symbol2scm ( "Staff"))) - tr = tr->get_parent_context () ; + Context *tr = context (); + while (tr && !tr->is_alias (ly_symbol2scm ("Staff"))) + tr = tr->get_parent_context (); if (tr && tr->is_alias (ly_symbol2scm ("Staff")) && tr != last_staff_) @@ -71,7 +70,6 @@ Note_head_line_engraver::acknowledge_grob (Grob_info info) } } - void Note_head_line_engraver::process_acknowledged_grobs () { @@ -79,15 +77,14 @@ Note_head_line_engraver::process_acknowledged_grobs () { /* TODO: Don't follow if there's a beam. - We can't do beam-stuff here, since beam doesn't exist yet. - Should probably store follow_ in line_, and suicide at some - later point */ + We can't do beam-stuff here, since beam doesn't exist yet. + Should probably store follow_ in line_, and suicide at some + later point */ if (follow_) line_ = make_spanner ("VoiceFollower", head_->self_scm ()); - + line_->set_bound (LEFT, last_head_); line_->set_bound (RIGHT, head_); - follow_ = false; } @@ -103,13 +100,11 @@ Note_head_line_engraver::stop_translation_timestep () } - - ADD_TRANSLATOR (Note_head_line_engraver, -/* descr */ "Engrave a line between two note heads, for example a glissando. If " -" followVoice is set, staff switches also generate a line.", -/* creats*/ "Glissando VoiceFollower", -/* accepts */ "glissando-event", -/* acks */ "rhythmic-head-interface", -/* reads */ "followVoice", -/* write */ ""); + /* descr */ "Engrave a line between two note heads, for example a glissando. If " + " followVoice is set, staff switches also generate a line.", + /* creats*/ "Glissando VoiceFollower", + /* accepts */ "glissando-event", + /* acks */ "rhythmic-head-interface", + /* reads */ "followVoice", + /* write */ ""); diff --git a/lily/note-head.cc b/lily/note-head.cc index a2521a75ff..ba5903c8ac 100644 --- a/lily/note-head.cc +++ b/lily/note-head.cc @@ -27,9 +27,9 @@ clean up the mess left by ledger line handling. */ static Stencil -internal_print (Grob *me, String * font_char) +internal_print (Grob *me, String *font_char) { - SCM style = me->get_property ("style"); + SCM style = me->get_property ("style"); if (!scm_is_symbol (style)) { return Stencil (); @@ -39,7 +39,7 @@ internal_print (Grob *me, String * font_char) SCM proc = me->get_property ("glyph-name-procedure"); SCM scm_font_char = scm_call_2 (proc, log, style); - Font_metric * fm = Font_interface::get_default_font (me); + Font_metric *fm = Font_interface::get_default_font (me); Direction stem_dir = CENTER; if (Grob *stem = unsmob_grob (me->get_property ("stem"))) @@ -50,20 +50,20 @@ internal_print (Grob *me, String * font_char) programming_error ("Must have stem dir for note head"); } } - + Stencil out; String prefix = "noteheads."; - String idx = - prefix + ((stem_dir == UP) ? "u" : "d") + ly_scm2string (scm_font_char); + String idx + = prefix + ((stem_dir == UP) ? "u" : "d") + ly_scm2string (scm_font_char); out = fm->find_by_name (idx); if (out.is_empty ()) { idx = prefix + "s" + ly_scm2string (scm_font_char); out = fm->find_by_name (idx); } - - if (out.is_empty()) + + if (out.is_empty ()) { me->warning (_f ("note head `%s' not found", idx.to_str0 ())); } @@ -75,10 +75,9 @@ internal_print (Grob *me, String * font_char) return out; } - MAKE_SCHEME_CALLBACK (Note_head, print, 1); SCM -Note_head::print (SCM smob) +Note_head::print (SCM smob) { Grob *me = unsmob_grob (smob); @@ -86,7 +85,6 @@ Note_head::print (SCM smob) return internal_print (me, &idx).smobbed_copy (); } - MAKE_SCHEME_CALLBACK (Note_head, brew_ez_stencil, 1); SCM Note_head::brew_ez_stencil (SCM smob) @@ -98,14 +96,14 @@ Note_head::brew_ez_stencil (SCM smob) SCM cause = me->get_property ("cause"); SCM spitch = unsmob_music (cause)->get_property ("pitch"); - Pitch* pit = unsmob_pitch (spitch); + Pitch *pit = unsmob_pitch (spitch); SCM idx = scm_int2num (pit->get_notename ()); SCM names = me->get_property ("note-names"); SCM charstr = SCM_EOL; if (scm_is_vector (names)) charstr = scm_vector_ref (names, idx); - else + else { char s[2] = "a"; s[0] = (pit->get_notename () + 2)%7 + 'a'; @@ -116,7 +114,7 @@ Note_head::brew_ez_stencil (SCM smob) SCM at = scm_list_n (ly_symbol2scm ("ez-ball"), charstr, scm_int2num (b), - scm_int2num (1-b), + scm_int2num (1 - b), SCM_UNDEFINED); Box bx (Interval (0, 1.0), Interval (-0.5, 0.5)); Stencil m (bx, at); @@ -124,19 +122,18 @@ Note_head::brew_ez_stencil (SCM smob) return m.smobbed_copy (); } - Real Note_head::stem_attachment_coordinate (Grob *me, Axis a) { SCM brewer = me->get_property ("print-function"); - Font_metric * fm = Font_interface::get_default_font (me); - + Font_metric *fm = Font_interface::get_default_font (me); + if (brewer == Note_head::print_proc) { String key; internal_print (me, &key); - int k = fm->name_to_index (key) ; + int k = fm->name_to_index (key); if (k >= 0) { Box b = fm->get_indexed_char (k); @@ -146,31 +143,31 @@ Note_head::stem_attachment_coordinate (Grob *me, Axis a) return 2 * (wxwy[a] - v.center ()) / v.length (); } } - + /* Fallback - */ + */ SCM v = me->get_property ("stem-attachment-function"); if (!ly_c_procedure_p (v)) return 0.0; - + SCM result = scm_call_2 (v, me->self_scm (), scm_int2num (a)); if (!scm_is_pair (result)) return 0.0; result = (a == X_AXIS) ? scm_car (result) : scm_cdr (result); - + return robust_scm2double (result, 0); } int -Note_head::get_balltype (Grob*me) +Note_head::get_balltype (Grob *me) { SCM s = me->get_property ("duration-log"); return scm_is_number (s) ? scm_to_int (s) is_mus_type ("note-event")) { @@ -45,34 +45,33 @@ Note_heads_engraver::try_music (Music *m) } else if (m->is_mus_type ("busy-playing-event")) return note_evs_.size (); - + return false; } - void Note_heads_engraver::process_music () { for (int i = 0; i < note_evs_.size (); i++) { - Music * ev = note_evs_[i]; + Music *ev = note_evs_[i]; Item *note = make_item ("NoteHead", ev->self_scm ()); - + Duration dur = *unsmob_duration (ev->get_property ("duration")); note->set_property ("duration-log", scm_int2num (dur.duration_log ())); if (dur.dot_count ()) { - Item * d = make_item ("Dots", note->self_scm ()); + Item *d = make_item ("Dots", note->self_scm ()); Rhythmic_head::set_dots (note, d); - + if (dur.dot_count () != robust_scm2int (d->get_property ("dot-count"), 0)) d->set_property ("dot-count", scm_int2num (dur.dot_count ())); d->set_parent (note, Y_AXIS); - + dots_.push (d); } @@ -83,21 +82,21 @@ Note_heads_engraver::process_music () if (scm_is_number (c0)) pos += scm_to_int (c0); - note->set_property ("staff-position", scm_int2num (pos)); + note->set_property ("staff-position", scm_int2num (pos)); /* Shaped note heads change on step of the scale. - */ + */ SCM shape_vector = get_property ("shapeNoteStyles"); if (scm_is_vector (shape_vector)) { SCM scm_tonic = get_property ("tonic"); - Pitch tonic (0, 0, 0); + Pitch tonic (0, 0, 0); if (unsmob_pitch (scm_tonic)) tonic = *unsmob_pitch (scm_tonic); - - unsigned int delta = (pit->get_notename() - tonic.get_notename() + 7) % 7; - + + unsigned int delta = (pit->get_notename () - tonic.get_notename () + 7) % 7; + SCM style = SCM_EOL; if (scm_c_vector_length (shape_vector) > delta && scm_is_symbol (scm_vector_ref (shape_vector, scm_from_int (delta)))) @@ -109,7 +108,7 @@ Note_heads_engraver::process_music () note->set_property ("style", style); } } - + notes_.push (note); } } @@ -122,12 +121,10 @@ Note_heads_engraver::stop_translation_timestep () note_evs_.clear (); } - - ADD_TRANSLATOR (Note_heads_engraver, -/* descr */ "Generate noteheads.", -/* creats*/ "NoteHead Dots", -/* accepts */ "note-event busy-playing-event", -/* acks */ "", -/* reads */ "middleCPosition", -/* write */ ""); + /* descr */ "Generate noteheads.", + /* creats*/ "NoteHead Dots", + /* accepts */ "note-event busy-playing-event", + /* acks */ "", + /* reads */ "middleCPosition", + /* write */ ""); diff --git a/lily/note-name-engraver.cc b/lily/note-name-engraver.cc index 2c99cc724c..0a3814f477 100644 --- a/lily/note-name-engraver.cc +++ b/lily/note-name-engraver.cc @@ -1,11 +1,10 @@ -/* +/* note-name-engraver.cc -- implement Note_name_engraver - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - - */ +*/ #include "engraver.hh" #include "item.hh" @@ -17,7 +16,7 @@ public: Link_array events_; Link_array texts_; - virtual bool try_music (Music*m); + virtual bool try_music (Music *m); virtual void process_music (); virtual void stop_translation_timestep (); }; @@ -36,7 +35,7 @@ Note_name_engraver::try_music (Music *m) void Note_name_engraver::process_music () { - String s ; + String s; for (int i = 0; i < events_.size (); i++) { if (i) @@ -44,13 +43,13 @@ Note_name_engraver::process_music () Pitch p = *unsmob_pitch (events_[i]->get_property ("pitch")); if (!to_boolean (get_property ("printOctaveNames"))) - p = Pitch (-1, p.get_notename (), p.get_alteration ()); - + p = Pitch (-1, p.get_notename (), p.get_alteration ()); + s += p.to_string (); } if (s.length ()) { - Item * t = make_item ("NoteName", events_[0]->self_scm () ); + Item *t = make_item ("NoteName", events_[0]->self_scm ()); t->set_property ("text", scm_makfrom0str (s.to_str0 ())); texts_.push (t); } @@ -59,19 +58,18 @@ Note_name_engraver::process_music () void Note_name_engraver::stop_translation_timestep () { - texts_.clear () ; + texts_.clear (); events_.clear (); } - Note_name_engraver::Note_name_engraver () { } ADD_TRANSLATOR (Note_name_engraver, -/* descr */ "", -/* creats*/ "NoteName", -/* accepts */ "note-event", -/* acks */ "", -/* reads */ "printOctaveNames", -/* write */ ""); + /* descr */ "", + /* creats*/ "NoteName", + /* accepts */ "note-event", + /* acks */ "", + /* reads */ "printOctaveNames", + /* write */ ""); diff --git a/lily/note-performer.cc b/lily/note-performer.cc index 531b4788d6..3bdbcb0df3 100644 --- a/lily/note-performer.cc +++ b/lily/note-performer.cc @@ -4,7 +4,7 @@ source file of the GNU LilyPond music typesetter (c) 1996--2005 Jan Nieuwenhuizen - */ +*/ #include "performer.hh" #include "audio-item.hh" @@ -13,24 +13,25 @@ #include "warn.hh" /** -Convert evs to audio notes. + Convert evs to audio notes. */ -class Note_performer : public Performer { +class Note_performer : public Performer +{ public: TRANSLATOR_DECLARATIONS (Note_performer); - + protected: - virtual bool try_music (Music *ev) ; + virtual bool try_music (Music *ev); virtual void stop_translation_timestep (); virtual void create_audio_elements (); - + private: Link_array note_evs_; Link_array notes_; }; -void +void Note_performer::create_audio_elements () { if (note_evs_.size ()) @@ -38,17 +39,17 @@ Note_performer::create_audio_elements () int transposing = 0; SCM prop = get_property ("instrumentTransposition"); - if (unsmob_pitch (prop)) + if (unsmob_pitch (prop)) transposing = unsmob_pitch (prop)->semitone_pitch (); while (note_evs_.size ()) { - Music* n = note_evs_.pop (); - SCM pit = n->get_property ("pitch"); + Music *n = note_evs_.pop (); + SCM pit = n->get_property ("pitch"); - if (Pitch * pitp = unsmob_pitch (pit)) + if (Pitch *pitp = unsmob_pitch (pit)) { - Audio_note* p = new Audio_note (*pitp, n->get_length (), - transposing); + Audio_note *p = new Audio_note (*pitp, n->get_length (), - transposing); Audio_element_info info (p, n); announce_element (info); notes_.push (p); @@ -58,7 +59,6 @@ Note_performer::create_audio_elements () } } - void Note_performer::stop_translation_timestep () { @@ -72,9 +72,9 @@ Note_performer::stop_translation_timestep () notes_.clear (); note_evs_.clear (); } - + bool -Note_performer::try_music (Music* ev) +Note_performer::try_music (Music *ev) { if (ev->is_mus_type ("note-event")) { @@ -83,12 +83,12 @@ Note_performer::try_music (Music* ev) } else if (ev->is_mus_type ("busy-playing-event")) return note_evs_.size (); - + return false; } ADD_TRANSLATOR (Note_performer, "", "", - "note-event busy-playing-event", "", "", ""); + "note-event busy-playing-event", "", "", ""); Note_performer::Note_performer () { diff --git a/lily/note-spacing.cc b/lily/note-spacing.cc index f8924576e2..b4d85287d2 100644 --- a/lily/note-spacing.cc +++ b/lily/note-spacing.cc @@ -1,4 +1,4 @@ -/* +/* note-spacing.cc -- implement Note_spacing source file of the GNU LilyPond music typesetter @@ -19,30 +19,28 @@ #include "output-def.hh" /* - -TODO: detect hshifts due to collisions, and account for them in -spacing? - -*/ + TODO: detect hshifts due to collisions, and account for them in + spacing? +*/ void -Note_spacing::get_spacing (Grob *me, Item* right_col, +Note_spacing::get_spacing (Grob *me, Item *right_col, Real base_space, Real increment, Real *space, Real *fixed) { Drul_array props (me->get_property ("left-items"), - me->get_property ("right-items")); + me->get_property ("right-items")); Direction d = LEFT; - Direction col_dir = right_col->break_status_dir (); + Direction col_dir = right_col->break_status_dir (); Drul_array extents; - Interval left_head_wid; + Interval left_head_wid; do { - for (SCM s = props[d]; scm_is_pair (s); s = scm_cdr (s)) + for (SCM s = props[d]; scm_is_pair (s); s = scm_cdr (s)) { - Item * it = dynamic_cast (unsmob_grob (scm_car (s))); - + Item *it = dynamic_cast (unsmob_grob (scm_car (s))); + if (d == RIGHT && it->break_status_dir () != col_dir) { it = it -> find_prebroken_piece (col_dir); @@ -51,14 +49,14 @@ Note_spacing::get_spacing (Grob *me, Item* right_col, /* some kind of mismatch, eg. a note column, that is behind a linebreak. - */ + */ if (!it) - continue; + continue; Item *it_col = it->get_column (); if (d == RIGHT && right_col != it_col) continue; - + if (Separation_item::has_interface (it)) { extents[d].unite (Separation_item::width (it)); @@ -68,30 +66,30 @@ Note_spacing::get_spacing (Grob *me, Item* right_col, if (d == LEFT) { SCM r = it->get_property ("rest"); - Grob * g = unsmob_grob (r); + Grob *g = unsmob_grob (r); if (!g) - g = Note_column::first_head (it); + g = Note_column::first_head (it); /* Ugh. If Stem is switched off, we don't know what the first note head will be. - */ + */ if (g) left_head_wid = g->extent (it_col, X_AXIS); } - + extents[d].unite (it->extent (it_col, X_AXIS)); if (d == RIGHT) { - Grob * accs = Note_column::accidentals (it); + Grob *accs = Note_column::accidentals (it); if (!accs) accs = Note_column::accidentals (it->get_parent (X_AXIS)); - + if (accs) { - Interval v = - Accidental_placement::get_relevant_accidental_extent (accs, it_col, me); - + Interval v + = Accidental_placement::get_relevant_accidental_extent (accs, it_col, me); + extents[d].unite (v); } } @@ -102,7 +100,6 @@ Note_spacing::get_spacing (Grob *me, Item* right_col, } while (flip (&d) != LEFT); - /* We look at the width of the note head, since smaller heads get less space eg. a quarter rest gets almost 0.5 ss less horizontal space than a note. @@ -112,30 +109,30 @@ Note_spacing::get_spacing (Grob *me, Item* right_col, FIXED also includes the left part of the right object. */ - *fixed = - (left_head_wid.is_empty () ? increment : - /* - Size of the head: - */ - (left_head_wid[RIGHT]+ + *fixed + = (left_head_wid.is_empty () ? increment : + /* + Size of the head: + */ + (left_head_wid[RIGHT]+ - /* - What's sticking out of the head, eg. a flag: - */ - (extents[LEFT][RIGHT] - left_head_wid[RIGHT])/2)) + /* + What's sticking out of the head, eg. a flag: + */ + (extents[LEFT][RIGHT] - left_head_wid[RIGHT]) / 2)) /* What is sticking out of the right note: - */ - + (extents[RIGHT].is_empty () ? 0.0 : - extents[RIGHT][LEFT] / 2); + */ + + (extents[RIGHT].is_empty () ? 0.0 : - extents[RIGHT][LEFT] / 2); /* We don't do complicated stuff: (base_space - increment) is the normal amount of white, which also determines the amount of stretch. Upon (extreme) stretching, notes with accidentals should stretch as much as notes without accidentals. - */ - *space = (base_space - increment) + *fixed ; + */ + *space = (base_space - increment) + *fixed; if (!extents[RIGHT].is_empty () && (Item::is_breakable (right_col) @@ -149,12 +146,12 @@ Note_spacing::get_spacing (Grob *me, Item* right_col, Since we only take half of the right-object space above, the barline will bump into the notes preceding it, if the right thing is big. We add the rest of the extents here: - */ - + */ + *space += -extents[RIGHT][LEFT] / 2; *fixed += -extents[RIGHT][LEFT] / 2; } - + stem_dir_correction (me, right_col, increment, space, fixed); } @@ -163,33 +160,32 @@ Note_spacing::left_column (Grob *me) { if (!me->is_live ()) return 0; - - return dynamic_cast (me)->get_column (); + + return dynamic_cast (me)->get_column (); } /* Compute the column of the right-items. This is a big function, -since RIGHT-ITEMS may span more columns (eg. if a clef if inserted, -this will add a new columns to RIGHT-ITEMS. Here we look at the -columns, and return the left-most. If there are multiple columns, we -prune RIGHT-ITEMS. - - */ + since RIGHT-ITEMS may span more columns (eg. if a clef if inserted, + this will add a new columns to RIGHT-ITEMS. Here we look at the + columns, and return the left-most. If there are multiple columns, we + prune RIGHT-ITEMS. +*/ Item * -Note_spacing::right_column (Grob*me) +Note_spacing::right_column (Grob *me) { if (!me->is_live ()) return 0; - + SCM right = me->get_property ("right-items"); Item *mincol = 0; int min_rank = INT_MAX; bool prune = false; - for (SCM s = right ; scm_is_pair (s) ; s = scm_cdr (s)) + for (SCM s = right; scm_is_pair (s); s = scm_cdr (s)) { - Item * ri = unsmob_item (scm_car (s)); + Item *ri = unsmob_item (scm_car (s)); - Item * col = ri->get_column (); + Item *col = ri->get_column (); int rank = Paper_column::get_rank (col); if (rank < min_rank) @@ -201,12 +197,12 @@ Note_spacing::right_column (Grob*me) mincol = col; } } - + if (prune) { // I'm a lazy bum. We could do this in-place. - SCM newright = SCM_EOL; - for (SCM s = right ; scm_is_pair (s) ; s = scm_cdr (s)) + SCM newright = SCM_EOL; + for (SCM s = right; scm_is_pair (s); s = scm_cdr (s)) { if (unsmob_item (scm_car (s))->get_column () == mincol) newright = scm_cons (scm_car (s), newright); @@ -214,12 +210,12 @@ Note_spacing::right_column (Grob*me) me->set_property ("right-items", newright); } - + if (!mincol) { /* - int r = Paper_column::get_rank (dynamic_cast(me)->get_column ()); - programming_error (_f ("Spacing wish column %d has no right item.", r)); + int r = Paper_column::get_rank (dynamic_cast(me)->get_column ()); + programming_error (_f ("Spacing wish column %d has no right item.", r)); */ return 0; @@ -234,40 +230,39 @@ Note_spacing::right_column (Grob*me) down-stem + up-stem less. TODO: have to check wether the stems are in the same staff. - */ void -Note_spacing::stem_dir_correction (Grob*me, Item * rcolumn, +Note_spacing::stem_dir_correction (Grob *me, Item *rcolumn, Real increment, - Real * space, Real *fixed) + Real *space, Real *fixed) { Drul_array stem_dirs (CENTER, CENTER); Drul_array stem_posns; - Drul_array head_posns; + Drul_array head_posns; Drul_array props (me->get_property ("left-items"), - me->get_property ("right-items")); + me->get_property ("right-items")); + + Drul_array beams_drul (0, 0); + Drul_array stems_drul (0, 0); - Drul_array beams_drul (0, 0); - Drul_array stems_drul (0, 0); - stem_dirs[LEFT] = stem_dirs[RIGHT] = CENTER; Interval intersect; Interval bar_xextent; - Interval bar_yextent; - + Interval bar_yextent; + bool correct_stem_dirs = true; Direction d = LEFT; bool acc_right = false; - + do { - for (SCM s = props[d]; scm_is_pair (s); s = scm_cdr (s)) + for (SCM s = props[d]; scm_is_pair (s); s = scm_cdr (s)) { - Item * it = dynamic_cast (unsmob_grob (scm_car (s))); + Item *it = dynamic_cast (unsmob_grob (scm_car (s))); if (d == RIGHT) acc_right = acc_right || Note_column::accidentals (it); - + Grob *stem = Note_column::get_stem (it); if (!stem || !stem->is_live ()) @@ -278,7 +273,7 @@ Note_spacing::stem_dir_correction (Grob*me, Item * rcolumn, { it = it->find_prebroken_piece (rcolumn->break_status_dir ()); } - + Grob *last = Separation_item::extremal_break_aligned_grob (it, LEFT, &bar_xextent); if (last) @@ -287,9 +282,9 @@ Note_spacing::stem_dir_correction (Grob*me, Item * rcolumn, break; } - return ; + return; } - + if (Stem::is_invisible (stem)) { correct_stem_dirs = false; @@ -298,7 +293,7 @@ Note_spacing::stem_dir_correction (Grob*me, Item * rcolumn, stems_drul[d] = stem; beams_drul[d] = Stem::get_beam (stem); - + Direction sd = Stem::get_direction (stem); if (stem_dirs[d] && stem_dirs[d] != sd) { @@ -310,52 +305,51 @@ Note_spacing::stem_dir_correction (Grob*me, Item * rcolumn, /* Correction doesn't seem appropriate when there is a large flag hanging from the note. - */ + */ if (d == LEFT - && Stem::duration_log (stem) > 2 && !Stem::get_beam (stem)) + && Stem::duration_log (stem) > 2 && !Stem::get_beam (stem)) { correct_stem_dirs = false; } - - Interval hp = Stem::head_positions (stem); - if (!hp.is_empty()) + + Interval hp = Stem::head_positions (stem); + if (!hp.is_empty ()) { - Real chord_start = hp[sd]; + Real chord_start = hp[sd]; Real stem_end = Stem::stem_end_position (stem); - + stem_posns[d] = Interval (chord_start ? stem_end); head_posns[d].unite (hp); } } } while (flip (&d) != LEFT); - /* don't correct if accidentals are sticking out of the right side. */ if (acc_right) - return ; + return; Real correction = 0.0; if (!bar_yextent.is_empty ()) { - stem_dirs[RIGHT] = - stem_dirs[LEFT]; + stem_dirs[RIGHT] = -stem_dirs[LEFT]; stem_posns[RIGHT] = bar_yextent; } - + if (correct_stem_dirs && stem_dirs[LEFT] *stem_dirs[RIGHT] == -1) { if (beams_drul[LEFT] && beams_drul[LEFT] == beams_drul[RIGHT]) { - + /* this is a knee: maximal correction. */ Real note_head_width = increment; - Grob * st = stems_drul[RIGHT]; - Grob * head = st ? Stem::support_head (st) : 0; + Grob *st = stems_drul[RIGHT]; + Grob *head = st ? Stem::support_head (st) : 0; Interval head_extent; if (head) @@ -379,7 +373,7 @@ Note_spacing::stem_dir_correction (Grob*me, Item * rcolumn, } else { - intersect = stem_posns[LEFT]; + intersect = stem_posns[LEFT]; intersect.intersect (stem_posns[RIGHT]); correct_stem_dirs = correct_stem_dirs && !intersect.is_empty (); @@ -387,16 +381,15 @@ Note_spacing::stem_dir_correction (Grob*me, Item * rcolumn, { correction = abs (intersect.length ()); - /* Ugh. 7 is hardcoded. */ - correction = (correction/7) get_property ("stem-spacing-correction"), 0); + correction = (correction / 7) get_property ("stem-spacing-correction"), 0); } - + if (!bar_yextent.is_empty ()) { correction *= 0.5; @@ -408,36 +401,35 @@ Note_spacing::stem_dir_correction (Grob*me, Item * rcolumn, /* Correct for the following situation: - X X - | | + X X + | | | | | X | | | | ======== - ^ move the center one to the left. - + ^ move the center one to the left. + this effect seems to be much more subtle than the stem-direction stuff (why?), and also does not scale with the difference in stem length. - - */ - + */ + Interval hp = head_posns[LEFT]; - hp.intersect (head_posns[RIGHT]); + hp.intersect (head_posns[RIGHT]); if (!hp.is_empty ()) - return ; + return; - Direction lowest = - (head_posns[LEFT][DOWN] > head_posns[RIGHT][UP]) ? RIGHT : LEFT; + Direction lowest + = (head_posns[LEFT][DOWN] > head_posns[RIGHT][UP]) ? RIGHT : LEFT; - Real delta = head_posns[-lowest][DOWN] - head_posns[lowest][UP] ; + Real delta = head_posns[-lowest][DOWN] - head_posns[lowest][UP]; Real corr = robust_scm2double (me->get_property ("stem-spacing-correction"), 0); - corr = (delta <= 1) ? 0.0 : 0.25; - - correction = -lowest * corr ; + corr = (delta <= 1) ? 0.0 : 0.25; + + correction = -lowest * corr; } *space += correction; @@ -447,11 +439,9 @@ Note_spacing::stem_dir_correction (Grob*me, Item * rcolumn, */ } - - ADD_INTERFACE (Note_spacing, "note-spacing-interface", - "This object calculates spacing wishes for individual voices.", - "left-items right-items stem-spacing-correction knee-spacing-correction"); + "This object calculates spacing wishes for individual voices.", + "left-items right-items stem-spacing-correction knee-spacing-correction"); diff --git a/lily/object-key-dumper-scheme.cc b/lily/object-key-dumper-scheme.cc index 6524285231..3a3d77575c 100644 --- a/lily/object-key-dumper-scheme.cc +++ b/lily/object-key-dumper-scheme.cc @@ -4,45 +4,41 @@ source file of the GNU LilyPond music typesetter (c) 2005 Han-Wen Nienhuys - */ #include "object-key-dumper.hh" #include "moment.hh" -LY_DEFINE(ly_make_dumper, "ly:make-dumper", - 0, 0, 0, - (), - "Create a key dumper. " - ) +LY_DEFINE (ly_make_dumper, "ly:make-dumper", + 0, 0, 0, + (), + "Create a key dumper. ") { Object_key_dumper *u = new Object_key_dumper (); - SCM x = u->self_scm(); + SCM x = u->self_scm (); scm_gc_unprotect_object (x); return x; } -LY_DEFINE(ly_dumper_definitions, "ly:dumper-definitions", - 1, 0, 0, - (SCM dumper), - "Return list of key definitions. " - ) +LY_DEFINE (ly_dumper_definitions, "ly:dumper-definitions", + 1, 0, 0, + (SCM dumper), + "Return list of key definitions. ") { Object_key_dumper *u = unsmob_key_dumper (dumper); - SCM_ASSERT_TYPE(u, dumper, SCM_ARG1, __FUNCTION__, "dumper"); - return u->get_file_contents(); + SCM_ASSERT_TYPE (u, dumper, SCM_ARG1, __FUNCTION__, "dumper"); + return u->get_file_contents (); } -LY_DEFINE(ly_dumper_key_serial, "ly:dumper-key-serial", - 2, 0, 0, - (SCM dumper, SCM key), - "Return the key serial number @var{key}. " - ) +LY_DEFINE (ly_dumper_key_serial, "ly:dumper-key-serial", + 2, 0, 0, + (SCM dumper, SCM key), + "Return the key serial number @var{key}. ") { - Object_key_dumper* u = unsmob_key_dumper (dumper); + Object_key_dumper *u = unsmob_key_dumper (dumper); Object_key *k = unsmob_key (key); - SCM_ASSERT_TYPE(u, dumper, SCM_ARG1, __FUNCTION__, "dumper"); - SCM_ASSERT_TYPE(k, key, SCM_ARG2, __FUNCTION__, "key"); + SCM_ASSERT_TYPE (u, dumper, SCM_ARG1, __FUNCTION__, "dumper"); + SCM_ASSERT_TYPE (k, key, SCM_ARG2, __FUNCTION__, "key"); return u->dump_key (k); } diff --git a/lily/object-key-dumper.cc b/lily/object-key-dumper.cc index e3a1ef5322..4a29c9c7ae 100644 --- a/lily/object-key-dumper.cc +++ b/lily/object-key-dumper.cc @@ -4,7 +4,6 @@ source file of the GNU LilyPond music typesetter (c) 2004--2005 Han-Wen Nienhuys - */ #include "object-key-dumper.hh" @@ -14,15 +13,15 @@ #include "ly-smobs.icc" SCM -Object_key_dumper::mark_smob (SCM smob ) +Object_key_dumper::mark_smob (SCM smob) { - Object_key_dumper * dumper = (Object_key_dumper*) SCM_CELL_WORD_1 (smob); - + Object_key_dumper *dumper = (Object_key_dumper *) SCM_CELL_WORD_1 (smob); + for (Key_to_key_map::const_iterator i (dumper->serialized_keys_.begin ()); - i != dumper->serialized_keys_.end(); + i != dumper->serialized_keys_.end (); i++) { - scm_gc_mark ((*i).first->self_scm()); + scm_gc_mark ((*i).first->self_scm ()); } return SCM_EOL; } @@ -34,8 +33,8 @@ Object_key_dumper::print_smob (SCM, SCM port, scm_print_state*) return 1; } -IMPLEMENT_DEFAULT_EQUAL_P(Object_key_dumper); -IMPLEMENT_SMOBS(Object_key_dumper); +IMPLEMENT_DEFAULT_EQUAL_P (Object_key_dumper); +IMPLEMENT_SMOBS (Object_key_dumper); Object_key_dumper::Object_key_dumper () { @@ -54,10 +53,10 @@ Object_key_dumper::key_serial (int k) SCM Object_key_dumper::serialize_key (Object_key const *key) { - SCM skey = key->dump(); - for (SCM s = skey ; scm_is_pair (s) ; s = scm_cdr (s)) + SCM skey = key->dump (); + for (SCM s = skey; scm_is_pair (s); s = scm_cdr (s)) { - if (Object_key const * sub_key = unsmob_key (scm_car (s))) + if (Object_key const *sub_key = unsmob_key (scm_car (s))) { scm_set_car_x (s, dump_key (sub_key)); } @@ -65,11 +64,11 @@ Object_key_dumper::serialize_key (Object_key const *key) { scm_set_car_x (s, scm_list_2 (ly_symbol2scm ("unquote"), - mom->as_scheme())); + mom->as_scheme ())); } } - file_contents_ = scm_cons (scm_list_3 (ly_symbol2scm("define-key"), + file_contents_ = scm_cons (scm_list_3 (ly_symbol2scm ("define-key"), scm_from_int (next_available_), skey), file_contents_); @@ -77,7 +76,7 @@ Object_key_dumper::serialize_key (Object_key const *key) serialized_keys_[key] = key; key_serial_numbers_[key] = next_available_; SCM retval = key_serial (next_available_); - next_available_ ++; + next_available_++; return retval; } @@ -93,7 +92,7 @@ Object_key_dumper::dump_key (Object_key const *key) { return key_serial (key_serial_numbers_[ serialized_keys_ [serialized] ]); } - + return serialize_key (key); } @@ -103,6 +102,6 @@ Object_key_dumper::get_file_contents () const return scm_reverse (file_contents_); } -Object_key_dumper::~Object_key_dumper() +Object_key_dumper::~Object_key_dumper () { } diff --git a/lily/object-key-undumper-scheme.cc b/lily/object-key-undumper-scheme.cc index 5a01f1d009..713659eea4 100644 --- a/lily/object-key-undumper-scheme.cc +++ b/lily/object-key-undumper-scheme.cc @@ -4,49 +4,43 @@ source file of the GNU LilyPond music typesetter (c) 2005 Han-Wen Nienhuys - */ #include "object-key-undumper.hh" -LY_DEFINE(ly_undumper_read_keys, "ly:undumper-read-keys", - 2, 0, 0, - (SCM undumper, SCM keys), - "Read serialized @var{keys} into @var{undumper}." - ) +LY_DEFINE (ly_undumper_read_keys, "ly:undumper-read-keys", + 2, 0, 0, + (SCM undumper, SCM keys), + "Read serialized @var{keys} into @var{undumper}.") { Object_key_undumper *u = unsmob_key_undumper (undumper); - SCM_ASSERT_TYPE(u, undumper, SCM_ARG1, __FUNCTION__, "Undumper"); + SCM_ASSERT_TYPE (u, undumper, SCM_ARG1, __FUNCTION__, "Undumper"); u->parse_contents (keys); return SCM_UNSPECIFIED; } -LY_DEFINE(ly_make_undumper, "ly:make-undumper", - 0, 0, 0, - (), - "Create a key undumper. " - ) +LY_DEFINE (ly_make_undumper, "ly:make-undumper", + 0, 0, 0, + (), + "Create a key undumper. ") { Object_key_undumper *u = new Object_key_undumper (); - SCM x = u->self_scm(); + SCM x = u->self_scm (); scm_gc_unprotect_object (x); return x; } +LY_DEFINE (ly_undumper_lookup, "ly:undumper-lookup", + 2, 0, 0, + (SCM undumper, SCM serial), + "Return the object key for number @var{serial}. ") -LY_DEFINE(ly_undumper_lookup, "ly:undumper-lookup", - 2, 0, 0, - (SCM undumper, SCM serial), - "Return the object key for number @var{serial}. " - ) - { - Object_key_undumper* u = unsmob_key_undumper (undumper); + Object_key_undumper *u = unsmob_key_undumper (undumper); - SCM_ASSERT_TYPE(u, undumper, SCM_ARG1, __FUNCTION__, "undumper"); - SCM_ASSERT_TYPE(scm_is_integer(serial), serial, SCM_ARG2, __FUNCTION__, "integer"); - return u->get_key (scm_to_int (serial))->self_scm(); + SCM_ASSERT_TYPE (u, undumper, SCM_ARG1, __FUNCTION__, "undumper"); + SCM_ASSERT_TYPE (scm_is_integer (serial), serial, SCM_ARG2, __FUNCTION__, "integer"); + return u->get_key (scm_to_int (serial))->self_scm (); } - diff --git a/lily/object-key-undumper.cc b/lily/object-key-undumper.cc index 52032e43cf..f904646b38 100644 --- a/lily/object-key-undumper.cc +++ b/lily/object-key-undumper.cc @@ -4,22 +4,21 @@ source file of the GNU LilyPond music typesetter (c) 2004--2005 Han-Wen Nienhuys - */ #include "object-key-undumper.hh" #include "ly-smobs.icc" -IMPLEMENT_SMOBS(Object_key_undumper); -IMPLEMENT_DEFAULT_EQUAL_P(Object_key_undumper); +IMPLEMENT_SMOBS (Object_key_undumper); +IMPLEMENT_DEFAULT_EQUAL_P (Object_key_undumper); SCM Object_key_undumper::mark_smob (SCM smob) { - Object_key_undumper * undumper = (Object_key_undumper*) SCM_CELL_WORD_1(smob); - for (Int_to_key_map::const_iterator i (undumper->keys_.begin()); - i != undumper->keys_.end(); i++) + Object_key_undumper *undumper = (Object_key_undumper *) SCM_CELL_WORD_1 (smob); + for (Int_to_key_map::const_iterator i (undumper->keys_.begin ()); + i != undumper->keys_.end (); i++) { scm_gc_mark ((*i).second->self_scm ()); } @@ -30,18 +29,16 @@ Object_key_undumper::mark_smob (SCM smob) int Object_key_undumper::print_smob (SCM s, SCM port, scm_print_state*) { - (void) s; + (void) s; scm_puts ("#", port); return 1; } - Object_key_undumper::Object_key_undumper () { - smobify_self(); + smobify_self (); } - void Object_key_undumper::parse_contents (SCM contents) { @@ -51,7 +48,6 @@ Object_key_undumper::parse_contents (SCM contents) if (scm_car (entry) != ly_symbol2scm ("define-key")) continue; - int number = scm_to_int (scm_cadr (entry)); SCM skey = scm_caddr (entry); @@ -65,31 +61,31 @@ Object_key_undumper::parse_contents (SCM contents) { int index = scm_to_int (scm_cadr (item)); Object_key const *key = get_key (index); - *tail = scm_cons (key->self_scm(), SCM_EOL); + *tail = scm_cons (key->self_scm (), SCM_EOL); } else { *tail = scm_cons (item, SCM_EOL); } - tail = SCM_CDRLOC(*tail); + tail = SCM_CDRLOC (*tail); } Object_key *k = Object_key::undump (new_key); keys_[number] = k; - scm_gc_unprotect_object (k->self_scm()); + scm_gc_unprotect_object (k->self_scm ()); } - + } -Object_key const* +Object_key const * Object_key_undumper::get_key (int idx) { Int_to_key_map::const_iterator i (keys_.find (idx)); - assert (i != keys_.end()); + assert (i != keys_.end ()); return (*i).second; } -Object_key_undumper::~Object_key_undumper() +Object_key_undumper::~Object_key_undumper () { } diff --git a/lily/object-key.cc b/lily/object-key.cc index d912b3d088..134ff7fb23 100644 --- a/lily/object-key.cc +++ b/lily/object-key.cc @@ -4,7 +4,6 @@ source file of the GNU LilyPond music typesetter (c) 2004--2005 Han-Wen Nienhuys - */ #include "lilypond-key.hh" @@ -13,18 +12,18 @@ SCM Object_key::mark_smob (SCM key) { - Object_key* k = (Object_key*) SCM_CELL_WORD_1 (key); - k->derived_mark(); + Object_key *k = (Object_key *) SCM_CELL_WORD_1 (key); + k->derived_mark (); return SCM_EOL; } void Object_key::derived_mark () const { - + } -Object_key::~Object_key() +Object_key::~Object_key () { } @@ -37,9 +36,9 @@ Object_key::get_type () const int Object_key::print_smob (SCM smob, SCM port, scm_print_state*) { - Object_key* k = (Object_key*) SCM_CELL_WORD_1 (smob); + Object_key *k = (Object_key *) SCM_CELL_WORD_1 (smob); scm_puts ("#get_type()), port); + scm_display (scm_from_int (k->get_type ()), port); scm_puts (">", port); return 1; } @@ -54,8 +53,8 @@ Object_key::compare (Object_key const *other) const { if (this == other) return 0; - - int c = sign (get_type () - other->get_type()); + + int c = sign (get_type () - other->get_type ()); if (c) return c; else @@ -65,11 +64,11 @@ Object_key::compare (Object_key const *other) const IMPLEMENT_SMOBS (Object_key); SCM -Object_key::equal_p (SCM a , SCM b) +Object_key::equal_p (SCM a, SCM b) { Object_key *ka = unsmob_key (a); Object_key *kb = unsmob_key (b); - + return (ka->compare (kb)) ? SCM_BOOL_F : SCM_BOOL_T; } @@ -79,34 +78,33 @@ Object_key::do_compare (Object_key const *) const return 0; } - SCM Object_key::dump () const { - return scm_cons (scm_from_int (get_type()), - as_scheme()); + return scm_cons (scm_from_int (get_type ()), + as_scheme ()); } - - SCM Object_key::as_scheme () const { - return SCM_EOL; + return SCM_EOL; } -Object_key* +Object_key * Object_key::from_scheme (SCM) { - return new Object_key(); + return new Object_key (); } -struct Object_dumper_table_entry { +struct Object_dumper_table_entry +{ Object_key_type type_; - Object_key* (*ctor_)(SCM); + Object_key *(*ctor_) (SCM); }; -static Object_dumper_table_entry undumpers[] = { +static Object_dumper_table_entry undumpers[] += { {BASE_KEY, Object_key::from_scheme}, {COPIED_KEY, Copied_key::from_scheme}, {GENERAL_KEY, Lilypond_general_key::from_scheme}, @@ -120,12 +118,12 @@ Object_key::undump (SCM scm_key) { int t = scm_to_int (scm_car (scm_key)); assert (t == undumpers[t].type_); - return (undumpers[t].ctor_)(scm_cdr (scm_key)); + return (undumpers[t].ctor_) (scm_cdr (scm_key)); } /****************************************************************/ -Copied_key::Copied_key (Object_key const* key, int count) +Copied_key::Copied_key (Object_key const *key, int count) { copy_count_ = count; original_ = key; @@ -140,8 +138,8 @@ Copied_key::get_type () const int Copied_key::do_compare (Object_key const *key) const { - Copied_key const *other = dynamic_cast (key); - + Copied_key const *other = dynamic_cast < Copied_key const *> (key); + int c = original_->compare (other->original_); if (c) return c; @@ -158,13 +156,12 @@ Copied_key::derived_mark () const SCM Copied_key::as_scheme () const { - return scm_list_2 (original_ ? original_->self_scm() : SCM_BOOL_F, scm_from_int (copy_count_)); + return scm_list_2 (original_ ? original_->self_scm () : SCM_BOOL_F, scm_from_int (copy_count_)); } - Object_key * -Copied_key::from_scheme (SCM a) +Copied_key::from_scheme (SCM a) { return new Copied_key (unsmob_key (scm_car (a)), - scm_to_int (scm_list_ref (a, scm_from_int (1)))); + scm_to_int (scm_list_ref (a, scm_from_int (1)))); } diff --git a/lily/open-type-font-scheme.cc b/lily/open-type-font-scheme.cc index 241ffac057..4430d14438 100644 --- a/lily/open-type-font-scheme.cc +++ b/lily/open-type-font-scheme.cc @@ -10,7 +10,7 @@ #include "open-type-font.hh" LY_DEFINE (ly_font_sub_fonts, "ly:font-sub-fonts", 1, 0, 0, - (SCM font), + (SCM font), "Given the font metric @var{font} of an OpenType font, return the " "names of the subfonts within @var{font}.") { @@ -20,13 +20,13 @@ LY_DEFINE (ly_font_sub_fonts, "ly:font-sub-fonts", 1, 0, 0, } LY_DEFINE (ly_otf_font_glyph_info, "ly:otf-font-glyph-info", 2, 0, 0, - (SCM font, SCM glyph), + (SCM font, SCM glyph), "Given the font metric @var{font} of an OpenType font, return the " "information about named glyph @var{glyph} (a string)") { - Modified_font_metric * fm - = dynamic_cast (unsmob_metrics (font)); - Open_type_font * otf = dynamic_cast (fm->original_font ()); + Modified_font_metric *fm + = dynamic_cast (unsmob_metrics (font)); + Open_type_font *otf = dynamic_cast (fm->original_font ()); SCM_ASSERT_TYPE (otf, font, SCM_ARG1, __FUNCTION__, "OTF font-metric"); SCM_ASSERT_TYPE (scm_is_string (glyph), glyph, SCM_ARG1, __FUNCTION__, "string"); diff --git a/lily/open-type-font.cc b/lily/open-type-font.cc index b47a53612e..386a618a9c 100644 --- a/lily/open-type-font.cc +++ b/lily/open-type-font.cc @@ -24,11 +24,11 @@ load_table (char const *tag_str, FT_Face face, FT_ULong *length) int error_code = FT_Load_Sfnt_Table (face, tag, 0, NULL, length); if (!error_code) { - FT_Byte *buffer = (FT_Byte*) malloc (*length); + FT_Byte *buffer = (FT_Byte *) malloc (*length); if (buffer == NULL) error (_f ("Cannot allocate %d bytes", *length)); - error_code = FT_Load_Sfnt_Table (face, tag, 0, buffer, length ); + error_code = FT_Load_Sfnt_Table (face, tag, 0, buffer, length); if (error_code) error (_f ("Could not load %s font table", tag_str)); @@ -47,8 +47,8 @@ load_scheme_table (char const *tag_str, FT_Face face) SCM tab = SCM_EOL; if (buffer) { - String contents ((Byte const*)buffer, length); - contents = "(quote (" + contents + "))"; + String contents ((Byte const *)buffer, length); + contents = "(quote (" + contents + "))"; tab = scm_c_eval_string (contents.to_str0 ()); free (buffer); @@ -56,7 +56,7 @@ load_scheme_table (char const *tag_str, FT_Face face) return tab; } -Index_to_charcode_map +Index_to_charcode_map make_index_to_charcode_map (FT_Face face) { Index_to_charcode_map m; @@ -69,7 +69,7 @@ make_index_to_charcode_map (FT_Face face) return m; } -Open_type_font::~Open_type_font() +Open_type_font::~Open_type_font () { FT_Done_Face (face_); } @@ -78,7 +78,7 @@ SCM Open_type_font::make_otf (String str) { FT_Face face; - int error_code = FT_New_Face(freetype2_library, str.to_str0 (), 0, &face); + int error_code = FT_New_Face (freetype2_library, str.to_str0 (), 0, &face); if (error_code == FT_Err_Unknown_File_Format) { @@ -101,7 +101,7 @@ Open_type_font::Open_type_font (FT_Face face) lily_character_table_ = SCM_EOL; lily_global_table_ = SCM_EOL; lily_subfonts_ = SCM_EOL; - + lily_character_table_ = alist_to_hashq (load_scheme_table ("LILC", face_)); lily_global_table_ = alist_to_hashq (load_scheme_table ("LILY", face_)); lily_subfonts_ = load_scheme_table ("LILF", face_); @@ -128,7 +128,7 @@ Open_type_font::attachment_point (String glyph_name) const SCM char_alist = entry; SCM att_scm = scm_cdr (scm_assq (ly_symbol2scm ("attachment"), char_alist)); - + return point_constant * ly_scm2offset (att_scm); } @@ -142,14 +142,14 @@ Open_type_font::get_indexed_char (int signed_idx) const int code = FT_Get_Glyph_Name (face_, signed_idx, name, len); if (code) warning (_f ("FT_Get_Glyph_Name() returned error: %d", code)); - + SCM sym = ly_symbol2scm (name); SCM alist = scm_hashq_ref (lily_character_table_, sym, SCM_BOOL_F); - + if (alist != SCM_BOOL_F) { SCM bbox = scm_cdr (scm_assq (ly_symbol2scm ("bbox"), alist)); - + Box b; b[X_AXIS][LEFT] = scm_to_double (scm_car (bbox)); bbox = scm_cdr (bbox); @@ -164,7 +164,7 @@ Open_type_font::get_indexed_char (int signed_idx) const return b; } } - + FT_UInt idx = signed_idx; FT_Load_Glyph (face_, idx, @@ -176,14 +176,14 @@ Open_type_font::get_indexed_char (int signed_idx) const Box b (Interval (-hb, m.width - hb), Interval (-vb, m.height - vb)); - b.scale (design_size () / Real (face_->units_per_EM)); + b.scale (design_size () / Real (face_->units_per_EM)); return b; } int Open_type_font::name_to_index (String nm) const { - char *nm_str = (char*) nm.to_str0 (); + char *nm_str = (char *) nm.to_str0 (); if (int idx = FT_Get_Name_Index (face_, nm_str)) return idx; return -1; @@ -192,13 +192,13 @@ Open_type_font::name_to_index (String nm) const unsigned Open_type_font::index_to_charcode (int i) const { - return ((Open_type_font*) this)->index_to_charcode_map_[i]; + return ((Open_type_font *) this)->index_to_charcode_map_[i]; } int Open_type_font::count () const { - return ((Open_type_font*) this)->index_to_charcode_map_.size (); + return ((Open_type_font *) this)->index_to_charcode_map_.size (); } Real @@ -212,12 +212,11 @@ Open_type_font::design_size () const non-design-size fonts. I vote for 1 - which will trip errors more quickly. --hwn. - */ + */ scm_from_int (1)); return scm_to_double (entry) * Real (point_constant); } - SCM Open_type_font::sub_fonts () const { diff --git a/lily/ottava-bracket.cc b/lily/ottava-bracket.cc index ff4fb00b79..9a02f4b637 100644 --- a/lily/ottava-bracket.cc +++ b/lily/ottava-bracket.cc @@ -1,11 +1,10 @@ -/* +/* ottava-bracket.cc -- implement Ottava_bracket source file of the GNU LilyPond music typesetter (c) 2004--2005 Han-Wen Nienhuys - - */ +*/ #include "text-item.hh" #include "line-spanner.hh" @@ -24,28 +23,26 @@ struct Ottava_bracket { DECLARE_SCHEME_CALLBACK (print, (SCM)); - static bool has_interface (Grob*); + static bool has_interface (Grob *); }; - /* TODO: the string for ottava shoudl depend on the available space, ie. - - Long: 15ma Short: 15ma Empty: 15 - 8va 8va 8 - 8va bassa 8ba 8 + Long: 15ma Short: 15ma Empty: 15 + 8va 8va 8 + 8va bassa 8ba 8 */ MAKE_SCHEME_CALLBACK (Ottava_bracket, print, 1); SCM Ottava_bracket::print (SCM smob) { - Spanner*me = dynamic_cast (unsmob_grob (smob)); + Spanner *me = dynamic_cast (unsmob_grob (smob)); Interval span_points; - + Grob *common = me->get_bound (LEFT)->common_refpoint (me->get_bound (RIGHT), X_AXIS); - Output_def * layout = me->get_layout (); - + Output_def *layout = me->get_layout (); + Drul_array broken; Direction d = LEFT; do @@ -59,8 +56,8 @@ Ottava_bracket::print (SCM smob) common = common_refpoint_of_list (heads, common, X_AXIS); for (SCM s = heads; scm_is_pair (s); s = scm_cdr (s)) { - Grob * h = unsmob_grob (scm_car (s)); - Grob * dots = Rhythmic_head::get_dots (h); + Grob *h = unsmob_grob (scm_car (s)); + Grob *dots = Rhythmic_head::get_dots (h); if (dots) common = dots->common_refpoint (common, X_AXIS); } @@ -71,18 +68,16 @@ Ottava_bracket::print (SCM smob) SCM properties = Font_interface::text_font_alist_chain (me); SCM markup = me->get_property ("text"); Stencil text; - if (Text_interface::markup_p (markup)) + if (Text_interface::markup_p (markup)) text = *unsmob_stencil (Text_interface::interpret_markup (layout->self_scm (), properties, markup)); - Drul_array shorten = robust_scm2interval (me->get_property ("shorten-pair"), Interval (0, 0)); - /* TODO: we should check if there are ledgers, and modify length of the spanner to that. - */ + */ do { Item *b = me->get_bound (d); @@ -92,17 +87,17 @@ Ottava_bracket::print (SCM smob) { for (SCM s = b->get_property ("note-heads"); scm_is_pair (s); s = scm_cdr (s)) { - Grob * h = unsmob_grob (scm_car (s)); + Grob *h = unsmob_grob (scm_car (s)); ext.unite (h->extent (common, X_AXIS)); - Grob * dots = Rhythmic_head::get_dots (h); + Grob *dots = Rhythmic_head::get_dots (h); if (dots && d == RIGHT) { - ext.unite (dots->extent (common, X_AXIS)); + ext.unite (dots->extent (common, X_AXIS)); } } } - + if (ext.is_empty ()) { ext = robust_relative_extent (b, common, X_AXIS); @@ -113,46 +108,42 @@ Ottava_bracket::print (SCM smob) span_points[d] = b->extent (common, X_AXIS)[RIGHT]; shorten[d] = 0.; } - + else span_points[d] = ext[d]; } while (flip (&d) != LEFT); - /* - 0.3 is ~ italic correction. - */ - Real text_size = text.extent (X_AXIS).is_empty () - ? 0.0 : text.extent (X_AXIS)[RIGHT] + 0.3; - + 0.3 is ~ italic correction. + */ + Real text_size = text.extent (X_AXIS).is_empty () + ? 0.0 : text.extent (X_AXIS)[RIGHT] + 0.3; + span_points[LEFT] = span_points[LEFT] get_property ("minimum-length"), -1.0)); - + - robust_scm2double (me->get_property ("minimum-length"), -1.0)); + Interval bracket_span_points = span_points; bracket_span_points[LEFT] += text_size; - + Drul_array edge_height = robust_scm2interval (me->get_property ("edge-height"), Interval (1.0, 1.0)); - Drul_array flare = robust_scm2interval (me->get_property ("bracket-flare"), Interval (0, 0)); - - edge_height[LEFT] = 0.0; - edge_height[RIGHT] *= - get_grob_direction (me); + edge_height[RIGHT] *= -get_grob_direction (me); if (broken[RIGHT]) edge_height[RIGHT] = 0.0; - + Stencil b; Interval empty; if (!bracket_span_points.is_empty () && bracket_span_points.length () > 0.001) b = Tuplet_bracket::make_bracket (me, Y_AXIS, Offset (bracket_span_points.length (), 0), - edge_height, + edge_height, empty, flare, shorten); @@ -160,31 +151,30 @@ Ottava_bracket::print (SCM smob) The vertical lines should not take space, for the following scenario: 8 -----+ - o | - | - | - + o | + | + | + Just a small amount, yes. In tight situations, it is even possible to center the `8' directly below the note, dropping the ottava line completely... */ - + b = Stencil (Box (b.extent (X_AXIS), - Interval (0.1, 0.1)), - b.expr ()); - + Interval (0.1, 0.1)), + b.expr ()); + b.translate_axis (bracket_span_points[LEFT], X_AXIS); text.translate_axis (span_points[LEFT], X_AXIS); text.align_to (Y_AXIS, CENTER); b.add_stencil (text); - + b.translate_axis (- me->relative_coordinate (common, X_AXIS), X_AXIS); - - return b.smobbed_copy (); -} + return b.smobbed_copy (); +} ADD_INTERFACE (Ottava_bracket, "ottava-bracket-interface", "An ottava bracket", diff --git a/lily/ottava-engraver.cc b/lily/ottava-engraver.cc index a987b147e5..1975eb0ca7 100644 --- a/lily/ottava-engraver.cc +++ b/lily/ottava-engraver.cc @@ -14,7 +14,7 @@ class Ottava_spanner_engraver : public Engraver { public: - TRANSLATOR_DECLARATIONS (Ottava_spanner_engraver); + TRANSLATOR_DECLARATIONS (Ottava_spanner_engraver); protected: virtual void finalize (); virtual void acknowledge_grob (Grob_info); @@ -24,16 +24,16 @@ protected: private: Spanner *span_; Spanner *finished_; - + SCM last_ottavation_; - + void typeset_all (); }; void Ottava_spanner_engraver::derived_mark () const { - scm_gc_mark (last_ottavation_ ); + scm_gc_mark (last_ottavation_); } Ottava_spanner_engraver::Ottava_spanner_engraver () @@ -53,9 +53,8 @@ Ottava_spanner_engraver::process_music () span_ = 0; if (scm_is_string (ott)) { - span_ = make_spanner ("OttavaBracket", SCM_EOL); + span_ = make_spanner ("OttavaBracket", SCM_EOL); span_->set_property ("text", ott); - SCM c0 (get_property ("middleCPosition")); SCM oc0 (get_property ("originalCentralCPosition")); @@ -69,7 +68,7 @@ Ottava_spanner_engraver::process_music () void Ottava_spanner_engraver::acknowledge_grob (Grob_info info) { - Item *it = dynamic_cast (info.grob_); + Item *it = dynamic_cast (info.grob_); if (span_ && it && Note_column::has_interface (info.grob_)) { Side_position_interface::add_support (span_, it); @@ -82,7 +81,7 @@ Ottava_spanner_engraver::acknowledge_grob (Grob_info info) void Ottava_spanner_engraver::typeset_all () -{ +{ if (finished_) { Direction d = LEFT; @@ -90,12 +89,12 @@ Ottava_spanner_engraver::typeset_all () { if (!finished_->get_bound (RIGHT)) { - Grob* e = unsmob_grob (get_property ("currentMusicalColumn")); + Grob *e = unsmob_grob (get_property ("currentMusicalColumn")); finished_->set_bound (d, e); } } while (flip (&d) != LEFT); - + finished_ = 0; } } @@ -105,7 +104,7 @@ Ottava_spanner_engraver::stop_translation_timestep () { if (span_ && !span_->get_bound (LEFT)) { - Grob* e = unsmob_grob (get_property ("currentMusicalColumn")); + Grob *e = unsmob_grob (get_property ("currentMusicalColumn")); span_->set_bound (LEFT, e); } @@ -123,9 +122,9 @@ Ottava_spanner_engraver::finalize () } ADD_TRANSLATOR (Ottava_spanner_engraver, -/* descr */ "Create a text spanner when the ottavation property changes..", -/* creats*/ "OttavaBracket", -/* accepts */ "", -/* acks */ "note-column-interface", -/* reads */ "ottavation", -/* write */ ""); + /* descr */ "Create a text spanner when the ottavation property changes..", + /* creats*/ "OttavaBracket", + /* accepts */ "", + /* acks */ "note-column-interface", + /* reads */ "ottavation", + /* write */ ""); diff --git a/lily/pango-font-scheme.cc b/lily/pango-font-scheme.cc index 606ea1f8d4..a230c68ea6 100644 --- a/lily/pango-font-scheme.cc +++ b/lily/pango-font-scheme.cc @@ -4,10 +4,8 @@ source file of the GNU LilyPond music typesetter (c) 2004--2005 Han-Wen Nienhuys - */ - #define PANGO_ENABLE_BACKEND // ugh, why necessary? #include @@ -19,25 +17,22 @@ #include "warn.hh" #if HAVE_PANGO_FT2 -#include "stencil.hh" - +#include "stencil.hh" LY_DEFINE (ly_pango_font_p, "ly:pango-font?", 1, 0, 0, (SCM f), "Is @var{f} a pango font?") { - return scm_from_bool (dynamic_cast (unsmob_metrics (f))); + return scm_from_bool (dynamic_cast (unsmob_metrics (f))); } - - LY_DEFINE (ly_pango_font_physical_fonts, "ly:pango-font-physical-fonts", 1, 0, 0, (SCM f), "Return alist of (PSNAME . FILENAME) tuples.") { - Pango_font *pf = dynamic_cast (unsmob_metrics (f)); + Pango_font *pf = dynamic_cast (unsmob_metrics (f)); SCM alist = SCM_EOL; if (pf) diff --git a/lily/pango-font.cc b/lily/pango-font.cc index 3fce9d55b3..d5d01499d5 100644 --- a/lily/pango-font.cc +++ b/lily/pango-font.cc @@ -4,10 +4,8 @@ source file of the GNU LilyPond music typesetter (c) 2004--2005 Han-Wen Nienhuys - */ - #define PANGO_ENABLE_BACKEND // ugh, why necessary? #include @@ -21,7 +19,6 @@ #if HAVE_PANGO_FT2 #include "stencil.hh" - Pango_font::Pango_font (PangoFT2FontMap *fontmap, Direction dir, PangoFontDescription *description, @@ -36,15 +33,14 @@ Pango_font::Pango_font (PangoFT2FontMap *fontmap, pango_description_ = pango_font_description_copy (description); // context_ = pango_ft2_font_map_create_context (fontmap); - attribute_list_= pango_attr_list_new(); - + attribute_list_= pango_attr_list_new (); /* urgh. I don't understand this. Why isn't this 1/(scale * resolution * output_scale) --hwn - */ + */ scale_ = INCH_TO_BP / (Real (PANGO_SCALE) * Real (PANGO_RESOLUTION) * output_scale); /* @@ -91,9 +87,9 @@ Pango_font::pango_item_string_stencil (PangoItem *item, String str, Real dx) con PangoRectangle ink_rect; pango_glyph_string_extents (pgs, pa->font, &ink_rect, &logical_rect); - PangoFcFont *fcfont = G_TYPE_CHECK_INSTANCE_CAST(pa->font, - PANGO_TYPE_FC_FONT, - PangoFcFont); + PangoFcFont *fcfont = G_TYPE_CHECK_INSTANCE_CAST (pa->font, + PANGO_TYPE_FC_FONT, + PangoFcFont); FT_Face ftface = pango_fc_font_lock_face (fcfont); Box b (Interval (PANGO_LBEARING (ink_rect), @@ -123,7 +119,7 @@ Pango_font::pango_item_string_stencil (PangoItem *item, String str, Real dx) con PangoFontDescription *descr = pango_font_describe (pa->font); Real size = pango_font_description_get_size (descr) - / (Real (PANGO_SCALE)); + / (Real (PANGO_SCALE)); FcPattern *fcpat = fcfont->font_pattern; char *filename = 0; @@ -152,8 +148,8 @@ Pango_font::pango_item_string_stencil (PangoItem *item, String str, Real dx) con name = name.left_string (idx); int slash_idx = name.index_last ('/'); // UGh. What's happens on windows? - if (slash_idx >= 0) - name = name.right_string (name.length() - slash_idx - 1); + if (slash_idx >= 0) + name = name.right_string (name.length () - slash_idx - 1); String initial = name.cut_string (0, 1); initial.to_upper (); @@ -179,7 +175,7 @@ Pango_font::pango_item_string_stencil (PangoItem *item, String str, Real dx) con else { warning (_ ("FreeType face has no PostScript font name.")); - return Stencil(); + return Stencil (); } } @@ -202,7 +198,7 @@ Pango_font::text_stencil (String str) const Real x = 0.0; while (ptr) { - PangoItem *item = (PangoItem*) ptr->data; + PangoItem *item = (PangoItem *) ptr->data; Stencil item_stencil = pango_item_string_stencil (item, str, x); @@ -216,13 +212,13 @@ Pango_font::text_stencil (String str) const /* UGH. Should have flags per output format signifying supported options. - */ + */ if (output_backend_global != "ps" && output_backend_global != "eps") { /* For Pango based backends, we take a shortcut. - */ + */ char *descr_string = pango_font_description_to_string (pango_description_); SCM exp = scm_list_3 (ly_symbol2scm ("utf8-string"), @@ -248,65 +244,58 @@ Pango_font::text_stencil (String str) const return dest; } - SCM Pango_font::font_file_name () const { return SCM_BOOL_F; } - #endif - - #if 0 void test_pango () { int dpi = 1200; - char * font_family = "Emmentaler"; - PangoContext * pango_context = - pango_ft2_get_context (dpi, dpi); + char *font_family = "Emmentaler"; + PangoContext *pango_context + = pango_ft2_get_context (dpi, dpi); PangoFontDescription *font_description; font_description = pango_font_description_new (); pango_font_description_set_family (font_description, g_strdup (font_family)); pango_font_description_set_style (font_description, (PangoStyle) 20); pango_context_set_font_description (pango_context, font_description); - - PangoAttrList *attr_list = pango_attr_list_new(); + PangoAttrList *attr_list = pango_attr_list_new (); char *str = "sfz"; GList *items = pango_itemize (pango_context, str, 0, strlen (str), attr_list, NULL); - GList *ptr = items; while (ptr) { - PangoItem *item = (PangoItem*)ptr->data; - printf( "off %d len %d num %d\n", item->offset, item->length, item->num_chars); + PangoItem *item = (PangoItem *)ptr->data; + printf ("off %d len %d num %d\n", item->offset, item->length, item->num_chars); PangoAnalysis paobj = item->analysis; - PangoAnalysis * pa = &paobj; + PangoAnalysis *pa = &paobj; PangoFontDescription *descr = pango_font_describe (pa->font); // assert (font_description == descr); printf ("font descr string '%s' fname '%s'", pango_font_description_to_string (descr), - pango_font_description_to_filename (descr) - ); + pango_font_description_to_filename (descr)); printf ("type name %s\n", g_type_name (G_TYPE_FROM_INSTANCE (pa->font))); - PangoFcFont * fcfont = G_TYPE_CHECK_INSTANCE_CAST (pa->font, - PANGO_TYPE_FC_FONT, - PangoFcFont); + PangoFcFont *fcfont = G_TYPE_CHECK_INSTANCE_CAST (pa->font, + PANGO_TYPE_FC_FONT, + PangoFcFont); FcPattern *fcpat = fcfont->font_pattern; FcPatternPrint (fcpat); char *retval ="bla"; - FcPatternGetString(fcpat, FC_FILE, 0, (FcChar8 **) &retval); + FcPatternGetString (fcpat, FC_FILE, 0, (FcChar8 **) &retval); printf ("retval %s\n", retval); FT_Face ftface = pango_fc_font_lock_face (fcfont); @@ -327,7 +316,7 @@ void test_pango () PangoGlyphGeometry ggeo = pgi->geometry; printf ("c %d w %d x %d y %d\n", pg, ggeo.width, ggeo.x_offset, - ggeo.y_offset ); + ggeo.y_offset); char str[1024]; FT_Get_Glyph_Name (ftface, pg, str, 1024); diff --git a/lily/pango-select-scheme.cc b/lily/pango-select-scheme.cc index 734fa7a885..1ae597c236 100644 --- a/lily/pango-select-scheme.cc +++ b/lily/pango-select-scheme.cc @@ -4,7 +4,6 @@ source file of the GNU LilyPond music typesetter (c) 2005 Han-Wen Nienhuys - */ #include "config.hh" @@ -12,11 +11,11 @@ #if HAVE_PANGO_FT2 #include "pango-font.hh" -LY_DEFINE(ly_make_pango_description_string, "ly:make-pango-description-string", - 2, 0, 0, (SCM chain, SCM size), - "Make a PangoFontDescription string for the property alist @var{chain} at size @var{size}.") +LY_DEFINE (ly_make_pango_description_string, "ly:make-pango-description-string", + 2, 0, 0, (SCM chain, SCM size), + "Make a PangoFontDescription string for the property alist @var{chain} at size @var{size}.") { - SCM_ASSERT_TYPE(scm_is_number (size), size, SCM_ARG1, __FUNCTION__, "number"); + SCM_ASSERT_TYPE (scm_is_number (size), size, SCM_ARG1, __FUNCTION__, "number"); PangoFontDescription *pfd = properties_to_pango_description (chain, scm_to_double (size)); char *str = pango_font_description_to_string (pfd); @@ -25,5 +24,5 @@ LY_DEFINE(ly_make_pango_description_string, "ly:make-pango-description-string", pango_font_description_free (pfd); return scm_str; } - + #endif diff --git a/lily/pango-select.cc b/lily/pango-select.cc index 8799850520..dea3b9d40b 100644 --- a/lily/pango-select.cc +++ b/lily/pango-select.cc @@ -4,7 +4,6 @@ source file of the GNU LilyPond music typesetter (c) 2004--2005 Han-Wen Nienhuys - */ #include @@ -13,7 +12,6 @@ #include "output-def.hh" #include "pango-font.hh" - PangoFontDescription * properties_to_pango_description (SCM chain, Real text_size) { @@ -31,12 +29,12 @@ properties_to_pango_description (SCM chain, Real text_size) SCM_BOOL_F); SCM variant = ly_chain_assoc_get (ly_symbol2scm ("font-shape"), chain, SCM_BOOL_F); - + SCM style = ly_chain_assoc_get (ly_symbol2scm ("font-shape"), chain, SCM_BOOL_F); SCM weight = ly_chain_assoc_get (ly_symbol2scm ("font-series"), chain, SCM_BOOL_F); - + description = symbols_to_pango_font_description (family, style, variant, weight, SCM_BOOL_F); @@ -44,7 +42,7 @@ properties_to_pango_description (SCM chain, Real text_size) Real step = robust_scm2double (ly_symbol2scm ("font-size"), 0.0); Real size = text_size * pow (2.0, step / 6.0); - + pango_font_description_set_size (description, gint (size * PANGO_SCALE)); return description; @@ -56,10 +54,10 @@ select_pango_font (Output_def *layout, SCM chain) PangoFontDescription *pfd = properties_to_pango_description (chain, point_constant * layout->get_dimension (ly_symbol2scm ("text-font-size"))); - char * str = pango_font_description_to_string (pfd); + char *str = pango_font_description_to_string (pfd); SCM scm_str = scm_makfrom0str (str); g_free (str); - + return find_pango_font (layout, scm_str, 1.0); } @@ -72,8 +70,7 @@ symbol_to_pango_style (SCM style) pstyle = PANGO_STYLE_ITALIC; } else if (style == ly_symbol2scm ("oblique") - || style == ly_symbol2scm ("slanted") - ) + || style == ly_symbol2scm ("slanted")) { pstyle = PANGO_STYLE_OBLIQUE; } @@ -92,7 +89,6 @@ symbol_to_pango_variant (SCM variant) return pvariant; } - PangoWeight symbol_to_pango_weight (SCM weight) { @@ -127,31 +123,29 @@ symbol_to_pango_stretch (SCM) // stretch) PangoStretch ps = PANGO_STRETCH_NORMAL; /* - // TODO - + // TODO + PANGO_STRETCH_ULTRA_CONDENSED, PANGO_STRETCH_EXTRA_CONDENSED, PANGO_STRETCH_CONDENSED, PANGO_STRETCH_SEMI_CONDENSED, - + PANGO_STRETCH_SEMI_EXPANDED, PANGO_STRETCH_EXPANDED, PANGO_STRETCH_EXTRA_EXPANDED, PANGO_STRETCH_ULTRA_EXPANDED - */ + */ return ps; } - - -PangoFontDescription* -symbols_to_pango_font_description(SCM family, - SCM style, - SCM variant, - SCM weight, - SCM stretch) +PangoFontDescription * +symbols_to_pango_font_description (SCM family, + SCM style, + SCM variant, + SCM weight, + SCM stretch) { - PangoFontDescription * description = pango_font_description_new (); + PangoFontDescription *description = pango_font_description_new (); String family_str = "roman"; if (scm_is_symbol (family)) diff --git a/lily/paper-book-scheme.cc b/lily/paper-book-scheme.cc index 811b7319dc..8b5d6c866e 100644 --- a/lily/paper-book-scheme.cc +++ b/lily/paper-book-scheme.cc @@ -4,7 +4,6 @@ source file of the GNU LilyPond music typesetter (c) 2005 Han-Wen Nienhuys - */ #include "paper-book.hh" @@ -12,23 +11,23 @@ #include "output-def.hh" LY_DEFINE (ly_paper_book_pages, "ly:paper-book-pages", - 1, 0, 0, (SCM pb), - "Return pages in book PB.") + 1, 0, 0, (SCM pb), + "Return pages in book PB.") { - return unsmob_paper_book(pb)->pages (); + return unsmob_paper_book (pb)->pages (); } LY_DEFINE (ly_paper_book_scopes, "ly:paper-book-scopes", - 1, 0, 0, (SCM book), - "Return pages in layout book @var{book}.") + 1, 0, 0, (SCM book), + "Return pages in layout book @var{book}.") { - Paper_book *pb = unsmob_paper_book(book); - SCM_ASSERT_TYPE(pb, book, SCM_ARG1, __FUNCTION__, "Paper_book"); - + Paper_book *pb = unsmob_paper_book (book); + SCM_ASSERT_TYPE (pb, book, SCM_ARG1, __FUNCTION__, "Paper_book"); + SCM scopes = SCM_EOL; if (ly_c_module_p (pb->header_)) scopes = scm_cons (pb->header_, scopes); - + return scopes; } @@ -40,8 +39,8 @@ LY_DEFINE (ly_paper_book_systems, "ly:paper-book-systems", } LY_DEFINE (ly_paper_book_paper, "ly:paper-book-paper", - 1, 0, 0, (SCM pb), - "Return pages in book PB.") + 1, 0, 0, (SCM pb), + "Return pages in book PB.") { return unsmob_paper_book (pb)->paper_->self_scm (); } diff --git a/lily/paper-book.cc b/lily/paper-book.cc index 0ad8a14be7..ea7c044417 100644 --- a/lily/paper-book.cc +++ b/lily/paper-book.cc @@ -24,7 +24,7 @@ Paper_book::Paper_book () pages_ = SCM_BOOL_F; scores_ = SCM_EOL; systems_ = SCM_BOOL_F; - + paper_ = 0; smobify_self (); } @@ -35,12 +35,12 @@ Paper_book::~Paper_book () IMPLEMENT_DEFAULT_EQUAL_P (Paper_book); IMPLEMENT_SMOBS (Paper_book) -IMPLEMENT_TYPE_P (Paper_book, "ly:paper-book?") + IMPLEMENT_TYPE_P (Paper_book, "ly:paper-book?") -SCM + SCM Paper_book::mark_smob (SCM smob) { - Paper_book *b = (Paper_book*) SCM_CELL_WORD_1 (smob); + Paper_book *b = (Paper_book *) SCM_CELL_WORD_1 (smob); if (b->paper_) scm_gc_mark (b->paper_->self_scm ()); scm_gc_mark (b->header_); @@ -53,8 +53,8 @@ Paper_book::mark_smob (SCM smob) int Paper_book::print_smob (SCM smob, SCM port, scm_print_state*) { - Paper_book *b = (Paper_book*) SCM_CELL_WORD_1 (smob); - + Paper_book *b = (Paper_book *) SCM_CELL_WORD_1 (smob); + scm_puts ("#<", port); scm_puts (classname (b), port); scm_puts (" ", port); @@ -66,7 +66,7 @@ SCM dump_fields () { SCM fields = SCM_EOL; - for (int i = dump_header_fieldnames_global.size (); i--; ) + for (int i = dump_header_fieldnames_global.size (); i--;) fields = scm_cons (ly_symbol2scm (dump_header_fieldnames_global[i].to_str0 ()), fields); @@ -87,11 +87,11 @@ Paper_book::output (String outname) /* Generate all stencils to trigger font loads. */ pages (); - + SCM scopes = SCM_EOL; if (ly_c_module_p (header_)) scopes = scm_cons (header_, scopes); - + String mod_nm = "scm framework-" + output_backend_global; SCM mod = scm_c_resolve_module (mod_nm.to_str0 ()); @@ -106,7 +106,7 @@ Paper_book::output (String outname) dump_fields (), SCM_UNDEFINED)); } - + if (make_preview) { SCM func = scm_c_module_lookup (mod, "output-preview-framework"); @@ -135,10 +135,9 @@ Paper_book::classic_output (String outname) String format = output_backend_global; String mod_nm = "scm framework-" + format; - + SCM mod = scm_c_resolve_module (mod_nm.to_str0 ()); SCM func = scm_c_module_lookup (mod, "output-classic-framework"); - func = scm_variable_ref (func); scm_apply_0 (func, scm_list_n (scm_makfrom0str (outname.to_str0 ()), @@ -150,7 +149,6 @@ Paper_book::classic_output (String outname) progress_indication ("\n"); } - /* TODO: resurrect more complex user-tweaks for titling? */ Stencil Paper_book::book_title () @@ -162,19 +160,18 @@ Paper_book::book_title () if (ly_c_module_p (header_)) scopes = scm_cons (header_, scopes); - SCM tit = SCM_EOL; if (ly_c_procedure_p (title_func)) tit = scm_call_2 (title_func, - paper_->self_scm (), - scopes); + paper_->self_scm (), + scopes); if (unsmob_stencil (tit)) title = *unsmob_stencil (tit); if (!title.is_empty ()) title.align_to (Y_AXIS, UP); - + return title; } @@ -195,34 +192,34 @@ Paper_book::score_title (SCM header) SCM tit = SCM_EOL; if (ly_c_procedure_p (title_func)) tit = scm_call_2 (title_func, - paper_->self_scm (), - scopes); + paper_->self_scm (), + scopes); if (unsmob_stencil (tit)) title = *unsmob_stencil (tit); if (!title.is_empty ()) title.align_to (Y_AXIS, UP); - + return title; } void -set_system_penalty (Paper_system * ps, SCM header) +set_system_penalty (Paper_system *ps, SCM header) { if (ly_c_module_p (header)) { SCM force = ly_module_lookup (header, ly_symbol2scm ("breakbefore")); - if (SCM_VARIABLEP(force) - && scm_is_bool (SCM_VARIABLE_REF(force))) + if (SCM_VARIABLEP (force) + && scm_is_bool (SCM_VARIABLE_REF (force))) { - ps->break_before_penalty_ = to_boolean (SCM_VARIABLE_REF(force)) + ps->break_before_penalty_ = to_boolean (SCM_VARIABLE_REF (force)) ? -10000 : 10000; } } } - + SCM Paper_book::systems () { @@ -236,7 +233,7 @@ Paper_book::systems () { Paper_system *ps = new Paper_system (title, true); set_system_penalty (ps, header_); - + systems_ = scm_cons (ps->self_scm (), systems_); scm_gc_unprotect_object (ps->self_scm ()); } @@ -267,7 +264,7 @@ Paper_book::systems () set_system_penalty (ps, header); } header = SCM_EOL; - + SCM system_list = scm_vector_to_list (scm_car (s)); system_list = scm_reverse (system_list); systems_ = scm_append (scm_list_2 (system_list, systems_)); @@ -287,9 +284,9 @@ Paper_book::systems () else assert (0); } - + systems_ = scm_reverse (systems_); - + int i = 0; Paper_system *last = 0; for (SCM s = systems_; s != SCM_EOL; s = scm_cdr (s)) @@ -303,7 +300,7 @@ Paper_book::systems () ps->break_before_penalty_ = 10000; last = ps; } - + return systems_; } diff --git a/lily/paper-column.cc b/lily/paper-column.cc index 8cf2a108f2..14de60d2dc 100644 --- a/lily/paper-column.cc +++ b/lily/paper-column.cc @@ -18,13 +18,12 @@ #include "font-interface.hh" #include "output-def.hh" -Grob * +Grob * Paper_column::clone (int count) const { return new Paper_column (*this, count); } - ADD_INTERFACE (Paper_column, "paper-column-interface", "@code{Paper_column} objects form the top-most X-parents for items. " " The are two types of columns: musical columns, where are attached to, and " @@ -37,8 +36,7 @@ ADD_INTERFACE (Paper_column, "paper-column-interface", " Since many columns go unused, you should only use the rank field to\n" " get ordering information. Two adjacent columns may have\n" " non-adjacent numbers.\n" - "\n" - , + "\n", "between-cols when bounded-by-me " "page-penalty shortest-playing-duration shortest-starter-duration"); @@ -49,41 +47,38 @@ Paper_column::do_break_processing () Item::do_break_processing (); } - int -Paper_column::get_rank (Grob*me) +Paper_column::get_rank (Grob *me) { - return dynamic_cast (me)->rank_; + return dynamic_cast (me)->rank_; } -System* +System * Paper_column::get_system () const { return system_; } -Paper_column* +Paper_column * Paper_column::get_column () const { - return (Paper_column*) (this); + return (Paper_column *) (this); } -Paper_column::Paper_column (SCM l, Object_key const*key) +Paper_column::Paper_column (SCM l, Object_key const *key) : Item (l, key) // guh.? { system_ = 0; rank_ = -1; } - -Paper_column::Paper_column (Paper_column const& src, int count) +Paper_column::Paper_column (Paper_column const &src, int count) : Item (src, count) { system_ = 0; rank_ = src.rank_; } - Moment Paper_column::when_mom (Grob *me) { @@ -104,19 +99,17 @@ Paper_column::is_musical (Grob *me) } return s != Moment (0); } - bool -Paper_column::is_used (Grob*me) +Paper_column::is_used (Grob *me) { - return scm_is_pair (me->get_property ("elements")) || Item::is_breakable (me) - || scm_is_pair (me->get_property ("bounded-by-me")) - ; + return scm_is_pair (me->get_property ("elements")) || Item::is_breakable (me) + || scm_is_pair (me->get_property ("bounded-by-me")); } /* - Print a vertical line and the rank number, to aid debugging. - */ + Print a vertical line and the rank number, to aid debugging. +*/ MAKE_SCHEME_CALLBACK (Paper_column, print, 1); SCM @@ -128,17 +121,17 @@ Paper_column::print (SCM p) SCM properties = Font_interface::text_font_alist_chain (me); SCM scm_mol = Text_interface::interpret_markup (me->get_layout ()->self_scm (), - properties, - scm_makfrom0str (r.to_str0 ())); + properties, + scm_makfrom0str (r.to_str0 ())); Stencil t = *unsmob_stencil (scm_mol); t.align_to (X_AXIS, CENTER); t.align_to (Y_AXIS, DOWN); - + Stencil l = Lookup::filled_box (Box (Interval (-0.01, 0.01), Interval (-2, -1))); t.add_stencil (l); - return t.smobbed_copy (); + return t.smobbed_copy (); } /* @@ -146,8 +139,8 @@ Paper_column::print (SCM p) columns are kept "alive". Unfortunately, when spanners are suicided, this falls apart again. (sigh.) - THIS IS BROKEN KLUDGE. WE SHOULD INVENT SOMETHING BETTER. - */ + THIS IS BROKEN KLUDGE. WE SHOULD INVENT SOMETHING BETTER. +*/ MAKE_SCHEME_CALLBACK (Paper_column, before_line_breaking, 1); SCM Paper_column::before_line_breaking (SCM grob) @@ -159,7 +152,7 @@ Paper_column::before_line_breaking (SCM grob) while (scm_is_pair (*ptrptr)) { - Grob * g = unsmob_grob (scm_car (*ptrptr)); + Grob *g = unsmob_grob (scm_car (*ptrptr)); if (!g || !g->is_live ()) { diff --git a/lily/paper-def.cc b/lily/paper-def.cc index 62b585bb5a..2048ec2170 100644 --- a/lily/paper-def.cc +++ b/lily/paper-def.cc @@ -1,4 +1,4 @@ -/* +/* paper-def.cc -- implement Paper_def source file of the GNU LilyPond music typesetter @@ -12,7 +12,6 @@ #include "pango-font.hh" #include "all-font-metrics.hh" - Real output_scale (Output_def *od) { @@ -49,31 +48,31 @@ find_scaled_font (Output_def *mod, Font_metric *f, Real m) { if (mod->parent_) return find_scaled_font (mod->parent_, f, m); - + Real lookup_mag = m / output_scale (mod); - + SCM font_table = get_font_table (mod); SCM sizes = scm_hashq_ref (font_table, f->self_scm (), SCM_EOL); SCM handle = scm_assoc (scm_make_real (lookup_mag), sizes); if (scm_is_pair (handle)) return unsmob_metrics (scm_cdr (handle)); - + SCM val = Modified_font_metric::make_scaled_font_metric (f, lookup_mag); - + sizes = scm_acons (scm_make_real (lookup_mag), val, sizes); scm_gc_unprotect_object (val); scm_hashq_set_x (font_table, f->self_scm (), sizes); return unsmob_metrics (val); } -Font_metric* -find_pango_font (Output_def *layout, SCM descr, Real factor) +Font_metric * +find_pango_font (Output_def *layout, SCM descr, Real factor) { if (layout->parent_) return find_pango_font (layout->parent_, descr, factor); - + SCM table = get_pango_font_table (layout); - SCM sizes = scm_hash_ref (table, descr, SCM_EOL); + SCM sizes = scm_hash_ref (table, descr, SCM_EOL); SCM size_key = scm_from_double (factor); SCM handle = scm_assoc (size_key, sizes); if (scm_is_pair (handle)) @@ -87,7 +86,7 @@ find_pango_font (Output_def *layout, SCM descr, Real factor) factor, output_scale (layout)); - sizes = scm_acons (size_key, fm->self_scm(), sizes); + sizes = scm_acons (size_key, fm->self_scm (), sizes); scm_hash_set_x (table, descr, sizes); return fm; @@ -96,7 +95,7 @@ find_pango_font (Output_def *layout, SCM descr, Real factor) /* TODO: this is a nasty interface. During formatting, the Output_def should be scaled to the output_scale_ specified in the toplevel Output_def. */ -Output_def * +Output_def * scale_output_def (Output_def *o, Real amount) { SCM proc = ly_lily_module_constant ("scale-layout"); diff --git a/lily/paper-outputter-scheme.cc b/lily/paper-outputter-scheme.cc index f9ed6adf7f..c0208297a8 100644 --- a/lily/paper-outputter-scheme.cc +++ b/lily/paper-outputter-scheme.cc @@ -4,7 +4,6 @@ source file of the GNU LilyPond music typesetter (c) 2005 Han-Wen Nienhuys - */ #include "paper-outputter.hh" @@ -16,11 +15,11 @@ LY_DEFINE (ly_make_paper_outputter, "ly:make-paper-outputter", "Create an outputter that evaluates within " "@code{output-}@var{format}, writing to file @var{outname}.") { - SCM_ASSERT_TYPE(scm_is_string (outname), outname, SCM_ARG1, __FUNCTION__, - "String"); - SCM_ASSERT_TYPE(scm_is_string (format), format, SCM_ARG2, __FUNCTION__, - "String"); - + SCM_ASSERT_TYPE (scm_is_string (outname), outname, SCM_ARG1, __FUNCTION__, + "String"); + SCM_ASSERT_TYPE (scm_is_string (format), format, SCM_ARG2, __FUNCTION__, + "String"); + String outname_str = ly_scm2string (outname); String f = ly_scm2string (format); @@ -55,18 +54,17 @@ LY_DEFINE (ly_outputter_dump_string, "ly:outputter-dump-string", Paper_outputter *po = unsmob_outputter (outputter); SCM_ASSERT_TYPE (po, outputter, SCM_ARG1, __FUNCTION__, "Paper_outputter"); SCM_ASSERT_TYPE (scm_is_string (str), str, SCM_ARG1, __FUNCTION__, "Paper_outputter"); - + return po->dump_string (str); } - LY_DEFINE (ly_outputter_port, "ly:outputter-port", 1, 0, 0, (SCM outputter), "Return output port for @var{outputter}.") { Paper_outputter *po = unsmob_outputter (outputter); SCM_ASSERT_TYPE (po, outputter, SCM_ARG1, __FUNCTION__, "Paper_outputter"); - + return po->file (); } diff --git a/lily/paper-outputter.cc b/lily/paper-outputter.cc index d74b0606b7..5da3ca0607 100644 --- a/lily/paper-outputter.cc +++ b/lily/paper-outputter.cc @@ -4,7 +4,7 @@ source file of the GNU LilyPond music typesetter (c) 1997--2005 Han-Wen Nienhuys - Jan Nieuwenhuizen + Jan Nieuwenhuizen */ #include "paper-outputter.hh" @@ -32,7 +32,7 @@ Paper_outputter::Paper_outputter (String file_name, String format) file_ = SCM_EOL; output_module_ = SCM_EOL; smobify_self (); - + file_name_ = file_name; String module_name = "scm output-" + format; output_module_ = scm_c_resolve_module (module_name.to_str0 ()); @@ -42,14 +42,13 @@ Paper_outputter::~Paper_outputter () { } - IMPLEMENT_SMOBS (Paper_outputter); IMPLEMENT_DEFAULT_EQUAL_P (Paper_outputter); SCM Paper_outputter::mark_smob (SCM x) { - Paper_outputter *p = (Paper_outputter*) SCM_CELL_WORD_1(x); + Paper_outputter *p = (Paper_outputter *) SCM_CELL_WORD_1 (x); scm_gc_mark (p->output_module_); return p->file_; } @@ -67,7 +66,7 @@ Paper_outputter::file () { if (file_ == SCM_EOL) if (file_name_ == "-") - file_ = scm_current_output_port(); + file_ = scm_current_output_port (); else file_ = scm_open_file (scm_makfrom0str (file_name_.to_str0 ()), scm_makfrom0str ("w")); @@ -95,7 +94,7 @@ Paper_outputter::output_scheme (SCM scm) void paper_outputter_dump (void *po, SCM x) { - Paper_outputter *me = (Paper_outputter*) po; + Paper_outputter *me = (Paper_outputter *) po; me->output_scheme (x); } @@ -103,7 +102,7 @@ void Paper_outputter::output_stencil (Stencil stil) { interpret_stencil_expression (stil.expr (), paper_outputter_dump, - (void*) this, Offset (0, 0)); + (void *) this, Offset (0, 0)); } void diff --git a/lily/paper-score.cc b/lily/paper-score.cc index a3a30d094a..b8bc7d318f 100644 --- a/lily/paper-score.cc +++ b/lily/paper-score.cc @@ -51,7 +51,7 @@ Paper_score::calc_breaking () Break_algorithm *algorithm = 0; Array sol; - algorithm = new Gourlay_breaking ; + algorithm = new Gourlay_breaking; algorithm->set_pscore (this); sol = algorithm->solve (); delete algorithm; @@ -71,14 +71,14 @@ Paper_score::process (String) /* FIXME: Check out why we need this - removing gives assertion failures down the road. - + doubly, also done in Score_engraver */ Link_array pc (system_->columns ()); pc[0]->set_property ("breakable", SCM_BOOL_T); pc.top ()->set_property ("breakable", SCM_BOOL_T); - + system_->pre_processing (); - + Array breaking = calc_breaking (); system_->break_into_pieces (breaking); SCM lines = system_->get_lines (); @@ -86,9 +86,9 @@ Paper_score::process (String) /* gourlay:do_solve also prints newline. */ progress_indication ("\n"); #endif - + /* Only keep result stencils in lines_, *title_; delete all grobs. */ systems_ = SCM_EOL; - + return lines; } diff --git a/lily/paper-system-scheme.cc b/lily/paper-system-scheme.cc index e065091e8f..e6da5d276b 100644 --- a/lily/paper-system-scheme.cc +++ b/lily/paper-system-scheme.cc @@ -4,7 +4,6 @@ source file of the GNU LilyPond music typesetter (c) 2005 Han-Wen Nienhuys - */ #include "paper-system.hh" @@ -17,11 +16,9 @@ LY_DEFINE (ly_paper_system_height, "ly:paper-system-extent", SCM_ASSERT_TYPE (ps, system, SCM_ARG1, __FUNCTION__, "paper-system"); SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG2, __FUNCTION__, "axis"); Axis ax = (Axis)scm_to_int (axis); - return ly_interval2scm (ps->to_stencil().extent (ax)); + return ly_interval2scm (ps->to_stencil ().extent (ax)); } - - LY_DEFINE (ly_paper_system_title_p, "ly:paper-system-title?", 1, 0, 0, (SCM system), "Is @var{system} a title system?") @@ -58,8 +55,6 @@ LY_DEFINE (ly_paper_system_stencil, "ly:paper-system-stencil", return ps->to_stencil ().smobbed_copy (); } - - LY_DEFINE (ly_paper_system_staff_extent, "ly:paper-system-staff-extents", 1, 0, 0, (SCM system), "Return the top and bottom staff refpoint.") diff --git a/lily/paper-system.cc b/lily/paper-system.cc index c614d9710e..c519404a65 100644 --- a/lily/paper-system.cc +++ b/lily/paper-system.cc @@ -16,8 +16,6 @@ IMPLEMENT_SMOBS (Paper_system); IMPLEMENT_TYPE_P (Paper_system, "ly:paper-system?"); IMPLEMENT_DEFAULT_EQUAL_P (Paper_system); - - Paper_system::Paper_system (Stencil s, bool is_title) { is_title_ = is_title; @@ -25,7 +23,7 @@ Paper_system::Paper_system (Stencil s, bool is_title) break_before_penalty_ = 0; smobify_self (); stencil_ = s; - staff_refpoints_ = Interval(0, 0); + staff_refpoints_ = Interval (0, 0); } Paper_system::~Paper_system () @@ -35,14 +33,14 @@ Paper_system::~Paper_system () SCM Paper_system::mark_smob (SCM smob) { - Paper_system *system = (Paper_system*) SCM_CELL_WORD_1 (smob); + Paper_system *system = (Paper_system *) SCM_CELL_WORD_1 (smob); return system-> stencil_.expr (); } int Paper_system::print_smob (SCM smob, SCM port, scm_print_state*) { - Paper_system *p = (Paper_system*) SCM_CELL_WORD_1 (smob); + Paper_system *p = (Paper_system *) SCM_CELL_WORD_1 (smob); scm_puts ("#<", port); scm_puts (classname (p), port); scm_puts ("n ", port); diff --git a/lily/parse-scm.cc b/lily/parse-scm.cc index b1619d9afd..78a3c52865 100644 --- a/lily/parse-scm.cc +++ b/lily/parse-scm.cc @@ -16,16 +16,16 @@ /* Pass string to scm parser, evaluate one expression. Return result value and #chars read. - + Thanks to Gary Houston */ SCM -internal_ly_parse_scm (Parse_start * ps) +internal_ly_parse_scm (Parse_start *ps) { Source_file *sf = ps->start_location_.source_file_; SCM port = sf->get_port (); int off = ps->start_location_.start_ - sf->to_str0 (); - + scm_seek (port, scm_long2num (off), scm_long2num (SEEK_SET)); SCM from = scm_ftell (port); @@ -48,7 +48,7 @@ internal_ly_parse_scm (Parse_start * ps) else answer = scm_primitive_eval (form); } - + /* Reset read_buf for scm_ftell. Shouldn't scm_read () do this for us? */ scm_fill_input (port); @@ -67,18 +67,18 @@ internal_ly_parse_scm (Parse_start * ps) SCM catch_protected_parse_body (void *p) { - Parse_start *ps = (Parse_start*) p; - + Parse_start *ps = (Parse_start *) p; + return internal_ly_parse_scm (ps); } -SCM +SCM parse_handler (void *data, SCM tag, SCM args) { - Parse_start* ps = (Parse_start *) data; + Parse_start *ps = (Parse_start *) data; (void) tag; - - ps->start_location_.error (_("GUILE signaled an error for the expression beginning here")); + + ps->start_location_.error (_ ("GUILE signaled an error for the expression beginning here")); if (scm_ilength (args) > 2) scm_display_error_message (scm_cadr (args), scm_caddr (args), scm_current_error_port ()); @@ -86,22 +86,21 @@ parse_handler (void *data, SCM tag, SCM args) /* The following is a kludge; we should probably search for [a-z][0-9] (a note), and start before that. - */ + */ ps->nchars = 1; - + return SCM_UNDEFINED; } /* Do some magical incantations: if not, lily will exit on the first - GUILE error, leaving no location trace. - */ - + GUILE error, leaving no location trace. +*/ #if GUILE_MINOR_VERSION < 7 - #define READ_ERROR "misc-error" - #else - #define READ_ERROR "read-error" +#define READ_ERROR "misc-error" +#else +#define READ_ERROR "read-error" #endif SCM @@ -109,11 +108,11 @@ protected_ly_parse_scm (Parse_start *ps) { return scm_internal_catch (ly_symbol2scm (READ_ERROR), &catch_protected_parse_body, - (void*) ps, - &parse_handler, (void*) ps); + (void *) ps, + &parse_handler, (void *) ps); } -bool parse_protect_global = true; +bool parse_protect_global = true; /* Try parsing. Upon failure return SCM_UNDEFINED. FIXME: shouldn't we return SCM_UNSCPECIFIED -- jcn */ @@ -124,11 +123,11 @@ ly_parse_scm (char const *s, int *n, Input i, bool safe) ps.str = s; ps.start_location_ = i; ps.safe_ = safe; - + SCM ans = parse_protect_global ? protected_ly_parse_scm (&ps) : internal_ly_parse_scm (&ps); *n = ps.nchars; - return ans; + return ans; } diff --git a/lily/part-combine-engraver.cc b/lily/part-combine-engraver.cc index 2712a2a150..b32b83236f 100644 --- a/lily/part-combine-engraver.cc +++ b/lily/part-combine-engraver.cc @@ -2,11 +2,10 @@ part-combine-engraver.cc -- implement PC-engraver source file of the GNU LilyPond music typesetter - + (c) 2000--2005 Jan Nieuwenhuizen Han-Wen Nienhuys - */ #include "engraver.hh" @@ -31,7 +30,7 @@ private: }; bool -Part_combine_engraver::try_music (Music*m) +Part_combine_engraver::try_music (Music *m) { event_ = m; return true; @@ -40,7 +39,7 @@ Part_combine_engraver::try_music (Music*m) Part_combine_engraver::Part_combine_engraver () { text_ = 0; - event_ = 0; + event_ = 0; } void @@ -60,7 +59,7 @@ Part_combine_engraver::process_music () if (Text_interface::markup_p (text)) { - text_ = make_item ("CombineTextScript", event_->self_scm () ); + text_ = make_item ("CombineTextScript", event_->self_scm ()); text_->set_property ("text", text); } } @@ -73,7 +72,7 @@ Part_combine_engraver::acknowledge_grob (Grob_info i) { if (Note_head::has_interface (i.grob_)) { - Grob*t = text_; + Grob *t = text_; Side_position_interface::add_support (t, i.grob_); if (Side_position_interface::get_axis (t) == X_AXIS && !t->get_parent (Y_AXIS)) @@ -86,19 +85,19 @@ Part_combine_engraver::acknowledge_grob (Grob_info i) } } -void +void Part_combine_engraver::stop_translation_timestep () { - text_ = 0; + text_ = 0; event_ = 0; } ADD_TRANSLATOR (Part_combine_engraver, -/* descr */ "Part combine engraver for orchestral scores: " - "Print markings a2, Solo, Solo II, and unisono ", -/* creats*/ "CombineTextScript", -/* accepts */ "part-combine-event", -/* acks */ "multi-measure-rest-interface " -"slur-interface stem-interface note-head-interface", -/* reads */ "printPartCombineTexts", -/* write */ ""); + /* descr */ "Part combine engraver for orchestral scores: " + "Print markings a2, Solo, Solo II, and unisono ", + /* creats*/ "CombineTextScript", + /* accepts */ "part-combine-event", + /* acks */ "multi-measure-rest-interface " + "slur-interface stem-interface note-head-interface", + /* reads */ "printPartCombineTexts", + /* write */ ""); diff --git a/lily/part-combine-iterator.cc b/lily/part-combine-iterator.cc index 5555d17e49..70086010b7 100644 --- a/lily/part-combine-iterator.cc +++ b/lily/part-combine-iterator.cc @@ -1,9 +1,9 @@ -/* - new-part-combine-music-iterator.cc -- implement Part_combine_iterator +/* + new-part-combine-music-iterator.cc -- implement Part_combine_iterator - source file of the GNU LilyPond music typesetter - - (c) 2004--2005 Han-Wen Nienhuys + source file of the GNU LilyPond music typesetter + + (c) 2004--2005 Han-Wen Nienhuys */ #include "context.hh" @@ -18,15 +18,15 @@ class Part_combine_iterator : public Music_iterator public: Part_combine_iterator (); - DECLARE_SCHEME_CALLBACK (constructor, ()); + DECLARE_SCHEME_CALLBACK (constructor, ()); protected: - virtual void derived_substitute (Context *f, Context *t) ; + virtual void derived_substitute (Context *f, Context *t); virtual void derived_mark () const; Part_combine_iterator (Part_combine_iterator const &); virtual void construct_children (); virtual Moment pending_moment () const; - virtual void do_quit (); + virtual void do_quit (); virtual void process (Moment); virtual Music_iterator *try_music_in_children (Music *) const; @@ -34,39 +34,40 @@ protected: virtual bool ok () const; private: - Music_iterator * first_iter_; - Music_iterator * second_iter_; + Music_iterator *first_iter_; + Music_iterator *second_iter_; Moment start_moment_; - + SCM split_list_; - enum Status { - APART, - TOGETHER, - SOLO1, - SOLO2, - UNISONO, - UNISILENCE, - }; + enum Status + { + APART, + TOGETHER, + SOLO1, + SOLO2, + UNISONO, + UNISILENCE, + }; Status state_; Status playing_state_; /* Should be SOLO1 or SOLO2 - */ + */ Status last_playing_; /* - TODO: this is getting of hand... - */ + TODO: this is getting of hand... + */ Interpretation_context_handle one_; Interpretation_context_handle two_; Interpretation_context_handle null_; Interpretation_context_handle shared_; Interpretation_context_handle solo_; - - void substitute_both (Context * to1, - Context * to2); + + void substitute_both (Context *to1, + Context *to2); void kill_mmrest (Context *); void chords_together (); @@ -76,7 +77,6 @@ private: void unisono (bool silent); }; - static Music *busy_playing_event; void @@ -102,7 +102,7 @@ Part_combine_iterator::Part_combine_iterator () split_list_ = SCM_EOL; state_ = APART; playing_state_ = APART; - + if (!busy_playing_event) { busy_playing_event @@ -121,7 +121,7 @@ Part_combine_iterator::derived_mark () const void Part_combine_iterator::derived_substitute (Context *f, - Context *t) + Context *t) { if (first_iter_) first_iter_->substitute_outlet (f, t); @@ -161,11 +161,10 @@ Part_combine_iterator::chords_together () } } - void -Part_combine_iterator::kill_mmrest (Context * tg) +Part_combine_iterator::kill_mmrest (Context *tg) { - static Music * mmrest; + static Music *mmrest; if (!mmrest) { mmrest = make_music_by_name (ly_symbol2scm ("MultiMeasureRestEvent")); @@ -185,13 +184,13 @@ Part_combine_iterator::solo1 () state_ = SOLO1; substitute_both (solo_.get_outlet (), null_.get_outlet ()); - + kill_mmrest (two_.get_outlet ()); kill_mmrest (shared_.get_outlet ()); if (playing_state_ != SOLO1) { - static Music* event; + static Music *event; if (!event) event = make_music_by_name (ly_symbol2scm ("SoloOneEvent")); @@ -202,50 +201,50 @@ Part_combine_iterator::solo1 () } void -Part_combine_iterator::substitute_both (Context * to1, - Context * to2) +Part_combine_iterator::substitute_both (Context *to1, + Context *to2) { - Context *tos[] = {to1, to2}; - Music_iterator *mis[] = {first_iter_, second_iter_}; - Interpretation_context_handle *hs[] = { + Context *tos[] = {to1, to2}; + Music_iterator *mis[] = {first_iter_, second_iter_}; + Interpretation_context_handle *hs[] + = { &null_, &one_, &two_, - &shared_, &solo_, + &shared_, &solo_, 0 }; - - for (int i = 0; i < 2 ; i++) + + for (int i = 0; i < 2; i++) { - for (int j = 0; hs[j]; j++) + for (int j = 0; hs[j]; j++) if (hs[j]->get_outlet () != tos[i]) - mis[i]->substitute_outlet (hs[j]->get_outlet (), tos[i]); + mis[i]->substitute_outlet (hs[j]->get_outlet (), tos[i]); } - for (int j = 0; hs[j]; j++) + for (int j = 0; hs[j]; j++) { - Context * t = hs[j]->get_outlet (); + Context *t = hs[j]->get_outlet (); if (t != to1 && t != to2) kill_mmrest (t); } } - void Part_combine_iterator::unisono (bool silent) { Status newstate = (silent) ? UNISILENCE : UNISONO; - + if (newstate == state_) - return; + return; else { /* If we're coming from SOLO2 state, we might have kill mmrests - in the 1st voice, so in that case, we use the second voice + in the 1st voice, so in that case, we use the second voice as a basis for events. - */ - Context *c1 = (last_playing_ == SOLO2) ? null_.get_outlet() : shared_.get_outlet(); - Context *c2 = (last_playing_ == SOLO2) ? shared_.get_outlet() : null_.get_outlet(); + */ + Context *c1 = (last_playing_ == SOLO2) ? null_.get_outlet () : shared_.get_outlet (); + Context *c2 = (last_playing_ == SOLO2) ? shared_.get_outlet () : null_.get_outlet (); substitute_both (c1, c2); kill_mmrest ((last_playing_ == SOLO2) ? one_.get_outlet () : two_.get_outlet ()); @@ -254,12 +253,12 @@ Part_combine_iterator::unisono (bool silent) if (playing_state_ != UNISONO && newstate == UNISONO) { - static Music* event; + static Music *event; if (!event) event = make_music_by_name (ly_symbol2scm ("UnisonoEvent")); (last_playing_ == SOLO2 ? second_iter_ : first_iter_) - ->try_music_in_children (event); + ->try_music_in_children (event); playing_state_ = UNISONO; } state_ = newstate; @@ -274,12 +273,12 @@ Part_combine_iterator::solo2 () else { state_ = SOLO2; - + substitute_both (null_.get_outlet (), solo_.get_outlet ()); - + if (playing_state_ != SOLO2) { - static Music* event; + static Music *event; if (!event) event = make_music_by_name (ly_symbol2scm ("SoloTwoEvent")); @@ -304,66 +303,63 @@ Part_combine_iterator::apart (bool silent) } } - void Part_combine_iterator::construct_children () { start_moment_ = get_outlet ()->now_mom (); - split_list_ = get_music ()->get_property ("split-list"); - SCM lst = get_music ()->get_property ("elements"); + split_list_ = get_music ()->get_property ("split-list"); + SCM lst = get_music ()->get_property ("elements"); SCM props = scm_list_n (/* used to have tweaks here. - */ - + */ + SCM_UNDEFINED); Context *tr - = get_outlet ()->find_create_context (ly_symbol2scm ("Voice"), - "shared", props); + = get_outlet ()->find_create_context (ly_symbol2scm ("Voice"), + "shared", props); shared_.set_context (tr); /* If we don't, we get a new staff for every Voice. - */ + */ set_context (tr); Context *solo_tr - = get_outlet ()->find_create_context (ly_symbol2scm ("Voice"), - "solo", props); + = get_outlet ()->find_create_context (ly_symbol2scm ("Voice"), + "solo", props); solo_ .set_context (solo_tr); Context *null - = get_outlet ()->find_create_context (ly_symbol2scm ("Devnull"), - "", SCM_EOL); + = get_outlet ()->find_create_context (ly_symbol2scm ("Devnull"), + "", SCM_EOL); if (!null) programming_error ("No Devnull found?"); - + null_.set_context (null); Context *one = tr->find_create_context (ly_symbol2scm ("Voice"), - "one", props); + "one", props); one_.set_context (one); set_context (one); first_iter_ = unsmob_iterator (get_iterator (unsmob_music (scm_car (lst)))); - Context *two = tr->find_create_context (ly_symbol2scm ("Voice"), - "two", props); + "two", props); two_.set_context (two); set_context (two); second_iter_ = unsmob_iterator (get_iterator (unsmob_music (scm_cadr (lst)))); - set_context (tr); - - char const * syms[] = { + char const *syms[] + = { "Stem", "DynamicLineSpanner", "Tie", @@ -374,12 +370,12 @@ Part_combine_iterator::construct_children () "Script", 0 }; - - for (char const**p = syms; *p; p++) + + for (char const **p = syms; *p; p++) { SCM sym = ly_symbol2scm (*p); execute_pushpop_property (one, sym, - ly_symbol2scm ("direction"), scm_int2num (1)); + ly_symbol2scm ("direction"), scm_int2num (1)); execute_pushpop_property (two, sym, ly_symbol2scm ("direction"), scm_int2num (-1)); @@ -392,15 +388,15 @@ Part_combine_iterator::process (Moment m) { Moment now = get_outlet ()->now_mom (); Moment *splitm = 0; - + for (; scm_is_pair (split_list_); split_list_ = scm_cdr (split_list_)) { splitm = unsmob_moment (scm_caar (split_list_)); if (splitm && *splitm + start_moment_ > now) - break ; + break; SCM tag = scm_cdar (split_list_); - + if (tag == ly_symbol2scm ("chords")) chords_together (); else if (tag == ly_symbol2scm ("apart") @@ -417,8 +413,8 @@ Part_combine_iterator::process (Moment m) solo2 (); else if (scm_is_symbol (tag)) { - String s = "Unknown split directive: " - + (scm_is_symbol (tag) ? ly_symbol2string (tag) : String ("not a symbol")); + String s = "Unknown split directive: " + + (scm_is_symbol (tag) ? ly_symbol2string (tag) : String ("not a symbol")); programming_error (s); } } @@ -429,7 +425,7 @@ Part_combine_iterator::process (Moment m) if (first_iter_->try_music_in_children (busy_playing_event)) last_playing_ = SOLO1; } - + if (second_iter_->ok ()) { second_iter_->process (m); @@ -438,10 +434,10 @@ Part_combine_iterator::process (Moment m) } } -Music_iterator* +Music_iterator * Part_combine_iterator::try_music_in_children (Music *m) const { - Music_iterator * i = first_iter_->try_music (m); + Music_iterator *i = first_iter_->try_music (m); if (i) return i; else diff --git a/lily/percent-repeat-engraver.cc b/lily/percent-repeat-engraver.cc index d3433dbfdf..99d440e9fb 100644 --- a/lily/percent-repeat-engraver.cc +++ b/lily/percent-repeat-engraver.cc @@ -1,11 +1,10 @@ -/* +/* new-chord-tremolo-engraver.cc -- implement Chord_tremolo_engraver - + source file of the GNU LilyPond music typesetter - + (c) 2000--2005 Han-Wen Nienhuys - - */ +*/ #include "repeated-music.hh" #include "global-context.hh" @@ -18,15 +17,14 @@ #include "score-engraver.hh" /** - This acknowledges repeated music with "percent" style. It typesets - a % sign. + This acknowledges repeated music with "percent" style. It typesets + a % sign. - TODO: + TODO: - - BEAT case: Create items for single beat repeats, i.e. c4 / / / + - BEAT case: Create items for single beat repeats, i.e. c4 / / / - - DOUBLE_MEASURE case: attach a % to an appropriate barline. - + - DOUBLE_MEASURE case: attach a % to an appropriate barline. */ class Percent_repeat_engraver : public Engraver { @@ -45,18 +43,20 @@ protected: Moment next_moment_; Moment body_length_; - enum { - UNKNOWN, - MEASURE, - DOUBLE_MEASURE, - } repeat_sign_type_ ; + enum + { + UNKNOWN, + MEASURE, + DOUBLE_MEASURE, + } + repeat_sign_type_; - Item * double_percent_; - Spanner * perc_; - Spanner * finished_perc_; + Item *double_percent_; + Spanner *perc_; + Spanner *finished_perc_; protected: virtual void finalize (); - virtual bool try_music (Music*); + virtual bool try_music (Music *); virtual void stop_translation_timestep (); virtual void start_translation_timestep (); virtual void process_music (); @@ -64,7 +64,7 @@ protected: Percent_repeat_engraver::Percent_repeat_engraver () { - perc_ = 0; + perc_ = 0; finished_perc_ = 0; repeat_ = 0; @@ -72,16 +72,16 @@ Percent_repeat_engraver::Percent_repeat_engraver () } bool -Percent_repeat_engraver::try_music (Music * m) +Percent_repeat_engraver::try_music (Music *m) { if (m->is_mus_type ("repeated-music") && m->get_property ("iterator-ctor") - == Percent_repeat_iterator::constructor_proc + == Percent_repeat_iterator::constructor_proc && !repeat_) { body_length_ = Repeated_music::body_get_length (m); int count = Repeated_music::repeat_count (m); - + Moment now = now_mom (); start_mom_ = now; stop_mom_ = start_mom_ + Moment (count) * body_length_; @@ -93,7 +93,7 @@ Percent_repeat_engraver::try_music (Music * m) else if (Moment (2)* meas_len == body_length_) { repeat_sign_type_ = DOUBLE_MEASURE; - next_moment_ += meas_len ; + next_moment_ += meas_len; } else { @@ -103,20 +103,19 @@ Percent_repeat_engraver::try_music (Music * m) repeat_ = m; - Global_context *global = get_global_context (); - for (int i = 0; i < count; i++) + for (int i = 0; i < count; i++) { global->add_moment_to_process (next_moment_ + Moment (i) * body_length_); /* bars between % too. - */ + */ if (repeat_sign_type_ == DOUBLE_MEASURE) global->add_moment_to_process (next_moment_ + meas_len + Moment (i) * body_length_); - + } - + return true; } @@ -139,9 +138,9 @@ Percent_repeat_engraver::process_music () else if (repeat_sign_type_ == DOUBLE_MEASURE) { double_percent_ = make_item ("DoublePercentRepeat", repeat_->self_scm ()); - /* - forbid breaks on a % line. Should forbid all breaks, really. - */ + /* + forbid breaks on a % line. Should forbid all breaks, really. + */ get_score_engraver ()->forbid_breaks (); // guh. Use properties! } @@ -176,8 +175,6 @@ Percent_repeat_engraver::typeset_perc () } - - void Percent_repeat_engraver::start_translation_timestep () { @@ -194,7 +191,6 @@ Percent_repeat_engraver::start_translation_timestep () } } - void Percent_repeat_engraver::stop_translation_timestep () { @@ -202,12 +198,10 @@ Percent_repeat_engraver::stop_translation_timestep () } - - ADD_TRANSLATOR (Percent_repeat_engraver, -/* descr */ "Make whole bar and double bar repeats.", -/* creats*/ "PercentRepeat DoublePercentRepeat", -/* accepts */ "repeated-music", -/* acks */ "", -/* reads */ "measureLength currentCommandColumn", -/* write */ ""); + /* descr */ "Make whole bar and double bar repeats.", + /* creats*/ "PercentRepeat DoublePercentRepeat", + /* accepts */ "repeated-music", + /* acks */ "", + /* reads */ "measureLength currentCommandColumn", + /* write */ ""); diff --git a/lily/percent-repeat-item.cc b/lily/percent-repeat-item.cc index 51b3f81a16..8dad52aba3 100644 --- a/lily/percent-repeat-item.cc +++ b/lily/percent-repeat-item.cc @@ -1,11 +1,10 @@ -/* +/* percent-repeat-item.cc -- implement Percent_repeat_item_interface - + source file of the GNU LilyPond music typesetter - + (c) 2001--2005 Han-Wen Nienhuys - - */ +*/ #include "percent-repeat-item.hh" @@ -15,14 +14,14 @@ #include "font-interface.hh" Stencil -Percent_repeat_item_interface::brew_slash ( Grob *me) +Percent_repeat_item_interface::brew_slash (Grob *me) { Real slope = robust_scm2double (me->get_property ("slope"), 1); Real wid = 2.0 / slope; /* todo: check out if in staff-rule thickness normally. - */ + */ Real thick = robust_scm2double (me->get_property ("thickness"), 1); Stencil m = Lookup::repeat_slash (wid, slope, thick); m.translate_axis (-m.extent (Y_AXIS).center (), Y_AXIS); @@ -31,24 +30,24 @@ Percent_repeat_item_interface::brew_slash ( Grob *me) /* todo: use grob props for dot_neg_kern, slash_neg_kern? - */ +*/ Stencil Percent_repeat_item_interface::x_percent (Grob *me, int count, Real dot_neg_kern, Real slash_neg_kern) { - Stencil m ; + Stencil m; Stencil s = brew_slash (me); - for (int i = count; i--;) + for (int i = count; i--;) { m.add_at_edge (X_AXIS, RIGHT, s, -slash_neg_kern, 0); } Stencil d1 = Font_interface::get_default_font (me)->find_by_name ("dots.dot"); - Stencil d2 = d1; - d1.translate_axis (0.5, Y_AXIS ); + Stencil d2 = d1; + d1.translate_axis (0.5, Y_AXIS); d2.translate_axis (-0.5, Y_AXIS); - + m.add_at_edge (X_AXIS, LEFT, d1, -dot_neg_kern, 0); m.add_at_edge (X_AXIS, RIGHT, d2, -dot_neg_kern, 0); @@ -76,8 +75,6 @@ Percent_repeat_item_interface::beat_slash (SCM grob) } ADD_INTERFACE (Percent_repeat_item_interface, "percent-repeat-interface", - "Repeats that look like percent signs", - "slope thickness"); - - + "Repeats that look like percent signs", + "slope thickness"); diff --git a/lily/percent-repeat-iterator.cc b/lily/percent-repeat-iterator.cc index 791ebe492a..a3049f737c 100644 --- a/lily/percent-repeat-iterator.cc +++ b/lily/percent-repeat-iterator.cc @@ -1,11 +1,10 @@ -/* +/* percent-repeat-iterator.cc -- implement Percent_repeat_iterator - + source file of the GNU LilyPond music typesetter - + (c) 2001--2005 Han-Wen Nienhuys - - */ +*/ #include "percent-repeat-iterator.hh" @@ -14,7 +13,6 @@ IMPLEMENT_CTOR_CALLBACK (Percent_repeat_iterator); - Percent_repeat_iterator::Percent_repeat_iterator () { child_iter_ = 0; @@ -41,7 +39,6 @@ Percent_repeat_iterator::construct_children () child_iter_ = unsmob_iterator (get_iterator (Repeated_music::body (mus))); } - void Percent_repeat_iterator::process (Moment m) { @@ -51,15 +48,15 @@ Percent_repeat_iterator::process (Moment m) if (yeah) set_context (yeah->get_outlet ()); else - get_music ()->origin ()->warning ( _ ("no one to print a percent")); + get_music ()->origin ()->warning (_ ("no one to print a percent")); } - + if (child_iter_->ok ()) child_iter_->process (m); - if (finish_mom_ <= m ) + if (finish_mom_ <= m) { - child_iter_->quit (); + child_iter_->quit (); child_iter_ = 0; } } @@ -70,10 +67,10 @@ Percent_repeat_iterator::pending_moment ()const if (child_iter_->ok ()) return child_iter_->pending_moment (); else - return finish_mom_ ; + return finish_mom_; } -Music_iterator* +Music_iterator * Percent_repeat_iterator::try_music_in_children (Music *m) const { return child_iter_->try_music (m); @@ -87,7 +84,7 @@ Percent_repeat_iterator::derived_mark ()const } void -Percent_repeat_iterator::derived_substitute (Context *f, Context *t ) +Percent_repeat_iterator::derived_substitute (Context *f, Context *t) { if (child_iter_) child_iter_->substitute_outlet (f, t); diff --git a/lily/performance.cc b/lily/performance.cc index 0a6d10486c..88ba2c8b8e 100644 --- a/lily/performance.cc +++ b/lily/performance.cc @@ -29,14 +29,13 @@ Performance::Performance () audio_elem_p_list_ = 0; } - Performance::~Performance () { delete audio_elem_p_list_; } void -Performance::output (Midi_stream& midi_stream) +Performance::output (Midi_stream &midi_stream) { int tracks_i = audio_staffs_.size () + 1; @@ -52,36 +51,34 @@ Performance::output (Midi_stream& midi_stream) { Audio_staff *s = audio_staffs_[i]; if (be_verbose_global) - progress_indication ("[" + to_string (i)) ; + progress_indication ("[" + to_string (i)); /* MIDI players tend to ignore instrument settings on channel 10, the percussion channel by default. - */ + */ if (channel % 16 == 9) - channel++; - + channel++; /* Huh? Why does each staff also have a separate channel? We should map channels to voices, not staves. --hwn. - */ + */ if (s->channel_ < 0) { s->channel_ = channel % 16; if (channel > 15) warning ("MIDI channel wrapped around. Remapping modulo 16."); } - + s->output (midi_stream, channel++); if (be_verbose_global) progress_indication ("]"); } } - void -Performance::output_header_track (Midi_stream& midi_stream) +Performance::output_header_track (Midi_stream &midi_stream) { Midi_track midi_track; @@ -96,7 +93,7 @@ Performance::output_header_track (Midi_stream& midi_stream) /* This seems silly, but in fact the audio elements should be generated elsewhere: not midi-specific. - */ + */ Audio_text creator_a (Audio_text::TEXT, str); Midi_text creator (&creator_a); midi_track.add (Moment (0), &creator); @@ -104,22 +101,21 @@ Performance::output_header_track (Midi_stream& midi_stream) /* Better not translate this */ str = "Generated automatically by: "; str += id_string; - + Audio_text generate_a (Audio_text::TEXT, str); Midi_text generate (&generate_a); midi_track.add (Moment (0), &generate); - + str = _ ("at "); time_t t (time (0)); str += ctime (&t); str = str.left_string (str.length () - 1); str = String_convert::pad_to (str, 60); - + Audio_text at_a (Audio_text::TEXT, str); Midi_text at (&at_a); midi_track.add (Moment (0), &at); - // TODO: // str = _f ("from musical definition: %s", origin_string_); @@ -144,7 +140,7 @@ Performance::output_header_track (Midi_stream& midi_stream) void Performance::add_element (Audio_element *p) { - if (Audio_staff*s = dynamic_cast (p)) + if (Audio_staff *s = dynamic_cast (p)) { audio_staffs_.push (s); } @@ -156,12 +152,12 @@ Performance::process (String out) { if (out == "-") out = "lelie.midi"; - + /* Maybe a bit crude, but we had this before */ File_name file_name (out); file_name.ext_ = "midi"; out = file_name.to_string (); - + Midi_stream midi_stream (out); progress_indication (_f ("MIDI output to `%s'...", out)); diff --git a/lily/performer-group-performer.cc b/lily/performer-group-performer.cc index 64e596e5af..39d6ccc7c5 100644 --- a/lily/performer-group-performer.cc +++ b/lily/performer-group-performer.cc @@ -4,8 +4,8 @@ source file of the GNU LilyPond music typesetter (c) 1996--2005 Han-Wen Nienhuys - Jan Nieuwenhuizen - */ + Jan Nieuwenhuizen +*/ #include "performer-group-performer.hh" @@ -14,14 +14,12 @@ #include "warn.hh" ADD_TRANSLATOR (Performer_group_performer, -/* descr */ "", -/* creats*/ "", -/* accepts */ "", -/* acks */ "", -/* reads */ "", -/* write */ ""); - - + /* descr */ "", + /* creats*/ "", + /* accepts */ "", + /* acks */ "", + /* reads */ "", + /* write */ ""); void Performer_group_performer::announce_element (Audio_element_info info) @@ -30,7 +28,7 @@ Performer_group_performer::announce_element (Audio_element_info info) Translator *t = context ()->get_parent_context ()->implementation (); - if (Performer_group_performer * eg = dynamic_cast (t)) + if (Performer_group_performer *eg = dynamic_cast (t)) eg->announce_element (info); } @@ -43,8 +41,8 @@ Performer_group_performer::acknowledge_audio_elements () for (SCM p = get_simple_trans_list (); scm_is_pair (p); p = scm_cdr (p)) { - Translator * t = unsmob_translator (scm_car (p)); - Performer * eng = dynamic_cast (t); + Translator *t = unsmob_translator (scm_car (p)); + Performer *eng = dynamic_cast (t); if (eng && eng!= info.origin_trans_) eng->acknowledge_audio_element (info); } @@ -59,10 +57,10 @@ Performer_group_performer::do_announces () create_audio_elements (); performer_each (get_simple_trans_list (), &Performer::create_audio_elements); - + if (!announce_infos_.size ()) - break ; - + break; + acknowledge_audio_elements (); announce_infos_.clear (); } @@ -72,13 +70,12 @@ Performer_group_performer::Performer_group_performer () { } - void performer_each (SCM list, Performer_method method) { for (SCM p = list; scm_is_pair (p); p = scm_cdr (p)) { - Performer * e = dynamic_cast(unsmob_translator (scm_car (p))); + Performer *e = dynamic_cast (unsmob_translator (scm_car (p))); if (e) (e->*method) (); } diff --git a/lily/performer.cc b/lily/performer.cc index d7d501d4e8..260c5d7154 100644 --- a/lily/performer.cc +++ b/lily/performer.cc @@ -4,17 +4,17 @@ source file of the GNU LilyPond music typesetter (c) 1996--2005 Han-Wen Nienhuys - Jan Nieuwenhuizen - */ + Jan Nieuwenhuizen +*/ #include "context.hh" #include "performer-group-performer.hh" #include "warn.hh" -void -Performer::play_element (Audio_element* p) -{ - get_daddy_performer ()->play_element (p); +void +Performer::play_element (Audio_element *p) +{ + get_daddy_performer ()->play_element (p); } int @@ -23,7 +23,7 @@ Performer::get_tempo () const return get_daddy_performer ()->get_tempo (); } -Performer_group_performer* +Performer_group_performer * Performer::get_daddy_performer () const { return @@ -40,7 +40,6 @@ Performer::create_audio_elements () { } - void Performer::announce_element (Audio_element_info i) { diff --git a/lily/pfb.cc b/lily/pfb.cc index 99495d1b21..0967358f1f 100644 --- a/lily/pfb.cc +++ b/lily/pfb.cc @@ -28,17 +28,17 @@ pfb2pfa (Byte const *pfb, int length) Byte type = *p++; if (type == 3) - break ; + break; - unsigned seglen = - p[0] | (p[1] << 8) + unsigned seglen + = p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24); p += 4; if (type == 1) { - out = (char*)realloc (out, olen + seglen + 1); - char *outp = out + olen ; + out = (char *)realloc (out, olen + seglen + 1); + char *outp = out + olen; memcpy (outp, p, seglen); olen += seglen; p += seglen; @@ -47,16 +47,16 @@ pfb2pfa (Byte const *pfb, int length) { unsigned outlength = (seglen * 2) + (seglen / 32) + 2; - out = (char*)realloc (out, olen + outlength + 1); + out = (char *)realloc (out, olen + outlength + 1); char *outp = out + olen; for (int i = seglen; i--;) { sprintf (outp, "%02x", *p++); outp += 2; - if (!(i % 32)) + if (! (i % 32)) { - *outp ++ = '\n'; + *outp++ = '\n'; } } @@ -71,8 +71,7 @@ pfb2pfa (Byte const *pfb, int length) LY_DEFINE (ly_pfb_to_pfa, "ly:pfb->pfa", 1, 0, 0, (SCM pfb_file_name), - "Convert the contents of a PFB file to PFA." - ) + "Convert the contents of a PFB file to PFA.") { SCM_ASSERT_TYPE (scm_is_string (pfb_file_name), pfb_file_name, SCM_ARG1, __FUNCTION__, "string"); @@ -80,7 +79,7 @@ LY_DEFINE (ly_pfb_to_pfa, "ly:pfb->pfa", String file_name = ly_scm2string (pfb_file_name); int len; char *str = gulp_file (file_name, &len); - char *pfa = pfb2pfa ((Byte*)str, len); + char *pfa = pfb2pfa ((Byte *)str, len); SCM pfa_scm = scm_makfrom0str (pfa); free (pfa); @@ -91,12 +90,11 @@ LY_DEFINE (ly_pfb_to_pfa, "ly:pfb->pfa", LY_DEFINE (ly_ttf_to_pfa, "ly:ttf->pfa", 1, 0, 0, (SCM ttf_file_name), "Convert the contents of a TTF file to Type42 PFA, returning it as " - " a string." - ) + " a string.") { SCM_ASSERT_TYPE (scm_is_string (ttf_file_name), ttf_file_name, SCM_ARG1, __FUNCTION__, "string"); - + String file_name = ly_scm2string (ttf_file_name); Memory_out_stream stream; diff --git a/lily/phrasing-slur-engraver.cc b/lily/phrasing-slur-engraver.cc index 9509bae468..7eda8473f3 100644 --- a/lily/phrasing-slur-engraver.cc +++ b/lily/phrasing-slur-engraver.cc @@ -21,12 +21,12 @@ class Phrasing_slur_engraver : public Engraver { Drul_array events_; - Music * running_slur_start_; + Music *running_slur_start_; Link_array slurs_; Link_array end_slurs_; protected: - virtual bool try_music (Music*); + virtual bool try_music (Music *); virtual void acknowledge_grob (Grob_info); virtual void stop_translation_timestep (); virtual void finalize (); @@ -59,7 +59,7 @@ Phrasing_slur_engraver::try_music (Music *m) { if (slurs_.is_empty ()) return false; - + events_[STOP] = m; return true; } @@ -67,16 +67,15 @@ Phrasing_slur_engraver::try_music (Music *m) return false; } - void Phrasing_slur_engraver::acknowledge_grob (Grob_info info) { Grob *e = info.grob_; if (Note_column::has_interface (info.grob_)) { - for (int i = slurs_.size (); i--; ) + for (int i = slurs_.size (); i--;) Slur::add_column (slurs_[i], e); - for (int i = end_slurs_.size (); i-- ; ) + for (int i = end_slurs_.size (); i--;) Slur::add_column (end_slurs_[i], e); } else @@ -89,21 +88,21 @@ Phrasing_slur_engraver::acknowledge_grob (Grob_info info) || Slur::has_interface (e) || to_boolean (inside)) { - for (int i = slurs_.size (); i--; ) + for (int i = slurs_.size (); i--;) Slur::add_extra_encompass (slurs_[i], e); - for (int i = end_slurs_.size (); i--; ) + for (int i = end_slurs_.size (); i--;) Slur::add_extra_encompass (end_slurs_[i], e); } else if (inside == SCM_BOOL_F) { - Grob *slur = slurs_.size()?slurs_[0] : 0; - slur = (end_slurs_.size () && !slur) + Grob *slur = slurs_.size ()?slurs_[0] : 0; + slur = (end_slurs_.size () && !slur) ? end_slurs_[0] : slur; if (slur) { e->add_offset_callback (Slur::outside_slur_callback_proc, Y_AXIS); - e->set_property ("slur", slur->self_scm()); + e->set_property ("slur", slur->self_scm ()); } } } @@ -124,12 +123,12 @@ Phrasing_slur_engraver::process_music () end_slurs_ = slurs_; slurs_.clear (); } - + if (events_[START] && slurs_.is_empty ()) { Music *ev = events_[START]; - Grob * slur = make_spanner ("PhrasingSlur", events_[START]->self_scm ()); + Grob *slur = make_spanner ("PhrasingSlur", events_[START]->self_scm ()); Direction updown = to_dir (ev->get_property ("direction")); if (updown) set_grob_direction (slur, updown); @@ -145,11 +144,10 @@ Phrasing_slur_engraver::stop_translation_timestep () events_[START] = events_[STOP] = 0; } - ADD_TRANSLATOR (Phrasing_slur_engraver, -/* descr */ "Print phrasing slurs. Similar to @ref{Slur_engraver}", -/* creats*/ "PhrasingSlur", -/* accepts */ "phrasing-slur-event", -/* acks */ "note-column-interface tie-interface fingering-interface script-interface slur-interface", -/* reads */ "", -/* write */ ""); + /* descr */ "Print phrasing slurs. Similar to @ref{Slur_engraver}", + /* creats*/ "PhrasingSlur", + /* accepts */ "phrasing-slur-event", + /* acks */ "note-column-interface tie-interface fingering-interface script-interface slur-interface", + /* reads */ "", + /* write */ ""); diff --git a/lily/piano-pedal-bracket.cc b/lily/piano-pedal-bracket.cc index 9d20e7aa54..75caaea3db 100644 --- a/lily/piano-pedal-bracket.cc +++ b/lily/piano-pedal-bracket.cc @@ -1,10 +1,9 @@ -/* +/* piano-pedal-bracket.cc -- implement Piano_pedal_bracket -source file of the GNU LilyPond music typesetter - -(c) 2003--2005 Han-Wen Nienhuys + source file of the GNU LilyPond music typesetter + (c) 2003--2005 Han-Wen Nienhuys */ #include "stencil.hh" @@ -15,17 +14,16 @@ source file of the GNU LilyPond music typesetter struct Piano_pedal_bracket { DECLARE_SCHEME_CALLBACK (print, (SCM)); - static bool has_interface (Grob*); + static bool has_interface (Grob *); }; - MAKE_SCHEME_CALLBACK (Piano_pedal_bracket, print, 1); SCM Piano_pedal_bracket::print (SCM smob) { - Spanner *me = dynamic_cast (unsmob_grob (smob)); - Spanner *orig = dynamic_cast (me->original_); - + Spanner *me = dynamic_cast (unsmob_grob (smob)); + Spanner *orig = dynamic_cast (me->original_); + Drul_array broken (false, false); Drul_array height = robust_scm2drul (me->get_property ("edge-height"), Interval (0, 0)); @@ -50,35 +48,34 @@ Piano_pedal_bracket::print (SCM smob) if (broken[d]) { if (orig - && ((d == RIGHT && me->get_break_index () != orig->broken_intos_.size()-1) + && ((d == RIGHT && me->get_break_index () != orig->broken_intos_.size () - 1) || (d == LEFT && me->get_break_index ()))) height[d] = 0.0; else - flare[d] = 0.0; + flare[d] = 0.0; } - - Interval ext = robust_relative_extent (b, common, X_AXIS); - span_points[d] = ext [broken[d] ? RIGHT : LEFT]; + + Interval ext = robust_relative_extent (b, common, X_AXIS); + span_points[d] = ext [broken[d] ? RIGHT : LEFT]; } while (flip (&d) != LEFT); - /* For 'Mixed' style pedals, i.e. a bracket preceded by text: Ped._____| - need to shorten by the extent of the text grob + need to shorten by the extent of the text grob */ if (textbit) { height[LEFT] = 0; - + Real padding = robust_scm2double (me->get_property ("bound-padding"), 0); - + span_points[LEFT] = padding + robust_relative_extent (textbit, common, X_AXIS)[RIGHT]; } - Stencil m ; - if (!span_points.is_empty () && - span_points.length () > 0.001) + Stencil m; + if (!span_points.is_empty () + && span_points.length () > 0.001) { m = Tuplet_bracket::make_bracket (me, Y_AXIS, Offset (span_points.length (), 0), @@ -91,8 +88,6 @@ Piano_pedal_bracket::print (SCM smob) return m.smobbed_copy (); } - - ADD_INTERFACE (Piano_pedal_bracket, "piano-pedal-bracket-interface", "The bracket of the piano pedal. It can be tuned through the regular " "bracket properties.", diff --git a/lily/piano-pedal-engraver.cc b/lily/piano-pedal-engraver.cc index 646fd1dd9c..e8ee2a12e6 100644 --- a/lily/piano-pedal-engraver.cc +++ b/lily/piano-pedal-engraver.cc @@ -1,12 +1,12 @@ -/* - piano-pedal-engraver.cc -- implement Piano_pedal_engraver - - source file of the GNU LilyPond music typesetter - - (c) 2000--2005 Jan Nieuwenhuizen - - Chris Jackson - extended to support - bracketed pedals. +/* + piano-pedal-engraver.cc -- implement Piano_pedal_engraver + + source file of the GNU LilyPond music typesetter + + (c) 2000--2005 Jan Nieuwenhuizen + + Chris Jackson - extended to support + bracketed pedals. */ #include "engraver.hh" @@ -25,39 +25,36 @@ struct Pedal_info { - char const * name_; + char const *name_; /* Event for currently running pedal. */ - Music* current_bracket_ev_; + Music *current_bracket_ev_; /* Event for currently starting pedal, (necessary? - + distinct from current_bracket_ev_, since current_bracket_ev_ only necessary for brackets, not for text style. */ - Music* start_ev_; + Music *start_ev_; - - /* Events that were found in this timestep. */ - Drul_array event_drul_; - Item* item_; - Spanner* bracket_; // A single portion of a pedal bracket - Spanner* finished_bracket_; + Drul_array event_drul_; + Item *item_; + Spanner *bracket_; // A single portion of a pedal bracket + Spanner *finished_bracket_; /* This grob contains all the pedals of the same type on the same staff */ - Spanner* line_spanner_; - Spanner* finished_line_spanner_; + Spanner *line_spanner_; + Spanner *finished_line_spanner_; }; - class Piano_pedal_engraver : public Engraver { public: @@ -66,7 +63,7 @@ public: protected: virtual void initialize (); virtual void finalize (); - virtual bool try_music (Music*); + virtual bool try_music (Music *); virtual void stop_translation_timestep (); virtual void acknowledge_grob (Grob_info); virtual void process_music (); @@ -79,16 +76,15 @@ private: Record a stack of the current pedal spanners, so if more than one pedal occurs simultaneously then extra space can be added between them. */ - + Link_array previous_; - void del_linespanner (Spanner*); - + void del_linespanner (Spanner *); + void create_text_grobs (Pedal_info *p, bool); void create_bracket_grobs (Pedal_info *p, bool); - void typeset_all (Pedal_info*p); + void typeset_all (Pedal_info *p); }; - Piano_pedal_engraver::Piano_pedal_engraver () { info_list_ = 0; @@ -97,12 +93,12 @@ Piano_pedal_engraver::Piano_pedal_engraver () void Piano_pedal_engraver::initialize () { - char * names [] = { "Sostenuto", "Sustain", "UnaCorda", 0 }; + char *names [] = { "Sostenuto", "Sustain", "UnaCorda", 0 }; - info_list_ = new Pedal_info[sizeof (names)/ sizeof (const char*)]; + info_list_ = new Pedal_info[sizeof (names)/ sizeof (const char *)]; Pedal_info *p = info_list_; - char **np = names ; + char **np = names; do { p->name_ = *np; @@ -118,7 +114,7 @@ Piano_pedal_engraver::initialize () p++; } - while (* (np ++)); + while (* (np++)); } Piano_pedal_engraver::~Piano_pedal_engraver () @@ -133,7 +129,7 @@ Piano_pedal_engraver::~Piano_pedal_engraver () void Piano_pedal_engraver::acknowledge_grob (Grob_info info) { - for (Pedal_info*p = info_list_; p && p->name_; p ++) + for (Pedal_info *p = info_list_; p && p->name_; p++) { if (Note_column::has_interface (info.grob_)) { @@ -141,11 +137,11 @@ Piano_pedal_engraver::acknowledge_grob (Grob_info info) { Side_position_interface::add_support (p->line_spanner_, info.grob_); add_bound_item (p->line_spanner_, info.grob_); - } + } if (p->bracket_) add_bound_item (p->bracket_, info.grob_); if (p->finished_bracket_) - add_bound_item (p->finished_bracket_, info.grob_); + add_bound_item (p->finished_bracket_, info.grob_); } } } @@ -155,11 +151,11 @@ Piano_pedal_engraver::try_music (Music *m) { if (m->is_mus_type ("pedal-event")) { - for (Pedal_info*p = info_list_; p->name_; p ++) + for (Pedal_info *p = info_list_; p->name_; p++) { String nm = p->name_ + String ("Event"); - if (ly_c_equal_p (m->get_property ("name") , - scm_str2symbol(nm.to_str0()))) + if (ly_c_equal_p (m->get_property ("name"), + scm_str2symbol (nm.to_str0 ()))) { Direction d = to_dir (m->get_property ("span-direction")); p->event_drul_[d] = m; @@ -173,20 +169,18 @@ Piano_pedal_engraver::try_music (Music *m) void Piano_pedal_engraver::process_music () { - for (Pedal_info*p = info_list_; p && p->name_; p ++) + for (Pedal_info *p = info_list_; p && p->name_; p++) { if (p->event_drul_[STOP] || p->event_drul_[START]) { if (!p->line_spanner_) { - String name = String (p->name_) + "PedalLineSpanner"; - Music * rq = (p->event_drul_[START] ? p->event_drul_[START] : p->event_drul_[STOP]); + String name = String (p->name_) + "PedalLineSpanner"; + Music *rq = (p->event_drul_[START] ? p->event_drul_[START] : p->event_drul_[STOP]); p->line_spanner_ = make_spanner (name.to_str0 (), rq->self_scm ()); - - } - + /* Choose the appropriate grobs to add to the line spanner These can be text items or text-spanners */ @@ -200,8 +194,7 @@ Piano_pedal_engraver::process_music () mixed: Ped. _____/\____| */ - - String prop = String ("pedal") + p->name_ + "Style"; + String prop = String ("pedal") + p->name_ + "Style"; SCM style = get_property (prop.to_str0 ()); bool mixed = style == ly_symbol2scm ("mixed"); @@ -209,7 +202,7 @@ Piano_pedal_engraver::process_music () || style == ly_symbol2scm ("bracket")); bool text = (style == ly_symbol2scm ("text") || mixed); - + if (text && !p->item_) create_text_grobs (p, mixed); if (bracket) @@ -222,11 +215,11 @@ void Piano_pedal_engraver::create_text_grobs (Pedal_info *p, bool mixed) { SCM s = SCM_EOL; - SCM strings = get_property ( ("pedal" + String (p->name_) + "Strings").to_str0 ()); + SCM strings = get_property (("pedal" + String (p->name_) + "Strings").to_str0 ()); if (scm_ilength (strings) < 3) { - Music * m = p->event_drul_[START]; + Music *m = p->event_drul_[START]; if (!m) m = p->event_drul_ [STOP]; String msg = _ ("Need 3 strings for piano pedals. No pedal made. "); @@ -234,17 +227,17 @@ Piano_pedal_engraver::create_text_grobs (Pedal_info *p, bool mixed) m->origin ()->warning (msg); else warning (msg); - - return ; + + return; } - - if (p->event_drul_[STOP] && p->event_drul_[START]) + + if (p->event_drul_[STOP] && p->event_drul_[START]) { if (!mixed) { if (!p->start_ev_) { - p->event_drul_[STOP]->origin ()->warning (_f ("can't find start of piano pedal: `%s'", p->name_)); + p->event_drul_[STOP]->origin ()->warning (_f ("can't find start of piano pedal: `%s'", p->name_)); } else { @@ -254,7 +247,7 @@ Piano_pedal_engraver::create_text_grobs (Pedal_info *p, bool mixed) } } else if (p->event_drul_[STOP]) - { + { if (!mixed) { if (!p->start_ev_) @@ -284,7 +277,7 @@ Piano_pedal_engraver::create_text_grobs (Pedal_info *p, bool mixed) previous_.push (p->line_spanner_); } } - + if (scm_is_string (s)) { String propname = String (p->name_) + "Pedal"; @@ -296,7 +289,7 @@ Piano_pedal_engraver::create_text_grobs (Pedal_info *p, bool mixed) p->item_->set_property ("text", s); Axis_group_interface::add_element (p->line_spanner_, p->item_); } - + if (!mixed) { p->event_drul_[START] = 0; @@ -304,7 +297,6 @@ Piano_pedal_engraver::create_text_grobs (Pedal_info *p, bool mixed) } } - void Piano_pedal_engraver::create_bracket_grobs (Pedal_info *p, bool mixed) { @@ -312,12 +304,12 @@ Piano_pedal_engraver::create_bracket_grobs (Pedal_info *p, bool mixed) { String msg = _f ("can't find start of piano pedal bracket: `%s'", p->name_); p->event_drul_[STOP]->origin ()->warning (msg); - p->event_drul_[STOP] = 0; + p->event_drul_[STOP] = 0; } if (p->event_drul_[STOP]) { - assert (!p->finished_bracket_); + assert (!p->finished_bracket_); Grob *cmc = unsmob_grob (get_property ("currentMusicalColumn")); @@ -346,7 +338,7 @@ Piano_pedal_engraver::create_bracket_grobs (Pedal_info *p, bool mixed) p->start_ev_ = p->event_drul_[START]; p->current_bracket_ev_ = p->event_drul_[START]; - p->bracket_ = make_spanner ("PianoPedalBracket", p->event_drul_[START]->self_scm ()); + p->bracket_ = make_spanner ("PianoPedalBracket", p->event_drul_[START]->self_scm ()); /* Set properties so that the stencil-creating function will @@ -359,8 +351,7 @@ Piano_pedal_engraver::create_bracket_grobs (Pedal_info *p, bool mixed) p->bracket_->set_property ("bracket-flare", scm_cons (scm_make_real (0), scm_cdr (flare))); } - - /* Set this property for 'mixed style' pedals, Ped._______/\ , + /* Set this property for 'mixed style' pedals, Ped._______/\ , so the stencil function will shorten the ____ line by the length of the Ped. text. */ @@ -379,7 +370,6 @@ Piano_pedal_engraver::create_bracket_grobs (Pedal_info *p, bool mixed) p->bracket_->set_property ("pedal-text", p->item_->self_scm ()); } - /* We do not use currentMusicalColumn for the left span-point. If the column as accidentals (eg on a different stave), the @@ -392,9 +382,9 @@ Piano_pedal_engraver::create_bracket_grobs (Pedal_info *p, bool mixed) TODO: what about the right span point? - + */ - Axis_group_interface::add_element (p->line_spanner_, p->bracket_); + Axis_group_interface::add_element (p->line_spanner_, p->bracket_); if (!p->event_drul_[STOP]) { @@ -404,10 +394,10 @@ Piano_pedal_engraver::create_bracket_grobs (Pedal_info *p, bool mixed) // position new pedal spanner below the current one */ - if (previous_.size ()) + if (previous_.size ()) Side_position_interface::add_support (p->line_spanner_, previous_.top ()); - previous_.push (p->line_spanner_); + previous_.push (p->line_spanner_); } } @@ -417,8 +407,8 @@ Piano_pedal_engraver::create_bracket_grobs (Pedal_info *p, bool mixed) void Piano_pedal_engraver::finalize () -{ - for (Pedal_info*p = info_list_; p && p->name_; p ++) +{ + for (Pedal_info *p = info_list_; p && p->name_; p++) { /* suicide? @@ -426,11 +416,11 @@ Piano_pedal_engraver::finalize () if (p->line_spanner_ && !p->line_spanner_->is_live ()) p->line_spanner_ = 0; - + if (p->bracket_ && !p->bracket_->is_live ()) p->bracket_ = 0; - + if (p->bracket_) { SCM cc = get_property ("currentCommandColumn"); @@ -467,7 +457,7 @@ Piano_pedal_engraver::del_linespanner (Spanner *g) void Piano_pedal_engraver::stop_translation_timestep () { - for (Pedal_info*p = info_list_; p && p->name_; p ++) + for (Pedal_info *p = info_list_; p && p->name_; p++) { if (!p->bracket_) { @@ -475,24 +465,22 @@ Piano_pedal_engraver::stop_translation_timestep () p->line_spanner_ = 0; del_linespanner (p->finished_line_spanner_); } - + typeset_all (p); } - - for (Pedal_info*p = info_list_; p->name_; p ++) + for (Pedal_info *p = info_list_; p->name_; p++) { p->event_drul_[STOP] = 0; p->event_drul_[START] = 0; } } - void -Piano_pedal_engraver::typeset_all (Pedal_info * p) +Piano_pedal_engraver::typeset_all (Pedal_info *p) { /* - Handle suicide. + Handle suicide. */ if (p->finished_line_spanner_ && !p->finished_line_spanner_->is_live ()) @@ -501,15 +489,14 @@ Piano_pedal_engraver::typeset_all (Pedal_info * p) && !p->finished_bracket_->is_live ()) p->finished_bracket_ = 0; - if (p->item_) { p->item_ = 0; } - + if (p->finished_bracket_) { - Grob * r = p->finished_bracket_->get_bound (RIGHT); + Grob *r = p->finished_bracket_->get_bound (RIGHT); if (!r) { p->finished_bracket_->set_bound (RIGHT, unsmob_grob (get_property ("currentMusicalColumn"))); @@ -520,31 +507,31 @@ Piano_pedal_engraver::typeset_all (Pedal_info * p) if (p->finished_line_spanner_) { - Grob * l = p->finished_line_spanner_->get_bound (LEFT); - Grob * r = p->finished_line_spanner_->get_bound (RIGHT); + Grob *l = p->finished_line_spanner_->get_bound (LEFT); + Grob *r = p->finished_line_spanner_->get_bound (RIGHT); if (!r && l) p->finished_line_spanner_->set_bound (RIGHT, l); else if (!l && r) p->finished_line_spanner_->set_bound (LEFT, r); else if (!r && !l) { - Grob * cc = unsmob_grob (get_property ("currentMusicalColumn")); - Item * ci = dynamic_cast (cc); + Grob *cc = unsmob_grob (get_property ("currentMusicalColumn")); + Item *ci = dynamic_cast (cc); p->finished_line_spanner_->set_bound (RIGHT, ci); - p->finished_line_spanner_->set_bound (LEFT, ci); + p->finished_line_spanner_->set_bound (LEFT, ci); } - + p->finished_line_spanner_ = 0; } } ADD_TRANSLATOR (Piano_pedal_engraver, - /* descr */ "Engrave piano pedal symbols and brackets.", - /* creats*/ "SostenutoPedal SustainPedal UnaCordaPedal SostenutoPedalLineSpanner SustainPedalLineSpanner UnaCordaPedalLineSpanner", - /* accepts */ "pedal-event", - /* acks */ "note-column-interface", - /* reads */ "currentCommandColumn " - "pedalSostenutoStrings pedalSustainStrings " - "pedalUnaCordaStrings pedalSostenutoStyle " - "pedalSustainStyle pedalUnaCordaStyle", - /* write */ ""); + /* descr */ "Engrave piano pedal symbols and brackets.", + /* creats*/ "SostenutoPedal SustainPedal UnaCordaPedal SostenutoPedalLineSpanner SustainPedalLineSpanner UnaCordaPedalLineSpanner", + /* accepts */ "pedal-event", + /* acks */ "note-column-interface", + /* reads */ "currentCommandColumn " + "pedalSostenutoStrings pedalSustainStrings " + "pedalUnaCordaStrings pedalSostenutoStyle " + "pedalSustainStyle pedalUnaCordaStyle", + /* write */ ""); diff --git a/lily/piano-pedal-performer.cc b/lily/piano-pedal-performer.cc index e423e01106..82c5f9b21b 100644 --- a/lily/piano-pedal-performer.cc +++ b/lily/piano-pedal-performer.cc @@ -11,30 +11,30 @@ /** perform Piano pedals - */ +*/ class Piano_pedal_performer : public Performer { struct Pedal_info { char const *name_; - Music* start_req_; - Drul_array req_drul_; + Music *start_req_; + Drul_array req_drul_; }; public: TRANSLATOR_DECLARATIONS (Piano_pedal_performer); ~Piano_pedal_performer (); - + protected: virtual void initialize (); - virtual bool try_music (Music*); + virtual bool try_music (Music *); virtual void create_audio_elements (); virtual void stop_translation_timestep (); virtual void start_translation_timestep (); private: Link_array audios_; - Pedal_info * info_alist_; + Pedal_info *info_alist_; }; Piano_pedal_performer::Piano_pedal_performer () @@ -53,8 +53,8 @@ Piano_pedal_performer::initialize () info_alist_ = new Pedal_info[4]; Pedal_info *p = info_alist_; - char * names [] = { "Sostenuto", "Sustain", "UnaCorda", 0 }; - char **np = names ; + char *names [] = { "Sostenuto", "Sustain", "UnaCorda", 0 }; + char **np = names; do { p->name_ = *np; @@ -64,14 +64,14 @@ Piano_pedal_performer::initialize () p++; } - while (* (np ++)); + while (* (np++)); } void Piano_pedal_performer::create_audio_elements () { - for (Pedal_info*p = info_alist_; p && p->name_; p ++) - + for (Pedal_info *p = info_alist_; p && p->name_; p++) + { if (p->req_drul_[STOP]) { @@ -81,7 +81,7 @@ Piano_pedal_performer::create_audio_elements () } else { - Audio_piano_pedal* a = new Audio_piano_pedal; + Audio_piano_pedal *a = new Audio_piano_pedal; a->type_string_ = String (p->name_); a->dir_ = STOP; audios_.push (a); @@ -92,7 +92,7 @@ Piano_pedal_performer::create_audio_elements () if (p->req_drul_[START]) { p->start_req_ = p->req_drul_[START]; - Audio_piano_pedal* a = new Audio_piano_pedal; + Audio_piano_pedal *a = new Audio_piano_pedal; a->type_string_ = String (p->name_); a->dir_ = START; audios_.push (a); @@ -113,7 +113,7 @@ Piano_pedal_performer::stop_translation_timestep () void Piano_pedal_performer::start_translation_timestep () { - for (Pedal_info*p = info_alist_; p && p->name_; p ++) + for (Pedal_info *p = info_alist_; p && p->name_; p++) { p->req_drul_[STOP] = 0; p->req_drul_[START] = 0; @@ -121,15 +121,15 @@ Piano_pedal_performer::start_translation_timestep () } bool -Piano_pedal_performer::try_music (Music* r) +Piano_pedal_performer::try_music (Music *r) { - if (r->is_mus_type ("pedal-event")) + if (r->is_mus_type ("pedal-event")) { - for (Pedal_info*p = info_alist_; p->name_; p ++) + for (Pedal_info *p = info_alist_; p->name_; p++) { String nm = p->name_ + String ("Event"); - if (ly_c_equal_p (r->get_property ("name") , - scm_str2symbol (nm.to_str0()))) + if (ly_c_equal_p (r->get_property ("name"), + scm_str2symbol (nm.to_str0 ()))) { Direction d = to_dir (r->get_property ("span-direction")); p->req_drul_[d] = r; @@ -141,5 +141,5 @@ Piano_pedal_performer::try_music (Music* r) } ADD_TRANSLATOR (Piano_pedal_performer, "", "", - "pedal-event", - "", "", "" ); + "pedal-event", + "", "", ""); diff --git a/lily/pitch-interval.cc b/lily/pitch-interval.cc index 3787d322e5..73c619e1bf 100644 --- a/lily/pitch-interval.cc +++ b/lily/pitch-interval.cc @@ -1,10 +1,9 @@ -/* +/* pitch-interval.cc -- implement Pitch_interval - + source file of the GNU LilyPond music typesetter - + (c) 2004--2005 Han-Wen Nienhuys - */ #include "pitch-interval.hh" @@ -13,30 +12,27 @@ Pitch_interval::Pitch_interval (Pitch p1, Pitch p2) { - elem_ref(LEFT) = p1; - elem_ref(RIGHT) = p2; + elem_ref (LEFT) = p1; + elem_ref (RIGHT) = p2; } - Pitch_interval::Pitch_interval () { - elem_ref(LEFT) = Pitch (100, 0, 0); - elem_ref(RIGHT) = Pitch (-100, 0, 0); + elem_ref (LEFT) = Pitch (100, 0, 0); + elem_ref (RIGHT) = Pitch (-100, 0, 0); } - bool Pitch_interval::is_empty () const { - return elem(LEFT) > elem(RIGHT); + return elem (LEFT) > elem (RIGHT); } - void Pitch_interval::add_point (Pitch p) { - if (elem_ref(LEFT) > p) - elem_ref(LEFT) = p; - if (elem_ref(RIGHT) < p) - elem_ref(RIGHT) = p; + if (elem_ref (LEFT) > p) + elem_ref (LEFT) = p; + if (elem_ref (RIGHT) < p) + elem_ref (RIGHT) = p; } diff --git a/lily/pitch-scheme.cc b/lily/pitch-scheme.cc index 035f6f2c08..c417c850f0 100644 --- a/lily/pitch-scheme.cc +++ b/lily/pitch-scheme.cc @@ -4,7 +4,6 @@ source file of the GNU LilyPond music typesetter (c) 2005 Han-Wen Nienhuys - */ #include "pitch.hh" @@ -14,7 +13,7 @@ LY_DEFINE (ly_pitch_transpose, "ly:pitch-transpose", "Transpose @var{p} by the amount @var{delta}, " "where @var{delta} is relative to middle C.") { - Pitch* t = unsmob_pitch (p); + Pitch *t = unsmob_pitch (p); Pitch *d = unsmob_pitch (delta); SCM_ASSERT_TYPE (t, p, SCM_ARG1, __FUNCTION__, "pitch"); SCM_ASSERT_TYPE (d, delta, SCM_ARG1, __FUNCTION__, "pitch"); @@ -31,7 +30,7 @@ LY_DEFINE (ly_make_pitch, "ly:make-pitch", "The @var{alter} is zero for a natural, negative for " "flats, or positive for sharps. ") { - SCM_ASSERT_TYPE (scm_integer_p (octave)== SCM_BOOL_T , octave, SCM_ARG1, __FUNCTION__, "integer"); + SCM_ASSERT_TYPE (scm_integer_p (octave)== SCM_BOOL_T, octave, SCM_ARG1, __FUNCTION__, "integer"); SCM_ASSERT_TYPE (scm_integer_p (note)== SCM_BOOL_T, note, SCM_ARG2, __FUNCTION__, "integer"); SCM_ASSERT_TYPE (scm_integer_p (alter)== SCM_BOOL_T, alter, SCM_ARG3, __FUNCTION__, "integer"); @@ -116,9 +115,9 @@ LY_DEFINE (ly_pitch_less_p, "ly:pitch - - */ +*/ #include "staff-symbol-referencer.hh" #include "note-head.hh" #include "rhythmic-head.hh" #include "engraver.hh" -class Pitch_squash_engraver : public Engraver { +class Pitch_squash_engraver : public Engraver +{ public: TRANSLATOR_DECLARATIONS (Pitch_squash_engraver); virtual void acknowledge_grob (Grob_info); }; - void Pitch_squash_engraver::acknowledge_grob (Grob_info i) { @@ -29,22 +28,20 @@ Pitch_squash_engraver::acknowledge_grob (Grob_info i) } } - - Pitch_squash_engraver::Pitch_squash_engraver () { } ADD_TRANSLATOR (Pitch_squash_engraver, -/* descr */ - "Set the vertical position of noteheads to " - "@code{squashedPosition}, if that " - "property is set. " - "This can be used to make a single line staff " - "demonstrating the rhythm of a melody.", - -/* creats*/ "", -/* accepts */ "", -/* acks */ "note-head-interface", -/* reads */ "squashedPosition", -/* write */ ""); + /* descr */ + "Set the vertical position of noteheads to " + "@code{squashedPosition}, if that " + "property is set. " + "This can be used to make a single line staff " + "demonstrating the rhythm of a melody.", + + /* creats*/ "", + /* accepts */ "", + /* acks */ "note-head-interface", + /* reads */ "squashedPosition", + /* write */ ""); diff --git a/lily/pitch.cc b/lily/pitch.cc index 23c69bc7ec..01bb70d5b1 100644 --- a/lily/pitch.cc +++ b/lily/pitch.cc @@ -31,7 +31,7 @@ Pitch::Pitch () int Pitch::compare (Pitch const &m1, Pitch const &m2) { - int o = m1.octave_ - m2.octave_; + int o = m1.octave_ - m2.octave_; int n = m1.notename_ - m2.notename_; int a = m1.alteration_ - m2.alteration_; @@ -47,12 +47,11 @@ Pitch::compare (Pitch const &m1, Pitch const &m2) int Pitch::steps () const { - return notename_ + octave_*7; + return notename_ + octave_*7; } /* Should be settable from input? */ -static Byte diatonic_scale_semitones[ ] = { 0, 2, 4, 5, 7, 9, 11 }; - +static Byte diatonic_scale_semitones[ ] = { 0, 2, 4, 5, 7, 9, 11 }; /* Calculate pitch height in 12th octave steps. Don't assume normalised pitch as this function is used to normalise the pitch. */ @@ -64,7 +63,7 @@ Pitch::semitone_pitch () const while (n < 0) { n += 7; - o --; + o--; } if (alteration_ % 2) @@ -83,7 +82,7 @@ Pitch::quartertone_pitch () const while (n < 0) { n += 7; - o --; + o--; } return ((o + n / 7) * 24 @@ -140,7 +139,7 @@ Pitch::normalise () void Pitch::transpose (Pitch delta) { - int new_semi = quartertone_pitch () +delta.quartertone_pitch (); + int new_semi = quartertone_pitch () +delta.quartertone_pitch (); octave_ += delta.octave_; notename_ += delta.notename_; alteration_ += new_semi - quartertone_pitch (); @@ -149,9 +148,9 @@ Pitch::transpose (Pitch delta) } Pitch -pitch_interval (Pitch const & from , Pitch const & to ) +pitch_interval (Pitch const &from, Pitch const &to) { - int sound = to.quartertone_pitch () - from.quartertone_pitch (); + int sound = to.quartertone_pitch () - from.quartertone_pitch (); Pitch pt (to.get_octave () - from.get_octave (), to.get_notename () - from.get_notename (), @@ -160,11 +159,10 @@ pitch_interval (Pitch const & from , Pitch const & to ) return pt.transposed (Pitch (0, 0, sound - pt.quartertone_pitch ())); } - /* FIXME Merge with *pitch->text* funcs in chord-name.scm */ char const *accname[] = {"eses", "eseh", "es", "eh", "", - "ih", "is" , "isih", "isis"}; + "ih", "is", "isih", "isis"}; String Pitch::to_string () const @@ -196,7 +194,7 @@ Pitch Pitch::to_relative_octave (Pitch p) const { /* account for c' = octave 1 iso. 0 4 */ - int oct_mod = octave_ + 1; + int oct_mod = octave_ + 1; Pitch up_pitch (p); Pitch down_pitch (p); @@ -222,7 +220,7 @@ Pitch::up_to (int notename) { if (notename_ > notename) octave_++; - notename_ = notename; + notename_ = notename; } void @@ -253,7 +251,7 @@ Pitch::print_smob (SCM s, SCM port, scm_print_state *) } SCM -Pitch::equal_p (SCM a , SCM b) +Pitch::equal_p (SCM a, SCM b) { Pitch *p = (Pitch *) SCM_CELL_WORD_1 (a); Pitch *q = (Pitch *) SCM_CELL_WORD_1 (b); @@ -265,7 +263,6 @@ Pitch::equal_p (SCM a , SCM b) return eq ? SCM_BOOL_T : SCM_BOOL_F; } - MAKE_SCHEME_CALLBACK (Pitch, less_p, 2); SCM Pitch::less_p (SCM p1, SCM p2) @@ -279,7 +276,6 @@ Pitch::less_p (SCM p1, SCM p2) return SCM_BOOL_F; } - int Pitch::get_octave () const { diff --git a/lily/property-iterator.cc b/lily/property-iterator.cc index 56ec999887..9ff020881b 100644 --- a/lily/property-iterator.cc +++ b/lily/property-iterator.cc @@ -38,7 +38,7 @@ void Property_unset_iterator::process (Moment m) { SCM sym = get_music ()->get_property ("symbol"); - type_check_assignment (sym, SCM_EOL, ly_symbol2scm ("translation-type?")); + type_check_assignment (sym, SCM_EOL, ly_symbol2scm ("translation-type?")); get_outlet ()->unset_property (sym); Simple_music_iterator::process (m); @@ -46,10 +46,10 @@ Property_unset_iterator::process (Moment m) MAKE_SCHEME_CALLBACK (Property_iterator, once_finalization, 2); SCM -Property_iterator::once_finalization (SCM translator, SCM music ) +Property_iterator::once_finalization (SCM translator, SCM music) { - Music * m = unsmob_music (music); - Context * tg + Music *m = unsmob_music (music); + Context *tg = dynamic_cast (unsmob_context (translator)); SCM sym = m->get_property ("symbol"); @@ -60,24 +60,23 @@ Property_iterator::once_finalization (SCM translator, SCM music ) void Property_iterator::do_quit () { - if (to_boolean (get_music ()->get_property ("once"))) + if (to_boolean (get_music ()->get_property ("once"))) { SCM trans = get_outlet ()->self_scm (); SCM music = get_music ()->self_scm (); - Global_context * tg = get_outlet ()->get_global_context (); + Global_context *tg = get_outlet ()->get_global_context (); tg->add_finalization (scm_list_n (once_finalization_proc, trans, music, SCM_UNDEFINED)); } } - SCM list_p = 0; /* This is a rather crude check: we merely check if the translator property is a list. - */ +*/ bool check_grob (Music *mus, SCM sym) { @@ -85,16 +84,15 @@ check_grob (Music *mus, SCM sym) { list_p = scm_c_eval_string ("list?"); } - - + SCM type = scm_object_property (sym, ly_symbol2scm ("translation-type?")); bool ok = type == list_p; if (!ok) { - mus->origin ()->warning (_f ("Not a grob name, `%s'." , ly_symbol2string (sym))); + mus->origin ()->warning (_f ("Not a grob name, `%s'.", ly_symbol2string (sym))); } - return ok; + return ok; } void @@ -119,14 +117,14 @@ MAKE_SCHEME_CALLBACK (Push_property_iterator, once_finalization, 2); SCM Push_property_iterator::once_finalization (SCM trans, SCM music) { - Music * mus = unsmob_music (music); - Context * tg = dynamic_cast (unsmob_context (trans)); - + Music *mus = unsmob_music (music); + Context *tg = dynamic_cast (unsmob_context (trans)); + SCM sym = mus->get_property ("symbol"); if (check_grob (mus, sym)) { SCM eprop = mus->get_property ("grob-property"); - + execute_pushpop_property (tg, sym, eprop, SCM_UNDEFINED); } return SCM_UNSPECIFIED; @@ -135,12 +133,12 @@ Push_property_iterator::once_finalization (SCM trans, SCM music) void Push_property_iterator::do_quit () { - if (to_boolean (get_music ()->get_property ("once"))) + if (to_boolean (get_music ()->get_property ("once"))) { SCM trans = get_outlet ()->self_scm (); SCM music = get_music ()->self_scm (); - Global_context * tg = get_outlet ()->get_global_context (); + Global_context *tg = get_outlet ()->get_global_context (); tg->add_finalization (scm_list_n (once_finalization_proc, trans, music, SCM_UNDEFINED)); } @@ -150,17 +148,15 @@ void Pop_property_iterator::process (Moment m) { SCM sym = get_music ()->get_property ("symbol"); - + if (check_grob (get_music (), sym)) { SCM eprop = get_music ()->get_property ("grob-property"); -execute_pushpop_property (get_outlet (), sym, eprop, SCM_UNDEFINED); + execute_pushpop_property (get_outlet (), sym, eprop, SCM_UNDEFINED); } Simple_music_iterator::process (m); } - - IMPLEMENT_CTOR_CALLBACK (Pop_property_iterator); IMPLEMENT_CTOR_CALLBACK (Push_property_iterator); IMPLEMENT_CTOR_CALLBACK (Property_iterator); diff --git a/lily/protected-scm.cc b/lily/protected-scm.cc index 7b5307daf9..976563ac89 100644 --- a/lily/protected-scm.cc +++ b/lily/protected-scm.cc @@ -1,11 +1,10 @@ -/* +/* protected-scm.cc -- implement Protected_scm - + source file of the GNU LilyPond music typesetter - + (c) 1998--2005 Han-Wen Nienhuys - - */ +*/ #include "protected-scm.hh" @@ -31,12 +30,12 @@ Protected_scm::~Protected_scm () scm_gc_unprotect_object (object_); } -Protected_scm & -Protected_scm::operator = (SCM s) +Protected_scm & +Protected_scm::operator= (SCM s) { if (object_ == s) return *this; - + if (SCM_NIMP (object_)) scm_gc_unprotect_object (object_); @@ -44,10 +43,10 @@ Protected_scm::operator = (SCM s) return *this; } -Protected_scm& -Protected_scm::operator = (Protected_scm const &s) +Protected_scm & +Protected_scm::operator= (Protected_scm const &s) { - return operator = (s.object_); + return operator= (s.object_); } Protected_scm::operator SCM () const @@ -55,7 +54,7 @@ Protected_scm::operator SCM () const return object_; } -SCM +SCM Protected_scm::to_SCM () const { return object_; diff --git a/lily/quote-iterator.cc b/lily/quote-iterator.cc index 89785ea4b9..ab7a206ce1 100644 --- a/lily/quote-iterator.cc +++ b/lily/quote-iterator.cc @@ -1,10 +1,9 @@ -/* +/* quote-iterator.cc -- implement Quote_iterator source file of the GNU LilyPond music typesetter (c) 2004--2005 Han-Wen Nienhuys - */ #include "context.hh" @@ -25,13 +24,13 @@ public: Moment stop_moment_; SCM event_vector_; int event_idx_; - int end_idx_ ; + int end_idx_; SCM transposed_musics_; - - DECLARE_SCHEME_CALLBACK (constructor, ()); + + DECLARE_SCHEME_CALLBACK (constructor, ()); bool quote_ok () const; - bool accept_music_type (Music*) const; + bool accept_music_type (Music *) const; protected: virtual void derived_mark () const; virtual void construct_children (); @@ -43,9 +42,9 @@ protected: bool Quote_iterator::accept_music_type (Music *mus) const { - SCM accept = get_outlet()->get_property ("quotedEventTypes"); - for (SCM s = mus->get_property ("types"); - scm_is_pair (s); s = scm_cdr (s)) + SCM accept = get_outlet ()->get_property ("quotedEventTypes"); + for (SCM s = mus->get_property ("types"); + scm_is_pair (s); s = scm_cdr (s)) { if (scm_memq (scm_car (s), accept) != SCM_BOOL_F) return true; @@ -54,11 +53,10 @@ Quote_iterator::accept_music_type (Music *mus) const return false; } - void Quote_iterator::derived_mark () const { - scm_gc_mark (transposed_musics_ ); + scm_gc_mark (transposed_musics_); } Quote_iterator::Quote_iterator () @@ -69,31 +67,29 @@ Quote_iterator::Quote_iterator () end_idx_ = 0; } - int -binsearch_scm_vector (SCM vec, SCM key, bool (*is_less)(SCM a, SCM b)) +binsearch_scm_vector (SCM vec, SCM key, bool (*is_less) (SCM a, SCM b)) { int lo = 0; int hi = scm_c_vector_length (vec); /* binary search */ do - { - int cmp = (lo + hi) / 2; + { + int cmp = (lo + hi) / 2; SCM when = scm_caar (scm_c_vector_ref (vec, cmp)); - bool result = (*is_less) (key, when); + bool result = (*is_less) (key, when); if (result) - hi = cmp; + hi = cmp; else - lo = cmp; + lo = cmp; } while (hi - lo > 1); return lo; } - void Quote_iterator::construct_children () { @@ -105,32 +101,30 @@ Quote_iterator::construct_children () if (scm_is_string (id) && scm_is_symbol (name)) { - Context *cue_context = get_outlet()->find_create_context (name, - ly_scm2string (id), SCM_EOL); + Context *cue_context = get_outlet ()->find_create_context (name, + ly_scm2string (id), SCM_EOL); quote_outlet_.set_context (cue_context); } else { quote_outlet_.set_context (get_outlet ()); } - event_vector_ = get_music ()->get_property ("quoted-events"); - + /* We have to delay initting event_idx_ , since we have to - take starting grace notes into account. Those may offset + take starting grace notes into account. Those may offset event_idx_. */ event_idx_ = -1; } - bool Quote_iterator::ok () const { return - Music_wrapper_iterator::ok() + Music_wrapper_iterator::ok () || quote_ok (); } @@ -143,9 +137,8 @@ Quote_iterator::quote_ok () const /* Don't quote the grace notes leading to an unquoted note. - */ - && vector_moment (event_idx_).main_part_ < stop_moment_.main_part_ - ); + */ + && vector_moment (event_idx_).main_part_ < stop_moment_.main_part_); } Moment @@ -155,13 +148,13 @@ Quote_iterator::pending_moment () const infty.set_infinite (1); Moment m (infty); - if (Music_wrapper_iterator::ok()) - m = m now_mom ().smobbed_copy (), &moment_less); - start_moment_ = get_outlet ()->now_mom () - music_start_mom(); - stop_moment_ = start_moment_ + get_music()->get_length (); - + start_moment_ = get_outlet ()->now_mom () - music_start_mom (); + stop_moment_ = start_moment_ + get_music ()->get_length (); + end_idx_ = binsearch_scm_vector (event_vector_, stop_moment_.smobbed_copy (), &moment_less); } - + m += start_moment_; while (event_idx_ <= end_idx_) { Moment em = vector_moment (event_idx_); if (em > m) - return ; + return; if (em == m) - break ; + break; event_idx_++; } @@ -213,18 +206,18 @@ Quote_iterator::process (Moment m) if (quote_ok ()) { SCM entry = scm_c_vector_ref (event_vector_, event_idx_); - Pitch * quote_pitch = unsmob_pitch (scm_cdar (entry)); + Pitch *quote_pitch = unsmob_pitch (scm_cdar (entry)); /* The pitch that sounds like central C - */ - Pitch * me_pitch = unsmob_pitch (get_outlet ()->get_property ("instrumentTransposition")); - + */ + Pitch *me_pitch = unsmob_pitch (get_outlet ()->get_property ("instrumentTransposition")); + for (SCM s = scm_cdr (entry); scm_is_pair (s); s = scm_cdr (s)) { SCM ev_acc = scm_car (s); - Music * mus = unsmob_music (scm_car (ev_acc)); + Music *mus = unsmob_music (scm_car (ev_acc)); if (!mus) programming_error ("need music in quote."); else if (accept_music_type (mus)) @@ -241,18 +234,18 @@ Quote_iterator::process (Moment m) SCM copy = ly_music_deep_copy (mus->self_scm ()); mus = unsmob_music (copy); - + transposed_musics_ = scm_cons (copy, transposed_musics_); mus->transpose (diff); } - + bool b = quote_outlet_.get_outlet ()->try_music (mus); if (!b) mus->origin ()->warning (_f ("In quotation: junking event %s", mus->name ())); } } - - event_idx_ ++; + + event_idx_++; } } diff --git a/lily/recording-group-engraver.cc b/lily/recording-group-engraver.cc index be0fe66da7..5b98ba672d 100644 --- a/lily/recording-group-engraver.cc +++ b/lily/recording-group-engraver.cc @@ -1,11 +1,10 @@ -/* +/* recording-group-engraver.cc -- implement Recording_group_engraver source file of the GNU LilyPond music typesetter (c) 2003--2005 Han-Wen Nienhuys - - */ +*/ #include "context.hh" #include "engraver-group-engraver.hh" @@ -28,7 +27,7 @@ public: void Recording_group_engraver::derived_mark () const { - Engraver_group_engraver::derived_mark(); + Engraver_group_engraver::derived_mark (); scm_gc_mark (now_events_); scm_gc_mark (accumulator_); } @@ -51,14 +50,13 @@ Recording_group_engraver::add_music (SCM music, SCM success) now_events_ = scm_cons (scm_cons (music, success), now_events_); } - void Recording_group_engraver::stop_translation_timestep () { Engraver_group_engraver::stop_translation_timestep (); accumulator_ = scm_acons (scm_cons (now_mom ().smobbed_copy (), - get_property ("instrumentTransposition")), + get_property ("instrumentTransposition")), now_events_, accumulator_); now_events_ = SCM_EOL; @@ -71,11 +69,11 @@ Recording_group_engraver::finalize () SCM proc = get_property ("recordEventSequence"); if (ly_c_procedure_p (proc)) - scm_call_2 (proc, context ()->self_scm (), scm_cdr (accumulator_)); + scm_call_2 (proc, context ()->self_scm (), scm_cdr (accumulator_)); } bool -Recording_group_engraver::try_music (Music *m) +Recording_group_engraver::try_music (Music *m) { bool retval = Translator_group::try_music (m); @@ -83,13 +81,12 @@ Recording_group_engraver::try_music (Music *m) return retval; } - ADD_TRANSLATOR (Recording_group_engraver, - "Engraver_group_engraver that records all music events " - "for this context. Calls the procedure " - "in @code{recordEventSequence} when finished.", - "", - "", - "", - "recordEventSequence", - ""); + "Engraver_group_engraver that records all music events " + "for this context. Calls the procedure " + "in @code{recordEventSequence} when finished.", + "", + "", + "", + "recordEventSequence", + ""); diff --git a/lily/relative-octave-check.cc b/lily/relative-octave-check.cc index 96b19eda3f..81d4c73cd6 100644 --- a/lily/relative-octave-check.cc +++ b/lily/relative-octave-check.cc @@ -4,7 +4,6 @@ source file of the GNU LilyPond music typesetter (c) 2005 Han-Wen Nienhuys - */ #include "music.hh" @@ -14,18 +13,17 @@ class Relative_octave_check { public: - DECLARE_SCHEME_CALLBACK(relative_callback, (SCM, SCM)); + DECLARE_SCHEME_CALLBACK (relative_callback, (SCM, SCM)); }; - -MAKE_SCHEME_CALLBACK(Relative_octave_check, relative_callback, 2) -SCM +MAKE_SCHEME_CALLBACK (Relative_octave_check, relative_callback, 2) + SCM Relative_octave_check::relative_callback (SCM music, SCM last_pitch) { Pitch p = *unsmob_pitch (last_pitch); - Music *m = unsmob_music (music); + Music *m = unsmob_music (music); Pitch *check_p = unsmob_pitch (m->get_property ("pitch")); - + int delta_oct = 0; if (check_p) { @@ -37,15 +35,15 @@ Relative_octave_check::relative_callback (SCM music, SCM last_pitch) if (result != *check_p) { - String s = _("Failed octave check, got: "); + String s = _ ("Failed octave check, got: "); s += result.to_string (); - + m->origin ()->warning (s); - + delta_oct = check_p->get_octave () - result.get_octave (); } } - + return Pitch (p.get_octave () + delta_oct, p.get_notename (), p.get_alteration ()).smobbed_copy (); } diff --git a/lily/relative-octave-music.cc b/lily/relative-octave-music.cc index 01ddcc0b37..a04b735cbf 100644 --- a/lily/relative-octave-music.cc +++ b/lily/relative-octave-music.cc @@ -1,35 +1,33 @@ -/* +/* relative-music.cc -- implement Relative_octave_music - + source file of the GNU LilyPond music typesetter - + (c) 1998--2005 Han-Wen Nienhuys - - */ +*/ #include "music.hh" #include "pitch.hh" #include "warn.hh" #include "scm-option.hh" - class Relative_octave_music { public: - DECLARE_SCHEME_CALLBACK(relative_callback, (SCM, SCM)); - DECLARE_SCHEME_CALLBACK(no_relative_callback, (SCM, SCM)); + DECLARE_SCHEME_CALLBACK (relative_callback, (SCM, SCM)); + DECLARE_SCHEME_CALLBACK (no_relative_callback, (SCM, SCM)); }; -MAKE_SCHEME_CALLBACK(Relative_octave_music, no_relative_callback, 2) -SCM +MAKE_SCHEME_CALLBACK (Relative_octave_music, no_relative_callback, 2) + SCM Relative_octave_music::no_relative_callback (SCM music, SCM pitch) { (void)music; return pitch; } -MAKE_SCHEME_CALLBACK(Relative_octave_music, relative_callback, 2) -SCM +MAKE_SCHEME_CALLBACK (Relative_octave_music, relative_callback, 2) + SCM Relative_octave_music::relative_callback (SCM music, SCM pitch) { Music *me = unsmob_music (music); @@ -39,15 +37,14 @@ Relative_octave_music::relative_callback (SCM music, SCM pitch) /* last-pitch should be junked some time, when we ditch 1.8 compat too. - When you do, B should start where A left off. + When you do, B should start where A left off. - \relative { A \relative { ...} B } */ + \relative { A \relative { ...} B } */ SCM last_pitch = me->get_property ("last-pitch"); Pitch *ptr = unsmob_pitch (last_pitch); - return (ptr) ? last_pitch : pitch; + return (ptr) ? last_pitch : pitch; } else return pitch; } - diff --git a/lily/repeat-acknowledge-engraver.cc b/lily/repeat-acknowledge-engraver.cc index 5978c0de26..0fdc741350 100644 --- a/lily/repeat-acknowledge-engraver.cc +++ b/lily/repeat-acknowledge-engraver.cc @@ -1,11 +1,10 @@ -/* +/* repeat-acknowledge-engraver.cc -- implement Repeat_acknowledge_engraver - + source file of the GNU LilyPond music typesetter - + (c) 2000--2005 Han-Wen Nienhuys - - */ +*/ #include "engraver.hh" #include "translator-group.hh" @@ -16,17 +15,16 @@ Objective: -- set and reset repeatCommands, so Unfolded_repeat_iterator knows - where to set variables. + where to set variables. -- collect information passed by Unfolded_repeat_iterator for - Bar_engraver: writes whichBar property. (TODO: check for - interactions with timing engraver.) - - */ + Bar_engraver: writes whichBar property. (TODO: check for + interactions with timing engraver.) +*/ class Repeat_acknowledge_engraver : public Engraver { public: - + TRANSLATOR_DECLARATIONS (Repeat_acknowledge_engraver); protected: virtual void start_translation_timestep (); @@ -41,7 +39,6 @@ Repeat_acknowledge_engraver::initialize () context ()->set_property ("repeatCommands", SCM_EOL); } - Repeat_acknowledge_engraver::Repeat_acknowledge_engraver () { } @@ -49,7 +46,7 @@ Repeat_acknowledge_engraver::Repeat_acknowledge_engraver () void Repeat_acknowledge_engraver::start_translation_timestep () { - Context * tr = context ()->where_defined (ly_symbol2scm ("repeatCommands")); + Context *tr = context ()->where_defined (ly_symbol2scm ("repeatCommands")); if (!tr) tr = context (); @@ -61,12 +58,12 @@ Repeat_acknowledge_engraver::process_music () { /* At the start of a piece, we don't print any repeat bars. - */ + */ if (!now_mom ().main_part_) - return ; - + return; + SCM cs = get_property ("repeatCommands"); - + String s = ""; bool start = false; bool end = false; @@ -80,7 +77,7 @@ Repeat_acknowledge_engraver::process_music () end = true; else if (scm_is_pair (command) && scm_car (command) == ly_symbol2scm ("volta")) volta_found = true; - cs = scm_cdr (cs); + cs = scm_cdr (cs); } if (start && end) @@ -92,14 +89,14 @@ Repeat_acknowledge_engraver::process_music () /* TODO: line breaks might be allowed if we set whichBar to "". - */ + */ /* We only set the barline if we wouldn't overwrite a previously set barline. - */ + */ SCM wb = get_property ("whichBar"); - SCM db = get_property ("defaultBarType"); + SCM db = get_property ("defaultBarType"); if (!scm_is_string (wb) || ly_c_equal_p (db, wb)) { if (s != "" || (volta_found && !scm_is_string (wb))) @@ -110,10 +107,10 @@ Repeat_acknowledge_engraver::process_music () } ADD_TRANSLATOR (Repeat_acknowledge_engraver, -/* descr */ "Acknowledge repeated music, and convert the contents of " -"repeatCommands ainto an appropriate setting for whichBar.", -/* creats*/ "", -/* accepts */ "", -/* acks */ "", -/* reads */ "repeatCommands whichBar", -/* write */ ""); + /* descr */ "Acknowledge repeated music, and convert the contents of " + "repeatCommands ainto an appropriate setting for whichBar.", + /* creats*/ "", + /* accepts */ "", + /* acks */ "", + /* reads */ "repeatCommands whichBar", + /* write */ ""); diff --git a/lily/repeated-music.cc b/lily/repeated-music.cc index e5ccef6c0c..4a0f7d6e88 100644 --- a/lily/repeated-music.cc +++ b/lily/repeated-music.cc @@ -1,11 +1,10 @@ -/* +/* repeated-music.cc -- implement Repeated_music - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - - */ +*/ #include "repeated-music.hh" #include "music-sequence.hh" @@ -25,22 +24,22 @@ Repeated_music::alternatives (Music *me) return me->get_property ("elements"); } -MAKE_SCHEME_CALLBACK(Repeated_music, relative_callback, 2); +MAKE_SCHEME_CALLBACK (Repeated_music, relative_callback, 2); SCM Repeated_music::relative_callback (SCM music, SCM pitch) { Pitch p = *unsmob_pitch (pitch); - Music *me = unsmob_music (music); + Music *me = unsmob_music (music); if (lily_1_8_relative) { Music *body = unsmob_music (me->get_property ("element")); if (body) p = body->to_relative_octave (p); - Pitch last = p ; + Pitch last = p; SCM alternatives = me->get_property ("elements"); - for (SCM s = alternatives; scm_is_pair (s); s = scm_cdr (s)) + for (SCM s = alternatives; scm_is_pair (s); s = scm_cdr (s)) { lily_1_8_compatibility_used = true; unsmob_music (scm_car (s))->to_relative_octave (p); @@ -54,15 +53,14 @@ Repeated_music::relative_callback (SCM music, SCM pitch) } } - Moment -Repeated_music::alternatives_get_length (Music *me, bool fold) +Repeated_music::alternatives_get_length (Music *me, bool fold) { SCM alternative_list = alternatives (me); int len = scm_ilength (alternative_list); if (len <= 0) return 0; - + if (fold) return Music_sequence::maximum_length (alternative_list); @@ -74,7 +72,7 @@ Repeated_music::alternatives_get_length (Music *me, bool fold) while (scm_is_pair (p) && done < count) { m = m + unsmob_music (scm_car (p))->get_length (); - done ++; + done++; if (count - done < len) p = scm_cdr (p); } @@ -91,10 +89,9 @@ Repeated_music::alternatives_volta_get_length (Music *me) return Music_sequence::cumulative_length (alternatives (me)); } - /* - Length of the body in THIS. Disregards REPEAT-COUNT. - */ + Length of the body in THIS. Disregards REPEAT-COUNT. +*/ Moment Repeated_music::body_get_length (Music *me) { @@ -106,7 +103,6 @@ Repeated_music::body_get_length (Music *me) return m; } - MAKE_SCHEME_CALLBACK (Repeated_music, unfolded_music_length, 1); SCM @@ -124,12 +120,12 @@ Repeated_music::folded_music_length (SCM m) { Music *me = unsmob_music (m); - Moment l = body_get_length (me) + alternatives_get_length (me, true); + Moment l = body_get_length (me) + alternatives_get_length (me, true); return l.smobbed_copy (); } int -Repeated_music::repeat_count (Music *me) +Repeated_music::repeat_count (Music *me) { return scm_to_int (me->get_property ("repeat-count")); } @@ -162,10 +158,10 @@ MAKE_SCHEME_CALLBACK (Repeated_music, first_start, 1); SCM Repeated_music::first_start (SCM m) { - Music * me = unsmob_music (m); - Music * body = unsmob_music (me->get_property ("element")); + Music *me = unsmob_music (m); + Music *body = unsmob_music (me->get_property ("element")); - Moment rv = (body) ? body->start_mom () : + Moment rv = (body) ? body->start_mom () : Music_sequence::first_start (me->get_property ("elements")); return rv.smobbed_copy (); diff --git a/lily/rest-collision-engraver.cc b/lily/rest-collision-engraver.cc index 3c5b2632c6..0a1af49d7a 100644 --- a/lily/rest-collision-engraver.cc +++ b/lily/rest-collision-engraver.cc @@ -13,15 +13,15 @@ class Rest_collision_engraver : public Engraver { - Item* rest_collision_; - int rest_count_; + Item *rest_collision_; + int rest_count_; Link_array note_columns_; protected: virtual void acknowledge_grob (Grob_info); virtual void process_acknowledged_grobs (); virtual void stop_translation_timestep (); public: - TRANSLATOR_DECLARATIONS (Rest_collision_engraver); + TRANSLATOR_DECLARATIONS (Rest_collision_engraver); }; Rest_collision_engraver::Rest_collision_engraver () @@ -35,14 +35,13 @@ Rest_collision_engraver::process_acknowledged_grobs () { if (rest_collision_ || note_columns_.is_empty () - || !rest_count_ + || !rest_count_ || (note_columns_.size () == rest_count_ - && rest_count_ < 2)) + && rest_count_ < 2)) return; rest_collision_ = make_item ("RestCollision", SCM_EOL); - for (int i = 0; i < note_columns_.size (); i++) Rest_collision::add_column (rest_collision_, note_columns_[i]); } @@ -54,7 +53,7 @@ Rest_collision_engraver::acknowledge_grob (Grob_info i) { note_columns_.push (i.grob_); if (Note_column::has_rests (i.grob_)) - rest_count_ ++; + rest_count_++; } } @@ -67,9 +66,9 @@ Rest_collision_engraver::stop_translation_timestep () } ADD_TRANSLATOR (Rest_collision_engraver, -/* descr */ "Handles collisions of rests.", -/* creats*/ "RestCollision", -/* accepts */ "", -/* acks */ "note-column-interface", -/* reads */ "", -/* write */ ""); + /* descr */ "Handles collisions of rests.", + /* creats*/ "RestCollision", + /* accepts */ "", + /* acks */ "note-column-interface", + /* reads */ "", + /* write */ ""); diff --git a/lily/rest-collision.cc b/lily/rest-collision.cc index 7dd7c4cc3e..bcc8a8545a 100644 --- a/lily/rest-collision.cc +++ b/lily/rest-collision.cc @@ -30,19 +30,18 @@ Rest_collision::force_shift_callback (SCM element_smob, SCM axis) assert (a == Y_AXIS); if (Note_column::has_rests (them)) - { - Grob * rc = unsmob_grob (them->get_property ("rest-collision")); + { + Grob *rc = unsmob_grob (them->get_property ("rest-collision")); if (rc && !to_boolean (rc->get_property ("positioning-done"))) { rc->set_property ("positioning-done", SCM_BOOL_T); do_shift (rc); } - } + } return scm_make_real (0.0); } - MAKE_SCHEME_CALLBACK (Rest_collision, force_shift_callback_rest, 2); SCM Rest_collision::force_shift_callback_rest (SCM rest, SCM axis) @@ -52,14 +51,13 @@ Rest_collision::force_shift_callback_rest (SCM rest, SCM axis) Grob *parent = rest_grob->get_parent (X_AXIS); if (Note_column::has_interface (parent)) - return force_shift_callback (parent->self_scm(), axis); + return force_shift_callback (parent->self_scm (), axis); else return scm_make_real (0.0); } - void -Rest_collision::add_column (Grob*me, Grob *p) +Rest_collision::add_column (Grob *me, Grob *p) { me->add_dependency (p); Pointer_group_interface::add_grob (me, ly_symbol2scm ("elements"), p); @@ -84,8 +82,7 @@ Rest_collision::add_column (Grob*me, Grob *p) /* TODO: look at horizontal-shift to determine ordering between rests for more than two voices. - - */ +*/ SCM Rest_collision::do_shift (Grob *me) { @@ -96,87 +93,89 @@ Rest_collision::do_shift (Grob *me) for (SCM s = elts; scm_is_pair (s); s = scm_cdr (s)) { - Grob * e = unsmob_grob (scm_car (s)); + Grob *e = unsmob_grob (scm_car (s)); if (unsmob_grob (e->get_property ("rest"))) { /* Ignore rests under beam. - */ - Grob* st = unsmob_grob (e->get_property ("stem")); + */ + Grob *st = unsmob_grob (e->get_property ("stem")); if (st && unsmob_grob (st->get_property ("beam"))) continue; - + rests.push (e); } else notes.push (e); } - - /* - handle rest-rest and rest-note collisions + /* + handle rest-rest and rest-note collisions - [todo] - * decide not to print rest if too crowded? - */ + [todo] + * decide not to print rest if too crowded? + */ /* no partners to collide with - */ + */ if (rests.size () + notes.size () < 2) return SCM_UNSPECIFIED; - Real staff_space = Staff_symbol_referencer::staff_space (me); /* only rests */ - if (!notes.size ()) + if (!notes.size ()) { /* This is incomplete: in case of an uneven number of rests, the center one should be centered on the staff. - */ - Drul_array< Link_array > ordered_rests; + */ + Drul_array< Link_array > ordered_rests; for (int i = 0; i < rests.size (); i++) { - Grob * r = Note_column::get_rest (rests[i]); - + Grob *r = Note_column::get_rest (rests[i]); + Direction d = get_grob_direction (r); if (d) { ordered_rests[d].push (rests[i]); } else - rests[d]->warning (_("rest direction not set. Cannot resolve collision.")); + rests[d]->warning (_ ("rest direction not set. Cannot resolve collision.")); } - Direction d = LEFT; - do { - ordered_rests[d].sort (Note_column::shift_compare); - } while (flip (&d) != LEFT); - - do { - if (ordered_rests[d].size () < 1) - { - if (ordered_rests[-d].size() > 1) - ordered_rests[-d][0]->warning (_ ("too many colliding rests")); - - return SCM_UNSPECIFIED; - } - } while (flip (&d) != LEFT); + Direction d = LEFT; + do + { + ordered_rests[d].sort (Note_column::shift_compare); + } + while (flip (&d) != LEFT); + + do + { + if (ordered_rests[d].size () < 1) + { + if (ordered_rests[-d].size () > 1) + ordered_rests[-d][0]->warning (_ ("too many colliding rests")); + + return SCM_UNSPECIFIED; + } + } + while (flip (&d) != LEFT); Grob *common = common_refpoint_of_array (ordered_rests[DOWN], me, Y_AXIS); - common = common_refpoint_of_array (ordered_rests[UP], common, Y_AXIS); + common = common_refpoint_of_array (ordered_rests[UP], common, Y_AXIS); - Real diff = - (ordered_rests[DOWN].top ()->extent (common, Y_AXIS)[UP] - - ordered_rests[UP].top ()->extent (common, Y_AXIS)[DOWN]) / staff_space; + Real diff + = (ordered_rests[DOWN].top ()->extent (common, Y_AXIS)[UP] + - ordered_rests[UP].top ()->extent (common, Y_AXIS)[DOWN]) / staff_space; if (diff > 0) { - int amount_down = (int) ceil (diff / 2); + int amount_down = (int) ceil (diff / 2); diff -= amount_down; Note_column::translate_rests (ordered_rests[DOWN].top (), -2 * amount_down); @@ -185,28 +184,31 @@ Rest_collision::do_shift (Grob *me) 2 * int (ceil (diff))); } - do { - for (int i = ordered_rests[d].size () -1; i-- > 0;) - { - Real last_y = ordered_rests[d][i+1]->extent (common, Y_AXIS)[d]; - Real y = ordered_rests[d][i]->extent (common, Y_AXIS)[-d]; + do + { + for (int i = ordered_rests[d].size () -1; i-- > 0;) + { + Real last_y = ordered_rests[d][i + 1]->extent (common, Y_AXIS)[d]; + Real y = ordered_rests[d][i]->extent (common, Y_AXIS)[-d]; + + Real diff = d * ((last_y - y) /staff_space); + if (diff > 0) + Note_column::translate_rests (ordered_rests[d][i], d * (int) ceil (diff) * 2); + } + } + while (flip (&d) != LEFT); - Real diff = d * ((last_y - y) /staff_space); - if (diff > 0) - Note_column::translate_rests (ordered_rests[d][i], d * (int) ceil (diff) * 2); - } - } while (flip (&d) != LEFT); } - else + else { /* Rests and notes. - */ + */ if (rests.size () > 1) { warning (_ ("too many colliding rests")); } - Grob * rcol = 0; + Grob *rcol = 0; Direction dir = CENTER; for (int i = rests.size (); !rcol && i--;) @@ -218,24 +220,24 @@ Rest_collision::do_shift (Grob *me) if (!rcol) return SCM_UNSPECIFIED; - + Grob *common = common_refpoint_of_array (notes, rcol, Y_AXIS); - + Interval restdim = rcol->extent (common, Y_AXIS); if (restdim.is_empty ()) return SCM_UNSPECIFIED; - + Real staff_space = Staff_symbol_referencer::staff_space (rcol); Real minimum_dist = robust_scm2double (me->get_property ("minimum-distance"), 1.0) * staff_space; Interval notedim; - for (int i = 0; i < notes.size (); i++) + for (int i = 0; i < notes.size (); i++) { notedim.unite (notes[i]->extent (common, Y_AXIS)); } - Real dist = - minimum_dist + dir * (notedim[dir] - restdim[-dir]) >? 0; + Real dist + = minimum_dist + dir * (notedim[dir] - restdim[-dir]) >? 0; int stafflines = Staff_symbol_referencer::line_count (me); if (!stafflines) @@ -243,12 +245,12 @@ Rest_collision::do_shift (Grob *me) programming_error ("No staff line count ? "); stafflines =5; } - + // move discretely by half spaces. int discrete_dist = int (ceil (dist / (0.5 *staff_space))); // move by whole spaces inside the staff. - if (discrete_dist < stafflines+1) + if (discrete_dist < stafflines + 1) discrete_dist = int (ceil (discrete_dist / 2.0)* 2.0); Note_column::translate_rests (rcol, dir * discrete_dist); @@ -256,7 +258,6 @@ Rest_collision::do_shift (Grob *me) return SCM_UNSPECIFIED; } - ADD_INTERFACE (Rest_collision, "rest-collision-interface", "Move around ordinary rests (not multi-measure-rests) to avoid " "conflicts.", diff --git a/lily/rest-engraver.cc b/lily/rest-engraver.cc index 690f994663..d6436d6a21 100644 --- a/lily/rest-engraver.cc +++ b/lily/rest-engraver.cc @@ -15,8 +15,8 @@ class Rest_engraver : public Engraver { Music *rest_req_; - Item * dot_; - Grob* rest_; + Item *dot_; + Grob *rest_; protected: virtual bool try_music (Music *); virtual void stop_translation_timestep (); @@ -27,10 +27,9 @@ public: TRANSLATOR_DECLARATIONS (Rest_engraver); }; - /* Should merge with Note_head_engraver - */ +*/ Rest_engraver::Rest_engraver () { rest_req_ = 0; @@ -54,17 +53,17 @@ Rest_engraver::stop_translation_timestep () void Rest_engraver::process_music () { - if (rest_req_ && !rest_) + if (rest_req_ && !rest_) { rest_ = make_item ("Rest", rest_req_->self_scm ()); - int durlog = unsmob_duration (rest_req_->get_property ("duration"))-> duration_log (); - + int durlog = unsmob_duration (rest_req_->get_property ("duration"))-> duration_log (); + rest_->set_property ("duration-log", - scm_int2num (durlog)); + scm_int2num (durlog)); int dots = unsmob_duration (rest_req_->get_property ("duration"))->dot_count (); - + if (dots) { dot_ = make_item ("Dots", SCM_EOL); @@ -72,7 +71,7 @@ Rest_engraver::process_music () Rhythmic_head::set_dots (rest_, dot_); dot_->set_parent (rest_, Y_AXIS); dot_->set_property ("dot-count", scm_int2num (dots)); - + } Pitch *p = unsmob_pitch (rest_req_->get_property ("pitch")); @@ -80,17 +79,17 @@ Rest_engraver::process_music () /* This is ridiculous -- rests don't have pitch, but we act as if our nose is bleeding. - */ + */ if (p) { int pos = p->steps (); SCM c0 = get_property ("middleCPosition"); if (scm_is_number (c0)) pos += scm_to_int (c0); - + rest_->set_property ("staff-position", scm_int2num (pos)); } - + } } @@ -106,9 +105,9 @@ Rest_engraver::try_music (Music *m) } ADD_TRANSLATOR (Rest_engraver, -/* descr */ "", -/* creats*/ "Rest Dots", -/* accepts */ "rest-event", -/* acks */ "", -/* reads */ "middleCPosition", -/* write */ ""); + /* descr */ "", + /* creats*/ "Rest Dots", + /* accepts */ "rest-event", + /* acks */ "", + /* reads */ "middleCPosition", + /* write */ ""); diff --git a/lily/rest.cc b/lily/rest.cc index 80b473eb10..421ab1fdfe 100644 --- a/lily/rest.cc +++ b/lily/rest.cc @@ -1,5 +1,5 @@ /* - rest.cc -- implement Rest + rest.cc -- implement Rest source file of the GNU LilyPond music typesetter @@ -29,15 +29,15 @@ Rest::after_line_breaking (SCM smob) { if (bt == 0 && lc > 1) { - me->translate_axis (ss , Y_AXIS); + me->translate_axis (ss, Y_AXIS); } } else { - me->translate_axis (ss/2 , Y_AXIS); + me->translate_axis (ss / 2, Y_AXIS); } - Grob * d = unsmob_grob (me->get_property ("dot")); + Grob *d = unsmob_grob (me->get_property ("dot")); if (d && bt > 4) // UGH. { d->set_property ("staff-position", @@ -53,7 +53,7 @@ Rest::after_line_breaking (SCM smob) /* make this function easily usable in C++ - */ +*/ String Rest::glyph_name (Grob *me, int balltype, String style, bool try_ledgers) { @@ -67,7 +67,7 @@ Rest::glyph_name (Grob *me, int balltype, String style, bool try_ledgers) Figure out when the rest is far enough outside the staff. This could bemore generic, but hey, we understand this even after dinner. - */ + */ ledgered_b |= (balltype == 0) && (pos >= +rad + 2 || pos < -rad); ledgered_b |= (balltype == 1) && (pos <= -rad - 2 || pos > +rad); } @@ -115,21 +115,20 @@ Rest::glyph_name (Grob *me, int balltype, String style, bool try_ledgers) + actual_style); } - MAKE_SCHEME_CALLBACK (Rest, print, 1); SCM Rest::brew_internal_stencil (SCM smob, bool ledgered) { - Grob* me = unsmob_grob (smob); + Grob *me = unsmob_grob (smob); SCM balltype_scm = me->get_property ("duration-log"); if (!scm_is_number (balltype_scm)) return Stencil ().smobbed_copy (); int balltype = scm_to_int (balltype_scm); - - String style; + + String style; SCM style_scm = me->get_property ("style"); if (scm_is_symbol (style_scm)) style = ly_scm2string (scm_symbol_to_string (style_scm)); @@ -143,8 +142,8 @@ Rest::brew_internal_stencil (SCM smob, bool ledgered) return out.smobbed_copy (); } -SCM -Rest::print (SCM smob) +SCM +Rest::print (SCM smob) { return brew_internal_stencil (smob, true); } @@ -165,7 +164,7 @@ Rest::extent_callback (SCM smob, SCM ax) consequence: we get too small extents and potential collisions with ledgered rests. - */ + */ SCM m = brew_internal_stencil (smob, a != X_AXIS); return ly_interval2scm (unsmob_stencil (m)->extent (a)); } @@ -174,12 +173,12 @@ MAKE_SCHEME_CALLBACK (Rest, polyphonic_offset_callback, 2); SCM Rest::polyphonic_offset_callback (SCM smob, SCM) { - Grob* me = unsmob_grob (smob); + Grob *me = unsmob_grob (smob); if (scm_is_number (me->get_property ("staff-position"))) return scm_make_real (0); Direction d = get_grob_direction (me); - Real off = 2 * d ; + Real off = 2 * d; if (off) off *= Staff_symbol_referencer::staff_space (me); @@ -187,6 +186,6 @@ Rest::polyphonic_offset_callback (SCM smob, SCM) } ADD_INTERFACE (Rest, "rest-interface", - "A rest symbol.", - "style direction minimum-distance"); + "A rest symbol.", + "style direction minimum-distance"); diff --git a/lily/rhythmic-column-engraver.cc b/lily/rhythmic-column-engraver.cc index f095ef8e1e..934e25b9dd 100644 --- a/lily/rhythmic-column-engraver.cc +++ b/lily/rhythmic-column-engraver.cc @@ -19,7 +19,7 @@ It also generates spacing objects. Originally, we have tried to have the spacing functionality at different levels. - + - by simply using the sequence of Separation-item as spacing-sequences (at staff level). Unfortunately, this fucks up if there are different kinds of tuplets in different voices (8th and @@ -35,20 +35,18 @@ spacing engraver don't know where to connect the last note of the voice on the right with), but we don't complain about those, and let the default spacing do its work. - - */ - +*/ class Rhythmic_column_engraver :public Engraver { Link_array rheads_; - Grob * stem_; - Grob * note_column_; - Grob * dotcol_; + Grob *stem_; + Grob *note_column_; + Grob *dotcol_; + + Grob *last_spacing_; + Grob *spacing_; - Grob * last_spacing_; - Grob * spacing_; - TRANSLATOR_DECLARATIONS (Rhythmic_column_engraver); protected: @@ -57,19 +55,16 @@ protected: virtual void stop_translation_timestep (); }; - - Rhythmic_column_engraver::Rhythmic_column_engraver () { - spacing_ = 0 ; + spacing_ = 0; last_spacing_ = 0; - + stem_ = 0; note_column_ = 0; dotcol_ = 0; } - void Rhythmic_column_engraver::process_acknowledged_grobs () { @@ -83,12 +78,10 @@ Rhythmic_column_engraver::process_acknowledged_grobs () spacing_->set_property ("left-items", scm_cons (note_column_->self_scm (), SCM_EOL)); - - if (last_spacing_) { Pointer_group_interface::add_grob (last_spacing_, - ly_symbol2scm ("right-items" ), + ly_symbol2scm ("right-items"), note_column_); } @@ -102,7 +95,6 @@ Rhythmic_column_engraver::process_acknowledged_grobs () rheads_.set_size (0); } - if (note_column_) { if (dotcol_ @@ -124,9 +116,9 @@ Rhythmic_column_engraver::process_acknowledged_grobs () void Rhythmic_column_engraver::acknowledge_grob (Grob_info i) { - Item * item = dynamic_cast (i.grob_); + Item *item = dynamic_cast (i.grob_); if (!item || item->get_parent (X_AXIS)) - return ; + return; if (Stem::has_interface (item)) { stem_ = item; @@ -144,24 +136,22 @@ Rhythmic_column_engraver::acknowledge_grob (Grob_info i) void Rhythmic_column_engraver::stop_translation_timestep () { - note_column_ = 0; + note_column_ = 0; if (spacing_) { last_spacing_ = spacing_; spacing_ = 0; } - + dotcol_ = 0; stem_ = 0; } - - ADD_TRANSLATOR (Rhythmic_column_engraver, -/* descr */ "Generates NoteColumn, an objects that groups stems, noteheads and rests.", -/* creats*/ "NoteColumn NoteSpacing", -/* accepts */ "", -/* acks */ "stem-interface rhythmic-head-interface dot-column-interface", -/* reads */ "", -/* write */ ""); + /* descr */ "Generates NoteColumn, an objects that groups stems, noteheads and rests.", + /* creats*/ "NoteColumn NoteSpacing", + /* accepts */ "", + /* acks */ "stem-interface rhythmic-head-interface dot-column-interface", + /* reads */ "", + /* write */ ""); diff --git a/lily/rhythmic-head.cc b/lily/rhythmic-head.cc index d9abe90010..7c177452cf 100644 --- a/lily/rhythmic-head.cc +++ b/lily/rhythmic-head.cc @@ -14,41 +14,41 @@ #include "staff-symbol-referencer.hh" #include "item.hh" -Item* -Rhythmic_head::get_dots (Grob*me) +Item * +Rhythmic_head::get_dots (Grob *me) { SCM s = me->get_property ("dot"); return unsmob_item (s); } -Item* -Rhythmic_head::get_stem (Grob*me) +Item * +Rhythmic_head::get_stem (Grob *me) { SCM s = me->get_property ("stem"); return unsmob_item (s); } int -Rhythmic_head::dot_count (Grob*me) +Rhythmic_head::dot_count (Grob *me) { return get_dots (me) ? scm_to_int (get_dots (me)->get_property ("dot-count")) : 0; } void -Rhythmic_head::set_dots (Grob*me, Item *dot) +Rhythmic_head::set_dots (Grob *me, Item *dot) { me->set_property ("dot", dot->self_scm ()); } int -Rhythmic_head::duration_log (Grob*me) +Rhythmic_head::duration_log (Grob *me) { SCM s = me->get_property ("duration-log"); return scm_is_number (s) ? scm_to_int (s) : 0; } ADD_INTERFACE (Rhythmic_head, "rhythmic-head-interface", - "Note head or rest", - "dot stem duration-log"); + "Note head or rest", + "dot stem duration-log"); diff --git a/lily/rod.cc b/lily/rod.cc index 889429a63e..268c5e737e 100644 --- a/lily/rod.cc +++ b/lily/rod.cc @@ -1,11 +1,10 @@ -/* +/* rod.cc -- implement Rod, Column_rod - + source file of the GNU LilyPond music typesetter - + (c) 1998--2005 Han-Wen Nienhuys - - */ +*/ #include "rod.hh" @@ -20,21 +19,21 @@ Rod::Rod () item_drul_[LEFT] = item_drul_[RIGHT] = 0; } - - void Rod::columnize () { if (!item_drul_[LEFT] || !item_drul_[RIGHT]) - return ; - + return; + Direction d = LEFT; - do { - Paper_column * pc = item_drul_[d]->get_column (); - distance_ += - d * item_drul_[d]->relative_coordinate (pc, X_AXIS); - item_drul_[d] = pc; - } while ((flip (&d))!= LEFT); + do + { + Paper_column *pc = item_drul_[d]->get_column (); + distance_ += -d * item_drul_[d]->relative_coordinate (pc, X_AXIS); + item_drul_[d] = pc; + } + while ((flip (&d))!= LEFT); } diff --git a/lily/scm-hash.cc b/lily/scm-hash.cc index 45845fc7e6..2e21757f4c 100644 --- a/lily/scm-hash.cc +++ b/lily/scm-hash.cc @@ -14,7 +14,7 @@ /* Return: number of objects. - */ +*/ int copy_scm_hashes (SCM dest, SCM src) { @@ -25,10 +25,9 @@ copy_scm_hashes (SCM dest, SCM src) scm_hashq_set_x (dest, scm_caar (s), scm_cdar (s)); k++; } - return k ; + return k; } - Scheme_hash_table::Scheme_hash_table () { hash_tab_ = SCM_EOL; @@ -37,7 +36,6 @@ Scheme_hash_table::Scheme_hash_table () elt_count_ = 0; } - Scheme_hash_table::Scheme_hash_table (Scheme_hash_table const &src) { @@ -45,12 +43,12 @@ Scheme_hash_table::Scheme_hash_table (Scheme_hash_table const &src) elt_count_ = 0; smobify_self (); - hash_tab_ = scm_make_vector (scm_int2num (src.elt_count_ >? 11 ), SCM_EOL); + hash_tab_ = scm_make_vector (scm_int2num (src.elt_count_ >? 11), SCM_EOL); elt_count_ = copy_scm_hashes (hash_tab_, src.hash_tab_); } void -Scheme_hash_table::operator = (Scheme_hash_table const & src) +Scheme_hash_table::operator= (Scheme_hash_table const &src) { if (&src == this) return; @@ -66,7 +64,7 @@ Scheme_hash_table::~Scheme_hash_table () SCM Scheme_hash_table::mark_smob (SCM s) { - Scheme_hash_table *me = (Scheme_hash_table*) SCM_CELL_WORD_1 (s); + Scheme_hash_table *me = (Scheme_hash_table *) SCM_CELL_WORD_1 (s); scm_gc_mark (me->hash_tab_); return SCM_EOL; } @@ -77,7 +75,7 @@ Scheme_hash_table::print_smob (SCM s, SCM p, scm_print_state*) assert (unsmob (s)); char str[1000]; sprintf (str, "#hash_tab_, p); scm_puts ("> ", p); return 1; @@ -117,7 +115,7 @@ Scheme_hash_table::set (SCM k, SCM v) */ if (elt_count_ > 2 * scm_c_vector_length (hash_tab_)) { - SCM nh = scm_make_vector (scm_int2num (3* elt_count_+1), SCM_EOL); + SCM nh = scm_make_vector (scm_int2num (3* elt_count_ + 1), SCM_EOL); elt_count_ = copy_scm_hashes (nh, hash_tab_); hash_tab_ = nh; } @@ -129,7 +127,7 @@ Scheme_hash_table::get (SCM k) const { /* 42 will stick out like a sore thumb, hopefully. - */ + */ return scm_hashq_ref (hash_tab_, k, scm_from_int (42)); } diff --git a/lily/scm-option.cc b/lily/scm-option.cc index 7ac4df60a7..d836451373 100644 --- a/lily/scm-option.cc +++ b/lily/scm-option.cc @@ -4,8 +4,7 @@ source file of the GNU LilyPond music typesetter (c) 2001--2005 Han-Wen Nienhuys - - */ +*/ #include "scm-option.hh" @@ -25,46 +24,42 @@ preferably, also dont use TESTING_LEVEL_GLOBAL, since it defeats another purpose of this very versatile interface, which is to support multiple debug/testing options concurrently. - - */ - +*/ /* Write midi as formatted ascii stream? */ bool midi_debug_global_b; int preview_resolution_global = 90; - /* General purpose testing flag */ int testing_level_global; /* Backwards compatibility. - */ +*/ bool lily_1_8_relative = false; bool lily_1_8_compatibility_used = false; /* crash if internally the wrong type is used for a grob property. - */ +*/ bool do_internal_type_checking_global; - /* - What is this function for ? - */ + What is this function for ? +*/ LY_DEFINE (ly_option_usage, "ly:option-usage", 0, 0, 0, (SCM), - "Print ly:set-option usage") + "Print ly:set-option usage") { - printf ( _("lilypond -e EXPR means:").to_str0 ()); + printf (_ ("lilypond -e EXPR means:").to_str0 ()); puts (""); printf (_ (" Evalute the Scheme EXPR before parsing any .ly files.").to_str0 ()); puts (""); printf (_ (" Multiple -e options may be given, they will be evaluated sequentially.").to_str0 ()); puts (""); - printf (_(" The function ly:set-option allows for access to some internal variables.").to_str0 ()); + printf (_ (" The function ly:set-option allows for access to some internal variables.").to_str0 ()); puts ("\n"); - printf (_ ("Usage: lilypond -e \"(ly:set-option SYMBOL VAL)\"").to_str0 ()); + printf (_ ("Usage: lilypond -e \"(ly:set - option SYMBOL VAL)\"").to_str0 ()); puts ("\n"); printf (_ ("Use help as SYMBOL to get online help.").to_str0 ()); @@ -79,31 +74,29 @@ don't timestamp the output @item -t, --test Switch on any experimental features. Not for general public use. - */ - LY_DEFINE (ly_set_option, "ly:set-option", 1, 1, 0, (SCM var, SCM val), - "Set a global option value. Supported options include\n" -"\n" -"@table @code\n" -"@item help\n" -"List all options.\n" -"@item midi-debug\n" -"If set to true, generate human readable MIDI\n" -"@item internal-type-checking\n" -"Set paranoia for property assignments\n" -"@item parse-protect\n" -"If protection is switched on, errors in inline scheme are caught in the parser. \n" -"If off, GUILE will halt on errors, and give a stack trace. Default is protected evaluation. \n" -"@item old-relative\n" -"Relative for simultaneous music functions similar to chord syntax\n" -"@item new-relative\n" -"Relative for simultaneous music functions similar to sequential music\n" -"@end table\n" -"\n" -"This function is useful to call from the command line: @code{lilypond -e\n" -"\"(ly:set-option 'midi-debug #t)\"}.\n") + "Set a global option value. Supported options include\n" + "\n" + "@table @code\n" + "@item help\n" + "List all options.\n" + "@item midi-debug\n" + "If set to true, generate human readable MIDI\n" + "@item internal-type-checking\n" + "Set paranoia for property assignments\n" + "@item parse-protect\n" + "If protection is switched on, errors in inline scheme are caught in the parser. \n" + "If off, GUILE will halt on errors, and give a stack trace. Default is protected evaluation. \n" + "@item old-relative\n" + "Relative for simultaneous music functions similar to chord syntax\n" + "@item new-relative\n" + "Relative for simultaneous music functions similar to sequential music\n" + "@end table\n" + "\n" + "This function is useful to call from the command line: @code{lilypond -e\n" + "\"(ly:set - option 'midi-debug #t)\"}.\n") { if (val == SCM_UNDEFINED) val = SCM_BOOL_T; @@ -115,7 +108,7 @@ LY_DEFINE (ly_set_option, "ly:set-option", 1, 1, 0, (SCM var, SCM val), midi_debug_global_b = to_boolean (val); else if (var == ly_symbol2scm ("testing-level")) testing_level_global = scm_to_int (val); - else if (var == ly_symbol2scm ("parse-protect" )) + else if (var == ly_symbol2scm ("parse-protect")) parse_protect_global = to_boolean (val); else if (var == ly_symbol2scm ("internal-type-checking")) do_internal_type_checking_global = to_boolean (val); @@ -133,14 +126,14 @@ LY_DEFINE (ly_set_option, "ly:set-option", 1, 1, 0, (SCM var, SCM val), { if (scm_is_symbol (var)) var = scm_symbol_to_string (var); - + warning (_f ("No such internal option: %s", ly_scm2string (var))); } return SCM_UNSPECIFIED; } LY_DEFINE (ly_get_option, "ly:get-option", 1, 0, 0, (SCM var), - "Get a global option setting. Supported options include\n" + "Get a global option setting. Supported options include\n" "@table @code\n" "@item old-relative-used\n" "Report whether old-relative compatibility mode is necessary\n" @@ -154,16 +147,16 @@ LY_DEFINE (ly_get_option, "ly:get-option", 1, 0, 0, (SCM var), "\n") { SCM o = SCM_UNSPECIFIED; - + if (var == ly_symbol2scm ("safe")) // heavily used; put in front. o = ly_bool2scm (be_safe_global); - else if (var == ly_symbol2scm ("old-relative-used")) + else if (var == ly_symbol2scm ("old-relative-used")) o = ly_bool2scm (lily_1_8_compatibility_used); else if (var == ly_symbol2scm ("old-relative")) o = ly_bool2scm (lily_1_8_relative); else if (var == ly_symbol2scm ("verbose")) o = ly_bool2scm (be_verbose_global); - else if ( var == ly_symbol2scm ("resolution")) + else if (var == ly_symbol2scm ("resolution")) o = scm_from_int (preview_resolution_global); else { @@ -171,8 +164,8 @@ LY_DEFINE (ly_get_option, "ly:get-option", 1, 0, 0, (SCM var), var = scm_symbol_to_string (var); String s = ly_scm2string (var); - - warning (_f ("No such internal option: %s", s.to_str0() )); + + warning (_f ("No such internal option: %s", s.to_str0 ())); } return o; } diff --git a/lily/score-context.cc b/lily/score-context.cc index 4b496db187..c89469d8f9 100644 --- a/lily/score-context.cc +++ b/lily/score-context.cc @@ -1,8 +1,8 @@ /* score-context.cc -- implement Score_context - + source file of the GNU LilyPond music typesetter - + (c) 2004--2005 Han-Wen Nienhuys */ @@ -13,8 +13,8 @@ void Score_context::prepare (Moment w) { - Translator* t = implementation (); - Score_translator * s = dynamic_cast (t); + Translator *t = implementation (); + Score_translator *s = dynamic_cast (t); s->prepare (w); } @@ -22,8 +22,8 @@ Score_context::prepare (Moment w) void Score_context::finish () { - Translator* t = implementation (); - Score_translator * s = dynamic_cast (t); + Translator *t = implementation (); + Score_translator *s = dynamic_cast (t); s->finish (); } @@ -31,12 +31,12 @@ Score_context::finish () void Score_context::one_time_step () { - Translator* t = implementation (); - Score_translator * s = dynamic_cast (t); + Translator *t = implementation (); + Score_translator *s = dynamic_cast (t); s->one_time_step (); } -Music_output* +Music_output * Score_context::get_output () { Translator *t = implementation (); @@ -44,7 +44,6 @@ Score_context::get_output () return s->get_output (); } - Score_context::Score_context (Object_key const *key) : Context (key) { diff --git a/lily/score-engraver.cc b/lily/score-engraver.cc index 19693e99f9..f7cba549b2 100644 --- a/lily/score-engraver.cc +++ b/lily/score-engraver.cc @@ -24,7 +24,7 @@ /* TODO: the column creation logic is rather hairy. Revise it. - */ +*/ Score_engraver::Score_engraver () { system_ = 0; @@ -39,25 +39,24 @@ Score_engraver::make_columns () { /* ugh. - */ + */ if (!command_column_) { SCM nmp = updated_grob_properties (context (), ly_symbol2scm ("NonMusicalPaperColumn")); - Object_key const *key1 = context()->get_grob_key ("NonMusicalPaperColumn"); - + Object_key const *key1 = context ()->get_grob_key ("NonMusicalPaperColumn"); + SCM pc = updated_grob_properties (context (), ly_symbol2scm ("PaperColumn")); - Object_key const *key2 = context()->get_grob_key ("PaperColumn"); + Object_key const *key2 = context ()->get_grob_key ("PaperColumn"); set_columns (new Paper_column (nmp, key1), new Paper_column (pc, key2)); - Grob_info i1; i1.grob_ = command_column_; i1.origin_trans_ = this; - + announce_grob (i1); Grob_info i2; @@ -73,7 +72,7 @@ Score_engraver::prepare (Moment m) { /* TODO: don't make columns when skipTypesetting is true. - */ + */ make_columns (); SCM w = m.smobbed_copy (); @@ -96,7 +95,7 @@ Score_engraver::finish () /* use start/finish? - */ +*/ void Score_engraver::initialize () { @@ -107,19 +106,19 @@ Score_engraver::initialize () + "\n" + _ ("Music font has not been installed properly.") + "\n" - + _f ("Search path `%s'", global_path.to_string ().to_str0()) + + _f ("Search path `%s'", global_path.to_string ().to_str0 ()) + "\n" - + _ ("Aborting")); + + _ ("Aborting")); } pscore_ = new Paper_score; - pscore_->layout_ = dynamic_cast (get_output_def ()); + pscore_->layout_ = dynamic_cast (get_output_def ()); SCM props = updated_grob_properties (context (), ly_symbol2scm ("System")); - Object_key const *sys_key = context()->get_grob_key ("System"); + Object_key const *sys_key = context ()->get_grob_key ("System"); pscore_->typeset_line (new System (props, sys_key)); - + system_ = pscore_->system_; make_columns (); system_->set_bound (LEFT, command_column_); @@ -128,30 +127,28 @@ Score_engraver::initialize () Engraver_group_engraver::initialize (); } - void Score_engraver::finalize () { Score_translator::finalize (); - Grob * cc + Grob *cc = unsmob_grob (get_property ("currentCommandColumn")); system_->set_bound (RIGHT, cc); cc->set_property ("breakable", SCM_BOOL_T); - + typeset_all (); } - void Score_engraver::one_time_step () { if (!to_boolean (get_property ("skipTypesetting"))) { recurse_over_translators (context (), &Engraver::process_music, UP); - Engraver_group_engraver::do_announces(); + Engraver_group_engraver::do_announces (); } - + recurse_over_translators (context (), &Translator::stop_translation_timestep, UP); } @@ -163,23 +160,19 @@ Score_engraver::announce_grob (Grob_info info) elems_.push (info.grob_); } - void Score_engraver::typeset_all () { - for (int i = 0; i < elems_.size (); i++) + for (int i = 0; i < elems_.size (); i++) { - Grob * elem = elems_[i]; + Grob *elem = elems_[i]; - - if (dynamic_cast (elem)) + if (dynamic_cast (elem)) { - if ( - (!elem->get_parent (X_AXIS) - || !unsmob_grob (elem->get_property ("axis-group-parent-X"))) + if ((!elem->get_parent (X_AXIS) + || !unsmob_grob (elem->get_property ("axis-group-parent-X"))) && elem != command_column_ - && elem != musical_column_ - ) + && elem != musical_column_) { bool br = to_boolean (elem->get_property ("breakable")); Axis_group_interface::add_element (br ? command_column_ : musical_column_, elem); @@ -197,22 +190,21 @@ Score_engraver::stop_translation_timestep () { // this generates all items. Engraver_group_engraver::stop_translation_timestep (); - + typeset_all (); if (to_boolean (command_column_->get_property ("breakable"))) { - breaks_ ++; + breaks_++; if (! (breaks_%8)) progress_indication ("[" + to_string (breaks_) + "]"); } - command_column_ = 0; musical_column_ = 0; } void -Score_engraver::set_columns (Paper_column *new_command, +Score_engraver::set_columns (Paper_column *new_command, Paper_column *new_musical) { assert (!command_column_ && !musical_column_); @@ -221,9 +213,9 @@ Score_engraver::set_columns (Paper_column *new_command, musical_column_ = new_musical; if (new_command) { - context ()->set_property ("currentCommandColumn", new_command->self_scm ()); + context ()->set_property ("currentCommandColumn", new_command->self_scm ()); } - + if (new_musical) { context ()->set_property ("currentMusicalColumn", new_musical->self_scm ()); @@ -233,11 +225,11 @@ Score_engraver::set_columns (Paper_column *new_command, system_->add_column (musical_column_); } -Music_output* +Music_output * Score_engraver::get_output () { Music_output *o = pscore_; - ///FIXME WTF? pscore_ = 0; + ///FIXME WTF? pscore_ = 0; return o; } @@ -267,7 +259,7 @@ Score_engraver::try_music (Music *m) SCM mpage_pen = m->get_property ("page-penalty"); if (scm_is_number (mpage_pen)) total_pp += scm_to_double (mpage_pen); - + command_column_->set_property ("page-penalty", scm_make_real (total_pp)); return true; } @@ -280,7 +272,7 @@ Score_engraver::forbid_breaks () if (command_column_) command_column_->set_property ("breakable", SCM_EOL); } - + void Score_engraver::acknowledge_grob (Grob_info gi) { @@ -302,8 +294,8 @@ Score_engraver::acknowledge_grob (Grob_info gi) { SCM spaceable = get_property ("verticallySpacedContexts"); Context *orig = gi.origin_contexts (this)[0]; - - if (scm_memq (ly_symbol2scm (orig->context_name ().to_str0()), + + if (scm_memq (ly_symbol2scm (orig->context_name ().to_str0 ()), spaceable) != SCM_BOOL_F) { Pointer_group_interface::add_grob (system_, @@ -311,23 +303,20 @@ Score_engraver::acknowledge_grob (Grob_info gi) gi.grob_); } } - -} - +} ADD_TRANSLATOR (Score_engraver, -/* descr */ "Top level engraver. Takes care of generating columns and the complete system (ie. System) " -"\n\n " -"This engraver decides whether a column is breakable. The default is " -"that a column is always breakable. However, when every Bar_engraver " -"that does not have a barline at a certain point will call " -"Score_engraver::forbid_breaks to stop linebreaks. In practice, this " -"means that you can make a breakpoint by creating a barline (assuming " -"that there are no beams or notes that prevent a breakpoint.) " -, -/* creats*/ "System PaperColumn NonMusicalPaperColumn", -/* accepts */ "break-event", -/* acks */ "note-spacing-interface staff-spacing-interface axis-group-interface", -/* reads */ "currentMusicalColumn currentCommandColumn verticallySpacedContexts", -/* write */ ""); + /* descr */ "Top level engraver. Takes care of generating columns and the complete system (ie. System) " + "\n\n " + "This engraver decides whether a column is breakable. The default is " + "that a column is always breakable. However, when every Bar_engraver " + "that does not have a barline at a certain point will call " + "Score_engraver::forbid_breaks to stop linebreaks. In practice, this " + "means that you can make a breakpoint by creating a barline (assuming " + "that there are no beams or notes that prevent a breakpoint.) ", + /* creats*/ "System PaperColumn NonMusicalPaperColumn", + /* accepts */ "break-event", + /* acks */ "note-spacing-interface staff-spacing-interface axis-group-interface", + /* reads */ "currentMusicalColumn currentCommandColumn verticallySpacedContexts", + /* write */ ""); diff --git a/lily/score-performer.cc b/lily/score-performer.cc index b127d32bdf..31f9ecdade 100644 --- a/lily/score-performer.cc +++ b/lily/score-performer.cc @@ -4,7 +4,7 @@ source file of the GNU LilyPond music typesetter (c) 1996--2005 Jan Nieuwenhuizen - */ +*/ #include "score-performer.hh" @@ -18,28 +18,26 @@ #include "output-def.hh" ADD_TRANSLATOR (Score_performer, -/* descr */ "", -/* creats*/ "", -/* accepts */ "", -/* acks */ "", -/* reads */ "", -/* write */ ""); - + /* descr */ "", + /* creats*/ "", + /* accepts */ "", + /* acks */ "", + /* reads */ "", + /* write */ ""); Score_performer::Score_performer () { performance_ = 0; } - Score_performer::~Score_performer () { } void -Score_performer::play_element (Audio_element * p) +Score_performer::play_element (Audio_element *p) { - if (Audio_item * i = dynamic_cast (p)) + if (Audio_item *i = dynamic_cast (p)) { audio_column_->add_audio_item (i); } @@ -52,7 +50,7 @@ Score_performer::announce_element (Audio_element_info info) announce_infos_.push (info); } -void +void Score_performer::prepare (Moment m) { audio_column_ = new Audio_column (m); @@ -65,8 +63,8 @@ Score_performer::finish () { recurse_over_translators (context (), &Translator::finalize, UP); } - -void + +void Score_performer::one_time_step () { recurse_over_translators (context (), &Performer::process_music, UP); @@ -80,11 +78,10 @@ Score_performer::get_tempo () const return ::get_tempo (performance_->midi_, Moment (Rational (1, 4))); } - Music_output * Score_performer::get_output () { - Music_output * o = performance_; + Music_output *o = performance_; performance_ = 0; return o; } diff --git a/lily/score-scheme.cc b/lily/score-scheme.cc index d8470132c1..3c7f5c9a27 100644 --- a/lily/score-scheme.cc +++ b/lily/score-scheme.cc @@ -4,10 +4,8 @@ source file of the GNU LilyPond music typesetter (c) 2005 Han-Wen Nienhuys - */ - #include "score.hh" #include "music.hh" #include "output-def.hh" @@ -32,19 +30,18 @@ LY_DEFINE (ly_score_embedded_format, "ly:score-embedded-format", "Run @var{score} through @var{layout}, an output definition, " "scaled to correct outputscale already, " "return a list of layout-lines. " - "\nTake optional Object_key argument." - ) + "\nTake optional Object_key argument.") { - Score * sc = unsmob_score (score); + Score *sc = unsmob_score (score); Output_def *od = unsmob_output_def (layout); if (sc->error_found_) return SCM_EOL; - + SCM_ASSERT_TYPE (sc, score, SCM_ARG1, __FUNCTION__, "Score"); SCM_ASSERT_TYPE (od, layout, SCM_ARG2, __FUNCTION__, "Output_def"); - Output_def * score_def = 0; + Output_def *score_def = 0; /* UGR, FIXME, these are default \layout blocks once again. They suck. */ @@ -54,7 +51,7 @@ LY_DEFINE (ly_score_embedded_format, "ly:score-embedded-format", if (!score_def) return scm_c_make_vector (0, SCM_EOL); - + score_def = score_def->clone (); SCM prot = score_def->self_scm (); scm_gc_unprotect_object (prot); @@ -62,11 +59,11 @@ LY_DEFINE (ly_score_embedded_format, "ly:score-embedded-format", /* TODO: SCORE_DEF should be scaled according to OD->parent_ or OD itself. */ score_def->parent_ = od; - + SCM context = ly_run_translator (sc->get_music (), score_def->self_scm (), key); SCM lines = ly_format_output (context, scm_makfrom0str ("")); - + scm_remember_upto_here_1 (prot); return lines; } diff --git a/lily/score-translator.cc b/lily/score-translator.cc index 64272aeeb4..ceb980d3fb 100644 --- a/lily/score-translator.cc +++ b/lily/score-translator.cc @@ -1,10 +1,10 @@ -/* +/* score-translator.cc -- implement Score_translator source file of the GNU LilyPond music typesetter (c) 2004--2005 Han-Wen Nienhuys - */ +*/ #include "score-translator.hh" #include "moment.hh" @@ -14,7 +14,7 @@ Score_translator::prepare (Moment) { } -Music_output* +Music_output * Score_translator::get_output () { return 0; diff --git a/lily/score.cc b/lily/score.cc index f8747dd660..e0cb8469a7 100644 --- a/lily/score.cc +++ b/lily/score.cc @@ -47,7 +47,7 @@ IMPLEMENT_TYPE_P (Score, "ly:score?"); SCM Score::mark_smob (SCM s) { - Score *sc = (Score*) SCM_CELL_WORD_1 (s); + Score *sc = (Score *) SCM_CELL_WORD_1 (s); scm_gc_mark (sc->header_); scm_gc_mark (sc->texts_); @@ -57,7 +57,7 @@ Score::mark_smob (SCM s) } int -Score::print_smob (SCM , SCM p, scm_print_state*) +Score::print_smob (SCM, SCM p, scm_print_state*) { scm_puts ("#", p); @@ -76,7 +76,7 @@ Score::Score (Score const &s) Music *m = unsmob_music (s.music_); music_ = m ? m->clone ()->self_scm () : SCM_EOL; scm_gc_unprotect_object (music_); - + for (int i = 0, n = s.defs_.size (); i < n; i++) defs_.push (s.defs_[i]->clone ()); @@ -87,7 +87,6 @@ Score::Score (Score const &s) texts_ = s.texts_; } - void default_rendering (SCM music, SCM outdef, SCM book_outputdef, @@ -97,27 +96,27 @@ default_rendering (SCM music, SCM outdef, { SCM scaled_def = outdef; SCM scaled_bookdef = book_outputdef; - + Output_def *bpd = unsmob_output_def (book_outputdef); /* ugh. */ if (bpd->c_variable ("is-paper") == SCM_BOOL_T) { Real scale = scm_to_double (bpd->c_variable ("outputscale")); - + Output_def *def = scale_output_def (unsmob_output_def (outdef), scale); scaled_def = def->self_scm (); scaled_bookdef = scale_output_def (bpd, scale)->self_scm (); unsmob_output_def (scaled_def)->parent_ = unsmob_output_def (scaled_bookdef); - + scm_gc_unprotect_object (scaled_bookdef); scm_gc_unprotect_object (scaled_def); } - + SCM context = ly_run_translator (music, scaled_def, key); - if (Global_context *g = dynamic_cast + if (Global_context *g = dynamic_cast (unsmob_context (context))) { SCM systems = ly_format_output (context, outname); @@ -144,11 +143,10 @@ default_rendering (SCM music, SCM outdef, } /* -Format score, return systems. OUTNAME is still passed to create a midi -file. - -LAYOUTBOOK should be scaled already. + Format score, return systems. OUTNAME is still passed to create a midi + file. + LAYOUTBOOK should be scaled already. */ SCM Score::book_rendering (String outname, @@ -158,21 +156,21 @@ Score::book_rendering (String outname, { if (error_found_) return SCM_EOL; - + SCM scaled_bookdef = SCM_EOL; Real scale = 1.0; if (layoutbook && layoutbook->c_variable ("is-paper") == SCM_BOOL_T) scale = scm_to_double (layoutbook->c_variable ("outputscale")); - + SCM out = scm_makfrom0str (outname.to_str0 ()); SCM systems = SCM_EOL; int outdef_count = defs_.size (); - Object_key * key = new Lilypond_general_key (book_key, user_key_, 0); - SCM scm_key = key->self_scm(); + Object_key *key = new Lilypond_general_key (book_key, user_key_, 0); + SCM scm_key = key->self_scm (); scm_gc_unprotect_object (scm_key); - + for (int i = 0; !i || i < outdef_count; i++) { Output_def *def = outdef_count ? defs_[i] : default_def; @@ -187,7 +185,7 @@ Score::book_rendering (String outname, /* TODO: fix or junk --no-layout. */ SCM context = ly_run_translator (music_, def->self_scm (), scm_key); - if (dynamic_cast (unsmob_context (context))) + if (dynamic_cast (unsmob_context (context))) { SCM s = ly_format_output (context, out); if (s != SCM_UNDEFINED) @@ -203,9 +201,6 @@ Score::book_rendering (String outname, } - - - void Score::set_music (SCM music, SCM parser) { @@ -216,20 +211,20 @@ Score::set_music (SCM music, SCM parser) if (unsmob_music (music_)) { - unsmob_music (music)->origin ()->error (_("Already have music in score")); - unsmob_music (music_)->origin ()->error (_("This is the previous music")); + unsmob_music (music)->origin ()->error (_ ("Already have music in score")); + unsmob_music (music_)->origin ()->error (_ ("This is the previous music")); } - Music * m = unsmob_music (music); + Music *m = unsmob_music (music); if (m && to_boolean (m->get_property ("error-found"))) { - m->origin()->error (_("Error found in this music expression. Ignoring it")); - + m->origin ()->error (_ ("Error found in this music expression. Ignoring it")); + this->error_found_ = this->error_found_ || to_boolean (m->get_property ("error-found")); - + } if (this->error_found_) - this->music_ = SCM_EOL; + this->music_ = SCM_EOL; else this->music_ = music; diff --git a/lily/script-column-engraver.cc b/lily/script-column-engraver.cc index 4cb6174439..5395e4c3b4 100644 --- a/lily/script-column-engraver.cc +++ b/lily/script-column-engraver.cc @@ -1,11 +1,10 @@ -/* +/* script-column-engraver.cc -- implement Script_column_engraver - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - - */ +*/ #include "engraver.hh" #include "script-column.hh" @@ -27,7 +26,6 @@ protected: virtual void stop_translation_timestep (); }; - Script_column_engraver::Script_column_engraver () { scol_ = 0; @@ -41,9 +39,9 @@ Script_column_engraver::stop_translation_timestep () } void -Script_column_engraver::acknowledge_grob (Grob_info inf) +Script_column_engraver::acknowledge_grob (Grob_info inf) { - Item *thing = dynamic_cast (inf.grob_); + Item *thing = dynamic_cast (inf.grob_); if (thing && Side_position_interface::has_interface (inf.grob_)) // ugh FIXME { if (!Item::is_breakable (thing) @@ -60,7 +58,7 @@ Script_column_engraver::process_acknowledged_grobs () if (!scol_ && scripts_.size () > 1) { scol_ = make_item ("ScriptColumn", SCM_EOL); - + } if (scol_) @@ -73,9 +71,9 @@ Script_column_engraver::process_acknowledged_grobs () } ADD_TRANSLATOR (Script_column_engraver, -/* descr */ "", -/* creats*/ "ScriptColumn", -/* accepts */ "", -/* acks */ "side-position-interface", -/* reads */ "", -/* write */ ""); + /* descr */ "", + /* creats*/ "ScriptColumn", + /* accepts */ "", + /* acks */ "side-position-interface", + /* reads */ "", + /* write */ ""); diff --git a/lily/script-column.cc b/lily/script-column.cc index b199527740..37051bd6a4 100644 --- a/lily/script-column.cc +++ b/lily/script-column.cc @@ -1,11 +1,10 @@ -/* +/* script-column.cc -- implement Script_column - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - - */ +*/ #include "script-column.hh" @@ -20,14 +19,14 @@ Script_column::add_staff_sided (Grob *me, Item *i) if (!scm_is_number (p)) return; - Pointer_group_interface::add_grob (me, ly_symbol2scm ("scripts"),i); - + Pointer_group_interface::add_grob (me, ly_symbol2scm ("scripts"), i); + me->add_dependency (i); } LY_DEFINE (ly_grob_script_priority_less, "ly:grob-script-priority-less", - 2, 0, 0, (SCM a, SCM b), - "Compare two grobs by script priority. For internal use.") + 2, 0, 0, (SCM a, SCM b), + "Compare two grobs by script priority. For internal use.") { Grob *i1 = unsmob_grob (a); Grob *i2 = unsmob_grob (b); @@ -42,33 +41,33 @@ MAKE_SCHEME_CALLBACK (Script_column, before_line_breaking, 1); SCM Script_column::before_line_breaking (SCM smob) { - Grob* me = unsmob_grob (smob); + Grob *me = unsmob_grob (smob); Drul_array scripts (SCM_EOL, SCM_EOL); Link_array staff_sided; - + for (SCM s = me->get_property ("scripts"); scm_is_pair (s); s = scm_cdr (s)) { Grob *sc = unsmob_grob (scm_car (s)); /* Don't want to consider scripts horizontally next to notes. - */ + */ if (!sc->has_offset_callback (Side_position_interface::aligned_side_proc, X_AXIS)) staff_sided.push (sc); } - + for (int i = 0; i < staff_sided.size (); i++) { - Grob* g = staff_sided[i]; + Grob *g = staff_sided[i]; Direction d = Side_position_interface::get_direction (g); if (!d) { - programming_error ( "No direction for script?"); + programming_error ("No direction for script?"); d = DOWN; g->set_property ("direction", scm_int2num (d)); } - + scripts[d] = scm_cons (g->self_scm (), scripts[d]); } @@ -77,23 +76,24 @@ Script_column::before_line_breaking (SCM smob) { SCM ss = scm_reverse_x (scripts[d], SCM_EOL); ss = scm_stable_sort_x (ss, ly_grob_script_priority_less_proc); - - Grob * last = 0; + + Grob *last = 0; for (SCM s = ss; scm_is_pair (s); s = scm_cdr (s)) { Grob *g = unsmob_grob (scm_car (s)); if (last) - Side_position_interface::add_support (g,last); - + Side_position_interface::add_support (g, last); + last = g; } - - } while (flip (&d) != DOWN); + + } + while (flip (&d) != DOWN); return SCM_UNSPECIFIED; } -ADD_INTERFACE (Script_column,"script-column-interface", +ADD_INTERFACE (Script_column, "script-column-interface", "An interface that sorts scripts " "according to their @code{script-priority}", ""); diff --git a/lily/script-engraver.cc b/lily/script-engraver.cc index 1afa849ebd..f393128911 100644 --- a/lily/script-engraver.cc +++ b/lily/script-engraver.cc @@ -38,7 +38,7 @@ class Script_engraver : public Engraver Spanner *slur_; protected: - virtual bool try_music (Music*); + virtual bool try_music (Music *); virtual void stop_translation_timestep (); virtual void process_music (); virtual void acknowledge_grob (Grob_info); @@ -87,9 +87,8 @@ copy_property (Grob *g, SCM sym, SCM alist) /* Add the properties, one by one for each Script. A little memory could be saved by tacking the props onto the Script grob (i.e. make ScriptStaccato , ScriptMarcato, etc. ). - */ -void make_script_from_event (Grob *p, bool * follow, Context *tg, +void make_script_from_event (Grob *p, bool *follow, Context *tg, SCM art_type, int index) { SCM alist = tg->get_property ("scriptDefinitions"); @@ -110,15 +109,15 @@ void make_script_from_event (Grob *p, bool * follow, Context *tg, art); *follow = scm_is_pair (follow_scm) && to_boolean (scm_cdr (follow_scm)); - bool priority_found = false ; - - for (SCM s = art ; scm_is_pair (s); s = scm_cdr (s)) + bool priority_found = false; + + for (SCM s = art; scm_is_pair (s); s = scm_cdr (s)) { SCM sym = scm_caar (s); SCM type = scm_object_property (sym, ly_symbol2scm ("backend-type?")); if (!ly_c_procedure_p (type)) continue; - + SCM val = scm_cdar (s); if (sym == ly_symbol2scm ("script-priority")) @@ -127,9 +126,8 @@ void make_script_from_event (Grob *p, bool * follow, Context *tg, /* Make sure they're in order of user input by adding index i. Don't use the direction in this priority. Smaller means closer to the head. */ - int prio = scm_to_int (val) + index; - - + int prio = scm_to_int (val) + index; + val = scm_int2num (prio); } if (p->internal_get_property (sym) == SCM_EOL) @@ -141,7 +139,7 @@ void make_script_from_event (Grob *p, bool * follow, Context *tg, p->set_property ("script-priority", scm_int2num (index)); } - + Side_position_interface::set_axis (p, Y_AXIS); } @@ -192,7 +190,7 @@ Script_engraver::acknowledge_grob (Grob_info info) for (int i = 0; i < script_count; i++) { Grob *e = scripts_[i].script_; - + if (Side_position_interface::get_axis (e) == X_AXIS && !e->get_parent (Y_AXIS)) { @@ -205,11 +203,11 @@ Script_engraver::acknowledge_grob (Grob_info info) else if (Note_column::has_interface (info.grob_)) { /* Make note column the parent of the script. That is not - correct, but due to seconds in a chord, noteheads may be - swapped around horizontally. + correct, but due to seconds in a chord, noteheads may be + swapped around horizontally. - As the note head to put it on is not known now, postpone this - decision to Script_interface::before_line_breaking (). */ + As the note head to put it on is not known now, postpone this + decision to Script_interface::before_line_breaking (). */ for (int i = 0; i < script_count; i++) { Grob *e = scripts_[i].script_; @@ -220,7 +218,7 @@ Script_engraver::acknowledge_grob (Grob_info info) } } else if (Slur::has_interface (info.grob_)) - slur_ = dynamic_cast (info.grob_); + slur_ = dynamic_cast (info.grob_); } void @@ -235,15 +233,15 @@ Script_engraver::stop_translation_timestep () ::quantised_position_proc, Y_AXIS); sc->set_property ("staff-padding", SCM_EOL); } - + scripts_.clear (); } ADD_TRANSLATOR (Script_engraver, -/* descr */ "Handles note scripted articulations.", -/* creats*/ "Script", -/* accepts */ "script-event articulation-event", -/* acks */ "stem-interface rhythmic-head-interface " - "slur-interface note-column-interface", -/* reads */ "scriptDefinitions", -/* write */ ""); + /* descr */ "Handles note scripted articulations.", + /* creats*/ "Script", + /* accepts */ "script-event articulation-event", + /* acks */ "stem-interface rhythmic-head-interface " + "slur-interface note-column-interface", + /* reads */ "scriptDefinitions", + /* write */ ""); diff --git a/lily/script-interface.cc b/lily/script-interface.cc index fd42a76b18..f2dcbea2c8 100644 --- a/lily/script-interface.cc +++ b/lily/script-interface.cc @@ -1,11 +1,10 @@ -/* +/* script-interface.cc -- implement Script_interface - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - - */ +*/ #include "directional-element-interface.hh" #include "warn.hh" @@ -85,18 +84,17 @@ Script_interface::print (SCM smob) struct Text_script { - static bool has_interface (Grob*); + static bool has_interface (Grob *); }; ADD_INTERFACE (Text_script, "text-script-interface", - "An object that is put above or below a note", - "add-stem-support slur script-priority inside-slur"); - + "An object that is put above or below a note", + "add-stem-support slur script-priority inside-slur"); /* Hmm. Where should we put add-stem-support ? - */ +*/ ADD_INTERFACE (Script_interface, "script-interface", - "An object that is put above or below a note", - "add-stem-support slur-padding slur script-priority script-stencil inside-slur"); + "An object that is put above or below a note", + "add-stem-support slur-padding slur script-priority script-stencil inside-slur"); diff --git a/lily/self-aligment-interface.cc b/lily/self-aligment-interface.cc index b4d4c77b15..de672c36f7 100644 --- a/lily/self-aligment-interface.cc +++ b/lily/self-aligment-interface.cc @@ -1,8 +1,8 @@ /* self-alignment-interface.cc - + source file of the GNU LilyPond music typesetter - + (c) 2004--2005 Han-Wen Nienhuys */ @@ -19,8 +19,8 @@ Self_alignment_interface::centered_on_parent (SCM element_smob, SCM axis) Axis a = (Axis) scm_to_int (axis); Grob *him = me->get_parent (a); Interval he = him->extent (him, a); - - return scm_make_real (he.is_empty () ? 0.0 : he.center ()); + + return scm_make_real (he.is_empty () ? 0.0 : he.center ()); } MAKE_SCHEME_CALLBACK (Self_alignment_interface, aligned_on_parent, 2); @@ -31,7 +31,7 @@ Self_alignment_interface::aligned_on_parent (SCM element_smob, SCM axis) Axis a = (Axis) scm_to_int (axis); Grob *him = me->get_parent (a); Interval he = him->extent (him, a); - + SCM sym = (a == X_AXIS) ? ly_symbol2scm ("self-alignment-X") : ly_symbol2scm ("self-alignment-Y"); SCM align_prop (me->internal_get_property (sym)); @@ -41,12 +41,12 @@ Self_alignment_interface::aligned_on_parent (SCM element_smob, SCM axis) Real x = 0.0; Real align = scm_to_double (align_prop); - + Interval ext (me->extent (me, a)); if (ext.is_empty ()) programming_error ("I'm empty. Can't align on self"); else - x -= ext.linear_combination (align) ; + x -= ext.linear_combination (align); if (!he.is_empty ()) x += he.linear_combination (align); @@ -57,15 +57,15 @@ Self_alignment_interface::aligned_on_parent (SCM element_smob, SCM axis) /* Position centered on parent. */ MAKE_SCHEME_CALLBACK (Self_alignment_interface, centered_on_other_axis_parent, 2); SCM -Self_alignment_interface::centered_on_other_axis_parent (SCM element_smob, +Self_alignment_interface::centered_on_other_axis_parent (SCM element_smob, SCM axis) { Grob *me = unsmob_grob (element_smob); Axis a = (Axis) scm_to_int (axis); Grob *him = me->get_parent (other_axis (a)); Interval he = him->extent (him, a); - - return scm_make_real (he.is_empty () ? 0.0 : he.center ()); + + return scm_make_real (he.is_empty () ? 0.0 : he.center ()); } /** callback that centers the element on itself @@ -79,7 +79,7 @@ Self_alignment_interface::aligned_on_self (SCM element_smob, SCM axis) SCM sym = (a == X_AXIS) ? ly_symbol2scm ("self-alignment-X") : ly_symbol2scm ("self-alignment-Y"); - + SCM align (me->internal_get_property (sym)); if (scm_is_number (align)) { @@ -92,7 +92,6 @@ Self_alignment_interface::aligned_on_self (SCM element_smob, SCM axis) return scm_make_real (0.0); } - ADD_INTERFACE (Self_alignment_interface, "self-alignment-interface", "Position this object on itself and/or on its parent. To this end, the following functions " " are provided: \n" @@ -106,6 +105,6 @@ ADD_INTERFACE (Self_alignment_interface, "self-alignment-interface", " extent of the parent \n" "@item Self_alignment_interface::centered_on_other_axis_parent\n" " For X-axis, center on the Y-parent, and vice versa.\n " - "@end table\n", + "@end table\n", "self-alignment-X self-alignment-Y"); diff --git a/lily/separating-group-spanner.cc b/lily/separating-group-spanner.cc index 7481ee0684..8192ea7bcc 100644 --- a/lily/separating-group-spanner.cc +++ b/lily/separating-group-spanner.cc @@ -1,11 +1,10 @@ -/* +/* separating-group-spanner.cc -- implement Separating_group_spanner - + source file of the GNU LilyPond music typesetter - + (c) 1998--2005 Han-Wen Nienhuys - - */ +*/ #include "separating-group-spanner.hh" @@ -16,7 +15,7 @@ #include "group-interface.hh" void -Separating_group_spanner::find_rods (Item * r, SCM next, Real padding) +Separating_group_spanner::find_rods (Item *r, SCM next, Real padding) { /* @@ -26,12 +25,11 @@ Separating_group_spanner::find_rods (Item * r, SCM next, Real padding) NEXT, making it linear in most of the cases. */ if (Separation_item::width (r).is_empty ()) - return; - + return; for (; scm_is_pair (next); next = scm_cdr (next)) { - Item *l = dynamic_cast (unsmob_grob (scm_car ( next))); + Item *l = dynamic_cast (unsmob_grob (scm_car (next))); Item *lb = l->find_prebroken_piece (RIGHT); if (lb) @@ -60,7 +58,7 @@ Separating_group_spanner::find_rods (Item * r, SCM next, Real padding) rod.item_drul_[RIGHT]= r; rod.distance_ = li[RIGHT] - ri[LEFT] + padding; - + rod.add_to_cols (); break; } @@ -77,18 +75,18 @@ MAKE_SCHEME_CALLBACK (Separating_group_spanner, set_spacing_rods, 1); SCM Separating_group_spanner::set_spacing_rods (SCM smob) { - Grob*me = unsmob_grob (smob); + Grob *me = unsmob_grob (smob); /* Ugh: padding is added doubly, also for SeparationItem - */ + */ Real padding = robust_scm2double (me->get_property ("padding"), 0.1); - + for (SCM s = me->get_property ("elements"); scm_is_pair (s) && scm_is_pair (scm_cdr (s)); s = scm_cdr (s)) { /* Order of elements is reversed! - */ + */ SCM elt = scm_car (s); Item *r = unsmob_item (elt); @@ -96,27 +94,24 @@ Separating_group_spanner::set_spacing_rods (SCM smob) continue; Item *rb - = dynamic_cast (r->find_prebroken_piece (LEFT)); - + = dynamic_cast (r->find_prebroken_piece (LEFT)); + find_rods (r, scm_cdr (s), padding); if (rb) find_rods (rb, scm_cdr (s), padding); } - return SCM_UNSPECIFIED ; + return SCM_UNSPECIFIED; } void -Separating_group_spanner::add_spacing_unit (Grob* me , Item*i) +Separating_group_spanner::add_spacing_unit (Grob *me, Item *i) { Pointer_group_interface::add_grob (me, ly_symbol2scm ("elements"), i); me->add_dependency (i); } - - - ADD_INTERFACE (Separating_group_spanner, "separation-spanner-interface", "A spanner that calculates spacing constraints (\"rods\") " "using the @code{separation-item-interface} grobs in @code{elements}.", diff --git a/lily/separating-line-group-engraver.cc b/lily/separating-line-group-engraver.cc index 7690c8812d..9d95c17f39 100644 --- a/lily/separating-line-group-engraver.cc +++ b/lily/separating-line-group-engraver.cc @@ -1,11 +1,10 @@ -/* -' separating-line-group-engraver.cc -- implement Separating_line_group_engraver - +/* + ' separating-line-group-engraver.cc -- implement Separating_line_group_engraver + source file of the GNU LilyPond music typesetter - + (c) 1998--2005 Han-Wen Nienhuys - - */ +*/ #include "separating-group-spanner.hh" #include "separation-item.hh" @@ -19,7 +18,7 @@ struct Spacings { - Item * staff_spacing_; + Item *staff_spacing_; Link_array note_spacings_; Spacings () @@ -29,32 +28,32 @@ struct Spacings bool is_empty () const { - return !staff_spacing_ && !note_spacings_.size (); + return !staff_spacing_ && !note_spacings_.size (); } - void clear () { + void clear () + { staff_spacing_ = 0; note_spacings_.clear (); } }; - class Separating_line_group_engraver : public Engraver { protected: - Item * break_item_; - Item * musical_item_; - Item * last_musical_item_; + Item *break_item_; + Item *musical_item_; + Item *last_musical_item_; Spacings current_spacings_; Spacings last_spacings_; - - Spanner * sep_span_; - + + Spanner *sep_span_; + virtual void acknowledge_grob (Grob_info); virtual void process_music (); virtual void finalize (); virtual void stop_translation_timestep (); - virtual void start_translation_timestep (); + virtual void start_translation_timestep (); public: TRANSLATOR_DECLARATIONS (Separating_line_group_engraver); }; @@ -74,7 +73,6 @@ Separating_line_group_engraver::process_music () { sep_span_ = make_spanner ("SeparatingGroupSpanner", SCM_EOL); - sep_span_->set_bound (LEFT, unsmob_grob (get_property ("currentCommandColumn"))); } } @@ -82,23 +80,23 @@ void Separating_line_group_engraver::finalize () { if (!sep_span_) - return ; - + return; + SCM ccol = get_property ("currentCommandColumn"); Grob *column = unsmob_grob (ccol); - + sep_span_->set_bound (RIGHT, unsmob_grob (ccol)); sep_span_ = 0; - for (int i = 0 ; i < last_spacings_.note_spacings_.size (); i++) + for (int i = 0; i < last_spacings_.note_spacings_.size (); i++) { Pointer_group_interface::add_grob (last_spacings_.note_spacings_[i], - ly_symbol2scm ("right-items" ), + ly_symbol2scm ("right-items"), column); } - + if (last_spacings_.staff_spacing_ - && last_spacings_.staff_spacing_->get_column () == column) + && last_spacings_.staff_spacing_->get_column () == column) { last_spacings_.staff_spacing_->suicide (); } @@ -107,7 +105,7 @@ Separating_line_group_engraver::finalize () void Separating_line_group_engraver::acknowledge_grob (Grob_info i) { - Item * it = dynamic_cast (i.grob_); + Item *it = dynamic_cast (i.grob_); if (!it) return; if (it->get_parent (X_AXIS) @@ -115,16 +113,15 @@ Separating_line_group_engraver::acknowledge_grob (Grob_info i) ->has_extent_callback (Axis_group_interface::group_extent_callback_proc, X_AXIS)) return; - if (to_boolean (it->get_property ("no-spacing-rods"))) - return ; + return; - if (Note_spacing::has_interface (it)) + if (Note_spacing::has_interface (it)) { current_spacings_.note_spacings_.push (it); - return ; + return; } - + bool ib = Item::is_breakable (it); Item *&p_ref_ (ib ? break_item_ : musical_item_); @@ -138,16 +135,13 @@ Separating_line_group_engraver::acknowledge_grob (Grob_info i) p_ref_->set_property ("breakable", SCM_BOOL_T); context ()->set_property ("breakableSeparationItem", p_ref_->self_scm ()); } - if (to_boolean (get_property ("createSpacing")) && p_ref_ == break_item_) { - Item *it = make_item ("StaffSpacing", SCM_EOL); + Item *it = make_item ("StaffSpacing", SCM_EOL); current_spacings_.staff_spacing_ = it; it->set_property ("left-items", scm_cons (break_item_->self_scm (), SCM_EOL)); - - if (int i = last_spacings_.note_spacings_.size ()) { @@ -155,12 +149,12 @@ Separating_line_group_engraver::acknowledge_grob (Grob_info i) Pointer_group_interface::add_grob (last_spacings_.note_spacings_[i], ly_symbol2scm ("right-items"), break_item_); - + } else if (last_spacings_.staff_spacing_) { last_spacings_.staff_spacing_->set_property ("right-items", - scm_cons (break_item_->self_scm (), SCM_EOL)); + scm_cons (break_item_->self_scm (), SCM_EOL)); } } } @@ -186,40 +180,38 @@ Separating_line_group_engraver::stop_translation_timestep () { Separating_group_spanner::add_spacing_unit (sep_span_, break_item_); } - - if (Item * sp = current_spacings_.staff_spacing_) + + if (Item *sp = current_spacings_.staff_spacing_) { /* TODO: should really look at the left-items of following note-spacing grobs. - */ + */ if (musical_item_) Pointer_group_interface::add_grob (sp, ly_symbol2scm ("right-items"), musical_item_); } - if (!current_spacings_.is_empty ()) { last_spacings_ = current_spacings_; } current_spacings_.clear (); - + if (musical_item_) { Separating_group_spanner::add_spacing_unit (sep_span_, musical_item_); } - + musical_item_ = 0; } - ADD_TRANSLATOR (Separating_line_group_engraver, -/* descr */ "Generates objects for computing spacing parameters.", -/* creats*/ "SeparationItem SeparatingGroupSpanner StaffSpacing", -/* accepts */ "", -/* acks */ "item-interface", -/* reads */ "createSpacing", -/* write */ "breakableSeparationItem"); + /* descr */ "Generates objects for computing spacing parameters.", + /* creats*/ "SeparationItem SeparatingGroupSpanner StaffSpacing", + /* accepts */ "", + /* acks */ "item-interface", + /* reads */ "createSpacing", + /* write */ "breakableSeparationItem"); diff --git a/lily/separation-item.cc b/lily/separation-item.cc index 7d852f69d7..68fb40fb23 100644 --- a/lily/separation-item.cc +++ b/lily/separation-item.cc @@ -1,11 +1,10 @@ -/* - separation-item.cc -- implement Separation_item - +/* + separation-item.cc -- implement Separation_item + source file of the GNU LilyPond music typesetter - + (c) 1998--2005 Han-Wen Nienhuys - - */ +*/ #include "separation-item.hh" @@ -15,7 +14,7 @@ #include "accidental-placement.hh" void -Separation_item::add_item (Grob*s, Item* i) +Separation_item::add_item (Grob *s, Item *i) { assert (i); Pointer_group_interface::add_grob (s, ly_symbol2scm ("elements"), i); @@ -23,7 +22,7 @@ Separation_item::add_item (Grob*s, Item* i) } void -Separation_item::add_conditional_item (Grob* me , Grob *e) +Separation_item::add_conditional_item (Grob *me, Grob *e) { Pointer_group_interface::add_grob (me, ly_symbol2scm ("conditional-elements"), e); } @@ -31,28 +30,27 @@ Separation_item::add_conditional_item (Grob* me , Grob *e) /* Return the width of ME given that we are considering the object on the LEFT. - */ +*/ Interval -Separation_item::conditional_width (Grob * me, Grob * left) +Separation_item::conditional_width (Grob *me, Grob *left) { Interval w = width (me); - - Item *item = dynamic_cast (me); - Paper_column * pc = item->get_column (); - - - for (SCM s = me->get_property ("conditional-elements"); scm_is_pair (s); s = scm_cdr (s)) + + Item *item = dynamic_cast (me); + Paper_column *pc = item->get_column (); + + for (SCM s = me->get_property ("conditional-elements"); scm_is_pair (s); s = scm_cdr (s)) { SCM elt = scm_car (s); if (!unsmob_grob (elt)) continue; - + Item *il = unsmob_item (elt); if (pc != il->get_column ()) { /* this shouldn't happen, but let's continue anyway. */ programming_error (_ ("Separation_item: I've been drinking too much")); - continue; /*UGH UGH*/ + continue; /*UGH UGH*/ } if (to_boolean (il->get_property ("no-spacing-rods"))) @@ -81,11 +79,11 @@ Separation_item::width (Grob *me) return ly_scm2interval (sw); } - Item *item = dynamic_cast (me); - Paper_column * pc = item->get_column (); + Item *item = dynamic_cast (me); + Paper_column *pc = item->get_column (); Interval w; - - for (SCM s = me->get_property ("elements"); scm_is_pair (s); s = scm_cdr (s)) + + for (SCM s = me->get_property ("elements"); scm_is_pair (s); s = scm_cdr (s)) { SCM elt = scm_car (s); if (!unsmob_grob (elt)) @@ -96,7 +94,7 @@ Separation_item::width (Grob *me) { /* this shouldn't happen, but let's continue anyway. */ programming_error (_ ("Separation_item: I've been drinking too much")); - continue; /*UGH UGH*/ + continue; /*UGH UGH*/ } if (to_boolean (il->get_property ("no-spacing-rods"))) @@ -116,35 +114,34 @@ Separation_item::width (Grob *me) w.widen (robust_scm2double (pad, 0.0)); me->set_property ("X-extent", ly_interval2scm (w)); - + return w; } Interval -Separation_item::relative_width (Grob * me, Grob * common) +Separation_item::relative_width (Grob *me, Grob *common) { Interval iv = width (me); - return dynamic_cast(me)->get_column ()->relative_coordinate (common, X_AXIS) + iv ; + return dynamic_cast (me)->get_column ()->relative_coordinate (common, X_AXIS) + iv; } - /* Try to find the break-aligned symbol in SEPARATION_ITEM that is sticking out at direction D. The x size is put in LAST_EXT */ -Grob* +Grob * Separation_item::extremal_break_aligned_grob (Grob *separation_item, Direction d, - Interval * last_ext) + Interval *last_ext) { - Grob *col = dynamic_cast (separation_item)->get_column (); + Grob *col = dynamic_cast (separation_item)->get_column (); last_ext->set_empty (); Grob *last_grob = 0; for (SCM s = separation_item->get_property ("elements"); scm_is_pair (s); s = scm_cdr (s)) { - Grob * break_item = unsmob_grob (scm_car (s)); - + Grob *break_item = unsmob_grob (scm_car (s)); + if (!scm_is_symbol (break_item->get_property ("break-align-symbol"))) continue; @@ -153,22 +150,18 @@ Separation_item::extremal_break_aligned_grob (Grob *separation_item, Direction d if (ext.is_empty ()) continue; if (!last_grob - || (last_grob && d * (ext[d]- (*last_ext)[d]) > 0) ) + || (last_grob && d * (ext[d]- (*last_ext)[d]) > 0)) { *last_ext = ext; - last_grob = break_item; + last_grob = break_item; } } - return last_grob; + return last_grob; } - - - ADD_INTERFACE (Separation_item, "separation-item-interface", "Item that computes widths to generate spacing rods. " - "This is done in concert with @ref{separation-spanner-interface}." - , + "This is done in concert with @ref{separation-spanner-interface}.", "padding X-extent conditional-elements elements"); diff --git a/lily/sequential-iterator.cc b/lily/sequential-iterator.cc index 3d619fd287..cf88a52d1d 100644 --- a/lily/sequential-iterator.cc +++ b/lily/sequential-iterator.cc @@ -13,10 +13,8 @@ #include "grace-fixup.hh" /* - TODO: handling of grace notes is exquisite pain. This handling should be formally specified and then the implementation verified. - */ /* @@ -24,25 +22,24 @@ if (scm_is_pair (cursor_)) - iter_->music_ == unsmob_music (scm_car (cursor_)) + iter_->music_ == unsmob_music (scm_car (cursor_)) else - iter_ == 0; + iter_ == 0; The length of musiclist from start to up to cursor_ (cursor_ not including), is summed - here_mom_ = sum (length (musiclist [start ... cursor>)) %) - - */ + here_mom_ = sum (length (musiclist [start ... cursor>)) %) +*/ Sequential_iterator::Sequential_iterator () { here_mom_ = Moment (0); - cursor_ = SCM_EOL; + cursor_ = SCM_EOL; grace_fixups_ = 0; iter_ = 0; } -SCM +SCM Sequential_iterator::get_music_list () const { return SCM_EOL; @@ -56,8 +53,6 @@ Sequential_iterator::do_quit () } - - void Sequential_iterator::derived_mark () const { @@ -66,7 +61,6 @@ Sequential_iterator::derived_mark () const scm_gc_mark (cursor_); } - void Sequential_iterator::derived_substitute (Context *f, Context *t) { @@ -76,7 +70,7 @@ Sequential_iterator::derived_substitute (Context *f, Context *t) /* TODO: this should be made lazily. - */ +*/ Grace_fixup * create_grace_fixup_list (SCM cursor) { @@ -101,19 +95,19 @@ create_grace_fixup_list (SCM cursor) p->grace_start_ = s.grace_part_; p->next_ = 0; *tail = p; - tail = &(*tail)->next_; + tail = &(*tail)->next_; } here.grace_part_ = s.grace_part_; } - + if (l.to_bool ()) { last = here; here += l; } } - + return head; } @@ -128,7 +122,7 @@ Sequential_iterator::construct_children () Music *m = unsmob_music (scm_car (cursor_)); iter_ = unsmob_iterator (get_iterator (m)); } - + while (iter_ && !iter_->ok ()) { next_element (true); @@ -140,12 +134,11 @@ Sequential_iterator::construct_children () /* iter_->ok () is tautology, but what the heck. - */ - if (iter_ && iter_->ok ()) + */ + if (iter_ && iter_->ok ()) descend_to_child (iter_->get_outlet ()); } - /* maintain invariants: change cursor, iter and here_mom_ in one fell swoop. @@ -154,8 +147,8 @@ void Sequential_iterator::next_element (bool) { Moment len = iter_->music_get_length () - iter_->music_start_mom (); - assert (!grace_fixups_ || grace_fixups_->start_ >= here_mom_); - + assert (!grace_fixups_ || grace_fixups_->start_ >= here_mom_); + if (len.main_part_ && get_grace_fixup ()) { @@ -184,7 +177,7 @@ Sequential_iterator::next_element (bool) last_mom_ = here_mom_;; here_mom_ += len; } - + cursor_ = scm_cdr (cursor_); iter_->quit (); @@ -194,21 +187,19 @@ Sequential_iterator::next_element (bool) iter_ = 0; } - - void Sequential_iterator::process (Moment until) { while (iter_) { - Grace_fixup * gf = get_grace_fixup (); + Grace_fixup *gf = get_grace_fixup (); if (gf && gf->start_ + gf->length_ - + Moment (Rational (0), gf->grace_start_) == until) + + Moment (Rational (0), gf->grace_start_) == until) { /* do the stuff/note/rest preceding a grace. - */ + */ iter_->process (iter_->music_get_length ()); } else @@ -216,15 +207,15 @@ Sequential_iterator::process (Moment until) Moment w = until - here_mom_ + iter_->music_start_mom (); iter_->process (w); } - + /* if the iter is still OK, there must be events left that have - - TIME > LEFT - + + TIME > LEFT + */ if (iter_->ok ()) - return ; + return; descend_to_child (iter_->get_outlet ()); next_element (true); @@ -239,7 +230,7 @@ Sequential_iterator::pending_moment () const /* Fix-up a grace note halfway in the music. */ - Grace_fixup * gf = get_grace_fixup (); + Grace_fixup *gf = get_grace_fixup (); if (gf && gf->length_ + iter_->music_start_mom () == cp) { @@ -252,16 +243,15 @@ Sequential_iterator::pending_moment () const return cp + here_mom_ - iter_->music_start_mom (); } - bool Sequential_iterator::ok () const { return iter_; } -Music_iterator* +Music_iterator * Sequential_iterator::try_music_in_children (Music *m) const -{ +{ return iter_ ? iter_->try_music (m) : 0; } @@ -270,18 +260,18 @@ IMPLEMENT_CTOR_CALLBACK (Sequential_iterator); bool Sequential_iterator::run_always () const { - return iter_ ? iter_->run_always () : false; + return iter_ ? iter_->run_always () : false; } void Sequential_iterator::next_grace_fixup () { - Grace_fixup * n = grace_fixups_->next_; + Grace_fixup *n = grace_fixups_->next_; delete grace_fixups_; grace_fixups_ = n; } -Grace_fixup* +Grace_fixup * Sequential_iterator::get_grace_fixup () const { if (grace_fixups_ && grace_fixups_->start_ == here_mom_) diff --git a/lily/sequential-music-iterator.cc b/lily/sequential-music-iterator.cc index bf0f630509..e8830fb7e4 100644 --- a/lily/sequential-music-iterator.cc +++ b/lily/sequential-music-iterator.cc @@ -16,5 +16,5 @@ IMPLEMENT_CTOR_CALLBACK (Sequential_music_iterator); SCM Sequential_music_iterator::get_music_list ()const { - return get_music()->get_property ("elements"); + return get_music ()->get_property ("elements"); } diff --git a/lily/side-position-interface.cc b/lily/side-position-interface.cc index 371f13fe5a..c9e3dc6eae 100644 --- a/lily/side-position-interface.cc +++ b/lily/side-position-interface.cc @@ -1,11 +1,10 @@ -/* +/* side-position-interface.cc -- implement Side_position_interface - + source file of the GNU LilyPond music typesetter - + (c) 1998--2005 Han-Wen Nienhuys - - */ +*/ #include "side-position-interface.hh" @@ -22,13 +21,13 @@ #include "string-convert.hh" void -Side_position_interface::add_support (Grob*me, Grob*e) +Side_position_interface::add_support (Grob *me, Grob *e) { Pointer_group_interface::add_grob (me, ly_symbol2scm ("side-support-elements"), e); } Direction -Side_position_interface::get_direction (Grob*me) +Side_position_interface::get_direction (Grob *me) { SCM d = me->get_property ("direction"); if (is_direction (d) && to_dir (d)) @@ -40,17 +39,16 @@ Side_position_interface::get_direction (Grob*me) { relative_dir = to_dir (reldir); } - + SCM other_elt = me->get_property ("direction-source"); - Grob * e = unsmob_grob (other_elt); + Grob *e = unsmob_grob (other_elt); if (e) { return (Direction) (relative_dir * get_grob_direction (e)); } - + return CENTER; } - MAKE_SCHEME_CALLBACK (Side_position_interface, aligned_on_support_extents, 2); SCM @@ -62,7 +60,6 @@ Side_position_interface::aligned_on_support_extents (SCM element_smob, SCM axis) return general_side_position (me, a, true); } - /* Put the element next to the support, optionally taking in account the extent of the support. */ SCM @@ -71,7 +68,7 @@ Side_position_interface::general_side_position (Grob *me, Axis a, bool use_exten Real ss = Staff_symbol_referencer::staff_space (me); SCM support = me->get_property ("side-support-elements"); Grob *common = common_refpoint_of_list (support, me->get_parent (a), a); - Grob * st = Staff_symbol_referencer::get_staff_symbol (me); + Grob *st = Staff_symbol_referencer::get_staff_symbol (me); bool include_staff = (st && a == Y_AXIS && scm_is_number (me->get_property ("staff-padding"))); @@ -82,7 +79,7 @@ Side_position_interface::general_side_position (Grob *me, Axis a, bool use_exten common = st->common_refpoint (common, Y_AXIS); dim = st->extent (common, Y_AXIS); } - + for (SCM s = support; s != SCM_EOL; s = scm_cdr (s)) { Grob *e = unsmob_grob (scm_car (s)); @@ -100,9 +97,9 @@ Side_position_interface::general_side_position (Grob *me, Axis a, bool use_exten dim = Interval (0, 0); Direction dir = Side_position_interface::get_direction (me); - + Real off = me->get_parent (a)->relative_coordinate (common, a); - Real minimum_space = ss * robust_scm2double (me->get_property ("minimum-space"), -1); + Real minimum_space = ss * robust_scm2double (me->get_property ("minimum-space"), -1); Real total_off = dim.linear_combination (dir) - off; total_off += dir * ss * robust_scm2double (me->get_property ("padding"), 0); @@ -116,10 +113,10 @@ Side_position_interface::general_side_position (Grob *me, Axis a, bool use_exten if (fabs (total_off) > 100 CM) { String msg - = String_convert::form_string ("Improbable offset for grob %s: %f%s", - me->name ().to_str0 (), total_off, - INTERNAL_UNIT); - + = String_convert::form_string ("Improbable offset for grob %s: %f%s", + me->name ().to_str0 (), total_off, + INTERNAL_UNIT); + programming_error (msg); } return scm_make_real (total_off); @@ -127,7 +124,7 @@ Side_position_interface::general_side_position (Grob *me, Axis a, bool use_exten /* Cut & paste (ugh.) - */ +*/ MAKE_SCHEME_CALLBACK (Side_position_interface, aligned_on_support_refpoints, 2); SCM Side_position_interface::aligned_on_support_refpoints (SCM smob, SCM axis) @@ -135,12 +132,10 @@ Side_position_interface::aligned_on_support_refpoints (SCM smob, SCM axis) Grob *me = unsmob_grob (smob); Axis a = (Axis) scm_to_int (axis); - return general_side_position (me, a, false); + return general_side_position (me, a, false); } - - Real directed_round (Real f, Direction d) { @@ -161,30 +156,29 @@ SCM Side_position_interface::quantised_position (SCM element_smob, SCM) { Grob *me = unsmob_grob (element_smob); - + Direction d = Side_position_interface::get_direction (me); - Grob * stsym = Staff_symbol_referencer::get_staff_symbol (me); + Grob *stsym = Staff_symbol_referencer::get_staff_symbol (me); if (stsym) { Real p = Staff_symbol_referencer::get_position (me); Real rp = directed_round (p, d); - Real rad = Staff_symbol_referencer::staff_radius (me) *2 ; + Real rad = Staff_symbol_referencer::staff_radius (me) *2; int ip = int (rp); Grob *head = me->get_parent (X_AXIS); - + if (Staff_symbol_referencer::on_staffline (me, ip) && ((abs (ip) <= rad) || (Note_head::has_interface (head) && sign (Staff_symbol_referencer::get_position (head)) - == -d) - )) + == -d))) { ip += d; rp += d; } - + return scm_make_real ((rp - p) * Staff_symbol_referencer::staff_space (me) / 2.0); } return scm_make_real (0.0); @@ -192,19 +186,19 @@ Side_position_interface::quantised_position (SCM element_smob, SCM) /* Position next to support, taking into account my own dimensions and padding. - */ +*/ MAKE_SCHEME_CALLBACK (Side_position_interface, aligned_side, 2); SCM Side_position_interface::aligned_side (SCM element_smob, SCM axis) { Grob *me = unsmob_grob (element_smob); Axis a = (Axis) scm_to_int (axis); - + Direction d = Side_position_interface::get_direction (me); - + Real o = scm_to_double (aligned_on_support_extents (element_smob, axis)); - Interval iv = me->extent (me, a); + Interval iv = me->extent (me, a); if (!iv.is_empty ()) { @@ -213,57 +207,54 @@ Side_position_interface::aligned_side (SCM element_smob, SCM axis) programming_error ("Direction unknown, but aligned-side wanted."); d = DOWN; } - o += - iv[-d]; + o += -iv[-d]; } /* - Maintain a minimum distance to the staff. This is similar to side - position with padding, but it will put adjoining objects on a row if - stuff sticks out of the staff a little. - */ - Grob * st = Staff_symbol_referencer::get_staff_symbol (me); + Maintain a minimum distance to the staff. This is similar to side + position with padding, but it will put adjoining objects on a row if + stuff sticks out of the staff a little. + */ + Grob *st = Staff_symbol_referencer::get_staff_symbol (me); if (st && a == Y_AXIS && scm_is_number (me->get_property ("staff-padding"))) { - Real padding = - Staff_symbol_referencer::staff_space (me) - * scm_to_double (me->get_property ("staff-padding")); - + Real padding + = Staff_symbol_referencer::staff_space (me) + * scm_to_double (me->get_property ("staff-padding")); + Grob *common = me->common_refpoint (st, Y_AXIS); - + Interval staff_size = st->extent (common, Y_AXIS); - Real diff = d*staff_size[d] + padding - d*(o + iv[-d]); - o += (d* (diff >? 0)); + Real diff = d*staff_size[d] + padding - d* (o + iv[-d]); + o += (d* (diff >? 0)); } - + return scm_make_real (o); } - void -Side_position_interface::set_axis (Grob*me, Axis a) +Side_position_interface::set_axis (Grob *me, Axis a) { me->add_offset_callback (Side_position_interface::aligned_side_proc, a); } // ugh. doesn't catch all variants. Axis -Side_position_interface::get_axis (Grob*me) +Side_position_interface::get_axis (Grob *me) { if (me->has_offset_callback (Side_position_interface::aligned_side_proc, X_AXIS) - || me->has_offset_callback (Side_position_interface::aligned_side_proc , X_AXIS)) + || me->has_offset_callback (Side_position_interface::aligned_side_proc, X_AXIS)) return X_AXIS; - + return Y_AXIS; } - ADD_INTERFACE (Side_position_interface, "side-position-interface", "Position a victim object (this one) next to other objects (the " "support). The property @code{direction} signifies where to put the " "victim object relative to the support (left or right, up or down?)\n\n " "The routine also takes the size the staff into account if " - "@code{staff-padding} is set. If undefined, the staff symbol is ignored." - , + "@code{staff-padding} is set. If undefined, the staff symbol is ignored.", "staff-padding side-support-elements direction-source " "direction side-relative-direction minimum-space padding"); diff --git a/lily/simple-music-iterator.cc b/lily/simple-music-iterator.cc index 0ce6b1feb1..9f62d373fc 100644 --- a/lily/simple-music-iterator.cc +++ b/lily/simple-music-iterator.cc @@ -1,11 +1,10 @@ -/* +/* simple-music-iterator.cc -- implement Simple_music_iterator - + source file of the GNU LilyPond music typesetter - + (c) 2000--2005 Han-Wen Nienhuys - - */ +*/ #include "simple-music-iterator.hh" @@ -30,7 +29,6 @@ Simple_music_iterator::ok ()const Engravers can detect and event the end-moments to be processed as well. - */ Moment Simple_music_iterator::pending_moment ()const @@ -41,13 +39,12 @@ Simple_music_iterator::pending_moment ()const return music_get_length (); } - void Simple_music_iterator::process (Moment m) { /* - don't do try_music (), since it would make the function useless for - base classes + don't do try_music (), since it would make the function useless for + base classes */ last_processed_mom_ = m; diff --git a/lily/simple-spacer-scheme.cc b/lily/simple-spacer-scheme.cc index b658d129e5..5cc4871c0d 100644 --- a/lily/simple-spacer-scheme.cc +++ b/lily/simple-spacer-scheme.cc @@ -4,10 +4,8 @@ source file of the GNU LilyPond music typesetter (c) 2005 Han-Wen Nienhuys - */ - #include #include @@ -17,29 +15,27 @@ #include "warn.hh" #include "simple-spacer.hh" -LY_DEFINE(ly_solve_spring_rod_problem, "ly:solve-spring-rod-problem", - 4, 1, 0, (SCM springs, SCM rods, SCM length, SCM ragged), - "Solve a spring and rod problem for @var{count} objects, that " - "are connected by @var{count-1} springs, and an arbitrary number of rods " - "Springs have the format (ideal, hooke) and rods (idx1, idx2, distance) " - "@var{length} is a number, @var{ragged} a boolean " - "Return: a list containing the force (positive for stretching, " - "negative for compressing and #f for non-satisfied constraints) " - "followed by the @var{spring-count}+1 positions of the objects. " - ) +LY_DEFINE (ly_solve_spring_rod_problem, "ly:solve-spring-rod-problem", + 4, 1, 0, (SCM springs, SCM rods, SCM length, SCM ragged), + "Solve a spring and rod problem for @var{count} objects, that " + "are connected by @var{count-1} springs, and an arbitrary number of rods " + "Springs have the format (ideal, hooke) and rods (idx1, idx2, distance) " + "@var{length} is a number, @var{ragged} a boolean " + "Return: a list containing the force (positive for stretching, " + "negative for compressing and #f for non-satisfied constraints) " + "followed by the @var{spring-count}+1 positions of the objects. ") { int len = scm_ilength (springs); if (len == 0) return scm_list_2 (scm_from_double (0.0), scm_from_double (0.0)); - + SCM_ASSERT_TYPE (len >= 0, springs, SCM_ARG1, __FUNCTION__, "list of springs"); SCM_ASSERT_TYPE (scm_ilength (rods) >= 0, rods, SCM_ARG2, __FUNCTION__, "list of rods"); SCM_ASSERT_TYPE (scm_is_number (length) || length == SCM_BOOL_F, length, SCM_ARG3, __FUNCTION__, "number or #f"); - - bool is_ragged = ragged == SCM_BOOL_T; - Simple_spacer spacer; + bool is_ragged = ragged == SCM_BOOL_T; + Simple_spacer spacer; for (SCM s = springs; scm_is_pair (s); s = scm_cdr (s)) { Real ideal = scm_to_double (scm_caar (s)); @@ -54,13 +50,13 @@ LY_DEFINE(ly_solve_spring_rod_problem, "ly:solve-spring-rod-problem", int l = scm_to_int (scm_car (entry)); int r = scm_to_int (scm_cadr (entry)); entry = scm_cddr (entry); - + Real distance = scm_to_double (scm_car (entry)); spacer.add_rod (l, r, distance); } spacer.line_len_ = scm_to_double (length); - + if (is_ragged) spacer.my_solve_natural_len (); else @@ -68,14 +64,12 @@ LY_DEFINE(ly_solve_spring_rod_problem, "ly:solve-spring-rod-problem", Array posns; posns.push (0.0); - for (int i = 0; i < spacer.springs_.size(); i++) + for (int i = 0; i < spacer.springs_.size (); i++) { Real l = spacer.springs_[i].length ((is_ragged) ? 0.0 : spacer.force_); - posns.push (posns.top() + l); + posns.push (posns.top () + l); } - - SCM force_return = SCM_BOOL_F; if (!isinf (spacer.force_) && (spacer.is_active () || is_ragged)) @@ -90,11 +84,11 @@ LY_DEFINE(ly_solve_spring_rod_problem, "ly:solve-spring-rod-problem", } SCM retval = SCM_EOL; - for (int i = posns.size(); i--;) + for (int i = posns.size (); i--;) { - retval = scm_cons (scm_from_double (posns[i]), retval); + retval = scm_cons (scm_from_double (posns[i]), retval); } retval = scm_cons (force_return, retval); - return retval; + return retval; } diff --git a/lily/simple-spacer.cc b/lily/simple-spacer.cc index ac65a0ce00..e9afca6cbd 100644 --- a/lily/simple-spacer.cc +++ b/lily/simple-spacer.cc @@ -1,16 +1,14 @@ -/* +/* simple-spacer.cc -- implement Simple_spacer - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys TODO: - add support for different stretch/shrink constants? - */ - #include #include @@ -24,42 +22,39 @@ #include "dimensions.hh" /* - A simple spacing constraint solver. The approach: + A simple spacing constraint solver. The approach: - Stretch the line uniformly until none of the constraints (rods) - block. It then is very wide. + Stretch the line uniformly until none of the constraints (rods) + block. It then is very wide. - Compress until the next constraint blocks, + Compress until the next constraint blocks, - Mark the springs over the constrained part to be non-active. - - Repeat with the smaller set of non-active constraints, until all - constraints blocked, or until the line is as short as desired. + Mark the springs over the constrained part to be non-active. - This is much simpler, and much much faster than full scale - Constrained QP. On the other hand, a situation like this will not - be typeset as dense as possible, because + Repeat with the smaller set of non-active constraints, until all + constraints blocked, or until the line is as short as desired. - c4 c4 c4 c4 - veryveryverylongsyllable2 veryveryverylongsyllable2 - " "4 veryveryverylongsyllable2 syllable4 + This is much simpler, and much much faster than full scale + Constrained QP. On the other hand, a situation like this will not + be typeset as dense as possible, because + c4 c4 c4 c4 + veryveryverylongsyllable2 veryveryverylongsyllable2 + " "4 veryveryverylongsyllable2 syllable4 - can be further compressed to + can be further compressed to - c4 c4 c4 c4 - veryveryverylongsyllable2 veryveryverylongsyllable2 - " "4 veryveryverylongsyllable2 syllable4 + c4 c4 c4 c4 + veryveryverylongsyllable2 veryveryverylongsyllable2 + " "4 veryveryverylongsyllable2 syllable4 - Perhaps this is not a bad thing, because the 1st looks better anyway. */ + Perhaps this is not a bad thing, because the 1st looks better anyway. */ /* - positive force = expanding, negative force = compressing. - */ Simple_spacer::Simple_spacer () @@ -88,32 +83,32 @@ Simple_spacer::add_rod (int l, int r, Real dist) { /* If a spring is fixed, we have to do something here: - we let the rod override the spring. - */ + we let the rod override the spring. + */ Real total_dist = 0.; - for (int i = l ; i < r; i++) + for (int i = l; i < r; i++) total_dist += springs_[i].ideal_; if (total_dist < dist) - for (int i = l ; i < r; i++) - springs_[i].ideal_ *= dist/total_dist; + for (int i = l; i < r; i++) + springs_[i].ideal_ *= dist / total_dist; return; } - + Real d = range_ideal_len (l, r); Real block_stretch = dist - d; - + Real block_force = c * block_stretch; force_ = force_ >? block_force; for (int i = l; i < r; i++) springs_[i].block_force_ = block_force >? - springs_[i].block_force_ ; + springs_[i].block_force_; } Real -Simple_spacer::range_ideal_len (int l, int r) const +Simple_spacer::range_ideal_len (int l, int r) const { Real d = 0.; for (int i = l; i < r; i++) @@ -137,7 +132,7 @@ Simple_spacer::range_stiffness (int l, int r) const Real Simple_spacer::active_blocking_force () const { - Real bf = - infinity_f; + Real bf = -infinity_f; for (int i = 0; i < springs_.size (); i++) if (springs_[i].is_active_) { @@ -149,13 +144,13 @@ Simple_spacer::active_blocking_force () const Real Simple_spacer::active_springs_stiffness () const { - Real stiff = range_stiffness (0, springs_.size ()); + Real stiff = range_stiffness (0, springs_.size ()); if (isinf (stiff)) { /* all springs are inactive. Take the stiffness of the latest spring to block. - */ + */ Real max_block_force = -infinity_f; int max_i = -1; @@ -168,7 +163,7 @@ Simple_spacer::active_springs_stiffness () const } } - stiff = springs_[max_i].hooke_; + stiff = springs_[max_i].hooke_; } return stiff; } @@ -177,14 +172,14 @@ void Simple_spacer::set_active_states () { /* float comparison is safe, since force is only copied. */ - for (int i = 0 ; i = force_) { springs_[i].is_active_ = false; - active_count_ --; + active_count_--; } -} +} Real Simple_spacer::configuration_length () const @@ -199,7 +194,7 @@ Simple_spacer::configuration_length () const bool Simple_spacer::is_active () const { - return active_count_; + return active_count_; } void @@ -220,12 +215,11 @@ Simple_spacer::my_solve_linelen () } } - void Simple_spacer::my_solve_natural_len () { Real line_len_force = 0.0; - + while (is_active ()) { force_ = active_blocking_force () >? 0.0; @@ -235,20 +229,18 @@ Simple_spacer::my_solve_natural_len () { line_len_force = force_ + (line_len_ - conf) - * active_springs_stiffness(); + * active_springs_stiffness (); } - + if (force_ < 1e-8) // ugh., break; - + set_active_states (); } force_ = line_len_force; } - - /****************************************************************/ Spring_description::Spring_description () @@ -259,7 +251,6 @@ Spring_description::Spring_description () block_force_ = 0.0; } - bool Spring_description::is_sane () const { @@ -273,28 +264,25 @@ Spring_description::length (Real f) const { if (!is_active_) f = block_force_; - return ideal_ + f / hooke_ ; + return ideal_ + f / hooke_; } /****************************************************************/ - /* - TODO: should a add penalty for widely varying spring forces (caused by constraints, eg. - ===== - | | + ===== + | | o|o| x ##x The ## forces the notes apart; we shouldn't allow the O's to touch this closely. - - */ +*/ void -Simple_spacer_wrapper::solve (Column_x_positions *positions, bool ragged) +Simple_spacer_wrapper::solve (Column_x_positions *positions, bool ragged) { if (ragged) spacer_->my_solve_natural_len (); @@ -302,7 +290,7 @@ Simple_spacer_wrapper::solve (Column_x_positions *positions, bool ragged) spacer_->my_solve_linelen (); positions->force_ = spacer_->force_; - + /* We used to have a penalty for compression, no matter what, but that fucked up wtk1-fugue2 (taking 3 full pages.) @@ -310,21 +298,21 @@ Simple_spacer_wrapper::solve (Column_x_positions *positions, bool ragged) positions->config_.push (spacer_->indent_); for (int i = 0; i < spacer_->springs_.size (); i++) { - Real l = spacer_->springs_[i].length ((ragged) ? 0.0 : spacer_->force_); + Real l = spacer_->springs_[i].length ((ragged) ? 0.0 : spacer_->force_); positions->config_.push (positions->config_.top () + l); /* - we have l>= 0 here, up to rounding errors + we have l>= 0 here, up to rounding errors */ } /* For raggedright, we must have a measure of music density: this is to prevent lots of short lines (which all have force = 0). - */ + */ if (ragged) { - positions->satisfies_constraints_ = - positions->config_.top () < spacer_->line_len_ ; + positions->satisfies_constraints_ + = positions->config_.top () < spacer_->line_len_; } else positions->satisfies_constraints_ = spacer_->is_active (); @@ -334,24 +322,24 @@ Simple_spacer_wrapper::solve (Column_x_positions *positions, bool ragged) /* Check if breaking constraints are met. - */ + */ bool break_satisfy = true; - int sz = positions->cols_.size (); - for (int i = sz; i--; ) + int sz = positions->cols_.size (); + for (int i = sz; i--;) { - SCM p = positions->cols_[i]->get_property ( "penalty"); + SCM p = positions->cols_[i]->get_property ("penalty"); if (scm_is_number (p)) { if (scm_to_double (p) < -9999) break_satisfy = break_satisfy && (i == 0 || i == sz -1); if (scm_to_double (p) > 9999) - break_satisfy = break_satisfy && !(i == 0 || i == sz -1); + break_satisfy = break_satisfy && ! (i == 0 || i == sz -1); } - + } - positions->satisfies_constraints_ = - positions->satisfies_constraints_ && break_satisfy; + positions->satisfies_constraints_ + = positions->satisfies_constraints_ && break_satisfy; } void @@ -368,7 +356,7 @@ Simple_spacer::add_spring (Real ideal, Real hooke) desc.hooke_ = 1.0; desc.ideal_ = 1.0; } - + if (isinf (hooke)) { desc.is_active_ = false; @@ -376,34 +364,34 @@ Simple_spacer::add_spring (Real ideal, Real hooke) else { /* - desc.is_active_ ? + desc.is_active_ ? */ - desc.block_force_ = - desc.hooke_ * desc.ideal_; // block at distance 0 - - active_count_ ++; + desc.block_force_ = -desc.hooke_ * desc.ideal_; // block at distance 0 + + active_count_++; } springs_.push (desc); } static int -compare_paper_column_rank (Grob *const &a, - Grob *const &b) +compare_paper_column_rank (Grob *const &a, + Grob *const &b) { - return Paper_column::get_rank (a) - Paper_column::get_rank (b); + return Paper_column::get_rank (a) - Paper_column::get_rank (b); } void Simple_spacer_wrapper::add_columns (Link_array const &icols) { Link_array cols (icols); - - for (int i = cols.size (); i--;) + + for (int i = cols.size (); i--;) if (scm_is_pair (cols[i]->get_property ("between-cols"))) { loose_cols_.push (cols[i]); cols.del (i); } - + spaced_cols_ = cols; for (int i = 0; i < cols.size () - 1; i++) { @@ -414,29 +402,27 @@ Simple_spacer_wrapper::add_columns (Link_array const &icols) s = scm_cdr (s)) { Spring_smob *sp = unsmob_spring (scm_car (s)); - - - if (sp->other_ == cols[i+1]) + + if (sp->other_ == cols[i + 1]) spring = sp; } if (!spring) programming_error (_f ("No spring between column %d and next one", - Paper_column::get_rank (cols[i]) - )); + Paper_column::get_rank (cols[i]))); Real ideal = (spring) ? spring->distance_ : spacer_->default_space_; Real hooke = (spring) ? spring->strength_ : 1.0; - + spacer_->add_spring (ideal, hooke); } - + for (int i = 0; i < cols.size () - 1; i++) { for (SCM s = Spaceable_grob::get_minimum_distances (cols[i]); scm_is_pair (s); s = scm_cdr (s)) { - Grob * other = unsmob_grob (scm_caar (s)); + Grob *other = unsmob_grob (scm_caar (s)); int oi = binsearch_links (cols, other, &compare_paper_column_rank); if (oi >= 0) { @@ -445,12 +431,12 @@ Simple_spacer_wrapper::add_columns (Link_array const &icols) } if (i - && !to_boolean (cols[i]->get_property ("allow-outside-line"))) + && !to_boolean (cols[i]->get_property ("allow-outside-line"))) { Interval e = cols[i]->extent (cols[i], X_AXIS); - if (!e.is_empty()) + if (!e.is_empty ()) { - spacer_->add_rod (i, cols.size()-1, e[RIGHT]); + spacer_->add_rod (i, cols.size () - 1, e[RIGHT]); spacer_->add_rod (0, i, e[LEFT]); } } @@ -467,7 +453,6 @@ Simple_spacer_wrapper::~Simple_spacer_wrapper () delete spacer_; } - -Simple_spacer_wrapper::Simple_spacer_wrapper (Simple_spacer_wrapper const&) +Simple_spacer_wrapper::Simple_spacer_wrapper (Simple_spacer_wrapper const &) { } diff --git a/lily/simultaneous-music-iterator.cc b/lily/simultaneous-music-iterator.cc index c3ba9ed041..0c9cead8fe 100644 --- a/lily/simultaneous-music-iterator.cc +++ b/lily/simultaneous-music-iterator.cc @@ -18,7 +18,6 @@ Simultaneous_music_iterator::Simultaneous_music_iterator () children_list_ = SCM_EOL; } - void Simultaneous_music_iterator::derived_mark () const { @@ -40,19 +39,19 @@ Simultaneous_music_iterator::construct_children () SCM i = get_music ()->get_property ("elements"); children_list_ = SCM_EOL; - SCM * tail = &children_list_; + SCM *tail = &children_list_; for (; scm_is_pair (i); i = scm_cdr (i), j++) { Music *mus = unsmob_music (scm_car (i)); SCM scm_iter = get_static_get_iterator (mus); - Music_iterator * mi = unsmob_iterator (scm_iter); + Music_iterator *mi = unsmob_iterator (scm_iter); /* if create_separate_contexts_ is set, create a new context with the number number as name */ SCM name = ly_symbol2scm (get_outlet ()->context_name ().to_str0 ()); - Context * t = (j && create_separate_contexts_) + Context *t = (j && create_separate_contexts_) ? get_outlet ()->find_create_context (name, to_string (j), SCM_EOL) : get_outlet (); @@ -62,7 +61,7 @@ Simultaneous_music_iterator::construct_children () mi->init_translator (mus, t); mi->construct_children (); - if (mi->ok ()) + if (mi->ok ()) { *tail = scm_cons (scm_iter, *tail); tail = SCM_CDRLOC (*tail); @@ -75,12 +74,12 @@ Simultaneous_music_iterator::construct_children () void Simultaneous_music_iterator::process (Moment until) { - SCM *proc = &children_list_; + SCM *proc = &children_list_; while (scm_is_pair (*proc)) { - Music_iterator * i = unsmob_iterator (scm_car (*proc)); + Music_iterator *i = unsmob_iterator (scm_car (*proc)); if (i->run_always () - || i->pending_moment () == until) + || i->pending_moment () == until) { i->process (until); } @@ -101,27 +100,27 @@ Simultaneous_music_iterator::pending_moment () const { Moment next; next.set_infinite (1); - + for (SCM s = children_list_; scm_is_pair (s); s = scm_cdr (s)) { - Music_iterator * it = unsmob_iterator (scm_car (s)); + Music_iterator *it = unsmob_iterator (scm_car (s)); next = next pending_moment (); } - + return next; } bool Simultaneous_music_iterator::ok () const { - bool run_always_ok = false; + bool run_always_ok = false; for (SCM s = children_list_; scm_is_pair (s); s = scm_cdr (s)) { - Music_iterator * it = unsmob_iterator (scm_car (s)); + Music_iterator *it = unsmob_iterator (scm_car (s)); if (!it->run_always ()) return true; else - run_always_ok = run_always_ok || it->ok (); + run_always_ok = run_always_ok || it->ok (); } return run_always_ok; } @@ -131,17 +130,17 @@ Simultaneous_music_iterator::run_always () const { for (SCM s = children_list_; scm_is_pair (s); s = scm_cdr (s)) { - Music_iterator * it = unsmob_iterator (scm_car (s)); + Music_iterator *it = unsmob_iterator (scm_car (s)); if (it->run_always ()) return true; } return false; } -Music_iterator* +Music_iterator * Simultaneous_music_iterator::try_music_in_children (Music *m) const { - Music_iterator * b = 0; + Music_iterator *b = 0; for (SCM s = children_list_; !b && scm_is_pair (s); s = scm_cdr (s)) b = unsmob_iterator (scm_car (s))->try_music (m); return b; diff --git a/lily/skyline.cc b/lily/skyline.cc index 79e9b7fd76..bbbf7f5580 100644 --- a/lily/skyline.cc +++ b/lily/skyline.cc @@ -1,4 +1,4 @@ -/* +/* skyline.cc -- implement Skyline_entry and funcs. source file of the GNU LilyPond music typesetter @@ -6,38 +6,36 @@ (c) 2002--2005 Han-Wen Nienhuys */ -#include "skyline.hh" +#include "skyline.hh" /* A skyline is a shape of the form: - ---- - | | - ---------| | - | | - | | - | |______ + ---- + | | + ---------| | + | | + | | + | |______ --------| |___ - + This file deals with building such skyline structure, and computing the minimum distance between two opposing skylines. - - + + Invariants for a skyline: skyline[...].width_ forms a partition of the real interval, where the segments are adjacent, and ascending. Hence we have - + skyline.top ().width_[RIGHT] = inf skyline[0].width_[LEFT] = -inf - - */ - +*/ -const Real EPS = 1e-12; +const Real EPS = 1e-12; /* TODO: avoid unnecessary fragmentation. @@ -52,12 +50,12 @@ insert_extent_into_skyline (Array *line, Box b, Axis line_axis, Interval extent = b[line_axis]; if (extent.is_empty ()) return; - + Real stick_out = b[other_axis (line_axis)][d]; /* - Intersect each segment of LINE with EXTENT, and if non-empty, insert relevant segments. - */ + Intersect each segment of LINE with EXTENT, and if non-empty, insert relevant segments. + */ for (int i = line->size (); i--;) { Interval w = line->elem (i).width_; @@ -65,32 +63,31 @@ insert_extent_into_skyline (Array *line, Box b, Axis line_axis, if (extent[LEFT] >= w[RIGHT]) break; - + Real my_height = line->elem (i).height_; - if (!w.is_empty () && - w.length () > EPS + if (!w.is_empty () + && w.length () > EPS && d* (my_height - stick_out) < 0) { Interval e1 (line->elem (i).width_[LEFT], extent[LEFT]); Interval e3 (extent[RIGHT], line->elem (i).width_[RIGHT]); if (!e3.is_empty () && e3.length () > EPS) - line->insert (Skyline_entry (e3, my_height), i+1); + line->insert (Skyline_entry (e3, my_height), i + 1); line->elem_ref (i).height_ = stick_out; line->elem_ref (i).width_ = w; if (!e1.is_empty () && e1.length () > EPS) - line->insert (Skyline_entry (e1, my_height), i ); + line->insert (Skyline_entry (e1, my_height), i); } - } } void merge_skyline (Array * a1, - Array const & a2, + Array const &a2, Direction dir) { for (int i = 0; i < a2.size (); i++) @@ -98,13 +95,12 @@ merge_skyline (Array * a1, Box b; b[X_AXIS] = a2[i].width_; b[Y_AXIS][dir] = a2[i].height_; - b[Y_AXIS][-dir] = dir * infinity_f ; + b[Y_AXIS][-dir] = dir * infinity_f; insert_extent_into_skyline (a1, b, X_AXIS, dir); } } - Array empty_skyline (Direction d) { @@ -115,7 +111,7 @@ empty_skyline (Direction d) i.swap (); Skyline_entry e; e.width_ = i; - e.height_ = -d * infinity_f; + e.height_ = -d * infinity_f; skyline.push (e); return skyline; } @@ -132,46 +128,44 @@ extents_to_skyline (Array const &extents, Axis a, Direction d) We could do a lot better (n log (n), using a balanced tree) but that seems overkill for now. - */ - for (int j = extents.size (); j--; ) + */ + for (int j = extents.size (); j--;) insert_extent_into_skyline (&skyline, extents[j], a, d); return skyline; } - - /* minimum distance that can be achieved between baselines. "Clouds" is a skyline pointing down. This is an O (n) algorithm. - */ +*/ Real skyline_meshing_distance (Array const &buildings, Array const &clouds) { int i = buildings.size () -1; - int j = clouds.size () -1; + int j = clouds.size () -1; + + Real distance = -infinity_f; - Real distance = - infinity_f; - while (i > 0 || j > 0) { Interval w = buildings[i].width_; w.intersect (clouds[j].width_); - + if (!w.is_empty ()) distance = distance >? (buildings[i].height_ - clouds[j].height_); - if (i>0 && buildings[i].width_[LEFT] >= clouds[j].width_[LEFT]) + if (i > 0 && buildings[i].width_[LEFT] >= clouds[j].width_[LEFT]) { i--; } - else if (j > 0 && buildings[i].width_[LEFT] <= clouds[j].width_[LEFT]) + else if (j > 0 && buildings[i].width_[LEFT] <= clouds[j].width_[LEFT]) { j--; - } + } } return distance; @@ -186,12 +180,12 @@ Skyline_entry::Skyline_entry (Interval i, Real r) { width_ = i; height_ = r; - + } void heighten_skyline (Array *buildings, Real ground) { for (int i = 0; i < buildings->size (); i++) - buildings->elem_ref (i).height_ += ground; + buildings->elem_ref (i).height_ += ground; } diff --git a/lily/slash-repeat-engraver.cc b/lily/slash-repeat-engraver.cc index 76e3d71f07..25430d0ace 100644 --- a/lily/slash-repeat-engraver.cc +++ b/lily/slash-repeat-engraver.cc @@ -1,11 +1,10 @@ -/* +/* slash-repeat-engraver.cc -- implement Slash_repeat_engraver - + source file of the GNU LilyPond music typesetter - + (c) 2000--2005 Han-Wen Nienhuys - - */ +*/ #include "repeated-music.hh" #include "global-context.hh" @@ -18,15 +17,14 @@ #include "score-engraver.hh" /** - This acknowledges repeated music with "percent" style. It typesets - a % sign. + This acknowledges repeated music with "percent" style. It typesets + a % sign. - TODO: + TODO: - - BEAT case: Create items for single beat repeats, i.e. c4 / / / + - BEAT case: Create items for single beat repeats, i.e. c4 / / / - - DOUBLE_MEASURE case: attach a % to an appropriate barline. - + - DOUBLE_MEASURE case: attach a % to an appropriate barline. */ class Slash_repeat_engraver : public Engraver { @@ -44,10 +42,10 @@ protected: Moment next_moment_; Moment body_length_; - Item * beat_slash_; - Item * double_percent_; + Item *beat_slash_; + Item *double_percent_; protected: - virtual bool try_music (Music*); + virtual bool try_music (Music *); virtual void stop_translation_timestep (); virtual void start_translation_timestep (); virtual void process_music (); @@ -60,7 +58,7 @@ Slash_repeat_engraver::Slash_repeat_engraver () } bool -Slash_repeat_engraver::try_music (Music * m) +Slash_repeat_engraver::try_music (Music *m) { if (m->is_mus_type ("repeated-music") && !repeat_ @@ -69,7 +67,7 @@ Slash_repeat_engraver::try_music (Music * m) { body_length_ = Repeated_music::body_get_length (m); int count = Repeated_music::repeat_count (m); - + Moment now = now_mom (); start_mom_ = now; stop_mom_ = start_mom_ + Moment (count) * body_length_; @@ -77,17 +75,17 @@ Slash_repeat_engraver::try_music (Music * m) Moment meas_length = robust_scm2moment (get_property ("measureLength"), Moment (0)); - if (body_length_ < meas_length ) + if (body_length_ < meas_length) { repeat_ = m; } else return false; - + Global_context *global = get_global_context (); - for (int i = 0; i < count; i++) + for (int i = 0; i < count; i++) global->add_moment_to_process (next_moment_ + Moment (i) * body_length_); - + return true; } @@ -106,7 +104,6 @@ Slash_repeat_engraver::process_music () } } - void Slash_repeat_engraver::start_translation_timestep () { @@ -123,12 +120,10 @@ Slash_repeat_engraver::stop_translation_timestep () } - - ADD_TRANSLATOR (Slash_repeat_engraver, -/* descr */ "Make beat repeats.", -/* creats*/ "RepeatSlash", -/* accepts */ "repeated-music", -/* acks */ "", -/* reads */ "measureLength", -/* write */ ""); + /* descr */ "Make beat repeats.", + /* creats*/ "RepeatSlash", + /* accepts */ "repeated-music", + /* acks */ "", + /* reads */ "measureLength", + /* write */ ""); diff --git a/lily/slur-configuration.cc b/lily/slur-configuration.cc index ec1bb08840..6ab45f334e 100644 --- a/lily/slur-configuration.cc +++ b/lily/slur-configuration.cc @@ -1,10 +1,9 @@ -/* +/* slur-configuration.cc -- implement Slur_configuration - + source file of the GNU LilyPond music typesetter - + (c) 2004--2005 Han-Wen Nienhuys - */ #include "slur-configuration.hh" @@ -23,7 +22,7 @@ #include "libc-extension.hh" Bezier -avoid_staff_line (Slur_score_state const &state, +avoid_staff_line (Slur_score_state const &state, Bezier bez) { Offset horiz (1, 0); @@ -48,15 +47,15 @@ avoid_staff_line (Slur_score_state const &state, && (int (fabs (my_round (p))) % 2 != Staff_symbol_referencer::line_count (staff) % 2)) { - Direction resolution_dir = - (distance ? state.dir_ : Direction (sign (p - my_round (p)))); + Direction resolution_dir + = (distance ? state.dir_ : Direction (sign (p - my_round (p)))); // TODO: parameter Real newp = my_round (p) + resolution_dir * 5 * state.thickness_; - + Real dy = (newp - p) * state.staff_space_ / 2.0; - + bez.control_[1][Y_AXIS] += dy; bez.control_[2][Y_AXIS] += dy; } @@ -66,7 +65,7 @@ avoid_staff_line (Slur_score_state const &state, Real fit_factor (Offset dz_unit, Offset dz_perp, - Bezier curve, Direction d, Array const &avoid) + Bezier curve, Direction d, Array const &avoid) { Real fit_factor = 0.0; Offset x0 = curve.control_[0]; @@ -80,7 +79,7 @@ fit_factor (Offset dz_unit, Offset dz_perp, for (int i = 0; i < avoid.size (); i++) { - Offset z = (avoid[i] - x0) ; + Offset z = (avoid[i] - x0); Offset p (dot_product (z, dz_unit), d* dot_product (z, dz_perp)); if (!curve_xext.contains (p[X_AXIS])) @@ -94,10 +93,10 @@ fit_factor (Offset dz_unit, Offset dz_perp, } return fit_factor; } - + void Slur_configuration::generate_curve (Slur_score_state const &state, - Real r_0, Real h_inf ) + Real r_0, Real h_inf) { Link_array encompasses = state.columns_; @@ -111,15 +110,15 @@ Slur_configuration::generate_curve (Slur_score_state const &state, Encompass_info inf (state.get_encompass_info (encompasses[i])); Real y = state.dir_ * ((state.dir_ * inf.head_) >? (state.dir_ *inf.stem_)); - avoid.push (Offset (inf.x_, y + state.dir_ * state.parameters_.free_head_distance_)); + avoid.push (Offset (inf.x_, y + state.dir_ * state.parameters_.free_head_distance_)); } Link_array extra_encompasses = extract_grob_array (state.slur_, ly_symbol2scm ("encompass-objects")); - for (int i = 0; i < extra_encompasses.size (); i++) + for (int i = 0; i < extra_encompasses.size (); i++) if (Slur::has_interface (extra_encompasses[i])) { - Grob * small_slur = extra_encompasses[i]; + Grob *small_slur = extra_encompasses[i]; Bezier b = Slur::get_curve (small_slur); Offset z = b.curve_point (0.5); @@ -138,34 +137,30 @@ Slur_configuration::generate_curve (Slur_score_state const &state, Real indent, height; get_slur_indent_height (&indent, &height, dz.length (), h_inf, r_0); - Real len = dz.length (); /* This condition, - len^2 > 4h^2 + 3 (i + 1/3len)^2 - 1/3 len^2 + len^2 > 4h^2 + 3 (i + 1/3len)^2 - 1/3 len^2 - is equivalent to: + is equivalent to: - |bez' (0)| < | bez' (.5)| + |bez' (0)| < | bez' (.5)| - when (control2 - control1) has the same direction as - (control3 - control0). */ - - + when (control2 - control1) has the same direction as + (control3 - control0). */ Real max_indent = len / 3.1; indent = indent get_property ("excentricity"), 0); - + Real x1 = (excentricity + indent); Real x2 = (excentricity - indent); - + Bezier curve; curve.control_[0] = attachment_[LEFT]; curve.control_[1] = attachment_[LEFT] + dz_perp * height * state.dir_ @@ -186,7 +181,7 @@ Slur_configuration::generate_curve (Slur_score_state const &state, curve.control_[3] = attachment_[RIGHT]; Real ff = fit_factor (dz_unit, dz_perp, curve, state.dir_, avoid); - + height = height >? ((height * ff) attachment_[LEFT][X_AXIS])) continue; - + Real y = bez.get_other_coordinate (X_AXIS, x); if (!edge) { @@ -257,29 +250,26 @@ Slur_configuration::score_encompass (Slur_score_state const &state) attachment_[RIGHT][Y_AXIS], attachment_[LEFT][Y_AXIS]); - if ( 1 ) // state.dir_ * state.encompass_infos_[j].get_point (state.dir_) > state.dir_ *line_y ) + if (1) // state.dir_ * state.encompass_infos_[j].get_point (state.dir_) > state.dir_ *line_y ) { - - Real closest = - state.dir_ * (state.dir_ * state.encompass_infos_[j].get_point (state.dir_) - >? state.dir_ *line_y - ); + + Real closest + = state.dir_ * (state.dir_ * state.encompass_infos_[j].get_point (state.dir_) + >? state.dir_ *line_y); Real d = fabs (closest - y); - + convex_head_distances.push (d); } } - - if (state.dir_ * (y - state.encompass_infos_[j].stem_) < 0) { - Real stem_dem = state.parameters_.stem_encompass_penalty_ ; + Real stem_dem = state.parameters_.stem_encompass_penalty_; if ((l_edge && state.dir_ == UP) || (r_edge && state.dir_ == DOWN)) stem_dem /= 5; - demerit += stem_dem; + demerit += stem_dem; } else if (!edge) { @@ -312,7 +302,7 @@ Slur_configuration::score_encompass (Slur_score_state const &state) For slurs over 3 or 4 heads, the average distance is not a good normalizer. */ - Real n = convex_head_distances.size (); + Real n = convex_head_distances.size (); if (n <= 2) { Real fact = 1.0; @@ -327,8 +317,8 @@ Slur_configuration::score_encompass (Slur_score_state const &state) avg_distance /= n; variance_penalty = state.parameters_.head_slur_distance_max_ratio_; if (min_dist > 0.0) - variance_penalty = - (avg_distance / (min_dist + state.parameters_.absolute_closeness_measure_ ) - 1.0) + variance_penalty + = (avg_distance / (min_dist + state.parameters_.absolute_closeness_measure_) - 1.0) ? 0.0; @@ -359,16 +349,16 @@ Slur_configuration::score_extra_encompass (Slur_score_state const &state) Direction d = LEFT; bool found = false; Real y = 0.0; - + do { /* We need to check for the bound explicitly, since the slur-ending can be almost vertical, making the Y coordinate a bad approximation of the object-slur - distance. + distance. */ - Item * as_item = dynamic_cast (state.extra_encompass_infos_[j].grob_); + Item *as_item = dynamic_cast (state.extra_encompass_infos_[j].grob_); if ((as_item && as_item->get_column () == state.extremes_[d] .bound_->get_column ()) @@ -387,14 +377,14 @@ Slur_configuration::score_extra_encompass (Slur_score_state const &state) if (!slur_wid.contains (x)) continue; - + y = curve_.get_other_coordinate (X_AXIS, x); } Real dist = state.extra_encompass_infos_[j].extents_[Y_AXIS].distance (y); - demerit += - fabs (0 >? (state.parameters_.extra_encompass_free_distance_ - dist)) / - state.parameters_.extra_encompass_free_distance_ + demerit + += fabs (0 >? (state.parameters_.extra_encompass_free_distance_ - dist)) + / state.parameters_.extra_encompass_free_distance_ * state.extra_encompass_infos_[j].penalty_; } #if DEBUG_SLUR_SCORING @@ -414,18 +404,17 @@ Slur_configuration::score_edges (Slur_score_state const &state) { Real y = attachment_[d][Y_AXIS]; Real dy = fabs (y - state.base_attachments_[d][Y_AXIS]); - + Real factor = state.parameters_.edge_attraction_factor_; Real demerit = factor * dy; if (state.extremes_[d].stem_ && state.extremes_[d].stem_dir_ == state.dir_ - && !Stem::get_beaming (state.extremes_[d].stem_, -d) - ) + && !Stem::get_beaming (state.extremes_[d].stem_, -d)) demerit /= 5; demerit *= exp (state.dir_ * d * slope - * state.parameters_.edge_slope_exponent_ ); - + * state.parameters_.edge_slope_exponent_); + score_ += demerit; #if DEBUG_SLUR_SCORING score_card_ += to_string ("E%.2f", demerit); @@ -455,7 +444,7 @@ Slur_configuration ::score_slopes (Slur_score_state const &state) demerit += state.parameters_.steeper_slope_factor_ * ((fabs (slur_dy) -max_dy) >? 0); - demerit += ((fabs (slur_dy/slur_dz[X_AXIS]) + demerit += ((fabs (slur_dy / slur_dz[X_AXIS]) - state.parameters_.max_slope_) >? 0) * state.parameters_.max_slope_factor_; @@ -478,12 +467,11 @@ Slur_configuration ::score_slopes (Slur_score_state const &state) score_ += demerit; } - void Slur_configuration::score (Slur_score_state const &state) { score_extra_encompass (state); - score_slopes (state); + score_slopes (state); score_edges (state); score_encompass (state); } diff --git a/lily/slur-engraver.cc b/lily/slur-engraver.cc index 48565f5ee1..200ad5c0f3 100644 --- a/lily/slur-engraver.cc +++ b/lily/slur-engraver.cc @@ -21,14 +21,14 @@ class Slur_engraver : public Engraver { Drul_array events_; - Music * running_slur_start_; + Music *running_slur_start_; Link_array slurs_; Link_array end_slurs_; void set_melisma (bool); protected: - virtual bool try_music (Music*); + virtual bool try_music (Music *); virtual void acknowledge_grob (Grob_info); virtual void stop_translation_timestep (); virtual void finalize (); @@ -75,9 +75,9 @@ Slur_engraver::acknowledge_grob (Grob_info info) Grob *e = info.grob_; if (Note_column::has_interface (info.grob_)) { - for (int i = slurs_.size (); i--; ) + for (int i = slurs_.size (); i--;) Slur::add_column (slurs_[i], e); - for (int i = end_slurs_.size (); i-- ; ) + for (int i = end_slurs_.size (); i--;) Slur::add_column (end_slurs_[i], e); } else @@ -86,21 +86,21 @@ Slur_engraver::acknowledge_grob (Grob_info info) if (Tie::has_interface (e) || to_boolean (inside)) { - for (int i = slurs_.size (); i--; ) + for (int i = slurs_.size (); i--;) Slur::add_extra_encompass (slurs_[i], e); - for (int i = end_slurs_.size (); i--; ) + for (int i = end_slurs_.size (); i--;) Slur::add_extra_encompass (end_slurs_[i], e); } else if (inside == SCM_BOOL_F) { - Grob *slur = slurs_.size()?slurs_[0] : 0; - slur = (end_slurs_.size () && !slur) + Grob *slur = slurs_.size ()?slurs_[0] : 0; + slur = (end_slurs_.size () && !slur) ? end_slurs_[0] : slur; if (slur) { e->add_offset_callback (Slur::outside_slur_callback_proc, Y_AXIS); - e->set_property ("slur", slur->self_scm()); + e->set_property ("slur", slur->self_scm ()); } } } @@ -110,7 +110,7 @@ void Slur_engraver::finalize () { if (slurs_.size ()) - slurs_[0]->warning (_("unterminated slur")); + slurs_[0]->warning (_ ("unterminated slur")); } void @@ -118,22 +118,22 @@ Slur_engraver::process_music () { if (events_[STOP]) { - if (slurs_.size() == 0) + if (slurs_.size () == 0) { - events_[STOP]->origin()->warning (_ ("No slur to end")); + events_[STOP]->origin ()->warning (_ ("No slur to end")); } - + end_slurs_ = slurs_; slurs_.clear (); } - + if (events_[START] && slurs_.is_empty ()) { Music *ev = events_[START]; bool double_slurs = to_boolean (get_property ("doubleSlurs")); - Grob * slur = make_spanner ("Slur", events_[START]->self_scm ()); + Grob *slur = make_spanner ("Slur", events_[START]->self_scm ()); Direction updown = to_dir (ev->get_property ("direction")); if (updown && !double_slurs) set_grob_direction (slur, updown); @@ -145,7 +145,7 @@ Slur_engraver::process_music () set_grob_direction (slur, DOWN); slur = make_spanner ("Slur", events_[START]->self_scm ()); set_grob_direction (slur, UP); - slurs_.push (slur); + slurs_.push (slur); } } set_melisma (slurs_.size ()); @@ -159,9 +159,9 @@ Slur_engraver::stop_translation_timestep () } ADD_TRANSLATOR (Slur_engraver, - /* descr */ "Build slurs grobs from slur events", - /* creats*/ "Slur", - /* accepts */ "slur-event", - /* acks */ "note-column-interface accidental-interface fingering-interface script-interface tie-interface text-script-interface", - /* reads */ "slurMelismaBusy doubleSlurs", - /* write */ ""); + /* descr */ "Build slurs grobs from slur events", + /* creats*/ "Slur", + /* accepts */ "slur-event", + /* acks */ "note-column-interface accidental-interface fingering-interface script-interface tie-interface text-script-interface", + /* reads */ "slurMelismaBusy doubleSlurs", + /* write */ ""); diff --git a/lily/slur-performer.cc b/lily/slur-performer.cc index 1c0b9f9ebf..aa3d4cdc6b 100644 --- a/lily/slur-performer.cc +++ b/lily/slur-performer.cc @@ -4,7 +4,7 @@ source file of the GNU LilyPond music typesetter (c) 1996--2005 Jan Nieuwenhuizen - */ +*/ #include "performer.hh" #include "audio-item.hh" @@ -14,14 +14,15 @@ /* this is C&P from beam_performer. - */ +*/ -class Slur_performer : public Performer { +class Slur_performer : public Performer +{ public: TRANSLATOR_DECLARATIONS (Slur_performer); - + protected: - virtual bool try_music (Music *ev) ; + virtual bool try_music (Music *ev); virtual void start_translation_timestep (); virtual void process_music (); void set_melisma (bool); @@ -38,8 +39,7 @@ Slur_performer::Slur_performer () now_stop_ev_ = 0; } - -void +void Slur_performer::process_music () { if (now_stop_ev_) @@ -55,7 +55,6 @@ Slur_performer::process_music () } } - void Slur_performer::set_melisma (bool ml) { @@ -68,7 +67,7 @@ Slur_performer::start_translation_timestep () start_ev_ = 0; now_stop_ev_ = 0; } - + bool Slur_performer::try_music (Music *m) { @@ -90,5 +89,5 @@ Slur_performer::try_music (Music *m) } ADD_TRANSLATOR (Slur_performer, "", "", - "slur-event", "", "", ""); + "slur-event", "", "", ""); diff --git a/lily/slur-scoring.cc b/lily/slur-scoring.cc index b06a1b019e..9539ced5c6 100644 --- a/lily/slur-scoring.cc +++ b/lily/slur-scoring.cc @@ -7,7 +7,6 @@ Jan Nieuwenhuizen */ - #include #include "slur-scoring.hh" @@ -47,11 +46,10 @@ - calculate encompass scoring directly after determining slur shape. - optimize. - */ struct Slur_score_state; -Slur_score_state::Slur_score_state() +Slur_score_state::Slur_score_state () { musical_dy_ = 0.0; valid_ = false; @@ -130,7 +128,7 @@ broken_trend_y (Slur_score_state const &state, Direction hdir) /* A broken slur should maintain the same vertical trend the unbroken slur would have had. */ Real by = 0.0; - if (Spanner *mother = dynamic_cast (state.slur_->original_)) + if (Spanner *mother = dynamic_cast (state.slur_->original_)) { int k = broken_spanner_index (state.slur_); int j = k + hdir; @@ -139,35 +137,34 @@ broken_trend_y (Slur_score_state const &state, Direction hdir) Grob *neighbor = mother->broken_intos_[j]; Spanner *common_mother - = dynamic_cast (state.common_[Y_AXIS]->original_); + = dynamic_cast (state.common_[Y_AXIS]->original_); int common_k - = broken_spanner_index (dynamic_cast (state.common_[Y_AXIS])); + = broken_spanner_index (dynamic_cast (state.common_[Y_AXIS])); int common_j = common_k + hdir; if (common_j < 0 || common_j >= common_mother->broken_intos_.size ()) return by; Grob *common_next_system = common_mother->broken_intos_[common_j]; - - SCM last_point = scm_car (scm_last_pair (neighbor->get_property ("control-points"))); - + + SCM last_point = scm_car (scm_last_pair (neighbor->get_property ("control-points"))); + return scm_to_double (scm_cdr (last_point)) + neighbor->relative_coordinate (common_next_system, Y_AXIS); } return by; } - /* copy slur dir forwards across line break. */ void -Slur_score_state::set_next_direction () +Slur_score_state::set_next_direction () { if (extremes_[RIGHT].note_column_) return; - - if (Spanner *mother = dynamic_cast (slur_->original_)) + + if (Spanner *mother = dynamic_cast (slur_->original_)) { int k = broken_spanner_index (slur_); int j = k + 1; @@ -228,8 +225,6 @@ Slur_score_state::get_encompass_info (Grob *col) const } - - Drul_array Slur_score_state::get_bound_info () const { @@ -275,26 +270,26 @@ Slur_score_state::get_bound_info () const void Slur_score_state::fill (Grob *me) { - slur_ = dynamic_cast (me); - columns_ + slur_ = dynamic_cast (me); + columns_ = extract_grob_array (me, ly_symbol2scm ("note-columns")); - + if (columns_.is_empty ()) { me->suicide (); - return ; + return; } staff_space_ = Staff_symbol_referencer::staff_space (me); Real lt = me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness")); - thickness_ = robust_scm2double (me->get_property ("thickness"), 1.0) * lt; - + thickness_ = robust_scm2double (me->get_property ("thickness"), 1.0) * lt; + dir_ = get_grob_direction (me); parameters_.fill (me); - + SCM eltlist = me->get_property ("note-columns"); SCM extra_list = me->get_property ("encompass-objects"); - Spanner *sp = dynamic_cast (me); + Spanner *sp = dynamic_cast (me); for (int i = X_AXIS; i < NO_AXES; i++) { @@ -303,38 +298,38 @@ Slur_score_state::fill (Grob *me) common_[a] = common_refpoint_of_list (extra_list, common_[a], a); Direction d = LEFT; - do { - /* - If bound is not in note-columns, we don't want to know about - its Y-position - */ - if (a != Y_AXIS) - common_[a] = common_[a]->common_refpoint (sp->get_bound (d), a); - } + do + { + /* + If bound is not in note-columns, we don't want to know about + its Y-position + */ + if (a != Y_AXIS) + common_[a] = common_[a]->common_refpoint (sp->get_bound (d), a); + } while (flip (&d) != LEFT); } extremes_ = get_bound_info (); is_broken_ = (!extremes_[LEFT].note_column_ - || !extremes_[RIGHT].note_column_); + || !extremes_[RIGHT].note_column_); + + has_same_beam_ + = (extremes_[LEFT].stem_ && extremes_[RIGHT].stem_ + && Stem::get_beam (extremes_[LEFT].stem_) == Stem::get_beam (extremes_[RIGHT].stem_)); - has_same_beam_ = - (extremes_[LEFT].stem_ && extremes_[RIGHT].stem_ - && Stem::get_beam (extremes_[LEFT].stem_) == Stem::get_beam (extremes_[RIGHT].stem_)); - base_attachments_ = get_base_attachments (); Drul_array end_ys = get_y_attachment_range (); - configurations_ = enumerate_attachments ( end_ys); + configurations_ = enumerate_attachments (end_ys); for (int i = 0; i < columns_.size (); i++) - encompass_infos_.push (get_encompass_info ( columns_[i])); + encompass_infos_.push (get_encompass_info (columns_[i])); extra_encompass_infos_ = get_extra_encompass_infos (); valid_ = true; - musical_dy_ = 0.0; Direction d = LEFT; do @@ -344,13 +339,11 @@ Slur_score_state::fill (Grob *me) * extremes_[d].slur_head_->relative_coordinate (common_[Y_AXIS], Y_AXIS); } while (flip (&d) != LEFT); - + edge_has_beams_ = (extremes_[LEFT].stem_ && Stem::get_beam (extremes_[LEFT].stem_)) || (extremes_[RIGHT].stem_ && Stem::get_beam (extremes_[RIGHT].stem_)); - - set_next_direction (); if (is_broken_) @@ -365,7 +358,7 @@ set_slur_control_points (Grob *me) if (!state.valid_) return; - + state.generate_curves (); SCM end_ys = me->get_property ("positions"); @@ -377,7 +370,7 @@ set_slur_control_points (Grob *me) } else { - best = state.get_best_curve(); + best = state.get_best_curve (); } SCM controls = SCM_EOL; @@ -385,13 +378,12 @@ set_slur_control_points (Grob *me) { Offset o = best.control_[i] - Offset (me->relative_coordinate (state.common_[X_AXIS], X_AXIS), - me->relative_coordinate (state.common_[Y_AXIS], Y_AXIS)); + me->relative_coordinate (state.common_[Y_AXIS], Y_AXIS)); controls = scm_cons (ly_offset2scm (o), controls); } me->set_property ("control-points", controls); } - Bezier Slur_score_state::get_best_curve () { @@ -399,7 +391,7 @@ Slur_score_state::get_best_curve () { configurations_[i]->score (*this); } - + Real opt = 1e6; int opt_idx = -1; for (int i = 0; i < configurations_.size (); i++) @@ -418,7 +410,7 @@ Slur_score_state::get_best_curve () && scm_is_pair (inspect_quants)) opt_idx = get_closest_index (inspect_quants); - configurations_[opt_idx]->score_card_ += to_string ("=%.2f", opt); + configurations_[opt_idx]->score_card_ += to_string ("=%.2f", opt); configurations_[opt_idx]->score_card_ += to_string ("i%d", opt_idx); // debug quanting @@ -437,7 +429,7 @@ Slur_score_state::get_closest_index (SCM inspect_quants) const int opt_idx = -1; Real mindist = 1e6; - for (int i = 0; i < configurations_.size (); i ++) + for (int i = 0; i < configurations_.size (); i++) { Real d = fabs (configurations_[i]->attachment_[LEFT][Y_AXIS] - ins[LEFT]) + fabs (configurations_[i]->attachment_[RIGHT][Y_AXIS] - ins[RIGHT]); @@ -455,7 +447,7 @@ Slur_score_state::get_closest_index (SCM inspect_quants) const /* TODO: should analyse encompasses to determine sensible region, and should limit slopes available. - */ +*/ Drul_array Slur_score_state::get_y_attachment_range () const @@ -467,9 +459,9 @@ Slur_score_state::get_y_attachment_range () const if (extremes_[d].note_column_) { end_ys[d] = dir_ - * ((dir_ * (base_attachments_[d][Y_AXIS] + parameters_.region_size_* dir_)) + * ((dir_ * (base_attachments_[d][Y_AXIS] + parameters_.region_size_* dir_)) >? (dir_ * (dir_ + extremes_[d].note_column_->extent (common_[Y_AXIS], - Y_AXIS)[dir_])) + Y_AXIS)[dir_])) >? (dir_ * base_attachments_[-d][Y_AXIS])); } else @@ -481,21 +473,21 @@ Slur_score_state::get_y_attachment_range () const } bool -spanner_less (Spanner *s1, Spanner* s2) +spanner_less (Spanner *s1, Spanner *s2) { Slice b1, b2; - Direction d = LEFT; + Direction d = LEFT; do { b1[d] = s1->get_bound (d)->get_column ()->rank_; b2[d] = s2->get_bound (d)->get_column ()->rank_; - } while (flip (&d) != LEFT); + } + while (flip (&d) != LEFT); return b2[LEFT] <= b1[LEFT] && b2[RIGHT] >= b1[RIGHT] && (b2[LEFT] != b1[LEFT] || b2[RIGHT] != b1[RIGHT]); } - Drul_array Slur_score_state::get_base_attachments () const { @@ -510,10 +502,10 @@ Slur_score_state::get_base_attachments () const Real y = 0.0; if (extremes_[d].note_column_) { - + /* fixme: X coord should also be set in this case. - */ + */ if (stem && extremes_[d].stem_dir_ == dir_ && Stem::get_beaming (stem, -d) @@ -524,18 +516,18 @@ Slur_score_state::get_base_attachments () const y = head->extent (common_[Y_AXIS], Y_AXIS)[dir_]; y += dir_ * 0.5 * staff_space_; + y = move_away_from_staffline (y, head); - y = move_away_from_staffline (y, head); - - Grob * fh = Note_column::first_head (extremes_[d].note_column_); - x = - (fh ? fh->extent (common_[X_AXIS], X_AXIS) - : extremes_[d].bound_->extent (common_[X_AXIS], X_AXIS)) + Grob *fh = Note_column::first_head (extremes_[d].note_column_); + x + = (fh ? fh->extent (common_[X_AXIS], X_AXIS) + : extremes_[d].bound_->extent (common_[X_AXIS], X_AXIS)) .linear_combination (CENTER); } base_attachment[d] = Offset (x, y); - } while (flip (&d) != LEFT); + } + while (flip (&d) != LEFT); do { @@ -550,13 +542,13 @@ Slur_score_state::get_base_attachments () const { x = slur_->get_broken_left_end_align (); } - Grob * col = (d == LEFT) ? columns_[0] : columns_.top(); - + Grob *col = (d == LEFT) ? columns_[0] : columns_.top (); + if (extremes_[-d].bound_ != col) { y = robust_relative_extent (col, common_[Y_AXIS], Y_AXIS)[dir_]; y += dir_ * 0.5 * staff_space_; - + if (get_grob_direction (col) == dir_ && Note_column::get_stem (col) && !Stem::is_invisible (Note_column::get_stem (col))) @@ -565,10 +557,9 @@ Slur_score_state::get_base_attachments () const else y = base_attachment[-d][Y_AXIS]; - y = move_away_from_staffline (y, col); - - base_attachment[d] = Offset (x, y); + + base_attachment[d] = Offset (x, y); } } while (flip (&d) != LEFT); @@ -582,13 +573,12 @@ Slur_score_state::move_away_from_staffline (Real y, { Real pos = (y - Staff_symbol_referencer::get_staff_symbol (on_staff)->relative_coordinate (common_[Y_AXIS], - Y_AXIS)) + Y_AXIS)) * 2.0 / staff_space_; - + if (fabs (pos - my_round (pos)) < 0.2 && Staff_symbol_referencer::on_staffline (on_staff, (int) rint (pos)) - && Staff_symbol_referencer::line_count (on_staff) - 1 >= rint (pos) - ) + && Staff_symbol_referencer::line_count (on_staff) - 1 >= rint (pos)) y += 1.5 * staff_space_ * dir_ / 10; return y; @@ -604,15 +594,12 @@ Slur_score_state::generate_curves () const } - - -Link_array +Link_array Slur_score_state::enumerate_attachments (Drul_array end_ys) const { /*ugh. */ Link_array scores; - Drul_array os; os[LEFT] = base_attachments_[LEFT]; Real minimum_length = staff_space_ @@ -643,19 +630,17 @@ Slur_score_state::enumerate_attachments (Drul_array end_ys) const } else if (dir_ * extremes_[d].stem_extent_[Y_AXIS][dir_] < dir_ * os[d][Y_AXIS] - && !extremes_[d].stem_extent_[X_AXIS].is_empty () - ) - + && !extremes_[d].stem_extent_[X_AXIS].is_empty ()) + os[d][X_AXIS] = extremes_[d].stem_extent_[X_AXIS].center (); } } while (flip (&d) != LEFT); - Offset dz; + Offset dz; dz = os[RIGHT] - os[LEFT]; if (dz[X_AXIS] < minimum_length - || fabs (dz[Y_AXIS] / dz[X_AXIS]) > parameters_.max_slope_ - ) + || fabs (dz[Y_AXIS] / dz[X_AXIS]) > parameters_.max_slope_) { do { @@ -676,7 +661,7 @@ Slur_score_state::enumerate_attachments (Drul_array end_ys) const { /* Horizontally move tilted slurs a little. Move more for bigger tilts. - + TODO: parameter */ os[d][X_AXIS] -= dir_ * extremes_[d].slur_head_extent_.length () @@ -684,12 +669,12 @@ Slur_score_state::enumerate_attachments (Drul_array end_ys) const } } while (flip (&d) != LEFT); - + s.attachment_ = os; s.index_ = scores.size (); scores.push (new Slur_configuration (s)); - + os[RIGHT][Y_AXIS] += dir_ * staff_space_ / 2; } @@ -700,18 +685,17 @@ Slur_score_state::enumerate_attachments (Drul_array end_ys) const return scores; } - Array Slur_score_state::get_extra_encompass_infos () const { Link_array encompasses = extract_grob_array (slur_, ly_symbol2scm ("encompass-objects")); Array collision_infos; - for (int i = encompasses.size (); i--; ) + for (int i = encompasses.size (); i--;) { if (Slur::has_interface (encompasses[i])) { - Spanner * small_slur = dynamic_cast (encompasses[i]); + Spanner *small_slur = dynamic_cast (encompasses[i]); Bezier b = Slur::get_curve (small_slur); Offset relative (small_slur->relative_coordinate (common_[X_AXIS], X_AXIS), @@ -719,7 +703,7 @@ Slur_score_state::get_extra_encompass_infos () const for (int k = 0; k < 3; k++) { - Direction hdir = Direction (k /2 - 1); + Direction hdir = Direction (k /2 - 1); /* Only take bound into account if small slur starts @@ -727,7 +711,7 @@ Slur_score_state::get_extra_encompass_infos () const */ if (hdir && small_slur->get_bound (hdir) != slur_->get_bound (hdir)) continue; - + Offset z = b.curve_point (k / 2.0); z += relative; @@ -763,7 +747,7 @@ Slur_score_state::get_extra_encompass_infos () const SCM cstyle = g->get_property ("cautionary-style"); parens = ly_c_equal_p (cstyle, ly_symbol2scm ("parentheses")); } - + SCM accs = g->get_property ("accidentals"); SCM scm_style = g->get_property ("style"); if (!scm_is_symbol (scm_style) @@ -776,10 +760,10 @@ Slur_score_state::get_extra_encompass_infos () const case FLAT: case DOUBLE_FLAT: xp = LEFT; - break ; + break; case SHARP: xp = 0.5 * dir_; - break ; + break; case NATURAL: xp = -dir_; break; @@ -789,7 +773,7 @@ Slur_score_state::get_extra_encompass_infos () const ye.widen (thickness_ * 0.5); xe.widen (thickness_ * 1.0); - Extra_collision_info info (g, xp, xe, ye, penalty); + Extra_collision_info info (g, xp, xe, ye, penalty); collision_infos.push (info); } } diff --git a/lily/slur.cc b/lily/slur.cc index c219eb0607..a35784eb3d 100644 --- a/lily/slur.cc +++ b/lily/slur.cc @@ -68,11 +68,11 @@ Slur::print (SCM smob) /* TODO: replace dashed with generic property. */ - SCM p = me->get_property ("dash-period"); - SCM f = me->get_property ("dash-fraction"); + SCM p = me->get_property ("dash-period"); + SCM f = me->get_property ("dash-fraction"); if (scm_is_number (p) && scm_is_number (f)) - a = Lookup::dashed_slur (one, thick, robust_scm2double (p, 1.0), - robust_scm2double(f,0)); + a = Lookup::dashed_slur (one, thick, robust_scm2double (p, 1.0), + robust_scm2double (f, 0)); else a = Lookup::slur (one, get_grob_direction (me) * base_thick * ss / 10.0, thick); @@ -97,9 +97,8 @@ Slur::print (SCM smob) return a.smobbed_copy (); } - Bezier -Slur::get_curve (Grob*me) +Slur::get_curve (Grob *me) { Bezier b; int i = 0; @@ -111,21 +110,18 @@ Slur::get_curve (Grob*me) } void -Slur::add_column (Grob*me, Grob*n) +Slur::add_column (Grob *me, Grob *n) { Pointer_group_interface::add_grob (me, ly_symbol2scm ("note-columns"), n); - add_bound_item (dynamic_cast (me), dynamic_cast (n)); + add_bound_item (dynamic_cast (me), dynamic_cast (n)); } - void -Slur::add_extra_encompass (Grob*me, Grob*n) +Slur::add_extra_encompass (Grob *me, Grob *n) { Pointer_group_interface::add_grob (me, ly_symbol2scm ("encompass-objects"), n); } - - MAKE_SCHEME_CALLBACK (Slur, outside_slur_callback, 2); SCM Slur::outside_slur_callback (SCM grob, SCM axis) @@ -138,7 +134,7 @@ Slur::outside_slur_callback (SCM grob, SCM axis) if (!slur) return scm_from_int (0); - + Grob *cx = script->common_refpoint (slur, X_AXIS); Grob *cy = script->common_refpoint (slur, Y_AXIS); @@ -150,12 +146,11 @@ Slur::outside_slur_callback (SCM grob, SCM axis) Interval yext = robust_relative_extent (script, cy, Y_AXIS); Interval xext = robust_relative_extent (script, cx, X_AXIS); - Real slur_padding = robust_scm2double (script->get_property ("slur-padding"), 0.0); // todo: slur property, script property? yext.widen (slur_padding); Real EPS = 1e-3; - + Interval bezext (curve.control_[0][X_AXIS], curve.control_[3][X_AXIS]); @@ -172,13 +167,13 @@ Slur::outside_slur_callback (SCM grob, SCM axis) if (consider[k]) { ys[k] - = (fabs(bezext[LEFT] - x) < EPS) + = (fabs (bezext[LEFT] - x) < EPS) ? curve.control_[0][Y_AXIS] - : ((fabs(bezext[RIGHT] - x) < EPS) + : ((fabs (bezext[RIGHT] - x) < EPS) ? curve.control_[3][Y_AXIS] : curve.get_other_coordinate (X_AXIS, x)); consider[k] = true; - + if (yext.contains (ys[k])) do_shift = true; } @@ -195,18 +190,18 @@ Slur::outside_slur_callback (SCM grob, SCM axis) k++; } } - + return scm_make_real (offset); } static Direction -get_default_dir (Grob*me) +get_default_dir (Grob *me) { Link_array encompasses = extract_grob_array (me, ly_symbol2scm ("note-columns")); Direction d = DOWN; - for (int i = 0; i < encompasses.size (); i ++) + for (int i = 0; i < encompasses.size (); i++) { if (Note_column::dir (encompasses[i]) < 0) { @@ -217,12 +212,11 @@ get_default_dir (Grob*me) return d; } - MAKE_SCHEME_CALLBACK (Slur, after_line_breaking, 1); SCM Slur::after_line_breaking (SCM smob) { - Spanner *me = dynamic_cast (unsmob_grob (smob)); + Spanner *me = dynamic_cast (unsmob_grob (smob)); if (!scm_ilength (me->get_property ("note-columns"))) { me->suicide (); @@ -242,4 +236,3 @@ ADD_INTERFACE (Slur, "slur-interface", "A slur", "positions quant-score excentricity encompass-objects control-points dash-period dash-fraction slur-details direction height-limit note-columns ratio thickness"); - diff --git a/lily/source-file.cc b/lily/source-file.cc index 6957cc19c0..c20fce8fb5 100644 --- a/lily/source-file.cc +++ b/lily/source-file.cc @@ -16,7 +16,7 @@ #include #else #include -#define istringstream(x) istrstream(x, length ()) +#define istringstream(x) istrstream (x, length ()) #endif #include "warn.hh" @@ -36,7 +36,7 @@ Source_file::load_stdin () contents_str0_ = chs.remove_array (); } -char* +char * gulp_file (String filename, int *filesize) { /* "b" must ensure to open literally, avoiding text (CR/LF) @@ -68,7 +68,7 @@ Source_file::Source_file (String filename, String data) { name_ = filename; istream_ = 0; - contents_str0_ = data.get_copy_str0(); + contents_str0_ = data.get_copy_str0 (); length_ = data.length (); pos_str0_ = to_str0 (); init_port (); @@ -88,7 +88,7 @@ Source_file::Source_file (String filename_string) load_stdin (); else contents_str0_ = gulp_file (filename_string, &length_); - + pos_str0_ = to_str0 (); init_port (); @@ -153,17 +153,17 @@ Source_file::~Source_file () } Slice -Source_file::line_slice (char const* pos_str0) const +Source_file::line_slice (char const *pos_str0) const { if (!contains (pos_str0)) return Slice (0, 0); - char const* data_str0 = to_str0 (); - char const * eof_C_ = data_str0 + length (); + char const *data_str0 = to_str0 (); + char const *eof_C_ = data_str0 + length (); if (pos_str0 == eof_C_) - pos_str0 --; - char const* begin_str0 = pos_str0; + pos_str0--; + char const *begin_str0 = pos_str0; while (begin_str0 > data_str0) if (*--begin_str0 == '\n') { @@ -189,22 +189,22 @@ Source_file::line_string (char const* pos_str0) const return ""; Slice line = line_slice (pos_str0); - char const* data_str0 = to_str0 (); - return String ((Byte const*)data_str0 + line[LEFT], line.length ()); + char const *data_str0 = to_str0 (); + return String ((Byte const *)data_str0 + line[LEFT], line.length ()); } int -Source_file::get_char (char const* pos_str0) const +Source_file::get_char (char const *pos_str0) const { if (!contains (pos_str0)) return 0; - char const* data_str0 = to_str0 (); + char const *data_str0 = to_str0 (); return pos_str0 - (line_slice (pos_str0)[SMALLER] + data_str0); } int -Source_file::get_column (char const* pos_str0) const +Source_file::get_column (char const *pos_str0) const { if (!contains (pos_str0)) return 0; @@ -293,10 +293,10 @@ Source_file::set_pos (char const * pos_str0) error (error_string (pos_str0) + "invalid pos"); } -char const* +char const * Source_file::seek_str0 (int n) { - char const* new_str0 = to_str0 () + n; + char const *new_str0 = to_str0 () + n; if (n < 0) new_str0 += length (); if (contains (new_str0)) @@ -307,15 +307,15 @@ Source_file::seek_str0 (int n) return pos_str0_; } -char const* +char const * Source_file::forward_str0 (int n) { - char const* old_pos = pos_str0_; - char const* new_str0 = pos_str0_ + n; + char const *old_pos = pos_str0_; + char const *new_str0 = pos_str0_ + n; if (contains (new_str0)) pos_str0_ = new_str0; else - error (error_string (new_str0) + "forward past eof"); + error (error_string (new_str0) + "forward past eof"); return old_pos; } @@ -323,6 +323,6 @@ Source_file::forward_str0 (int n) String Source_file::get_string (int n) { - String str = String ((Byte const*)forward_str0 (n), n); + String str = String ((Byte const *)forward_str0 (n), n); return str; } diff --git a/lily/source.cc b/lily/source.cc index b73fa590ac..4cf670458a 100644 --- a/lily/source.cc +++ b/lily/source.cc @@ -32,30 +32,30 @@ Sources::set_path (File_path *f) } /** - open a file + open a file - @param file_string the file to be opened, name might be changed if it - is found in a search path. UGH! + @param file_string the file to be opened, name might be changed if it + is found in a search path. UGH! - @return 0 if no file found - */ -Source_file* + @return 0 if no file found +*/ +Source_file * Sources::get_file (String &file_string) //UGH { if ((file_string != "-") && path_) { - String file_string_o = path_->find (file_string); + String file_string_o = path_->find (file_string); if ((file_string_o == "") && (file_string != "")) return 0; file_string = file_string_o; } - Source_file * f = new Source_file (file_string) ; + Source_file *f = new Source_file (file_string); add (f); return f; } void -Sources::add (Source_file* sourcefile) +Sources::add (Source_file *sourcefile) { sourcefile_list_ = new Killing_cons (sourcefile, sourcefile_list_); } @@ -65,16 +65,16 @@ Sources::~Sources () delete sourcefile_list_; } /** - search the list for file whose map contains pointer #str0# + search the list for file whose map contains pointer #str0# - @return 0 if not found. - */ -Source_file* -Sources::get_sourcefile (char const* str0) + @return 0 if not found. +*/ +Source_file * +Sources::get_sourcefile (char const *str0) { for (Cons *i = sourcefile_list_; i; i = i->next_) - if (i->car_->contains (str0)) + if (i->car_->contains (str0)) return i->car_; return 0; } diff --git a/lily/spaceable-grob.cc b/lily/spaceable-grob.cc index 23b2c6cb69..17d15ba94b 100644 --- a/lily/spaceable-grob.cc +++ b/lily/spaceable-grob.cc @@ -1,15 +1,14 @@ -/* +/* spaceable-grob.cc -- implement Spaceable_grob - + source file of the GNU LilyPond music typesetter - + (c) 2000--2005 Han-Wen Nienhuys - - */ +*/ #include "spaceable-grob.hh" -#include +#include #include #include "warn.hh" @@ -17,7 +16,7 @@ #include "group-interface.hh" SCM -Spaceable_grob::get_minimum_distances (Grob*me) +Spaceable_grob::get_minimum_distances (Grob *me) { return me->get_property ("minimum-distances"); } @@ -25,11 +24,11 @@ Spaceable_grob::get_minimum_distances (Grob*me) /*todo: merge code of spring & rod? */ void -Spaceable_grob::add_rod (Grob *me , Grob * p, Real d) +Spaceable_grob::add_rod (Grob *me, Grob *p, Real d) { // printf ("rod %lf\n", d); - + SCM mins = get_minimum_distances (me); SCM newdist = scm_make_real (d); for (SCM s = mins; scm_is_pair (s); s = scm_cdr (s)) @@ -38,8 +37,8 @@ Spaceable_grob::add_rod (Grob *me , Grob * p, Real d) if (scm_car (dist) == p->self_scm ()) { scm_set_cdr_x (dist, scm_max (scm_cdr (dist), - newdist)); - return ; + newdist)); + return; } } @@ -48,7 +47,7 @@ Spaceable_grob::add_rod (Grob *me , Grob * p, Real d) } void -Spaceable_grob::add_spring (Grob*me, Grob * p, Real d, Real strength) +Spaceable_grob::add_spring (Grob *me, Grob *p, Real d, Real strength) { // printf ("dist %lf, str %lf\n", d, strength); if (d <= 0.0 || strength <= 0.0) @@ -57,53 +56,49 @@ Spaceable_grob::add_spring (Grob*me, Grob * p, Real d, Real strength) d = 1.0; strength = 1.0; } - - if (isinf (d) || isnan(d) + + if (isinf (d) || isnan (d) || isnan (strength)) { /* strength == INF is possible. It means fixed distance. - */ + */ programming_error ("Insane distance found."); d = 1.0; strength = 1.0; } - + #ifndef NDEBUG SCM mins = me->get_property ("ideal-distances"); for (SCM s = mins; scm_is_pair (s); s = scm_cdr (s)) { - Spring_smob * sp = unsmob_spring(scm_car (s)); + Spring_smob *sp = unsmob_spring (scm_car (s)); if (sp->other_ == p) { programming_error ("already have that spring"); - return ; + return; } } #endif - + Spring_smob spring; spring.strength_ = strength; spring.distance_ = d; spring.other_ = p; - + Group_interface::add_thing (me, ly_symbol2scm ("ideal-distances"), spring.smobbed_copy ()); } - void -Spaceable_grob::remove_interface (Grob*me) +Spaceable_grob::remove_interface (Grob *me) { - me->set_property ("minimum-distances" , SCM_EOL); + me->set_property ("minimum-distances", SCM_EOL); me->set_property ("spacing-wishes", SCM_EOL); me->set_property ("ideal-distances", SCM_EOL); } - - ADD_INTERFACE (Spaceable_grob, "spaceable-grob-interface", - "A layout object that takes part in the spacing problem. " - , + "A layout object that takes part in the spacing problem. ", "measure-length spacing-wishes penalty minimum-distances ideal-distances " "allow-outside-line left-neighbors right-neighbors"); diff --git a/lily/spacing-engraver.cc b/lily/spacing-engraver.cc index 14d040e13d..ec4b189fa2 100644 --- a/lily/spacing-engraver.cc +++ b/lily/spacing-engraver.cc @@ -1,11 +1,10 @@ -/* +/* spacing-engraver.cc -- implement Spacing_engraver - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - - */ +*/ #include "paper-column.hh" #include "engraver.hh" @@ -19,16 +18,16 @@ struct Rhythmic_tuple { Grob_info info_; Moment end_; - + Rhythmic_tuple () - { - } + { + } Rhythmic_tuple (Grob_info i, Moment m) - { - info_ = i; - end_ = m; - } - static int time_compare (Rhythmic_tuple const &, Rhythmic_tuple const &); + { + info_ = i; + end_ = m; + } + static int time_compare (Rhythmic_tuple const &, Rhythmic_tuple const &); }; /** @@ -43,8 +42,8 @@ class Spacing_engraver : public Engraver Array now_durations_; Array stopped_durations_; Moment now_; - Spanner * spacing_; - + Spanner *spacing_; + TRANSLATOR_DECLARATIONS (Spacing_engraver); protected: virtual void acknowledge_grob (Grob_info); @@ -78,8 +77,8 @@ Spacing_engraver::process_music () if (!spacing_) { spacing_ = make_spanner ("SpacingSpanner", SCM_EOL); - spacing_->set_bound (LEFT, unsmob_grob (get_property ("currentCommandColumn"))); - + spacing_->set_bound (LEFT, unsmob_grob (get_property ("currentCommandColumn"))); + } } @@ -88,8 +87,8 @@ Spacing_engraver::finalize () { if (spacing_) { - Grob * p = unsmob_grob (get_property ("currentCommandColumn")); - + Grob *p = unsmob_grob (get_property ("currentCommandColumn")); + spacing_->set_bound (RIGHT, p); spacing_ = 0; } @@ -100,16 +99,16 @@ Spacing_engraver::acknowledge_grob (Grob_info i) { if (Note_spacing::has_interface (i.grob_) || Staff_spacing::has_interface (i.grob_)) { - Pointer_group_interface::add_grob (spacing_, ly_symbol2scm ("wishes"), i.grob_); + Pointer_group_interface::add_grob (spacing_, ly_symbol2scm ("wishes"), i.grob_); } - + if (i.grob_->internal_has_interface (ly_symbol2scm ("lyric-syllable-interface")) || i.grob_->internal_has_interface (ly_symbol2scm ("multi-measure-event"))) return; /* - only pay attention to durations that are not grace notes. - */ + only pay attention to durations that are not grace notes. + */ if (!now_.grace_part_) { Music *r = i.music_cause (); @@ -129,7 +128,7 @@ Spacing_engraver::stop_translation_timestep () shortest_playing.set_infinite (1); for (int i = 0; i < playing_durations_.size (); i++) { - Music * mus = playing_durations_[i].info_.music_cause (); + Music *mus = playing_durations_[i].info_.music_cause (); if (mus) { Moment m = mus->get_length (); @@ -150,17 +149,17 @@ Spacing_engraver::stop_translation_timestep () } } now_durations_.clear (); - + shortest_playing = shortest_playing (unsmob_grob (get_property ("currentMusicalColumn"))); + + Paper_column *sc + = dynamic_cast (unsmob_grob (get_property ("currentMusicalColumn"))); assert (starter.to_bool ()); SCM sh = shortest_playing.smobbed_copy (); SCM st = starter.smobbed_copy (); - sc->set_property ("shortest-playing-duration", sh); + sc->set_property ("shortest-playing-duration", sh); sc->set_property ("shortest-starter-duration", st); } @@ -176,12 +175,10 @@ Spacing_engraver::start_translation_timestep () } - - ADD_TRANSLATOR (Spacing_engraver, -/* descr */ "make a SpacingSpanner and do bookkeeping of shortest starting and playing notes ", -/* creats*/ "SpacingSpanner", -/* accepts */ "", -/* acks */ "grob-interface", -/* reads */ "", -/* write */ ""); + /* descr */ "make a SpacingSpanner and do bookkeeping of shortest starting and playing notes ", + /* creats*/ "SpacingSpanner", + /* accepts */ "", + /* acks */ "grob-interface", + /* reads */ "", + /* write */ ""); diff --git a/lily/spacing-loose-columns.cc b/lily/spacing-loose-columns.cc index 329a77a7dd..830657e6f9 100644 --- a/lily/spacing-loose-columns.cc +++ b/lily/spacing-loose-columns.cc @@ -4,7 +4,6 @@ source file of the GNU LilyPond music typesetter (c) 2005 Han-Wen Nienhuys - */ #include "system.hh" @@ -12,22 +11,21 @@ #include "column-x-positions.hh" #include "staff-spacing.hh" - /* Find the loose columns in POSNS, and drape them around the columns specified in BETWEEN-COLS. */ void -set_loose_columns (System* which, Column_x_positions const *posns) +set_loose_columns (System *which, Column_x_positions const *posns) { int loose_col_count = posns->loose_cols_.size (); for (int i = 0; i < loose_col_count; i++) { int divide_over = 1; - Item *loose = dynamic_cast (posns->loose_cols_[i]); - Paper_column* col = dynamic_cast (loose); - + Item *loose = dynamic_cast (posns->loose_cols_[i]); + Paper_column *col = dynamic_cast (loose); + if (col->system_) continue; - + Item *left = 0; Item *right = 0; while (1) @@ -36,12 +34,12 @@ set_loose_columns (System* which, Column_x_positions const *posns) if (!scm_is_pair (between)) break; - Item *le = dynamic_cast (unsmob_grob (scm_car (between))); - Item *re = dynamic_cast (unsmob_grob (scm_cdr (between))); + Item *le = dynamic_cast (unsmob_grob (scm_car (between))); + Item *re = dynamic_cast (unsmob_grob (scm_cdr (between))); - if (!(le && re)) + if (! (le && re)) break; - + if (!left && le) { left = le->get_column (); @@ -55,12 +53,12 @@ set_loose_columns (System* which, Column_x_positions const *posns) if (!right->get_system ()) right = right->find_prebroken_piece (LEFT); - + Grob *common = right->common_refpoint (left, X_AXIS); int count = 0; - Real total_space = 0.0; - Real total_fixed = 0.0; + Real total_space = 0.0; + Real total_fixed = 0.0; for (SCM wish = col->get_property ("spacing-wishes"); scm_is_pair (wish); wish = scm_cdr (wish)) { Grob *spacing = unsmob_grob (scm_car (wish)); @@ -72,7 +70,7 @@ set_loose_columns (System* which, Column_x_positions const *posns) total_fixed += fixed; total_space += space; - count ++; + count++; } } @@ -96,12 +94,12 @@ set_loose_columns (System* which, Column_x_positions const *posns) Real left_point = left->extent (common, X_AXIS)[RIGHT]; Real space_left = ((right_point - left_point) >? 0.0) - - (my_extent.is_empty() ? 0.0 : my_extent.length ()); + - (my_extent.is_empty () ? 0.0 : my_extent.length ()); Real padding = (space_left / 2) - - */ +*/ #include #include @@ -30,81 +29,78 @@ /* TODO: this file/class is too complex. Should figure out how to chop this up even more. - - */ +*/ class Spacing_spanner { public: - static void standard_breakable_column_spacing (Grob * me, Item*l, Item*r, - Real * fixed, Real * space, Moment); - - - static Real default_bar_spacing (Grob*, Grob*, Grob*, Moment); - static Real note_spacing (Grob*, Grob*, Grob*, Moment, bool*); - static Real get_duration_space (Grob*, Moment dur, Rational shortest, bool*); - static Rational find_shortest (Grob *, Link_array const &); - static void breakable_column_spacing (Grob*, Item* l, Item *r, Moment); + static void standard_breakable_column_spacing (Grob *me, Item *l, Item *r, + Real *fixed, Real *space, Moment); + + static Real default_bar_spacing (Grob *, Grob *, Grob *, Moment); + static Real note_spacing (Grob *, Grob *, Grob *, Moment, bool *); + static Real get_duration_space (Grob *, Moment dur, Rational shortest, bool *); + static Rational find_shortest (Grob *, Link_array const &); + static void breakable_column_spacing (Grob *, Item *l, Item *r, Moment); static void find_loose_columns () {} - static void prune_loose_columns (Grob*, Link_array *cols, Rational); + static void prune_loose_columns (Grob *, Link_array *cols, Rational); static void find_loose_columns (Link_array cols); static void set_explicit_neighbor_columns (Link_array cols); static void set_implicit_neighbor_columns (Link_array cols); - static void do_measure (Rational, Grob*me, Link_array *cols); - static void musical_column_spacing (Grob*, Item*, Item*, Real, Rational); - DECLARE_SCHEME_CALLBACK (set_springs, (SCM )); - static bool has_interface (Grob*); + static void do_measure (Rational, Grob *me, Link_array *cols); + static void musical_column_spacing (Grob *, Item *, Item *, Real, Rational); + DECLARE_SCHEME_CALLBACK (set_springs, (SCM)); + static bool has_interface (Grob *); }; /* Return whether COL is fixed to its neighbors by some kind of spacing constraint. - + If in doubt, then we're not loose; the spacing engine should space for it, risking suboptimal spacing. - - (Otherwise, we might risk core dumps, and other weird stuff.) + (Otherwise, we might risk core dumps, and other weird stuff.) */ static bool -loose_column (Grob *l, Grob *c, Grob *r) +loose_column (Grob *l, Grob *c, Grob *r) { SCM rns = c->get_property ("right-neighbors"); SCM lns = c->get_property ("left-neighbors"); - /* + /* If this column doesn't have a proper neighbor, we should really make it loose, but spacing it correctly is more than we can currently can handle. (this happens in the following situation: - | - | clef G - * + | + | clef G + * - | | || - | | || - O O || + | | || + | | || + O O || the column containing the clef is really loose, and should be attached right to the first column, but that is a lot of work for such a borderline case.) - - */ + + */ if (!scm_is_pair (lns) || !scm_is_pair (rns)) return false; - Item * l_neighbor = dynamic_cast (unsmob_grob (scm_car (lns))); - Item * r_neighbor = dynamic_cast (unsmob_grob (scm_car (rns))); + Item *l_neighbor = dynamic_cast (unsmob_grob (scm_car (lns))); + Item *r_neighbor = dynamic_cast (unsmob_grob (scm_car (rns))); if (!l_neighbor || !r_neighbor) return false; l_neighbor = l_neighbor->get_column (); - r_neighbor = dynamic_cast (Note_spacing::right_column (r_neighbor)); + r_neighbor = dynamic_cast (Note_spacing::right_column (r_neighbor)); if (l == l_neighbor && r == r_neighbor) return false; @@ -112,28 +108,25 @@ loose_column (Grob *l, Grob *c, Grob *r) if (!l_neighbor || !r_neighbor) return false; - - /* Only declare loose if the bounds make a little sense. This means some cases (two isolated, consecutive clef changes) won't be nicely folded, but hey, then don't do that. */ - if (! ((Paper_column::is_musical (l_neighbor) || Item::is_breakable (l_neighbor)) - && (Paper_column::is_musical (r_neighbor) || Item::is_breakable (r_neighbor))) ) + if (! ((Paper_column::is_musical (l_neighbor) || Item::is_breakable (l_neighbor)) + && (Paper_column::is_musical (r_neighbor) || Item::is_breakable (r_neighbor)))) { return false; } - /* A rather hairy check, but we really only want to move around clefs. (anything else?) in any case, we don't want to move bar lines. - */ + */ for (SCM e = c->get_property ("elements"); scm_is_pair (e); e = scm_cdr (e)) { - Grob * g = unsmob_grob (scm_car (e)); + Grob *g = unsmob_grob (scm_car (e)); if (g && Break_align_interface::has_interface (g)) { for (SCM s = g->get_property ("elements"); scm_is_pair (s); @@ -142,14 +135,14 @@ loose_column (Grob *l, Grob *c, Grob *r) Grob *h = unsmob_grob (scm_car (s)); /* - ugh. -- fix staff-bar name? + ugh. -- fix staff-bar name? */ - if (h && h->get_property ("break-align-symbol") == ly_symbol2scm ("staff-bar")) + if (h && h->get_property ("break-align-symbol") == ly_symbol2scm ("staff-bar")) return false; } } } - + return true; } @@ -159,11 +152,11 @@ loose_column (Grob *l, Grob *c, Grob *r) between. */ void -Spacing_spanner::prune_loose_columns (Grob*me, Link_array *cols, Rational shortest) +Spacing_spanner::prune_loose_columns (Grob *me, Link_array *cols, Rational shortest) { Link_array newcols; Real increment = robust_scm2double (me->get_property ("spacing-increment"), 1.2); - for (int i = 0; i < cols->size (); i++) + for (int i = 0; i < cols->size (); i++) { if (Item::is_breakable (cols->elem (i)) || Paper_column::is_musical (cols->elem (i))) { @@ -172,7 +165,7 @@ Spacing_spanner::prune_loose_columns (Grob*me, Link_array *cols, Rational } Grob *c = cols->elem (i); - if (loose_column (cols->elem (i-1), c, cols->elem (i+1))) + if (loose_column (cols->elem (i - 1), c, cols->elem (i + 1))) { SCM lns = c->get_property ("left-neighbors"); lns = scm_is_pair (lns) ? scm_car (lns) : SCM_BOOL_F; @@ -191,17 +184,17 @@ Spacing_spanner::prune_loose_columns (Grob*me, Link_array *cols, Rational /* Set distance constraints for loose columns */ - Drul_array next_door; + Drul_array next_door; next_door[LEFT] = cols->elem (i - 1); - next_door[RIGHT] = cols->elem (i + 1); + next_door[RIGHT] = cols->elem (i + 1); Direction d = LEFT; Drul_array dists (0, 0); do { dists[d] = 0.0; - Item *lc = dynamic_cast ((d == LEFT) ? next_door[LEFT] : c); - Item *rc = dynamic_cast (d == LEFT ? c : next_door[RIGHT]); + Item *lc = dynamic_cast ((d == LEFT) ? next_door[LEFT] : c); + Item *rc = dynamic_cast (d == LEFT ? c : next_door[RIGHT]); for (SCM s = lc->get_property ("spacing-wishes"); scm_is_pair (s); s = scm_cdr (s)) @@ -220,13 +213,13 @@ Spacing_spanner::prune_loose_columns (Grob*me, Link_array *cols, Rational /* The note spacing should be taken from the musical columns. - + */ Real base = note_spacing (me, lc, rc, shortest, &dummy); Note_spacing::get_spacing (sp, rc, base, increment, &space, &fixed); - space -= increment; - + space -= increment; + dists[d] = dists[d] >? space; } else @@ -237,15 +230,15 @@ Spacing_spanner::prune_loose_columns (Grob*me, Link_array *cols, Rational dists[d] = dists[d] >? fixed_space; } - + } } while (flip (&d) != LEFT); Rod r; r.distance_ = dists[LEFT] + dists[RIGHT]; - r.item_drul_[LEFT] = dynamic_cast (cols->elem (i-1)); - r.item_drul_[RIGHT] = dynamic_cast (cols->elem (i+1)); + r.item_drul_[LEFT] = dynamic_cast (cols->elem (i - 1)); + r.item_drul_[RIGHT] = dynamic_cast (cols->elem (i + 1)); r.add_to_cols (); } @@ -259,7 +252,7 @@ Spacing_spanner::prune_loose_columns (Grob*me, Link_array *cols, Rational } /* - Set neighboring columns determined by the spacing-wishes grob property. + Set neighboring columns determined by the spacing-wishes grob property. */ void Spacing_spanner::set_explicit_neighbor_columns (Link_array cols) @@ -270,21 +263,21 @@ Spacing_spanner::set_explicit_neighbor_columns (Link_array cols) int min_rank = 100000; // inf. - SCM wishes = cols[i]->get_property ("spacing-wishes"); + SCM wishes = cols[i]->get_property ("spacing-wishes"); for (SCM s = wishes; scm_is_pair (s); s = scm_cdr (s)) { - Item * wish = dynamic_cast (unsmob_grob (scm_car (s))); + Item *wish = dynamic_cast (unsmob_grob (scm_car (s))); - Item * lc = wish->get_column (); - Grob * right = Note_spacing::right_column (wish); + Item *lc = wish->get_column (); + Grob *right = Note_spacing::right_column (wish); if (!right) continue; - Item * rc = dynamic_cast (right); + Item *rc = dynamic_cast (right); int right_rank = Paper_column::get_rank (rc); - int left_rank = Paper_column::get_rank (lc); + int left_rank = Paper_column::get_rank (lc); /* update the left column. @@ -292,8 +285,8 @@ Spacing_spanner::set_explicit_neighbor_columns (Link_array cols) if (right_rank <= min_rank) { if (right_rank < min_rank) - right_neighbors = SCM_EOL; - + right_neighbors = SCM_EOL; + min_rank = right_rank; right_neighbors = scm_cons (wish->self_scm (), right_neighbors); } @@ -306,7 +299,7 @@ Spacing_spanner::set_explicit_neighbor_columns (Link_array cols) if (scm_is_pair (left_neighs) && unsmob_grob (scm_car (left_neighs))) { - Item * it = dynamic_cast (unsmob_grob (scm_car (left_neighs))); + Item *it = dynamic_cast (unsmob_grob (scm_car (left_neighs))); maxrank = Paper_column::get_rank (it->get_column ()); } @@ -329,14 +322,14 @@ Spacing_spanner::set_explicit_neighbor_columns (Link_array cols) /* Set neighboring columns that have no left/right-neighbor set - yet. Only do breakable non-musical columns, and musical columns. + yet. Only do breakable non-musical columns, and musical columns. */ void Spacing_spanner::set_implicit_neighbor_columns (Link_array cols) { for (int i = 0; i < cols.size (); i++) { - Item * it = dynamic_cast(cols[i]); + Item *it = dynamic_cast (cols[i]); if (!Item::is_breakable (it) && !Paper_column::is_musical (it)) continue; @@ -346,20 +339,19 @@ Spacing_spanner::set_implicit_neighbor_columns (Link_array cols) sloppy with typnig left/right-neighbors should take list, but paper-column found instead. */ SCM ln = cols[i] ->get_property ("left-neighbors"); - if (!scm_is_pair (ln) && i ) + if (!scm_is_pair (ln) && i) { - cols[i]->set_property ("left-neighbors", scm_cons (cols[i-1]->self_scm (), SCM_EOL)); + cols[i]->set_property ("left-neighbors", scm_cons (cols[i - 1]->self_scm (), SCM_EOL)); } SCM rn = cols[i] ->get_property ("right-neighbors"); - if (!scm_is_pair (rn) && i < cols.size () - 1) + if (!scm_is_pair (rn) && i < cols.size () - 1) { cols[i]->set_property ("right-neighbors", scm_cons (cols[i + 1]->self_scm (), SCM_EOL)); } } } - MAKE_SCHEME_CALLBACK (Spacing_spanner, set_springs, 1); SCM Spacing_spanner::set_springs (SCM smob) @@ -388,23 +380,21 @@ Spacing_spanner::set_springs (SCM smob) prune_loose_columns (me, &all, global_shortest); set_implicit_neighbor_columns (all); - int j = 0; for (int i = 1; i < all.size (); i++) { Grob *sc = all[i]; if (Item::is_breakable (sc)) - { - Link_array measure (all.slice (j, i+1)); - do_measure (global_shortest, me, &measure); + { + Link_array measure (all.slice (j, i + 1)); + do_measure (global_shortest, me, &measure); j = i; - } + } } return SCM_UNSPECIFIED; } - /* We want the shortest note that is also "common" in the piece, so we find the shortest in each measure, and take the most frequently @@ -413,7 +403,6 @@ Spacing_spanner::set_springs (SCM smob) This probably gives weird effects with modern music, where every note has a different duration, but hey, don't write that kind of stuff, then. - */ Rational Spacing_spanner::find_shortest (Grob *me, Link_array const &cols) @@ -421,25 +410,25 @@ Spacing_spanner::find_shortest (Grob *me, Link_array const &cols) /* ascending in duration */ - Array durations; + Array durations; Array counts; - + Rational shortest_in_measure; shortest_in_measure.set_infinite (1); - - for (int i = 0 ; i < cols.size (); i++) + + for (int i = 0; i < cols.size (); i++) { if (Paper_column::is_musical (cols[i])) { - Moment *when = unsmob_moment (cols[i]->get_property ("when")); + Moment *when = unsmob_moment (cols[i]->get_property ("when")); /* ignore grace notes for shortest notes. */ if (when && when->grace_part_) continue; - - SCM st = cols[i]->get_property ("shortest-starter-duration"); + + SCM st = cols[i]->get_property ("shortest-starter-duration"); Moment this_shortest = *unsmob_moment (st); assert (this_shortest.to_bool ()); shortest_in_measure = shortest_in_measure const &cols) counts.push (1); } - shortest_in_measure.set_infinite (1); + shortest_in_measure.set_infinite (1); } } @@ -486,13 +475,13 @@ Spacing_spanner::find_shortest (Grob *me, Link_array const &cols) // printf ("duration %d/%d, count %d\n", durations[i].num (), durations[i].den (), counts[i]); } - SCM bsd = me->get_property ("base-shortest-duration"); + SCM bsd = me->get_property ("base-shortest-duration"); Rational d = Rational (1, 8); if (Moment *m = unsmob_moment (bsd)) d = m->main_part_; - + if (max_idx >= 0) - d = d const &cols) per-measure spacing. Now we have piecewise spacing. We should fix this to support "spacing-regions": some regions have different notes (different time sigs) than others, and should be spaced differently. - */ +*/ void -Spacing_spanner::do_measure (Rational global_shortest, Grob*me, - Link_array *cols) +Spacing_spanner::do_measure (Rational global_shortest, Grob *me, + Link_array *cols) { Real headwid = robust_scm2double (me->get_property ("spacing-increment"), 1); for (int i = 0; i < cols->size () - 1; i++) { - Item * l = dynamic_cast (cols->elem (i)); - Item * r = dynamic_cast (cols->elem (i+1)); + Item *l = dynamic_cast (cols->elem (i)); + Item *r = dynamic_cast (cols->elem (i + 1)); - Paper_column * lc = dynamic_cast (l); - Paper_column * rc = dynamic_cast (r); + Paper_column *lc = dynamic_cast (l); + Paper_column *rc = dynamic_cast (r); if (!Paper_column::is_musical (l)) { breakable_column_spacing (me, l, r, global_shortest); /* - The case that the right part is broken as well is rather rare, but it is possible, eg. with a single empty measure, or if one staff finishes a tad earlier than the rest. - - */ + + */ Item *lb = l->find_prebroken_piece (RIGHT); Item *rb = r->find_prebroken_piece (LEFT); - + if (lb) breakable_column_spacing (me, lb, r, global_shortest); @@ -544,16 +532,16 @@ Spacing_spanner::do_measure (Rational global_shortest, Grob*me, musical_column_spacing (me, lc, rc, headwid, global_shortest); if (Item *rb = r->find_prebroken_piece (LEFT)) musical_column_spacing (me, lc, rb, headwid, global_shortest); - } + } } } /* Generate the space between two musical columns LC and RC, given spacing parameters INCR and SHORTEST. - */ +*/ void -Spacing_spanner::musical_column_spacing (Grob *me, Item * lc, Item *rc, Real increment, Rational global_shortest) +Spacing_spanner::musical_column_spacing (Grob *me, Item *lc, Item *rc, Real increment, Rational global_shortest) { bool expand_only = false; Real base_note_space = note_spacing (me, lc, rc, global_shortest, &expand_only); @@ -561,8 +549,8 @@ Spacing_spanner::musical_column_spacing (Grob *me, Item * lc, Item *rc, Real inc Real compound_note_space = 0.0; Real compound_fixed_note_space = 0.0; int wish_count = 0; - - SCM seq = lc->get_property ("right-neighbors"); + + SCM seq = lc->get_property ("right-neighbors"); /* We adjust the space following a note only if the next note @@ -571,7 +559,7 @@ Spacing_spanner::musical_column_spacing (Grob *me, Item * lc, Item *rc, Real inc */ for (SCM s = seq; scm_is_pair (s); s = scm_cdr (s)) { - Grob * wish = unsmob_grob (scm_car (s)); + Grob *wish = unsmob_grob (scm_car (s)); Item *wish_rcol = Note_spacing::right_column (wish); if (Note_spacing::left_column (wish) != lc @@ -585,30 +573,29 @@ Spacing_spanner::musical_column_spacing (Grob *me, Item * lc, Item *rc, Real inc { Real space = 0.0; Real fixed = 0.0; - + Note_spacing::get_spacing (wish, rc, base_note_space, increment, &space, &fixed); - compound_note_space = compound_note_space + space; compound_fixed_note_space = compound_fixed_note_space + fixed; - wish_count ++; - + wish_count++; + } } - if (Paper_column::when_mom (rc).grace_part_ && - !Paper_column::when_mom (lc).grace_part_) + if (Paper_column::when_mom (rc).grace_part_ + && !Paper_column::when_mom (lc).grace_part_) { /* Ugh. 0.8 is arbitrary. - */ - compound_note_space *= 0.8; + */ + compound_note_space *= 0.8; } - + if (compound_note_space < 0 || wish_count == 0) { compound_note_space = base_note_space; - compound_fixed_note_space = increment; + compound_fixed_note_space = increment; } else { @@ -630,7 +617,7 @@ Spacing_spanner::musical_column_spacing (Grob *me, Item * lc, Item *rc, Real inc /* TODO: make sure that the space doesn't exceed the right margin. - */ + */ if (packed) { /* @@ -651,23 +638,22 @@ Spacing_spanner::musical_column_spacing (Grob *me, Item * lc, Item *rc, Real inc distance = compound_note_space; } - Spaceable_grob::add_spring (lc, rc, distance, strength); + Spaceable_grob::add_spring (lc, rc, distance, strength); } - /* The one-size-fits all spacing. It doesn't take into account different spacing wishes from one to the next column. - */ +*/ void -Spacing_spanner::standard_breakable_column_spacing (Grob * me, Item*l, Item*r, - Real * fixed, Real * space, - Moment shortest) +Spacing_spanner::standard_breakable_column_spacing (Grob *me, Item *l, Item *r, + Real *fixed, Real *space, + Moment shortest) { *fixed = 0.0; Direction d = LEFT; - Drul_array cols (l, r); - + Drul_array cols (l, r); + do { if (!Paper_column::is_musical (cols[d])) @@ -675,14 +661,13 @@ Spacing_spanner::standard_breakable_column_spacing (Grob * me, Item*l, Item*r, /* Tied accidentals over barlines cause problems, so lets see what happens if we do this for non musical columns only. - */ + */ Interval lext = cols[d]->extent (cols [d], X_AXIS); if (!lext.is_empty ()) *fixed += -d * lext[-d]; } } while (flip (&d) != LEFT); - if (l->is_breakable (l) && r->is_breakable (r)) { @@ -690,10 +675,10 @@ Spacing_spanner::standard_breakable_column_spacing (Grob * me, Item*l, Item*r, Moment mlen (1); if (dt) mlen = *dt; - + Real incr = robust_scm2double (me->get_property ("spacing-increment"), 1); - *space = *fixed + incr * double (mlen.main_part_ / shortest.main_part_) * 0.8; + *space = *fixed + incr * double (mlen.main_part_ / shortest.main_part_) * 0.8; } else { @@ -704,8 +689,8 @@ Spacing_spanner::standard_breakable_column_spacing (Grob * me, Item*l, Item*r, /* In this case, Staff_spacing should handle the job, using dt when it is 0 is silly. - */ - *space = *fixed + 0.5; + */ + *space = *fixed + 0.5; } else { @@ -715,12 +700,11 @@ Spacing_spanner::standard_breakable_column_spacing (Grob * me, Item*l, Item*r, } } - /* Read hints from L and generate springs. */ void -Spacing_spanner::breakable_column_spacing (Grob*me, Item* l, Item *r, Moment shortest) +Spacing_spanner::breakable_column_spacing (Grob *me, Item *l, Item *r, Moment shortest) { Real compound_fixed = 0.0; Real compound_space = 0.0; @@ -733,7 +717,7 @@ Spacing_spanner::breakable_column_spacing (Grob*me, Item* l, Item *r, Moment sho for (SCM s = l->get_property ("spacing-wishes"); scm_is_pair (s); s = scm_cdr (s)) { - Item * spacing_grob = dynamic_cast (unsmob_grob (scm_car (s))); + Item *spacing_grob = dynamic_cast (unsmob_grob (scm_car (s))); if (!spacing_grob || !Staff_spacing::has_interface (spacing_grob)) continue; @@ -763,13 +747,13 @@ Spacing_spanner::breakable_column_spacing (Grob*me, Item* l, Item *r, Moment sho compound_space += space; compound_fixed += fixed_space; - wish_count ++ ; + wish_count++; } } if (compound_space <= 0.0 || !wish_count) { - standard_breakable_column_spacing (me, l, r, &compound_fixed, &compound_space , + standard_breakable_column_spacing (me, l, r, &compound_fixed, &compound_space, shortest); wish_count = 1; } @@ -782,34 +766,32 @@ Spacing_spanner::breakable_column_spacing (Grob*me, Item* l, Item *r, Moment sho assert (!isinf (compound_space)); compound_space = compound_space >? compound_fixed; - /* Hmm. we do 1/0 in the next thing. Perhaps we should check if this works on all architectures. - */ + */ /* There used to be code that changed spacing depending on raggedright setting. Ugh. - Do it more cleanly, or rename the property. - - */ + Do it more cleanly, or rename the property. + + */ Real strength = 1 / (compound_space - compound_fixed); Real distance = compound_space; Spaceable_grob::add_spring (l, r, distance, strength); } - /** - Get the measure wide ant for arithmetic spacing. - */ + Get the measure wide ant for arithmetic spacing. +*/ Real -Spacing_spanner::get_duration_space (Grob*me, Moment d, Rational shortest, bool * expand_only) +Spacing_spanner::get_duration_space (Grob *me, Moment d, Rational shortest, bool *expand_only) { Real k = robust_scm2double (me->get_property ("shortest-duration-space"), 1); Real incr = robust_scm2double (me->get_property ("spacing-increment"), 1); - + if (d < shortest) { /* @@ -825,39 +807,39 @@ Spacing_spanner::get_duration_space (Grob*me, Moment d, Rational shortest, bool mm for 8th. (white space), suggesting that we use (1.2 / 1.5)^{-log2(duration ratio)} - - */ + + */ Rational ratio = d.main_part_ / shortest; - return ((k-1) + double (ratio)) * incr; + return ((k - 1) + double (ratio)) * incr; } else { /* - John S. Gourlay. ``Spacing a Line of Music, '' Technical - Report OSU-CISRC-10/87-TR35, Department of Computer and - Information Science, The Ohio State University, 1987. - */ - Real log = log_2 (shortest); + John S. Gourlay. ``Spacing a Line of Music, '' Technical + Report OSU-CISRC-10/87-TR35, Department of Computer and + Information Science, The Ohio State University, 1987. + */ + Real log = log_2 (shortest); k -= log; Rational compdur = d.main_part_ + d.grace_part_ /Rational (3); - *expand_only = false; - + *expand_only = false; + return (log_2 (compdur) + k) * incr; } } Real -Spacing_spanner::note_spacing (Grob*me, Grob *lc, Grob *rc, - Moment shortest, bool * expand_only) +Spacing_spanner::note_spacing (Grob *me, Grob *lc, Grob *rc, + Moment shortest, bool *expand_only) { Moment shortest_playing_len = 0; SCM s = lc->get_property ("shortest-playing-duration"); if (unsmob_moment (s)) shortest_playing_len = *unsmob_moment (s); - + if (! shortest_playing_len.to_bool ()) { programming_error ("can't find a ruling note at " + Paper_column::when_mom (lc).to_string ()); @@ -865,7 +847,7 @@ Spacing_spanner::note_spacing (Grob*me, Grob *lc, Grob *rc, } Moment lwhen = Paper_column::when_mom (lc); - Moment rwhen = Paper_column::when_mom (rc); + Moment rwhen = Paper_column::when_mom (rc); Moment delta_t = rwhen - lwhen; if (!Paper_column::is_musical (rc)) @@ -874,8 +856,8 @@ Spacing_spanner::note_spacing (Grob*me, Grob *lc, Grob *rc, when toying with mmrests, it is possible to have musical column on the left and non-musical on the right, spanning several measures. - */ - + */ + Moment *dt = unsmob_moment (rc->get_property ("measure-length")); if (dt) { @@ -884,7 +866,7 @@ Spacing_spanner::note_spacing (Grob*me, Grob *lc, Grob *rc, /* The following is an extra safety measure, such that the length of a mmrest event doesn't cause havoc. - */ + */ shortest_playing_len = shortest_playing_len ? delta_t; if (delta_t.main_part_ && !lwhen.grace_part_) { @@ -916,28 +898,23 @@ Spacing_spanner::note_spacing (Grob*me, Grob *lc, Grob *rc, dist *= grace_fact; } - return dist; } - - ADD_INTERFACE (Spacing_spanner, "spacing-spanner-interface", -"The space taken by a note is dependent on its duration. Doubling a\n" -"duration adds spacing-increment to the space. The most common shortest\n" -"note gets @code{shortest-duration-space}. Notes that are even shorter are\n" -"spaced proportonial to their duration.\n" -"\n" -"Typically, the increment is the width of a black note head. In a\n" -"piece with lots of 8th notes, and some 16th notes, the eighth note\n" -"gets 2 note heads width (i.e. the space following a note is 1 note\n" -"head width) A 16th note is followed by 0.5 note head width. The\n" -"quarter note is followed by 3 NHW, the half by 4 NHW, etc.\n", - "grace-space-factor spacing-increment base-shortest-duration shortest-duration-space common-shortest-duration"); - - + "The space taken by a note is dependent on its duration. Doubling a\n" + "duration adds spacing-increment to the space. The most common shortest\n" + "note gets @code{shortest-duration-space}. Notes that are even shorter are\n" + "spaced proportonial to their duration.\n" + "\n" + "Typically, the increment is the width of a black note head. In a\n" + "piece with lots of 8th notes, and some 16th notes, the eighth note\n" + "gets 2 note heads width (i.e. the space following a note is 1 note\n" + "head width) A 16th note is followed by 0.5 note head width. The\n" + "quarter note is followed by 3 NHW, the half by 4 NHW, etc.\n", + "grace-space-factor spacing-increment base-shortest-duration shortest-duration-space common-shortest-duration"); ADD_INTERFACE (Spacing_interface, "spacing-interface", - "Something to do with line breaking and spacing. Kill this one after determining line breaks.", - ""); + "Something to do with line breaking and spacing. Kill this one after determining line breaks.", + ""); diff --git a/lily/span-arpeggio-engraver.cc b/lily/span-arpeggio-engraver.cc index 267be1b517..6f3df8c95f 100644 --- a/lily/span-arpeggio-engraver.cc +++ b/lily/span-arpeggio-engraver.cc @@ -14,15 +14,15 @@ #include "side-position-interface.hh" #include "staff-symbol-referencer.hh" -/** - Make arpeggios that span multiple staves. Catch arpeggios, and span a - Span_arpeggio over them if we find more than two arpeggios. - */ +/** + Make arpeggios that span multiple staves. Catch arpeggios, and span a + Span_arpeggio over them if we find more than two arpeggios. +*/ class Span_arpeggio_engraver : public Engraver { public: TRANSLATOR_DECLARATIONS (Span_arpeggio_engraver); - + protected: virtual void acknowledge_grob (Grob_info); virtual void process_acknowledged_grobs (); @@ -33,7 +33,6 @@ private: Link_array arpeggios_; }; - Span_arpeggio_engraver::Span_arpeggio_engraver () { span_arpeggio_ = 0; @@ -63,20 +62,20 @@ Span_arpeggio_engraver::process_acknowledged_grobs () && to_boolean (get_property ("connectArpeggios"))) { span_arpeggio_ = make_item ("Arpeggio", SCM_EOL); - + } } void Span_arpeggio_engraver::stop_translation_timestep () { - if (span_arpeggio_) + if (span_arpeggio_) { /* we do this very late, to make sure we also catch `extra' side-pos support like accidentals. - */ - for (int i = 0; i < arpeggios_.size (); i ++) + */ + for (int i = 0; i < arpeggios_.size (); i++) { for (SCM s = arpeggios_[i]->get_property ("stems"); scm_is_pair (s); s = scm_cdr (s)) @@ -91,18 +90,16 @@ Span_arpeggio_engraver::stop_translation_timestep () it transparent. */ arpeggios_[i]->set_property ("print-function", SCM_EOL); } - + span_arpeggio_ = 0; } arpeggios_.clear (); } - - ADD_TRANSLATOR (Span_arpeggio_engraver, -/* descr */ "", -/* creats*/ "Arpeggio", -/* accepts */ "", -/* acks */ "arpeggio-interface", -/* reads */ "connectArpeggios", -/* write */ ""); + /* descr */ "", + /* creats*/ "Arpeggio", + /* accepts */ "", + /* acks */ "arpeggio-interface", + /* reads */ "connectArpeggios", + /* write */ ""); diff --git a/lily/span-bar-engraver.cc b/lily/span-bar-engraver.cc index 6bfcd31c2e..879477420c 100644 --- a/lily/span-bar-engraver.cc +++ b/lily/span-bar-engraver.cc @@ -11,15 +11,14 @@ #include "span-bar.hh" #include "engraver.hh" -/** +/** - Make bars that span multiple "staves". Catch bars, and span a - Span_bar over them if we find more than 2 bars. Vertical alignment - of staves changes the appearance of spanbars. It is up to the - aligner (Vertical_align_engraver, in this case, to add extra - dependencies to the spanbars. - - */ +Make bars that span multiple "staves". Catch bars, and span a +Span_bar over them if we find more than 2 bars. Vertical alignment +of staves changes the appearance of spanbars. It is up to the +aligner (Vertical_align_engraver, in this case, to add extra +dependencies to the spanbars. +*/ class Span_bar_engraver : public Engraver { Item *spanbar_; @@ -43,15 +42,15 @@ Span_bar_engraver::acknowledge_grob (Grob_info i) int depth = i.origin_contexts (this).size (); if (depth && Bar_line::has_interface (i.grob_)) { - Item * it = dynamic_cast (i.grob_); + Item *it = dynamic_cast (i.grob_); bars_.push (it); - if (bars_.size () >= 2 && !spanbar_) + if (bars_.size () >= 2 && !spanbar_) { spanbar_ = make_item ("SpanBar", SCM_EOL); spanbar_->set_parent (bars_[0], X_AXIS); - + } } } @@ -59,28 +58,26 @@ Span_bar_engraver::acknowledge_grob (Grob_info i) void Span_bar_engraver::stop_translation_timestep () { - if (spanbar_) + if (spanbar_) { - for (int i = 0; i < bars_.size () ; i++) + for (int i = 0; i < bars_.size (); i++) Span_bar::add_bar (spanbar_, bars_[i]); SCM vissym = ly_symbol2scm ("break-visibility"); - SCM vis = bars_[0]->internal_get_property (vissym); + SCM vis = bars_[0]->internal_get_property (vissym); if (ly_c_equal_p (spanbar_->internal_get_property (vissym), vis)) spanbar_->internal_set_property (vissym, vis); - spanbar_ = 0; } bars_.set_size (0); } - ADD_TRANSLATOR (Span_bar_engraver, -/* descr */ "This engraver makes cross-staff barlines: It catches all normal " -"bar lines, and draws a single span-bar across them.", -/* creats*/ "SpanBar", -/* accepts */ "", -/* acks */ "bar-line-interface", -/* reads */ "", -/* write */ ""); + /* descr */ "This engraver makes cross-staff barlines: It catches all normal " + "bar lines, and draws a single span-bar across them.", + /* creats*/ "SpanBar", + /* accepts */ "", + /* acks */ "bar-line-interface", + /* reads */ "", + /* write */ ""); diff --git a/lily/span-bar.cc b/lily/span-bar.cc index 052808adb9..2d76103c38 100644 --- a/lily/span-bar.cc +++ b/lily/span-bar.cc @@ -17,9 +17,9 @@ #include "bar-line.hh" void -Span_bar::add_bar (Grob*me, Grob*b) +Span_bar::add_bar (Grob *me, Grob *b) { - Pointer_group_interface::add_grob (me, ly_symbol2scm ("elements"), b); + Pointer_group_interface::add_grob (me, ly_symbol2scm ("elements"), b); me->add_dependency (b); } @@ -28,24 +28,24 @@ MAKE_SCHEME_CALLBACK (Span_bar, print, 1); /* Limitations/Bugs: - (1) Elements from 'me->get_property ("elements")' must be - ordered according to their y coordinates relative to their common - axis group parent. Otherwise, the computation goes mad. +(1) Elements from 'me->get_property ("elements")' must be +ordered according to their y coordinates relative to their common +axis group parent. Otherwise, the computation goes mad. - (TODO: - apply a sort algorithm that ensures this precondition.) However, - until now, I have seen no case where lily has not fulfilled this - precondition. +(TODO: +apply a sort algorithm that ensures this precondition.) However, +until now, I have seen no case where lily has not fulfilled this +precondition. - (2) This method depends on bar_engraver not being removed from - staff context. If bar_engraver is removed, the size of the staff - lines is evaluated as 0, which results in a solid span bar line - with faulty y coordinate. */ +(2) This method depends on bar_engraver not being removed from +staff context. If bar_engraver is removed, the size of the staff +lines is evaluated as 0, which results in a solid span bar line +with faulty y coordinate. */ /* This routine was originally by Juergen Reuter, but it was a on the bulky side. Rewritten by Han-Wen. */ SCM -Span_bar::print (SCM smobbed_me) +Span_bar::print (SCM smobbed_me) { Grob *me = unsmob_grob (smobbed_me); SCM first_elt = me->get_property ("elements"); @@ -63,10 +63,10 @@ Span_bar::print (SCM smobbed_me) SCM glyph = me->get_property ("glyph"); /* glyph may not be a string, when ME is killed by Hara Kiri in - between. */ + between. */ if (!scm_is_string (glyph)) return SCM_EOL; - + String glyph_string = ly_scm2string (glyph); /* compose span_bar_mol */ @@ -79,12 +79,12 @@ Span_bar::print (SCM smobbed_me) Grob *staff_bar = unsmob_grob (smobbed_staff_bar); Interval ext = staff_bar->extent (refp, Y_AXIS); if (ext.is_empty ()) - continue; - + continue; + if (!prev_extent.is_empty ()) { Interval l (prev_extent [UP], - ext[DOWN]); + ext[DOWN]); if (l.is_empty ()) { @@ -93,8 +93,8 @@ Span_bar::print (SCM smobbed_me) else { Stencil interbar = Bar_line::compound_barline (staff_bar, - glyph_string, - l.length ()); + glyph_string, + l.length ()); interbar.translate_axis (l.center (), Y_AXIS); span_bar_mol.add_stencil (interbar); } @@ -104,7 +104,7 @@ Span_bar::print (SCM smobbed_me) span_bar_mol.translate_axis (- me->relative_coordinate (refp, Y_AXIS), Y_AXIS); - + return span_bar_mol.smobbed_copy (); } @@ -121,7 +121,7 @@ Span_bar::width_callback (SCM element_smob, SCM scm_axis) urg. */ Stencil m = Bar_line::compound_barline (se, gl, 40 PT); - + return ly_interval2scm (m.extent (X_AXIS)); } @@ -129,7 +129,7 @@ MAKE_SCHEME_CALLBACK (Span_bar, before_line_breaking, 1); SCM Span_bar::before_line_breaking (SCM smob) { - Grob * g = unsmob_grob (smob); + Grob *g = unsmob_grob (smob); evaluate_empty (g); evaluate_glyph (g); @@ -150,19 +150,19 @@ Span_bar::center_on_spanned_callback (SCM element_smob, SCM axis) Interval i (get_spanned_interval (me)); /* Bar_line::print delivers a barline of y-extent (-h/2, h/2), so - we have to translate ourselves to be in the center of the + we have to translate ourselves to be in the center of the interval that we span. */ if (i.is_empty ()) { me->suicide (); return scm_make_real (0.0); } - + return scm_make_real (i.center ()); } void -Span_bar::evaluate_empty (Grob*me) +Span_bar::evaluate_empty (Grob *me) { /* TODO: filter all hara-kiried out of ELEMENS list, and then optionally do suicide. Call this cleanage function from @@ -174,13 +174,13 @@ Span_bar::evaluate_empty (Grob*me) } void -Span_bar::evaluate_glyph (Grob*me) +Span_bar::evaluate_glyph (Grob *me) { SCM gl = me->get_property ("glyph"); if (scm_is_string (gl)) - return ; - + return; + for (SCM s = me->get_property ("elements"); !scm_is_string (gl) && scm_is_pair (s); s = scm_cdr (s)) { @@ -193,9 +193,9 @@ Span_bar::evaluate_glyph (Grob*me) me->suicide (); return; } - + String type = ly_scm2string (gl); - if (type == "|:") + if (type == "|:") { type = ".|"; } @@ -215,18 +215,17 @@ Span_bar::evaluate_glyph (Grob*me) } Interval -Span_bar::get_spanned_interval (Grob*me) +Span_bar::get_spanned_interval (Grob *me) { return ly_scm2interval (Axis_group_interface::group_extent_callback - (me->self_scm (), scm_int2num (Y_AXIS))); + (me->self_scm (), scm_int2num (Y_AXIS))); } - MAKE_SCHEME_CALLBACK (Span_bar, get_bar_size, 1); SCM Span_bar::get_bar_size (SCM smob) { - Grob* me = unsmob_grob (smob); + Grob *me = unsmob_grob (smob); Interval iv (get_spanned_interval (me)); if (iv.is_empty ()) { @@ -237,11 +236,8 @@ Span_bar::get_bar_size (SCM smob) return scm_make_real (iv.length ()); } - - ADD_INTERFACE (Span_bar, "span-bar-interface", - "A bar line that spanned between other barlines. This interface is " + "A bar line that spanned between other barlines. This interface is " " used for bar lines that connect different staves.", - "elements"); - + "elements"); diff --git a/lily/span-dynamic-performer.cc b/lily/span-dynamic-performer.cc index 1b11fba6e7..175c1da92f 100644 --- a/lily/span-dynamic-performer.cc +++ b/lily/span-dynamic-performer.cc @@ -12,33 +12,33 @@ /* TODO: fold this into 1 engraver: \< and \> should also stop when absdyn is encountered. - */ +*/ struct Audio_dynamic_tuple { - Audio_dynamic* audio_; + Audio_dynamic *audio_; Moment mom_; }; /** perform span-dynamics - */ +*/ class Span_dynamic_performer : public Performer { public: TRANSLATOR_DECLARATIONS (Span_dynamic_performer); protected: - virtual bool try_music (Music*); + virtual bool try_music (Music *); virtual void acknowledge_audio_element (Audio_element_info); virtual void process_music (); virtual void stop_translation_timestep (); private: - Audio_dynamic* audio_; + Audio_dynamic *audio_; Real last_volume_; - Music* span_start_event_; - Drul_array span_events_; + Music *span_start_event_; + Drul_array span_events_; Array dynamic_tuples_; Array finished_dynamic_tuples_; Direction dir_; @@ -57,7 +57,7 @@ Span_dynamic_performer::Span_dynamic_performer () void Span_dynamic_performer::acknowledge_audio_element (Audio_element_info i) { - if (Audio_dynamic * d = dynamic_cast (i.elem_)) + if (Audio_dynamic *d = dynamic_cast (i.elem_)) { last_volume_ = d->volume_; } @@ -76,7 +76,7 @@ Span_dynamic_performer::process_music () Audio_dynamic_tuple a = { audio_, now_mom () }; dynamic_tuples_.push (a); } - + if (span_events_[STOP]) { if (!span_start_event_) @@ -95,20 +95,20 @@ Span_dynamic_performer::process_music () if (span_events_[START]) { - dir_ = (span_events_[START]->is_mus_type ("crescendo-event")) + dir_ = (span_events_[START]->is_mus_type ("crescendo-event")) ? RIGHT : LEFT; span_start_event_ = span_events_[START]; - + dynamic_tuples_.clear (); Audio_dynamic_tuple a = { audio_, now_mom () }; dynamic_tuples_.push (a); } if (span_events_[STOP]) - { + { finished_dynamic_tuples_.top ().audio_->volume_ = last_volume_; } - + if (span_events_[START]) { dynamic_tuples_[0].audio_->volume_ = last_volume_; @@ -130,26 +130,26 @@ Span_dynamic_performer::stop_translation_timestep () urg. Catch and fix the case of: - | | - x| x| - f cresc. -- -- -- -- -- pp + | | + x| x| + f cresc. -- -- -- -- -- pp - Actually, we should provide a non-displayed dynamic/volume setting, - to set volume to 'ff' just before the pp. - */ + Actually, we should provide a non-displayed dynamic/volume setting, + to set volume to 'ff' just before the pp. + */ if (!dv || sign (dv) != finished_dir_) { // urg. 20%: about two volume steps dv = (Real)finished_dir_ * 0.2; if (!start_volume) start_volume = finished_dynamic_tuples_.top - ().audio_->volume_ - dv; + ().audio_->volume_ - dv; } Moment start_mom = finished_dynamic_tuples_[0].mom_; Moment dt = finished_dynamic_tuples_.top ().mom_ - start_mom; for (int i = 0; i < finished_dynamic_tuples_.size (); i++) { - Audio_dynamic_tuple* a = &finished_dynamic_tuples_[i]; + Audio_dynamic_tuple *a = &finished_dynamic_tuples_[i]; Real volume = start_volume + dv * (Real) (a->mom_ - start_mom).main_part_ / (Real)dt.main_part_; a->audio_->volume_ = volume; @@ -169,7 +169,7 @@ Span_dynamic_performer::stop_translation_timestep () } bool -Span_dynamic_performer::try_music (Music* r) +Span_dynamic_performer::try_music (Music *r) { if (r->is_mus_type ("crescendo-event") || r->is_mus_type ("decrescendo-event")) @@ -181,6 +181,6 @@ Span_dynamic_performer::try_music (Music* r) return false; } ADD_TRANSLATOR (Span_dynamic_performer, - "", "", - "crescendo-event decrescendo-event", - "", "", ""); + "", "", + "crescendo-event decrescendo-event", + "", "", ""); diff --git a/lily/spanner.cc b/lily/spanner.cc index 842d706e6d..0a72592b32 100644 --- a/lily/spanner.cc +++ b/lily/spanner.cc @@ -10,7 +10,7 @@ #include -#include +#include #include "warn.hh" #include "paper-column.hh" @@ -20,9 +20,7 @@ #include "system.hh" #include "group-interface.hh" - - -Grob * +Grob * Spanner::clone (int count) const { return new Spanner (*this, count); @@ -32,29 +30,29 @@ void Spanner::do_break_processing () { //break_into_pieces - Item * left = spanned_drul_[LEFT]; - Item * right = spanned_drul_[RIGHT]; + Item *left = spanned_drul_[LEFT]; + Item *right = spanned_drul_[RIGHT]; if (!left || !right) return; - + /* Check if our parent in X-direction spans equally wide or wider than we do. - */ - for (int a = X_AXIS; a < NO_AXES; a ++) + */ + for (int a = X_AXIS; a < NO_AXES; a++) { - if (Spanner* parent = dynamic_cast (get_parent ((Axis)a))) + if (Spanner *parent = dynamic_cast (get_parent ((Axis)a))) { if (!parent->spanned_rank_iv ().superset (this->spanned_rank_iv ())) { programming_error (to_string ("Spanner `%s' is not fully contained in parent spanner `%s'.", - name ().to_str0 (), - parent->name ().to_str0 ())); + name ().to_str0 (), + parent->name ().to_str0 ())); } } } - + if (get_system () || is_broken ()) return; @@ -66,16 +64,16 @@ Spanner::do_break_processing () Direction d = LEFT; do { - Item* bound = left->find_prebroken_piece (d); + Item *bound = left->find_prebroken_piece (d); if (!bound) programming_error ("no broken bound"); else if (bound->get_system ()) { - Spanner * span = dynamic_cast (clone (broken_intos_.size ())); + Spanner *span = dynamic_cast (clone (broken_intos_.size ())); span->set_bound (LEFT, bound); span->set_bound (RIGHT, bound); - assert (span->get_system ()); + assert (span->get_system ()); span->get_system ()->typeset_grob (span); broken_intos_.push (span); } @@ -89,10 +87,10 @@ Spanner::do_break_processing () break_points.insert (left, 0); break_points.push (right); - for (int i =1; i < break_points.size (); i++) + for (int i =1; i < break_points.size (); i++) { - Drul_array bounds; - bounds[LEFT] = break_points[i-1]; + Drul_array bounds; + bounds[LEFT] = break_points[i - 1]; bounds[RIGHT] = break_points[i]; Direction d = LEFT; do @@ -102,18 +100,18 @@ Spanner::do_break_processing () } while ((flip (&d))!= LEFT); - if (!bounds[LEFT] || ! bounds[RIGHT]) + if (!bounds[LEFT] || ! bounds[RIGHT]) { programming_error ("bounds of this piece aren't breakable. "); - continue; + continue; } - Spanner *span = dynamic_cast (clone (broken_intos_.size ())); + Spanner *span = dynamic_cast (clone (broken_intos_.size ())); span->set_bound (LEFT, bounds[LEFT]); span->set_bound (RIGHT, bounds[RIGHT]); - if (!bounds[LEFT]->get_system () - + if (!bounds[LEFT]->get_system () + || !bounds[RIGHT]->get_system () || bounds[LEFT]->get_system () != bounds[RIGHT]->get_system ()) { @@ -142,13 +140,13 @@ void Spanner::set_my_columns () { Direction i = (Direction) LEFT; - do + do { if (!spanned_drul_[i]->get_system ()) set_bound (i, spanned_drul_[i]->find_prebroken_piece ((Direction) -i)); - } + } while (flip (&i) != LEFT); -} +} Interval_t Spanner::spanned_rank_iv () @@ -162,8 +160,7 @@ Spanner::spanned_rank_iv () return iv; } - -Item* +Item * Spanner::get_bound (Direction d) const { return spanned_drul_ [d]; @@ -174,21 +171,21 @@ Spanner::get_bound (Direction d) const X-axis parent of THIS to S. */ void -Spanner::set_bound (Direction d, Grob*s) +Spanner::set_bound (Direction d, Grob *s) { - Item * i = dynamic_cast (s); + Item *i = dynamic_cast (s); if (!i) { programming_error ("Must have Item for spanner bound."); return; } - + spanned_drul_[d] = i; /** We check for System to prevent the column -> line_of_score -> column -> line_of_score -> etc situation */ - if (d == LEFT && !dynamic_cast (this)) + if (d == LEFT && !dynamic_cast (this)) { set_parent (i, X_AXIS); } @@ -199,15 +196,15 @@ Spanner::set_bound (Direction d, Grob*s) [maybe we should try keeping all columns alive?, and perhaps inherit position from their (non-)musical brother] - + */ - if (dynamic_cast (i)) + if (dynamic_cast (i)) { - Pointer_group_interface::add_grob (i, ly_symbol2scm ("bounded-by-me"), this); + Pointer_group_interface::add_grob (i, ly_symbol2scm ("bounded-by-me"), this); } } -Spanner::Spanner (SCM s, Object_key const*key) +Spanner::Spanner (SCM s, Object_key const *key) : Grob (s, key) { break_index_ = 0; @@ -225,14 +222,14 @@ Spanner::Spanner (Spanner const &s, int count) Real Spanner::spanner_length () const -{ +{ Real l = spanned_drul_[LEFT]->relative_coordinate (0, X_AXIS); Real r = spanned_drul_[RIGHT]->relative_coordinate (0, X_AXIS); if (r< l) programming_error ("spanner with negative length"); - return r-l; + return r - l; } System * @@ -245,23 +242,21 @@ Spanner::get_system () const return spanned_drul_[LEFT]->get_system (); } - -Grob* -Spanner::find_broken_piece (System*l) const +Grob * +Spanner::find_broken_piece (System *l) const { - int idx = binsearch_links (broken_intos_, (Spanner*)l, Spanner::compare); - + int idx = binsearch_links (broken_intos_, (Spanner *)l, Spanner::compare); + if (idx < 0) return 0; else return broken_intos_ [idx]; } - int -Spanner::compare (Spanner * const &p1, Spanner * const &p2) +Spanner::compare (Spanner *const &p1, Spanner *const &p2) { - return p1->get_system ()->rank_ - p2->get_system ()->rank_; + return p1->get_system ()->rank_ - p2->get_system ()->rank_; } bool @@ -270,7 +265,6 @@ Spanner::is_broken () const return broken_intos_.size (); } - /* If this is a broken spanner, return the amount the left end is to be shifted horizontally so that the spanner starts after the initial @@ -280,14 +274,13 @@ Spanner::is_broken () const Real Spanner::get_broken_left_end_align () const { - Paper_column *sc = dynamic_cast (spanned_drul_[LEFT]->get_column ()); + Paper_column *sc = dynamic_cast (spanned_drul_[LEFT]->get_column ()); // Relevant only if left span point is first column in line - if (sc != NULL && - sc->break_status_dir () == RIGHT) + if (sc != NULL + && sc->break_status_dir () == RIGHT) { /* - We used to do a full search for the Break_align_item. But that doesn't make a difference, since the Paper_column is likely to contain only a Break_align_item. @@ -305,28 +298,27 @@ Spanner::do_derived_mark () const We'd be fucked if this is called before spanned_drul_[] is inited. */ if (status_ == ORPHAN) return SCM_EOL; - + Direction d = LEFT; do if (spanned_drul_[d]) scm_gc_mark (spanned_drul_[d]->self_scm ()); while (flip (&d) != LEFT); - for (int i = broken_intos_.size () ; i--;) + for (int i = broken_intos_.size (); i--;) scm_gc_mark (broken_intos_[i]->self_scm ()); return SCM_EOL; } - /* Set left or right bound to IT. Warning: caller should ensure that subsequent calls put in ITems that are left-to-right ordered. - */ +*/ void -add_bound_item (Spanner* sp, Grob*it) +add_bound_item (Spanner *sp, Grob *it) { if (!sp->get_bound (LEFT)) sp->set_bound (LEFT, it); @@ -334,48 +326,44 @@ add_bound_item (Spanner* sp, Grob*it) sp->set_bound (RIGHT, it); } - MAKE_SCHEME_CALLBACK (Spanner, set_spacing_rods, 1); SCM Spanner::set_spacing_rods (SCM smob) { - Grob*me = unsmob_grob (smob); + Grob *me = unsmob_grob (smob); Rod r; - Spanner*sp = dynamic_cast (me); + Spanner *sp = dynamic_cast (me); r.item_drul_[LEFT] = sp->get_bound (LEFT); r.item_drul_[RIGHT] = sp->get_bound (RIGHT); - r.distance_ = - robust_scm2double (me->get_property ("minimum-length"), 0); + r.distance_ + = robust_scm2double (me->get_property ("minimum-length"), 0); r.add_to_cols (); return SCM_UNSPECIFIED; } - /* - Return I such that SP == SP->ORIGINAL_->BROKEN_INTOS_[I]. - */ + Return I such that SP == SP->ORIGINAL_->BROKEN_INTOS_[I]. +*/ int -broken_spanner_index (Spanner * sp) +broken_spanner_index (Spanner *sp) { - Spanner * parent = dynamic_cast (sp->original_); + Spanner *parent = dynamic_cast (sp->original_); return parent->broken_intos_.find_index (sp); } - -Spanner* -unsmob_spanner (SCM s ) +Spanner * +unsmob_spanner (SCM s) { - return dynamic_cast (unsmob_grob (s)); + return dynamic_cast (unsmob_grob (s)); } ADD_INTERFACE (Spanner, - "spanner-interface", -"Some objects are horizontally spanned between objects. For\n" -"example, slur, beam, tie, etc. These grobs form a subtype called\n" -"@code{Spanner}. All spanners have two span-points (these must be\n" -"@code{Item} objects), one on the left and one on the right. The left bound is\n" -"also the X-reference point of the spanner.\n" -, - "minimum-length"); + "spanner-interface", + "Some objects are horizontally spanned between objects. For\n" + "example, slur, beam, tie, etc. These grobs form a subtype called\n" + "@code{Spanner}. All spanners have two span-points (these must be\n" + "@code{Item} objects), one on the left and one on the right. The left bound is\n" + "also the X-reference point of the spanner.\n", + "minimum-length"); diff --git a/lily/spring-smob.cc b/lily/spring-smob.cc index baf3e9eb0e..ecbeed1993 100644 --- a/lily/spring-smob.cc +++ b/lily/spring-smob.cc @@ -1,11 +1,10 @@ -/* +/* spring.cc -- implement Spring - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Han-Wen Nienhuys - - */ +*/ #include "spring.hh" #include "warn.hh" @@ -19,7 +18,6 @@ Spring_smob::Spring_smob () other_ = 0; } - IMPLEMENT_SIMPLE_SMOBS (Spring_smob); SCM @@ -33,7 +31,7 @@ Spring_smob::print_smob (SCM, SCM p, scm_print_state *) } SCM -Spring_smob::equal_p (SCM a , SCM b) +Spring_smob::equal_p (SCM a, SCM b) { return a == b? SCM_BOOL_T : SCM_BOOL_F; } diff --git a/lily/staff-collecting-engraver.cc b/lily/staff-collecting-engraver.cc index fb9ff7d639..ad8ca8546a 100644 --- a/lily/staff-collecting-engraver.cc +++ b/lily/staff-collecting-engraver.cc @@ -1,11 +1,10 @@ -/* -staff-collecting-engraver.cc -- implement Staff_collecting_engraver +/* + staff-collecting-engraver.cc -- implement Staff_collecting_engraver -source file of the GNU LilyPond music typesetter + source file of the GNU LilyPond music typesetter -(c) 2001--2005 Han-Wen Nienhuys - - */ + (c) 2001--2005 Han-Wen Nienhuys +*/ #include "staff-symbol.hh" #include "engraver.hh" @@ -21,7 +20,7 @@ public: Staff_collecting_engraver::Staff_collecting_engraver () { - + } void @@ -36,12 +35,11 @@ Staff_collecting_engraver::acknowledge_grob (Grob_info gi) } } - ADD_TRANSLATOR (Staff_collecting_engraver, -/* descr */ "Maintain the stavesFound variable", + /* descr */ "Maintain the stavesFound variable", -/* creats*/ "", -/* accepts */ "", -/* acks */ "staff-symbol-interface", -/* reads */ "stavesFound", -/* write */ "stavesFound"); + /* creats*/ "", + /* accepts */ "", + /* acks */ "staff-symbol-interface", + /* reads */ "stavesFound", + /* write */ "stavesFound"); diff --git a/lily/staff-performer.cc b/lily/staff-performer.cc index fda68819a0..902744a6cc 100644 --- a/lily/staff-performer.cc +++ b/lily/staff-performer.cc @@ -4,7 +4,7 @@ source file of the GNU LilyPond music typesetter (c) 1997--2005 Jan Nieuwenhuizen - */ +*/ #include "warn.hh" #include "audio-column.hh" @@ -14,10 +14,9 @@ #include "context.hh" /** Perform a staff. Individual notes should have their instrument - (staff-wide) set, so we override play_element () - - */ -class Staff_performer : public Performer_group_performer + (staff-wide) set, so we override play_element () +*/ +class Staff_performer : public Performer_group_performer { public: TRANSLATOR_DECLARATIONS (Staff_performer); @@ -27,23 +26,23 @@ public: String instrument_string_; protected: - virtual void play_element (Audio_element* p); + virtual void play_element (Audio_element *p); virtual void finalize (); virtual void initialize (); virtual void create_audio_elements (); virtual void stop_translation_timestep (); private: - Audio_staff* audio_staff_; - Audio_instrument* instrument_; - Audio_text* instrument_name_; - Audio_text* name_; - Audio_tempo* tempo_; + Audio_staff *audio_staff_; + Audio_instrument *instrument_; + Audio_text *instrument_name_; + Audio_text *name_; + Audio_tempo *tempo_; }; ADD_TRANSLATOR (Staff_performer, "", "", - "", - "", "", ""); + "", + "", "", ""); Staff_performer::Staff_performer () { @@ -86,7 +85,7 @@ Staff_performer::create_audio_elements () /* Have to be here before notes arrive into the staff. - */ + */ play_element (instrument_); play_element (instrument_name_); } @@ -97,9 +96,9 @@ void Staff_performer::stop_translation_timestep () { SCM proc = ly_lily_module_constant ("percussion?"); - + SCM drums = scm_call_1 (proc, ly_symbol2scm (instrument_string_.to_str0 ())); - audio_staff_->channel_ = (drums == SCM_BOOL_T ? 9 : -1 ); + audio_staff_->channel_ = (drums == SCM_BOOL_T ? 9 : -1); if (name_) { play_element (name_); @@ -123,9 +122,9 @@ Staff_performer::finalize () audio_staff_ = 0; } -String -Staff_performer::new_instrument_string () -{ +String +Staff_performer::new_instrument_string () +{ // mustn't ask Score for instrument: it will return piano! SCM minstr = get_property ("midiInstrument"); @@ -138,10 +137,10 @@ Staff_performer::new_instrument_string () return instrument_string_; } -void -Staff_performer::play_element (Audio_element* p) +void +Staff_performer::play_element (Audio_element *p) { - if (Audio_item *ai = dynamic_cast (p)) + if (Audio_item *ai = dynamic_cast (p)) { audio_staff_->add_audio_item (ai); } diff --git a/lily/staff-spacing.cc b/lily/staff-spacing.cc index 623e271766..124f19d370 100644 --- a/lily/staff-spacing.cc +++ b/lily/staff-spacing.cc @@ -1,17 +1,16 @@ -/* - staff-spacing.cc -- implement Staff_spacing - - source file of the GNU LilyPond music typesetter +/* + staff-spacing.cc -- implement Staff_spacing - (c) 2001--2005 Han-Wen Nienhuys + source file of the GNU LilyPond music typesetter + (c) 2001--2005 Han-Wen Nienhuys */ #include "staff-spacing.hh" #include -#include "paper-column.hh" +#include "paper-column.hh" #include "separation-item.hh" #include "warn.hh" #include "bar-line.hh" @@ -23,23 +22,22 @@ /* Insert some more space for the next note, in case it has a stem in the wrong direction - - */ +*/ Real -Staff_spacing::next_note_correction (Grob * me, - Grob * g, +Staff_spacing::next_note_correction (Grob *me, + Grob *g, Interval bar_size) { if (!g || !Note_column::has_interface (g)) return 0.0; - Item *col = dynamic_cast (g)->get_column (); + Item *col = dynamic_cast (g)->get_column (); Real max_corr = 0. >? (- g->extent (col, X_AXIS)[LEFT]); /* Duh. If this gets out of hand, we should invent something more generic. - */ - if (Grob * a = Note_column::accidentals (g)) + */ + if (Grob *a = Note_column::accidentals (g)) { Interval v; if (Accidental_placement::has_interface (a)) @@ -48,21 +46,21 @@ Staff_spacing::next_note_correction (Grob * me, } else v = a->extent (col, X_AXIS); - + max_corr = max_corr >? (- v[LEFT]); } - if (Grob* a = unsmob_grob (g->get_property ("arpeggio"))) + if (Grob *a = unsmob_grob (g->get_property ("arpeggio"))) { max_corr = max_corr >? (- a->extent (col, X_AXIS)[LEFT]); } - + /* Let's decrease the space a little if the problem is not located after a barline. */ if (bar_size.is_empty ()) max_corr *= 0.75; - + if (!bar_size.is_empty ()) if (Grob *stem = Note_column::get_stem (g)) { @@ -70,15 +68,15 @@ Staff_spacing::next_note_correction (Grob * me, if (d == DOWN) { Real stem_start = Stem::head_positions (stem) [DOWN]; - Real stem_end = Stem::stem_end_position (stem); + Real stem_end = Stem::stem_end_position (stem); Interval stem_posns (stem_start ? stem_start); stem_posns.intersect (bar_size); - Real corr = abs (stem_posns.length ()/7.) get_property ("stem-spacing-correction"), 1); + Real corr = abs (stem_posns.length () / 7.) get_property ("stem-spacing-correction"), 1); if (d != DOWN) corr = 0.0; @@ -88,7 +86,6 @@ Staff_spacing::next_note_correction (Grob * me, return max_corr; } - /* Y-positions that are covered by BAR_GROB, in the case that it is a barline. */ @@ -100,7 +97,7 @@ Staff_spacing::bar_y_positions (Grob *bar_grob) if (Bar_line::has_interface (bar_grob)) { SCM glyph = bar_grob->get_property ("glyph"); - + String glyph_string = scm_is_string (glyph) ? ly_scm2string (glyph) : ""; if (glyph_string.left_string (1) == "|" || glyph_string.left_string (1) == ".") { @@ -119,44 +116,43 @@ Staff_spacing::bar_y_positions (Grob *bar_grob) This is slightly convoluted, since the staffspacing grob gets pointers to the separation-items, not the note-columns or note-spacings. - - */ +*/ Real -Staff_spacing::next_notes_correction (Grob *me, Grob * last_grob) +Staff_spacing::next_notes_correction (Grob *me, Grob *last_grob) { Interval bar_size = bar_y_positions (last_grob); Real max_corr = 0.0; for (SCM s = me->get_property ("right-items"); - scm_is_pair (s); s = scm_cdr (s)) + scm_is_pair (s); s = scm_cdr (s)) { - Grob * g = unsmob_grob (scm_car (s)); + Grob *g = unsmob_grob (scm_car (s)); - max_corr = max_corr >? next_note_correction (me, g, bar_size); + max_corr = max_corr >? next_note_correction (me, g, bar_size); for (SCM t = g->get_property ("elements"); - scm_is_pair (t); t = scm_cdr (t)) + scm_is_pair (t); t = scm_cdr (t)) max_corr = max_corr >? next_note_correction (me, unsmob_grob (scm_car (t)), bar_size); - + } - + return max_corr; } void -Staff_spacing::get_spacing_params (Grob *me, Real * space, Real * fixed) +Staff_spacing::get_spacing_params (Grob *me, Real *space, Real *fixed) { *space = 1.0; *fixed = 1.0; - Grob * separation_item = 0; - Item * me_item = dynamic_cast (me); - + Grob *separation_item = 0; + Item *me_item = dynamic_cast (me); + for (SCM s = me->get_property ("left-items"); scm_is_pair (s); s = scm_cdr (s)) { - Grob * cand = unsmob_grob (scm_car (s)); + Grob *cand = unsmob_grob (scm_car (s)); if (cand && Separation_item::has_interface (cand)) - separation_item = cand ; + separation_item = cand; } // printf ("doing col %d\n" , Paper_column::get_rank (left_col)); @@ -169,30 +165,30 @@ Staff_spacing::get_spacing_params (Grob *me, Real * space, Real * fixed) Interval last_ext; Grob *last_grob = Separation_item::extremal_break_aligned_grob (separation_item, RIGHT, - &last_ext); + &last_ext); if (!last_grob) { /* TODO: - + Should insert a adjustable space here? For excercises, you might want to - use a staff without a clef in the beginning. - */ - + use a staff without a clef in the beginning. + */ + /* we used to have a warning here, but it generates a lot of spurious error messages. */ - return ; + return; } *fixed = last_ext[RIGHT]; *space = *fixed + 1.0; - + SCM alist = last_grob->get_property ("space-alist"); if (!scm_list_p (alist)) - return ; - + return; + SCM space_def = scm_sloppy_assq (ly_symbol2scm ("first-note"), alist); if (me_item->break_status_dir () == CENTER) { @@ -200,32 +196,31 @@ Staff_spacing::get_spacing_params (Grob *me, Real * space, Real * fixed) if (scm_is_pair (nndef)) space_def = nndef; } - - + if (!scm_is_pair (space_def)) { - programming_error ("Unknown prefatory spacing. "); - return; + programming_error ("Unknown prefatory spacing. "); + return; } space_def = scm_cdr (space_def); Real distance = scm_to_double (scm_cdr (space_def)); - SCM type = scm_car (space_def) ; + SCM type = scm_car (space_def); *fixed = last_ext[RIGHT]; if (type == ly_symbol2scm ("fixed-space")) { - *fixed += distance; - *space = *fixed; + *fixed += distance; + *space = *fixed; } - else if (type == ly_symbol2scm ("extra-space")) + else if (type == ly_symbol2scm ("extra-space")) { *space = *fixed + distance; } else if (type == ly_symbol2scm ("semi-fixed-space")) { - *fixed += distance / 2; - *space = *fixed + distance/2; + *fixed += distance / 2; + *space = *fixed + distance / 2; } else if (type == ly_symbol2scm ("minimum-space")) { @@ -236,13 +231,12 @@ Staff_spacing::get_spacing_params (Grob *me, Real * space, Real * fixed) *space = last_ext[LEFT] + (last_ext.length () >? distance); *fixed = *space; } - + *space += next_notes_correction (me, last_grob); } - ADD_INTERFACE (Staff_spacing, "staff-spacing-interface", "This object calculates spacing details from a " " breakable symbol (left) to another object. For example, it takes care " " of optical spacing from a bar lines to a note.", - "stem-spacing-correction left-items right-items"); + "stem-spacing-correction left-items right-items"); diff --git a/lily/staff-symbol-engraver.cc b/lily/staff-symbol-engraver.cc index d9d9fb5743..1c668ed8fe 100644 --- a/lily/staff-symbol-engraver.cc +++ b/lily/staff-symbol-engraver.cc @@ -6,7 +6,6 @@ (c) 1997--2005 Han-Wen Nienhuys */ - #include "score.hh" #include "paper-column.hh" #include "output-def.hh" @@ -15,22 +14,22 @@ #include "moment.hh" /** - Manage the staff symbol. - */ -class Staff_symbol_engraver : public Engraver { + Manage the staff symbol. +*/ +class Staff_symbol_engraver : public Engraver +{ public: TRANSLATOR_DECLARATIONS (Staff_symbol_engraver); - + protected: Spanner *span_; - + virtual ~Staff_symbol_engraver (); virtual void acknowledge_grob (Grob_info); virtual void finalize (); virtual void process_music (); }; - Staff_symbol_engraver::~Staff_symbol_engraver () { assert (!span_); @@ -47,10 +46,9 @@ Staff_symbol_engraver::process_music () if (!span_) { span_ = make_spanner ("StaffSymbol", SCM_EOL); - + span_->set_bound (LEFT, unsmob_grob (get_property ("currentCommandColumn"))); - } } @@ -71,20 +69,17 @@ Staff_symbol_engraver::acknowledge_grob (Grob_info s) } - - ADD_TRANSLATOR (Staff_symbol_engraver, -/* descr */ "Create the constellation of five (default) " -"staff lines.", -/* creats*/ "StaffSymbol", -/* accepts */ "", -/* acks */ "grob-interface", -/* reads */ "", -/* write */ ""); + /* descr */ "Create the constellation of five (default) " + "staff lines.", + /* creats*/ "StaffSymbol", + /* accepts */ "", + /* acks */ "grob-interface", + /* reads */ "", + /* write */ ""); /****************************************************************/ - class Tab_staff_symbol_engraver : public Staff_symbol_engraver { public: @@ -111,10 +106,10 @@ Tab_staff_symbol_engraver::Tab_staff_symbol_engraver () } ADD_TRANSLATOR (Tab_staff_symbol_engraver, -/* descr */ "Create a staff-symbol, but look at stringTunings for the number of lines." -"staff lines.", -/* creats*/ "StaffSymbol", -/* accepts */ "", -/* acks */ "grob-interface", -/* reads */ "stringTunings", -/* write */ ""); + /* descr */ "Create a staff-symbol, but look at stringTunings for the number of lines." + "staff lines.", + /* creats*/ "StaffSymbol", + /* accepts */ "", + /* acks */ "grob-interface", + /* reads */ "stringTunings", + /* write */ ""); diff --git a/lily/staff-symbol-referencer.cc b/lily/staff-symbol-referencer.cc index 376fea6b5d..3bc52e10d6 100644 --- a/lily/staff-symbol-referencer.cc +++ b/lily/staff-symbol-referencer.cc @@ -17,8 +17,8 @@ int Staff_symbol_referencer::line_count (Grob *me) { - Grob *st = get_staff_symbol (me); - return st ? Staff_symbol::line_count (st) : 0; + Grob *st = get_staff_symbol (me); + return st ? Staff_symbol::line_count (st) : 0; } bool @@ -30,7 +30,7 @@ Staff_symbol_referencer::on_staffline (Grob *me) /* This does not take size into account. maybe rename: on_virtual_staffline, on_staff_or_ledger_line? - */ +*/ bool Staff_symbol_referencer::on_staffline (Grob *me, int pos) { @@ -38,12 +38,12 @@ Staff_symbol_referencer::on_staffline (Grob *me, int pos) return ((pos + sz) % 2) == 0; } -Grob* +Grob * Staff_symbol_referencer::get_staff_symbol (Grob *me) { if (Staff_symbol::has_interface (me)) return me; - + SCM st = me->get_property ("staff-symbol"); return unsmob_grob (st); } @@ -88,7 +88,7 @@ Staff_symbol_referencer::get_position (Grob *me) } int -Staff_symbol_referencer::get_rounded_position (Grob*me) +Staff_symbol_referencer::get_rounded_position (Grob *me) { return int (rint (get_position (me))); } @@ -108,7 +108,6 @@ LY_DEFINE (ly_grob_staff_position, "ly:grob-staff-position", return scm_make_real (pos); } - /* should use offset callback! */ MAKE_SCHEME_CALLBACK (Staff_symbol_referencer, callback, 2); SCM @@ -165,15 +164,14 @@ Staff_symbol_referencer::staff_radius (Grob *me) int compare_position (Grob *const &a, Grob *const &b) { - return sign (Staff_symbol_referencer::get_position ((Grob*)a) - - Staff_symbol_referencer::get_position ((Grob*) b)); + return sign (Staff_symbol_referencer::get_position ((Grob *)a) + - Staff_symbol_referencer::get_position ((Grob *) b)); } ADD_INTERFACE (Staff_symbol_referencer, "staff-symbol-referencer-interface", "An object whose Y position is meant relative to a staff " "symbol. " "These usually have @code{Staff_symbol_referencer::callback} " - "in their @code{Y-offset-callbacks}. " - , + "in their @code{Y-offset-callbacks}. ", "staff-position"); diff --git a/lily/staff-symbol.cc b/lily/staff-symbol.cc index c1634ac4fe..926f1a3bac 100644 --- a/lily/staff-symbol.cc +++ b/lily/staff-symbol.cc @@ -22,12 +22,11 @@ SCM Staff_symbol::print (SCM smob) { Grob *me = unsmob_grob (smob); - Spanner* sp = dynamic_cast (me); - Grob * common + Spanner *sp = dynamic_cast (me); + Grob *common = sp->get_bound (LEFT)->common_refpoint (sp->get_bound (RIGHT), X_AXIS); - + Interval span_points (0, 0); - /* For raggedright without ragged staffs, simply set width to the linewidth. @@ -35,10 +34,10 @@ Staff_symbol::print (SCM smob) (ok -- lousy UI, since width is in staff spaces) --hwn. - */ + */ Real t = me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness")); t *= robust_scm2double (me->get_property ("thickness"), 1.0); - + Direction d = LEFT; do { @@ -49,36 +48,35 @@ Staff_symbol::print (SCM smob) don't multiply by Staff_symbol_referencer::staff_space (me), since that would make aligning staff symbols of different sizes to one right margin hell. - */ + */ span_points[RIGHT] = scm_to_double (width_scm); } else { - Item * x = sp->get_bound (d); + Item *x = sp->get_bound (d); - span_points[d] = x->relative_coordinate (common , X_AXIS); + span_points[d] = x->relative_coordinate (common, X_AXIS); if (!x->break_status_dir () && !x->extent (x, X_AXIS).is_empty ()) span_points[d] += x->extent (x, X_AXIS)[d]; } - span_points[d] -= d* t/2; + span_points[d] -= d* t / 2; } while (flip (&d) != LEFT); - int l = Staff_symbol::line_count (me); - - Real height = (l-1) * staff_space (me) /2; - Stencil a = - Lookup::horizontal_line (span_points - -me->relative_coordinate (common, X_AXIS), - t); + + Real height = (l - 1) * staff_space (me) /2; + Stencil a + = Lookup::horizontal_line (span_points + -me->relative_coordinate (common, X_AXIS), + t); Stencil m; for (int i = 0; i < l; i++) { - Stencil b(a); + Stencil b (a); b.translate_axis (height - i * staff_space (me), Y_AXIS); m.add_stencil (b); } @@ -86,13 +84,13 @@ Staff_symbol::print (SCM smob) } int -Staff_symbol::get_steps (Grob*me) +Staff_symbol::get_steps (Grob *me) { return line_count (me) * 2; } int -Staff_symbol::line_count (Grob*me) +Staff_symbol::line_count (Grob *me) { SCM c = me->get_property ("line-count"); if (scm_is_number (c)) @@ -102,29 +100,28 @@ Staff_symbol::line_count (Grob*me) } Real -Staff_symbol::staff_space (Grob*me) +Staff_symbol::staff_space (Grob *me) { return robust_scm2double (me->get_property ("staff-space"), 1.0); } Real -Staff_symbol::get_line_thickness (Grob* me) +Staff_symbol::get_line_thickness (Grob *me) { - Real lt = me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness")); + Real lt = me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness")); return robust_scm2double (me->get_property ("thickness"), 1.0) * lt; } Real -Staff_symbol::get_ledger_line_thickness (Grob * me) +Staff_symbol::get_ledger_line_thickness (Grob *me) { SCM lt_pair = me->get_property ("ledger-line-thickness"); Offset z = robust_scm2offset (lt_pair, Offset (1.0, 0.1)); - + return z[X_AXIS] * get_line_thickness (me) + z[Y_AXIS]* staff_space (me); } - ADD_INTERFACE (Staff_symbol, "staff-symbol-interface", "This spanner draws the lines of a staff. " "A staff symbol definines a vertical unit, the staff space. " @@ -132,5 +129,5 @@ ADD_INTERFACE (Staff_symbol, "staff-symbol-interface", "The center (i.e. middle line " "or space) is position 0. The length of the symbol may be set by hand " "through the @code{width} property. ", - - "ledger-line-thickness width staff-space thickness line-count"); + + "ledger-line-thickness width staff-space thickness line-count"); diff --git a/lily/stanza-number-align-engraver.cc b/lily/stanza-number-align-engraver.cc index 2d1d7c5e12..70c95f8746 100644 --- a/lily/stanza-number-align-engraver.cc +++ b/lily/stanza-number-align-engraver.cc @@ -1,12 +1,11 @@ -/* -stanza-number-align-engraver.cc -- implement +/* + stanza-number-align-engraver.cc -- implement -source file of the GNU LilyPond music typesetter + source file of the GNU LilyPond music typesetter -(c) 2004--2005 Han-Wen Nienhuys - - */ + (c) 2004--2005 Han-Wen Nienhuys +*/ #include "context.hh" #include "engraver.hh" @@ -17,10 +16,10 @@ source file of the GNU LilyPond music typesetter class Stanza_number_align_engraver : public Engraver { -public: +public: TRANSLATOR_DECLARATIONS (Stanza_number_align_engraver); -protected: +protected: Link_array lyrics_; Link_array stanza_numbers_; virtual void acknowledge_grob (Grob_info); @@ -29,14 +28,14 @@ protected: Stanza_number_align_engraver::Stanza_number_align_engraver () { - + } void Stanza_number_align_engraver::acknowledge_grob (Grob_info gi) { Grob *h = gi.grob_; - + if (h->internal_has_interface (ly_symbol2scm ("lyric-syllable-interface"))) lyrics_.push (h); else if (h->internal_has_interface (ly_symbol2scm ("stanza-number-interface"))) @@ -49,17 +48,16 @@ Stanza_number_align_engraver::stop_translation_timestep () for (int i = lyrics_.size (); i--;) for (int j = stanza_numbers_.size (); j--;) Side_position_interface::add_support (stanza_numbers_[j], lyrics_[i]); - + stanza_numbers_.clear (); lyrics_.clear (); } - ADD_TRANSLATOR (Stanza_number_align_engraver, - "This engraver ensures that stanza numbers are neatly aligned. ", - "", - "", - "stanza-number-interface lyric-syllable-interface ", - "", - ""); + "This engraver ensures that stanza numbers are neatly aligned. ", + "", + "", + "stanza-number-interface lyric-syllable-interface ", + "", + ""); diff --git a/lily/stanza-number-engraver.cc b/lily/stanza-number-engraver.cc index d27718a1c0..8d5c8fda19 100644 --- a/lily/stanza-number-engraver.cc +++ b/lily/stanza-number-engraver.cc @@ -1,10 +1,9 @@ -/* +/* lyric-number-engraver.cc -- implement Stanza_number_engraver - + source file of the GNU LilyPond music typesetter - - (c) 2000--2005 Han-Wen Nienhuys , Glen Prideaux + (c) 2000--2005 Han-Wen Nienhuys , Glen Prideaux */ #include "engraver.hh" @@ -18,7 +17,7 @@ class Stanza_number_engraver : public Engraver This is naughty, since last_stanza_ may be GCd from under us. But since we don't look at the contents, we are/should be (knock on wood) OK. - */ + */ SCM last_stanza_; public: TRANSLATOR_DECLARATIONS (Stanza_number_engraver); @@ -27,12 +26,11 @@ public: virtual void acknowledge_grob (Grob_info); }; - /* TODO: should make engraver that collects all the stanzas on a higher level, and then groups them to the side. Stanza numbers should be all aligned. - */ +*/ Stanza_number_engraver::Stanza_number_engraver () { @@ -43,18 +41,17 @@ void Stanza_number_engraver::process_music () { SCM stanza = get_property ("stanza"); - + if (scm_is_string (stanza) && stanza != last_stanza_) { last_stanza_ = stanza; - + text_ = make_item ("StanzaNumber", SCM_EOL); text_->set_property ("text", stanza); - + } } - void Stanza_number_engraver::acknowledge_grob (Grob_info inf) { @@ -71,11 +68,10 @@ Stanza_number_engraver::stop_translation_timestep () text_ = 0; } - ADD_TRANSLATOR (Stanza_number_engraver, -/* descr */ "", -/* creats*/ "StanzaNumber", -/* accepts */ "", -/* acks */ "lyric-syllable-interface", -/* reads */ "stanza", -/* write */ ""); + /* descr */ "", + /* creats*/ "StanzaNumber", + /* accepts */ "", + /* acks */ "lyric-syllable-interface", + /* reads */ "stanza", + /* write */ ""); diff --git a/lily/stem-engraver.cc b/lily/stem-engraver.cc index 63f8d78843..b7bb2b0bf0 100644 --- a/lily/stem-engraver.cc +++ b/lily/stem-engraver.cc @@ -18,20 +18,20 @@ #include "stem.hh" /** - Make stems upon receiving noteheads. - */ + Make stems upon receiving noteheads. +*/ class Stem_engraver : public Engraver { Grob *stem_; Grob *tremolo_; Music *rhythmic_ev_; Music *tremolo_ev_; - + TRANSLATOR_DECLARATIONS (Stem_engraver); protected: void make_stem (Grob_info); - + virtual void acknowledge_grob (Grob_info); virtual void stop_translation_timestep (); virtual bool try_music (Music *); @@ -55,7 +55,7 @@ Stem_engraver::make_stem (Grob_info gi) /* docme: why do we take duration-log from request, not from note head? - */ + */ int duration_log = gi.music_cause ()->duration_log (); stem_->set_property ("duration-log", scm_int2num (duration_log)); @@ -85,7 +85,7 @@ Stem_engraver::make_stem (Grob_info gi) - (duration_log > 2 ? duration_log - 2 : 0); if (tremolo_flags <= 0) { - tremolo_ev_->origin ()->warning (_("tremolo duration is too long")); + tremolo_ev_->origin ()->warning (_ ("tremolo duration is too long")); tremolo_flags = 0; } @@ -94,7 +94,7 @@ Stem_engraver::make_stem (Grob_info gi) tremolo_ = make_item ("StemTremolo", tremolo_ev_->self_scm ()); /* The number of tremolo flags is the number of flags of the - tremolo-type minus the number of flags of the note itself. */ + tremolo-type minus the number of flags of the note itself. */ tremolo_->set_property ("flag-count", scm_int2num (tremolo_flags)); tremolo_->set_parent (stem_, X_AXIS); stem_->set_property ("tremolo-flag", tremolo_->self_scm ()); @@ -111,19 +111,19 @@ Stem_engraver::acknowledge_grob (Grob_info gi) if (Rhythmic_head::get_stem (gi.grob_)) return; - Music * cause = gi.music_cause (); + Music *cause = gi.music_cause (); if (!cause) - return ; - + return; + if (!stem_) make_stem (gi); - + int duration_log = cause->duration_log (); if (Stem::duration_log (stem_) != duration_log) { // FIXME: gi.music_cause ()->origin ()->warning (_f ("Adding note head to incompatible stem (type = %d)", 1 << Stem::duration_log (stem_))); - + gi.music_cause ()->origin ()->warning (_f ("Don't you want polyphonic voices instead?")); } @@ -167,10 +167,10 @@ Stem_engraver::try_music (Music *m) } ADD_TRANSLATOR (Stem_engraver, -/* descr */ "Create stems and single-stem tremolos. It also works together with " -"the beam engraver for overriding beaming.", -/* creats*/ "Stem StemTremolo", -/* accepts */ "tremolo-event", -/* acks */ "rhythmic-head-interface", -/* reads */ "tremoloFlags stemLeftBeamCount stemRightBeamCount", -/* write */ ""); + /* descr */ "Create stems and single-stem tremolos. It also works together with " + "the beam engraver for overriding beaming.", + /* creats*/ "Stem StemTremolo", + /* accepts */ "tremolo-event", + /* acks */ "rhythmic-head-interface", + /* reads */ "tremoloFlags stemLeftBeamCount stemRightBeamCount", + /* write */ ""); diff --git a/lily/stem-tremolo.cc b/lily/stem-tremolo.cc index 813d92903b..132a30b3a2 100644 --- a/lily/stem-tremolo.cc +++ b/lily/stem-tremolo.cc @@ -1,11 +1,10 @@ -/* +/* stem-tremolo.cc -- implement Stem_tremolo - + source file of the GNU LilyPond music typesetter - + (c) 1997--2005 Han-Wen Nienhuys - - */ +*/ #include "stem-tremolo.hh" @@ -28,7 +27,7 @@ SCM Stem_tremolo::dim_callback (SCM e, SCM) { Grob *se = unsmob_grob (e); - + Real space = Staff_symbol_referencer::staff_space (se); return ly_interval2scm (Interval (-space, space)); } @@ -54,7 +53,7 @@ Stencil Stem_tremolo::raw_stencil (Grob *me) { Grob *stem = unsmob_grob (me->get_property ("stem")); - Spanner*beam = Stem::get_beam (stem); + Spanner *beam = Stem::get_beam (stem); Real dydx; if (beam) { @@ -62,10 +61,10 @@ Stem_tremolo::raw_stencil (Grob *me) SCM s = beam->get_property ("positions"); if (is_number_pair (s)) dy = -scm_to_double (scm_car (s)) +scm_to_double (scm_cdr (s)); - + Real dx = Beam::last_visible_stem (beam)->relative_coordinate (0, X_AXIS) - Beam::first_visible_stem (beam)->relative_coordinate (0, X_AXIS); - dydx = dx ? dy/dx : 0; + dydx = dx ? dy / dx : 0; } else // urg @@ -78,10 +77,10 @@ Stem_tremolo::raw_stencil (Grob *me) width *= ss; thick *= ss; - + Stencil a (Lookup::beam (dydx, width, thick, blot)); a.translate (Offset (-width * 0.5, width * 0.5 * dydx)); - + int tremolo_flags = 0; SCM s = me->get_property ("flag-count"); if (scm_is_number (s)) @@ -98,7 +97,7 @@ Stem_tremolo::raw_stencil (Grob *me) /* Who the fuck is 0.81 ? --hwn. */ Real beam_translation = beam ? Beam::get_beam_translation (beam) : 0.81; - Stencil mol; + Stencil mol; for (int i = 0; i < tremolo_flags; i++) { Stencil b (a); @@ -110,7 +109,7 @@ Stem_tremolo::raw_stencil (Grob *me) MAKE_SCHEME_CALLBACK (Stem_tremolo, print, 1); SCM -Stem_tremolo::print (SCM grob) +Stem_tremolo::print (SCM grob) { Grob *me = unsmob_grob (grob); Grob *stem = unsmob_grob (me->get_property ("stem")); @@ -119,7 +118,7 @@ Stem_tremolo::print (SCM grob) programming_error ("No stem for stem-tremolo"); return SCM_EOL; } - + Spanner *beam = Stem::get_beam (stem); Direction stemdir = Stem::get_direction (stem); if (stemdir == 0) @@ -138,7 +137,7 @@ Stem_tremolo::print (SCM grob) int beam_count = beam ? (Stem::beam_multiplicity (stem).length () + 1) : 0; Real beamthickness = 0.0; - SCM sbt = (beam) ? beam->get_property ("thickness") : SCM_EOL ; + SCM sbt = (beam) ? beam->get_property ("thickness") : SCM_EOL; if (scm_is_number (sbt)) beamthickness = scm_to_double (sbt) * ss; @@ -171,8 +170,6 @@ Stem_tremolo::print (SCM grob) return mol.smobbed_copy (); } - - ADD_INTERFACE (Stem_tremolo, "stem-tremolo-interface", - "A beam slashing a stem to indicate a tremolo.", - "stem beam-width beam-thickness flag-count"); + "A beam slashing a stem to indicate a tremolo.", + "stem beam-width beam-thickness flag-count"); diff --git a/lily/stem.cc b/lily/stem.cc index 07fe670290..0f227b4c94 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -4,7 +4,7 @@ source file of the GNU LilyPond music typesetter (c) 1996--2005 Han-Wen Nienhuys - Jan Nieuwenhuizen + Jan Nieuwenhuizen TODO: This is way too hairy @@ -62,13 +62,12 @@ Stem::get_beaming (Grob *me, Direction d) return scm_ilength (lst); } - Interval Stem::head_positions (Grob *me) { if (head_count (me)) { - Drul_array e (extremal_heads (me)); + Drul_array e (extremal_heads (me)); return Interval (Staff_symbol_referencer::get_position (e[DOWN]), Staff_symbol_referencer::get_position (e[UP])); } @@ -162,16 +161,15 @@ Stem::last_head (Grob *me) Direction d = get_direction (me); if (d) return extremal_heads (me)[d]; - return 0; + return 0; } /* START is part where stem reaches `last' head. - This function returns a drul with (bottom-head, top-head). - + This function returns a drul with (bottom-head, top-head). */ -Drul_array +Drul_array Stem::extremal_heads (Grob *me) { const int inf = 1000000; @@ -194,7 +192,9 @@ Stem::extremal_heads (Grob *me) exthead[d] = n; extpos[d] = p; } - } while (flip (&d) != DOWN); + } + while (flip (&d) != DOWN); + } return exthead; } @@ -209,7 +209,7 @@ integer_compare (int const &a, int const &b) Array Stem::note_head_positions (Grob *me) { - Array ps ; + Array ps; for (SCM s = me->get_property ("note-heads"); scm_is_pair (s); s = scm_cdr (s)) { @@ -240,7 +240,7 @@ Stem::is_invisible (Grob *me) { Real stemlet_length = robust_scm2double (me->get_property ("stemlet-length"), 0.0); - + return !((head_count (me) || stemlet_length > 0.0) && scm_to_int (me->get_property ("duration-log")) >= 1); @@ -254,8 +254,8 @@ Stem::get_default_dir (Grob *me) if (hp.is_empty ()) return CENTER; - int udistance = (int) (UP * hp[UP] - staff_center); - int ddistance = (int) (DOWN * hp[DOWN] - staff_center); + int udistance = (int) (UP *hp[UP] - staff_center); + int ddistance = (int) (DOWN *hp[DOWN] - staff_center); if (sign (ddistance - udistance)) return Direction (sign (ddistance - udistance)); @@ -315,11 +315,11 @@ Stem::get_default_stem_end_position (Grob *me) { /* Crude hack: add extra space if tremolo flag is there. - We can't do this for the beam, since we get into a loop - (Stem_tremolo::raw_stencil () looks at the beam.) --hwn */ + We can't do this for the beam, since we get into a loop + (Stem_tremolo::raw_stencil () looks at the beam.) --hwn */ Real minlen = 1.0 - + 2 * Stem_tremolo::raw_stencil (t_flag).extent (Y_AXIS).length () + + 2 * Stem_tremolo::raw_stencil (t_flag).extent (Y_AXIS).length () / ss; if (durlog >= 3) @@ -349,9 +349,9 @@ Stem::get_default_stem_end_position (Grob *me) if (!get_beam (me) && dir == UP && durlog > 2) { - Grob * closest_to_flag = extremal_heads (me)[dir]; - Grob * dots = closest_to_flag - ? Rhythmic_head::get_dots (closest_to_flag ) : 0; + Grob *closest_to_flag = extremal_heads (me)[dir]; + Grob *dots = closest_to_flag + ? Rhythmic_head::get_dots (closest_to_flag) : 0; if (dots) { @@ -392,8 +392,8 @@ Stem::position_noteheads (Grob *me) if (!head_count (me)) return; - Link_array heads = - extract_grob_array (me, ly_symbol2scm ("note-heads")); + Link_array heads + = extract_grob_array (me, ly_symbol2scm ("note-heads")); heads.sort (compare_position); Direction dir = get_direction (me); @@ -411,16 +411,16 @@ Stem::position_noteheads (Grob *me) bool parity = true; Real lastpos = Real (Staff_symbol_referencer::get_position (heads[0])); - for (int i = 1; i < heads.size (); i ++) + for (int i = 1; i < heads.size (); i++) { Real p = Staff_symbol_referencer::get_position (heads[i]); Real dy = fabs (lastpos- p); /* - dy should always be 0.5, 0.0, 1.0, but provide safety margin - for rounding errors. + dy should always be 0.5, 0.0, 1.0, but provide safety margin + for rounding errors. */ - if (dy < 1.1) + if (dy < 1.1) { if (parity) { @@ -444,18 +444,18 @@ Stem::position_noteheads (Grob *me) heads[i]->translate_axis (-thick * (2 - reverse_overlap) * d, X_AXIS); - /* TODO: - + /* TODO: + For some cases we should kern some more: when the distance between the next or prev note is too large, we'd get large white gaps, eg. - - | + + | X| - |X <- kern this. - | + |X <- kern this. + | X - + */ } parity = !parity; @@ -476,13 +476,13 @@ Stem::before_line_breaking (SCM smob) /* Do the calculations for visible stems, but also for invisible stems with note heads (i.e. half notes.) - */ + */ if (head_count (me)) { stem_end_position (me); // ugh. Trigger direction calc. position_noteheads (me); } - + return SCM_UNSPECIFIED; } @@ -490,7 +490,7 @@ Stem::before_line_breaking (SCM smob) ugh. When in a beam with tuplet brackets, brew_mol is called early, caching a wrong value. - */ +*/ MAKE_SCHEME_CALLBACK (Stem, height, 2); SCM Stem::height (SCM smob, SCM ax) @@ -520,13 +520,12 @@ Stem::height (SCM smob, SCM ax) programming_error ("No stem direction"); d = UP; } - iv[d] += d * Beam::get_thickness (b) * 0.5 ; + iv[d] += d * Beam::get_thickness (b) * 0.5; } return ly_interval2scm (iv); } - Stencil Stem::flag (Grob *me) { @@ -538,7 +537,7 @@ Stem::flag (Grob *me) SCM flag_style_scm = me->get_property ("flag-style"); if (scm_is_symbol (flag_style_scm)) flag_style = ly_symbol2string (flag_style_scm); - + if (flag_style == "no-flag") return Stencil (); @@ -556,9 +555,9 @@ Stem::flag (Grob *me) { if (adjust) { - int p = (int)(rint (stem_end_position (me))); - staffline_offs = - Staff_symbol_referencer::on_staffline (me, p) ? "0" : "1"; + int p = (int) (rint (stem_end_position (me))); + staffline_offs + = Staff_symbol_referencer::on_staffline (me, p) ? "0" : "1"; } else { @@ -605,21 +604,21 @@ Stem::width_callback (SCM e, SCM ax) Grob *me = unsmob_grob (e); Interval r; - + if (is_invisible (me)) { r.set_empty (); - } + } else if (unsmob_grob (me->get_property ("beam")) || abs (duration_log (me)) <= 2) { r = Interval (-1, 1); - r *= thickness (me)/2; + r *= thickness (me) / 2; } else { r = flag (me).extent (X_AXIS) - + thickness (me)/2; - } + + thickness (me) / 2; + } return ly_interval2scm (r); } @@ -641,11 +640,11 @@ Stem::print (SCM smob) Real stemlet_length = robust_scm2double (me->get_property ("stemlet-length"), 0.0); bool stemlet = stemlet_length > 0.0; - + /* TODO: make the stem start a direction ? This is required to avoid stems passing in tablature chords. */ - Grob *lh = - to_boolean (me->get_property ("avoid-note-head")) + Grob *lh + = to_boolean (me->get_property ("avoid-note-head")) ? last_head (me) : first_head (me); Grob *beam = get_beam (me); @@ -655,7 +654,7 @@ Stem::print (SCM smob) if (!lh && stemlet && !beam) return SCM_EOL; - + if (is_invisible (me)) return SCM_EOL; @@ -663,7 +662,6 @@ Stem::print (SCM smob) Real y1 = y2; Real half_space = Staff_symbol_referencer::staff_space (me) * 0.5; - if (lh) y2 = Staff_symbol_referencer::get_position (lh); else if (stemlet) @@ -684,21 +682,20 @@ Stem::print (SCM smob) { /* must not take ledgers into account. - */ + */ Interval head_height = hed->extent (hed, Y_AXIS); Real y_attach = Note_head::stem_attachment_coordinate (hed, Y_AXIS); y_attach = head_height.linear_combination (y_attach); - stem_y[Direction (-d)] += d * y_attach/half_space; + stem_y[Direction (-d)] += d * y_attach / half_space; } - // URG Real stem_width = thickness (me); - Real blot = - me->get_layout ()->get_dimension (ly_symbol2scm ("blotdiameter")); + Real blot + = me->get_layout ()->get_dimension (ly_symbol2scm ("blotdiameter")); - Box b = Box (Interval (-stem_width/2, stem_width/2), + Box b = Box (Interval (-stem_width / 2, stem_width / 2), Interval (stem_y[DOWN]*half_space, stem_y[UP]*half_space)); Stencil ss = Lookup::round_filled_box (b, blot); @@ -707,8 +704,8 @@ Stem::print (SCM smob) if (!get_beam (me) && abs (duration_log (me)) > 2) { Stencil fl = flag (me); - fl.translate_axis (stem_y[d]*half_space - d * blot/2, Y_AXIS); - fl.translate_axis (stem_width/2, X_AXIS); + fl.translate_axis (stem_y[d]*half_space - d * blot / 2, Y_AXIS); + fl.translate_axis (stem_width / 2, X_AXIS); mol.add_stencil (fl); } @@ -717,33 +714,33 @@ Stem::print (SCM smob) /* move the stem to right of the notehead if it is up. - */ +*/ MAKE_SCHEME_CALLBACK (Stem, offset_callback, 2); SCM Stem::offset_callback (SCM element_smob, SCM) { Grob *me = unsmob_grob (element_smob); Real r = 0.0; - + if (Grob *f = first_head (me)) { Interval head_wid = f->extent (f, X_AXIS); Real attach = 0.0; - + if (is_invisible (me)) attach = 0.0; else attach = Note_head::stem_attachment_coordinate (f, X_AXIS); - + Direction d = get_direction (me); Real real_attach = head_wid.linear_combination (d * attach); r = real_attach; - + /* If not centered: correct for stem thickness. */ if (attach) { Real rule_thick = thickness (me); - r += - d * rule_thick * 0.5; + r += -d * rule_thick * 0.5; } } else @@ -751,7 +748,7 @@ Stem::offset_callback (SCM element_smob, SCM) SCM rests = me->get_property ("rests"); if (scm_is_pair (rests)) { - Grob * rest = unsmob_grob (scm_car (rests)); + Grob *rest = unsmob_grob (scm_car (rests)); r = rest->extent (rest, X_AXIS).center (); } } @@ -762,7 +759,7 @@ Spanner * Stem::get_beam (Grob *me) { SCM b = me->get_property ("beam"); - return dynamic_cast (unsmob_grob (b)); + return dynamic_cast (unsmob_grob (b)); } Stem_info @@ -783,7 +780,6 @@ Stem::get_stem_info (Grob *me) return si; } - /* TODO: add extra space for tremolos! */ void Stem::calc_stem_info (Grob *me) @@ -793,7 +789,7 @@ Stem::calc_stem_info (Grob *me) if (!my_dir) { programming_error ("No stem dir set?"); - my_dir = UP; + my_dir = UP; } Real staff_space = Staff_symbol_referencer::staff_space (me); @@ -802,25 +798,22 @@ Stem::calc_stem_info (Grob *me) Real beam_thickness = Beam::get_thickness (beam); int beam_count = Beam::get_direction_beam_count (beam, my_dir); - /* Simple standard stem length */ SCM lengths = me->get_property ("beamed-lengths"); - Real ideal_length = - scm_to_double (robust_list_ref (beam_count - 1, lengths)) - + Real ideal_length + = scm_to_double (robust_list_ref (beam_count - 1, lengths)) + * staff_space /* stem only extends to center of beam - */ - - 0.5 * beam_thickness - ; + */ + - 0.5 * beam_thickness; /* Condition: sane minimum free stem length (chord to beams) */ lengths = me->get_property ("beamed-minimum-free-lengths"); - Real ideal_minimum_free = - scm_to_double (robust_list_ref (beam_count - 1, lengths)) + Real ideal_minimum_free + = scm_to_double (robust_list_ref (beam_count - 1, lengths)) * staff_space; - /* UGH It seems that also for ideal minimum length, we must use the maximum beam count (for this direction): @@ -839,48 +832,46 @@ Stem::calc_stem_info (Grob *me) ideal_length = ideal_length >? ideal_minimum_length; /* Convert to Y position, calculate for dir == UP */ - Real note_start = - /* staff positions */ + Real note_start + = /* staff positions */ head_positions (me)[my_dir] * 0.5 * my_dir * staff_space; Real ideal_y = note_start + ideal_length; - /* Conditions for Y position */ /* Lowest beam of (UP) beam must never be lower than second staffline - Reference? + Reference? - Although this (additional) rule is probably correct, - I expect that highest beam (UP) should also never be lower - than middle staffline, just as normal stems. + Although this (additional) rule is probably correct, + I expect that highest beam (UP) should also never be lower + than middle staffline, just as normal stems. - Reference? + Reference? - Obviously not for grace beams. + Obviously not for grace beams. - Also, not for knees. Seems to be a good thing. */ + Also, not for knees. Seems to be a good thing. */ bool no_extend_b = to_boolean (me->get_property ("no-stem-extend")); bool is_knee = to_boolean (beam->get_property ("knee")); if (!no_extend_b && !is_knee) { /* Highest beam of (UP) beam must never be lower than middle staffline */ - ideal_y = ideal_y >? 0; + ideal_y = ideal_y >? 0; /* Lowest beam of (UP) beam must never be lower than second staffline */ - ideal_y = ideal_y >? (-staff_space + ideal_y = ideal_y >? (-staff_space - beam_thickness + height_of_my_beams); } - ideal_y -= robust_scm2double (beam->get_property ("shorten"), 0); - Real minimum_free = - scm_to_double (robust_list_ref - (beam_count - 1, - me->get_property - ("beamed-extreme-minimum-free-lengths"))) + Real minimum_free + = scm_to_double (robust_list_ref + (beam_count - 1, + me->get_property + ("beamed-extreme-minimum-free-lengths"))) * staff_space; Real minimum_length = minimum_free @@ -907,7 +898,6 @@ Stem::beam_multiplicity (Grob *stem) return le; } - /* FIXME: Too many properties */ ADD_INTERFACE (Stem, "stem-interface", "The stem represent the graphical stem. " diff --git a/lily/stencil-scheme.cc b/lily/stencil-scheme.cc index 263d06ae52..4ef10f4e08 100644 --- a/lily/stencil-scheme.cc +++ b/lily/stencil-scheme.cc @@ -8,7 +8,7 @@ #include -#include // isinf +#include // isinf #include "font-metric.hh" #include "stencil.hh" @@ -16,10 +16,10 @@ /* TODO: naming add/combine. - */ +*/ /* UGH. Junk all mutators. - */ +*/ LY_DEFINE (ly_stencil_set_extent_x, "ly:stencil-set-extent!", 3, 0, 0, (SCM stil, SCM axis, SCM np), "Set the extent of @var{stil} " @@ -51,7 +51,7 @@ LY_DEFINE (ly_translate_stencil_axis, "ly:stencil-translate-axis", SCM_ASSERT_TYPE (!isinf (real_amount) && !isnan (real_amount), amount, SCM_ARG2, __FUNCTION__, "finite number"); #endif - + SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG3, __FUNCTION__, "axis"); SCM new_s = s->smobbed_copy (); @@ -98,7 +98,6 @@ LY_DEFINE (ly_stencil_get_extent, "ly:stencil-extent", return ly_interval2scm (s->extent (Axis (scm_to_int (axis)))); } - LY_DEFINE (ly_stencil_empty_p, "ly:stencil-empty?", 1, 0, 0, (SCM stil), "Return whether @var{stil} is empty ") @@ -108,7 +107,6 @@ LY_DEFINE (ly_stencil_empty_p, "ly:stencil-empty?", return scm_from_bool (s->is_empty ()); } - LY_DEFINE (ly_stencil_origin, "ly:stencil-origin", 2, 0, 0, (SCM stil, SCM axis), "Return a pair of numbers signifying the origin @var{stil} in " @@ -118,10 +116,9 @@ LY_DEFINE (ly_stencil_origin, "ly:stencil-origin", SCM_ASSERT_TYPE (s, stil, SCM_ARG1, __FUNCTION__, "stencil"); SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG2, __FUNCTION__, "axis"); - return scm_from_double (s->origin()[Axis (scm_to_int (axis))]); + return scm_from_double (s->origin ()[Axis (scm_to_int (axis))]); } - LY_DEFINE (ly_stencil_moved_to_edge, "ly:stencil-moved-to-edge", 4, 2, 0, (SCM first, SCM axis, SCM direction, SCM second, SCM padding, SCM minimum), @@ -130,7 +127,7 @@ LY_DEFINE (ly_stencil_moved_to_edge, "ly:stencil-moved-to-edge", { /* C&P from combine-at-edge. - */ + */ Stencil *s1 = unsmob_stencil (first); Stencil *s2 = unsmob_stencil (second); Stencil first_stencil; @@ -159,16 +156,14 @@ LY_DEFINE (ly_stencil_moved_to_edge, "ly:stencil-moved-to-edge", Direction (scm_to_int (direction)), *s2, p, m).smobbed_copy (); else - return Stencil().smobbed_copy (); + return Stencil ().smobbed_copy (); } - - LY_DEFINE (ly_stencil_combine_at_edge, "ly:stencil-combine-at-edge", - 4, 2, 0, (SCM first, SCM axis, SCM direction, - SCM second, - SCM padding, - SCM minimum), + 4, 2, 0, (SCM first, SCM axis, SCM direction, + SCM second, + SCM padding, + SCM minimum), "Construct a stencil by putting @var{second} next to @var{first}. " "@var{axis} can be 0 (x-axis) or 1 (y-axis), " "@var{direction} can be -1 (left or down) or 1 (right or up). " @@ -181,9 +176,9 @@ LY_DEFINE (ly_stencil_combine_at_edge, "ly:stencil-combine-at-edge", Stencil *s2 = unsmob_stencil (second); Stencil result; - SCM_ASSERT_TYPE (s1 || first == SCM_BOOL_F || first == SCM_EOL, + SCM_ASSERT_TYPE (s1 || first == SCM_BOOL_F || first == SCM_EOL, first, SCM_ARG1, __FUNCTION__, "Stencil, #f or ()"); - SCM_ASSERT_TYPE (s2 || second == SCM_BOOL_F || second == SCM_EOL, + SCM_ASSERT_TYPE (s2 || second == SCM_BOOL_F || second == SCM_EOL, second, SCM_ARG4, __FUNCTION__, "Stencil, #f or ()"); SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG2, __FUNCTION__, "axis"); SCM_ASSERT_TYPE (is_direction (direction), direction, SCM_ARG3, __FUNCTION__, "dir"); @@ -203,7 +198,7 @@ LY_DEFINE (ly_stencil_combine_at_edge, "ly:stencil-combine-at-edge", if (s1) result = *s1; - + if (s2) result.add_at_edge (Axis (scm_to_int (axis)), Direction (scm_to_int (direction)), *s2, p, m); @@ -211,7 +206,7 @@ LY_DEFINE (ly_stencil_combine_at_edge, "ly:stencil-combine-at-edge", return result.smobbed_copy (); } -LY_DEFINE (ly_stencil_add , "ly:stencil-add", +LY_DEFINE (ly_stencil_add, "ly:stencil-add", 0, 0, 1, (SCM args), "Combine stencils. Takes any number of arguments.") { @@ -234,7 +229,7 @@ LY_DEFINE (ly_stencil_add , "ly:stencil-add", } LY_DEFINE (ly_make_stencil, "ly:make-stencil", - 3, 0, 0, (SCM expr, SCM xext, SCM yext), + 3, 0, 0, (SCM expr, SCM xext, SCM yext), " \n" "Stencils are a device independent output expressions." "They carry two pieces of information: \n\n" @@ -251,7 +246,6 @@ LY_DEFINE (ly_make_stencil, "ly:make-stencil", return s.smobbed_copy (); } - LY_DEFINE (ly_stencil_align_to_x, "ly:stencil-align-to!", 3, 0, 0, (SCM stil, SCM axis, SCM dir), "Align @var{stil} using its own extents. " @@ -267,17 +261,15 @@ LY_DEFINE (ly_stencil_align_to_x, "ly:stencil-align-to!", return stil; } - LY_DEFINE (ly_stencil_fonts, "ly:stencil-fonts", 1, 0, 0, (SCM s), - " Analyse @var{s}, and return a list of fonts used in @var{s}.") + " Analyse @var{s}, and return a list of fonts used in @var{s}.") { Stencil *stil = unsmob_stencil (s); SCM_ASSERT_TYPE (stil, s, SCM_ARG1, __FUNCTION__, "Stencil"); return find_expression_fonts (stil->expr ()); } - struct Stencil_interpret_arguments { SCM func; @@ -286,15 +278,15 @@ struct Stencil_interpret_arguments void stencil_interpret_in_scm (void *p, SCM expr) { - Stencil_interpret_arguments *ap = (Stencil_interpret_arguments*) p; + Stencil_interpret_arguments *ap = (Stencil_interpret_arguments *) p; scm_call_2 (ap->func, ap->arg1, expr); } LY_DEFINE (ly_interpret_stencil_expression, "ly:interpret-stencil-expression", - 4, 0, 0, (SCM expr, SCM func, SCM arg1, SCM offset), - "Parse EXPR, feed bits to FUNC with first arg ARG1") + 4, 0, 0, (SCM expr, SCM func, SCM arg1, SCM offset), + "Parse EXPR, feed bits to FUNC with first arg ARG1") { - SCM_ASSERT_TYPE (ly_c_procedure_p(func), func, SCM_ARG1, __FUNCTION__, + SCM_ASSERT_TYPE (ly_c_procedure_p (func), func, SCM_ARG1, __FUNCTION__, "procedure"); Stencil_interpret_arguments a; @@ -302,25 +294,22 @@ LY_DEFINE (ly_interpret_stencil_expression, "ly:interpret-stencil-expression", a.arg1 = arg1; Offset o = ly_scm2offset (offset); - interpret_stencil_expression (expr, stencil_interpret_in_scm, (void*) &a, o); + interpret_stencil_expression (expr, stencil_interpret_in_scm, (void *) &a, o); return SCM_UNSPECIFIED; } - - -LY_DEFINE (ly_bracket , "ly:bracket", - 4, 0, 0, - (SCM a, SCM iv, SCM t, SCM p), - "Make a bracket in direction @var{a}. The extent of the bracket is " - "given by @var{iv}. The wings protude by an amount of @var{p}, which " - "may be negative. The thickness is given by @var{t}.") +LY_DEFINE (ly_bracket, "ly:bracket", + 4, 0, 0, + (SCM a, SCM iv, SCM t, SCM p), + "Make a bracket in direction @var{a}. The extent of the bracket is " + "given by @var{iv}. The wings protude by an amount of @var{p}, which " + "may be negative. The thickness is given by @var{t}.") { - SCM_ASSERT_TYPE (is_axis (a), a, SCM_ARG1, __FUNCTION__, "axis") ; - SCM_ASSERT_TYPE (is_number_pair (iv), iv, SCM_ARG2, __FUNCTION__, "number pair") ; - SCM_ASSERT_TYPE (scm_is_number (t), a, SCM_ARG3, __FUNCTION__, "number") ; - SCM_ASSERT_TYPE (scm_is_number (p), a, SCM_ARG4, __FUNCTION__, "number") ; - + SCM_ASSERT_TYPE (is_axis (a), a, SCM_ARG1, __FUNCTION__, "axis"); + SCM_ASSERT_TYPE (is_number_pair (iv), iv, SCM_ARG2, __FUNCTION__, "number pair"); + SCM_ASSERT_TYPE (scm_is_number (t), a, SCM_ARG3, __FUNCTION__, "number"); + SCM_ASSERT_TYPE (scm_is_number (p), a, SCM_ARG4, __FUNCTION__, "number"); return Lookup::bracket ((Axis)scm_to_int (a), ly_scm2interval (iv), scm_to_double (t), @@ -328,19 +317,16 @@ LY_DEFINE (ly_bracket , "ly:bracket", 0.95 * scm_to_double (t)).smobbed_copy (); } - - -LY_DEFINE (ly_filled_box , "ly:round-filled-box", - 3, 0, 0, - (SCM xext, SCM yext, SCM blot), - "Make a @code{Stencil} " - "that prints a black box of dimensions @var{xext}, " - "@var{yext} and roundness @var{blot}." - ) +LY_DEFINE (ly_filled_box, "ly:round-filled-box", + 3, 0, 0, + (SCM xext, SCM yext, SCM blot), + "Make a @code{Stencil} " + "that prints a black box of dimensions @var{xext}, " + "@var{yext} and roundness @var{blot}.") { - SCM_ASSERT_TYPE (is_number_pair (xext), xext, SCM_ARG1, __FUNCTION__, "number pair") ; - SCM_ASSERT_TYPE (is_number_pair (yext), yext, SCM_ARG2, __FUNCTION__, "number pair") ; - SCM_ASSERT_TYPE (scm_is_number (blot), blot, SCM_ARG3, __FUNCTION__, "number") ; + SCM_ASSERT_TYPE (is_number_pair (xext), xext, SCM_ARG1, __FUNCTION__, "number pair"); + SCM_ASSERT_TYPE (is_number_pair (yext), yext, SCM_ARG2, __FUNCTION__, "number pair"); + SCM_ASSERT_TYPE (scm_is_number (blot), blot, SCM_ARG3, __FUNCTION__, "number"); return Lookup::round_filled_box (Box (ly_scm2interval (xext), ly_scm2interval (yext)), scm_to_double (blot)).smobbed_copy (); diff --git a/lily/stencil.cc b/lily/stencil.cc index 688efe2855..0c314964ae 100644 --- a/lily/stencil.cc +++ b/lily/stencil.cc @@ -10,7 +10,7 @@ #include -#include // isinf +#include // isinf #include "input-smob.hh" #include "font-metric.hh" @@ -43,7 +43,7 @@ Stencil::print_smob (SCM, SCM port, scm_print_state *) SCM Stencil::mark_smob (SCM smob) { - Stencil *s = (Stencil*) SCM_CELL_WORD_1 (smob); + Stencil *s = (Stencil *) SCM_CELL_WORD_1 (smob); return s->expr_; } @@ -93,7 +93,7 @@ Stencil::translate (Offset o) programming_error (String_convert::form_string ("Improbable offset for stencil: %f staff space", o[a]) + "\n" + "Setting to zero."); - o[a] = 0.0; + o[a] = 0.0; } incr (a); } @@ -121,8 +121,6 @@ Stencil::add_stencil (Stencil const &s) dim_.unite (s.dim_); } - - void Stencil::set_empty (bool e) { @@ -175,8 +173,8 @@ Stencil::moved_to_edge (Axis a, Direction d, Stencil const &s, toadd.translate_axis (offset, a); if (minimum > 0 && d * (-origin ()[a] + toadd.origin ()[a]) < minimum) - toadd.translate_axis ( -toadd.origin ()[a] - + origin ()[a] + d * minimum, a); + toadd.translate_axis (-toadd.origin ()[a] + + origin ()[a] + d * minimum, a); return toadd; } @@ -189,38 +187,36 @@ Stencil::add_at_edge (Axis a, Direction d, Stencil const &s, Real padding, add_stencil (moved_to_edge (a, d, s, padding, minimum)); } - /****************************************************************/ - void interpret_stencil_expression (SCM expr, - void (*func) (void*, SCM), + void (*func) (void *, SCM), void *func_arg, Offset o) { while (1) { if (!scm_is_pair (expr)) - return; + return; SCM head = scm_car (expr); if (head == ly_symbol2scm ("translate-stencil")) - { - o += ly_scm2offset (scm_cadr (expr)); - expr = scm_caddr (expr); - } + { + o += ly_scm2offset (scm_cadr (expr)); + expr = scm_caddr (expr); + } else if (head == ly_symbol2scm ("combine-stencil")) - { - for (SCM x = scm_cdr (expr); scm_is_pair (x); x = scm_cdr (x)) + { + for (SCM x = scm_cdr (expr); scm_is_pair (x); x = scm_cdr (x)) interpret_stencil_expression (scm_car (x), func, func_arg, o); - return; - } + return; + } else if (head == ly_symbol2scm ("grob-cause")) { SCM grob = scm_cadr (expr); - + (*func) (func_arg, scm_list_3 (head, ly_quote_scm (ly_offset2scm (o)), grob)); interpret_stencil_expression (scm_caddr (expr), func, func_arg, o); @@ -228,7 +224,7 @@ interpret_stencil_expression (SCM expr, return; } else if (head == ly_symbol2scm ("color")) - { + { SCM color = scm_cadr (expr); SCM r = scm_car (color); SCM g = scm_cadr (color); @@ -237,22 +233,21 @@ interpret_stencil_expression (SCM expr, (*func) (func_arg, scm_list_4 (ly_symbol2scm ("setcolor"), r, g, b)); interpret_stencil_expression (scm_caddr (expr), func, func_arg, o); (*func) (func_arg, scm_list_1 (ly_symbol2scm ("resetcolor"))); - + return; - } + } else - { - (*func) (func_arg, - scm_list_4 (ly_symbol2scm ("placebox"), - scm_make_real (o[X_AXIS]), - scm_make_real (o[Y_AXIS]), - expr)); - return; - } + { + (*func) (func_arg, + scm_list_4 (ly_symbol2scm ("placebox"), + scm_make_real (o[X_AXIS]), + scm_make_real (o[Y_AXIS]), + expr)); + return; + } } } - struct Font_list { SCM fonts_; @@ -261,7 +256,7 @@ struct Font_list static void find_font_function (void *fs, SCM x) { - Font_list *me = (Font_list*) fs; + Font_list *me = (Font_list *) fs; if (scm_car (x) == ly_symbol2scm ("placebox")) { @@ -269,13 +264,13 @@ find_font_function (void *fs, SCM x) SCM what = scm_caddr (args); if (scm_is_pair (what)) - { - SCM head = scm_car (what); - if (ly_symbol2scm ("text") == head) - me->fonts_ = scm_cons (scm_cadr (what), me->fonts_); - else if (head == ly_symbol2scm ("char")) - me->fonts_ = scm_cons (scm_cadr (what), me->fonts_); - } + { + SCM head = scm_car (what); + if (ly_symbol2scm ("text") == head) + me->fonts_ = scm_cons (scm_cadr (what), me->fonts_); + else if (head == ly_symbol2scm ("char")) + me->fonts_ = scm_cons (scm_cadr (what), me->fonts_); + } } } @@ -287,9 +282,8 @@ find_expression_fonts (SCM expr) fl.fonts_ = SCM_EOL; interpret_stencil_expression (expr, &find_font_function, - (void*) &fl, Offset (0, 0)); + (void *) &fl, Offset (0, 0)); return fl.fonts_; } - diff --git a/lily/string-number-engraver.cc b/lily/string-number-engraver.cc index 9924753592..fd87ec4aff 100644 --- a/lily/string-number-engraver.cc +++ b/lily/string-number-engraver.cc @@ -4,7 +4,6 @@ source file of the GNU LilyPond music typesetter (c) 2005 Han-Wen Nienhuys - */ #include "engraver.hh" @@ -15,12 +14,11 @@ class String_number_engraver : public Engraver public: TRANSLATOR_DECLARATIONS (String_number_engraver); protected: - virtual bool try_music (Music* m); + virtual bool try_music (Music *m); }; - bool -String_number_engraver::try_music (Music * ) +String_number_engraver::try_music (Music *) { return true; } @@ -33,17 +31,16 @@ String_number_engraver::String_number_engraver () /* TODO: string numbers are printed right of the note circled. This engraver should provide this functionality. - - */ +*/ ADD_TRANSLATOR (String_number_engraver, -/* descr */ "Swallow string-number-events - the purpose of this engraver is to" -" process tab for normal notation. To provent warnings for unprocessed " -" string-number-event to obscure real error messages, this engraver " -" swallows them all.", - -/* creats*/ "", -/* accepts */ "string-number-event", -/* acks */ "", -/* reads */ "", -/* write */ ""); + /* descr */ "Swallow string-number-events - the purpose of this engraver is to" + " process tab for normal notation. To provent warnings for unprocessed " + " string-number-event to obscure real error messages, this engraver " + " swallows them all.", + + /* creats*/ "", + /* accepts */ "string-number-event", + /* acks */ "", + /* reads */ "", + /* write */ ""); diff --git a/lily/sustain-pedal.cc b/lily/sustain-pedal.cc index 6806ce2c9d..68db12e760 100644 --- a/lily/sustain-pedal.cc +++ b/lily/sustain-pedal.cc @@ -1,11 +1,10 @@ -/* +/* sustain-pedal.cc -- implement Sustain_pedal - + source file of the GNU LilyPond music typesetter - + (c) 2000--2005 Han-Wen Nienhuys - - */ +*/ #include "grob.hh" #include "stencil.hh" #include "font-interface.hh" @@ -15,39 +14,36 @@ Urg. This is almost text Problem is: - * we have no kerning - * symbols are at wrong place in font + * we have no kerning + * symbols are at wrong place in font Properties: glyph -- text string (TODO: make one large glyph of the Ped symbol, removes need for member_print ()) - */ - /* - FIXME. Need to use markup. - */ + FIXME. Need to use markup. +*/ struct Sustain_pedal { public: DECLARE_SCHEME_CALLBACK (print, (SCM)); }; - MAKE_SCHEME_CALLBACK (Sustain_pedal, print, 1); SCM -Sustain_pedal::print (SCM smob) +Sustain_pedal::print (SCM smob) { - Grob * e = unsmob_grob (smob); - + Grob *e = unsmob_grob (smob); + Stencil mol; SCM glyph = e->get_property ("text"); if (!scm_is_string (glyph)) return mol.smobbed_copy (); - + String text = ly_scm2string (glyph); for (int i = 0; i < text.length (); i++) @@ -64,7 +60,7 @@ Sustain_pedal::print (SCM smob) if (!m.is_empty ()) mol.add_at_edge (X_AXIS, RIGHT, m, 0, 0); } - + return mol.smobbed_copy (); } diff --git a/lily/swallow-engraver.cc b/lily/swallow-engraver.cc index 868047126b..e9178e7142 100644 --- a/lily/swallow-engraver.cc +++ b/lily/swallow-engraver.cc @@ -13,11 +13,11 @@ class Swallow_engraver : public Engraver public: TRANSLATOR_DECLARATIONS (Swallow_engraver); protected: - bool try_music (Music*) ; + bool try_music (Music *); }; bool -Swallow_engraver::try_music (Music*) +Swallow_engraver::try_music (Music *) { return true; } @@ -27,10 +27,10 @@ Swallow_engraver::Swallow_engraver () } ADD_TRANSLATOR (Swallow_engraver, -/* descr */ "This engraver swallows everything given to it silently. The purpose of " - "this is to prevent spurious \"event junked\" warnings.", -/* creats*/ "", -/* accepts */ "general-music", -/* acks */ "", -/* reads */ "", -/* write */ ""); + /* descr */ "This engraver swallows everything given to it silently. The purpose of " + "this is to prevent spurious \"event junked\" warnings.", + /* creats*/ "", + /* accepts */ "general-music", + /* acks */ "", + /* reads */ "", + /* write */ ""); diff --git a/lily/swallow-perf.cc b/lily/swallow-perf.cc index 173224ec8a..92c7c4ba9c 100644 --- a/lily/swallow-perf.cc +++ b/lily/swallow-perf.cc @@ -13,7 +13,7 @@ class Swallow_performer : public Performer public: TRANSLATOR_DECLARATIONS (Swallow_performer); protected: - virtual bool try_music (Music*); + virtual bool try_music (Music *); }; bool @@ -23,16 +23,16 @@ Swallow_performer::try_music (Music *m) || m->is_mus_type ("melisma-playing-event")) return false; else - return true; + return true; } Swallow_performer::Swallow_performer () {} ADD_TRANSLATOR (Swallow_performer, -/* descr */ "", -/* creats*/ "", -/* accepts */ "general-music", -/* acks */ "", -/* reads */ "", -/* write */ ""); + /* descr */ "", + /* creats*/ "", + /* accepts */ "general-music", + /* acks */ "", + /* reads */ "", + /* write */ ""); diff --git a/lily/system-start-delimiter-engraver.cc b/lily/system-start-delimiter-engraver.cc index 7e8adb3d7c..de89a20764 100644 --- a/lily/system-start-delimiter-engraver.cc +++ b/lily/system-start-delimiter-engraver.cc @@ -1,11 +1,10 @@ -/* +/* system-start-delimiter-engraver.cc -- implement System_start_delimiter_engraver - + source file of the GNU LilyPond music typesetter - + (c) 2000--2005 Han-Wen Nienhuys - - */ +*/ #include "system-start-delimiter.hh" #include "engraver.hh" @@ -21,14 +20,12 @@ public: TRANSLATOR_DECLARATIONS (System_start_delimiter_engraver); protected: - Spanner * delim_; + Spanner *delim_; virtual void acknowledge_grob (Grob_info); virtual void process_music (); virtual void finalize (); }; - - void System_start_delimiter_engraver::acknowledge_grob (Grob_info inf) { @@ -37,8 +34,8 @@ System_start_delimiter_engraver::acknowledge_grob (Grob_info inf) /* don't add as Axis_group_interface::add_element (delim_, ), because that would set the parent as well */ - - Pointer_group_interface::add_grob (delim_, ly_symbol2scm ("elements"), inf.grob_); + + Pointer_group_interface::add_grob (delim_, ly_symbol2scm ("elements"), inf.grob_); } else if (System_start_delimiter::has_interface (inf.grob_)) { @@ -47,18 +44,18 @@ System_start_delimiter_engraver::acknowledge_grob (Grob_info inf) /* UGH UGH - */ - if (scm_is_string (gl) && ly_c_equal_p (gl, scm_makfrom0str ("brace")) - && scm_is_string (my_gl) && ly_c_equal_p (my_gl, scm_makfrom0str ("bracket"))) + */ + if (scm_is_string (gl) && ly_c_equal_p (gl, scm_makfrom0str ("brace")) + && scm_is_string (my_gl) && ly_c_equal_p (my_gl, scm_makfrom0str ("bracket"))) inf.grob_->translate_axis (-0.8, X_AXIS); // ugh - else if (scm_is_string (gl) && ly_c_equal_p (gl, scm_makfrom0str ("bracket")) - && scm_is_string (my_gl) && ly_c_equal_p (my_gl, scm_makfrom0str ("bracket"))) - { - inf.grob_->translate_axis ( -0.8, X_AXIS); // ugh - inf.grob_->set_property ("arch-height", - scm_make_real (scm_to_double (inf.grob_->get_property - ("arch-height"))+0.5)); - } + else if (scm_is_string (gl) && ly_c_equal_p (gl, scm_makfrom0str ("bracket")) + && scm_is_string (my_gl) && ly_c_equal_p (my_gl, scm_makfrom0str ("bracket"))) + { + inf.grob_->translate_axis (-0.8, X_AXIS); // ugh + inf.grob_->set_property ("arch-height", + scm_make_real (scm_to_double (inf.grob_->get_property + ("arch-height")) + 0.5)); + } } } @@ -74,10 +71,10 @@ System_start_delimiter_engraver::process_music () { SCM delim_name = get_property ("systemStartDelimiter"); delim_ = make_spanner_from_properties (this, delim_name, SCM_EOL, - ly_symbol2string (delim_name).to_str0()); + ly_symbol2string (delim_name).to_str0 ()); delim_->set_bound (LEFT, unsmob_grob (get_property ("currentCommandColumn"))); - + } } void @@ -86,14 +83,14 @@ System_start_delimiter_engraver::finalize () if (delim_) { delim_->set_bound (RIGHT, unsmob_grob (get_property ("currentCommandColumn"))); - + } } ADD_TRANSLATOR (System_start_delimiter_engraver, -/* descr */ "Creates a system start delimiter (ie. SystemStart@{Bar, Brace, Bracket@} spanner", -/* creats*/ "SystemStartBar SystemStartBrace SystemStartBracket", -/* accepts */ "", -/* acks */ "system-start-delimiter-interface staff-symbol-interface", -/* reads */ "systemStartDelimiter", -/* write */ ""); + /* descr */ "Creates a system start delimiter (ie. SystemStart@{Bar, Brace, Bracket@} spanner", + /* creats*/ "SystemStartBar SystemStartBrace SystemStartBracket", + /* accepts */ "", + /* acks */ "system-start-delimiter-interface staff-symbol-interface", + /* reads */ "systemStartDelimiter", + /* write */ ""); diff --git a/lily/system-start-delimiter.cc b/lily/system-start-delimiter.cc index ded4977de0..0a5b6fe532 100644 --- a/lily/system-start-delimiter.cc +++ b/lily/system-start-delimiter.cc @@ -1,11 +1,10 @@ -/* +/* system-start-delimiter.cc -- implement System_start_delimiter source file of the GNU LilyPond music typesetter (c) 2000--2005 Han-Wen Nienhuys - - */ +*/ #include "system-start-delimiter.hh" @@ -20,52 +19,50 @@ #include "lookup.hh" Stencil -System_start_delimiter::staff_bracket (Grob*me, Real height) +System_start_delimiter::staff_bracket (Grob *me, Real height) { - Real arc_height = scm_to_double (me->get_property ("arch-height")) ; + Real arc_height = scm_to_double (me->get_property ("arch-height")); SCM at = scm_list_n (ly_symbol2scm ("bracket"), - me->get_property ("arch-angle"), - me->get_property ("arch-width"), - scm_make_real (arc_height), - scm_make_real (height), - me->get_property ("arch-thick"), - me->get_property ("thickness"), - SCM_UNDEFINED); + me->get_property ("arch-angle"), + me->get_property ("arch-width"), + scm_make_real (arc_height), + scm_make_real (height), + me->get_property ("arch-thick"), + me->get_property ("thickness"), + SCM_UNDEFINED); -/* -TODO: sort this out. - -Another thing: -In system-start-delimiter.cc I see the line + /* + TODO: sort this out. - Real h = height + 2 * arc_height; + Another thing: + In system-start-delimiter.cc I see the line + + Real h = height + 2 * arc_height; -But I really think that you mean + But I really think that you mean - Real h = height + 2 * arc_width; + Real h = height + 2 * arc_width; -(arc_height changes the x-axis-size of arc ; arc_width changes the -y-axis-size) -Will not fix it since I'm not sure. + (arc_height changes the x-axis-size of arc ; arc_width changes the + y-axis-size) + Will not fix it since I'm not sure. - */ + */ Real h = height + 2 * arc_height; - Box b (Interval (0, 1.5), Interval (-h/2, h/2)); + Box b (Interval (0, 1.5), Interval (-h / 2, h / 2)); Stencil mol (b, at); mol.align_to (X_AXIS, CENTER); return mol; } - - Stencil -System_start_delimiter::simple_bar (Grob*me, Real h) +System_start_delimiter::simple_bar (Grob *me, Real h) { - Real lt = me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness")) ; + Real lt = me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness")); Real w = lt * robust_scm2double (me->get_property ("thickness"), 1); - return Lookup::round_filled_box (Box (Interval (0, w), Interval (-h/2, h/2)), + return Lookup::round_filled_box (Box (Interval (0, w), Interval (-h / 2, h / 2)), lt); } @@ -74,14 +71,14 @@ MAKE_SCHEME_CALLBACK (System_start_delimiter, after_line_breaking, 1); SCM System_start_delimiter::after_line_breaking (SCM smob) { - Grob * me = unsmob_grob (smob); - SCM gl = me->get_property ("glyph"); + Grob *me = unsmob_grob (smob); + SCM gl = me->get_property ("glyph"); if (ly_c_equal_p (gl, scm_makfrom0str ("bar-line"))) { int count = 0; /* - Get all coordinates, to trigger Hara kiri. + Get all coordinates, to trigger Hara kiri. */ SCM elts = me->get_property ("elements"); Grob *common = common_refpoint_of_list (elts, me, Y_AXIS); @@ -90,11 +87,10 @@ System_start_delimiter::after_line_breaking (SCM smob) Interval v = unsmob_grob (scm_car (s))->extent (common, Y_AXIS); if (!v.is_empty ()) - count ++; + count++; } - - if (count <= 1) + if (count <= 1) { me->suicide (); } @@ -102,7 +98,6 @@ System_start_delimiter::after_line_breaking (SCM smob) return SCM_UNSPECIFIED; } - MAKE_SCHEME_CALLBACK (System_start_delimiter, print, 1); SCM System_start_delimiter::print (SCM smob) @@ -114,19 +109,19 @@ System_start_delimiter::print (SCM smob) SCM s = me->get_property ("glyph"); if (!scm_is_string (s)) return SCM_EOL; - SCM gsym = scm_string_to_symbol (s) ; + SCM gsym = scm_string_to_symbol (s); Real staff_space = Staff_symbol_referencer::staff_space (me); SCM elts = me->get_property ("elements"); - Grob * common = common_refpoint_of_list (elts, me, Y_AXIS); + Grob *common = common_refpoint_of_list (elts, me, Y_AXIS); Interval ext; for (SCM s = elts; scm_is_pair (s); s = scm_cdr (s)) { - Spanner * sp = unsmob_spanner (scm_car (s)); - if (sp && - sp->get_bound (LEFT) == me->get_bound (LEFT)) + Spanner *sp = unsmob_spanner (scm_car (s)); + if (sp + && sp->get_bound (LEFT) == me->get_bound (LEFT)) { Interval dims = sp->extent (common, Y_AXIS); if (!dims.is_empty ()) @@ -195,10 +190,8 @@ System_start_delimiter::staff_brace (Grob *me, Real y) return Stencil (b, stil.expr ()); } - ADD_INTERFACE (System_start_delimiter, "system-start-delimiter-interface", "The brace, bracket or bar in front of the system. " - "It is implemented as a spanner." - , + "It is implemented as a spanner.", "collapse-height thickness " "arch-height arch-angle arch-thick arch-width bracket-thick glyph"); diff --git a/lily/system.cc b/lily/system.cc index 8f1e907f4e..d1066602fe 100644 --- a/lily/system.cc +++ b/lily/system.cc @@ -25,27 +25,24 @@ #include "paper-system.hh" #include "tweak-registration.hh" - System::System (System const &src, int count) : Spanner (src, count) { rank_ = 0; } -System::System (SCM s, Object_key const*key) +System::System (SCM s, Object_key const *key) : Spanner (s, key) { rank_ = 0; } - -Grob * +Grob * System::clone (int count) const { return new System (*this, count); } - int System::element_count () const { @@ -57,13 +54,13 @@ System::spanner_count () const { int k = 0; for (SCM s = get_property ("all-elements"); scm_is_pair (s); s = scm_cdr (s)) - if (dynamic_cast (unsmob_grob (scm_car (s)))) + if (dynamic_cast (unsmob_grob (scm_car (s)))) k++; return k; } void -System::typeset_grob (Grob * elem) +System::typeset_grob (Grob *elem) { if (elem->pscore_) programming_error ("Adding element twice."); @@ -94,9 +91,9 @@ System::get_lines () if (g->internal_has_interface (ly_symbol2scm ("only-prebreak-interface"))) { /* - Kill no longer needed grobs. - */ - Item * it = dynamic_cast (g); + Kill no longer needed grobs. + */ + Item *it = dynamic_cast (g); if (it && Item::is_breakable (it)) { it->find_prebroken_piece (LEFT)->suicide (); @@ -120,10 +117,10 @@ System::get_lines () fixup_refpoint (scm_car (s)); count += scm_ilength (all); } - + /* needed for doing items. - */ + */ fixup_refpoints (get_property ("all-elements")); for (SCM s = get_property ("all-elements"); scm_is_pair (s); s = scm_cdr (s)) @@ -131,7 +128,7 @@ System::get_lines () handle_broken_dependencies (); #if 0 /* don't do this: strange side effects. */ - + /* Because the this->get_property (all-elements) contains items in 3 versions, handle_broken_dependencies () will leave duplicated items in all-elements. Strictly speaking this is harmless, but @@ -140,22 +137,22 @@ System::get_lines () for (int i = 0; i < line_count; i++) { SCM all = broken_intos_[i]->get_property ("all-elements"); - all = ly_list_qsort_uniq_x(all); + all = ly_list_qsort_uniq_x (all); } #endif - + if (be_verbose_global) - progress_indication (_f ("Element count %d.", count + element_count ())); + progress_indication (_f ("Element count %d.", count + element_count ())); int line_count = broken_intos_.size (); SCM lines = scm_c_make_vector (line_count, SCM_EOL); - + for (int i = 0; i < line_count; i++) { if (be_verbose_global) progress_indication ("["); - System *system = dynamic_cast (broken_intos_[i]); + System *system = dynamic_cast (broken_intos_[i]); system->post_processing (); scm_vector_set_x (lines, scm_int2num (i), system->get_line ()); @@ -166,22 +163,22 @@ System::get_lines () } void -System::break_into_pieces (Array const &breaking) +System::break_into_pieces (Array const &breaking) { for (int i = 0; i < breaking.size (); i++) { - System *system = dynamic_cast (clone (i)); + System *system = dynamic_cast (clone (i)); system->rank_ = i; Link_array c (breaking[i].cols_); pscore_->typeset_line (system); - + system->set_bound (LEFT, c[0]); system->set_bound (RIGHT, c.top ()); for (int j = 0; j < c.size (); j++) { c[j]->translate_axis (breaking[i].config_[j], X_AXIS); - dynamic_cast (c[j])->system_ = system; + dynamic_cast (c[j])->system_ = system; } set_loose_columns (system, &breaking[i]); broken_intos_.push (system); @@ -189,13 +186,13 @@ System::break_into_pieces (Array const &breaking) } void -System::add_column (Paper_column*p) +System::add_column (Paper_column *p) { Grob *me = this; SCM cs = me->get_property ("columns"); - Grob *prev = scm_is_pair (cs) ? unsmob_grob (scm_car (cs)) : 0; + Grob *prev = scm_is_pair (cs) ? unsmob_grob (scm_car (cs)) : 0; - p->rank_ = prev ? Paper_column::get_rank (prev) + 1 : 0; + p->rank_ = prev ? Paper_column::get_rank (prev) + 1 : 0; me->set_property ("columns", scm_cons (p->self_scm (), cs)); @@ -212,7 +209,7 @@ apply_tweaks (Grob *g, bool broken) { SCM proc = scm_caar (s); SCM rest = scm_cdar (s); - scm_apply_1 (proc, g->self_scm(), rest); + scm_apply_1 (proc, g->self_scm (), rest); } } } @@ -225,13 +222,12 @@ System::pre_processing () if (be_verbose_global) progress_indication (_f ("Grob count %d", element_count ())); - + for (SCM s = get_property ("all-elements"); scm_is_pair (s); s = scm_cdr (s)) unsmob_grob (scm_car (s))->handle_prebroken_dependencies (); - + fixup_refpoints (get_property ("all-elements")); - for (SCM s = get_property ("all-elements"); scm_is_pair (s); s = scm_cdr (s)) apply_tweaks (unsmob_grob (scm_car (s)), false); @@ -240,7 +236,7 @@ System::pre_processing () Grob *sc = unsmob_grob (scm_car (s)); sc->calculate_dependencies (PRECALCED, PRECALCING, ly_symbol2scm ("before-line-breaking-callback")); } - + progress_indication ("\n"); progress_indication (_ ("Calculating line breaks...")); progress_indication (" "); @@ -259,11 +255,11 @@ System::post_processing () for (SCM s = get_property ("all-elements"); scm_is_pair (s); s = scm_cdr (s)) { Grob *g = unsmob_grob (scm_car (s)); - + apply_tweaks (g, true); g->calculate_dependencies (POSTCALCED, POSTCALCING, - ly_symbol2scm ("after-line-breaking-callback")); + ly_symbol2scm ("after-line-breaking-callback")); } Interval iv (extent (this, Y_AXIS)); @@ -271,7 +267,7 @@ System::post_processing () programming_error ("System with zero extent."); else translate_axis (-iv[MAX], Y_AXIS); - + /* Generate all stencils to trigger font loads. This might seem inefficient, but Stencils are cached per grob anyway. */ @@ -288,7 +284,7 @@ System::post_processing () SCM System::get_line () -{ +{ static int const LAYER_COUNT = 3; SCM exprs = SCM_EOL; @@ -296,7 +292,7 @@ System::get_line () /* Output stencils in three layers: 0, 1, 2. Default layer: 1. */ SCM all = get_property ("all-elements"); - + for (int i = 0; i < LAYER_COUNT; i++) for (SCM s = all; scm_is_pair (s); s = scm_cdr (s)) { @@ -322,7 +318,7 @@ System::get_line () st.translate (o + extra); *tail = scm_cons (st.expr (), SCM_EOL); - tail = SCM_CDRLOC(*tail); + tail = SCM_CDRLOC (*tail); } if (Stencil *me = get_stencil ()) @@ -335,25 +331,24 @@ System::get_line () exprs)); Interval staff_refpoints; - staff_refpoints.set_empty(); + staff_refpoints.set_empty (); for (SCM s = get_property ("spaceable-staves"); scm_is_pair (s); s = scm_cdr (s)) - { - Grob *g = unsmob_grob (scm_car (s)); - staff_refpoints.add_point (g->relative_coordinate (this, Y_AXIS)); - } - - + { + Grob *g = unsmob_grob (scm_car (s)); + staff_refpoints.add_point (g->relative_coordinate (this, Y_AXIS)); + } + Paper_system *pl = new Paper_system (sys_stencil, false); pl->staff_refpoints_ = staff_refpoints; - Item * break_point = this->get_bound(LEFT); - pl->break_before_penalty_ = - robust_scm2double (break_point->get_property ("page-penalty"), 0.0); - + Item *break_point = this->get_bound (LEFT); + pl->break_before_penalty_ + = robust_scm2double (break_point->get_property ("page-penalty"), 0.0); + return scm_gc_unprotect_object (pl->self_scm ()); } -Link_array +Link_array System::broken_col_range (Item const *left, Item const *right) const { Link_array ret; @@ -370,7 +365,7 @@ System::broken_col_range (Item const *left, Item const *right) const while (scm_is_pair (s) && scm_car (s) != left->self_scm ()) { - Paper_column*c = dynamic_cast (unsmob_grob (scm_car (s))); + Paper_column *c = dynamic_cast (unsmob_grob (scm_car (s))); if (Item::is_breakable (c) && !c->system_) ret.push (c); diff --git a/lily/tab-note-heads-engraver.cc b/lily/tab-note-heads-engraver.cc index b5bd9c2ceb..aff6336ab7 100644 --- a/lily/tab-note-heads-engraver.cc +++ b/lily/tab-note-heads-engraver.cc @@ -4,7 +4,6 @@ based on note-heads-engraver.cc, by Jean-Baptiste Lamy , (c) 2002--2005 - */ #include @@ -26,7 +25,7 @@ class Tab_note_heads_engraver : public Engraver { Link_array notes_; - + Link_array dots_; Link_array note_events_; Link_array tabstring_events_; @@ -34,19 +33,18 @@ public: TRANSLATOR_DECLARATIONS (Tab_note_heads_engraver); protected: - virtual bool try_music (Music *event) ; + virtual bool try_music (Music *event); virtual void process_music (); virtual void stop_translation_timestep (); }; - Tab_note_heads_engraver::Tab_note_heads_engraver () { } bool -Tab_note_heads_engraver::try_music (Music *m) +Tab_note_heads_engraver::try_music (Music *m) { if (m->is_mus_type ("note-event")) { @@ -62,41 +60,38 @@ Tab_note_heads_engraver::try_music (Music *m) { return note_events_.size (); } - + return false; } - void Tab_note_heads_engraver::process_music () { - int j = 0; + int j = 0; for (int i = 0; i < note_events_.size (); i++) { SCM stringTunings = get_property ("stringTunings"); int number_of_strings = ((int) ly_length (stringTunings)); bool high_string_one = to_boolean (get_property ("highStringOne")); - - Music * event = note_events_[i]; - Item * note = make_item ("TabNoteHead", event->self_scm ()); + Music *event = note_events_[i]; + Item *note = make_item ("TabNoteHead", event->self_scm ()); - - Music * tabstring_event = 0; + Music *tabstring_event = 0; for (SCM s = event->get_property ("articulations"); !tabstring_event && scm_is_pair (s); s = scm_cdr (s)) { - Music * art = unsmob_music (scm_car (s)); + Music *art = unsmob_music (scm_car (s)); if (art->is_mus_type ("string-number-event")) tabstring_event = art; } - if (!tabstring_event && j < tabstring_events_.size ()) + if (!tabstring_event && j < tabstring_events_.size ()) { tabstring_event = tabstring_events_[j]; - if (j +1 < tabstring_events_.size ()) + if (j +1 < tabstring_events_.size ()) j++; } @@ -112,36 +107,35 @@ Tab_note_heads_engraver::process_music () tab_string = high_string_one ? 1 : number_of_strings; string_found = false; } - + Duration dur = *unsmob_duration (event->get_property ("duration")); note->set_property ("duration-log", - scm_int2num (dur.duration_log ())); + scm_int2num (dur.duration_log ())); if (dur.dot_count ()) { - Item * d = make_item ("Dots", event->self_scm ()); + Item *d = make_item ("Dots", event->self_scm ()); Rhythmic_head::set_dots (note, d); - + if (dur.dot_count () != scm_to_int (d->get_property ("dot-count"))) d->set_property ("dot-count", scm_int2num (dur.dot_count ())); d->set_parent (note, Y_AXIS); - + dots_.push (d); } - - + SCM scm_pitch = event->get_property ("pitch"); - SCM proc = get_property ("tablatureFormat"); + SCM proc = get_property ("tablatureFormat"); SCM min_fret_scm = get_property ("minimumFret"); int min_fret = scm_is_number (min_fret_scm) ? scm_to_int (min_fret_scm) : 0; while (!string_found) { int fret = unsmob_pitch (scm_pitch)->semitone_pitch () - - scm_to_int (scm_list_ref (stringTunings, scm_int2num (tab_string-1))); - if (fretset_property ("text", text); - + + note->set_property ("text", text); + note->set_property ("staff-position", scm_int2num (pos)); notes_.push (note); } @@ -169,12 +163,11 @@ Tab_note_heads_engraver::stop_translation_timestep () tabstring_events_.clear (); } - ADD_TRANSLATOR (Tab_note_heads_engraver, -/* descr */ "Generate one or more tablature noteheads from Music of type NoteEvent.", -/* creats*/ "TabNoteHead Dots", -/* accepts */ "note-event string-number-event busy-playing-event", -/* acks */ "", -/* reads */ "middleCPosition stringTunings minimumFret tablatureFormat highStringOne stringOneTopmost", -/* write */ ""); + /* descr */ "Generate one or more tablature noteheads from Music of type NoteEvent.", + /* creats*/ "TabNoteHead Dots", + /* accepts */ "note-event string-number-event busy-playing-event", + /* acks */ "", + /* reads */ "middleCPosition stringTunings minimumFret tablatureFormat highStringOne stringOneTopmost", + /* write */ ""); diff --git a/lily/template5.cc b/lily/template5.cc index d7ed5211f4..3b638996ec 100644 --- a/lily/template5.cc +++ b/lily/template5.cc @@ -26,6 +26,4 @@ Interval_t::T_to_string (Rational a) return a.to_string (); } - - template INTERVAL__INSTANTIATE (Rational); diff --git a/lily/tempo-performer.cc b/lily/tempo-performer.cc index 074fbcc709..0cbbbf450c 100644 --- a/lily/tempo-performer.cc +++ b/lily/tempo-performer.cc @@ -6,7 +6,6 @@ (c) 1997--2005 Jan Nieuwenhuizen */ - #include "audio-item.hh" #include "performer.hh" @@ -18,13 +17,13 @@ public: protected: - virtual bool try_music (Music* req); + virtual bool try_music (Music *req); virtual void stop_translation_timestep (); virtual void create_audio_elements (); private: - Music* tempo_req_; - Audio_tempo* audio_; + Music *tempo_req_; + Audio_tempo *audio_; }; Tempo_performer::Tempo_performer () @@ -37,7 +36,6 @@ Tempo_performer::~Tempo_performer () { } - void Tempo_performer::create_audio_elements () { @@ -46,9 +44,9 @@ Tempo_performer::create_audio_elements () SCM met = tempo_req_->get_property ("metronome-count"); Duration *d = unsmob_duration (tempo_req_->get_property ("tempo-unit")); - - Rational r = (d->get_length () / Moment (Rational (1, 4)) * Moment (scm_to_int (met))).main_part_; - + + Rational r = (d->get_length () / Moment (Rational (1, 4)) * Moment (scm_to_int (met))).main_part_; + audio_ = new Audio_tempo (int (r)); Audio_element_info info (audio_, tempo_req_); @@ -68,7 +66,7 @@ Tempo_performer::stop_translation_timestep () } bool -Tempo_performer::try_music (Music* req) +Tempo_performer::try_music (Music *req) { if (tempo_req_) return false; @@ -78,8 +76,6 @@ Tempo_performer::try_music (Music* req) } - - ADD_TRANSLATOR (Tempo_performer, "", "", - "metronome-change-event", - "", "", "" ); + "metronome-change-event", + "", "", ""); diff --git a/lily/text-engraver.cc b/lily/text-engraver.cc index 21d0b8f525..9569f3d24b 100644 --- a/lily/text-engraver.cc +++ b/lily/text-engraver.cc @@ -1,11 +1,10 @@ -/* +/* text-engraver.cc -- implement Text_engraver - + source file of the GNU LilyPond music typesetter - + (c) 1998--2005 Han-Wen Nienhuys - - */ +*/ #include "directional-element-interface.hh" #include "engraver.hh" @@ -16,7 +15,7 @@ /** typeset directions that are plain text. - */ +*/ class Text_engraver : public Engraver { Link_array evs_; @@ -24,7 +23,7 @@ class Text_engraver : public Engraver public: TRANSLATOR_DECLARATIONS (Text_engraver); protected: - virtual bool try_music (Music* m); + virtual bool try_music (Music *m); virtual void stop_translation_timestep (); virtual void process_acknowledged_grobs (); virtual void acknowledge_grob (Grob_info); @@ -48,21 +47,21 @@ Text_engraver::acknowledge_grob (Grob_info inf) { for (int i = 0; i < texts_.size (); i++) { - Grob*t = texts_[i]; + Grob *t = texts_[i]; Side_position_interface::add_support (t, inf.grob_); /* ugh. - */ + */ if (Side_position_interface::get_axis (t) == X_AXIS && !t->get_parent (Y_AXIS)) t->set_parent (inf.grob_, Y_AXIS); else if (Side_position_interface::get_axis (t) == Y_AXIS - && !t->get_parent (X_AXIS)) + && !t->get_parent (X_AXIS)) t->set_parent (inf.grob_, X_AXIS); } } - + if (Stem::has_interface (inf.grob_)) { for (int i = 0; i < texts_.size (); i++) @@ -79,12 +78,11 @@ Text_engraver::process_acknowledged_grobs () return; for (int i = 0; i < evs_.size (); i++) { - Music * r = evs_[i]; - + Music *r = evs_[i]; + // URG: Text vs TextScript Item *text = make_item ("TextScript", r->self_scm ()); - Axis ax = Y_AXIS; Side_position_interface::set_axis (text, ax); @@ -93,17 +91,16 @@ Text_engraver::process_acknowledged_grobs () SCM s = text->get_property ("script-priority"); if (scm_is_number (s)) priority = scm_to_int (s); - + /* see script-engraver.cc */ priority += i; - + text->set_property ("script-priority", scm_int2num (priority)); Direction dir = to_dir (r->get_property ("direction")); if (dir) set_grob_direction (text, dir); - SCM mark = r->get_property ("text"); text->set_property ("text", mark); @@ -118,15 +115,14 @@ Text_engraver::stop_translation_timestep () evs_.clear (); } - Text_engraver::Text_engraver () { } ADD_TRANSLATOR (Text_engraver, -/* descr */ "Create text-scripts", -/* creats*/ "TextScript", -/* accepts */ "text-script-event", -/* acks */ "rhythmic-head-interface stem-interface", -/* reads */ "", -/* write */ ""); + /* descr */ "Create text-scripts", + /* creats*/ "TextScript", + /* accepts */ "text-script-event", + /* acks */ "rhythmic-head-interface stem-interface", + /* reads */ "", + /* write */ ""); diff --git a/lily/text-item.cc b/lily/text-item.cc index d5dd43c344..2cbaedefc2 100644 --- a/lily/text-item.cc +++ b/lily/text-item.cc @@ -1,17 +1,17 @@ -/* +/* text-item.cc -- implement Text_interface source file of the GNU LilyPond music typesetter - + (c) 1998--2005 Han-Wen Nienhuys - Jan Nieuwenhuizen + Jan Nieuwenhuizen */ #include "text-item.hh" #include -#include "main.hh" +#include "main.hh" #include "config.hh" #include "pango-font.hh" #include "warn.hh" @@ -20,15 +20,14 @@ #include "output-def.hh" #include "modified-font-metric.hh" - MAKE_SCHEME_CALLBACK (Text_interface, interpret_string, 3) -SCM + SCM Text_interface::interpret_string (SCM layout_smob, SCM props, SCM markup) { Output_def *layout = unsmob_output_def (layout_smob); - + SCM_ASSERT_TYPE (layout, layout_smob, SCM_ARG1, __FUNCTION__, "Layout definition"); SCM_ASSERT_TYPE (scm_is_string (markup), markup, SCM_ARG3, @@ -40,9 +39,8 @@ Text_interface::interpret_string (SCM layout_smob, return fm->text_stencil (str).smobbed_copy (); } - MAKE_SCHEME_CALLBACK (Text_interface, interpret_markup, 3) -SCM + SCM Text_interface::interpret_markup (SCM layout_smob, SCM props, SCM markup) { if (scm_is_string (markup)) @@ -53,20 +51,20 @@ Text_interface::interpret_markup (SCM layout_smob, SCM props, SCM markup) SCM args = scm_cdr (markup); if (!markup_p (markup)) programming_error ("Markup head has no markup signature."); - + return scm_apply_2 (func, layout_smob, props, args); } else { programming_error ("Is not a markup: "); - scm_display (markup, scm_current_error_port()); + scm_display (markup, scm_current_error_port ()); assert (false); Box b; - b[X_AXIS].set_empty(); - b[Y_AXIS].set_empty(); - - Stencil s(b, SCM_EOL); - return s.smobbed_copy(); + b[X_AXIS].set_empty (); + b[Y_AXIS].set_empty (); + + Stencil s (b, SCM_EOL); + return s.smobbed_copy (); } } @@ -75,7 +73,7 @@ SCM Text_interface::print (SCM grob) { Grob *me = unsmob_grob (grob); - + SCM t = me->get_property ("text"); SCM chain = Font_interface::text_font_alist_chain (me); return interpret_markup (me->get_layout ()->self_scm (), chain, t); @@ -97,5 +95,3 @@ ADD_INTERFACE (Text_interface, "text-interface", "text baseline-skip word-space"); - - diff --git a/lily/text-metrics.cc b/lily/text-metrics.cc index 3092afa01b..927a9d39e9 100644 --- a/lily/text-metrics.cc +++ b/lily/text-metrics.cc @@ -19,10 +19,10 @@ lookup_tex_text_dimension (Font_metric *font, SCM text) Box b; SCM limit = ly_lily_module_constant ("TEX_STRING_HASHLIMIT"); - String key_str = ly_scm2string (font->font_file_name()); + String key_str = ly_scm2string (font->font_file_name ()); int hash_code = scm_to_int (scm_hash (text, limit)); - key_str = to_string (hash_code) + key_str; - + key_str = to_string (hash_code) + key_str; + SCM val = SCM_BOOL_F; if (text_dimension_hash_tab) { @@ -37,21 +37,21 @@ lookup_tex_text_dimension (Font_metric *font, SCM text) val = scm_cdr (val); b[Y_AXIS][UP] = scm_to_double (scm_car (val)) * point_constant; val = scm_cdr (val); - b[Y_AXIS][DOWN] = scm_to_double (scm_car (val)) * point_constant; + b[Y_AXIS][DOWN] = scm_to_double (scm_car (val)) * point_constant; } - - return b; + + return b; } -LY_DEFINE(ly_load_text_dimensions, "ly:load-text-dimensions", - 1, 0, 0, - (SCM dimension_alist), - "Load dimensions from TeX in a (KEY . (W H D)) format alist") +LY_DEFINE (ly_load_text_dimensions, "ly:load-text-dimensions", + 1, 0, 0, + (SCM dimension_alist), + "Load dimensions from TeX in a (KEY . (W H D)) format alist") { if (!text_dimension_hash_tab) { - text_dimension_hash_tab = - scm_gc_protect_object (scm_c_make_hash_table (113)); + text_dimension_hash_tab + = scm_gc_protect_object (scm_c_make_hash_table (113)); } for (SCM s = dimension_alist; @@ -60,7 +60,7 @@ LY_DEFINE(ly_load_text_dimensions, "ly:load-text-dimensions", { SCM key = scm_caar (s); SCM val = scm_cdar (s); - + if (scm_hash_ref (text_dimension_hash_tab, key, SCM_BOOL_F) == SCM_BOOL_F) { @@ -74,11 +74,11 @@ LY_DEFINE(ly_load_text_dimensions, "ly:load-text-dimensions", void try_load_text_metrics (String basename) { - String path = global_path.find (basename + ".textmetrics"); + String path = global_path.find (basename + ".textmetrics"); if (path != "") { String contents (gulp_file_to_string (path, true)); - contents = "(quote (" + contents + "))"; + contents = "(quote (" + contents + "))"; SCM lst = scm_c_eval_string (contents.to_str0 ()); ly_load_text_dimensions (lst); diff --git a/lily/text-spanner-engraver.cc b/lily/text-spanner-engraver.cc index 44a6ee8dda..0001365823 100644 --- a/lily/text-spanner-engraver.cc +++ b/lily/text-spanner-engraver.cc @@ -13,7 +13,7 @@ class Text_spanner_engraver : public Engraver { public: - TRANSLATOR_DECLARATIONS (Text_spanner_engraver); + TRANSLATOR_DECLARATIONS (Text_spanner_engraver); protected: virtual void finalize (); virtual void acknowledge_grob (Grob_info); @@ -25,11 +25,10 @@ private: Spanner *span_; Spanner *finished_; Music *current_req_; - Drul_array req_drul_; + Drul_array req_drul_; void typeset_all (); }; - Text_spanner_engraver::Text_spanner_engraver () { finished_ = 0; @@ -78,9 +77,8 @@ Text_spanner_engraver::process_music () else { current_req_ = req_drul_[START]; - span_ = make_spanner ("TextSpanner", req_drul_[START]->self_scm ()); + span_ = make_spanner ("TextSpanner", req_drul_[START]->self_scm ()); - Side_position_interface::set_axis (span_, Y_AXIS); req_drul_[START] = 0; } @@ -90,25 +88,25 @@ Text_spanner_engraver::process_music () void Text_spanner_engraver::acknowledge_grob (Grob_info info) { - Spanner * spans[2] ={span_, finished_}; - for (int i = 0; i < 2 ; i++) + Spanner *spans[2] ={span_, finished_}; + for (int i = 0; i < 2; i++) { if (spans[i] && Note_column::has_interface (info.grob_)) { Side_position_interface::add_support (spans[i], info.grob_); - add_bound_item (spans[i], dynamic_cast (info.grob_)); + add_bound_item (spans[i], dynamic_cast (info.grob_)); } } } void Text_spanner_engraver::typeset_all () -{ +{ if (finished_) { if (!finished_->get_bound (RIGHT)) { - Grob* e = unsmob_grob (get_property ("currentMusicalColumn")); + Grob *e = unsmob_grob (get_property ("currentMusicalColumn")); finished_->set_bound (RIGHT, e); } finished_ = 0; @@ -120,7 +118,7 @@ Text_spanner_engraver::stop_translation_timestep () { if (span_ && !span_->get_bound (LEFT)) { - Grob* e = unsmob_grob (get_property ("currentMusicalColumn")); + Grob *e = unsmob_grob (get_property ("currentMusicalColumn")); span_->set_bound (LEFT, e); } @@ -142,9 +140,9 @@ Text_spanner_engraver::finalize () } ADD_TRANSLATOR (Text_spanner_engraver, -/* descr */ "Create text spanner from a Music.", -/* creats*/ "TextSpanner", -/* accepts */ "text-span-event", -/* acks */ "note-column-interface", -/* reads */ "", -/* write */ ""); + /* descr */ "Create text spanner from a Music.", + /* creats*/ "TextSpanner", + /* accepts */ "text-span-event", + /* acks */ "note-column-interface", + /* reads */ "", + /* write */ ""); diff --git a/lily/text-spanner.cc b/lily/text-spanner.cc index 2919f01a25..f21432c9e7 100644 --- a/lily/text-spanner.cc +++ b/lily/text-spanner.cc @@ -5,7 +5,7 @@ (c) 2000--2005 Jan Nieuwenhuizen - Revised over good by Han-Wen. + Revised over good by Han-Wen. */ #include "text-spanner.hh" @@ -34,15 +34,15 @@ MAKE_SCHEME_CALLBACK (Text_spanner, print, 1); TODO: this function is too long */ SCM -Text_spanner::print (SCM smob) +Text_spanner::print (SCM smob) { Grob *me = unsmob_grob (smob); - Spanner *spanner = dynamic_cast (me); - + Spanner *spanner = dynamic_cast (me); + /* Ugh, must be same as Hairpin::print. */ Grob *common = spanner->get_bound (LEFT)->common_refpoint (spanner->get_bound (RIGHT), X_AXIS); - Output_def * layout = me->get_layout (); + Output_def *layout = me->get_layout (); SCM flare = me->get_property ("bracket-flare"); SCM shorten = me->get_property ("shorten-pair"); @@ -63,23 +63,22 @@ Text_spanner::print (SCM smob) span_points[d] = b->relative_coordinate (common, X_AXIS); } else - { - Real encl = robust_scm2double (me->get_property ("enclose-bounds"), 0.0); - Interval ext = b->extent (common, X_AXIS); - - span_points[d] = - robust_relative_extent (b, common, X_AXIS).linear_combination (d * encl); - - if (is_number_pair (shorten)) - span_points -= d * scm_to_double (index_get_cell (shorten, d)); - } - + { + Real encl = robust_scm2double (me->get_property ("enclose-bounds"), 0.0); + Interval ext = b->extent (common, X_AXIS); + + span_points[d] + = robust_relative_extent (b, common, X_AXIS).linear_combination (d * encl); + + if (is_number_pair (shorten)) + span_points -= d * scm_to_double (index_get_cell (shorten, d)); + } + if (is_number_pair (flare)) span_points -= d * scm_to_double (index_get_cell (flare, d)); } while (flip (&d) != LEFT); - SCM properties = Font_interface::text_font_alist_chain (me); SCM edge_text = me->get_property ("edge-text"); Drul_array edge; @@ -90,40 +89,40 @@ Text_spanner::print (SCM smob) { if (broken[d]) continue; - + SCM text = index_get_cell (edge_text, d); - if (Text_interface::markup_p (text)) + if (Text_interface::markup_p (text)) edge[d] = *unsmob_stencil (Text_interface::interpret_markup (layout->self_scm (), properties, text)); - + if (!edge[d].is_empty ()) edge[d].align_to (Y_AXIS, CENTER); } while (flip (&d) != LEFT); } - + Drul_array edge_height = robust_scm2interval (me->get_property ("edge-height"), Interval (0.0, 0.0)); Drul_array edge_line; - { - Direction d = LEFT; - int dir = to_dir (me->get_property ("direction")); - do - { - if (broken[d]) - continue; - - Real dx = 0.0; - if (is_number_pair (flare)) - dx = scm_to_double (index_get_cell (flare, d)) * d; - - Real dy = - dir * edge_height[d] ; - if (dy) - edge_line[d] = Line_spanner::line_stencil (me, Offset (0, 0), Offset (dx, dy)); - } - while (flip (&d) != LEFT); - } - + { + Direction d = LEFT; + int dir = to_dir (me->get_property ("direction")); + do + { + if (broken[d]) + continue; + + Real dx = 0.0; + if (is_number_pair (flare)) + dx = scm_to_double (index_get_cell (flare, d)) * d; + + Real dy = -dir * edge_height[d]; + if (dy) + edge_line[d] = Line_spanner::line_stencil (me, Offset (0, 0), Offset (dx, dy)); + } + while (flip (&d) != LEFT); + } + Stencil m; do { @@ -132,7 +131,7 @@ Text_spanner::print (SCM smob) { edge[d].translate_axis (span_points[d], X_AXIS); m.add_stencil (edge[d]); - span_points[d] += -d * ext[-d]; + span_points[d] += -d * ext[-d]; } } while (flip (&d) != LEFT); @@ -149,7 +148,7 @@ Text_spanner::print (SCM smob) if (!span_points.is_empty ()) { Stencil l = Line_spanner::line_stencil (me, Offset (span_points[LEFT], 0), - Offset (span_points[RIGHT], 0)); + Offset (span_points[RIGHT], 0)); m.add_stencil (l); } m.translate_axis (- me->relative_coordinate (common, X_AXIS), X_AXIS); diff --git a/lily/tfm-reader.cc b/lily/tfm-reader.cc index fa91480267..1b6862ec02 100644 --- a/lily/tfm-reader.cc +++ b/lily/tfm-reader.cc @@ -1,13 +1,13 @@ -/* +/* tfm-reader.cc -- implement Tex_font_metric_reader - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Jan Nieuwenhuizen - + some code shamelessly copied from GNU fontutils-0.6/tfm/tfm_input.c - */ +*/ #include "tfm-reader.hh" @@ -15,15 +15,14 @@ #include "warn.hh" #define format_string String_convert::form_string -#define FIX_UNITY \ - (1 << 20) +#define FIX_UNITY \ + (1 << 20) static const Real fix_to_real (Fix f); - Tex_font_metric_reader::Tex_font_metric_reader (String name) : input_ (name) { - + for (int i = 0; i < TFM_SIZE; i++) ascii_to_metric_idx_.push (-1); @@ -71,7 +70,7 @@ void Tex_font_metric_reader::read_header () { U16 file_length = input_.get_U16 (); - (void) file_length; + (void) file_length; U16 header_length = input_.get_U16 (); info_.first_charcode = input_.get_U16 (); @@ -82,21 +81,21 @@ Tex_font_metric_reader::read_header () U16 italic_correction_word_count = input_.get_U16 (); U16 lig_kern_word_count = input_.get_U16 (); U16 kern_word_count = input_.get_U16 (); - (void)kern_word_count; + (void)kern_word_count; U16 extensible_word_count = input_.get_U16 (); - (void)extensible_word_count; - + (void)extensible_word_count; + header_.param_word_count = input_.get_U16 (); info_.parameter_count = header_.param_word_count; header_.char_info_pos = (6 + header_length) * 4; header_.width_pos = header_.char_info_pos - + (info_.last_charcode - - info_.first_charcode + 1) * 4; + + (info_.last_charcode + - info_.first_charcode + 1) * 4; header_.height_pos = header_.width_pos + width_word_count * 4; header_.depth_pos = header_.height_pos + height_word_count * 4; header_.italic_correction_pos = header_.depth_pos - + depth_word_count * 4; + + depth_word_count * 4; header_.lig_kern_pos = header_.italic_correction_pos + italic_correction_word_count * 4; header_.kern_pos = header_.lig_kern_pos + lig_kern_word_count * 4; @@ -183,7 +182,7 @@ Tex_font_metric_reader::read_char_metric (Char_code code) try to read it. */ if (code < info_.first_charcode || code > info_.last_charcode) return tfm_char; - + //brr /* Move to the appropriate place in the `char_info' array. */ input_.seek_str0 (header_.char_info_pos + (code - info_.first_charcode) * 4); @@ -197,7 +196,6 @@ Tex_font_metric_reader::read_char_metric (Char_code code) return tfm_char; } - /* We assume we are positioned at the beginning of a `char_info' word. We read that word to get the indexes into the dimension tables; then we go read the tables to get the values (if the character exists). */ @@ -221,14 +219,14 @@ Tex_font_metric_reader::read_char () Tex_font_char_metric tfm_char; -#define GET_CHAR_DIMEN(d) \ - if (d##_index != 0) \ - { \ - input_.seek_str0 (header_. d##_pos + d##_index*4); \ - tfm_char.d##_fix_ = input_.get_U32 (); \ - tfm_char.d##_ = fix_to_real (tfm_char.d##_fix_) \ - * info_.design_size; \ - } +#define GET_CHAR_DIMEN(d) \ + if (d##_index != 0) \ + { \ + input_.seek_str0 (header_. d##_pos + d##_index*4); \ + tfm_char.d##_fix_ = input_.get_U32 (); \ + tfm_char.d##_ = fix_to_real (tfm_char.d##_fix_) \ + * info_.design_size; \ + } GET_CHAR_DIMEN (width); GET_CHAR_DIMEN (height); @@ -259,7 +257,7 @@ Tex_font_metric_reader::read_char () #define KERN_FLAG 128 void -Tex_font_metric_reader::read_lig_kern_program (Array * ligatures, Array * kerns) +Tex_font_metric_reader::read_lig_kern_program (Array* ligatures, Array* kerns) { bool end_b; @@ -271,13 +269,12 @@ Tex_font_metric_reader::read_lig_kern_program (Array * ligatures, bool kern_step_b = input_.get_U8 () >= KERN_FLAG; U8 remainder = input_.get_U8 (); - if (kern_step_b) { Tfm_kern kern_element; kern_element.character = next_char; - char const* old_pos = input_.pos_str0 (); + char const *old_pos = input_.pos_str0 (); input_.seek_str0 (header_.kern_pos + remainder * 4); kern_element.kern = get_U32_fix_scaled (); input_.set_pos (old_pos); @@ -293,6 +290,8 @@ Tex_font_metric_reader::read_lig_kern_program (Array * ligatures, ligatures->push (ligature_element); } - } while (!end_b); + } + while (!end_b); + } diff --git a/lily/tfm.cc b/lily/tfm.cc index 1e8dc4fb00..8d86135022 100644 --- a/lily/tfm.cc +++ b/lily/tfm.cc @@ -1,12 +1,12 @@ -/* +/* tfm.cc -- implement Tex_font_metric - + source file of the GNU LilyPond music typesetter - + (c) 1999--2005 Jan Nieuwenhuizen some code shamelessly copied from GNU fontutils-0.6/tfm/tfm_input.c - */ +*/ #include "file-name.hh" #include "tfm.hh" @@ -40,11 +40,11 @@ Tex_font_char_metric::dimensions () const b.set_empty (); return b; } - + Real d = -depth_; Real point_constant = 1 PT; - - return Box (Interval (0, width_* point_constant ), + + return Box (Interval (0, width_* point_constant), Interval ((d ? height_) * point_constant)); } @@ -65,10 +65,10 @@ Tex_font_metric::find_ascii (int ascii, bool warn) const { if (ascii >= 0 && ascii < ascii_to_metric_idx_.size () && ascii_to_metric_idx_[ascii] >= 0) - return & char_metrics_[ascii_to_metric_idx_ [ascii]]; + return &char_metrics_[ascii_to_metric_idx_ [ascii]]; else if (warn) warning (_f ("can't find ascii character: %d", ascii)); - return &dummy_static_char_metric; + return &dummy_static_char_metric; } /* UGH: glyphs need not be consecutive in TFM. */ diff --git a/lily/tie-column.cc b/lily/tie-column.cc index a6f053376e..9f8bf74fb9 100644 --- a/lily/tie-column.cc +++ b/lily/tie-column.cc @@ -1,11 +1,10 @@ -/* +/* tie-column.cc -- implement Tie_column - + source file of the GNU LilyPond music typesetter - + (c) 2000--2005 Han-Wen Nienhuys - - */ +*/ #include "tie-column.hh" #include "paper-column.hh" @@ -20,65 +19,62 @@ */ /* TODO: this doesn't follow standard pattern. Regularize. - */ +*/ void -Tie_column::add_tie (Grob*me, Grob *tie) +Tie_column::add_tie (Grob *me, Grob *tie) { if (tie->get_parent (Y_AXIS) && Tie_column::has_interface (tie->get_parent (Y_AXIS))) - return ; + return; - if (!Pointer_group_interface::count (me, ly_symbol2scm ("ties"))) { - dynamic_cast (me)->set_bound (LEFT, Tie::head (tie, LEFT)); - dynamic_cast (me)->set_bound (RIGHT, Tie::head (tie, RIGHT)); + dynamic_cast (me)->set_bound (LEFT, Tie::head (tie, LEFT)); + dynamic_cast (me)->set_bound (RIGHT, Tie::head (tie, RIGHT)); } - - + tie->set_parent (me, Y_AXIS); Pointer_group_interface::add_grob (me, ly_symbol2scm ("ties"), tie); tie->add_dependency (me); } void -Tie_column::set_directions (Grob*me) +Tie_column::set_directions (Grob *me) { werner_directions (me); } int -tie_compare (Grob* const & s1, - Grob* const & s2) +tie_compare (Grob *const &s1, + Grob *const &s2) { return sign (Tie::get_position (s1) - Tie::get_position (s2)); } /* -Werner: + Werner: - . The algorithm to choose the direction of the ties doesn't work - properly. I suggest the following for applying ties sequentially - from top to bottom: + . The algorithm to choose the direction of the ties doesn't work + properly. I suggest the following for applying ties sequentially + from top to bottom: - + The topmost tie is always `up'. + + The topmost tie is always `up'. - + If there is a vertical gap to the last note above larger than - or equal to a fifth (or sixth?), the tie is `up', otherwise it - is `down'. - - + The bottommost tie is always `down'. + + If there is a vertical gap to the last note above larger than + or equal to a fifth (or sixth?), the tie is `up', otherwise it + is `down'. + + The bottommost tie is always `down'. */ void Tie_column::werner_directions (Grob *me) { - Link_array ties = - extract_grob_array (me, ly_symbol2scm ("ties")); + Link_array ties + = extract_grob_array (me, ly_symbol2scm ("ties")); if (!ties.size ()) - return ; - + return; + ties.sort (tie_compare); Direction d = get_grob_direction (me); @@ -86,20 +82,20 @@ Tie_column::werner_directions (Grob *me) { for (int i = ties.size (); i--;) { - Grob * t = ties[i]; + Grob *t = ties[i]; if (!get_grob_direction (t)) set_grob_direction (t, d); } - return ; + return; } - + if (ties.size () == 1) { - Grob * t = ties[0]; + Grob *t = ties[0]; if (t->is_live () && !get_grob_direction (t)) set_grob_direction (t, Tie::get_default_dir (t)); - return ; + return; } Real last_down_pos = 10000; @@ -108,19 +104,19 @@ Tie_column::werner_directions (Grob *me) /* Go downward. - */ + */ Grob *last_tie = 0; for (int i = ties.size (); i--;) { Grob *t = ties[i]; - + Direction d = get_grob_direction (t); - Real p = Tie::get_position (t); + Real p = Tie::get_position (t); if (!d) { if (last_tie && Tie::get_column_rank (t, LEFT) - < Tie::get_column_rank (last_tie, LEFT)) + < Tie::get_column_rank (last_tie, LEFT)) { d = DOWN; } @@ -142,10 +138,9 @@ Tie_column::werner_directions (Grob *me) last_tie = t; } - return ; + return; } - MAKE_SCHEME_CALLBACK (Tie_column, after_line_breaking, 1); SCM Tie_column::after_line_breaking (SCM smob) @@ -156,19 +151,19 @@ Tie_column::after_line_breaking (SCM smob) /* Extend the spanner over its Tie constituents. - */ +*/ MAKE_SCHEME_CALLBACK (Tie_column, before_line_breaking, 1); SCM Tie_column::before_line_breaking (SCM smob) { - Spanner *me = dynamic_cast (unsmob_grob (smob)); + Spanner *me = dynamic_cast (unsmob_grob (smob)); for (SCM s = me->get_property ("ties"); scm_is_pair (s); s = scm_cdr (s)) { - Spanner *tie = dynamic_cast (unsmob_grob (scm_car (s))); + Spanner *tie = dynamic_cast (unsmob_grob (scm_car (s))); Direction dir = LEFT; do { - if (dir * Paper_column::get_rank (tie->get_bound (dir)->get_column ()) + if (dir * Paper_column::get_rank (tie->get_bound (dir)->get_column ()) > dir * Paper_column::get_rank (me->get_bound (dir)->get_column ())) { me->set_bound (dir, Tie::head (tie, dir)); @@ -180,6 +175,6 @@ Tie_column::before_line_breaking (SCM smob) } ADD_INTERFACE (Tie_column, "tie-column-interface", - "Object that sets directions of multiple ties in a tied chord", - "direction"); + "Object that sets directions of multiple ties in a tied chord", + "direction"); diff --git a/lily/tie-engraver.cc b/lily/tie-engraver.cc index 43d6917587..efd6098c5a 100644 --- a/lily/tie-engraver.cc +++ b/lily/tie-engraver.cc @@ -1,11 +1,10 @@ -/* +/* tie-engraver.cc -- implement Tie_engraver - + source file of the GNU LilyPond music typesetter - + (c) 1998--2005 Han-Wen Nienhuys - - */ +*/ #include "tie.hh" #include "context.hh" @@ -33,10 +32,10 @@ struct Head_event_tuple Grob *head_; SCM tie_definition_; Music *event_; - Head_event_tuple() + Head_event_tuple () { } - Head_event_tuple(Grob *h, Music *m, SCM def) + Head_event_tuple (Grob *h, Music *m, SCM def) { head_ = h; event_ = m; @@ -50,27 +49,26 @@ class Tie_engraver : public Engraver Link_array now_heads_; Array heads_to_tie_; Link_array ties_; - - Spanner * tie_column_; - + + Spanner *tie_column_; + protected: virtual void stop_translation_timestep (); virtual void derived_mark () const; virtual void start_translation_timestep (); virtual void acknowledge_grob (Grob_info); - virtual bool try_music (Music*); + virtual bool try_music (Music *); virtual void process_music (); - void typeset_tie (Grob*); + void typeset_tie (Grob *); public: TRANSLATOR_DECLARATIONS (Tie_engraver); }; - void Tie_engraver::derived_mark () const { Engraver::derived_mark (); - for (int i = 0; i < heads_to_tie_.size(); i++) + for (int i = 0; i < heads_to_tie_.size (); i++) scm_gc_mark (heads_to_tie_[i].tie_definition_); } @@ -80,7 +78,6 @@ Tie_engraver::Tie_engraver () tie_column_ = 0; } - bool Tie_engraver::try_music (Music *mus) { @@ -88,7 +85,7 @@ Tie_engraver::try_music (Music *mus) { event_ = mus; } - + return true; } @@ -106,29 +103,29 @@ Tie_engraver::acknowledge_grob (Grob_info i) { if (Note_head::has_interface (i.grob_)) { - Grob * h = i.grob_; + Grob *h = i.grob_; now_heads_.push (h); - for (int i = heads_to_tie_.size (); i--;) + for (int i = heads_to_tie_.size (); i--;) { - Grob *th = heads_to_tie_[i].head_; - Music * right_mus = unsmob_music (h->get_property ("cause")); - Music * left_mus = unsmob_music (th->get_property ("cause")); + Grob *th = heads_to_tie_[i].head_; + Music *right_mus = unsmob_music (h->get_property ("cause")); + Music *left_mus = unsmob_music (th->get_property ("cause")); /* maybe should check positions too. - */ + */ if (right_mus && left_mus && ly_c_equal_p (right_mus->get_property ("pitch"), - left_mus->get_property ("pitch"))) + left_mus->get_property ("pitch"))) { - Grob * p = new Spanner (heads_to_tie_[i].tie_definition_, - context()->get_grob_key ("Tie")); + Grob *p = new Spanner (heads_to_tie_[i].tie_definition_, + context ()->get_grob_key ("Tie")); announce_grob (p, heads_to_tie_[i].event_->self_scm ()); Tie::set_interface (p); // cannot remove yet! - + Tie::set_head (p, LEFT, th); Tie::set_head (p, RIGHT, h); - + ties_.push (p); heads_to_tie_.del (i); } @@ -150,7 +147,7 @@ Tie_engraver::start_translation_timestep () { context ()->set_property ("tieMelismaBusy", ly_bool2scm (heads_to_tie_.size ())); - + } void @@ -162,8 +159,8 @@ Tie_engraver::stop_translation_timestep () { heads_to_tie_.clear (); } - - for (int i = 0; i< ties_.size (); i++) + + for (int i = 0; i< ties_.size (); i++) { typeset_tie (ties_[i]); } @@ -171,23 +168,22 @@ Tie_engraver::stop_translation_timestep () ties_.clear (); tie_column_ = 0; } - + if (event_) { SCM start_definition = updated_grob_properties (context (), ly_symbol2scm ("Tie")); if (!to_boolean (get_property ("tieWaitForNote"))) - heads_to_tie_.clear(); + heads_to_tie_.clear (); - for (int i = 0; i < now_heads_.size(); i++) + for (int i = 0; i < now_heads_.size (); i++) { heads_to_tie_.push (Head_event_tuple (now_heads_[i], event_, - start_definition - )); - } + start_definition)); + } } - + event_ = 0; now_heads_.clear (); } @@ -201,22 +197,23 @@ Tie_engraver::typeset_tie (Grob *her) Direction d = LEFT; Drul_array new_head_drul; new_head_drul[LEFT] = Tie::head (her, LEFT); - new_head_drul[RIGHT] = Tie::head (her, RIGHT); - do { - if (!Tie::head (her, d)) - new_head_drul[d] = Tie::head (her, (Direction)-d); - } while (flip (&d) != LEFT); + new_head_drul[RIGHT] = Tie::head (her, RIGHT); + do + { + if (!Tie::head (her, d)) + new_head_drul[d] = Tie::head (her, (Direction) - d); + } + while (flip (&d) != LEFT); index_set_cell (her->get_property ("head-pair"), LEFT, new_head_drul[LEFT]->self_scm ()); index_set_cell (her->get_property ("head-pair"), RIGHT, new_head_drul[RIGHT]->self_scm ()); } - ADD_TRANSLATOR (Tie_engraver, -/* descr */ "Generate ties between noteheads of equal pitch.", -/* creats*/ "Tie TieColumn", -/* accepts */ "tie-event", -/* acks */ "rhythmic-head-interface", -/* reads */ "tieMelismaBusy", -/* write */ ""); + /* descr */ "Generate ties between noteheads of equal pitch.", + /* creats*/ "Tie TieColumn", + /* accepts */ "tie-event", + /* acks */ "rhythmic-head-interface", + /* reads */ "tieMelismaBusy", + /* write */ ""); diff --git a/lily/tie-performer.cc b/lily/tie-performer.cc index 560d89bde2..2c0b3c4b32 100644 --- a/lily/tie-performer.cc +++ b/lily/tie-performer.cc @@ -1,11 +1,10 @@ -/* +/* tie-performer.cc -- implement Tie_performer - + source file of the GNU LilyPond music typesetter - + (c) 1998--2005 Han-Wen Nienhuys - - */ +*/ #include "context.hh" #include "audio-item.hh" @@ -20,12 +19,12 @@ class Tie_performer : public Performer Array heads_to_tie_; bool ties_created_; - + protected: virtual void stop_translation_timestep (); virtual void start_translation_timestep (); virtual void acknowledge_audio_element (Audio_element_info); - virtual bool try_music (Music*); + virtual bool try_music (Music *); virtual void process_music (); public: TRANSLATOR_DECLARATIONS (Tie_performer); @@ -34,7 +33,7 @@ public: Tie_performer::Tie_performer () { event_ = 0; - last_event_ = 0; + last_event_ = 0; ties_created_ = false; } @@ -45,7 +44,7 @@ Tie_performer::try_music (Music *mus) { event_ = mus; } - + return true; } @@ -59,22 +58,22 @@ Tie_performer::process_music () void Tie_performer::acknowledge_audio_element (Audio_element_info inf) { - if (Audio_note * an = dynamic_cast (inf.elem_)) + if (Audio_note *an = dynamic_cast (inf.elem_)) { now_heads_.push (inf); - for (int i = heads_to_tie_.size (); i--;) + for (int i = heads_to_tie_.size (); i--;) { - Music * right_mus = inf.event_; - - Audio_note *th = dynamic_cast (heads_to_tie_[i].elem_); - Music * left_mus = heads_to_tie_[i].event_; + Music *right_mus = inf.event_; + + Audio_note *th = dynamic_cast (heads_to_tie_[i].elem_); + Music *left_mus = heads_to_tie_[i].event_; if (right_mus && left_mus && ly_c_equal_p (right_mus->get_property ("pitch"), left_mus->get_property ("pitch"))) { an->tie_to (th); - ties_created_ = true; + ties_created_ = true; } } } @@ -85,7 +84,7 @@ Tie_performer::start_translation_timestep () { context ()->set_property ("tieMelismaBusy", ly_bool2scm (heads_to_tie_.size ())); - + } void @@ -97,7 +96,7 @@ Tie_performer::stop_translation_timestep () last_event_ = 0; ties_created_ = false; } - + if (event_) { heads_to_tie_ = now_heads_; @@ -108,9 +107,9 @@ Tie_performer::stop_translation_timestep () } ADD_TRANSLATOR (Tie_performer, -/* descr */ "Generate ties between noteheads of equal pitch.", -/* creats*/ "", -/* accepts */ "tie-event", -/* acks */ "", -/* reads */ "tieMelismaBusy", -/* write */ ""); + /* descr */ "Generate ties between noteheads of equal pitch.", + /* creats*/ "", + /* accepts */ "tie-event", + /* acks */ "", + /* reads */ "tieMelismaBusy", + /* write */ ""); diff --git a/lily/tie.cc b/lily/tie.cc index 569aa220ad..59755a8ad7 100644 --- a/lily/tie.cc +++ b/lily/tie.cc @@ -34,28 +34,26 @@ c4 \staffchange c4 do we have non-horizontal ties then? - */ - +*/ void -Tie::set_head (Grob*me, Direction d, Grob * h) +Tie::set_head (Grob *me, Direction d, Grob *h) { assert (!head (me, d)); index_set_cell (me->get_property ("head-pair"), d, h->self_scm ()); - - dynamic_cast (me)->set_bound (d, h); + + dynamic_cast (me)->set_bound (d, h); me->add_dependency (h); } void -Tie::set_interface (Grob*me) +Tie::set_interface (Grob *me) { me->set_property ("head-pair", scm_cons (SCM_EOL, SCM_EOL)); } - -Grob* -Tie::head (Grob*me, Direction d) +Grob * +Tie::head (Grob *me, Direction d) { SCM c = me->get_property ("head-pair"); @@ -68,39 +66,37 @@ Tie::head (Grob*me, Direction d) int Tie::get_column_rank (Grob *me, Direction d) { - Spanner *span = dynamic_cast (me); - Grob * h = head (me, d); + Spanner *span = dynamic_cast (me); + Grob *h = head (me, d); if (!h) h = span->get_bound (d); - Grob *col = dynamic_cast (h)->get_column (); + Grob *col = dynamic_cast (h)->get_column (); return Paper_column::get_rank (col); } Real -Tie::get_position (Grob*me) +Tie::get_position (Grob *me) { Direction d = head (me, LEFT) ? LEFT:RIGHT; return Staff_symbol_referencer::get_position (head (me, d)); } - /* Default: Put the tie oppositie of the stem [Wanske p231] In case of chords: Tie_column takes over - + The direction of the Tie is more complicated (See [Ross] p136 and further). - (what about linebreaks? ) - + (what about linebreaks? ) */ Direction -Tie::get_default_dir (Grob*me) +Tie::get_default_dir (Grob *me) { - Item * sl = head (me, LEFT) ? Rhythmic_head::get_stem (head (me, LEFT)) :0; - Item * sr = head (me, RIGHT) ? Rhythmic_head::get_stem (head (me, RIGHT)) :0; + Item *sl = head (me, LEFT) ? Rhythmic_head::get_stem (head (me, LEFT)) :0; + Item *sr = head (me, RIGHT) ? Rhythmic_head::get_stem (head (me, RIGHT)) :0; if (sl && sr) { if (get_grob_direction (sl) == UP @@ -110,16 +106,14 @@ Tie::get_default_dir (Grob*me) else if (sl || sr) { Item *s = sl ? sl : sr; - return - get_grob_direction (s); + return -get_grob_direction (s); } - return UP; } - void -Tie::set_direction (Grob*me) +Tie::set_direction (Grob *me) { if (!get_grob_direction (me)) { @@ -133,13 +127,12 @@ Tie::set_direction (Grob*me) /* TODO: we should also use thickness for computing the clearance between head and tie. Very thick ties will now touch the note head. - - */ +*/ SCM Tie::get_control_points (SCM smob) -{ - Spanner*me = unsmob_spanner (smob); - Direction headdir = CENTER; +{ + Spanner *me = unsmob_spanner (smob); + Direction headdir = CENTER; if (head (me, LEFT)) headdir = LEFT; else if (head (me, RIGHT)) @@ -154,33 +147,33 @@ Tie::get_control_points (SCM smob) set_direction (me); Direction dir = get_grob_direction (me); - + Real staff_space = Staff_symbol_referencer::staff_space (me); Real x_gap_f = robust_scm2double (me->get_property ("x-gap"), 0); - Grob* l = me->get_bound (LEFT); - Grob* r = me->get_bound (RIGHT); + Grob *l = me->get_bound (LEFT); + Grob *r = me->get_bound (RIGHT); - Grob* commonx = me->common_refpoint (l, X_AXIS); + Grob *commonx = me->common_refpoint (l, X_AXIS); commonx = me->common_refpoint (r, X_AXIS); - + Real left_x; /* - the tie has to be long enough to be visible, but should not go + the tie has to be long enough to be visible, but should not go through key sigs. In the 1.5 series the pref.matter - note distance is fixed , so this won't be a problem anymore. - */ - Real lambda = 0.9; - + */ + Real lambda = 0.9; + if (Note_head::has_interface (l)) { Real where = RIGHT; /* This correction is due te the shape of the black note head. - */ + */ if (Rhythmic_head::duration_log (l) == 2) where += dir* 0.2; left_x = l->extent (l, X_AXIS).linear_combination (where) @@ -188,13 +181,12 @@ Tie::get_control_points (SCM smob) } else left_x = l->extent (l, X_AXIS).linear_combination (lambda); - Real width; if (Note_head::has_interface (l) && Note_head::has_interface (r)) { - width = - + r->extent (commonx, X_AXIS)[LEFT] + width + = + r->extent (commonx, X_AXIS)[LEFT] - l->extent (commonx, X_AXIS)[RIGHT] -2 * x_gap_f; } @@ -205,24 +197,22 @@ Tie::get_control_points (SCM smob) - l->extent (commonx, X_AXIS)[RIGHT] - 2 * x_gap_f; else - width = - - l->extent (commonx, X_AXIS).linear_combination (lambda) + width + = -l->extent (commonx, X_AXIS).linear_combination (lambda) + r->extent (commonx, X_AXIS)[LEFT] - 2 * x_gap_f; } - - SCM details = me->get_property ("details"); SCM lim // groetjes aan de chirurgendochter. = scm_assq (ly_symbol2scm ("height-limit"), details); - - Real h_inf = scm_to_double (scm_cdr (lim)) * staff_space; + + Real h_inf = scm_to_double (scm_cdr (lim)) * staff_space; Real r_0 = scm_to_double (scm_cdr (scm_assq (ly_symbol2scm ("ratio"), details))); - Bezier b = slur_shape (width, h_inf, r_0); - + Bezier b = slur_shape (width, h_inf, r_0); + /* I think this better, particularly for small ties. It always allows the user to move ties if they seem in the wrong place @@ -231,59 +221,57 @@ Tie::get_control_points (SCM smob) */ - Real ypos = Tie::get_position (me) * staff_space/2 + Real ypos = Tie::get_position (me) * staff_space / 2 + dir * scm_to_double (me->get_property ("y-offset"));; /* Make sure we don't start on a dots - */ + */ if (Note_head::has_interface (l) && Rhythmic_head::get_dots (l)) { - Grob* dots = Rhythmic_head::get_dots (l); + Grob *dots = Rhythmic_head::get_dots (l); if (fabs (staff_space * Staff_symbol_referencer::get_position (dots) /2 - - ypos) < 0.5) + - ypos) < 0.5) { - ypos += 0.5 * dir ; + ypos += 0.5 * dir; } } - /* todo: prevent ending / staffline collision. todo: tie / stem collision - */ + */ b = slur_shape (width, h_inf, r_0); b.scale (1, dir); b.translate (Offset (left_x, ypos)); - /* Avoid colliding of the horizontal part with stafflines. - + TODO: redo this, heuristic is half-baken, and ties often look ugly as a result. TODO: doesn't work when on staff with even number of lines. - */ + */ Array horizontal (b.solve_derivative (Offset (1, 0))); if (horizontal.size ()) { /* ugh. Doesnt work for non-horizontal curves. - */ + */ Real y = b.curve_point (horizontal[0])[Y_AXIS]; - Real ry = rint (y/staff_space) * staff_space; + Real ry = rint (y / staff_space) * staff_space; Real diff = ry - y; Real newy = y; Real clear = staff_space * scm_to_double (me->get_property ("staffline-clearance")); - if (fabs (y) <= - Staff_symbol_referencer::staff_radius (me) * staff_space + clear + if (fabs (y) + <= Staff_symbol_referencer::staff_radius (me) * staff_space + clear && fabs (diff) < clear) { Real y1 = ry + clear; @@ -295,47 +283,44 @@ Tie::get_control_points (SCM smob) Any way. This test is to make sure that staffline collision avoidance does not result in completely flat ties. - */ + */ if (fabs (y1 - ypos) < 0.5) y1 = y2; else if (fabs (y2 - ypos) < 0.5) y2 = y1; - + newy = (fabs (y1 - y) < fabs (y2 - y)) ? y1 : y2; - + // newy = ry - 0.5 * staff_space * sign (diff) ; /* we don't want horizontal ties - */ + */ if (fabs (newy - b.control_[0][Y_AXIS]) < 1e-2) { - newy = newy + dir * staff_space; + newy = newy + dir * staff_space; } } Real y0 = b.control_ [0][Y_AXIS]; - b.control_[2][Y_AXIS] = - b.control_[1][Y_AXIS] = - (b.control_[1][Y_AXIS] - y0) * ((newy - y0) / (y - y0)) + y0; + b.control_[2][Y_AXIS] + = b.control_[1][Y_AXIS] + = (b.control_[1][Y_AXIS] - y0) * ((newy - y0) / (y - y0)) + y0; } else programming_error ("Tie is nowhere horizontal"); - - SCM controls = SCM_EOL; for (int i = 4; i--;) controls = scm_cons (ly_offset2scm (b.control_[i]), controls); return controls; } - MAKE_SCHEME_CALLBACK (Tie, print, 1); SCM -Tie::print (SCM smob) +Tie::print (SCM smob) { - Grob*me = unsmob_grob (smob); + Grob *me = unsmob_grob (smob); SCM cp = me->get_property ("control-points"); if (!scm_is_pair (cp)) // list is more accurate @@ -346,10 +331,10 @@ Tie::print (SCM smob) if (!scm_is_pair (cp)) return Stencil ().smobbed_copy (); - + Real thick = Staff_symbol_referencer::line_thickness (me) - * robust_scm2double (me->get_property ("thickness"), 1); + * robust_scm2double (me->get_property ("thickness"), 1); Bezier b; int i = 0; @@ -358,15 +343,12 @@ Tie::print (SCM smob) b.control_[i] = ly_scm2offset (scm_car (s)); i++; } - - Stencil a = Lookup::slur (b, get_grob_direction (me) * thick, thick); - - return a.smobbed_copy (); -} + Stencil a = Lookup::slur (b, get_grob_direction (me) * thick, thick); + return a.smobbed_copy (); +} ADD_INTERFACE (Tie, "tie-interface", - "A tie connecting two noteheads.\n" - , - "y-offset staffline-clearance control-points head-pair details thickness x-gap direction minimum-length"); + "A tie connecting two noteheads.\n", + "y-offset staffline-clearance control-points head-pair details thickness x-gap direction minimum-length"); diff --git a/lily/time-scaled-music-iterator.cc b/lily/time-scaled-music-iterator.cc index 77581af8e9..06a4f7ab1b 100644 --- a/lily/time-scaled-music-iterator.cc +++ b/lily/time-scaled-music-iterator.cc @@ -1,11 +1,10 @@ -/* +/* time-scaled-music-iterator.cc -- implement Time_scaled_music_iterator - + source file of the GNU LilyPond music typesetter - + (c) 1998--2005 Han-Wen Nienhuys - - */ +*/ #include "time-scaled-music-iterator.hh" #include "context.hh" @@ -25,5 +24,5 @@ Time_scaled_music_iterator::process (Moment m) Music_wrapper_iterator::process (m); } - + IMPLEMENT_CTOR_CALLBACK (Time_scaled_music_iterator); diff --git a/lily/time-signature-engraver.cc b/lily/time-signature-engraver.cc index e217fd9003..5dc4913a80 100644 --- a/lily/time-signature-engraver.cc +++ b/lily/time-signature-engraver.cc @@ -12,8 +12,8 @@ #include "misc.hh" /** - generate time_signatures. - */ + generate time_signatures. +*/ class Time_signature_engraver : public Engraver { Item *time_signature_; @@ -26,9 +26,8 @@ public: TRANSLATOR_DECLARATIONS (Time_signature_engraver); }; - Time_signature_engraver::Time_signature_engraver () -{ +{ time_signature_ = 0; last_time_fraction_ = SCM_BOOL_F; } @@ -51,15 +50,13 @@ Time_signature_engraver::process_music () Todo: should make typecheck? OTOH, Tristan Keuris writes 8/20 in his Intermezzi. - */ + */ warning (_f ("Found strange time signature %d/%d.", - den, - scm_to_int (scm_car (fr)) - )); + den, + scm_to_int (scm_car (fr)))); } - - - last_time_fraction_ = fr; + + last_time_fraction_ = fr; time_signature_ = make_item ("TimeSignature", SCM_EOL); time_signature_->set_property ("fraction", fr); } @@ -70,12 +67,11 @@ Time_signature_engraver::stop_translation_timestep () { time_signature_ = 0; } - ADD_TRANSLATOR (Time_signature_engraver, -/* descr */ "Create a TimeSignature whenever @code{timeSignatureFraction} changes", -/* creats*/ "TimeSignature", -/* accepts */ "", -/* acks */ "", -/* reads */ "", -/* write */ ""); + /* descr */ "Create a TimeSignature whenever @code{timeSignatureFraction} changes", + /* creats*/ "TimeSignature", + /* accepts */ "", + /* acks */ "", + /* reads */ "", + /* write */ ""); diff --git a/lily/time-signature-performer.cc b/lily/time-signature-performer.cc index 3b499d5ddd..4b9aad5e48 100644 --- a/lily/time-signature-performer.cc +++ b/lily/time-signature-performer.cc @@ -23,10 +23,9 @@ protected: SCM prev_fraction_; private: - Audio_time_signature* audio_; + Audio_time_signature *audio_; }; - Time_signature_performer::Time_signature_performer () { prev_fraction_ = SCM_BOOL_F; @@ -37,7 +36,6 @@ Time_signature_performer::~Time_signature_performer () { } - void Time_signature_performer::create_audio_elements () { @@ -47,7 +45,7 @@ Time_signature_performer::create_audio_elements () prev_fraction_ = fr; int b = scm_to_int (scm_car (fr)); int o = scm_to_int (scm_cdr (fr)); - + audio_ = new Audio_time_signature (b, o); Audio_element_info info (audio_, 0); announce_element (info); diff --git a/lily/time-signature.cc b/lily/time-signature.cc index 93717f10e2..d560b8d226 100644 --- a/lily/time-signature.cc +++ b/lily/time-signature.cc @@ -1,11 +1,10 @@ -/* +/* time-signature.cc -- implement Time_signature - + source file of the GNU LilyPond music typesetter - + (c) 1996--2005 Han-Wen Nienhuys - - */ +*/ #include "time-signature.hh" @@ -20,12 +19,11 @@ this file should go ; The formatting can completely be done with markups. - - */ +*/ MAKE_SCHEME_CALLBACK (Time_signature, print, 1); SCM -Time_signature::print (SCM smob) +Time_signature::print (SCM smob) { Grob *me = unsmob_grob (smob); SCM st = me->get_property ("style"); @@ -47,7 +45,7 @@ Time_signature::print (SCM smob) m = numbered_time_signature (me, n, d); if (Staff_symbol_referencer::line_count (me) % 2 == 0) - m.translate_axis (Staff_symbol_referencer::staff_space (me) / 2 , Y_AXIS); + m.translate_axis (Staff_symbol_referencer::staff_space (me) / 2, Y_AXIS); return m.smobbed_copy (); } @@ -66,8 +64,8 @@ Time_signature::special_time_signature (Grob *me, SCM scm_style, int n, int d) if (style == "C") { if /* neither C2/2 nor C4/4 */ - (((n != 2) || (d != 2)) && - ((n != 4) || (d != 4))) + (((n != 2) || (d != 2)) + && ((n != 4) || (d != 4))) { return numbered_time_signature (me, n, d); } @@ -81,28 +79,28 @@ Time_signature::special_time_signature (Grob *me, SCM scm_style, int n, int d) return out; /* If there is no such symbol, we default to the numbered style. - (Here really with a warning!) */ + (Here really with a warning!) */ me->warning (_f ("time signature symbol `%s' not found; " "reverting to numbered style", char_name)); return numbered_time_signature (me, n, d); } Stencil -Time_signature::numbered_time_signature (Grob*me, int num, int den) +Time_signature::numbered_time_signature (Grob *me, int num, int den) { SCM chain = me->get_property_alist_chain (Font_interface::text_font_alist_chain (me)); chain = scm_cons (scm_list_1 (scm_cons (ly_symbol2scm ("font-encoding"), - ly_symbol2scm ("fetaNumber"))), + ly_symbol2scm ("fetaNumber"))), chain); - + SCM sn = Text_interface::interpret_markup (me->get_layout ()->self_scm (), chain, - scm_makfrom0str (to_string (num).to_str0 ())); + scm_makfrom0str (to_string (num).to_str0 ())); SCM sd = Text_interface::interpret_markup (me->get_layout ()->self_scm (), chain, - scm_makfrom0str (to_string (den).to_str0 ())); + scm_makfrom0str (to_string (den).to_str0 ())); Stencil n = *unsmob_stencil (sn); Stencil d = *unsmob_stencil (sd); - + n.align_to (X_AXIS, CENTER); d.align_to (X_AXIS, CENTER); Stencil m; @@ -118,33 +116,33 @@ Time_signature::numbered_time_signature (Grob*me, int num, int den) } m.align_to (X_AXIS, LEFT); - + return m; } ADD_INTERFACE (Time_signature, "time-signature-interface", - "A time signature, in different styles.\n" -" The following values for 'style are are recognized:\n" -"\n" -" @table @samp\n" -" @item @code{C}\n" -" 4/4 and 2/2 are typeset as C and struck C, respectively. All\n" -" other time signatures are written with two digits.\n" -"\n" -" @item @code{neomensural}\n" -" 2/2, 3/2, 2/4, 3/4, 4/4, 6/4, 9/4, 4/8, 6/8 and 9/8 are\n" -" typeset with neo-mensural style mensuration marks. All other time\n" -" signatures are written with two digits.\n" -"\n" -" @item @code{mensural}\n" -" 2/2, 3/2, 2/4, 3/4, 4/4, 6/4, 9/4, 4/8, 6/8 and 9/8 are\n" -" typeset with mensural style mensuration marks. All other time\n" -" signatures are written with two digits.\n" -"\n" -" @item @code{single-digit}\n" -" All time signatures are typeset with a single\n" -" digit, e.g. 3/2 is written as 3.\n" -" @end table\n" -"\n" -"See also the test-file @file{input/test/time.ly}.\n", - "fraction style"); + "A time signature, in different styles.\n" + " The following values for 'style are are recognized:\n" + "\n" + " @table @samp\n" + " @item @code{C}\n" + " 4/4 and 2/2 are typeset as C and struck C, respectively. All\n" + " other time signatures are written with two digits.\n" + "\n" + " @item @code{neomensural}\n" + " 2/2, 3/2, 2/4, 3/4, 4/4, 6/4, 9/4, 4/8, 6/8 and 9/8 are\n" + " typeset with neo-mensural style mensuration marks. All other time\n" + " signatures are written with two digits.\n" + "\n" + " @item @code{mensural}\n" + " 2/2, 3/2, 2/4, 3/4, 4/4, 6/4, 9/4, 4/8, 6/8 and 9/8 are\n" + " typeset with mensural style mensuration marks. All other time\n" + " signatures are written with two digits.\n" + "\n" + " @item @code{single-digit}\n" + " All time signatures are typeset with a single\n" + " digit, e.g. 3/2 is written as 3.\n" + " @end table\n" + "\n" + "See also the test-file @file{input/test/time.ly}.\n", + "fraction style"); diff --git a/lily/timing-engraver.cc b/lily/timing-engraver.cc index 0e2fb868dc..7660ba9a3e 100644 --- a/lily/timing-engraver.cc +++ b/lily/timing-engraver.cc @@ -13,38 +13,36 @@ #include "grob.hh" /** - Do time bookkeeping - */ + Do time bookkeeping +*/ class Timing_engraver : public Timing_translator, public Engraver { protected: /* Needed to know whether we're advancing in grace notes, or not. */ Moment last_moment_; - + virtual void start_translation_timestep (); virtual void initialize (); - virtual void process_music(); + virtual void process_music (); virtual void stop_translation_timestep (); public: TRANSLATOR_DECLARATIONS (Timing_engraver); }; - Timing_engraver::Timing_engraver () { last_moment_.main_part_ = Rational (-1); } - void Timing_engraver::initialize () { Timing_translator::initialize (); - + SCM which = get_property ("whichBar"); Moment now = now_mom (); - + /* Set the first bar of the score? */ if (!scm_is_string (which)) which = (now.main_part_ || now.main_part_ == last_moment_.main_part_) @@ -54,25 +52,24 @@ Timing_engraver::initialize () } void -Timing_engraver::process_music() +Timing_engraver::process_music () { Timing_translator::process_music (); - bool start_of_measure = (last_moment_.main_part_ != now_mom().main_part_ + bool start_of_measure = (last_moment_.main_part_ != now_mom ().main_part_ && !measure_position ().main_part_); /* We can't do this in start_translation_timestep(), since time sig changes won't have happened by then. - */ + */ if (start_of_measure) { Moment mlen = Moment (measure_length ()); unsmob_grob (get_property ("currentCommandColumn")) - ->set_property ("measure-length", mlen.smobbed_copy ()); + ->set_property ("measure-length", mlen.smobbed_copy ()); } } - void Timing_engraver::start_translation_timestep () @@ -95,7 +92,7 @@ Timing_engraver::start_translation_timestep () { SCM always = get_property ("barAlways"); - if ( start_of_measure || (to_boolean (always))) + if (start_of_measure || (to_boolean (always))) { /* should this work, or be junked? See input/bugs/no-bars.ly */ which = get_property ("defaultBarType"); @@ -113,17 +110,14 @@ Timing_engraver::stop_translation_timestep () last_moment_ = now_mom (); } - ADD_TRANSLATOR (Timing_engraver, -/* descr */ " Responsible for synchronizing timing information from staves. " -"Normally in @code{Score}. In order to create polyrhythmic music, " -"this engraver should be removed from @code{Score} and placed in " -"@code{Staff}. " -"\n\nThis engraver adds the alias @code{Timing} to its containing context." - - , -/* creats*/ "", -/* accepts */ "", -/* acks */ "", -/* reads */ "automaticBars whichBar barAlways defaultBarType skipBars timing measureLength measurePosition currentBarNumber", -/* write */ ""); + /* descr */ " Responsible for synchronizing timing information from staves. " + "Normally in @code{Score}. In order to create polyrhythmic music, " + "this engraver should be removed from @code{Score} and placed in " + "@code{Staff}. " + "\n\nThis engraver adds the alias @code{Timing} to its containing context.", + /* creats*/ "", + /* accepts */ "", + /* acks */ "", + /* reads */ "automaticBars whichBar barAlways defaultBarType skipBars timing measureLength measurePosition currentBarNumber", + /* write */ ""); diff --git a/lily/timing-translator.cc b/lily/timing-translator.cc index 16c7b6d2bb..7edc7ec4fd 100644 --- a/lily/timing-translator.cc +++ b/lily/timing-translator.cc @@ -35,7 +35,7 @@ Timing_translator::stop_translation_timestep () /* Hmm. We insert the bar moment every time we process a moment. A waste of cpu? - */ + */ && !now.grace_part_) global->add_moment_to_process (now + barleft); } @@ -46,18 +46,18 @@ Timing_translator::initialize () { /* - move this to engraver-init.ly? - */ + move this to engraver-init.ly? + */ context ()->add_alias (ly_symbol2scm ("Timing")); - context ()->set_property ("timing" , SCM_BOOL_T); - context ()->set_property ("currentBarNumber" , scm_int2num (1)); + context ()->set_property ("timing", SCM_BOOL_T); + context ()->set_property ("currentBarNumber", scm_int2num (1)); context ()->set_property ("timeSignatureFraction", - scm_cons (scm_int2num (4), scm_int2num (4))); + scm_cons (scm_int2num (4), scm_int2num (4))); /* Do not init measurePosition; this should be done from global context. - */ + */ context ()->set_property ("measureLength", Moment (Rational (1)).smobbed_copy ()); context ()->set_property ("beatLength", Moment (Rational (1, 4)).smobbed_copy ()); } @@ -81,15 +81,15 @@ Moment Timing_translator::measure_position () const { SCM sm = get_property ("measurePosition"); - - Moment m = 0; + + Moment m = 0; if (unsmob_moment (sm)) { m = *unsmob_moment (sm); while (m.main_part_ < Rational (0)) m.main_part_ += measure_length (); } - + return m; } @@ -99,7 +99,7 @@ Timing_translator::start_translation_timestep () Global_context *global = get_global_context (); Moment now = global->now_mom (); - Moment dt = now - global->previous_moment (); + Moment dt = now - global->previous_moment (); if (dt < Moment (0)) { programming_error ("Moving backwards in time"); @@ -110,7 +110,7 @@ Timing_translator::start_translation_timestep () programming_error ("Moving infinitely to future"); dt = 0; } - + if (!dt.to_bool ()) return; @@ -127,9 +127,9 @@ Timing_translator::start_translation_timestep () context ()->set_property ("measurePosition", measposp.smobbed_copy ()); } - + measposp += dt; - + SCM barn = get_property ("currentBarNumber"); int b = 0; if (scm_is_number (barn)) @@ -144,7 +144,7 @@ Timing_translator::start_translation_timestep () while (c && measposp.main_part_ >= len) { measposp.main_part_ -= len; - b ++; + b++; } context ()->set_property ("currentBarNumber", scm_int2num (b)); @@ -152,8 +152,7 @@ Timing_translator::start_translation_timestep () } ADD_TRANSLATOR (Timing_translator, - "This engraver adds the alias " - "@code{Timing} to its containing context." - , + "This engraver adds the alias " + "@code{Timing} to its containing context.", - "", "", "", "", ""); + "", "", "", "", ""); diff --git a/lily/translator-ctors.cc b/lily/translator-ctors.cc index c580060457..7f9f41bce7 100644 --- a/lily/translator-ctors.cc +++ b/lily/translator-ctors.cc @@ -16,11 +16,10 @@ Scheme_hash_table *global_translator_dict = 0; -LY_DEFINE (get_all_translators, "ly:get-all-translators", 0, 0, 0, (), - "Return a list of all translator objects that may be instantiated. " - ) +LY_DEFINE (get_all_translators, "ly:get-all-translators", 0, 0, 0, (), + "Return a list of all translator objects that may be instantiated. ") { - SCM l = global_translator_dict ? global_translator_dict->to_alist () : SCM_EOL; + SCM l = global_translator_dict ? global_translator_dict->to_alist () : SCM_EOL; for (SCM s = l; scm_is_pair (s); s = scm_cdr (s)) { @@ -36,13 +35,13 @@ add_translator (Translator *t) if (!global_translator_dict) global_translator_dict = new Scheme_hash_table; - SCM k = ly_symbol2scm (classname (t)); + SCM k = ly_symbol2scm (classname (t)); global_translator_dict->set (k, t->self_scm ()); scm_gc_unprotect_object (t->self_scm ()); } -Translator* +Translator * get_translator (SCM sym) { SCM v = SCM_BOOL_F; diff --git a/lily/translator-group.cc b/lily/translator-group.cc index f5183e4606..081cd86113 100644 --- a/lily/translator-group.cc +++ b/lily/translator-group.cc @@ -16,13 +16,12 @@ #include "main.hh" #include "music.hh" -Translator_group* +Translator_group * Translator_group::get_daddy_translator () const { return context ()->get_parent_context ()->implementation (); } - void translator_each (SCM list, Translator_method method) { @@ -30,7 +29,6 @@ translator_each (SCM list, Translator_method method) (unsmob_translator (scm_car (p))->*method) (); } - void Translator_group::initialize () { @@ -38,9 +36,8 @@ Translator_group::initialize () context ()->set_property ("acceptHashTable", tab); } - bool -translator_accepts_any_of (Translator*tr, SCM ifaces) +translator_accepts_any_of (Translator *tr, SCM ifaces) { SCM ack_ifs = scm_assoc (ly_symbol2scm ("events-accepted"), tr->translator_description ()); @@ -55,11 +52,11 @@ SCM find_accept_translators (SCM gravlist, SCM ifaces) { SCM l = SCM_EOL; - for (SCM s = gravlist; scm_is_pair (s); s = scm_cdr (s)) + for (SCM s = gravlist; scm_is_pair (s); s = scm_cdr (s)) { - Translator* tr = unsmob_translator (scm_car (s)); + Translator *tr = unsmob_translator (scm_car (s)); if (translator_accepts_any_of (tr, ifaces)) - l = scm_cons (tr->self_scm (), l); + l = scm_cons (tr->self_scm (), l); } l = scm_reverse_x (l, SCM_EOL); @@ -67,7 +64,7 @@ find_accept_translators (SCM gravlist, SCM ifaces) } bool -Translator_group::try_music (Music* m) +Translator_group::try_music (Music *m) { SCM tab = get_property ("acceptHashTable"); SCM name = scm_sloppy_assq (ly_symbol2scm ("name"), @@ -87,30 +84,28 @@ Translator_group::try_music (Music* m) for (SCM p = accept_list; scm_is_pair (p); p = scm_cdr (p)) { - Translator * t = unsmob_translator (scm_car (p)); + Translator *t = unsmob_translator (scm_car (p)); if (t && t->try_music (m)) return true; } return false; } - SCM Translator_group::get_simple_trans_list () { return simple_trans_list_; } - void -recurse_over_translators (Context * c, Translator_method ptr, Direction dir) +recurse_over_translators (Context *c, Translator_method ptr, Direction dir) { - Translator_group * tg - = dynamic_cast (c->implementation ()); + Translator_group *tg + = dynamic_cast (c->implementation ()); /* - Top down: - */ + Top down: + */ if (dir == DOWN) { translator_each (tg->get_simple_trans_list (), @@ -134,7 +129,7 @@ recurse_over_translators (Context * c, Translator_method ptr, Direction dir) } } -Translator_group::Translator_group() +Translator_group::Translator_group () { simple_trans_list_ = SCM_EOL; } @@ -142,5 +137,5 @@ Translator_group::Translator_group() void Translator_group::derived_mark () const { - scm_gc_mark (simple_trans_list_); + scm_gc_mark (simple_trans_list_); } diff --git a/lily/translator-scheme.cc b/lily/translator-scheme.cc index 27da857289..cec56a0a76 100644 --- a/lily/translator-scheme.cc +++ b/lily/translator-scheme.cc @@ -4,15 +4,14 @@ source file of the GNU LilyPond music typesetter (c) 2002--2005 Han-Wen Nienhuys - - */ +*/ #include "context-def.hh" #include "translator-group.hh" LY_DEFINE (ly_translator_name, "ly:translator-name", 1, 0, 0, (SCM trans), - "Return the type name of the translator object @var{trans}. " + "Return the type name of the translator object @var{trans}. " "The name is a symbol.") { Translator *tr = unsmob_translator (trans); @@ -22,8 +21,8 @@ LY_DEFINE (ly_translator_name, "ly:translator-name", } LY_DEFINE (ly_translator_description, "ly:translator-description", - 1, 0, 0, (SCM me), - "Return an alist of properties of translator @var{me}.") + 1, 0, 0, (SCM me), + "Return an alist of properties of translator @var{me}.") { Translator *tr = unsmob_translator (me); SCM_ASSERT_TYPE (tr, me, SCM_ARG1, __FUNCTION__, "Translator"); @@ -33,7 +32,7 @@ LY_DEFINE (ly_translator_description, "ly:translator-description", int Translator::print_smob (SCM s, SCM port, scm_print_state *) { - Translator *me = (Translator*) SCM_CELL_WORD_1 (s); + Translator *me = (Translator *) SCM_CELL_WORD_1 (s); scm_puts ("#", port); diff --git a/lily/translator.cc b/lily/translator.cc index af72ca083a..9f192103b9 100644 --- a/lily/translator.cc +++ b/lily/translator.cc @@ -36,7 +36,7 @@ Translator::do_announces () void Translator::process_music () { - + } Translator::Translator () @@ -55,7 +55,6 @@ Translator::try_music (Music *) { return false; } - Moment Translator::now_mom () const @@ -69,14 +68,12 @@ Translator::get_output_def () const return daddy_context_->get_output_def (); } - -Translator_group* +Translator_group * Translator::get_daddy_translator () const { return daddy_context_->implementation (); } - SCM Translator::internal_get_property (SCM sym) const { @@ -95,8 +92,7 @@ Translator::stop_translation_timestep () - It is called before any user information enters the translators. (i.e. any \property or event is not processed yet.) - - */ +*/ void Translator::start_translation_timestep () { @@ -112,16 +108,13 @@ Translator::finalize () { } - /* - SMOBS - */ SCM Translator::mark_smob (SCM sm) { - Translator * me = (Translator*) SCM_CELL_WORD_1 (sm); + Translator *me = (Translator *) SCM_CELL_WORD_1 (sm); me->derived_mark (); return SCM_EOL; } @@ -132,20 +125,17 @@ Translator::translator_description () const return SCM_EOL; } - Global_context * Translator::get_global_context () const { return daddy_context_ ->get_global_context (); } - Score_context * Translator::get_score_context () const { return daddy_context_->get_score_context (); -} - +} SCM Translator::static_translator_description ()const @@ -153,7 +143,6 @@ Translator::static_translator_description ()const return SCM_EOL; } - IMPLEMENT_SMOBS (Translator); IMPLEMENT_DEFAULT_EQUAL_P (Translator); IMPLEMENT_TYPE_P (Translator, "ly:translator?"); @@ -167,5 +156,5 @@ Translator::must_be_last () const void Translator::derived_mark () const { - + } diff --git a/lily/trill-spanner-engraver.cc b/lily/trill-spanner-engraver.cc index c64d87c9e4..fd93042b28 100644 --- a/lily/trill-spanner-engraver.cc +++ b/lily/trill-spanner-engraver.cc @@ -10,9 +10,8 @@ C&P from text-spanner.cc - todo: ending should be detected automatically? a new note - automatically is the end of the trill? - - */ + automatically is the end of the trill? +*/ #include "note-column.hh" #include "side-position-interface.hh" @@ -21,7 +20,7 @@ class Trill_spanner_engraver : public Engraver { public: - TRANSLATOR_DECLARATIONS (Trill_spanner_engraver); + TRANSLATOR_DECLARATIONS (Trill_spanner_engraver); protected: virtual void finalize (); virtual void acknowledge_grob (Grob_info); @@ -33,11 +32,10 @@ private: Spanner *span_; Spanner *finished_; Music *current_req_; - Drul_array req_drul_; + Drul_array req_drul_; void typeset_all (); }; - Trill_spanner_engraver::Trill_spanner_engraver () { finished_ = 0; @@ -86,7 +84,7 @@ Trill_spanner_engraver::process_music () else { current_req_ = req_drul_[START]; - span_ = make_spanner ("TrillSpanner", req_drul_[START]->self_scm ()); + span_ = make_spanner ("TrillSpanner", req_drul_[START]->self_scm ()); Side_position_interface::set_axis (span_, Y_AXIS); req_drul_[START] = 0; } @@ -96,25 +94,25 @@ Trill_spanner_engraver::process_music () void Trill_spanner_engraver::acknowledge_grob (Grob_info info) { - Spanner * spans[2] ={span_, finished_}; - for (int i = 0; i < 2 ; i++) + Spanner *spans[2] ={span_, finished_}; + for (int i = 0; i < 2; i++) { if (spans[i] && Note_column::has_interface (info.grob_)) { Side_position_interface::add_support (spans[i], info.grob_); - add_bound_item (spans[i], dynamic_cast (info.grob_)); + add_bound_item (spans[i], dynamic_cast (info.grob_)); } } } void Trill_spanner_engraver::typeset_all () -{ +{ if (finished_) { if (!finished_->get_bound (RIGHT)) { - Grob* e = unsmob_grob (get_property ("currentMusicalColumn")); + Grob *e = unsmob_grob (get_property ("currentMusicalColumn")); finished_->set_bound (RIGHT, e); } finished_ = 0; @@ -126,7 +124,7 @@ Trill_spanner_engraver::stop_translation_timestep () { if (span_ && !span_->get_bound (LEFT)) { - Grob* e = unsmob_grob (get_property ("currentMusicalColumn")); + Grob *e = unsmob_grob (get_property ("currentMusicalColumn")); span_->set_bound (LEFT, e); } @@ -148,9 +146,9 @@ Trill_spanner_engraver::finalize () } ADD_TRANSLATOR (Trill_spanner_engraver, -/* descr */ "Create trill spanner from a Music.", -/* creats*/ "TrillSpanner", -/* accepts */ "trill-span-event", -/* acks */ "note-column-interface", -/* reads */ "", -/* write */ ""); + /* descr */ "Create trill spanner from a Music.", + /* creats*/ "TrillSpanner", + /* accepts */ "trill-span-event", + /* acks */ "note-column-interface", + /* reads */ "", + /* write */ ""); diff --git a/lily/tuplet-bracket.cc b/lily/tuplet-bracket.cc index 2db6fca93f..dc1f4a3c20 100644 --- a/lily/tuplet-bracket.cc +++ b/lily/tuplet-bracket.cc @@ -16,17 +16,15 @@ - There is no support for kneed brackets, or nested brackets. - number placement for parallel beams should be much more advanced: - for sloped beams some extra horizontal offset must be introduced. + for sloped beams some extra horizontal offset must be introduced. - number placement is usually done over the center note, not the - graphical center. - - */ + graphical center. +*/ /* - - TODO: quantise, we don't want to collide with staff lines. - (or should we be above staff?) + TODO: quantise, we don't want to collide with staff lines. + (or should we be above staff?) todo: handle breaking elegantly. */ @@ -48,7 +46,7 @@ #include "staff-symbol-referencer.hh" #include "lookup.hh" -static Grob* +static Grob * get_x_bound_grob (Grob *g, Direction my_dir) { if (Note_column::get_stem (g) @@ -59,25 +57,23 @@ get_x_bound_grob (Grob *g, Direction my_dir) return g; } - - -Grob* +Grob * Tuplet_bracket::parallel_beam (Grob *me, Link_array const &cols, bool *equally_long) { /* - ugh: code dup. + ugh: code dup. */ - Grob *s1 = Note_column::get_stem (cols[0]); - Grob *s2 = Note_column::get_stem (cols.top ()); + Grob *s1 = Note_column::get_stem (cols[0]); + Grob *s2 = Note_column::get_stem (cols.top ()); + + Grob *b1 = s1 ? Stem::get_beam (s1) : 0; + Grob *b2 = s2 ? Stem::get_beam (s2) : 0; - Grob*b1 = s1 ? Stem::get_beam (s1) : 0; - Grob*b2 = s2 ? Stem::get_beam (s2) : 0; - - Spanner*sp = dynamic_cast (me); + Spanner *sp = dynamic_cast (me); *equally_long = false; if (! (b1 && (b1 == b2) && !sp->is_broken ())) - return 0; + return 0; Link_array beam_stems = extract_grob_array (b1, ly_symbol2scm ("stems")); if (beam_stems.size () == 0) @@ -86,53 +82,51 @@ Tuplet_bracket::parallel_beam (Grob *me, Link_array const &cols, bool *equ *equally_long = 0; return 0; } - + *equally_long = (beam_stems[0] == s1 && beam_stems.top () == s2); return b1; } - /* TODO: in the case that there is no bracket, but there is a (single) beam, follow beam precisely for determining tuplet number location. - - */ +*/ MAKE_SCHEME_CALLBACK (Tuplet_bracket, print, 1); SCM -Tuplet_bracket::print (SCM smob) +Tuplet_bracket::print (SCM smob) { Grob *me = unsmob_grob (smob); - Stencil mol; - Link_array columns = - extract_grob_array (me, ly_symbol2scm ("note-columns")); + Stencil mol; + Link_array columns + = extract_grob_array (me, ly_symbol2scm ("note-columns")); if (!columns.size ()) return mol.smobbed_copy (); { SCM lp = me->get_property ("left-position"); - SCM rp = me->get_property ("right-position"); + SCM rp = me->get_property ("right-position"); if (!scm_is_number (rp) || !scm_is_number (lp)) after_line_breaking (smob); } - + Real ly = robust_scm2double (me->get_property ("left-position"), 0); - Real ry = robust_scm2double (me->get_property ("right-position"), 0); - + Real ry = robust_scm2double (me->get_property ("right-position"), 0); + bool equally_long = false; - Grob * par_beam = parallel_beam (me, columns, &equally_long); + Grob *par_beam = parallel_beam (me, columns, &equally_long); - Spanner*sp = dynamic_cast (me); + Spanner *sp = dynamic_cast (me); bool bracket_visibility = !(par_beam && equally_long); bool number_visibility = true; /* Fixme: the type of this prop is sucky. - */ + */ SCM bracket = me->get_property ("bracket-visibility"); if (scm_is_bool (bracket)) { @@ -141,101 +135,101 @@ Tuplet_bracket::print (SCM smob) else if (bracket == ly_symbol2scm ("if-no-beam")) bracket_visibility = !par_beam; - SCM numb = me->get_property ("number-visibility"); + SCM numb = me->get_property ("number-visibility"); if (scm_is_bool (numb)) { number_visibility = ly_scm2bool (numb); } else if (numb == ly_symbol2scm ("if-no-beam")) number_visibility = !par_beam; - - Grob * commonx = columns[0]->common_refpoint (columns.top (), X_AXIS); + + Grob *commonx = columns[0]->common_refpoint (columns.top (), X_AXIS); /* Tuplet brackets are normally not broken, but we shouldn't crash if they are. - */ + */ commonx = commonx->common_refpoint (sp->get_bound (LEFT), X_AXIS); - commonx = commonx->common_refpoint (sp->get_bound (RIGHT), X_AXIS); - + commonx = commonx->common_refpoint (sp->get_bound (RIGHT), X_AXIS); + Direction dir = get_grob_direction (me); - Grob * lgr = get_x_bound_grob (columns[0], dir); - Grob * rgr = get_x_bound_grob (columns.top (), dir); - + Grob *lgr = get_x_bound_grob (columns[0], dir); + Grob *rgr = get_x_bound_grob (columns.top (), dir); + Real x0 = robust_relative_extent (lgr, commonx, X_AXIS)[LEFT]; Real x1 = robust_relative_extent (rgr, commonx, X_AXIS)[RIGHT]; Real w = x1 -x0; - + SCM number = me->get_property ("text"); Output_def *pap = me->get_layout (); Stencil num; - if (scm_is_string (number) && number_visibility) + if (scm_is_string (number) && number_visibility) { SCM properties = Font_interface::text_font_alist_chain (me); SCM snum = Text_interface::interpret_markup (pap->self_scm (), properties, number); num = *unsmob_stencil (snum); num.align_to (X_AXIS, CENTER); - num.translate_axis (w/2, X_AXIS); + num.translate_axis (w / 2, X_AXIS); num.align_to (Y_AXIS, CENTER); - - num.translate_axis ((ry-ly)/2, Y_AXIS); + + num.translate_axis ((ry - ly) / 2, Y_AXIS); mol.add_stencil (num); } - /* No bracket when it would be smaller than the number. TODO: should use GAP in calculation too. - */ + */ if (bracket_visibility && number_visibility && mol.extent (X_AXIS).length () > w) { bracket_visibility = false; } - - if (bracket_visibility) + + if (bracket_visibility) { - Real ss = Staff_symbol_referencer::staff_space (me); + Real ss = Staff_symbol_referencer::staff_space (me); Real gap = 0.; if (!num.extent (X_AXIS).is_empty ()) gap = num.extent (X_AXIS).length () + 1.0; - + SCM fl = me->get_property ("bracket-flare"); SCM eh = me->get_property ("edge-height"); SCM sp = me->get_property ("shorten-pair"); - + Direction d = LEFT; Drul_array height, flare, shorten; - do { - flare[d] = height[d] = shorten[d] = 0.0; - if (is_number_pair (fl)) - flare[d] += ss * scm_to_double (index_get_cell (fl, d)); - if (is_number_pair (eh)) - height[d] += - dir * ss *scm_to_double (index_get_cell (eh, d)); - if (is_number_pair (sp)) - shorten[d] += ss *scm_to_double (index_get_cell (sp, d)); - } + do + { + flare[d] = height[d] = shorten[d] = 0.0; + if (is_number_pair (fl)) + flare[d] += ss * scm_to_double (index_get_cell (fl, d)); + if (is_number_pair (eh)) + height[d] += -dir * ss *scm_to_double (index_get_cell (eh, d)); + if (is_number_pair (sp)) + shorten[d] += ss *scm_to_double (index_get_cell (sp, d)); + } while (flip (&d) != LEFT); - + Stencil brack = make_bracket (me, Y_AXIS, - Offset (w, ry - ly), - height, + Offset (w, ry - ly), + height, /* 0.1 = more space at right due to italics TODO: use italic correction of font. - */ + */ Interval (-0.5, 0.5) * gap + 0.1, - flare, shorten); + flare, shorten); mol.add_stencil (brack); } - + mol.translate_axis (ly, Y_AXIS); - mol.translate_axis (x0 - sp->get_bound (LEFT)->relative_coordinate (commonx, X_AXIS), X_AXIS); + mol.translate_axis (x0 - sp->get_bound (LEFT)->relative_coordinate (commonx, X_AXIS), X_AXIS); return mol.smobbed_copy (); } @@ -244,9 +238,9 @@ Tuplet_bracket::print (SCM smob) TODO: this will fail for very short (shorter than the flare) brackets. - */ +*/ Stencil -Tuplet_bracket::make_bracket (Grob *me, // for line properties. +Tuplet_bracket::make_bracket (Grob *me, // for line properties. Axis protusion_axis, Offset dz, Drul_array height, @@ -255,88 +249,93 @@ Tuplet_bracket::make_bracket (Grob *me, // for line properties. Drul_array shorten) { Drul_array corners (Offset (0, 0), dz); - + Real length = dz.length (); Drul_array gap_corners; - Axis bracket_axis = other_axis (protusion_axis); Drul_array straight_corners = corners; Direction d = LEFT; - do { - straight_corners[d] += - d * shorten[d] /length * dz; - } while (flip (&d) != LEFT); - + do + { + straight_corners[d] += -d * shorten[d] /length * dz; + } + while (flip (&d) != LEFT); - if (gap.is_empty()) + if (gap.is_empty ()) gap = Interval (0, 0); - do { - gap_corners[d] = (dz * 0.5) + gap[d] / length * dz; - } while (flip (&d) != LEFT); + do + { + gap_corners[d] = (dz * 0.5) + gap[d] / length * dz; + } + while (flip (&d) != LEFT); Drul_array flare_corners = straight_corners; - do { - flare_corners[d][bracket_axis] = straight_corners[d][bracket_axis]; - flare_corners[d][protusion_axis] += height[d]; - straight_corners[d][bracket_axis] += - d * flare[d]; - } while (flip (&d) != LEFT); + do + { + flare_corners[d][bracket_axis] = straight_corners[d][bracket_axis]; + flare_corners[d][protusion_axis] += height[d]; + straight_corners[d][bracket_axis] += -d * flare[d]; + } + while (flip (&d) != LEFT); Stencil m; - do { - m.add_stencil (Line_interface::line (me, straight_corners[d], - gap_corners[d])); - - m.add_stencil (Line_interface::line (me, straight_corners[d], - flare_corners[d])); - } while (flip (&d) != LEFT); - - return m; -} + do + { + m.add_stencil (Line_interface::line (me, straight_corners[d], + gap_corners[d])); + m.add_stencil (Line_interface::line (me, straight_corners[d], + flare_corners[d])); + } + while (flip (&d) != LEFT); + + return m; +} /* use first -> last note for slope, and then correct for disturbing notes in between. */ void -Tuplet_bracket::calc_position_and_height (Grob*me, Real *offset, Real * dy) +Tuplet_bracket::calc_position_and_height (Grob *me, Real *offset, Real *dy) { - Link_array columns = - extract_grob_array (me, ly_symbol2scm ("note-columns")); + Link_array columns + = extract_grob_array (me, ly_symbol2scm ("note-columns")); SCM cols = me->get_property ("note-columns"); - Grob * commony = common_refpoint_of_list (cols, me, Y_AXIS); - Grob * commonx = common_refpoint_of_list (cols, me, X_AXIS); + Grob *commony = common_refpoint_of_list (cols, me, Y_AXIS); + Grob *commonx = common_refpoint_of_list (cols, me, X_AXIS); Interval staff; - if (Grob * st = Staff_symbol_referencer::get_staff_symbol (me)) + if (Grob *st = Staff_symbol_referencer::get_staff_symbol (me)) staff = st->extent (commony, Y_AXIS); - + Direction dir = get_grob_direction (me); /* Use outer non-rest columns to determine slope - */ + */ int l = 0; while (l = l && Note_column::has_rests (columns[r])) r--; - + if (l < r) { Interval rv = columns[r]->extent (commony, Y_AXIS); Interval lv = columns[l]->extent (commony, Y_AXIS); rv.unite (staff); lv.unite (staff); - Real graphical_dy = rv[dir] - lv[dir]; + Real graphical_dy = rv[dir] - lv[dir]; Slice ls = Note_column::head_positions_interval (columns[l]); Slice rs = Note_column::head_positions_interval (columns[r]); - + Interval musical_dy; musical_dy[UP] = rs[UP] - ls[UP]; musical_dy[DOWN] = rs[DOWN] - ls[DOWN]; @@ -350,16 +349,13 @@ Tuplet_bracket::calc_position_and_height (Grob*me, Real *offset, Real * dy) else * dy = 0; - - *offset = - dir * infinity_f; + *offset = -dir * infinity_f; if (!columns.size ()) return; - - - Grob * lgr = get_x_bound_grob (columns[0], dir); - Grob * rgr = get_x_bound_grob (columns.top (), dir); + Grob *lgr = get_x_bound_grob (columns[0], dir); + Grob *rgr = get_x_bound_grob (columns.top (), dir); Real x0 = robust_relative_extent (lgr, commonx, X_AXIS)[LEFT]; Real x1 = robust_relative_extent (rgr, commonx, X_AXIS)[RIGHT]; @@ -367,61 +363,57 @@ Tuplet_bracket::calc_position_and_height (Grob*me, Real *offset, Real * dy) Slope. */ Real factor = columns.size () > 1 ? 1/ (x1 - x0) : 1.0; - - for (int i = 0; i < columns.size (); i++) + + for (int i = 0; i < columns.size (); i++) { Interval note_ext = columns[i]->extent (commony, Y_AXIS); note_ext.unite (staff); Real notey = note_ext[dir] - me->relative_coordinate (commony, Y_AXIS); - + Real x = columns[i]->relative_coordinate (commonx, X_AXIS) - x0; - Real tuplety = *dy * x * factor; + Real tuplety = *dy * x * factor; if (notey * dir > (*offset + tuplety) * dir) - *offset = notey - tuplety; + *offset = notey - tuplety; } // padding - *offset += scm_to_double (me->get_property ("padding")) *dir; + *offset += scm_to_double (me->get_property ("padding")) *dir; - /* horizontal brackets should not collide with staff lines. - - */ + + */ Real ss = Staff_symbol_referencer::staff_space (me); - if (*dy == 0 && fabs (*offset) < ss * Staff_symbol_referencer::staff_radius (me)) + if (*dy == 0 && fabs (*offset) < ss * Staff_symbol_referencer::staff_radius (me)) { // quantize, then do collision check. *offset *= 2 / ss; - + *offset = rint (*offset); if (Staff_symbol_referencer::on_staffline (me, (int) rint (*offset))) *offset += dir; *offset *= 0.5 * ss; } - -} - +} /* We depend on the beams if there are any. - */ +*/ MAKE_SCHEME_CALLBACK (Tuplet_bracket, before_line_breaking, 1); SCM Tuplet_bracket::before_line_breaking (SCM smob) { Grob *me = unsmob_grob (smob); - Link_array columns = - extract_grob_array (me, ly_symbol2scm ("note-columns")); - + Link_array columns + = extract_grob_array (me, ly_symbol2scm ("note-columns")); for (int i = columns.size (); i--;) { - Grob * s = Note_column::get_stem (columns[i]); - Grob * b = s ? Stem::get_beam (s): 0; + Grob *s = Note_column::get_stem (columns[i]); + Grob *b = s ? Stem::get_beam (s): 0; if (b) me->add_dependency (b); } @@ -433,35 +425,35 @@ MAKE_SCHEME_CALLBACK (Tuplet_bracket, after_line_breaking, 1); SCM Tuplet_bracket::after_line_breaking (SCM smob) { - Grob * me = unsmob_grob (smob); - Link_array columns = - extract_grob_array (me, ly_symbol2scm ("note-columns")); + Grob *me = unsmob_grob (smob); + Link_array columns + = extract_grob_array (me, ly_symbol2scm ("note-columns")); if (!columns.size ()) { me->suicide (); return SCM_UNSPECIFIED; } - if (dynamic_cast (me)->is_broken ()) + if (dynamic_cast (me)->is_broken ()) { - me->warning (_("Killing tuplet bracket across linebreak.")); + me->warning (_ ("Killing tuplet bracket across linebreak.")); me->suicide (); return SCM_UNSPECIFIED; } - + Direction dir = get_grob_direction (me); if (!dir) { dir = Tuplet_bracket::get_default_dir (me); set_grob_direction (me, dir); } - + bool equally_long = false; - Grob * par_beam = parallel_beam (me, columns, &equally_long); + Grob *par_beam = parallel_beam (me, columns, &equally_long); /* We follow the beam only if there is one, and we are next to it. - */ + */ Real dy, offset; if (!par_beam || get_grob_direction (par_beam) != dir) @@ -470,22 +462,21 @@ Tuplet_bracket::after_line_breaking (SCM smob) } else { - SCM ps = par_beam->get_property ("positions"); + SCM ps = par_beam->get_property ("positions"); Real lp = scm_to_double (scm_car (ps)); Real rp = scm_to_double (scm_cdr (ps)); /* duh. magic. - */ + */ offset = lp + dir * (0.5 + scm_to_double (me->get_property ("padding"))); dy = rp- lp; } - - - SCM lp = me->get_property ("left-position"); - SCM rp = me->get_property ("right-position"); - + + SCM lp = me->get_property ("left-position"); + SCM rp = me->get_property ("right-position"); + if (scm_is_number (lp) && !scm_is_number (rp)) { rp = scm_make_real (scm_to_double (lp) + dy); @@ -506,17 +497,16 @@ Tuplet_bracket::after_line_breaking (SCM smob) return SCM_UNSPECIFIED; } - /* - similar to beam ? - */ + similar to beam ? +*/ Direction -Tuplet_bracket::get_default_dir (Grob*me) +Tuplet_bracket::get_default_dir (Grob *me) { - Drul_array dirs (0, 0); + Drul_array dirs (0, 0); for (SCM s = me->get_property ("note-columns"); scm_is_pair (s); s = scm_cdr (s)) { - Grob * nc = unsmob_grob (scm_car (s)); + Grob *nc = unsmob_grob (scm_car (s)); Direction d = Note_column::dir (nc); if (d) dirs[d]++; @@ -526,23 +516,20 @@ Tuplet_bracket::get_default_dir (Grob*me) } void -Tuplet_bracket::add_column (Grob*me, Item*n) +Tuplet_bracket::add_column (Grob *me, Item *n) { Pointer_group_interface::add_grob (me, ly_symbol2scm ("note-columns"), n); me->add_dependency (n); - add_bound_item (dynamic_cast (me), n); + add_bound_item (dynamic_cast (me), n); } - - - ADD_INTERFACE (Tuplet_bracket, "tuplet-bracket-interface", "A bracket with a number in the middle, used for tuplets.", - + "note-columns bracket-flare edge-height shorten-pair " "padding left-position right-position bracket-visibility " "number-visibility thickness direction"); diff --git a/lily/tuplet-engraver.cc b/lily/tuplet-engraver.cc index e881e0de78..9acf07106b 100644 --- a/lily/tuplet-engraver.cc +++ b/lily/tuplet-engraver.cc @@ -1,11 +1,10 @@ -/* +/* tuplet-engraver.cc -- implement Tuplet_engraver - + source file of the GNU LilyPond music typesetter - + (c) 1998--2005 Han-Wen Nienhuys - - */ +*/ #include "tuplet-bracket.hh" #include "note-column.hh" @@ -19,7 +18,7 @@ struct Tuplet_description Rational stop_; Rational span_stop_; Spanner *spanner_; - Tuplet_description() + Tuplet_description () { music_ = 0; spanner_ = 0; @@ -35,7 +34,7 @@ protected: Array tuplets_; virtual void acknowledge_grob (Grob_info); - virtual bool try_music (Music*r); + virtual bool try_music (Music *r); virtual void start_translation_timestep (); virtual void process_music (); }; @@ -50,13 +49,13 @@ Tuplet_engraver::try_music (Music *music) { Tuplet_description d; d.music_ = music; - d.stop_ = now_mom ().main_part_ + music->get_length ().main_part_; + d.stop_ = now_mom ().main_part_ + music->get_length ().main_part_; d.span_stop_ = d.stop_; - + SCM s = get_property ("tupletSpannerDuration"); if (unsmob_moment (s)) d.span_stop_ = d.span_stop_ self_scm ()); tuplets_[i].spanner_ = spanner; @@ -91,9 +90,9 @@ Tuplet_engraver::acknowledge_grob (Grob_info i) if (Note_column::has_interface (i.grob_)) { for (int j = 0; j < tuplets_.size (); j++) - if (tuplets_[j].spanner_) + if (tuplets_[j].spanner_) Tuplet_bracket::add_column (tuplets_[j].spanner_, - dynamic_cast (i.grob_)); + dynamic_cast (i.grob_)); } } @@ -115,10 +114,10 @@ Tuplet_engraver::start_translation_timestep () { if (!sp->get_bound (RIGHT)) sp->set_bound (RIGHT, sp->get_bound (LEFT)); - + tuplets_[i].spanner_ = 0; } - + if (tsd.to_bool ()) tuplets_[i].span_stop_ += tsd.main_part_; } @@ -135,9 +134,9 @@ Tuplet_engraver::Tuplet_engraver () } ADD_TRANSLATOR (Tuplet_engraver, -/* descr */ "Catch Time_scaled_music and generate appropriate bracket ", -/* creats*/ "TupletBracket", -/* accepts */ "time-scaled-music", -/* acks */ "note-column-interface", -/* reads */ "tupletNumberFormatFunction tupletSpannerDuration", -/* write */ ""); + /* descr */ "Catch Time_scaled_music and generate appropriate bracket ", + /* creats*/ "TupletBracket", + /* accepts */ "time-scaled-music", + /* acks */ "note-column-interface", + /* reads */ "tupletNumberFormatFunction tupletSpannerDuration", + /* write */ ""); diff --git a/lily/tweak-registration-scheme.cc b/lily/tweak-registration-scheme.cc index 29de348eb9..0e13e326d5 100644 --- a/lily/tweak-registration-scheme.cc +++ b/lily/tweak-registration-scheme.cc @@ -4,18 +4,15 @@ source file of the GNU LilyPond music typesetter (c) 2004--2005 Han-Wen Nienhuys - */ - #include "tweak-registration.hh" #include "grob.hh" #include "object-key-undumper.hh" LY_DEFINE (ly_clear_tweak_registry, "ly:tweak-clear-registry", 0, 0, 0, (), - "Clear global tweak registry" - ) + "Clear global tweak registry") { global_registry_->clear (); return SCM_UNSPECIFIED; @@ -24,15 +21,14 @@ LY_DEFINE (ly_clear_tweak_registry, "ly:tweak-clear-registry", LY_DEFINE (ly_grob_insert_tweak, "ly:grob-insert-tweak", 2, 0, 0, (SCM grob, SCM tweak), - "add new tweak for grob." - ) + "add new tweak for grob.") { Grob *gr = unsmob_grob (grob); SCM_ASSERT_TYPE (gr, grob, SCM_ARG1, __FUNCTION__, "Grob"); SCM_ASSERT_TYPE (scm_list_p (tweak) == SCM_BOOL_T && ly_c_procedure_p (scm_car (tweak)), tweak, SCM_ARG2, __FUNCTION__, "Tweak"); - + global_registry_->insert_grob_tweak (gr, tweak); return SCM_UNSPECIFIED; } @@ -40,43 +36,36 @@ LY_DEFINE (ly_grob_insert_tweak, "ly:grob-insert-tweak", LY_DEFINE (ly_grob_replace_tweak, "ly:grob-replace-tweak", 2, 0, 0, (SCM grob, SCM tweak), - "Replace tweak for grob." - ) + "Replace tweak for grob.") { Grob *gr = unsmob_grob (grob); SCM_ASSERT_TYPE (gr, grob, SCM_ARG1, __FUNCTION__, "Grob"); SCM_ASSERT_TYPE (scm_list_p (tweak) == SCM_BOOL_T && ly_c_procedure_p (scm_car (tweak)), tweak, SCM_ARG2, __FUNCTION__, "Tweak"); - + global_registry_->replace_grob_tweak (gr, tweak); return SCM_UNSPECIFIED; } - LY_DEFINE (ly_tweak_read_keys, "ly:tweak-define-keys", 1, 0, 0, (SCM keys), - "Read keys" - ) + "Read keys") { - global_registry_->undumper ()->parse_contents (keys); + global_registry_->undumper ()->parse_contents (keys); return SCM_UNSPECIFIED; } - LY_DEFINE (ly_all_tweaks, "ly:all-tweaks", 0, 0, 0, (), - "all tweaks" - ) + "all tweaks") { return global_registry_->list_tweaks (); } - LY_DEFINE (ly_tweak_read_tweaks, "ly:tweak-define-tweaks", 1, 0, 0, (SCM tweaks), - "Read tweaks" - ) + "Read tweaks") { for (SCM s = tweaks; scm_is_pair (s); s = scm_cdr (s)) global_registry_->insert_tweak_from_file (scm_car (s)); diff --git a/lily/tweak-registration.cc b/lily/tweak-registration.cc index bde84f7cb7..fe815e19c8 100644 --- a/lily/tweak-registration.cc +++ b/lily/tweak-registration.cc @@ -4,7 +4,6 @@ source file of the GNU LilyPond music typesetter (c) 2004--2005 Han-Wen Nienhuys - */ #include "tweak-registration.hh" @@ -39,8 +38,8 @@ Tweak_registry::insert_tweak_from_file (SCM tweak) { SCM skey = scm_car (tweak); - assert (scm_is_pair (skey) && - scm_car (skey) == ly_symbol2scm ("key")); + assert (scm_is_pair (skey) + && scm_car (skey) == ly_symbol2scm ("key")); Object_key const *key = undumper_->get_key (scm_to_int (scm_cadr (skey))); if (tweaks_.find (key) == tweaks_.end ()) @@ -67,7 +66,7 @@ Tweak_registry::replace_grob_tweak (Grob *g, SCM tweak) } SCM -Tweak_registry::get_tweaks (Grob *g) +Tweak_registry::get_tweaks (Grob *g) { Object_key const *key = g->get_key (); if (tweaks_.find (key) == tweaks_.end ()) @@ -94,7 +93,7 @@ Tweak_registry::list_tweaks () SCM Tweak_registry::mark_smob (SCM smob) { - Tweak_registry *me = (Tweak_registry*) SCM_CELL_WORD_1 (smob); + Tweak_registry *me = (Tweak_registry *) SCM_CELL_WORD_1 (smob); for (Tweak_map::const_iterator i (me->tweaks_.begin ()); i != me->tweaks_.end (); @@ -106,7 +105,7 @@ Tweak_registry::mark_smob (SCM smob) if (me->undumper_) scm_gc_mark (me->undumper_->self_scm ()); - + return SCM_EOL; } @@ -114,11 +113,11 @@ int Tweak_registry::print_smob (SCM smob, SCM port, scm_print_state*) { (void) smob; // smother warning. - scm_puts ("#", port); + scm_puts ("#", port); return 1; } -Object_key_undumper* +Object_key_undumper * Tweak_registry::undumper () const { return undumper_; @@ -127,7 +126,6 @@ Tweak_registry::undumper () const IMPLEMENT_DEFAULT_EQUAL_P (Tweak_registry); IMPLEMENT_SMOBS (Tweak_registry); - Tweak_registry *global_registry_; void diff --git a/lily/type-swallow-translator.cc b/lily/type-swallow-translator.cc index 72982a1132..616099fbed 100644 --- a/lily/type-swallow-translator.cc +++ b/lily/type-swallow-translator.cc @@ -12,62 +12,58 @@ class Skip_event_swallow_translator : public virtual Translator { protected: - virtual bool try_music (Music*) { return true; } + virtual bool try_music (Music *) { return true; } -public: +public: TRANSLATOR_DECLARATIONS (Skip_event_swallow_translator); }; - class Rest_swallow_translator : public virtual Translator { protected: - virtual bool try_music (Music*) { return true; } + virtual bool try_music (Music *) { return true; } -public: +public: TRANSLATOR_DECLARATIONS (Rest_swallow_translator); }; - Skip_event_swallow_translator::Skip_event_swallow_translator (){} ADD_TRANSLATOR (Skip_event_swallow_translator, - "Swallow \\skip.", - "", - "skip-event", - "", - "", - ""); - + "Swallow \\skip.", + "", + "skip-event", + "", + "", + ""); Rest_swallow_translator::Rest_swallow_translator (){} ADD_TRANSLATOR (Rest_swallow_translator, - "Swallow rest", - "", - "rest-event", - "", - "", - + "Swallow rest", + "", + "rest-event", + "", + "", - ""); + ""); class Note_swallow_translator : public virtual Translator { protected: - virtual bool try_music (Music*) { return true; } + virtual bool try_music (Music *) { return true; } -public: +public: TRANSLATOR_DECLARATIONS (Note_swallow_translator); }; Note_swallow_translator::Note_swallow_translator (){} ADD_TRANSLATOR (Note_swallow_translator, - "Swallow notes", - "", - "note-event", - "", - "", - ""); - + "Swallow notes", + "", + "note-event", + "", + "", + ""); + diff --git a/lily/unfolded-repeat-iterator.cc b/lily/unfolded-repeat-iterator.cc index c871c37395..c7a5db97f7 100644 --- a/lily/unfolded-repeat-iterator.cc +++ b/lily/unfolded-repeat-iterator.cc @@ -1,10 +1,10 @@ -/* -unfolded-repeat-iterator.cc -- implement Unfolded_repeat_iterator, Volta_repeat_iterator +/* + unfolded-repeat-iterator.cc -- implement Unfolded_repeat_iterator, Volta_repeat_iterator -source file of the GNU LilyPond music typesetter + source file of the GNU LilyPond music typesetter -(c) 2002--2005 Han-Wen Nienhuys + (c) 2002--2005 Han-Wen Nienhuys */ #include "music.hh" @@ -19,13 +19,12 @@ protected: virtual SCM get_music_list () const; }; - SCM Unfolded_repeat_iterator::get_music_list () const { SCM l = SCM_EOL; SCM *tail = &l; - + SCM body = get_music ()->get_property ("element"); SCM alts = get_music ()->get_property ("elements"); int alt_count = scm_ilength (alts); @@ -34,7 +33,7 @@ Unfolded_repeat_iterator::get_music_list () const for (int i = 0; i < rep_count; i++) { if (unsmob_music (body)) - *tail = scm_cons (body, SCM_EOL) ; + *tail = scm_cons (body, SCM_EOL); tail = SCM_CDRLOC (*tail); @@ -43,12 +42,12 @@ Unfolded_repeat_iterator::get_music_list () const *tail = scm_cons (scm_car (alts), SCM_EOL); tail = SCM_CDRLOC (*tail); if (i >= rep_count - alt_count) - + alts = scm_cdr (alts); - } + } } - return l; + return l; } class Volta_repeat_iterator : public Sequential_iterator @@ -70,7 +69,6 @@ protected: int done_count_; }; - Volta_repeat_iterator::Volta_repeat_iterator () { done_count_ = alt_count_ = rep_count_ = 0; @@ -81,14 +79,14 @@ SCM Volta_repeat_iterator::get_music_list ()const { return scm_cons (get_music ()->get_property ("element"), - get_music ()->get_property ("elements")); + get_music ()->get_property ("elements")); } void Volta_repeat_iterator::construct_children () { Sequential_iterator::construct_children (); - + SCM alts = get_music ()->get_property ("elements"); alt_count_ = scm_ilength (alts); @@ -96,17 +94,16 @@ Volta_repeat_iterator::construct_children () done_count_ = 0; } - /* TODO: add source information for debugging - */ +*/ void Volta_repeat_iterator::add_repeat_command (SCM what) { SCM reps = ly_symbol2scm ("repeatCommands"); SCM current_reps = get_outlet ()->internal_get_property (reps); - Context * where = get_outlet ()->where_defined (reps); + Context *where = get_outlet ()->where_defined (reps); if (where && current_reps == SCM_EOL || scm_is_pair (current_reps)) { @@ -115,16 +112,15 @@ Volta_repeat_iterator::add_repeat_command (SCM what) } } - void Volta_repeat_iterator::next_element (bool side_effect) { - done_count_ ++; + done_count_++; Sequential_iterator::next_element (side_effect); if (side_effect) - { + { if (alt_count_) { String repstr = to_string (rep_count_ - alt_count_ + done_count_) + "."; @@ -136,8 +132,6 @@ Volta_repeat_iterator::next_element (bool side_effect) add_repeat_command (ly_symbol2scm ("end-repeat")); } - - if (done_count_ == 1 && alt_count_ < rep_count_) { repstr = "1.--" + to_string (rep_count_ - alt_count_ + done_count_) + "."; @@ -154,7 +148,6 @@ Volta_repeat_iterator::next_element (bool side_effect) } } - void Volta_repeat_iterator::process (Moment m) { @@ -166,6 +159,5 @@ Volta_repeat_iterator::process (Moment m) Sequential_iterator::process (m); } - IMPLEMENT_CTOR_CALLBACK (Volta_repeat_iterator); IMPLEMENT_CTOR_CALLBACK (Unfolded_repeat_iterator); diff --git a/lily/vaticana-ligature-engraver.cc b/lily/vaticana-ligature-engraver.cc index a0af4f2c17..da0169237f 100644 --- a/lily/vaticana-ligature-engraver.cc +++ b/lily/vaticana-ligature-engraver.cc @@ -1,10 +1,10 @@ /* vaticana-ligature-engraver.cc -- implement Vaticana_ligature_engraver - + source file of the GNU LilyPond music typesetter - + (c) 2003--2005 Juergen Reuter - */ +*/ #include "gregorian-ligature-engraver.hh" #include "gregorian-ligature.hh" @@ -54,41 +54,41 @@ bool Vaticana_ligature_engraver::is_stacked_head (int prefix_set, int context_info) { - bool is_stacked_b; + bool is_stacked_b; - // upper head of pes is stacked upon lower head of pes ... - is_stacked_b = context_info & PES_UPPER; + // upper head of pes is stacked upon lower head of pes ... + is_stacked_b = context_info & PES_UPPER; - // ... unless this note starts a flexa - if (context_info & FLEXA_LEFT) - is_stacked_b = false; + // ... unless this note starts a flexa + if (context_info & FLEXA_LEFT) + is_stacked_b = false; - // ... or another pes - if (context_info & PES_LOWER) - is_stacked_b = false; + // ... or another pes + if (context_info & PES_LOWER) + is_stacked_b = false; - // ... or the previous note is a semivocalis or inclinatum - if (context_info & AFTER_DEMINUTUM) - is_stacked_b = false; + // ... or the previous note is a semivocalis or inclinatum + if (context_info & AFTER_DEMINUTUM) + is_stacked_b = false; - // auctum head is never stacked upon preceding note - if (prefix_set & AUCTUM) - is_stacked_b = false; + // auctum head is never stacked upon preceding note + if (prefix_set & AUCTUM) + is_stacked_b = false; - // virga is never stacked upon preceding note - if (prefix_set & VIRGA) - is_stacked_b = false; + // virga is never stacked upon preceding note + if (prefix_set & VIRGA) + is_stacked_b = false; - // oriscus is never stacked upon preceding note - if (prefix_set & ORISCUS) - is_stacked_b = false; + // oriscus is never stacked upon preceding note + if (prefix_set & ORISCUS) + is_stacked_b = false; - if ((prefix_set & DEMINUTUM) && - !(prefix_set & INCLINATUM) && - (context_info & FLEXA_RIGHT)) - is_stacked_b = true; // semivocalis head of deminutus form + if ((prefix_set & DEMINUTUM) + && ! (prefix_set & INCLINATUM) + && (context_info & FLEXA_RIGHT)) + is_stacked_b = true; // semivocalis head of deminutus form - return is_stacked_b; + return is_stacked_b; } /* @@ -109,14 +109,14 @@ need_extra_space (int prev_prefix_set, int prefix_set, */ return true; - if ((prefix_set & INCLINATUM) && - !(prev_prefix_set & INCLINATUM)) + if ((prefix_set & INCLINATUM) + && ! (prev_prefix_set & INCLINATUM)) /* * Always start a series of inclinatum heads with an extra space. */ return true; - if ((context_info & FLEXA_LEFT) && !(context_info & PES_UPPER)) + if ((context_info & FLEXA_LEFT) && ! (context_info & PES_UPPER)) /* * Before a flexa (but not within a torculus), make a an * additional small space such that the appendix on the left side @@ -150,11 +150,11 @@ Vaticana_ligature_engraver::align_heads (Array primitives, /* * The paper column where we put the whole ligature into. */ - Paper_column *column = - dynamic_cast (primitives[0].grob_)->get_column (); + Paper_column *column + = dynamic_cast (primitives[0].grob_)->get_column (); - Real join_thickness = - thickness * column->get_layout ()->get_dimension (ly_symbol2scm ("linethickness")); + Real join_thickness + = thickness * column->get_layout ()->get_dimension (ly_symbol2scm ("linethickness")); /* * Amount of extra space two put between some particular @@ -173,11 +173,11 @@ Vaticana_ligature_engraver::align_heads (Array primitives, int prev_prefix_set = 0; for (int i = 0; i < primitives.size (); i++) { - Item *primitive = dynamic_cast (primitives[i].grob_); - int prefix_set = - scm_to_int (primitive->get_property ("prefix-set")); - int context_info = - scm_to_int (primitive->get_property ("context-info")); + Item *primitive = dynamic_cast (primitives[i].grob_); + int prefix_set + = scm_to_int (primitive->get_property ("prefix-set")); + int context_info + = scm_to_int (primitive->get_property ("context-info")); /* * Get glyph_name, delta_pitch and context_info for this head. @@ -227,12 +227,12 @@ Vaticana_ligature_engraver::align_heads (Array primitives, * of this and the other head are horizontally aligned. */ head_width = 0.0; - x_offset = join_thickness - - Font_interface::get_default_font (primitive)-> + x_offset = join_thickness + - Font_interface::get_default_font (primitive)-> find_by_name ("noteheads." + glyph_name).extent (X_AXIS).length (); } - else if (!String::compare (glyph_name, "flexa") || - !String::compare (glyph_name, "")) + else if (!String::compare (glyph_name, "flexa") + || !String::compare (glyph_name, "")) { /* * This head represents either half of a flexa shape. @@ -247,8 +247,8 @@ Vaticana_ligature_engraver::align_heads (Array primitives, * This is a regular head, placed right to the previous one. * Retrieve its width from corresponding font. */ - head_width = - Font_interface::get_default_font (primitive)-> + head_width + = Font_interface::get_default_font (primitive)-> find_by_name ("noteheads." + glyph_name).extent (X_AXIS).length (); x_offset = 0.0; } @@ -257,16 +257,16 @@ Vaticana_ligature_engraver::align_heads (Array primitives, * Save the head's final x-offset. */ primitive->set_property ("x-offset", - scm_make_real (x_offset)); + scm_make_real (x_offset)); /* * If the head is the 2nd head of a pes or flexa (but not a * flexa shape), mark this head to be joined with the left-side * neighbour head (i.e. the previous head) by a vertical beam. */ - if ((context_info & PES_UPPER) || - ((context_info & FLEXA_RIGHT) && - !(context_info & PES_LOWER))) + if ((context_info & PES_UPPER) + || ((context_info & FLEXA_RIGHT) + && ! (context_info & PES_LOWER))) { if (!prev_primitive) { @@ -276,7 +276,7 @@ Vaticana_ligature_engraver::align_heads (Array primitives, else { prev_primitive->set_property ("add-join", - ly_bool2scm (true)); + ly_bool2scm (true)); /* * Create a small overlap of adjacent heads so that the join @@ -333,8 +333,8 @@ Vaticana_ligature_engraver::align_heads (Array primitives, void check_for_prefix_loss (Item *primitive) { - int prefix_set = - scm_to_int (primitive->get_property ("prefix-set")); + int prefix_set + = scm_to_int (primitive->get_property ("prefix-set")); if (prefix_set & ~PES_OR_FLEXA) { String prefs = Gregorian_ligature::prefixes_to_str (primitive); @@ -348,211 +348,212 @@ void Vaticana_ligature_engraver::transform_heads (Spanner *ligature, Array primitives) { - Real flexa_width = robust_scm2double ( ligature->get_property ("flexa-width"), 2); + Real flexa_width = robust_scm2double (ligature->get_property ("flexa-width"), 2); - Real thickness = robust_scm2double ( ligature->get_property ("thickness"), 1); + Real thickness = robust_scm2double (ligature->get_property ("thickness"), 1); Item *prev_primitive = 0; int prev_prefix_set = 0; int prev_context_info = 0; int prev_delta_pitch = 0; String prev_glyph_name = ""; - for (int i = 0; i < primitives.size (); i++) { - Item *primitive = dynamic_cast (primitives[i].grob_); - - int delta_pitch; - SCM delta_pitch_scm = primitive->get_property ("delta-pitch"); - if (delta_pitch_scm != SCM_EOL) - { - delta_pitch = scm_to_int (delta_pitch_scm); - } - else - { - primitive->programming_error ("Vaticana_ligature:" - "delta-pitch undefined -> " - "ignoring grob"); - continue; - } - - /* retrieve & complete prefix_set and context_info */ - int prefix_set = - scm_to_int (primitive->get_property ("prefix-set")); - int context_info = - scm_to_int (primitive->get_property ("context-info")); - if (is_stacked_head (prefix_set, context_info)) - { - context_info |= STACKED_HEAD; - primitive->set_property ("context-info", - scm_int2num (context_info)); - } + for (int i = 0; i < primitives.size (); i++) + { + Item *primitive = dynamic_cast (primitives[i].grob_); - /* - * Now determine which head to typeset (this is context sensitive - * information, since it depends on neighbouring heads; therefore, - * this decision must be made here in the engraver rather than in - * the backend). - */ - String glyph_name; - if (prefix_set & VIRGA) - { - glyph_name = "svaticana.punctum"; - primitive->set_property ("add-stem", ly_bool2scm (true)); - } - else if (prefix_set & QUILISMA) - glyph_name = "svaticana.quilisma"; - else if (prefix_set & ORISCUS) - glyph_name = "ssolesmes.oriscus"; - else if (prefix_set & STROPHA) - if (prefix_set & AUCTUM) - glyph_name = "ssolesmes.stropha.aucta"; - else glyph_name = "ssolesmes.stropha"; - else if (prefix_set & INCLINATUM) - if (prefix_set & AUCTUM) - glyph_name = "ssolesmes.incl.auctum"; - else if (prefix_set & DEMINUTUM) - glyph_name = "ssolesmes.incl.parvum"; - else - glyph_name = "svaticana.inclinatum"; - else if (prefix_set & DEMINUTUM) - if (i == 0) + int delta_pitch; + SCM delta_pitch_scm = primitive->get_property ("delta-pitch"); + if (delta_pitch_scm != SCM_EOL) { - // initio debilis - glyph_name = "svaticana.reverse.plica"; + delta_pitch = scm_to_int (delta_pitch_scm); } - else if (prev_delta_pitch > 0) + else { - // epiphonus - if (!(prev_context_info & FLEXA_RIGHT)) - /* correct head of previous primitive */ - if (prev_delta_pitch > 1) - prev_glyph_name = "svaticana.epiphonus"; - else - prev_glyph_name = "svaticana.vepiphonus"; - glyph_name = "svaticana.plica"; + primitive->programming_error ("Vaticana_ligature:" + "delta-pitch undefined -> " + "ignoring grob"); + continue; } - else // (prev_delta_pitch <= 0) - { - // cephalicus - if (!(prev_context_info & FLEXA_RIGHT)) - /* correct head of previous primitive */ - { - if (i > 1) - { - /* cephalicus head with fixed size cauda */ - prev_glyph_name = "svaticana.inner.cephalicus"; - } - else - { - /* cephalicus head without cauda */ - prev_glyph_name = "svaticana.cephalicus"; - } - /* - * Flexa has no variable size cauda if its left head is - * stacked on the right head. This is true for - * cephalicus. Hence, remove the cauda. - * - * Urgh: for the current implementation, this rule only - * applies for cephalicus; but it is a fundamental rule. - * Therefore, the following line of code should be - * placed somewhere else. - */ - prev_primitive->set_property ("add-cauda", - ly_bool2scm (false)); - } - glyph_name = "svaticana.reverse.plica"; + /* retrieve & complete prefix_set and context_info */ + int prefix_set + = scm_to_int (primitive->get_property ("prefix-set")); + int context_info + = scm_to_int (primitive->get_property ("context-info")); + if (is_stacked_head (prefix_set, context_info)) + { + context_info |= STACKED_HEAD; + primitive->set_property ("context-info", + scm_int2num (context_info)); } - else if (prefix_set & (CAVUM | LINEA)) - if ((prefix_set & CAVUM) && (prefix_set & LINEA)) - glyph_name = "svaticana.linea.punctum.cavum"; - else if (prefix_set & CAVUM) - glyph_name = "svaticana.punctum.cavum"; - else - glyph_name = "svaticana.linea.punctum"; - else if (prefix_set & AUCTUM) - if (prefix_set & ASCENDENS) - glyph_name = "ssolesmes.auct.asc"; - else - glyph_name = "ssolesmes.auct.desc"; - else if ((context_info & STACKED_HEAD) && - (context_info & PES_UPPER)) - if (prev_delta_pitch > 1) - glyph_name = "svaticana.upes"; - else - glyph_name = "svaticana.vupes"; - else - glyph_name = "svaticana.punctum"; - /* - * This head needs a cauda, if it starts a flexa, is not the upper - * head of a pes, and if it is a punctum. - */ - if ((context_info & FLEXA_LEFT) && !(context_info & PES_UPPER)) - if (!String::compare (glyph_name, "svaticana.punctum")) - primitive->set_property ("add-cauda", ly_bool2scm (true)); - - /* - * Execptional rule for porrectus: - * - * If the current head is preceded by a \flexa and succeded by a - * \pes (e.g. "a \flexa g \pes a"), then join the current head and - * the previous head into a single curved flexa shape. - */ - if ((context_info & FLEXA_RIGHT) && (context_info & PES_LOWER)) - { - check_for_prefix_loss (prev_primitive); - prev_glyph_name = "flexa"; - prev_primitive->set_property ("flexa-height", - scm_int2num (prev_delta_pitch)); - prev_primitive->set_property ("flexa-width", - scm_make_real (flexa_width)); - bool add_cauda = !(prev_prefix_set && PES_OR_FLEXA); - prev_primitive->set_property ("add-cauda", - ly_bool2scm (add_cauda)); - check_for_prefix_loss (primitive); - glyph_name = ""; - primitive->set_property ("flexa-width", - scm_make_real (flexa_width)); - } - - /* - * Exceptional rule for pes: - * - * If this head is stacked on the previous one due to a \pes, then - * set the glyph of the previous head to that for this special - * case, thereby avoiding potential vertical collision with the - * current head. - */ - if (prefix_set & PES_OR_FLEXA) - { - if ((context_info & PES_UPPER) && (context_info & STACKED_HEAD)) + /* + * Now determine which head to typeset (this is context sensitive + * information, since it depends on neighbouring heads; therefore, + * this decision must be made here in the engraver rather than in + * the backend). + */ + String glyph_name; + if (prefix_set & VIRGA) + { + glyph_name = "svaticana.punctum"; + primitive->set_property ("add-stem", ly_bool2scm (true)); + } + else if (prefix_set & QUILISMA) + glyph_name = "svaticana.quilisma"; + else if (prefix_set & ORISCUS) + glyph_name = "ssolesmes.oriscus"; + else if (prefix_set & STROPHA) + if (prefix_set & AUCTUM) + glyph_name = "ssolesmes.stropha.aucta"; + else glyph_name = "ssolesmes.stropha"; + else if (prefix_set & INCLINATUM) + if (prefix_set & AUCTUM) + glyph_name = "ssolesmes.incl.auctum"; + else if (prefix_set & DEMINUTUM) + glyph_name = "ssolesmes.incl.parvum"; + else + glyph_name = "svaticana.inclinatum"; + else if (prefix_set & DEMINUTUM) + if (i == 0) { - if (!String::compare (prev_glyph_name, "svaticana.punctum")) + // initio debilis + glyph_name = "svaticana.reverse.plica"; + } + else if (prev_delta_pitch > 0) + { + // epiphonus + if (! (prev_context_info & FLEXA_RIGHT)) + /* correct head of previous primitive */ if (prev_delta_pitch > 1) - prev_glyph_name = "svaticana.lpes"; + prev_glyph_name = "svaticana.epiphonus"; else - prev_glyph_name = "svaticana.vlpes"; + prev_glyph_name = "svaticana.vepiphonus"; + glyph_name = "svaticana.plica"; + } + else // (prev_delta_pitch <= 0) + { + // cephalicus + if (! (prev_context_info & FLEXA_RIGHT)) + /* correct head of previous primitive */ + { + if (i > 1) + { + /* cephalicus head with fixed size cauda */ + prev_glyph_name = "svaticana.inner.cephalicus"; + } + else + { + /* cephalicus head without cauda */ + prev_glyph_name = "svaticana.cephalicus"; + } + + /* + * Flexa has no variable size cauda if its left head is + * stacked on the right head. This is true for + * cephalicus. Hence, remove the cauda. + * + * Urgh: for the current implementation, this rule only + * applies for cephalicus; but it is a fundamental rule. + * Therefore, the following line of code should be + * placed somewhere else. + */ + prev_primitive->set_property ("add-cauda", + ly_bool2scm (false)); + } + glyph_name = "svaticana.reverse.plica"; } - } + else if (prefix_set & (CAVUM | LINEA)) + if ((prefix_set & CAVUM) && (prefix_set & LINEA)) + glyph_name = "svaticana.linea.punctum.cavum"; + else if (prefix_set & CAVUM) + glyph_name = "svaticana.punctum.cavum"; + else + glyph_name = "svaticana.linea.punctum"; + else if (prefix_set & AUCTUM) + if (prefix_set & ASCENDENS) + glyph_name = "ssolesmes.auct.asc"; + else + glyph_name = "ssolesmes.auct.desc"; + else if ((context_info & STACKED_HEAD) + && (context_info & PES_UPPER)) + if (prev_delta_pitch > 1) + glyph_name = "svaticana.upes"; + else + glyph_name = "svaticana.vupes"; + else + glyph_name = "svaticana.punctum"; - if (prev_primitive) - prev_primitive->set_property ("glyph-name", - scm_makfrom0str (prev_glyph_name.to_str0 ())); + /* + * This head needs a cauda, if it starts a flexa, is not the upper + * head of a pes, and if it is a punctum. + */ + if ((context_info & FLEXA_LEFT) && ! (context_info & PES_UPPER)) + if (!String::compare (glyph_name, "svaticana.punctum")) + primitive->set_property ("add-cauda", ly_bool2scm (true)); - /* - * In the backend, flexa shapes and joins need to know about line - * thickness. Hence, for simplicity, let's distribute the - * ligature grob's value for thickness to each ligature head (even - * if not all of them need to know). - */ - primitive->set_property ("thickness", scm_make_real (thickness)); + /* + * Execptional rule for porrectus: + * + * If the current head is preceded by a \flexa and succeded by a + * \pes (e.g. "a \flexa g \pes a"), then join the current head and + * the previous head into a single curved flexa shape. + */ + if ((context_info & FLEXA_RIGHT) && (context_info & PES_LOWER)) + { + check_for_prefix_loss (prev_primitive); + prev_glyph_name = "flexa"; + prev_primitive->set_property ("flexa-height", + scm_int2num (prev_delta_pitch)); + prev_primitive->set_property ("flexa-width", + scm_make_real (flexa_width)); + bool add_cauda = !(prev_prefix_set && PES_OR_FLEXA); + prev_primitive->set_property ("add-cauda", + ly_bool2scm (add_cauda)); + check_for_prefix_loss (primitive); + glyph_name = ""; + primitive->set_property ("flexa-width", + scm_make_real (flexa_width)); + } + + /* + * Exceptional rule for pes: + * + * If this head is stacked on the previous one due to a \pes, then + * set the glyph of the previous head to that for this special + * case, thereby avoiding potential vertical collision with the + * current head. + */ + if (prefix_set & PES_OR_FLEXA) + { + if ((context_info & PES_UPPER) && (context_info & STACKED_HEAD)) + { + if (!String::compare (prev_glyph_name, "svaticana.punctum")) + if (prev_delta_pitch > 1) + prev_glyph_name = "svaticana.lpes"; + else + prev_glyph_name = "svaticana.vlpes"; + } + } - prev_primitive = primitive; - prev_prefix_set = prefix_set; - prev_context_info = context_info; - prev_delta_pitch = delta_pitch; - prev_glyph_name = glyph_name; - } + if (prev_primitive) + prev_primitive->set_property ("glyph-name", + scm_makfrom0str (prev_glyph_name.to_str0 ())); + + /* + * In the backend, flexa shapes and joins need to know about line + * thickness. Hence, for simplicity, let's distribute the + * ligature grob's value for thickness to each ligature head (even + * if not all of them need to know). + */ + primitive->set_property ("thickness", scm_make_real (thickness)); + + prev_primitive = primitive; + prev_prefix_set = prefix_set; + prev_context_info = context_info; + prev_delta_pitch = delta_pitch; + prev_glyph_name = glyph_name; + } prev_primitive->set_property ("glyph-name", scm_makfrom0str (prev_glyph_name.to_str0 ())); @@ -562,7 +563,7 @@ Vaticana_ligature_engraver::transform_heads (Spanner *ligature, #if 0 // experimental code to collapse spacing after ligature /* TODO: set to max (old/new spacing-increment), since other voices/staves also may want to set this property. */ - Item *first_primitive = dynamic_cast (primitives[0].grob_); + Item *first_primitive = dynamic_cast (primitives[0].grob_); Paper_column *paper_column = first_primitive->get_column (); paper_column->warning (_f ("Vaticana_ligature_engraver: " "setting `spacing-increment = %f': ptr =%ul", @@ -572,11 +573,10 @@ Vaticana_ligature_engraver::transform_heads (Spanner *ligature, #endif } - ADD_TRANSLATOR (Vaticana_ligature_engraver, -/* descr */ "Handles ligatures by glueing special ligature heads together.", -/* creats*/ "VaticanaLigature", -/* accepts */ "ligature-event", -/* acks */ "note-head-interface rest-interface", -/* reads */ "", -/* write */ ""); + /* descr */ "Handles ligatures by glueing special ligature heads together.", + /* creats*/ "VaticanaLigature", + /* accepts */ "ligature-event", + /* acks */ "note-head-interface rest-interface", + /* reads */ "", + /* write */ ""); diff --git a/lily/vaticana-ligature.cc b/lily/vaticana-ligature.cc index f9d6462942..d8e8b03e2d 100644 --- a/lily/vaticana-ligature.cc +++ b/lily/vaticana-ligature.cc @@ -1,8 +1,8 @@ /* vaticana-ligature.cc -- implement Vaticana_ligature - + source file of the GNU LilyPond music typesetter - + (c) 2003--2005 Juergen Reuter */ @@ -27,7 +27,7 @@ vaticana_brew_cauda (Grob *me, Real blotdiameter) { bool on_staffline = Staff_symbol_referencer::on_staffline (me, pos); - int interspaces = Staff_symbol_referencer::line_count (me)-1; + int interspaces = Staff_symbol_referencer::line_count (me) - 1; bool above_staff = pos > interspaces; if (delta_pitch > -1) @@ -99,9 +99,9 @@ vaticana_brew_flexa (Grob *me, * Compensate curve thickness that appears to be smaller in steep * section of bend. */ - Real left_height = - right_height + - min (0.12 * abs (interval), 0.3) * staff_space; + Real left_height + = right_height + + min (0.12 * abs (interval), 0.3) * staff_space; /* * Compensate optical illusion regarding vertical position of left @@ -130,22 +130,22 @@ vaticana_brew_flexa (Grob *me, if (solid) { - Stencil solid_head = - Lookup::bezier_sandwich (top_curve, bottom_curve); + Stencil solid_head + = Lookup::bezier_sandwich (top_curve, bottom_curve); stencil.add_stencil (solid_head); } else // outline { Bezier inner_top_curve = top_curve; inner_top_curve.translate (Offset (0.0, -line_thickness)); - Stencil top_edge = - Lookup::bezier_sandwich (top_curve, inner_top_curve); + Stencil top_edge + = Lookup::bezier_sandwich (top_curve, inner_top_curve); stencil.add_stencil (top_edge); Bezier inner_bottom_curve = bottom_curve; inner_bottom_curve.translate (Offset (0.0, +line_thickness)); - Stencil bottom_edge = - Lookup::bezier_sandwich (bottom_curve, inner_bottom_curve); + Stencil bottom_edge + = Lookup::bezier_sandwich (bottom_curve, inner_bottom_curve); stencil.add_stencil (bottom_edge); /* @@ -205,13 +205,13 @@ vaticana_brew_primitive (Grob *me) String glyph_name = ly_scm2string (glyph_name_scm); Stencil out; - Real thickness = robust_scm2double ( me->get_property ("thickness"), 1); + Real thickness = robust_scm2double (me->get_property ("thickness"), 1); - Real line_thickness = - thickness * me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness")); + Real line_thickness + = thickness * me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness")); - Real blotdiameter = - (me->get_layout ()->get_dimension (ly_symbol2scm ("blotdiameter"))); + Real blotdiameter + = (me->get_layout ()->get_dimension (ly_symbol2scm ("blotdiameter"))); int pos = Staff_symbol_referencer::get_rounded_position (me); @@ -222,7 +222,7 @@ vaticana_brew_primitive (Grob *me) else delta_pitch = 0; - Real x_offset = robust_scm2double ( me->get_property ("x-offset"), 0); + Real x_offset = robust_scm2double (me->get_property ("x-offset"), 0); bool add_stem = to_boolean (me->get_property ("add-stem")); bool add_cauda = to_boolean (me->get_property ("add-cauda")); @@ -238,9 +238,9 @@ vaticana_brew_primitive (Grob *me) * flexa_width.) */ Real staff_space = Staff_symbol_referencer::staff_space (me); - Real flexa_width = robust_scm2double ( me->get_property ("flexa-width"), 2) *staff_space; - out = - Lookup::blank (Box (Interval (0, 0.5*flexa_width), Interval (0, 0))); + Real flexa_width = robust_scm2double (me->get_property ("flexa-width"), 2) *staff_space; + out + = Lookup::blank (Box (Interval (0, 0.5*flexa_width), Interval (0, 0))); } else if (!String::compare (glyph_name, "flexa")) { @@ -248,8 +248,8 @@ vaticana_brew_primitive (Grob *me) } else { - out = - Font_interface::get_default_font (me)-> + out + = Font_interface::get_default_font (me)-> find_by_name ("noteheads." + glyph_name); } out.translate_axis (x_offset, X_AXIS); @@ -257,25 +257,25 @@ vaticana_brew_primitive (Grob *me) if (add_cauda) { - Stencil cauda = - vaticana_brew_cauda (me, pos, delta_pitch, - line_thickness, blotdiameter); + Stencil cauda + = vaticana_brew_cauda (me, pos, delta_pitch, + line_thickness, blotdiameter); out.add_stencil (cauda); } if (add_stem) { - Stencil stem = - vaticana_brew_cauda (me, pos, -1, - line_thickness, blotdiameter); + Stencil stem + = vaticana_brew_cauda (me, pos, -1, + line_thickness, blotdiameter); stem.translate_axis (head_width - line_thickness, X_AXIS); out.add_stencil (stem); } if (add_join) { - Stencil join = - vaticana_brew_join (me, delta_pitch, line_thickness, blotdiameter); + Stencil join + = vaticana_brew_join (me, delta_pitch, line_thickness, blotdiameter); join.translate_axis (head_width - line_thickness, X_AXIS); out.add_stencil (join); } diff --git a/lily/vertical-align-engraver.cc b/lily/vertical-align-engraver.cc index f45d48a261..33c0f1a98a 100644 --- a/lily/vertical-align-engraver.cc +++ b/lily/vertical-align-engraver.cc @@ -15,8 +15,8 @@ class Vertical_align_engraver : public Engraver { - Spanner * valign_; - bool qualifies (Grob_info) const; + Spanner *valign_; + bool qualifies (Grob_info) const; public: TRANSLATOR_DECLARATIONS (Vertical_align_engraver); protected: @@ -53,7 +53,7 @@ Vertical_align_engraver::finalize () bool Vertical_align_engraver::qualifies (Grob_info i) const { - int sz = i.origin_contexts ((Translator*)this).size () ; + int sz = i.origin_contexts ((Translator *)this).size (); return sz > 0 && Axis_group_interface::has_interface (i.grob_) && !i.grob_->get_parent (Y_AXIS) && Axis_group_interface::has_axis (i.grob_, Y_AXIS); @@ -68,11 +68,10 @@ Vertical_align_engraver::acknowledge_grob (Grob_info i) } } - ADD_TRANSLATOR (Vertical_align_engraver, -/* descr */ "Catch Vertical axis groups and stack them.", -/* creats*/ "VerticalAlignment", -/* accepts */ "", -/* acks */ "axis-group-interface", -/* reads */ "", -/* write */ ""); + /* descr */ "Catch Vertical axis groups and stack them.", + /* creats*/ "VerticalAlignment", + /* accepts */ "", + /* acks */ "axis-group-interface", + /* reads */ "", + /* write */ ""); diff --git a/lily/volta-bracket.cc b/lily/volta-bracket.cc index 3ef1ae9508..1127f2776a 100644 --- a/lily/volta-bracket.cc +++ b/lily/volta-bracket.cc @@ -27,50 +27,49 @@ -- * Should look for system_start_delim to find left edge of staff. - -*/ + */ MAKE_SCHEME_CALLBACK (Volta_bracket_interface, print, 1); SCM -Volta_bracket_interface::print (SCM smob) +Volta_bracket_interface::print (SCM smob) { Grob *me = unsmob_grob (smob); - Spanner *orig_span = dynamic_cast (me->original_); + Spanner *orig_span = dynamic_cast (me->original_); - bool broken_first_bracket = orig_span && (orig_span->broken_intos_[0] == (Spanner*)me); + bool broken_first_bracket = orig_span && (orig_span->broken_intos_[0] == (Spanner *)me); - bool broken_last_bracket = orig_span && (orig_span->broken_intos_.top () == (Spanner*)me); + bool broken_last_bracket = orig_span && (orig_span->broken_intos_.top () == (Spanner *)me); bool no_vertical_start = orig_span && !broken_first_bracket; bool no_vertical_end = orig_span && !broken_last_bracket; SCM s = me->get_property ("bars"); - Grob * endbar = scm_is_pair (s) ? unsmob_grob (scm_car (s)) : 0; + Grob *endbar = scm_is_pair (s) ? unsmob_grob (scm_car (s)) : 0; SCM glyph = endbar ? endbar->get_property ("glyph") : SCM_EOL; - + String str; if (scm_is_string (glyph)) str = ly_scm2string (glyph); else str = "|"; - - const char* cs = str.to_str0 (); - no_vertical_end |= - (strcmp (cs, ":|")!= 0 && strcmp (cs, "|:")!= 0 && strcmp (cs, "|.")!= 0 - && strcmp (cs, ":|:")!= 0 && strcmp (cs, ".|")!= 0); - Output_def * layout = me->get_layout (); + const char *cs = str.to_str0 (); + no_vertical_end + |= (strcmp (cs, ":|")!= 0 && strcmp (cs, "|:")!= 0 && strcmp (cs, "|.")!= 0 + && strcmp (cs, ":|:")!= 0 && strcmp (cs, ".|")!= 0); + + Output_def *layout = me->get_layout (); Real half_space = 0.5; - Item * bound = dynamic_cast (me)->get_bound (LEFT); + Item *bound = dynamic_cast (me)->get_bound (LEFT); /* not a start, but really broken in two */ - Real left = 0.; + Real left = 0.; if (bound->break_status_dir () == RIGHT) { Paper_column *pc = bound->get_column (); - left = pc->extent (pc, X_AXIS)[RIGHT] - bound->relative_coordinate (pc, X_AXIS); + left = pc->extent (pc, X_AXIS)[RIGHT] - bound->relative_coordinate (pc, X_AXIS); } else { @@ -80,13 +79,13 @@ Volta_bracket_interface::print (SCM smob) */ } - Real w = dynamic_cast (me)->spanner_length () - left - half_space; - Real h = robust_scm2double (me->get_property ("height"), 1); + Real w = dynamic_cast (me)->spanner_length () - left - half_space; + Real h = robust_scm2double (me->get_property ("height"), 1); - Stencil start, end ; + Stencil start, end; if (!no_vertical_start) - start = Line_interface::line (me, Offset (0, 0), Offset (0, h)); - + start = Line_interface::line (me, Offset (0, 0), Offset (0, h)); + if (!no_vertical_end) end = Line_interface::line (me, Offset (w, 0), Offset (w, h)); @@ -98,7 +97,7 @@ Volta_bracket_interface::print (SCM smob) { SCM text = me->get_property ("text"); SCM properties = me->get_property_alist_chain (SCM_EOL); - SCM snum = Text_interface::interpret_markup (layout->self_scm (), properties, text); + SCM snum = Text_interface::interpret_markup (layout->self_scm (), properties, text); Stencil num = *unsmob_stencil (snum); mol.add_at_edge (X_AXIS, LEFT, num, - num.extent (X_AXIS).length () @@ -108,17 +107,16 @@ Volta_bracket_interface::print (SCM smob) return mol.smobbed_copy (); } - void -Volta_bracket_interface::add_bar (Grob *me, Item* b) +Volta_bracket_interface::add_bar (Grob *me, Item *b) { Pointer_group_interface::add_grob (me, ly_symbol2scm ("bars"), b); Side_position_interface::add_support (me, b); - add_bound_item (dynamic_cast (me), b); + add_bound_item (dynamic_cast (me), b); } void -Volta_bracket_interface::add_column (Grob*me, Grob* c) +Volta_bracket_interface::add_column (Grob *me, Grob *c) { Side_position_interface::add_support (me, c); } diff --git a/lily/volta-engraver.cc b/lily/volta-engraver.cc index cedc195012..531c6fa02a 100644 --- a/lily/volta-engraver.cc +++ b/lily/volta-engraver.cc @@ -1,11 +1,10 @@ -/* +/* volta-engraver.cc -- implement Volta_engraver - + source file of the GNU LilyPond music typesetter - + (c) 2000--2005 Han-Wen Nienhuys - - */ +*/ #include "engraver.hh" #include "context.hh" @@ -19,7 +18,7 @@ /* Create Volta spanners, by reading repeatCommands property, usually set by Unfolded_repeat_iterator. - */ +*/ class Volta_engraver : public Engraver { public: @@ -30,7 +29,7 @@ protected: virtual void finalize (); virtual void stop_translation_timestep (); virtual void process_music (); - + Moment started_mom_; Spanner *volta_span_; Spanner *end_volta_span_; @@ -38,7 +37,7 @@ protected: SCM start_string_; bool staff_eligible (); - + }; Volta_engraver::Volta_engraver () @@ -48,14 +47,13 @@ Volta_engraver::Volta_engraver () end_volta_span_ = 0; } - /* TODO: this logic should be rewritten, it is buggy. One of the problems is that we can't determine wether or not to print the volta bracket during the first step, since that requires acknowledging the staff. - */ +*/ bool Volta_engraver::staff_eligible () { @@ -65,7 +63,6 @@ Volta_engraver::staff_eligible () return to_boolean (doit); } - if (!unsmob_grob (staff_)) return false; @@ -77,10 +74,10 @@ Volta_engraver::staff_eligible () /* only put a volta on the top staff. - + May be this is a bit convoluted, and we should have a single volta engraver in score context or somesuch. - + */ if (!scm_is_pair (staffs)) { @@ -94,17 +91,15 @@ Volta_engraver::staff_eligible () return true; } - void Volta_engraver::process_music () { SCM cs = get_property ("repeatCommands"); if (!staff_eligible ()) - return ; + return; - - bool end = false; + bool end = false; start_string_ = SCM_EOL; while (scm_is_pair (cs)) { @@ -114,12 +109,12 @@ Volta_engraver::process_music () && scm_car (c) == ly_symbol2scm ("volta") && scm_is_pair (scm_cdr (c))) { - if (scm_cadr (c) == SCM_BOOL_F) + if (scm_cadr (c) == SCM_BOOL_F) end = true; else start_string_ = scm_cadr (c); } - + cs = scm_cdr (cs); } @@ -127,14 +122,13 @@ Volta_engraver::process_music () { SCM l (get_property ("voltaSpannerDuration")); Moment now = now_mom (); - + bool early_stop = unsmob_moment (l) && *unsmob_moment (l) <= now - started_mom_; - + end = end || early_stop; } - if (end && !volta_span_) { warning (_ ("No volta spanner to end")); // fixme: be more verbose. @@ -145,38 +139,36 @@ Volta_engraver::process_music () volta_span_ = 0; } - if (volta_span_ && - (scm_is_string (start_string_) || scm_is_pair (start_string_))) + if (volta_span_ + && (scm_is_string (start_string_) || scm_is_pair (start_string_))) { warning (_ ("Already have a volta spanner. Stopping that one prematurely.")); - + if (end_volta_span_) { warning (_ ("Also have a stopped spanner. Giving up.")); - return ; + return; } end_volta_span_ = volta_span_; volta_span_ = 0; } - if (!volta_span_ && - (scm_is_string (start_string_) || scm_is_pair (start_string_))) + if (!volta_span_ + && (scm_is_string (start_string_) || scm_is_pair (start_string_))) { - started_mom_ = now_mom () ; + started_mom_ = now_mom (); volta_span_ = make_spanner ("VoltaBracket", SCM_EOL); - volta_span_->set_property ("text", start_string_); } } - void Volta_engraver::acknowledge_grob (Grob_info i) { - if (Item* item = dynamic_cast (i.grob_)) + if (Item *item = dynamic_cast (i.grob_)) { if (Note_column::has_interface (item)) { @@ -188,7 +180,7 @@ Volta_engraver::acknowledge_grob (Grob_info i) if (volta_span_) Volta_bracket_interface::add_bar (volta_span_, item); if (end_volta_span_) - Volta_bracket_interface::add_bar (end_volta_span_ , item); + Volta_bracket_interface::add_bar (end_volta_span_, item); } } else if (Staff_symbol::has_interface (i.grob_)) @@ -209,9 +201,7 @@ Volta_engraver::finalize () { } - - -void +void Volta_engraver::stop_translation_timestep () { if (volta_span_ && !staff_eligible ()) @@ -222,15 +212,15 @@ Volta_engraver::stop_translation_timestep () we need to do this here, because STAFF_ is not initialized yet in the 1st call of process_music () */ - - volta_span_->suicide ( ); + + volta_span_->suicide (); volta_span_ = 0; } - + if (end_volta_span_ && !end_volta_span_->get_bound (RIGHT)) { - Grob * cc = unsmob_grob (get_property ("currentCommandColumn")); - Item * ci = dynamic_cast (cc); + Grob *cc = unsmob_grob (get_property ("currentCommandColumn")); + Item *ci = dynamic_cast (cc); end_volta_span_->set_bound (RIGHT, ci); } @@ -238,21 +228,21 @@ Volta_engraver::stop_translation_timestep () if (volta_span_ && !volta_span_->get_bound (LEFT)) { - Grob * cc = unsmob_grob (get_property ("currentCommandColumn")); - Item * ci = dynamic_cast (cc); + Grob *cc = unsmob_grob (get_property ("currentCommandColumn")); + Item *ci = dynamic_cast (cc); volta_span_->set_bound (LEFT, ci); } - + } /* TODO: should attach volta to paper-column if no bar is found. - */ +*/ ADD_TRANSLATOR (Volta_engraver, -/* descr */ "Make volta brackets.", -/* creats*/ "VoltaBracket", -/* accepts */ "", -/* acks */ "bar-line-interface staff-symbol-interface note-column-interface", -/* reads */ "repeatCommands voltaSpannerDuration stavesFound", -/* write */ ""); + /* descr */ "Make volta brackets.", + /* creats*/ "VoltaBracket", + /* accepts */ "", + /* acks */ "bar-line-interface staff-symbol-interface note-column-interface", + /* reads */ "repeatCommands voltaSpannerDuration stavesFound", + /* write */ "");