Functions and methods do not return errorcodes, but use assert for
checking status.
- A program should be light and agile, its subroutines
- connected like a strings of pearls. The spirit and intent of
- the program should be retained throughout. There should be
- neither too little nor too much, neither needless loops nor
- useless variables, neither lack of structure nor overwhelming
- rigidity.
-
- A program should follow the 'Law of Least
- Astonishment'. What is this law? It is simply that the
- program should always respond to the user in the way that
- astonishes him least.
-
- A program, no matter how complex, should act as a
- single unit. The program should be directed by the logic
- within rather than by outward appearances.
-
- If the program fails in these requirements, it will be
- in a state of disorder and confusion. The only way to correct
- this is to rewrite the program.
- -- Geoffrey James, "The Tao of Programming"
+=head2 Quote:
+
+A program should be light and agile, its subroutines
+connected like a strings of pearls. The spirit and intent of
+the program should be retained throughout. There should be
+neither too little nor too much, neither needless loops nor
+useless variables, neither lack of structure nor overwhelming
+rigidity.
+
+A program should follow the 'Law of Least
+Astonishment'. What is this law? It is simply that the
+program should always respond to the user in the way that
+astonishes him least.
+
+A program, no matter how complex, should act as a
+single unit. The program should be directed by the logic
+within rather than by outward appearances.
+
+If the program fails in these requirements, it will be
+in a state of disorder and confusion. The only way to correct
+this is to rewrite the program.
+
+-- Geoffrey James, "The Tao of Programming"
=head2 INDENTATION
NB: in PCursor (which is part of the library) P stands for PointerCursor
-=head2 MEMBERS(2)
+=head2 MEMBERS (2)
Standard methods:
=over 5
=item *
+
more keystrokes (disk space!)
=item *
+
it looks silly C<get_slu_p()>
=item *
+
it looks like code from micro suckers
=item *
+
(which) might scare away some (otherwise good?)
progammers, or make you a paria in the free
software community
=item *
+
it has ambiguities
=item *
+
not very useful if not used consistently
=item *
+
usefullness in I<very large>
(but how many classes is very large?)
remains an issue.
=over 5
=item *
+
learn about cut and paste / use emacs or vi
or lean to type using ten fingers
=item *
+
Use emacs dabbrev-expand, with dabbrev-case-fold-search set to nil.
=item *
+
use no, or pick less silly, abbrvs.
=item *
+
use non-ambiguous postfixes C<identifier_name_type_modifier[_modifier]>
=back
=over 5
=item C<byte>
+
+
unsigned char. (The postfix _by is ambiguous)
=item C<b>
+
+
bool
=item C<bi>
+
bit
=item C<ch>
+
char
=item C<f>
+
float
=item C<i>
+
signed integer
=item C<str>
+
string class
=item C<sz>
+
Zero terminated c string
=item C<u>
+
unsigned integer
=back
=over 5
=item C<a>
+
array
=item C<array>
+
user built array.
=item C<c>
-const
+
+const. Note that the proper order C<Type const> i.s.o. C<const Type>
=item C<l>
+
temporary pointer to object (link)
=item C<p>
+
pointer to newed object
=item C<r>
+
reference
=back
=over 5
=item C<loop_i>
+
Variable loop: an integer
=item C<u>
+
Temporary variable: an unsigned integer
=item C<test_ch>
+
Variable test: a character
=item C<first_name_str>
+
Variable first_name: a String class object
=item C<last_name_ch_a>
+
Variable last_name: a C<char> array
=item C<foo_i_p>
+
Variable foo: an C<Int*> that you must delete
=item C<bar_i_l>
+
Variable bar: an C<Int*> that you must not delete
=back
# identify module:
#
NAME = Documentation
-MAJOR_VERSION = $(TOPLEVEL_MAJOR_VERSION)
-MINOR_VERSION = $(TOPLEVEL_MINOR_VERSION)
-PATCH_LEVEL = $(TOPLEVEL_PATCH_LEVEL)
-# use to send patches, always empty for released version:
-MY_PATCH_LEVEL = $(TOPLEVEL_MY_PATCH_LEVEL)
-build = ./$(depth)/lily/$(outdir)/.build
+
#
# generic variables:
#
include ./$(depth)/make/Variables.make
+include ./$(depth)/make/Version.make
+include ./$(depth)/make/Files.make
#
-# list of source files:
#
-PODFILES = $(shell ls *.pod)
+
OUTPODFILES = $(patsubst %,$(outdir)/%,$(PODFILES))
TEXTFILES = $(OUTPODFILES:.pod=.text)
GROFFFILES = $(OUTPODFILES:.pod=.1)
# list of distribution files:
#
-DISTFILES = $(PODFILES) Makefile lelie_logo.gif
+EXTRA_DISTFILES = lelie_icon.gif lelie_logo.gif
#
default: do-doc
Stem_info(){}
- Stem_info(const Stem*);
+ Stem_info(Stem const *);
};
-Stem_info::Stem_info(const Stem*s)
+Stem_info::Stem_info(Stem const *s)
{
x = s->hindex();
int dir = s->dir;
void
Clef_register::process_requests()
{
- const Time_description *time_l = get_staff_info().time_c_l_;
+ Time_description const *time_l = get_staff_info().time_c_l_;
if (!clef_req_l_ && (!time_l->whole_in_measure_|| !time_l->when_)) {
clef_p_ = new Clef_item;
clef_p_->change = false;
parse_dimen(String dim)
{
int i=dim.length_i()-1;
- const char *s = dim;
+ char const *s = dim;
while (i > 0 && (isspace(s[i]) || isalpha(s[i])) ){
i--;
}
#endif
}
-Idealspacing::Idealspacing(const PCol * l,const PCol * r)
+Idealspacing::Idealspacing(PCol const * l,PCol const * r)
{
space = 0.0;
hooke = 0.0;
/// a macro to declare the classes name as a static and virtual function.
#define NAME_MEMBERS(c) \
-static const char *static_name(){ return #c; }\
-virtual const char *name() const{ return c::static_name(); } \
+static char const *static_name(){ return #c; }\
+virtual char const *name() const{ return c::static_name(); } \
int a_stupid_nonexistent_function_to_allow_the_semicolon_come_out()
#endif // CLASS-NAME_HH
Real hooke;
/// the two columns
- const PCol *left, *right;
+ PCol const *left, *right;
void print()const;
void OK() const ;
- Idealspacing(const PCol *left,const PCol *right);
+ Idealspacing(PCol const *left,PCol const *right);
};
/// the total music def of one movement
struct Input_score {
/// defined where?
- const char* defined_ch_c_l_;
+ char const * defined_ch_c_l_;
int errorlevel_i_;
/// paper_, staffs_ and commands_ form the problem definition.
Midi_def* midi_p_;
IPointerList<Input_staff*> staffs_;
- Input_music * score_wide_music_p_;
/* *************************************************************** */
Input_score();
void set(Midi_def* midi_p);
void print() const;
Score*parse();
- void set(Input_music*);
};
#endif
struct Input_staff {
- const char * defined_ch_c_l_;
+ char const * defined_ch_c_l_;
String type;
IPointerList<Input_music*> music_;
- Input_music * score_wide_music_p_;
/* *************** */
~Input_staff();
void add(Input_music*m);
Input_staff(Input_staff const&);
Input_staff(String);
- void set_score_wide(Input_music*m);
- Staff* parse(Score*, Input_music *score_wide);
+ Staff* parse(Score*);
void print() const;
};
/* for the keyword table */
struct Keyword_ent
{
- const char *name;
+ char const *name;
int tokcode;
};
Keyword_ent *table;
int maxkey;
Keyword_table(Keyword_ent *);
- int lookup(const char *s) const;
+ int lookup(char const *s) const;
};
/// helper struct for #Spacing_problem#
struct Colinfo {
- const PCol *pcol_;
- const Real* fixpos;
+ PCol const *pcol_;
+ Real const * fixpos;
Interval width;
/* *************** */
void operator=(Colinfo const&);
Colinfo(Colinfo const&);
~Colinfo();
- Colinfo(const PCol*,const Real*);
+ Colinfo(PCol const *,Real const *);
void print() const;
bool fixed() const { return fixpos;}
Real fixed_position()const { return *fixpos; }
springs. The lower the energy, the better the configuration.
*/
class Spacing_problem {
- Array<const Idealspacing*> ideals;
+ Array<Idealspacing const *> ideals;
Array<Colinfo> cols;
/// the index of #c# in #cols#
- int col_id(const PCol *c) const;
+ int col_id(PCol const *c) const;
/// generate an (nonoptimal) solution
Vector find_initial_solution() const;
bool check_feasible() const;
/// does #this# contain the column #w#?
- bool contains(const PCol *w);
+ bool contains(PCol const *w);
/// make the energy function
void make_matrices(Matrix &quad, Vector &lin,Real&) const;
since they can be "summed" if the columns to which #i# refers are
not in this problem, the spacing is ignored.
*/
- void add_ideal(const Idealspacing *i);
+ void add_ideal(Idealspacing const *i);
/** add a col to the problem. columns have to be added left to right. The column contains
info on it's minimum width.
*/
- void add_column(const PCol *, bool fixed=false, Real fixpos=0.0);
+ void add_column(PCol const *, bool fixed=false, Real fixpos=0.0);
Vector try_initial_solution() const;
void OK() const;
void print() const;
- void print_ideal(const Idealspacing*)const;
+ void print_ideal(Idealspacing const *)const;
};
struct Local_key_register : Request_register {
Local_key local_key_;
Local_key_item* key_item_p_;
- const Key *key_c_l_;
+ Key const *key_c_l_;
/* *************** */
virtual void process_requests();
virtual void acknowledge_element(Staff_elem_info);
*/
struct PCol {
- PointerList<const Item*> its;
- PointerList<const Spanner*> stoppers, starters;
+ PointerList<Item const *> its;
+ PointerList<Spanner const *> stoppers, starters;
PCol *daddy_l_;
/// if lines are broken then this column is in #line#
- const Line_of_score *line_l_;
+ Line_of_score const *line_l_;
/// if lines are broken then this column x-coord #hpos#
Real hpos;
/**
@return argument as a cursor of the list
*/
- PCursor<PCol *> find_col(const PCol *)const;
+ PCursor<PCol *> find_col(PCol const *)const;
/* MAIN ROUTINES */
void process();
PScore * pscore_l_;
- PointerList<const Spanner*> spans;
+ PointerList<Spanner const *> spans;
PointerList<Item*> its;
/* *************** */
Real standard_height()const;
Real note_width() const;
void print() const;
- const Lookup* lookup_l(); // TODO naming
+ Lookup const * lookup_l(); // TODO naming
Real duration_to_dist(Moment);
};
Matrix A,H;
Array<int> active;
Array<int> inactive; // actually this is a set, not an array.
- const Ineq_constrained_qp *opt;
+ Ineq_constrained_qp const *opt;
public:
String status()const;
IPointerList<Score_column*> cols_;
PScore *pscore_p_;
- const char *defined_ch_c_l_;
+ char const *defined_ch_c_l_;
int errorlevel_i_;
/* *************************************************************** */
String TeXstring() const;
// is #c# contained in #*this#?
- bool element(const PCol *c);
+ bool element(PCol const *c);
};
#endif
struct Staff_elem_info {
Staff_elem * elem_p_;
Request*req_l_;
- const Voice * voice_l_;
+ Voice const * voice_l_;
Array<Request_register*> origin_reg_l_arr_;
/* *** */
struct Staff_info {
int *c0_position_i_;
Staff_walker *walk_l_;
- const Time_description *time_c_l_;
- const Rhythmic_grouping *rhythmic_c_l_;
+ Time_description const *time_c_l_;
+ Rhythmic_grouping const *rhythmic_c_l_;
bool break_allowed_b_;
};
struct Staff_elem_info {
Staff_elem * elem_p_;
Request*req_l_;
- const Voice * voice_l_;
+ Voice const * voice_l_;
Voice_group_registers * group_regs_l_;
Request_register * origin_reg_l_;
midi_p_ = (s.midi_p_)? new Midi_def(*s.midi_p_) : 0;
defined_ch_c_l_ = s.defined_ch_c_l_;
errorlevel_i_ = s.errorlevel_i_;
- score_wide_music_p_ = (s.score_wide_music_p_) ?
- s.score_wide_music_p_->clone():0;
}
Score*
if (midi_p_)
s_p->set(new Midi_def(*midi_p_));
if (paper_p_)
- s_p->set( new Paper_def(*paper_p_));
+ s_p->set(new Paper_def(*paper_p_));
for (iter_top(staffs_,i); i.ok(); i++) {
- Staff* staf_p=i->parse(s_p, score_wide_music_p_);
+ Staff* staf_p=i->parse(s_p);
s_p->add(staf_p);
}
return s_p;
}
-void
-Input_score::set(Input_music *m_p)
-{
- delete score_wide_music_p_;
- score_wide_music_p_ =m_p;
-}
-
Input_score::~Input_score()
{
delete paper_p_;
- delete score_wide_music_p_;
delete midi_p_;
}
Input_score::Input_score()
{
- score_wide_music_p_ =0;
defined_ch_c_l_=0;
paper_p_= 0;
midi_p_ = 0;
}
void
-Key_item::read(const Key_register& key_reg_r)
+Key_item::read(Key_register const & key_reg_r)
{
const Array<int> &idx_arr =key_reg_r.accidental_idx_arr_;
for (int i = 0 ; i< idx_arr.size(); i++) {
void
Key_register::process_requests()
{
- const Time_description *time_l = get_staff_info().time_c_l_;
+ Time_description const *time_l = get_staff_info().time_c_l_;
if (!keyreq_l_ &&
(!time_l->whole_in_measure_|| !time_l->when_)) {
#include ".build"
;
-const char *
+char const *
lily_version_sz()
{
static char v[1024];
bool
-Spacing_problem::contains(const PCol *w)
+Spacing_problem::contains(PCol const *w)
{
for (int i=0; i< cols.size(); i++)
if (cols[i].pcol_ == w)
}
int
-Spacing_problem::col_id(const PCol *w)const
+Spacing_problem::col_id(PCol const *w)const
{
for (int i=0; i< cols.size(); i++)
if (cols[i].pcol_ == w)
add one column to the problem.
*/
void
-Spacing_problem::add_column(const PCol *col, bool fixed, Real fixpos)
+Spacing_problem::add_column(PCol const *col, bool fixed, Real fixpos)
{
Colinfo c(col,(fixed)? &fixpos : 0);
cols.push(c);
}
void
-Spacing_problem::add_ideal(const Idealspacing *i)
+Spacing_problem::add_ideal(Idealspacing const *i)
{
- const PCol *l =i->left;
- const PCol *r= i->right;
+ PCol const *l =i->left;
+ PCol const *r= i->right;
if (!contains(l) || !contains(r)) {
return;
}
void
-Spacing_problem::print_ideal(const Idealspacing*id)const
+Spacing_problem::print_ideal(Idealspacing const *id)const
{
#ifndef NPRINT
int l = col_id(id->left);
width = c.width;
}
-Colinfo::Colinfo(const PCol*col_p, const Real*fixed_r_p )
+Colinfo::Colinfo(PCol const *col_p, Real const *fixed_r_p )
{
fixpos = (fixed_r_p)? new Real(*fixed_r_p) : 0;
pcol_ = col_p;
void
Local_key_register::acknowledge_element(Staff_elem_info info)
{
- if (info.req_l_->melodic()) {
- Melodic_req * melodic_l_ = info.req_l_->melodic();
+ if (info.req_l_->note()) {
+ Note_req * note_l_ = info.req_l_->note();
- if( melodic_l_->forceacc_b_ ||
- local_key_.oct(melodic_l_->octave_i_).acc(melodic_l_->notename_i_)
- != melodic_l_->accidental_i_) {
+ if( note_l_->forceacc_b_ ||
+ local_key_.oct(note_l_->octave_i_).acc(note_l_->notename_i_)
+ != note_l_->accidental_i_) {
Item * support_l_ = info.elem_p_->item();
key_item_p_ = new Local_key_item(*get_staff_info().c0_position_i_);
}
- key_item_p_->add(melodic_l_);
+ key_item_p_->add(note_l_);
key_item_p_->add(support_l_);
- local_key_.oct(melodic_l_->octave_i_)
- .set(melodic_l_->notename_i_, melodic_l_->accidental_i_);
+ local_key_.oct(note_l_->octave_i_)
+ .set(note_l_->notename_i_, note_l_->accidental_i_);
}
} else if (info.elem_p_->name()==Key_item::static_name()) {
Key_register * key_reg_l =
void
Local_key_register::process_requests()
{
- const Time_description * time_c_l_ = get_staff_info().time_c_l_;
+ Time_description const * time_c_l_ = get_staff_info().time_c_l_;
if (! time_c_l_->whole_in_measure_){
if (key_c_l_)
local_key_.reset(*key_c_l_);
}
void
-Molecule::add(const Molecule &m)
+Molecule::add(Molecule const &m)
{
for (iter_top(m.ats,c); c.ok(); c++) {
add(**c);
}
void
-Molecule::add_right(const Molecule &m)
+Molecule::add_right(Molecule const &m)
{
if (!ats.size()) {
add(m);
}
void
-Molecule::add_left(const Molecule &m)
+Molecule::add_left(Molecule const &m)
{
if (!ats.size()) {
add(m);
void
-Molecule::add_top(const Molecule &m)
+Molecule::add_top(Molecule const &m)
{
if (!ats.size()) {
add(m);
}
void
-Molecule::add_bottom(const Molecule &m)
+Molecule::add_bottom(Molecule const &m)
{
if (!ats.size()) {
add(m);
}
void
-Molecule::operator = (const Molecule&)
+Molecule::operator = (Molecule const &)
{
assert(false);
}
-Molecule::Molecule(const Molecule&s)
+Molecule::Molecule(Molecule const &s)
{
add(s);
}
}
int
-PCol::compare(const PCol &c1, const PCol &c2)
+PCol::compare(PCol const &c1, PCol const &c2)
{
PScore*ps_l = c1.pscore_l_;
PCursor<PCol*> ac(ps_l->find_col(&c1));
assert(ps && pc);
for (iter_top(pc->its,i); i.ok(); i++){
if (i->pstaff_l_ == ps)
- ret.push((Item*)(const Item*)i);
+ ret.push((Item*)(Item const *)i);
}
return ret;
}
}
PCursor<PCol *>
-PScore::find_col(const PCol *c)const
+PScore::find_col(PCol const *c)const
{
- const PCol*what = c;
+ PCol const *what = c;
if (what->daddy_l_ )
what = what->daddy_l_;
mtor << "}\n";
#endif
}
-const Lookup*
+Lookup const *
Paper_def::lookup_l()
{
return lookup_p_;
stem_p_ = 0;
}
if (beam_p_ && end_beam_b_) {
- const Rhythmic_grouping * rg_c_l = get_staff_info().rhythmic_c_l_;
+ Rhythmic_grouping const * rg_c_l = get_staff_info().rhythmic_c_l_;
rg_c_l->extend(current_grouping->interval());
beam_p_->set_grouping(*rg_c_l, *current_grouping);
typeset_element(beam_p_);
Tex_stream::operator<<(String s)
{
- for (const char *cp = s; *cp; cp++) {
+ for (char const *cp = s; *cp; cp++) {
if (outputting_comment) {
*os << *cp;
if (*cp == '\n') {
defined_ch_c_l_ = 0;
}
bool
-Text_def::compare(const Text_def&def)
+Text_def::compare(Text_def const &def)
{
return align_i_ == def.align_i_ && text_str_ == def.text_str_
&& style_str_ == def.style_str_;
#include "string.hh"
-extern const char* lily_version_sz();
+extern char const * lily_version_sz();
String
get_version_str()