* lily/include/source.hh (class Sources): idem.
* lily/include/performance.hh (class Performance): use vector
iso. Cons<>
* flower/include/cons.hh (class Cons): remove file.
* flower/include/flower-proto.hh: remove template cruft.
* lily/include/font-metric.hh: use size_t not vsize for indices.
* flower/include/flower-proto.hh (Module): remove std-vector.hh
from proto.
* lily/include/all-font-metrics.hh: use HAVE_PANGO_FT2
* flower/include/flower-proto.hh: remove outdated templates.
2006-02-16 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ * lily/include/midi-item.hh (class Midi_track): idem.
+
+ * lily/include/source.hh (class Sources): idem.
+
+ * lily/include/performance.hh (class Performance): use vector
+ iso. Cons<>
+
+ * flower/include/cons.hh (class Cons): remove file.
+
+ * flower/include/flower-proto.hh: remove template cruft.
+
+ * lily/include/font-metric.hh: use size_t not vsize for indices.
+
+ * flower/include/flower-proto.hh (Module): remove std-vector.hh
+ from proto.
+
+ * lily/include/all-font-metrics.hh: use HAVE_PANGO_FT2
+
* lily/include/paper-book.hh (class Paper_book):
make get_system_specs() public.
+++ /dev/null
-/*
- cons.hh -- declare LISP like datatypes
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1999--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
-*/
-
-#ifndef CONS_HH
-#define CONS_HH
-
-#include <cassert>
-using namespace std;
-
-template<class T>
-class Cons
-{
-public:
- T *car_;
- Cons *next_;
- Cons ()
- {
- car_ = 0;
- next_ = 0;
- }
- Cons (T *t, Cons<T> *c)
- {
- car_ = t;
- next_ = c;
- }
- virtual ~Cons ()
- {
- delete next_;
- }
-};
-
-template<class T>
-class Killing_cons : public Cons<T>
-{
-public:
- Killing_cons (T *t, Cons<T> *p)
- : Cons<T> (t, p)
- {
- }
- virtual ~Killing_cons ();
-};
-
-/// remove the link pointed to by *p.
-template<class T>
-Cons<T> *remove_cons (Cons<T> **pp)
-{
- Cons<T> *knip = *pp;
- *pp = (*pp)->next_;
- knip->next_ = 0;
- return knip;
-}
-
-template<class T> int cons_list_size (Cons<T> *l)
-{
- int i = 0;
- while (l)
- {
- l = l->next_;
- i++;
- }
- return i;
-}
-
-template<class T>
-Cons<T> *last_cons (Cons<T> *head)
-{
- while (head && head->next_)
- head = head->next_;
- return head;
-}
-
-/**
-
-Invariants:
-
-(*tail_) is either the head_ pointer, or a next_ pointer from the list.
-
-**tail_ == NULL
-*/
-
-template<class T>
-class Cons_list
-{
-public:
- Cons<T> *head_;
- Cons<T> ** nil_pointer_address_;
- Cons_list ()
- {
- init ();
- }
- void init ()
- {
- head_ = 0;
- nil_pointer_address_ = &head_;
- }
- void append (T *c)
- {
- append (new Cons<T> (c, 0));
- }
- void append (Cons<T> *c)
- {
- 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<T> *remove_cons (Cons<T> **pp)
- {
- if (& (*pp)->next_ == nil_pointer_address_)
- nil_pointer_address_ = pp;
-
- return ::remove_cons (pp);
- }
-
- /// junk everything after the first I elements.
- void truncate (int i)
- {
- Cons<T> **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;
- }
- ~Cons_list ()
- {
- junk ();
- }
- int size ()
- {
- return cons_list_size (head_);
- }
-};
-
-template<class T>
-void copy_killing_cons_list (Cons_list<T> &, Cons<T> *src);
-template<class T>
-void
-clone_killing_cons_list (Cons_list<T> &, Cons<T> *src);
-
-#endif /* CONS_HH */
-
struct String_convert;
#include "std-string.hh"
-#include "std-vector.hh"
using namespace std;
#include "real.hh"
static string rational_string (Rational);
static string pointer_string (void const *);
static string precision_string (double x, int n);
- static vector<string> split (string str, char c);
+ // static vector<string> split (string str, char c);
static string i64_string (I64, char const *fmt = 0);
static string to_lower (string s);
static string to_upper (string s);
return (sign (x) > 0 ? str : "-" + str);
}
-vector<string>
-String_convert::split (string str, char c)
-{
- vector<string> a;
- ssize i = str.find (c);
- while (i != NPOS)
- {
- string s = str.substr (0, i);
- a.push_back (s);
- while (str[++i] == c)
- ;
- str = str.substr (i);
- i = str.find (c);
- }
- if (str.length ())
- a.push_back (str);
- return a;
-}
string
String_convert::long_string (long l)
{
}
-vsize
+size_t
Font_metric::count () const
{
return 0;
}
Box
-Font_metric::get_ascii_char (vsize) const
+Font_metric::get_ascii_char (size_t) const
{
return Box (Interval (0, 0), Interval (0, 0));
}
Box
-Font_metric::get_indexed_char (vsize k) const
+Font_metric::get_indexed_char (size_t k) const
{
return get_ascii_char (k);
}
-vsize
+size_t
Font_metric::name_to_index (string) const
{
- return VPOS;
+ return (size_t)-1;
}
Offset
-Font_metric::get_indexed_wxwy (vsize) const
+Font_metric::get_indexed_wxwy (size_t) const
{
return Offset (0, 0);
}
return s;
}
-vsize
-Font_metric::index_to_ascii (vsize i) const
+size_t
+Font_metric::index_to_ascii (size_t i) const
{
return i;
}
-vsize
-Font_metric::index_to_charcode (vsize i) const
+size_t
+Font_metric::index_to_charcode (size_t i) const
{
return index_to_ascii (i);
}
Stencil
-Font_metric::get_ascii_char_stencil (vsize code) const
+Font_metric::get_ascii_char_stencil (size_t code) const
{
SCM at = scm_list_3 (ly_symbol2scm ("char"), self_scm (),
scm_from_unsigned (code));
}
Stencil
-Font_metric::get_indexed_char_stencil (vsize code) const
+Font_metric::get_indexed_char_stencil (size_t code) const
{
- vsize idx = index_to_ascii (code);
+ size_t idx = index_to_ascii (code);
SCM at = scm_list_3 (ly_symbol2scm ("char"), self_scm (),
scm_from_unsigned (idx));
Box b = get_indexed_char (code);
#ifndef ACCIDENTAL_INTERFACE_HH
#define ACCIDENTAL_INTERFACE_HH
+#include "std-vector.hh"
+
#include "box.hh"
#include "lily-guile.hh"
#include "lily-proto.hh"
#include "font-metric.hh"
#include "config.hh"
-#if HAVE_PANGO16
+#if HAVE_PANGO_FT2
#include <pango/pango.h>
#include <pango/pangoft2.h>
#endif
#ifndef AXIS_GROUP_INTERFACE_HH
#define AXIS_GROUP_INTERFACE_HH
+#include "std-vector.hh"
#include "lily-proto.hh"
#include "lily-guile.hh"
#ifndef BEAM_HH
#define BEAM_HH
+#include "std-vector.hh"
#include "lily-proto.hh"
#include "lily-guile.hh"
#include "stem-info.hh"
#ifndef CONTEXT_DEF_HH
#define CONTEXT_DEF_HH
+#include "std-vector.hh"
#include "lily-proto.hh"
#include "smobs.hh"
#include "input.hh"
#define CONTEXT_HH
+#include "std-vector.hh"
#include "moment.hh"
#include "lily-proto.hh"
#include "virtual-methods.hh"
SCM description_;
string file_name_;
+
virtual Stencil text_stencil (string) const;
virtual Box text_dimension (string) const;
virtual string font_name () const;
- virtual vsize count () const;
+ virtual size_t count () const;
virtual Offset attachment_point (string) const;
- virtual Offset get_indexed_wxwy (vsize) const;
- virtual Box get_indexed_char (vsize index) const;
- virtual Box get_ascii_char (vsize ascii) const;
- virtual vsize name_to_index (string) const;
- virtual vsize index_to_charcode (vsize) const;
- virtual vsize index_to_ascii (vsize) const;
+ virtual Offset get_indexed_wxwy (size_t) const;
+ virtual Box get_indexed_char (size_t index) const;
+ virtual Box get_ascii_char (size_t ascii) const;
+
+ /*
+ WTF are these vsize ?
+
+ Font_metric is not related to vector<>
+ */
+ virtual size_t name_to_index (string) const;
+ virtual size_t index_to_charcode (size_t) const;
+ virtual size_t index_to_ascii (size_t) const;
virtual Real design_size () const;
virtual Stencil find_by_name (string) const;
- virtual Stencil get_indexed_char_stencil (vsize k) const;
- virtual Stencil get_ascii_char_stencil (vsize k) const;
+ virtual Stencil get_indexed_char_stencil (size_t k) const;
+ virtual Stencil get_ascii_char_stencil (size_t k) const;
virtual SCM sub_fonts () const;
virtual SCM font_file_name () const;
DECLARE_SMOBS (Font_metric,);
#include "lily-guile.hh"
#include "lily-proto.hh"
+#include "std-vector.hh"
struct Horizontal_bracket
{
#define LOOKUP_HH
#include "stencil.hh"
+#include "std-vector.hh"
struct Lookup
{
#ifndef MIDI_ITEM_HH
#define MIDI_ITEM_HH
-#include "cons.hh"
#include "audio-item.hh"
+#include "std-vector.hh"
/**
Any piece of midi information.
/*
Compensate for starting grace notes.
*/
- Cons_list<Midi_event> event_p_list_;
+ vector<Midi_event*> events_;
Midi_track ();
+ ~Midi_track ();
void add (Moment delta_time_mom, Midi_item *midi);
virtual string data_string () const;
Stencil text_stencil (string) const;
static SCM make_scaled_font_metric (Font_metric *fm, Real magnification);
- vsize count () const;
- Offset get_indexed_wxwy (vsize) const;
+ size_t count () const;
+ Offset get_indexed_wxwy (size_t) const;
Offset attachment_point (string) const;
- vsize name_to_index (string) const;
- vsize index_to_charcode (vsize) const;
+ size_t name_to_index (string) const;
+ size_t index_to_charcode (size_t) const;
Font_metric *original_font () const;
protected:
string font_name () const;
Real design_size () const;
void derived_mark () const;
- Box get_indexed_char (vsize) const;
- vsize index_to_ascii (vsize) const;
- Box get_ascii_char (vsize) const;
+ Box get_indexed_char (size_t) const;
+ size_t index_to_ascii (size_t) const;
+ Box get_ascii_char (size_t) const;
Box tex_kludge (string) const;
};
string font_name () const;
~Open_type_font ();
Offset attachment_point (string) const;
- vsize count () const;
- Box get_indexed_char (vsize) const;
- vsize name_to_index (string) const;
- //vsize glyph_name_to_charcode (string) const;
- vsize index_to_charcode (vsize) const;
+ size_t count () const;
+ Box get_indexed_char (size_t) const;
+ size_t name_to_index (string) const;
+ //size_t glyph_name_to_charcode (string) const;
+ size_t index_to_charcode (size_t) const;
void derived_mark () const;
SCM sub_fonts () const;
Real design_size () const;
#define PERFORMANCE_HH
#include "std-vector.hh"
-#include "cons.hh"
#include "music-output.hh"
/* MIDI output. */
void write_output (string filename);
vector<Audio_staff*> audio_staffs_;
- Cons<Audio_element> *audio_element_list_;
+ vector<Audio_element*> audio_elements_;
Output_def *midi_;
};
INSTANTIATE_COMPARE (Pitch, Pitch::compare);
-int compare (vector<Pitch> *, vector<Pitch> *);
extern SCM pitch_less_proc;
Pitch pitch_interval (Pitch const &from, Pitch const &to);
#ifndef SOURCE_FILE_HH
#define SOURCE_FILE_HH
-#include "std-string.hh"
+#include "flower-proto.hh"
#include "std-vector.hh"
#include "lily-proto.hh"
+#include "protected-scm.hh"
#include <iostream>
using namespace std;
-#include "protected-scm.hh"
-
/**
class for reading and mapping a file.
#ifndef SOURCE_HH
#define SOURCE_HH
-#include "cons.hh"
#include "flower-proto.hh"
-#include "std-string.hh"
+#include "std-vector.hh"
/* A set of sourcefiles. */
class Sources
{
Sources (Sources const &) {}
- Cons<Source_file> *sourcefile_list_;
+ vector<Source_file*> sourcefiles_;
bool is_binary_;
public:
#include "lily-proto.hh"
#include "lily-guile.hh"
#include "rational.hh"
+#include "std-vector.hh"
struct Spacing_options
{
#ifndef STEM_HH
#define STEM_HH
+#include "std-vector.hh"
#include "lily-proto.hh"
#include "lily-guile.hh"
#include "stem-info.hh"
#include "virtual-methods.hh"
#include "input.hh"
#include "smobs.hh"
+#include "std-vector.hh"
struct Acknowledge_information
{
#include "lily-guile.hh"
#include "lily-proto.hh"
+#include "std-vector.hh"
class Tuplet_bracket
{
string s = symbols;
replace_all (s, '\n', ' ');
replace_all (s, '\t', ' ');
- return ly_string_array_to_scm (String_convert::split (s, ' '));
+ return ly_string_array_to_scm (split_string (s, ' '));
}
SCM
#include "lilypond-input-version.hh"
#include "string-convert.hh"
-#include "std-vector.hh"
+#include "misc.hh"
Lilypond_version::Lilypond_version (int major, int minor, int patch)
{
patch_ = 0;
vector<string> version;
- version = String_convert::split (str, '.');
+ version = split_string (str, '.');
if (version.size () > 0 && isdigit (version[0][0]))
major_ = String_convert::dec2int (version[0]);
USER_NAME, GROUP_NAME, JAIL, DIR, JAIL_MAX
};
- vector<string> components = String_convert::split (jail_spec, ',');
+ vector<string> components = split_string (jail_spec, ',');
if (components.size () != JAIL_MAX)
{
error (_f ("expected %d arguments with jail, found: %d", JAIL_MAX,
assert (delta_time_mom >= Moment (0));
Midi_event *e = new Midi_event (delta_time_mom, midi);
- event_p_list_.append (new Killing_cons<Midi_event> (e, 0));
+ events_.push_back (e);
}
string
string str = Midi_chunk::data_string ();
if (do_midi_debugging_global)
str += "\n";
- for (Cons<Midi_event> *i = event_p_list_.head_; i; i = i->next_)
+
+ for (vector<Midi_event*>::const_iterator i (events_.begin());
+ i != events_.end(); i ++)
{
- str += i->car_->to_string ();
+ str += (*i)->to_string ();
if (do_midi_debugging_global)
str += "\n";
}
{
return this->class_name ();
}
+
+Midi_track::~Midi_track ()
+{
+ junk_pointers (events_);
+}
return log (x) / log (2.0);
}
+vector<string>
+split_string (string str, char c)
+{
+ vector<string> a;
+ ssize i = str.find (c);
+ while (i != NPOS)
+ {
+ string s = str.substr (0, i);
+ a.push_back (s);
+ while (str[++i] == c)
+ ;
+ str = str.substr (i);
+ i = str.find (c);
+ }
+ if (str.length ())
+ a.push_back (str);
+ return a;
+}
+
+#if 0
vector<string>
split_string (string s, char c)
{
return rv;
}
+#endif
Real
}
Box
-Open_type_font::get_indexed_char (vsize signed_idx) const
+Open_type_font::get_indexed_char (size_t signed_idx) const
{
if (SCM_HASHTABLE_P (lily_index_to_bbox_table_))
{
if (SCM_HASHTABLE_P (lily_character_table_))
{
- const vsize len = 256;
+ const size_t len = 256;
char name[len];
- vsize code = FT_Get_Glyph_Name (face_, signed_idx, name, len);
+ size_t code = FT_Get_Glyph_Name (face_, signed_idx, name, len);
if (code)
warning (_f ("FT_Get_Glyph_Name() returned error: %d", code));
return b;
}
-vsize
+size_t
Open_type_font::name_to_index (string nm) const
{
char *nm_str = (char *) nm.c_str ();
- if (vsize idx = FT_Get_Name_Index (face_, nm_str))
+ if (size_t idx = FT_Get_Name_Index (face_, nm_str))
return idx;
- return VPOS;
+
+ return (size_t) -1;
}
-vsize
-Open_type_font::index_to_charcode (vsize i) const
+size_t
+Open_type_font::index_to_charcode (size_t i) const
{
return ((Open_type_font *) this)->index_to_charcode_map_[i];
}
-vsize
+size_t
Open_type_font::count () const
{
return ((Open_type_font *) this)->index_to_charcode_map_.size ();
for (int i = 0; i < face_->num_glyphs; i++)
{
- const vsize len = 256;
+ const size_t len = 256;
char name[len];
- vsize code = FT_Get_Glyph_Name (face_, i, name, len);
+ size_t code = FT_Get_Glyph_Name (face_, i, name, len);
if (code)
warning (_f ("FT_Get_Glyph_Name() returned error: %d", code));
Performance::Performance ()
{
midi_ = 0;
- audio_element_list_ = 0;
}
Performance::~Performance ()
{
- delete audio_element_list_;
+ junk_pointers (audio_elements_);
}
void
{
if (Audio_staff *s = dynamic_cast<Audio_staff *> (p))
audio_staffs_.push_back (s);
- audio_element_list_ = new Killing_cons<Audio_element> (p, audio_element_list_);
+
+ audio_elements_.push_back (p);
}
void
Sources::Sources ()
{
- sourcefile_list_ = 0;
path_ = 0;
is_binary_ = false;
}
void
Sources::add (Source_file *sourcefile)
{
- sourcefile_list_ = new Killing_cons<Source_file> (sourcefile, sourcefile_list_);
+ sourcefiles_.push_back (sourcefile);
}
Sources::~Sources ()
{
- delete sourcefile_list_;
+ junk_pointers (sourcefiles_);
}
-/**
- search the list for file whose map contains pointer #str0#
- @return 0 if not found.
-*/
Source_file *
Sources::get_sourcefile (char const *str0)
{
+ for (vector<Source_file*>::iterator i = sourcefiles_.begin();
+ i != sourcefiles_.end (); i++)
+ {
+ if ((*i)->contains (str0))
+ return *i;
+ }
- for (Cons<Source_file> *i = sourcefile_list_; i; i = i->next_)
- if (i->car_->contains (str0))
- return i->car_;
return 0;
}