From: Jan Nieuwenhuizen Date: Sun, 13 Feb 2000 17:30:20 +0000 (+0100) Subject: partial: 1.3.24.jcn X-Git-Tag: release/1.3.24~1 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=aa17e80c30e989e7112ebf25bcbe286e4bad3483;p=lilypond.git partial: 1.3.24.jcn ========== * Added a ROADMAP file explaining the source directory layout. * Minor tweak in the feta 6 and 9 numeral * Moved files from lib/ to flower/ * Removed Note_head_side class. * Updated the webpage to be a little more chatty. * Small Local_key_engraver optimization: only lookup timing engraver once. * Fixed dashed slurs * Rewrite of Slur code. Be much more picky about slur shapes. We try to offset the slur instead of bending it too much * Look at stem directions for tie direction. * Compound multimeasure rests. Put measures_i_ variable in an element property. Made the symbol a lot wider. * Time signature small cleanups. 1.3.22.h --- diff --git a/flower/binary-source-file.cc b/flower/binary-source-file.cc new file mode 100644 index 0000000000..eb6cbbb0ba --- /dev/null +++ b/flower/binary-source-file.cc @@ -0,0 +1,95 @@ +/* + binary-source-file.cc -- implement Binary_source_file + + source file of the LilyPond music typesetter + + (c) 1997--2000 Jan Nieuwenhuizen +*/ + + +#include // INT_MAX +#include + +#include "proto.hh" +#include "string.hh" +#include "source-file.hh" +#include "binary-source-file.hh" +#include "string-convert.hh" + +Binary_source_file::Binary_source_file (String& filename_str) + : Source_file (filename_str) +{ +} + +Binary_source_file::~Binary_source_file () +{ +} + +String +Binary_source_file::error_str (char const* pos_ch_C) const +{ + assert (this); + if (!in_b (pos_ch_C)) + return ""; + + char const* begin_ch_C = pos_ch_C - 8 >? ch_C (); + char const* end_ch_C = pos_ch_C + 7 + +#ifndef BINARY_SOURCE_FILE_HH +#define BINARY_SOURCE_FILE_HH + +#include "source-file.hh" + +class Binary_source_file : public Source_file +{ +public: + Binary_source_file (String& filename_str ); + virtual ~Binary_source_file (); + + U8 get_U8 (); + U16 get_U16 (); + U32 get_U32 (); + Byte get_Byte () {return get_U8 (); } + int get_int () { return get_U32 (); } + + virtual String error_str (char const* pos_ch_C ) const; + virtual int line_i (char const* pos_ch_C ) const; +}; + +#endif // BINARY_SOURCE_FILE_HH diff --git a/flower/include/source-file.hh b/flower/include/source-file.hh new file mode 100644 index 0000000000..560ab09ed9 --- /dev/null +++ b/flower/include/source-file.hh @@ -0,0 +1,72 @@ +// +// source-file.hh -- declare Source_file +// +// copyright 1997 Jan Nieuwenhuizen + +#ifndef SOURCE_FILE_HH +#define SOURCE_FILE_HH + +#include "proto.hh" +#include "string.hh" +#include "interval.hh" + +class istream; + + +/** + 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. +*/ + +class Source_file +{ +public: + /** Ugh! filename gets changed! The path to the opened file may + change, since it might be searched in multiple directories. */ + Source_file (String filename_str_r ); + + Source_file (String name_str, String data_str); + virtual ~Source_file (); + + char const* ch_C () const; + virtual String error_str (char const* pos_ch_C ) const; + istream * istream_l (); + bool in_b (char const* pos_ch_C ) const; + int length_i () const; + virtual int line_i (char const* pos_ch_C ) const; + String name_str () const; + String file_line_column_str (char const* ch_C ) const; + + // return start + n + char const* seek_ch_C (int n); + // return here + n bytes + char const* forward_ch_C (int n); + char const* pos_ch_C () { return pos_ch_C_; } + String get_str (int n); + void set_pos (char const * pos_ch_C); + + // tbd + // String get_line (); + // String get_word (); + // only used in binary-source-file, currently + + +protected: + Slice line_slice (char const* pos_ch_C) const; + String line_str (char const* pos_ch_C) const; + int column_i (char const* pos_ch_C) const; + int char_i (char const* pos_ch_C) const; + + char const* pos_ch_C_; + +private: + String name_str_; + istream* istream_p_; + File_storage * storage_p_; +}; + +#endif // SOURCE_FILE_HH // + diff --git a/flower/include/source.hh b/flower/include/source.hh new file mode 100644 index 0000000000..711f453c05 --- /dev/null +++ b/flower/include/source.hh @@ -0,0 +1,37 @@ +// +// source.hh -- part of LilyPond +// +// copyright 1997 Jan Nieuwenhuizen + +#ifndef SOURCE_HH +#define SOURCE_HH +#include "cons.hh" +#include "proto.hh" + +/** + a set of sourcefiles. + + TODO: + */ +class Sources +{ + Sources (Sources const&) {} +public: + Sources (); + ~Sources(); + + Source_file * get_file_l (String &filename ); + Source_file* sourcefile_l (char const* ch_C ); + void add (Source_file* sourcefile_p ); + void set_path (File_path*p_C); + void set_binary (bool); + + const File_path * path_C_; +private: + Cons *sourcefile_p_list_; + bool binary_b_ ; +}; + + + +#endif // SOURCE_HH // diff --git a/flower/include/string-storage.hh b/flower/include/string-storage.hh new file mode 100644 index 0000000000..ac48e15579 --- /dev/null +++ b/flower/include/string-storage.hh @@ -0,0 +1,30 @@ +/* + string-storage.hh -- declare String_storage + + source file of the GNU LilyPond music typesetter + + (c) 1998--2000 Jan Nieuwenhuizen + + */ + +#ifndef STRING_STORAGE_HH +#define STRING_STORAGE_HH + +#include "string.hh" +#include "file-storage.hh" + +/** + Urg, let String act as file storage. + */ +class String_storage : public File_storage, protected String +{ +public: + String_storage (String s) : String (s) { } + +protected: + virtual char const* ch_C () const { return String::ch_C (); } + virtual int length_i () const { return String::length_i (); } +}; + +#endif /* STRING_STORAGE_HH */ + diff --git a/flower/source-file.cc b/flower/source-file.cc new file mode 100644 index 0000000000..c5e5b1dd34 --- /dev/null +++ b/flower/source-file.cc @@ -0,0 +1,243 @@ +/* + source-file.cc -- implement Source_file + + source file of the GNU LilyPond music typesetter + + (c) 1997--2000 Jan Nieuwenhuizen + & Han-Wen Nienhuys +*/ + + +#include +#include + +#include "string.hh" +#include "proto.hh" +#include "warn.hh" +#include "source-file.hh" +#include "simple-file-storage.hh" +#include "string-storage.hh" + +Source_file::Source_file (String filename_str) +{ + name_str_ = filename_str; + istream_p_ = 0; + storage_p_ = new Simple_file_storage (filename_str); + pos_ch_C_ = ch_C (); +} + +Source_file::Source_file (String name_str, String data_str) +{ + name_str_ = name_str; + istream_p_ = 0; + storage_p_ = new String_storage (data_str); + pos_ch_C_ = ch_C (); +} + +istream* +Source_file::istream_l () +{ + /* + if (!name_str_.length_i ()) + return &cin; + */ + + if (!istream_p_) + { + if (length_i ()) // can-t this be done without such a hack? + istream_p_ = new istrstream (ch_C (), length_i ()); + else + { + istream_p_ = new istrstream ("", 0); + istream_p_->set (ios::eofbit); + } + } + return istream_p_; +} + +String +Source_file::file_line_column_str (char const *context_ch_C) const +{ + if (!ch_C ()) + return "(" + _ ("position unknown") + ")"; + else + return name_str () + ":" + to_str (line_i (context_ch_C)) + + ":" + to_str (char_i (context_ch_C)); +} + +String +Source_file::name_str () const +{ + return name_str_; +} + +Source_file::~Source_file () +{ + delete istream_p_; + istream_p_ = 0; + delete storage_p_; +} + +Slice +Source_file::line_slice (char const* pos_ch_C) const +{ + if (!in_b (pos_ch_C)) + return Slice (0,0); + + char const* data_ch_C = ch_C (); + char const * eof_C_ = data_ch_C + length_i (); + + if (pos_ch_C == eof_C_) + pos_ch_C --; + char const* begin_ch_C = pos_ch_C; + while (begin_ch_C > data_ch_C) + if (*--begin_ch_C == '\n') + { + begin_ch_C++; + break; + } + + char const* end_ch_C = pos_ch_C; + while (end_ch_C < eof_C_) + if (*end_ch_C++ == '\n') + { + end_ch_C--; + break; + } + + return Slice (begin_ch_C - data_ch_C, end_ch_C - data_ch_C); +} + +String +Source_file::line_str (char const* pos_ch_C) const +{ + if (!in_b (pos_ch_C)) + return ""; + + Slice line = line_slice (pos_ch_C); + char const* data_ch_C = ch_C (); + return String ((Byte const*)data_ch_C + line[LEFT], line.length ()); +} + +int +Source_file::char_i (char const* pos_ch_C) const +{ + if (!in_b (pos_ch_C)) + return 0; + + char const* data_ch_C = ch_C (); + return pos_ch_C - (line_slice (pos_ch_C)[SMALLER] + data_ch_C); +} + +int +Source_file::column_i (char const* pos_ch_C) const +{ + if (!in_b (pos_ch_C)) + return 0; + + int ch_i = char_i (pos_ch_C); + String line = line_str (pos_ch_C); + + int col_i = 0; + for (int i = 0; i < ch_i; i++) + if (line[i] == '\t') + col_i = (col_i / 8 + 1) * 8; + else + col_i++; + + return col_i; +} + +String +Source_file::error_str (char const* pos_ch_C) const +{ + if (!in_b (pos_ch_C)) + return "(" + _ ("position unknown") + ")"; + + int ch_i = char_i (pos_ch_C); + String line = line_str (pos_ch_C); + String context = line.left_str (ch_i) + + to_str ('\n') + + to_str (' ', column_i (pos_ch_C)) + + line.cut_str (ch_i, INT_MAX); + + return context; +} + +bool +Source_file::in_b (char const* pos_ch_C) const +{ + return (pos_ch_C && (pos_ch_C >= ch_C ()) && (pos_ch_C <= ch_C () + length_i ())); +} + +int +Source_file::line_i (char const* pos_ch_C) const +{ + if (!in_b (pos_ch_C)) + return 0; + + int i = 1; + char const* scan_ch_C = ch_C (); + if (!scan_ch_C) + return 0; + + while (scan_ch_C < pos_ch_C) + if (*scan_ch_C++ == '\n') + i++; + return i; +} + +int +Source_file::length_i () const +{ + return storage_p_->length_i (); +} + +char const * +Source_file::ch_C () const +{ + return storage_p_->ch_C (); +} + +void +Source_file::set_pos (char const * pos_ch_C) +{ + if (in_b (pos_ch_C)) + pos_ch_C_ = pos_ch_C; + else + error (error_str (pos_ch_C) + "invalid pos"); +} + +char const* +Source_file::seek_ch_C (int n) +{ + char const* new_ch_C = ch_C () + n; + if (n < 0) + new_ch_C += length_i (); + if (in_b (new_ch_C)) + pos_ch_C_ = new_ch_C; + else + error (error_str (new_ch_C) + "seek past eof"); + + return pos_ch_C_; +} + +char const* +Source_file::forward_ch_C (int n) +{ + char const* old_pos_C = pos_ch_C_; + char const* new_ch_C = pos_ch_C_ + n; + if (in_b (new_ch_C)) + pos_ch_C_ = new_ch_C; + else + error (error_str (new_ch_C) + "forward past eof"); + + return old_pos_C; +} + +String +Source_file::get_str (int n) +{ + String str ((Byte const*)forward_ch_C (n), n); + return str; +} diff --git a/lib/binary-source-file.cc b/lib/binary-source-file.cc deleted file mode 100644 index eb6cbbb0ba..0000000000 --- a/lib/binary-source-file.cc +++ /dev/null @@ -1,95 +0,0 @@ -/* - binary-source-file.cc -- implement Binary_source_file - - source file of the LilyPond music typesetter - - (c) 1997--2000 Jan Nieuwenhuizen -*/ - - -#include // INT_MAX -#include - -#include "proto.hh" -#include "string.hh" -#include "source-file.hh" -#include "binary-source-file.hh" -#include "string-convert.hh" - -Binary_source_file::Binary_source_file (String& filename_str) - : Source_file (filename_str) -{ -} - -Binary_source_file::~Binary_source_file () -{ -} - -String -Binary_source_file::error_str (char const* pos_ch_C) const -{ - assert (this); - if (!in_b (pos_ch_C)) - return ""; - - char const* begin_ch_C = pos_ch_C - 8 >? ch_C (); - char const* end_ch_C = pos_ch_C + 7 - -#ifndef BINARY_SOURCE_FILE_HH -#define BINARY_SOURCE_FILE_HH - -#include "source-file.hh" - -class Binary_source_file : public Source_file -{ -public: - Binary_source_file (String& filename_str ); - virtual ~Binary_source_file (); - - U8 get_U8 (); - U16 get_U16 (); - U32 get_U32 (); - Byte get_Byte () {return get_U8 (); } - int get_int () { return get_U32 (); } - - virtual String error_str (char const* pos_ch_C ) const; - virtual int line_i (char const* pos_ch_C ) const; -}; - -#endif // BINARY_SOURCE_FILE_HH diff --git a/lib/include/source-file.hh b/lib/include/source-file.hh deleted file mode 100644 index 560ab09ed9..0000000000 --- a/lib/include/source-file.hh +++ /dev/null @@ -1,72 +0,0 @@ -// -// source-file.hh -- declare Source_file -// -// copyright 1997 Jan Nieuwenhuizen - -#ifndef SOURCE_FILE_HH -#define SOURCE_FILE_HH - -#include "proto.hh" -#include "string.hh" -#include "interval.hh" - -class istream; - - -/** - 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. -*/ - -class Source_file -{ -public: - /** Ugh! filename gets changed! The path to the opened file may - change, since it might be searched in multiple directories. */ - Source_file (String filename_str_r ); - - Source_file (String name_str, String data_str); - virtual ~Source_file (); - - char const* ch_C () const; - virtual String error_str (char const* pos_ch_C ) const; - istream * istream_l (); - bool in_b (char const* pos_ch_C ) const; - int length_i () const; - virtual int line_i (char const* pos_ch_C ) const; - String name_str () const; - String file_line_column_str (char const* ch_C ) const; - - // return start + n - char const* seek_ch_C (int n); - // return here + n bytes - char const* forward_ch_C (int n); - char const* pos_ch_C () { return pos_ch_C_; } - String get_str (int n); - void set_pos (char const * pos_ch_C); - - // tbd - // String get_line (); - // String get_word (); - // only used in binary-source-file, currently - - -protected: - Slice line_slice (char const* pos_ch_C) const; - String line_str (char const* pos_ch_C) const; - int column_i (char const* pos_ch_C) const; - int char_i (char const* pos_ch_C) const; - - char const* pos_ch_C_; - -private: - String name_str_; - istream* istream_p_; - File_storage * storage_p_; -}; - -#endif // SOURCE_FILE_HH // - diff --git a/lib/include/source.hh b/lib/include/source.hh deleted file mode 100644 index 711f453c05..0000000000 --- a/lib/include/source.hh +++ /dev/null @@ -1,37 +0,0 @@ -// -// source.hh -- part of LilyPond -// -// copyright 1997 Jan Nieuwenhuizen - -#ifndef SOURCE_HH -#define SOURCE_HH -#include "cons.hh" -#include "proto.hh" - -/** - a set of sourcefiles. - - TODO: - */ -class Sources -{ - Sources (Sources const&) {} -public: - Sources (); - ~Sources(); - - Source_file * get_file_l (String &filename ); - Source_file* sourcefile_l (char const* ch_C ); - void add (Source_file* sourcefile_p ); - void set_path (File_path*p_C); - void set_binary (bool); - - const File_path * path_C_; -private: - Cons *sourcefile_p_list_; - bool binary_b_ ; -}; - - - -#endif // SOURCE_HH // diff --git a/lib/include/string-storage.hh b/lib/include/string-storage.hh deleted file mode 100644 index ac48e15579..0000000000 --- a/lib/include/string-storage.hh +++ /dev/null @@ -1,30 +0,0 @@ -/* - string-storage.hh -- declare String_storage - - source file of the GNU LilyPond music typesetter - - (c) 1998--2000 Jan Nieuwenhuizen - - */ - -#ifndef STRING_STORAGE_HH -#define STRING_STORAGE_HH - -#include "string.hh" -#include "file-storage.hh" - -/** - Urg, let String act as file storage. - */ -class String_storage : public File_storage, protected String -{ -public: - String_storage (String s) : String (s) { } - -protected: - virtual char const* ch_C () const { return String::ch_C (); } - virtual int length_i () const { return String::length_i (); } -}; - -#endif /* STRING_STORAGE_HH */ - diff --git a/lib/source-file.cc b/lib/source-file.cc deleted file mode 100644 index c5e5b1dd34..0000000000 --- a/lib/source-file.cc +++ /dev/null @@ -1,243 +0,0 @@ -/* - source-file.cc -- implement Source_file - - source file of the GNU LilyPond music typesetter - - (c) 1997--2000 Jan Nieuwenhuizen - & Han-Wen Nienhuys -*/ - - -#include -#include - -#include "string.hh" -#include "proto.hh" -#include "warn.hh" -#include "source-file.hh" -#include "simple-file-storage.hh" -#include "string-storage.hh" - -Source_file::Source_file (String filename_str) -{ - name_str_ = filename_str; - istream_p_ = 0; - storage_p_ = new Simple_file_storage (filename_str); - pos_ch_C_ = ch_C (); -} - -Source_file::Source_file (String name_str, String data_str) -{ - name_str_ = name_str; - istream_p_ = 0; - storage_p_ = new String_storage (data_str); - pos_ch_C_ = ch_C (); -} - -istream* -Source_file::istream_l () -{ - /* - if (!name_str_.length_i ()) - return &cin; - */ - - if (!istream_p_) - { - if (length_i ()) // can-t this be done without such a hack? - istream_p_ = new istrstream (ch_C (), length_i ()); - else - { - istream_p_ = new istrstream ("", 0); - istream_p_->set (ios::eofbit); - } - } - return istream_p_; -} - -String -Source_file::file_line_column_str (char const *context_ch_C) const -{ - if (!ch_C ()) - return "(" + _ ("position unknown") + ")"; - else - return name_str () + ":" + to_str (line_i (context_ch_C)) - + ":" + to_str (char_i (context_ch_C)); -} - -String -Source_file::name_str () const -{ - return name_str_; -} - -Source_file::~Source_file () -{ - delete istream_p_; - istream_p_ = 0; - delete storage_p_; -} - -Slice -Source_file::line_slice (char const* pos_ch_C) const -{ - if (!in_b (pos_ch_C)) - return Slice (0,0); - - char const* data_ch_C = ch_C (); - char const * eof_C_ = data_ch_C + length_i (); - - if (pos_ch_C == eof_C_) - pos_ch_C --; - char const* begin_ch_C = pos_ch_C; - while (begin_ch_C > data_ch_C) - if (*--begin_ch_C == '\n') - { - begin_ch_C++; - break; - } - - char const* end_ch_C = pos_ch_C; - while (end_ch_C < eof_C_) - if (*end_ch_C++ == '\n') - { - end_ch_C--; - break; - } - - return Slice (begin_ch_C - data_ch_C, end_ch_C - data_ch_C); -} - -String -Source_file::line_str (char const* pos_ch_C) const -{ - if (!in_b (pos_ch_C)) - return ""; - - Slice line = line_slice (pos_ch_C); - char const* data_ch_C = ch_C (); - return String ((Byte const*)data_ch_C + line[LEFT], line.length ()); -} - -int -Source_file::char_i (char const* pos_ch_C) const -{ - if (!in_b (pos_ch_C)) - return 0; - - char const* data_ch_C = ch_C (); - return pos_ch_C - (line_slice (pos_ch_C)[SMALLER] + data_ch_C); -} - -int -Source_file::column_i (char const* pos_ch_C) const -{ - if (!in_b (pos_ch_C)) - return 0; - - int ch_i = char_i (pos_ch_C); - String line = line_str (pos_ch_C); - - int col_i = 0; - for (int i = 0; i < ch_i; i++) - if (line[i] == '\t') - col_i = (col_i / 8 + 1) * 8; - else - col_i++; - - return col_i; -} - -String -Source_file::error_str (char const* pos_ch_C) const -{ - if (!in_b (pos_ch_C)) - return "(" + _ ("position unknown") + ")"; - - int ch_i = char_i (pos_ch_C); - String line = line_str (pos_ch_C); - String context = line.left_str (ch_i) - + to_str ('\n') - + to_str (' ', column_i (pos_ch_C)) - + line.cut_str (ch_i, INT_MAX); - - return context; -} - -bool -Source_file::in_b (char const* pos_ch_C) const -{ - return (pos_ch_C && (pos_ch_C >= ch_C ()) && (pos_ch_C <= ch_C () + length_i ())); -} - -int -Source_file::line_i (char const* pos_ch_C) const -{ - if (!in_b (pos_ch_C)) - return 0; - - int i = 1; - char const* scan_ch_C = ch_C (); - if (!scan_ch_C) - return 0; - - while (scan_ch_C < pos_ch_C) - if (*scan_ch_C++ == '\n') - i++; - return i; -} - -int -Source_file::length_i () const -{ - return storage_p_->length_i (); -} - -char const * -Source_file::ch_C () const -{ - return storage_p_->ch_C (); -} - -void -Source_file::set_pos (char const * pos_ch_C) -{ - if (in_b (pos_ch_C)) - pos_ch_C_ = pos_ch_C; - else - error (error_str (pos_ch_C) + "invalid pos"); -} - -char const* -Source_file::seek_ch_C (int n) -{ - char const* new_ch_C = ch_C () + n; - if (n < 0) - new_ch_C += length_i (); - if (in_b (new_ch_C)) - pos_ch_C_ = new_ch_C; - else - error (error_str (new_ch_C) + "seek past eof"); - - return pos_ch_C_; -} - -char const* -Source_file::forward_ch_C (int n) -{ - char const* old_pos_C = pos_ch_C_; - char const* new_ch_C = pos_ch_C_ + n; - if (in_b (new_ch_C)) - pos_ch_C_ = new_ch_C; - else - error (error_str (new_ch_C) + "forward past eof"); - - return old_pos_C; -} - -String -Source_file::get_str (int n) -{ - String str ((Byte const*)forward_ch_C (n), n); - return str; -}