From 4d07e087ecd4173441dd5d3ba8b4731d82ee08a5 Mon Sep 17 00:00:00 2001 From: fred Date: Sun, 24 Mar 2002 19:37:39 +0000 Subject: [PATCH] lilypond-0.0.46.jcn1 --- lily/bar-reg.cc | 3 +- lily/beam.cc | 6 +- lily/clef-reg.cc | 5 +- lily/command-request.cc | 6 ++ lily/complex-staff.cc | 19 +------ lily/complex-walker.cc | 17 ++---- lily/crescendo.cc | 24 ++++++-- lily/debug.cc | 3 +- lily/dynamic-reg.cc | 73 ++++++++++++++++++++---- lily/global-regs.cc | 47 ++++++++++++++++ lily/grouping.cc | 2 +- lily/headreg.cc | 3 +- lily/identifier.cc | 32 +++++++---- lily/input-music.cc | 2 +- lily/input-register.cc | 76 +++++++++++++++++++++++++ lily/input-score.cc | 5 +- lily/input-staff.cc | 30 ++++------ lily/input.cc | 85 ++++++++++++++++++++++++++++ lily/key-reg.cc | 5 +- lily/local-key-reg.cc | 5 +- lily/lyric-item.cc | 2 +- lily/lyric-register.cc | 55 ++++++++++++++++++ lily/main.cc | 42 +++++++------- lily/meter-reg.cc | 1 + lily/midi-output.cc | 5 +- lily/midi-walker.cc | 2 +- lily/musical-request.cc | 8 +-- lily/my-lily-lexer.cc | 7 ++- lily/my-lily-parser.cc | 35 ++++++++---- lily/p-col.cc | 22 ++++---- lily/p-score.cc | 6 +- lily/register-group.cc | 11 +++- lily/register.cc | 6 +- lily/score.cc | 7 +-- lily/scores.cc | 3 +- lily/script-reg.cc | 1 + lily/slur-reg.cc | 7 ++- lily/slur.cc | 8 +-- lily/spanner.cc | 17 +++--- lily/staff-column.cc | 3 + lily/staff-elem-info.cc | 2 + lily/staff-elem.cc | 46 +++++++-------- lily/staff-info.cc | 62 ++++++++++++++++++++ lily/staff-regs.cc | 118 +++++++++++++++++++++++++++++++++++++++ lily/staff-sym-reg.cc | 53 ++++++++++++++++++ lily/staff-sym.cc | 48 ++++++++++++++++ lily/staff-walker.cc | 8 ++- lily/staff.cc | 7 +-- lily/staffline.cc | 8 ++- lily/stem-beam-reg.cc | 7 ++- lily/stem.cc | 4 +- lily/swallow-reg.cc | 23 ++++++++ lily/text-def.cc | 1 - lily/text-reg.cc | 1 + lily/text-spanner.cc | 6 +- lily/time-description.cc | 6 +- lily/voice-element.cc | 105 ++++++++++++++++++++++++++++++++++ lily/voice-group-regs.cc | 53 +++++++----------- lily/voice-regs.cc | 22 +++++--- lily/voice.cc | 2 +- lily/walk-regs.cc | 82 +++------------------------ lily/warn.cc | 32 ++++++++--- mi2mu/midi-track.cc | 2 +- 63 files changed, 1049 insertions(+), 345 deletions(-) create mode 100644 lily/global-regs.cc create mode 100644 lily/input-register.cc create mode 100644 lily/input.cc create mode 100644 lily/lyric-register.cc create mode 100644 lily/staff-info.cc create mode 100644 lily/staff-regs.cc create mode 100644 lily/staff-sym-reg.cc create mode 100644 lily/staff-sym.cc create mode 100644 lily/swallow-reg.cc create mode 100644 lily/voice-element.cc diff --git a/lily/bar-reg.cc b/lily/bar-reg.cc index 93334497cf..8450b6bf7e 100644 --- a/lily/bar-reg.cc +++ b/lily/bar-reg.cc @@ -9,7 +9,7 @@ #include "bar-reg.hh" #include "bar.hh" #include "command-request.hh" -#include "score-column.hh" +//#include "score-column.hh" #include "time-description.hh" Bar_register::Bar_register() @@ -83,5 +83,6 @@ Bar_register::post_move_processing() } IMPLEMENT_STATIC_NAME(Bar_register); +ADD_THIS_REGISTER(Bar_register); diff --git a/lily/beam.cc b/lily/beam.cc index c4d62b54d2..a20e859e23 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -180,8 +180,8 @@ Beam::do_break_at( PCol *, PCol *) const void Beam::do_pre_processing() { - left = (*stems.top()) ->pcol_l_; - right = (*stems.bottom())->pcol_l_; + left_col_l_ = (*stems.top()) ->pcol_l_; + right_col_l_ = (*stems.bottom())->pcol_l_; assert(stems.size()>1); if (!dir_i_) set_default_dir(); @@ -278,7 +278,7 @@ Beam::brew_molecule_p() const return out; sb.translate(Offset(x, (x * slope + left_pos)* inter)); out->add(sb); } - out->translate(Offset(x0 - left->hpos,0)); + out->translate(Offset(x0 - left_col_l_->hpos,0)); } IMPLEMENT_STATIC_NAME(Beam); diff --git a/lily/clef-reg.cc b/lily/clef-reg.cc index 403dabb250..f0bff0374c 100644 --- a/lily/clef-reg.cc +++ b/lily/clef-reg.cc @@ -36,7 +36,7 @@ Clef_register::set_type(String s) c0_position_i_= 10; }else return false; - *get_staff_info().c0_position_i_ = c0_position_i_; + *get_staff_info().c0_position_i_l_ = c0_position_i_; return true; } @@ -45,7 +45,7 @@ void Clef_register::read_req(Clef_change_req*c_l) { if (!set_type(c_l->clef_str_)) - error("unknown clef type ", c_l->defined_ch_C_); + c_l->error("unknown clef type "); } bool @@ -106,3 +106,4 @@ Clef_register::post_move_processing() } } IMPLEMENT_STATIC_NAME(Clef_register); +ADD_THIS_REGISTER(Clef_register); diff --git a/lily/command-request.cc b/lily/command-request.cc index 7d95dd980d..dfa448f41f 100644 --- a/lily/command-request.cc +++ b/lily/command-request.cc @@ -72,7 +72,9 @@ IMPLEMENT_STATIC_NAME(Clef_change_req); void Clef_change_req::do_print() const { +#ifndef NPRINT mtor << clef_str_ ; +#endif } Clef_change_req::Clef_change_req(String s) @@ -85,7 +87,9 @@ IMPLEMENT_STATIC_NAME(Group_feature_req); void Group_feature_req::do_print() const { +#ifndef NPRINT mtor << "stemdir " << stemdir_i_; +#endif } Group_feature_req::Group_feature_req() @@ -98,7 +102,9 @@ IMPLEMENT_STATIC_NAME(Group_change_req); void Group_change_req::do_print()const { +#ifndef NPRINT mtor << "id : " << newgroup_str_; +#endif } /* *************** */ IMPLEMENT_STATIC_NAME(Terminate_voice_req); diff --git a/lily/complex-staff.cc b/lily/complex-staff.cc index 661d8332ed..57d2fc0861 100644 --- a/lily/complex-staff.cc +++ b/lily/complex-staff.cc @@ -1,13 +1,8 @@ #include "complex-staff.hh" #include "complex-walker.hh" -#include "score.hh" #include "p-score.hh" -#include "staffsym.hh" -#include "score-column.hh" -const NO_LINES = 5; - -/** Aside from putting fields right, this generates the staff symbol. +/** Aside from putting fields right */ void Complex_staff::set_output(PScore* pscore_l ) @@ -15,18 +10,6 @@ Complex_staff::set_output(PScore* pscore_l ) pstaff_l_ = new PStaff(pscore_l); pscore_l_ = pscore_l; pscore_l_->add(pstaff_l_); - - Staff_symbol *span_p = new Staff_symbol(NO_LINES); - - Score_column* col_last - =score_l_->find_col(score_l_->last(), false); - Score_column* col_first= - score_l_->find_col(0, false); - - span_p->set_extent(col_first->pcol_l_->postbreak_p_, - col_last->pcol_l_->prebreak_p_); - - pscore_l_->typeset_spanner(span_p, pstaff_l_); } diff --git a/lily/complex-walker.cc b/lily/complex-walker.cc index 09773b1503..ba7be37cd1 100644 --- a/lily/complex-walker.cc +++ b/lily/complex-walker.cc @@ -5,18 +5,12 @@ (c) 1997 Han-Wen Nienhuys */ - -#include "musical-request.hh" #include "staff-column.hh" #include "voice.hh" #include "p-score.hh" #include "complex-staff.hh" #include "debug.hh" -#include "voice-group-regs.hh" -#include "voice-regs.hh" #include "complex-walker.hh" -//#include "misc.hh" -#include "command-request.hh" #include "walk-regs.hh" void @@ -37,16 +31,15 @@ Complex_walker::do_announces() walk_regs_p_->do_announces(); } -bool -Complex_walker::try_command_request(Command_req *req_l) -{ - return walk_regs_p_->try_request(req_l); -} void Complex_walker::try_request(Request*req) { - walk_regs_p_->try_request(req); + bool b =walk_regs_p_->try_request(req); + if (!b) + + req->warning("junking request: " + String(req->name())); + } void diff --git a/lily/crescendo.cc b/lily/crescendo.cc index 29aa3ab841..163e3be737 100644 --- a/lily/crescendo.cc +++ b/lily/crescendo.cc @@ -5,16 +5,17 @@ (c) 1997 Han-Wen Nienhuys */ - +#include "dimen.hh" #include "crescendo.hh" #include "lookup.hh" #include "paper-def.hh" - +#include "debug.hh" Crescendo::Crescendo(int s) { staff_size_i_ = s; grow_dir_i_ =0; dir_i_ = -1 ; + left_dyn_b_ = right_dyn_b_ =false; } Spanner* @@ -27,9 +28,24 @@ Crescendo::do_break_at(PCol*, PCol*)const Molecule* Crescendo::brew_molecule_p() const return m_p ; { + Real x_off_dim=0.0; + Real absdyn_dim = 10 PT; // UGR + m_p = new Molecule; - Real w_f = width().length(); - Symbol s( paper()->lookup_l()->hairpin(w_f, grow_dir_i_ < 0) ); + Real w_dim = width().length(); + if ( left_dyn_b_ ) { + w_dim -= absdyn_dim; + x_off_dim += absdyn_dim; + } + if ( right_dyn_b_ ) { + w_dim -= absdyn_dim; + } + + if (w_dim < 0) { + error("Crescendo too small"); + w_dim = 0; + } + Symbol s( paper()->lookup_l()->hairpin(w_dim, grow_dir_i_ < 0) ); m_p->add(Atom(s)); int pos = (dir_i_ >0) ? staff_size_i_ + 4 : - 4 ; m_p->translate(Offset(0,pos * paper()->internote())); diff --git a/lily/debug.cc b/lily/debug.cc index 67bcd70681..a2bce7c8ce 100644 --- a/lily/debug.cc +++ b/lily/debug.cc @@ -55,6 +55,7 @@ void set_debug(bool b) { check_debug =b; -} + set_flower_debug(*monitor, check_debug); + } diff --git a/lily/dynamic-reg.cc b/lily/dynamic-reg.cc index 5f137035fa..e0e38a7a59 100644 --- a/lily/dynamic-reg.cc +++ b/lily/dynamic-reg.cc @@ -5,24 +5,28 @@ (c) 1997 Han-Wen Nienhuys */ - +#include "debug.hh" +#include "crescendo.hh" #include "dynamic-reg.hh" #include "musical-request.hh" #include "text-item.hh" #include "lookup.hh" #include "paper-def.hh" +#include "score-column.hh" Dynamic_register::Dynamic_register() { dir_i_ =0; post_move_processing(); dynamic_p_ =0; + to_end_cresc_p_ = cresc_p_ = 0; + cresc_req_l_ = 0; } void Dynamic_register::post_move_processing() { - dynamic_req_l_ = 0; + dynamic_req_l_arr_.set_size(0); } bool @@ -31,27 +35,54 @@ Dynamic_register::try_request(Request * r) Musical_req * m = r->musical(); if (!m || !m->dynamic()) return false; - assert(!dynamic_req_l_); - dynamic_req_l_ = m->dynamic(); + dynamic_req_l_arr_.push(m->dynamic()); return true; } void Dynamic_register::process_requests() { - if(dynamic_req_l_){ - if (dynamic_req_l_->absdynamic()) { + Crescendo* new_cresc_p=0; + for (int i=0; i < dynamic_req_l_arr_.size(); i++) { + Dynamic_req *dreq_l = dynamic_req_l_arr_[i]; + if (dreq_l->absdynamic()) { Text_def * td_p = new Text_def; td_p->align_i_ = 0; String loud =Dynamic_req::loudness_str( - dynamic_req_l_->absdynamic()->loudness_); + dreq_l->absdynamic()->loudness_); td_p->text_str_ = paper()->lookup_l()->dynamic(loud).tex; - - td_p->style_str_ = "dynamic"; - + + assert (!dynamic_p_) ; // TODO + dynamic_p_ = new Text_item(td_p, 10 ); // TODO! - announce_element(Staff_elem_info(dynamic_p_, dynamic_req_l_)); + announce_element(Staff_elem_info(dynamic_p_, dreq_l)); + } else if (dreq_l->span_dynamic()) { + + Span_dynamic_req* span_l = dreq_l->span_dynamic(); + if (span_l->spantype == Span_req::STOP) { + if (!cresc_p_) { + span_l->warning("Can't find cresc to end " ); + } else { + assert(!to_end_cresc_p_); + to_end_cresc_p_ =cresc_p_; + cresc_p_ = 0; + } + } else if (span_l->spantype == Span_req::START) { + cresc_req_l_ = span_l; + assert(!new_cresc_p); + new_cresc_p = new Crescendo(10); + new_cresc_p->grow_dir_i_ = span_l->dynamic_dir_i_; + announce_element(Staff_elem_info(new_cresc_p, span_l)); + } + } + } + + if ( new_cresc_p ) { + cresc_p_ = new_cresc_p; + cresc_p_->left_col_l_ = get_staff_info().musical_l()->pcol_l_; + if (dynamic_p_) { + cresc_p_->left_dyn_b_ = true; } } } @@ -63,6 +94,15 @@ Dynamic_register::pre_move_processing() typeset_element(dynamic_p_); dynamic_p_ = 0; } + if ( to_end_cresc_p_) { + if (dynamic_p_) + to_end_cresc_p_->right_dyn_b_=true; + + to_end_cresc_p_->right_col_l_ = get_staff_info().musical_l()->pcol_l_; + + typeset_element(to_end_cresc_p_); + to_end_cresc_p_ = 0; + } } bool @@ -79,3 +119,14 @@ Dynamic_register::set_feature(Features i) } IMPLEMENT_STATIC_NAME(Dynamic_register); +ADD_THIS_REGISTER(Dynamic_register); + +Dynamic_register::~Dynamic_register() +{ + delete dynamic_p_; + delete to_end_cresc_p_; + if (cresc_p_) { + cresc_req_l_->warning("unended crescendo"); + } + delete cresc_p_; +} diff --git a/lily/global-regs.cc b/lily/global-regs.cc new file mode 100644 index 0000000000..207cc16c55 --- /dev/null +++ b/lily/global-regs.cc @@ -0,0 +1,47 @@ +/* + global-regs.cc -- implement + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + +#include "input-register.hh" +#include "debug.hh" +#include "register.hh" + +struct Request_register_table_entry { + String name_str_; + Reg_ctor ctor_l_; + Request_register_table_entry(String s, Reg_ctor f) { + name_str_ =s; + ctor_l_ = f; + } + Request_register_table_entry() + { + ctor_l_ =0; + } +}; + +static Array *reg_table=0; + +void +add_request_register(String s, Reg_ctor f) +{ + if (!reg_table) + reg_table = new Array; + + reg_table->push(Request_register_table_entry(s, f)); +} + + +Request_register* +get_nongroup_register_p(String s) +{ + for (int i=0; i < reg_table->size(); i++) { + if ((*reg_table)[i].name_str_ == s) + return (*(*reg_table)[i].ctor_l_)(); + } + error("Unknown register `" + s +"\'"); + return 0; +} diff --git a/lily/grouping.cc b/lily/grouping.cc index bc665a19c0..2e59f05bd2 100644 --- a/lily/grouping.cc +++ b/lily/grouping.cc @@ -93,7 +93,7 @@ Rhythmic_grouping::intersect(MInterval t) for (int i=0; i < children.size(); i++) { MInterval inter = intersection(t, children[i]->interval()); - if (inter.empty() || inter.length() <= Rational( 0 )) { + if (inter.empty_b() || inter.length() <= Rational( 0 )) { delete children[i]; children[i] =0; } else { diff --git a/lily/headreg.cc b/lily/headreg.cc index 61232d25b8..318ed3a607 100644 --- a/lily/headreg.cc +++ b/lily/headreg.cc @@ -46,7 +46,7 @@ Notehead_register::process_requests() note_p_ = n_p; n_p->set_rhythmic(note_req_l_->rhythmic()); n_p->position = note_req_l_->note()->height() + - *get_staff_info().c0_position_i_; + *get_staff_info().c0_position_i_l_; } else { note_p_ = new Rest ( note_req_l_->rhythmic()->duration_); if (note_req_l_->rhythmic()->duration_.type_i_ <= 2) @@ -75,3 +75,4 @@ Notehead_register::post_move_processing() } IMPLEMENT_STATIC_NAME(Notehead_register); +ADD_THIS_REGISTER(Notehead_register); diff --git a/lily/identifier.cc b/lily/identifier.cc index 0eab514cb5..8b989f9868 100644 --- a/lily/identifier.cc +++ b/lily/identifier.cc @@ -11,7 +11,7 @@ #include "identifier.hh" #include "my-lily-lexer.hh" #include "debug.hh" - +#include "input-register.hh" #include "input-score.hh" #include "symtable.hh" #include "input-staff.hh" @@ -19,6 +19,7 @@ #include "lookup.hh" #include "script-def.hh" #include "request.hh" +#include "input-register.hh" void Identifier::error(String expect) @@ -29,13 +30,12 @@ Identifier::error(String expect) } Identifier::Identifier(String n, int code) - : name(n) + : name(n) { token_code_i_ = code; data = 0; accessed_b_ = 0; init_b_ = 0; - defined_ch_C_ = 0; } void @@ -61,6 +61,8 @@ DEFAULT_PRINT(M_chord_id, Music_general_chord, mchord); DEFAULT_PRINT(M_voice_id, Music_voice, mvoice); DEFAULT_PRINT(Request_id, Request, request); DEFAULT_PRINT(Score_id, Input_score, score); +DEFAULT_PRINT(Input_regs_id, Input_register, iregs); + void Real_id::do_print() const { @@ -85,12 +87,18 @@ Idclass::~Idclass() { delete accessor(false); }\ Idclass::Idclass(String s, Class*st, int code):Identifier(s,code) { data = st; }\ -implement_id_class(Real_id, Real, real) -implement_id_class(Script_id, Script_def, script) -implement_id_class(Lookup_id, Lookup, lookup) -implement_id_class(Symtables_id, Symtables, symtables) -implement_id_class(Staff_id, Input_staff, staff) -implement_id_class(M_chord_id, Music_general_chord, mchord) -implement_id_class(M_voice_id, Music_voice, mvoice) -implement_id_class(Score_id, Input_score, score) -implement_id_class(Request_id, Request, request) +implement_id_class(Real_id, Real, real); +implement_id_class(Script_id, Script_def, script); +implement_id_class(Lookup_id, Lookup, lookup); +implement_id_class(Symtables_id, Symtables, symtables); +implement_id_class(Staff_id, Input_staff, staff); +implement_id_class(M_chord_id, Music_general_chord, mchord); +implement_id_class(M_voice_id, Music_voice, mvoice); +implement_id_class(Score_id, Input_score, score); +implement_id_class(Request_id, Request, request); +implement_id_class(Input_regs_id, Input_register, iregs); + +Identifier::Identifier(Identifier const&) +{ + assert(false); +} diff --git a/lily/input-music.cc b/lily/input-music.cc index e407c87dd5..9ba6838179 100644 --- a/lily/input-music.cc +++ b/lily/input-music.cc @@ -12,7 +12,7 @@ Input_music::check_plet(Voice_element* velt_l) if ( i->plet() ) { Moment start_moment = 0; if ( !find_plet_start_b( i->plet()->type_c_, start_moment ) ) { - error( "begin of plet not found", i->defined_ch_C_ ); + i ->error( "begin of plet not found"); break; } Moment moment = 0; diff --git a/lily/input-register.cc b/lily/input-register.cc new file mode 100644 index 0000000000..e038b18dd2 --- /dev/null +++ b/lily/input-register.cc @@ -0,0 +1,76 @@ +/* + input-register.cc -- implement Input_register + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ +#include "debug.hh" +#include "register.hh" +#include "input-register.hh" +Input_register::~Input_register() +{} + +Input_register::Input_register() +{ +} + +bool +Input_register::group_b()const +{ + return ireg_list_.size(); +} + +Array +Input_register::get_nongroups_str_arr()const +{ + Array s_arr; + for (iter_top(ireg_list_, i); i.ok(); i++) { + if (!i->group_b()) + s_arr.push(i->name_str_); + } + return s_arr; +} + +Input_register* +Input_register::get_ireg_l(String nm)const +{ + for (iter_top(ireg_list_, i); i.ok(); i++) { + if (i->name_str_ == nm) + return i; + } + return 0; +} +Array +Input_register::get_nongroup_p_arr() const return a; +{ + Array sa(get_nongroups_str_arr()); + for (int i=0; i < sa.size(); i++) + a.push(get_nongroup_register_p(sa[i])); +} + +void +Input_register::add(Input_register *p) +{ + ireg_list_.bottom().add(p); +} + +void +Input_register::print() const +{ +#ifndef NPRINT + mtor << name_str_ << " { "; + for (iter_top(ireg_list_, i); i.ok(); i++) + i->print(); + mtor <<" }\n"; +#endif +} + + +Input_register::Input_register(Input_register const&s) + : Input(s) +{ + name_str_ = s.name_str_; + for (iter_top(s.ireg_list_, i); i.ok(); i++) + add(new Input_register(*i.ptr())); +} diff --git a/lily/input-score.cc b/lily/input-score.cc index ed7d831eea..a2dacc048e 100644 --- a/lily/input-score.cc +++ b/lily/input-score.cc @@ -37,10 +37,10 @@ Input_score::set(Midi_def* midi_p) } Input_score::Input_score(Input_score const&s) + : Input(s) { paper_p_ = (s.paper_p_)? new Paper_def(*s.paper_p_) :0; midi_p_ = (s.midi_p_)? new Midi_def(*s.midi_p_) : 0; - defined_ch_C_ = s.defined_ch_C_; errorlevel_i_ = s.errorlevel_i_; } @@ -48,7 +48,7 @@ Score* Input_score::parse() { Score *s_p = new Score; - s_p->defined_ch_C_= defined_ch_C_; + s_p->errorlevel_i_ = errorlevel_i_; if (midi_p_) s_p->set(new Midi_def(*midi_p_)); @@ -72,7 +72,6 @@ Input_score::~Input_score() Input_score::Input_score() { - defined_ch_C_=0; paper_p_= 0; midi_p_ = 0; errorlevel_i_ = 0; diff --git a/lily/input-staff.cc b/lily/input-staff.cc index 9262851f3c..618d98f012 100644 --- a/lily/input-staff.cc +++ b/lily/input-staff.cc @@ -12,15 +12,12 @@ #include "input-staff.hh" #include "staff.hh" #include "complex-staff.hh" -#include "lyric-staff.hh" - #include "my-lily-lexer.hh" +#include "input-register.hh" - -Input_staff::Input_staff(String s) +Input_staff::Input_staff() { - type= s; - defined_ch_C_ = 0; + ireg_p_ =0; } void @@ -32,18 +29,10 @@ Input_staff::add(Input_music*m) Staff* Input_staff::parse(Score*score_l) { - Staff *p=0; - if (type == "melodic") - p = new Complex_staff; - else if (type == "lyric") - p = new Lyric_staff; - else { - error( "Unknown staff-type `" + type +"\'", defined_ch_C_ ); - exit( 1 ); - } - + Staff *p=new Complex_staff; + p->score_l_ = score_l; - + p->ireg_p_ = (ireg_p_)? new Input_register(*ireg_p_):0; for (iter_top(music_,i); i.ok(); i++) { Voice_list vl = i->convert(); p->add(vl); @@ -52,11 +41,12 @@ Input_staff::parse(Score*score_l) } Input_staff::Input_staff(Input_staff const&s) + : Input(s) { for (iter_top(s.music_,i); i.ok(); i++) add(i->clone()); - defined_ch_C_ = s.defined_ch_C_; - type = s.type; + + ireg_p_ = (s.ireg_p_)? new Input_register(*s.ireg_p_):0; } void @@ -66,9 +56,11 @@ Input_staff::print() const mtor << "Input_staff {\n"; for (iter_top(music_,i); i.ok(); i++) i->print(); + ireg_p_->print(); mtor << "}\n"; #endif } Input_staff::~Input_staff() { + delete ireg_p_; } diff --git a/lily/input.cc b/lily/input.cc new file mode 100644 index 0000000000..1ff4e86244 --- /dev/null +++ b/lily/input.cc @@ -0,0 +1,85 @@ +/* + input.cc -- implement Input + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ +#include "proto.hh" +#include "input.hh" +#include "string.hh" +#include "source.hh" +#include "source-file.hh" + +Input::Input(Sources*s, char const *cl) +{ + sources_l_=s; + defined_ch_C_=cl; +} + +Input::Input() +{ + sources_l_ = 0; + defined_ch_C_ = 0; +} + +Input::Input(Input const &s) +{ + sources_l_ = s.sources_l_; + defined_ch_C_ = s.defined_ch_C_; +} + +void +Input::set_spot(Input const &i) +{ + *this = i; +} + +void +Input::message(String message_str)const +{ + String str = ""; + Source_file* sourcefile_l=0; + + if (sources_l_) + sourcefile_l = sources_l_->sourcefile_l( defined_ch_C_ ); + + if ( sourcefile_l ) { + str += sourcefile_l->file_line_no_str(defined_ch_C_) + String(": "); + } + + str += message_str; + if ( sourcefile_l ) { + str += ":\n"; + str += sourcefile_l->error_str( defined_ch_C_); + } + /* + if ( busy_parsing() ) + cerr << endl; + */ + cerr << str << endl; +} + +void +Input::warning( String message_str)const +{ + message( "warning: " + message_str); +} +void +Input::error(String s)const +{ + message("error: "+ s); + exit (1); +} + +String +Input::location_str()const +{ + Source_file * sourcefile_l=0; + if (sources_l_) + sourcefile_l = sources_l_->sourcefile_l (defined_ch_C_); + if (sourcefile_l) + return sourcefile_l->file_line_no_str(defined_ch_C_); + else + return "(location unknown)"; +} diff --git a/lily/key-reg.cc b/lily/key-reg.cc index 83fb84c0cd..ca98995b1c 100644 --- a/lily/key-reg.cc +++ b/lily/key-reg.cc @@ -39,7 +39,7 @@ Key_register::acknowledge_element(Staff_elem_info info) { Command_req * r_l = info.req_l_->command() ; if (r_l && r_l->clefchange() && !kit_p_) { - int c0_i= *get_staff_info().c0_position_i_; + int c0_i= *get_staff_info().c0_position_i_l_; kit_p_ = new Key_item(c0_i); kit_p_->read(*this); announce_element(Staff_elem_info(kit_p_, keyreq_l_)); @@ -57,7 +57,7 @@ Key_register::process_requests() } if ( default_key_b_ || keyreq_l_) { - int c0_i= *get_staff_info().c0_position_i_; + int c0_i= *get_staff_info().c0_position_i_l_; kit_p_ = new Key_item(c0_i); kit_p_->read(*this); announce_element(Staff_elem_info(kit_p_, keyreq_l_)); @@ -98,3 +98,4 @@ Key_register::post_move_processing() kit_p_ = 0; } IMPLEMENT_STATIC_NAME(Key_register); +ADD_THIS_REGISTER(Key_register); diff --git a/lily/local-key-reg.cc b/lily/local-key-reg.cc index ea7e66b7d7..876a0ecf01 100644 --- a/lily/local-key-reg.cc +++ b/lily/local-key-reg.cc @@ -40,7 +40,7 @@ Local_key_register::acknowledge_element(Staff_elem_info info) if (!key_item_p_) { - key_item_p_ = new Local_key_item(*get_staff_info().c0_position_i_); + key_item_p_ = new Local_key_item(*get_staff_info().c0_position_i_l_); } key_item_p_->add(note_l_); @@ -64,7 +64,8 @@ Local_key_register::process_requests() if (key_C_) local_key_.reset(*key_C_); else if( time_C_->when_ >Moment(0)) - warning ("Help me! can't figure current key", 0); + warning ("Help me! can't figure current key", (const char*)0); } } IMPLEMENT_STATIC_NAME(Local_key_register); +ADD_THIS_REGISTER(Local_key_register); diff --git a/lily/lyric-item.cc b/lily/lyric-item.cc index 1a54f12bca..8bca62e9c9 100644 --- a/lily/lyric-item.cc +++ b/lily/lyric-item.cc @@ -22,5 +22,5 @@ Lyric_item::do_pre_processing() // test context-error if ( tdef_l()->text_str_.index_i( "Gates" ) >=0)// :-) - warning( "foul word", tdef_l()->defined_ch_C_ ); + tdef_l()->warning( "foul word"); } diff --git a/lily/lyric-register.cc b/lily/lyric-register.cc new file mode 100644 index 0000000000..73f0def7b0 --- /dev/null +++ b/lily/lyric-register.cc @@ -0,0 +1,55 @@ +/* + lyric-register.cc -- implement Lyric_register + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + +#include "staff-walker.hh" +#include "lyric-register.hh" +#include "lyric-item.hh" +#include "musical-request.hh" + +Lyric_register::Lyric_register() +{ + +} + +bool +Lyric_register::try_request(Request*r) +{ + Musical_req * m =r->musical(); + if (!m || ! m->lreq_l()) + return false; + lreq_arr_.push(m->lreq_l()); + + return true; +} + +void +Lyric_register::process_requests() +{ + for (int i=0; i < lreq_arr_.size(); i++) { + Item *lp = new Lyric_item(lreq_arr_[i],i); + typeset_element(lp); + } + get_staff_info().walk_l_->allow_break(); +} + +void +Lyric_register::post_move_processing() +{ + lreq_arr_.set_size(0); +} + + +bool +Lyric_register::acceptable_request_b(Request*r) +{ + Musical_req * m =r->musical(); + return (!m || ! m->lreq_l()) ; +} + +IMPLEMENT_STATIC_NAME(Lyric_register); +ADD_THIS_REGISTER(Lyric_register); diff --git a/lily/main.cc b/lily/main.cc index dd38e5cad5..1576773e86 100644 --- a/lily/main.cc +++ b/lily/main.cc @@ -21,7 +21,6 @@ Sources* source_l_g = 0; bool only_midi = false; -extern void parse_file(String,String); void @@ -96,33 +95,35 @@ notice() "USA.\n"; } -static File_path * path =0; -struct Main_init { - Main_init() { - path = new File_path(String(DIR_DATADIR)+"/init/"); - path->push(DIR_DATADIR ); - debug_init(); - } - ~Main_init() { - delete path; - } -} main_init; +static File_path * path_l =0; void do_one_file(String init_str, String file_str) { - source_l_g = new Sources; - source_l_g->set_path(path); - My_lily_parser parser(source_l_g); - parser.parse_file(init_str, file_str); + Sources sources; + source_l_g = &sources; + source_l_g->set_path(path_l); + { + My_lily_parser parser(source_l_g); + parser.parse_file(init_str, file_str); + } do_scores(); - delete source_l_g; source_l_g = 0; } int main (int argc, char **argv) { + debug_init(); // should be first + File_path path(String(DIR_DATADIR)+"/init/") ; + path_l = & path; + path_l->push(DIR_DATADIR ); + + char const * env_l=getenv("LILYINCLUDE"); + if (env_l) { + path.add(env_l); + } + Getopt_long oparser(argc, argv,theopts); cout << get_version_str() << endl; String init_str("symbol.ini"); @@ -137,7 +138,7 @@ main (int argc, char **argv) exit(0); break; case 'I': - path->push(oparser.optarg); + path.push(oparser.optarg); break; case 'i': init_str = oparser.optarg; @@ -172,11 +173,6 @@ main (int argc, char **argv) return 0; } -String -find_file(String f) -{ - return path->find(f); -} /// make input file name: add default extension. "" is stdin. void diff --git a/lily/meter-reg.cc b/lily/meter-reg.cc index 3c500e6042..c4ef7b9bb1 100644 --- a/lily/meter-reg.cc +++ b/lily/meter-reg.cc @@ -63,3 +63,4 @@ Meter_register::post_move_processing() meter_p_ =0; } IMPLEMENT_STATIC_NAME(Meter_register); +ADD_THIS_REGISTER(Meter_register); diff --git a/lily/midi-output.cc b/lily/midi-output.cc index 5992cf9505..c239e82af5 100644 --- a/lily/midi-output.cc +++ b/lily/midi-output.cc @@ -83,12 +83,15 @@ Midi_output::header() str += ",\n"; Midi_text generate( Midi_text::TEXT, str ); midi_track.add( Moment( 0 ), &generate ); + +#if 0 // TODO! Source_file* sourcefile_l = source_l_g->sourcefile_l( score_l_->defined_ch_C_ ); if ( sourcefile_l ) { - str = "from musical definition: " + str += "from musical definition: " + sourcefile_l->file_line_no_str(score_l_->defined_ch_C_); } +#endif Midi_text from( Midi_text::TEXT, str ); midi_track.add( Moment( 0 ), &from ); diff --git a/lily/midi-walker.cc b/lily/midi-walker.cc index ef1ea8382a..a024458349 100644 --- a/lily/midi-walker.cc +++ b/lily/midi-walker.cc @@ -82,7 +82,7 @@ Midi_walker::process_requests() Command_req *c_l = ptr()->commandreq_l_arr_[i]->command(); Meter_change_req* meter_l = c_l->meterchange(); if ( meter_l ) - output_event( Midi_time( meter_l->beats_i_, meter_l->one_beat_i_, 18 ), 0 ); + output_event( Midi_time( meter_l->beats_i_, meter_l->one_beat_i_, 18 ), 0 ); Key_change_req* key_l = c_l->keychange(); if ( key_l ) { int sharps_i = key_l->sharps_i(); diff --git a/lily/musical-request.cc b/lily/musical-request.cc index c7a848a18f..1ba4fd7801 100644 --- a/lily/musical-request.cc +++ b/lily/musical-request.cc @@ -65,12 +65,11 @@ Span_req::do_print() const Request::Request() { elt_l_ = 0; - defined_ch_C_ = 0; } Request::Request(Request const&src) + :Input(src) { elt_l_ = 0; - defined_ch_C_ = src.defined_ch_C_; } /* *************** */ Spacing_req::Spacing_req() @@ -115,8 +114,7 @@ Melodic_req::transpose(Melodic_req const & delta) } accidental_i_ += delta.accidental_i_; if (abs(accidental_i_) > 2) { - warning("transposition makes accidental larger than 2", - delta.defined_ch_C_); + delta.warning("transposition makes accidental larger than 2"); } } @@ -363,7 +361,7 @@ Request::voice_l() if (!elt_l_) return 0; else - return (Voice*)elt_l_->voice_l_; + return (Voice*)elt_l_->voice_C_; } /* *************** */ diff --git a/lily/my-lily-lexer.cc b/lily/my-lily-lexer.cc index 57909e8708..2bb88b7448 100644 --- a/lily/my-lily-lexer.cc +++ b/lily/my-lily-lexer.cc @@ -26,9 +26,11 @@ static Keyword_ent the_key_tab[]={ "clef", CLEF, "cm", CM_T, "duration", DURATIONCOMMAND, - "dynamic", DYNAMIC, + "absdynamic", ABSDYNAMIC, + "group", GROUP, "geometric", GEOMETRIC, "in", IN_T, + "inputregister", INPUT_REGS, "lyric", LYRIC, "key", KEY, "melodic" , MELODIC, @@ -51,6 +53,7 @@ static Keyword_ent the_key_tab[]={ "start", START_T, "stem", STEM, "table", TABLE, + "spandynamic", SPANDYNAMIC, "symboltables", SYMBOLTABLES, "tempo", TEMPO, "texid", TEXID, @@ -103,7 +106,7 @@ My_lily_lexer::~My_lily_lexer() mtor << "deleting: " << ai.key()<<'\n'; Identifier *i_p = ai.val(); if (!i_p->accessed_b_ && !i_p->init_b_) - warning("Variable not used", i_p->defined_ch_C_); + i_p->warning("Variable not used"); delete ai.val(); } diff --git a/lily/my-lily-parser.cc b/lily/my-lily-parser.cc index 9924a78a7e..0696d91912 100644 --- a/lily/my-lily-parser.cc +++ b/lily/my-lily-parser.cc @@ -1,5 +1,5 @@ /* - my-lily-parser.cc -- implement + my-lily-parser.cc -- implement My_lily_parser source file of the LilyPond music typesetter @@ -45,18 +45,20 @@ My_lily_parser::parse_file(String init, String s) lexer_p_ = new My_lily_lexer; set_debug(); + init_parse_b_ = true; lexer_p_->new_input(init, source_l_); do_yyparse(); print_declarations(); init_parse_b_ = false; + set_debug(); lexer_p_->new_input(s, source_l_); do_yyparse(); if(!define_spot_array_.empty()) - warning("Braces don't match.",0); + warning("Braces don't match."); } My_lily_parser::~My_lily_parser() @@ -67,7 +69,7 @@ My_lily_parser::~My_lily_parser() void My_lily_parser::remember_spot() { - define_spot_array_.push(here_ch_C()); + define_spot_array_.push(here_input()); } char const * @@ -109,7 +111,7 @@ My_lily_parser::get_word_element(Text_def* tdef_p, Duration * duration_p) Lyric_req* lreq_p = new Lyric_req(tdef_p); lreq_p->duration_ = *duration_p; - lreq_p->defined_ch_C_ = here_ch_C(); + lreq_p->set_spot( here_input()); velt_p->add(lreq_p); @@ -121,11 +123,11 @@ Voice_element * My_lily_parser::get_rest_element(String, Duration * duration_p ) { Voice_element* velt_p = new Voice_element; - velt_p->defined_ch_C_ = lexer_p_->here_ch_C(); + velt_p->set_spot( here_input()); Rest_req * rest_req_p = new Rest_req; rest_req_p->duration_ = *duration_p; - rest_req_p->defined_ch_C_ = here_ch_C(); + rest_req_p->set_spot( here_input()); velt_p->add(rest_req_p); delete duration_p; @@ -136,18 +138,18 @@ Voice_element * My_lily_parser::get_note_element(Note_req *rq, Duration * duration_p ) { Voice_element*v = new Voice_element; - v->defined_ch_C_ = here_ch_C(); + v->set_spot( here_input()); if (duration_p->type_i_ >= 2) { Stem_req * stem_req_p = new Stem_req(); stem_req_p->duration_ = *duration_p; - stem_req_p->defined_ch_C_ = here_ch_C(); + stem_req_p->set_spot( here_input()); v->add(stem_req_p); } rq->set_duration(*duration_p); - rq->defined_ch_C_ = here_ch_C(); + rq->set_spot( here_input()); v->add(rq); @@ -199,7 +201,7 @@ My_lily_parser::get_parens_request(char c) break; } - req_p->defined_ch_C_ = here_ch_C(); + req_p->set_spot( here_input()); return req_p; } @@ -212,7 +214,6 @@ My_lily_parser::My_lily_parser(Sources * source_l) textstyle_str_="roman"; // in lexer? error_level_i_ = 0; last_duration_mode = false; - defined_ch_C_ = 0; fatal_error_i_ = 0; } @@ -228,3 +229,15 @@ My_lily_parser::add_requests(Voice_element*v) } post_reqs.set_size(0); } + +Input +My_lily_parser::pop_spot() +{ + return define_spot_array_.pop(); +} + +Input +My_lily_parser::here_input()const +{ + return Input(source_l_, here_ch_C()); +} diff --git a/lily/p-col.cc b/lily/p-col.cc index 3ace8fba82..c47a4b2d27 100644 --- a/lily/p-col.cc +++ b/lily/p-col.cc @@ -1,3 +1,11 @@ +/* + p-col.cc -- implement PCol + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + #include "p-col.hh" #include "p-score.hh" #include "p-staff.hh" @@ -10,7 +18,7 @@ PCol::width() const for (iter_top(its,i); i.ok(); i++) w.unite(i->width()); - if (w.empty()) + if (w.empty_b()) w.unite(Interval(0,0)); return w; } @@ -18,15 +26,6 @@ PCol::width() const int PCol::rank() const { -#if 0 - if(!pscore_l_) - return -1; - PCursor me=pscore_l_->find_col( (PCol*)this); - if (!me.ok()) - return -1; - PCursor bot(pscore_l_->cols.top()); - return me - bot; -#endif assert(rank_i_ != -1); return rank_i_; } @@ -47,8 +46,7 @@ PCol::print() const #ifndef NPRINT mtor << "PCol {"; - if (rank() >= 0) - mtor << "rank: " << rank_i_ << '\n'; + mtor << "rank: " << rank_i_ << '\n'; mtor << "# symbols: " << its.size() ; if (breakable_b()){ diff --git a/lily/p-score.cc b/lily/p-score.cc index 800d3287cf..d31762e54a 100644 --- a/lily/p-score.cc +++ b/lily/p-score.cc @@ -220,10 +220,10 @@ PScore::find_col(PCol const *c)const void PScore::add_broken(Spanner*s) { - assert(s->left->line_l_ == s->right->line_l_); + assert(s->left_col_l_->line_l_ == s->right_col_l_->line_l_); broken_spans.bottom().add(s); - s->left->starters.bottom().add (s); - s->right->stoppers.bottom().add (s); + s->left_col_l_->starters.bottom().add (s); + s->right_col_l_->stoppers.bottom().add (s); } void diff --git a/lily/register-group.cc b/lily/register-group.cc index 0725d6c16b..18be472825 100644 --- a/lily/register-group.cc +++ b/lily/register-group.cc @@ -12,7 +12,7 @@ #include "register.hh" bool -Register_group_register::acceptable_request_b(Request* r) +Register_group_register::acceptable_request_b(Request* r)const { for (iter_top(reg_list_, i); i.ok(); i++) { if (i->acceptable_request_b(r)) @@ -65,7 +65,7 @@ Register_group_register::acknowledge_element(Staff_elem_info info) } bool -Register_group_register::contains_b(Request_register* reg_l) +Register_group_register::contains_b(Request_register* reg_l)const { bool parent_b = Request_register::contains_b(reg_l); @@ -93,6 +93,12 @@ Register_group_register::try_request(Request*req_l) } return false; } +void +Register_group_register::add(Array p_arr) +{ + for (int i =0; ioutfile); the_output << "% outputting Score, defined at: " << - source_l_g-> - sourcefile_l (defined_ch_C_)->file_line_no_str(defined_ch_C_) << "\n"; + input_.location_str() << "\n"; pscore_p_->output(the_output); + } void diff --git a/lily/scores.cc b/lily/scores.cc index 3115cb5007..22526b42bd 100644 --- a/lily/scores.cc +++ b/lily/scores.cc @@ -14,8 +14,7 @@ do_scores() for (int i=0; i < score_array_global.size(); i++) { Input_score* &is_p = score_array_global[i]; if (is_p->errorlevel_i_) { - warning("Score contains errors. Will not process it. ", - is_p->defined_ch_C_); + is_p->warning("Score contains errors. Will not process it. "); delete is_p; continue; } diff --git a/lily/script-reg.cc b/lily/script-reg.cc index b782066c31..cd7b081429 100644 --- a/lily/script-reg.cc +++ b/lily/script-reg.cc @@ -75,3 +75,4 @@ Script_register::set_feature(Features i) dir_i_ = i.direction_i_; } IMPLEMENT_STATIC_NAME(Script_register); +ADD_THIS_REGISTER(Script_register); diff --git a/lily/slur-reg.cc b/lily/slur-reg.cc index 935a86468c..8acf6a1fec 100644 --- a/lily/slur-reg.cc +++ b/lily/slur-reg.cc @@ -57,8 +57,8 @@ Slur_register::process_requests() // end slur: move the slur to other array if (slur_req_l->spantype == Span_req::STOP) { if (slur_l_stack_.empty()) - warning("can't find slur to end", - slur_req_l->defined_ch_C_); + + slur_req_l->warning("can't find slur to end"); else { end_slur_l_arr_.push(slur_l_stack_.pop()); requests_arr_.pop(); @@ -95,7 +95,8 @@ Slur_register::post_move_processing() Slur_register::~Slur_register() { for (int i=0; i < requests_arr_.size(); i++) { - warning("unterminated slur", requests_arr_[i]->defined_ch_C_); + requests_arr_[i]->warning("unterminated slur"); } } IMPLEMENT_STATIC_NAME(Slur_register); +ADD_THIS_REGISTER(Slur_register); diff --git a/lily/slur.cc b/lily/slur.cc index 8de13e023a..6e8e9e5f69 100644 --- a/lily/slur.cc +++ b/lily/slur.cc @@ -59,8 +59,8 @@ Slur::set_default_dir() void Slur::do_pre_processing() { - right = encompass.top()->pcol_l_; - left = encompass[0]->pcol_l_; + right_col_l_ = encompass.top()->pcol_l_; + left_col_l_ = encompass[0]->pcol_l_; } Spanner* @@ -74,9 +74,9 @@ Slur::do_break_at(PCol*l, PCol*r) const if (encompass[i]->pcol_l_->line_l_==l->line_l_) ret->encompass.push(encompass[i]); } - if (right != r) + if (right_col_l_ != r) ret->open_right = true; - if (left != l) + if (left_col_l_ != l) ret->open_left = true; diff --git a/lily/spanner.cc b/lily/spanner.cc index 87a01078aa..d2a8c2bc75 100644 --- a/lily/spanner.cc +++ b/lily/spanner.cc @@ -17,28 +17,29 @@ Spanner::broken_at(PCol*c1, PCol *c2)const { Spanner *span_p = do_break_at(c1,c2); - for (int i=0; i < dependants.size(); i++) { - dependants[i]->substitute_dependency((Staff_elem*)this, span_p); + for (int i=0; i < dependant_l_arr_.size(); i++) { + dependant_l_arr_[i]-> + substitute_dependency((Staff_elem*)this, span_p); } - span_p->left = c1; - span_p->right = c2; + span_p->left_col_l_ = c1; + span_p->right_col_l_ = c2; return span_p; } Spanner::Spanner() { - left = right = 0; + left_col_l_ = right_col_l_ = 0; } Interval Spanner::width()const { - Real r = right->hpos; - Real l = left->hpos; - assert(*left < *right); + Real r = right_col_l_->hpos; + Real l = left_col_l_->hpos; + assert(*left_col_l_ < *right_col_l_); assert(r>=l); return Interval(0, r-l); diff --git a/lily/staff-column.cc b/lily/staff-column.cc index baca3a0a98..96c837fb57 100644 --- a/lily/staff-column.cc +++ b/lily/staff-column.cc @@ -121,6 +121,9 @@ align_items(Array item_l_arr) Interval wid(0,0); for (int i =0; i < item_l_arr.size(); i++) { Interval item_width= item_l_arr[i]->width(); + if (item_width.empty_b()) { + item_width = Interval(0,0); + } Real dx =wid.right - item_width.left; item_width += dx; item_l_arr[i]->translate(Offset(dx ,0)); diff --git a/lily/staff-elem-info.cc b/lily/staff-elem-info.cc index 9a6283e373..1bb9db32d4 100644 --- a/lily/staff-elem-info.cc +++ b/lily/staff-elem-info.cc @@ -36,3 +36,5 @@ Features::dir(int d) return f; f.initialiser_b_ = true; f.direction_i_ = d; } + + diff --git a/lily/staff-elem.cc b/lily/staff-elem.cc index d623d3b49a..4db170e085 100644 --- a/lily/staff-elem.cc +++ b/lily/staff-elem.cc @@ -14,8 +14,8 @@ Staff_elem::TeXstring() const } Staff_elem::Staff_elem(Staff_elem const&s) - : dependants(s.dependants), - dependencies(s.dependencies) + :dependancy_l_arr_(s.dependancy_l_arr_), + dependant_l_arr_(s.dependant_l_arr_) { status = s.status; assert(!s.output); @@ -25,7 +25,7 @@ Staff_elem::Staff_elem(Staff_elem const&s) } /** TODO: - If deleted, then remove dependants depency! + If deleted, then remove dependant_l_arr_ depency! */ Staff_elem::~Staff_elem() { @@ -49,7 +49,7 @@ Staff_elem::width() const } else r = output->extent().x; - if (!r.empty()) // float exception on DEC Alpha + if (!r.empty_b()) // float exception on DEC Alpha r+=offset_.x; return r; @@ -66,7 +66,7 @@ Staff_elem::height() const } else r = output->extent().y; - if (!r.empty()) + if (!r.empty_b()) r+=offset_.y; @@ -121,9 +121,9 @@ Staff_elem::pre_processing() assert(status != PRECALCING); // cyclic dependency status = PRECALCING; - for (int i=0; i < dependencies.size(); i++) - if (dependencies[i]) - dependencies[i]->pre_processing(); + for (int i=0; i < dependancy_l_arr_.size(); i++) + if (dependancy_l_arr_[i]) + dependancy_l_arr_[i]->pre_processing(); do_pre_processing(); @@ -137,9 +137,9 @@ Staff_elem::post_processing() assert(status != POSTCALCING);// cyclic dependency status=POSTCALCING; - for (int i=0; i < dependencies.size(); i++) - if (dependencies[i]) - dependencies[i]->post_processing(); + for (int i=0; i < dependancy_l_arr_.size(); i++) + if (dependancy_l_arr_[i]) + dependancy_l_arr_[i]->post_processing(); do_post_processing(); status=POSTCALCED; } @@ -150,9 +150,9 @@ Staff_elem::molecule_processing() if (status >= OUTPUT) return; status = OUTPUT; // do it only once. - for (int i=0; i < dependencies.size(); i++) - if (dependencies[i]) - dependencies[i]->molecule_processing(); + for (int i=0; i < dependancy_l_arr_.size(); i++) + if (dependancy_l_arr_[i]) + dependancy_l_arr_[i]->molecule_processing(); output= brew_molecule_p(); } @@ -176,26 +176,26 @@ void Staff_elem::substitute_dependency(Staff_elem * old, Staff_elem * newdep) { bool hebbes_b=false; - for (int i=0; i < dependencies.size(); i++) { - if (dependencies[i] == old){ - dependencies[i] = newdep; + for (int i=0; i < dependancy_l_arr_.size(); i++) { + if (dependancy_l_arr_[i] == old){ + dependancy_l_arr_[i] = newdep; hebbes_b = true; - } else if (dependencies[i] == newdep) { + } else if (dependancy_l_arr_[i] == newdep) { hebbes_b = true; } } if (!hebbes_b) - dependencies.push(newdep); + dependancy_l_arr_.push(newdep); } void Staff_elem::add_dependency(Staff_elem * p) { - for (int i=0; i < dependencies.size(); i ++) - if (dependencies[i] == p) + for (int i=0; i < dependancy_l_arr_.size(); i ++) + if (dependancy_l_arr_[i] == p) return; - dependencies.push(p); - p->dependants.push(p); + dependancy_l_arr_.push(p); + p->dependant_l_arr_.push(p); } IMPLEMENT_STATIC_NAME(Staff_elem); diff --git a/lily/staff-info.cc b/lily/staff-info.cc new file mode 100644 index 0000000000..b6fb13d347 --- /dev/null +++ b/lily/staff-info.cc @@ -0,0 +1,62 @@ +/* + staff-info.cc -- implement Staff_info + + source file of the LilyPond music typesetter + (c) 1997 Han-Wen Nienhuys +*/ +#include "staff.hh" +#include "proto.hh" +#include "staff-info.hh" +#include "score-column.hh" +#include "complex-walker.hh" +#include "staff-column.hh" + +Staff* +Staff_info::staff_l() +{ + return walk_l_->staff_l_; +} + +Score* +Staff_info::score_l() +{ + return staff_l()->score_l_; +} +Staff_info::Staff_info() +{ + c0_position_i_l_ = 0; + walk_l_ = 0; + time_C_ = 0; + rhythmic_C_ =0; + break_allowed_b_ = 0; +} + +Staff_column* +Staff_info::column_l() +{ + return walk_l_->ptr(); +} + +Score_column* +Staff_info::musical_l() +{ + return column_l() -> musical_column_l_; +} + +Score_column* +Staff_info::command_l() +{ + return column_l() -> command_column_l_; +} +PCol* +Staff_info::command_pcol_l() +{ + return command_l()->pcol_l_; +} + +Moment +Staff_info::when() +{ + return walk_l_->when(); +} + diff --git a/lily/staff-regs.cc b/lily/staff-regs.cc new file mode 100644 index 0000000000..e22d32873c --- /dev/null +++ b/lily/staff-regs.cc @@ -0,0 +1,118 @@ +/* + staff-regs.cc -- implement Staff_registers + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ +#include "staff-sym.hh" +#include "voice-group-regs.hh" +#include "voice-regs.hh" +#include "staff-regs.hh" +#include "command-request.hh" +#include "bar.hh" +#include "debug.hh" +#include "input-register.hh" + +Staff_info +Staff_registers::get_staff_info() return inf; +{ + inf = Request_register::get_staff_info(); + inf.c0_position_i_l_ = &c0_position_i_; +} + +Staff_registers::Staff_registers(Input_register const*ireg_C) +{ + c0_position_i_ = 0; + base_position_i_ =0; + add( ireg_C->get_nongroup_p_arr()); + ireg_C_ =ireg_C; +} + +/** Magic function which takes a Voice_registers out of one of its own + children, and puts it in another. This also handles the push and + popgroup feature. */ +void +Staff_registers::change_group(Group_change_req * greq_l, + Voice_registers *voice_regs_l, + Voice_group_registers * old_group) +{ + + Voice_registers *regs_p = (old_group) + ? (Voice_registers*) old_group->get_register_p( + voice_regs_l) + : new Voice_registers( + greq_l->voice_l(), ireg_C_->get_ireg_l("Voice_group_registers") + ->get_ireg_l("Voice_registers")); + + String new_str = greq_l->newgroup_str_; + String old_str; + if (old_group) + old_str = old_group->group_id_str_; + if ( new_str[0] == '+') { + new_str = old_str + new_str; + } else if (new_str[0] == '-') { + int idx = old_str.index_last_i('+'); + if (idx >=0) + new_str = old_str.left_str ( idx ); + } + Voice_group_registers * new_group_l = get_group(new_str); + new_group_l->add(regs_p); + + mtor << "processed change_group " << get_staff_info().when()<<"\n"; + print(); +} + +Voice_group_registers * +Staff_registers::get_group(String id) +{ + for (int i=0; i < group_l_arr_.size(); i++) { + if (group_l_arr_[i]->group_id_str_ == id) + return group_l_arr_[i]; + } + Voice_group_registers *group_p = + new Voice_group_registers(id, ireg_C_->get_ireg_l("Voice_group_registers")); + group_l_arr_.push(group_p); + add(group_p); + return group_p; +} + + +void +Staff_registers::terminate_register(Request_register * reg) +{ + for (int i=0; i < group_l_arr_.size(); i++) { + if (group_l_arr_[i] == reg) { + group_l_arr_.del(i); + Register_group_register::terminate_register(reg); + return; + } + } + assert(false); +} + +bool +Staff_registers::try_request(Request * r) +{ + bool b = Register_group_register::try_request(r); + if (!b) { + Command_req * cr_l = r->command() ; + + if (cr_l && cr_l->groupchange()) { + change_group(cr_l->groupchange(), 0, 0); + b = true; + } else + b= false; + } + return b; +} + +IMPLEMENT_STATIC_NAME(Staff_registers); + +bool +Staff_registers::acceptable_request_b(Request*r)const +{ + return Register_group_register::acceptable_request_b(r) || + (r->command() && r->command()->groupchange()); +} + diff --git a/lily/staff-sym-reg.cc b/lily/staff-sym-reg.cc new file mode 100644 index 0000000000..34a53a552b --- /dev/null +++ b/lily/staff-sym-reg.cc @@ -0,0 +1,53 @@ +/* + staff-sym-reg.cc -- implement Staff_sym_register + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + +#include "staff-sym-reg.hh" +#include "staff-sym.hh" +#include "score.hh" +#include "p-col.hh" + +const NO_LINES = 5; + +Staff_sym_register::Staff_sym_register() +{ + span_p_ = 0; + last_mom_ =0; +} + +void +Staff_sym_register::post_move_processing() +{ + if (!span_p_ && !last_mom_) { + span_p_= new Staff_symbol(NO_LINES); + span_p_->left_col_l_ = + get_staff_info().command_pcol_l()->postbreak_p_; // GUH + } + if (!last_mom_) { + last_mom_ = get_staff_info().score_l()->last(); + } +} + + +void +Staff_sym_register::pre_move_processing() +{ + Staff_info i=get_staff_info(); + if ( span_p_ && i.when() == last_mom_) { + span_p_->right_col_l_ = i.command_pcol_l()->prebreak_p_; + typeset_element(span_p_); + span_p_ =0; + } +} + +IMPLEMENT_STATIC_NAME(Staff_sym_register); +ADD_THIS_REGISTER(Staff_sym_register); +Staff_sym_register::~Staff_sym_register() +{ + assert(!span_p_); + delete span_p_; +} diff --git a/lily/staff-sym.cc b/lily/staff-sym.cc new file mode 100644 index 0000000000..9eb0e76899 --- /dev/null +++ b/lily/staff-sym.cc @@ -0,0 +1,48 @@ +/* + staffsym.cc -- implement Staff_symbol + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ +#include "staff-sym.hh" +#include "lookup.hh" +#include "paper-def.hh" +#include "debug.hh" + + + +Staff_symbol::Staff_symbol(int l) +{ + no_lines_i_ = l; +} + +IMPLEMENT_STATIC_NAME(Staff_symbol); + +void +Staff_symbol::do_print()const +{ + mtor << "lines: " << no_lines_i_; +} + +Molecule* +Staff_symbol::brew_molecule_p() const +{ + Atom a = paper()->lookup_l()->linestaff(no_lines_i_, width().length()); + return new Molecule(a); +} + +Spanner* +Staff_symbol::do_break_at(PCol*p1, PCol*p2)const +{ + Staff_symbol *span_p=new Staff_symbol(*this); + return span_p; +} + +void +Staff_symbol::set_extent(PCol*p1, PCol*p2) +{ + assert(p1&&p2); + left_col_l_ = p1; + right_col_l_ = p2; +} diff --git a/lily/staff-walker.cc b/lily/staff-walker.cc index 32cd6dab1f..ea37d9d63e 100644 --- a/lily/staff-walker.cc +++ b/lily/staff-walker.cc @@ -57,7 +57,11 @@ Staff_walker::process_timing_reqs() if (tr_l->meterchange()) { int b_i=tr_l->meterchange()->beats_i_; int o_i = tr_l->meterchange()->one_beat_i_; - time_.set_meter(b_i, o_i); + if (! time_.allow_meter_change_b() ) + + tr_l->warning("Meterchange should be at start of measure"); + else + time_.set_meter(b_i, o_i); *default_grouping = Rhythmic_grouping( MInterval(0,Moment(b_i, o_i)), b_i); @@ -69,7 +73,7 @@ Staff_walker::process_timing_reqs() if (tr_l->partial()) { time_.setpartial(tr_l->partial()->duration_); } else if (tr_l->barcheck() && time_.whole_in_measure_) { - warning( "Barcheck failed", tr_l->defined_ch_C_ ); + tr_l ->warning( "Barcheck failed"); } else if (tr_l->cadenza()) { time_.set_cadenza(tr_l->cadenza()->on_b_); } else if (tr_l->measuregrouping()) { diff --git a/lily/staff.cc b/lily/staff.cc index b23f163d29..d9623fe436 100644 --- a/lily/staff.cc +++ b/lily/staff.cc @@ -5,20 +5,17 @@ (c) 1997 Han-Wen Nienhuys */ - +#include "input-register.hh" #include "proto.hh" -#include "plist.hh" #include "staff.hh" #include "score.hh" #include "voice.hh" -#include "staff-walker.hh" #include "staff-column.hh" #include "score-column.hh" #include "voice-element.hh" #include "debug.hh" #include "musical-request.hh" #include "command-request.hh" // todo -#include "midi-stream.hh" #include "pqueue.hh" @@ -163,12 +160,14 @@ Staff::print() const for (iter_top(voice_list_,i); i.ok(); i++) { i->print(); } + ireg_p_->print(); mtor <<"}\n"; #endif } Staff::Staff() { + ireg_p_ =0; score_l_ =0; pscore_l_ =0; pstaff_l_ =0; diff --git a/lily/staffline.cc b/lily/staffline.cc index a0ac8a6f99..742cee60c2 100644 --- a/lily/staffline.cc +++ b/lily/staffline.cc @@ -11,7 +11,9 @@ static String make_vbox(Interval i) { - Real r = (i.empty()) ? 0.0 : i.length(); + if (i.empty_b()) + i = Interval(0,0); + Real r = i.length(); String s("\\vbox to "); s += print_dimen(r); s += "{\\vskip "+print_dimen(i.right)+" "; @@ -64,8 +66,8 @@ Line_of_staff::Line_of_staff(Line_of_score * sc, PStaff*st) PCol *linestop = sc->cols.bottom(); for (iter_top(pstaff_l_->spans,i); i.ok(); i++) { - PCol *brokenstart = &max(*linestart, *i->left); - PCol *brokenstop = &min(*linestop, *i->right); + PCol *brokenstart = &max(*linestart, *i->left_col_l_); + PCol *brokenstop = &min(*linestop, *i->right_col_l_); if ( *brokenstart < *brokenstop) { Spanner*span_p =i->broken_at(brokenstart,brokenstop); line_of_score_l_->pscore_l_-> // higghl diff --git a/lily/stem-beam-reg.cc b/lily/stem-beam-reg.cc index 9169f78599..80aa450771 100644 --- a/lily/stem-beam-reg.cc +++ b/lily/stem-beam-reg.cc @@ -88,8 +88,8 @@ Stem_beam_register::process_requests() if (beam_p_) { if (stem_req_l_->duration_.type_i_<= 4) - warning( "stem doesn't fit in Beam", - stem_req_l_->defined_ch_C_); + + stem_req_l_->warning( "stem doesn't fit in Beam"); else beam_p_->add(stem_p_); stem_p_->print_flag = false; @@ -146,7 +146,7 @@ Stem_beam_register::post_move_processing() Stem_beam_register::~Stem_beam_register() { if (beam_p_) - warning("unterminated beam", start_req_l_->defined_ch_C_); + start_req_l_->warning("unterminated beam"); } void @@ -156,3 +156,4 @@ Stem_beam_register::set_feature(Features i) } IMPLEMENT_STATIC_NAME(Stem_beam_register); +ADD_THIS_REGISTER(Stem_beam_register); diff --git a/lily/stem.cc b/lily/stem.cc index 5e6592c482..047aec7b9f 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -42,7 +42,7 @@ Stem::set_stemend(Real se) // todo: margins if (! ((dir > 0 && se >= maxnote) || (se <= minnote && dir <0)) ) - warning("Weird stem size; check for narrow beams",0); + warning("Weird stem size; check for narrow beams"); top = (dir < 0) ? maxnote : se; bot = (dir < 0) ? se : minnote; @@ -107,7 +107,7 @@ void Stem::set_default_extents() { if (minnote > maxnote) { - warning("Empty stem. Ugh!", 0); + warning("Empty stem. Ugh!"); minnote = -10; maxnote = 20; } diff --git a/lily/swallow-reg.cc b/lily/swallow-reg.cc new file mode 100644 index 0000000000..24a20ef7d0 --- /dev/null +++ b/lily/swallow-reg.cc @@ -0,0 +1,23 @@ +/* + swallow-reg.cc -- implement Swallow_register + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ +#include "swallow-reg.hh" + +IMPLEMENT_STATIC_NAME(Swallow_register); +ADD_THIS_REGISTER(Swallow_register); + +bool +Swallow_register::acceptable_request_b(Request*) const +{ + return true; +} + +bool +Swallow_register::try_request(Request*) +{ + return true; +} diff --git a/lily/text-def.cc b/lily/text-def.cc index 22affae7ed..71fb743886 100644 --- a/lily/text-def.cc +++ b/lily/text-def.cc @@ -8,7 +8,6 @@ Text_def::Text_def() { align_i_ = 1; // right style_str_ = "roman"; - defined_ch_C_ = 0; } bool Text_def::compare(Text_def const &def) diff --git a/lily/text-reg.cc b/lily/text-reg.cc index fbe54a5db4..5c61f6179d 100644 --- a/lily/text-reg.cc +++ b/lily/text-reg.cc @@ -58,3 +58,4 @@ Text_register::post_move_processing() text_req_l_ = 0; } IMPLEMENT_STATIC_NAME(Text_register); +ADD_THIS_REGISTER(Text_register); diff --git a/lily/text-spanner.cc b/lily/text-spanner.cc index 77ab800bdb..fbc04ca4c6 100644 --- a/lily/text-spanner.cc +++ b/lily/text-spanner.cc @@ -55,9 +55,9 @@ Text_spanner::brew_molecule_p() const void Text_spanner::do_pre_processing() { - right = support->right; - left = support->left; - assert(left && right); + right_col_l_ = support->right_col_l_; + left_col_l_ = support->left_col_l_; + assert(left_col_l_ && right_col_l_); } Interval diff --git a/lily/time-description.cc b/lily/time-description.cc index cdc0071a92..2266b61b33 100644 --- a/lily/time-description.cc +++ b/lily/time-description.cc @@ -85,7 +85,11 @@ Time_description::set_meter(int l, int o) if(whole_in_measure_) error_t("Meterchange should be at start of measure", *this); } - +bool +Time_description::allow_meter_change_b() +{ + return!(whole_in_measure_); +} void Time_description::setpartial(Moment p) { diff --git a/lily/voice-element.cc b/lily/voice-element.cc new file mode 100644 index 0000000000..b499e3d727 --- /dev/null +++ b/lily/voice-element.cc @@ -0,0 +1,105 @@ +/* + voice-elt.cc -- implement Voice_element + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + +#include "proto.hh" +#include "plist.hh" +#include "debug.hh" +#include "voice.hh" +#include "voice-element.hh" +#include "musical-request.hh" +#include "command-request.hh" + + +void +Voice_element::transpose(Melodic_req const&d)const +{ + for (iter_top(reqs,i); i.ok(); i++) { + i->transpose(d); + } +} + +void +Voice_element::print() const +{ +#ifndef NPRINT + mtor << "voice_element { dur :"<< duration_ <<"\n"; + for (iter_top(reqs,rc); rc.ok(); rc++) { + rc->print(); + } + mtor << "}\n"; +#endif +} + +void +Voice_element::add(Request*r) +{ + if (r->duration()) { + assert (!duration_ || duration_ == r->duration()); + duration_ = r->duration(); + } + + r->elt_l_ = this; + reqs.bottom().add(r); +} + + +Voice_element::Voice_element() +{ + voice_C_ = 0; + duration_ = 0; +} + +Voice_element::Voice_element(Voice_element const&src) + : Input(src) +{ + + voice_C_=0; + for (iter_top(src.reqs, i); i.ok(); i++) + add(i->clone()); + +} +bool +Voice_element::find_plet_start_b(char c, Moment& moment_r)// b unused? +{ + assert( c == ']' ); + moment_r += duration_; + for ( PCursor i( reqs.top() ); i.ok(); i++ ) { + if (i->beam() && i->beam()->spantype == Span_req::START ) + return true; + } + return false; +} + +void +Voice_element::set_default_group(String s) +{ + for (iter_top(reqs, i); i.ok(); i++) + if (i->command() &&i->command()->groupchange()) + return ; + Group_change_req *greq = new Group_change_req; + greq->newgroup_str_ = s; + add(greq); +} + +void +Voice_element::set_plet_backwards(Moment& now_moment_r, + Moment until_moment, int num_i, int den_i) +{ + now_moment_r += duration_; + if ( now_moment_r > until_moment ) + return; + for ( PCursor i( reqs.top() ); i.ok(); i++ ) { + if (i->beam() && i->beam()->spantype == Span_req::START ) + i->beam()->nplet = den_i; + if (i->rhythmic()) { + i->rhythmic()->duration_.plet_.type_i_ = den_i; + i->rhythmic()->duration_.plet_.iso_i_ = num_i; + + } + } +} diff --git a/lily/voice-group-regs.cc b/lily/voice-group-regs.cc index b9351bd8e8..476b204a53 100644 --- a/lily/voice-group-regs.cc +++ b/lily/voice-group-regs.cc @@ -12,23 +12,18 @@ #include "voice-regs.hh" #include "voice-group-regs.hh" #include "register.hh" -#include "text-reg.hh" -#include "stem-beam-reg.hh" -#include "script-reg.hh" #include "complex-walker.hh" #include "command-request.hh" #include "debug.hh" -#include "dynamic-reg.hh" +#include "input-register.hh" static int temp_id_count; -Voice_group_registers::Voice_group_registers(String id) +Voice_group_registers::Voice_group_registers(String id, + Input_register const *ireg_C) { - add(new Dynamic_register); - add(new Text_register); - add(new Stem_beam_register); - add(new Script_register); - + ireg_C_ =ireg_C; + Register_group_register::add(ireg_C->get_nongroup_p_arr()); if (id=="") // UGH id = __FUNCTION__ + String(temp_id_count++); group_id_str_ = id; @@ -44,35 +39,15 @@ Voice_group_registers::try_request(Request*r_l) } return false; gotcha: - if (r_l->groupfeature()) { - set_feature(Features::dir(r_l->groupfeature()->stemdir_i_)); + Command_req* c_l = r_l->command(); + if (c_l&& c_l->groupfeature()) { + set_feature(Features::dir(c_l->groupfeature()->stemdir_i_)); return true; } return Register_group_register::try_request(r_l); } -bool -Voice_group_registers::static_acceptable_request_b(Request*r) -{ - return (r->stem() || r->beam() || r->text() || r->script() || - r->groupfeature()); -} - -void -Voice_group_registers::terminate_register(Request_register*r_l) -{ - if (r_l->name() == Voice_registers::static_name()) { - for (int i=0; i name() == Voice_registers::static_name()) { + for (int i=0; i get_nongroup_p_arr()); } void @@ -42,8 +42,12 @@ Voice_registers::try_request(Request*r_l) daddy_reg_l_->terminate_register(this); return true; // scary. We're deleted now.. } else if (c&&c->groupchange()) { - - ((Walker_registers*)daddy_reg_l_->daddy_reg_l_)-> // scary. + /* this is scary as well. The groupchange has to be handled by + the Staff_registers, which are two levels up in the hierarchy + */ + + assert(daddy_reg_l_->name() == Voice_group_registers::static_name()); + ((Staff_registers*)daddy_reg_l_->daddy_reg_l_)-> // scary. change_group(c->groupchange(), this, (Voice_group_registers*)daddy_reg_l_); // UGR! return true; @@ -56,7 +60,7 @@ bool Voice_registers::acceptable_request_b(Request*r) { Command_req * c_l = r->command(); - return r->groupchange() || (c_l&&c_l->terminate()) + return (c_l&&(c_l->terminate()||c_l->groupchange())) || Register_group_register::acceptable_request_b(r); } IMPLEMENT_STATIC_NAME(Voice_registers); diff --git a/lily/voice.cc b/lily/voice.cc index d76b3ebe83..a5e10f7fd9 100644 --- a/lily/voice.cc +++ b/lily/voice.cc @@ -65,7 +65,7 @@ Voice::Voice() void Voice::add(Voice_element*v) { - v->voice_l_ = this; + v->voice_C_ = this; elts.bottom().add(v); } diff --git a/lily/walk-regs.cc b/lily/walk-regs.cc index b258bd559d..e0221462e7 100644 --- a/lily/walk-regs.cc +++ b/lily/walk-regs.cc @@ -5,32 +5,26 @@ (c) 1997 Han-Wen Nienhuys */ - #include "debug.hh" -#include "clef-reg.hh" -#include "local-key-reg.hh" -#include "key-reg.hh" -#include "meter-reg.hh" -#include "bar-reg.hh" -#include "bar.hh" #include "walk-regs.hh" +#include "staff-regs.hh" #include "staff-elem.hh" #include "staff.hh" #include "complex-walker.hh" #include "staff-column.hh" -#include "voice-group-regs.hh" -#include "voice-regs.hh" -#include "command-request.hh" #include "score-walker.hh" +#include "bar.hh" // needed for Bar::static_name +#include "input-register.hh" Walker_registers::Walker_registers(Complex_walker *w) { walk_l_ = w; - add( new Bar_register); - add( new Clef_register); - add( new Key_register); - add( new Meter_register); - add( new Local_key_register); + Input_register * ireg_l = w->staff_l_->ireg_p_; + if (ireg_l->name_str_ == "Staff_registers") + add(new Staff_registers(ireg_l)); + else { + add(ireg_l->get_nongroup_p_arr()); + } } void @@ -101,70 +95,12 @@ Walker_registers::post_move_processing() Register_group_register::post_move_processing(); } -void -Walker_registers::change_group(Group_change_req * greq_l, - Voice_registers *voice_regs_l, - Voice_group_registers * old_group) -{ - Voice_registers *regs_p = (old_group) - ? (Voice_registers*) old_group->get_register_p(voice_regs_l) - : new Voice_registers(greq_l->voice_l()); - Voice_group_registers * new_group_l = get_group(greq_l->newgroup_str_); - new_group_l->add(regs_p); - - mtor << "processed change request"; - print(); -} - -Voice_group_registers * -Walker_registers::get_group(String id) -{ - for (int i=0; i < group_l_arr_.size(); i++) { - if (group_l_arr_[i]->group_id_str_ == id) - return group_l_arr_[i]; - } - Voice_group_registers *group_p = new Voice_group_registers(id); - group_l_arr_.push(group_p); - add(group_p); - return group_p; -} - -void -Walker_registers::terminate_register(Request_register * reg) -{ - for (int i=0; i < group_l_arr_.size(); i++) { - if (group_l_arr_[i] == reg) { - group_l_arr_.del(i); - Register_group_register::terminate_register(reg); - return; - } - } - assert(false); -} - -bool -Walker_registers::try_request(Request * r) -{ - bool b = Register_group_register::try_request(r); - if (!b) { - Command_req * cr_l = r->command() ; - - if (cr_l && cr_l->groupchange()) { - change_group(cr_l->groupchange(), 0, 0); - } else - warning("junking request: " + String(r->name()), - r->defined_ch_C_); - } - return b; -} - Staff_info Walker_registers::get_staff_info() return inf; { if (walk_l_->score_walk_l_) // we get called ctors inf.break_allowed_b_ = walk_l_->score_walk_l_->break_allowed_b(); - inf.c0_position_i_ = &walk_l_->c0_position_i_; inf.walk_l_ = walk_l_; inf.time_C_ = &walk_l_->time_; inf.rhythmic_C_ = walk_l_->default_grouping; diff --git a/lily/warn.cc b/lily/warn.cc index 2b9f1db767..4240aa04b5 100644 --- a/lily/warn.cc +++ b/lily/warn.cc @@ -1,3 +1,11 @@ +/* + warn.cc -- implement warning and error messages. Needs cleanup. + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + #include "proto.hh" #include "plist.hh" #include "debug.hh" @@ -7,16 +15,11 @@ #include "source-file.hh" #include "source.hh" #include "main.hh" +#include "input.hh" ostream &warnout (cerr); ostream *mlog(&cerr); -/* -void -warning(String s) -{ - WARN << s; -} -*/ + void error(String s) @@ -44,7 +47,7 @@ error_t(String const & s, Time_description const &t_tdes) void message( String message_str, char const* context_ch_C ) { - String str = ""; //"lilypond: ";// GNU format messages! + String str = ""; Source_file* sourcefile_l = source_l_g->sourcefile_l( context_ch_C ); if ( sourcefile_l ) { str += sourcefile_l->file_line_no_str(context_ch_C) + String(": "); @@ -76,3 +79,16 @@ error( String message_str, char const* context_ch_C ) lexer->errorlevel_i_ |= 1;*/ // exit( 1 ); } + + +void +warning(String m) +{ + warning(m, (char*)0); +} + +void +message(String m) +{ + error(m, (char*)0); +} diff --git a/mi2mu/midi-track.cc b/mi2mu/midi-track.cc index 18de844098..ecf889bba6 100644 --- a/mi2mu/midi-track.cc +++ b/mi2mu/midi-track.cc @@ -143,7 +143,7 @@ Midi_track::output_mudela( Lily_stream& lily_stream_r ) tor( NORMAL_ver ) << '[' << flush; if ( bars_i > bar_i ) { - Moment into_bar_mom = now_mom - ( bars_i - 1 ) * bar_mom; + Moment into_bar_mom = now_mom - Moment( bars_i - 1 ) * bar_mom; if ( bars_i > 1 ) { if ( !into_bar_mom ) lily_stream_r << "|"; -- 2.39.5