From 97ed8bd0a34fbbdc5e191e05ba68dc641105ffbf Mon Sep 17 00:00:00 2001 From: fred Date: Wed, 27 Mar 2002 02:07:25 +0000 Subject: [PATCH] lilypond-1.5.47 --- lily/include/lily-proto.hh | 1 - lily/include/music-output-def.hh | 6 ------ lily/include/music-output.hh | 2 +- lily/include/my-lily-lexer.hh | 6 ++---- lily/include/my-lily-parser.hh | 2 +- lily/include/paper-outputter.hh | 4 ++-- lily/midi-def.cc | 6 +++--- lily/music-output-def.cc | 14 ++++---------- lily/my-lily-lexer.cc | 19 ++++++++++--------- lily/my-lily-parser.cc | 7 ++++--- lily/paper-def.cc | 10 +++++----- lily/paper-outputter.cc | 7 +++---- lily/paper-score.cc | 12 ++++++------ lily/parser.yy | 22 +++++++++------------- lily/scores.cc | 1 - 15 files changed, 50 insertions(+), 69 deletions(-) diff --git a/lily/include/lily-proto.hh b/lily/include/lily-proto.hh index e250a6a7ef..329d08cefa 100644 --- a/lily/include/lily-proto.hh +++ b/lily/include/lily-proto.hh @@ -144,7 +144,6 @@ class Rest_req; class Rhythmic_req; class Scaled_font_metric; class Scheme_hash_table; -class Scope; class Score; class Grob; class Score_engraver; diff --git a/lily/include/music-output-def.hh b/lily/include/music-output-def.hh index 8015d60790..54b8954c53 100644 --- a/lily/include/music-output-def.hh +++ b/lily/include/music-output-def.hh @@ -18,10 +18,6 @@ /** Definition of how to output lilypond. - - TODO: smobify, remove Music_output_def_identifier. - - TODO: remove Scope structure. Scheme_hash_table has all the info. */ class Music_output_def { @@ -29,8 +25,6 @@ public: Scheme_hash_table * translator_tab_; Scheme_hash_table * variable_tab_; - Scope *translator_p_dict_p_; - Scope *scope_p_; SCM scaled_fonts_; SCM style_sheet_; diff --git a/lily/include/music-output.hh b/lily/include/music-output.hh index 19723a0c45..c15ac41ff5 100644 --- a/lily/include/music-output.hh +++ b/lily/include/music-output.hh @@ -19,7 +19,7 @@ class Music_output { public: - Scope * header_l_; + Scheme_hash_table * header_l_; String default_out_str_; String origin_str_; int errorlevel_i_; diff --git a/lily/include/my-lily-lexer.hh b/lily/include/my-lily-lexer.hh index 9868a3f686..40701e2355 100644 --- a/lily/include/my-lily-lexer.hh +++ b/lily/include/my-lily-lexer.hh @@ -32,8 +32,6 @@ public: String main_input_str_; void * lexval_l; Scheme_hash_table * toplevel_variable_tab_; - Scope * scope_p_; - bool main_input_b_; /* @@ -42,7 +40,7 @@ public: Protected_scm chordmodifier_tab_; Protected_scm pitchname_tab_; - Link_array scope_l_arr_; + Link_array scope_l_arr_; Keyword_table * keytable_p_; int errorlevel_i_; @@ -61,7 +59,7 @@ public: void push_lyric_state (); void pop_state (); void LexerError (char const *); - void set_identifier (String str, SCM); + void set_identifier (SCM name_str, SCM); bool note_state_b () const; bool chord_state_b () const; bool lyric_state_b () const; diff --git a/lily/include/my-lily-parser.hh b/lily/include/my-lily-parser.hh index ddb7038294..47b85c5799 100644 --- a/lily/include/my-lily-parser.hh +++ b/lily/include/my-lily-parser.hh @@ -40,7 +40,7 @@ public: public: Duration default_duration_; - Scope *default_header_p_; + Scheme_hash_table *default_header_p_; int fatal_error_i_; Sources * source_l_; diff --git a/lily/include/paper-outputter.hh b/lily/include/paper-outputter.hh index bccde18b7f..56defcc3b2 100644 --- a/lily/include/paper-outputter.hh +++ b/lily/include/paper-outputter.hh @@ -43,7 +43,7 @@ public: void output_int_def (String k, int v); void output_Real_def (String k, Real v); void output_String_def (String k, String v); - void output_scope (Scope*, String prefix); + void output_scope (Scheme_hash_table*, String prefix); void output_version (); void output_font_def (int i, String str); void output_font_switch (int i); @@ -53,7 +53,7 @@ public: void output_scheme (SCM scm); void write_header_field_to_file (String filename, SCM, SCM); - void write_header_fields_to_file (Scope *); + void write_header_fields_to_file (Scheme_hash_table *); }; #endif // PAPER_OUTPUTTER_HH diff --git a/lily/midi-def.cc b/lily/midi-def.cc index 5d76f00341..2f2479815d 100644 --- a/lily/midi-def.cc +++ b/lily/midi-def.cc @@ -11,7 +11,7 @@ #include "midi-def.hh" #include "performance.hh" #include "debug.hh" -#include "scope.hh" +#include "scm-hash.hh" Midi_def::Midi_def () { @@ -23,7 +23,7 @@ int Midi_def::get_tempo_i (Moment one_beat_mom) { SCM wis = ly_symbol2scm ("whole-in-seconds"); - Moment *w = unsmob_moment (scope_p_->scm_elem (wis)); + Moment *w = unsmob_moment (variable_tab_->get (wis)); Moment wholes_per_min = Moment (60); if (!w) @@ -46,7 +46,7 @@ Midi_def::set_tempo (Moment one_beat_mom, int beats_per_minute_i) Moment beats_per_second = Moment (beats_per_minute_i) / Moment (60); Moment m = Moment (1)/Moment (beats_per_second * one_beat_mom); - scope_p_->set ("whole-in-seconds", m.smobbed_copy ()); + variable_tab_->set (ly_symbol2scm ("whole-in-seconds"), m.smobbed_copy ()); } diff --git a/lily/music-output-def.cc b/lily/music-output-def.cc index 10d883e24a..f2f3195b6e 100644 --- a/lily/music-output-def.cc +++ b/lily/music-output-def.cc @@ -9,7 +9,6 @@ #include "scm-hash.hh" #include "dictionary.hh" -#include "scope.hh" #include "debug.hh" #include "music-output-def.hh" #include "global-translator.hh" @@ -33,8 +32,6 @@ Music_output_def::Music_output_def () variable_tab_ = new Scheme_hash_table; translator_tab_ = new Scheme_hash_table; - scope_p_ = new Scope (variable_tab_); - translator_p_dict_p_ = new Scope (translator_tab_); smobify_self (); scm_gc_unprotect_object (variable_tab_->self_scm ()); @@ -52,13 +49,10 @@ Music_output_def::Music_output_def (Music_output_def const &s) style_sheet_ = SCM_EOL; scaled_fonts_ = SCM_EOL; + smobify_self (); scm_gc_unprotect_object (variable_tab_->self_scm ()); scm_gc_unprotect_object (translator_tab_->self_scm ()); - - - scope_p_ = new Scope (variable_tab_); - translator_p_dict_p_ = new Scope (translator_tab_); style_sheet_ = scm_list_copy (s.style_sheet_); scaled_fonts_ = scm_list_copy (s.scaled_fonts_); @@ -87,11 +81,11 @@ Music_output_def::assign_translator (SCM transdef) assert (tp); - String s; + SCM s = ly_symbol2scm (""); if (gh_string_p (tp->type_name_)) - s = ly_scm2string (tp->type_name_); + s = scm_string_to_symbol (tp->type_name_); - translator_p_dict_p_->set (s, transdef); + translator_tab_->set (s, transdef); } /* diff --git a/lily/my-lily-lexer.cc b/lily/my-lily-lexer.cc index 767ebf54a2..59e8d2f4a3 100644 --- a/lily/my-lily-lexer.cc +++ b/lily/my-lily-lexer.cc @@ -20,7 +20,6 @@ #include "debug.hh" #include "source-file.hh" #include "main.hh" -#include "scope.hh" #include "input.hh" #include "moment.hh" @@ -97,9 +96,7 @@ My_lily_lexer::My_lily_lexer () { keytable_p_ = new Keyword_table (the_key_tab); toplevel_variable_tab_ = new Scheme_hash_table ; - scope_p_ = new Scope (toplevel_variable_tab_); - - scope_l_arr_.push (scope_p_); + scope_l_arr_.push (toplevel_variable_tab_); errorlevel_i_ = 0; main_input_b_ = false; @@ -133,21 +130,25 @@ My_lily_lexer::start_main_input () } void -My_lily_lexer::set_identifier (String name_str, SCM s) +My_lily_lexer::set_identifier (SCM name, SCM s) { - if (lookup_keyword (name_str) >= 0) + assert (gh_string_p (name)); + + if (lookup_keyword (ly_scm2string (name)) >= 0) { - warning (_f ("Identifier name is a keyword: `%s'", name_str)); + size_t sz; + char * str = gh_scm2newstr (name, &sz) ; + warning (_f ("Identifier name is a keyword: `%s'", str)); + free (str); } - scope_l_arr_.top ()->set (name_str, s); + scope_l_arr_.top ()->set (scm_string_to_symbol (name), s); } My_lily_lexer::~My_lily_lexer () { delete keytable_p_; scm_gc_unprotect_object (toplevel_variable_tab_->self_scm ()); - delete scope_p_ ; } diff --git a/lily/my-lily-parser.cc b/lily/my-lily-parser.cc index 730a6db343..ff1baa3642 100644 --- a/lily/my-lily-parser.cc +++ b/lily/my-lily-parser.cc @@ -13,7 +13,7 @@ #include "main.hh" #include "parser.hh" #include "file-results.hh" -#include "scope.hh" +#include "scm-hash.hh" My_lily_parser::My_lily_parser (Sources * source_l) { @@ -29,7 +29,8 @@ My_lily_parser::My_lily_parser (Sources * source_l) My_lily_parser::~My_lily_parser () { delete lexer_p_; - delete default_header_p_; + if (default_header_p_) + scm_gc_unprotect_object (default_header_p_->self_scm()); } void @@ -113,7 +114,7 @@ My_lily_parser::paper_description () Music_output_def *id = unsmob_music_output_def (me->lexer_p_->lookup_identifier ("$defaultpaper")); Paper_def *p = dynamic_cast (id->clone ()); - SCM al = p->translator_p_dict_p_->to_alist (); + SCM al = p->translator_tab_->to_alist (); SCM l = SCM_EOL; for (SCM s = al ; gh_pair_p (s); s = ly_cdr (s)) { diff --git a/lily/paper-def.cc b/lily/paper-def.cc index 03766359ef..f051844532 100644 --- a/lily/paper-def.cc +++ b/lily/paper-def.cc @@ -15,7 +15,7 @@ #include "debug.hh" #include "scaled-font-metric.hh" #include "main.hh" -#include "scope.hh" +#include "scm-hash.hh" #include "file-results.hh" // urg? header_global_p #include "paper-outputter.hh" @@ -48,7 +48,7 @@ Paper_def::get_var (String s) const SCM Paper_def::get_scmvar (String s) const { - return scope_p_->scm_elem (ly_symbol2scm (s.ch_C ())); + return variable_tab_->get (ly_symbol2scm (s.ch_C ())); } @@ -62,7 +62,7 @@ Real Paper_def::get_realvar (SCM s) const { SCM val ; - if (!scope_p_->try_retrieve (s, &val)) + if (!variable_tab_->try_retrieve (s, &val)) { programming_error ("unknown paper variable: " + ly_symbol2string (s)); return 0.0; @@ -70,7 +70,7 @@ Paper_def::get_realvar (SCM s) const Real sc = 1.0; SCM ssc; - if (scope_p_->try_retrieve (ly_symbol2scm ("outputscale"), &ssc)) + if (variable_tab_->try_retrieve (ly_symbol2scm ("outputscale"), &ssc)) { sc = gh_scm2double (ssc); } @@ -144,7 +144,7 @@ Paper_def::find_font (SCM fn, Real m) return unsmob_metrics (ly_cdr (met)); SCM ssc; - if (scope_p_->try_retrieve (ly_symbol2scm ("outputscale"), &ssc)) + if (variable_tab_->try_retrieve (ly_symbol2scm ("outputscale"), &ssc)) { m /= gh_scm2double (ssc); } diff --git a/lily/paper-outputter.cc b/lily/paper-outputter.cc index 1c0681010a..7f1cfaac4c 100644 --- a/lily/paper-outputter.cc +++ b/lily/paper-outputter.cc @@ -21,8 +21,7 @@ #include "debug.hh" #include "font-metric.hh" #include "main.hh" -#include "scope.hh" - +#include "scm-hash.hh" #include "lily-version.hh" #include "paper-def.hh" #include "file-results.hh" @@ -95,7 +94,7 @@ Paper_outputter::output_scheme (SCM scm) } void -Paper_outputter::output_scope (Scope *scope, String prefix) +Paper_outputter::output_scope (Scheme_hash_table *scope, String prefix) { SCM al = scope->to_alist (); for (SCM s = al ; gh_pair_p (s); s = ly_cdr (s)) @@ -173,7 +172,7 @@ Paper_outputter::write_header_field_to_file (String filename, SCM key, SCM value } void -Paper_outputter::write_header_fields_to_file (Scope * header) +Paper_outputter::write_header_fields_to_file (Scheme_hash_table * header) { if (dump_header_fieldnames_global.size ()) { diff --git a/lily/paper-score.cc b/lily/paper-score.cc index 2154b40bf5..a6f1168049 100644 --- a/lily/paper-score.cc +++ b/lily/paper-score.cc @@ -15,7 +15,7 @@ #include "paper-column.hh" #include "paper-score.hh" #include "paper-column.hh" -#include "scope.hh" +#include "scm-hash.hh" #include "gourlay-breaking.hh" #include "paper-outputter.hh" #include "file-results.hh" @@ -100,9 +100,9 @@ Paper_score::process () if (global_header_p) { - Scope gh (global_header_p); - outputter_l_->output_scope (&gh, "lilypond"); - outputter_l_->write_header_fields_to_file (&gh); + + outputter_l_->output_scope (global_header_p, "lilypond"); + outputter_l_->write_header_fields_to_file (global_header_p); } if (header_l_) { @@ -113,8 +113,8 @@ Paper_score::process () outputter_l_->output_comment (_ ("Outputting Score, defined at: ")); outputter_l_->output_comment (origin_str_); - if (paper_l_->scope_p_) - outputter_l_->output_scope (paper_l_->scope_p_, "lilypondpaper"); + if (paper_l_->variable_tab_) + outputter_l_->output_scope (paper_l_->variable_tab_, "lilypondpaper"); SCM scm = scm_list_n (ly_symbol2scm ("header-end"), SCM_UNDEFINED); outputter_l_->output_scheme (scm); diff --git a/lily/parser.yy b/lily/parser.yy index 9459adbf57..ae165c9c21 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -47,7 +47,6 @@ this. #include "property-iterator.hh" #include "file-results.hh" #include "input.hh" -#include "scope.hh" #include "relative-music.hh" #include "lyric-combine-music.hh" #include "transposed-music.hh" @@ -145,7 +144,6 @@ of the parse stack onto the heap. */ String *string; // needed by the lexer as temporary scratch area. Music *music; Score *score; - Scope *scope; Scheme_hash_table *scmhash; Music_output_def * outputdef; @@ -363,9 +361,9 @@ toplevel_expression: } | output_def { if (dynamic_cast ($1)) - THIS->lexer_p_->set_identifier ("$defaultpaper", $1->self_scm ()); + THIS->lexer_p_->set_identifier (gh_str02scm ("$defaultpaper"), $1->self_scm ()); else if (dynamic_cast ($1)) - THIS->lexer_p_->set_identifier ("$defaultmidi", $1->self_scm ()); + THIS->lexer_p_->set_identifier (gh_str02scm ("$defaultmidi"), $1->self_scm ()); } | embedded_scm { // junk value @@ -406,9 +404,7 @@ notenames_body: lilypond_header_body: { $$ = new Scheme_hash_table; - - Scope *sc = new Scope ($$); - THIS->lexer_p_-> scope_l_arr_.push (sc); + THIS->lexer_p_-> scope_l_arr_.push ($$); } | lilypond_header_body assignment { @@ -418,7 +414,7 @@ lilypond_header_body: lilypond_header: HEADER '{' lilypond_header_body '}' { $$ = $3; - delete THIS->lexer_p_-> scope_l_arr_.pop (); + THIS->lexer_p_->scope_l_arr_.pop (); } ; @@ -442,7 +438,7 @@ assignment: ip.warning (_ ("Identifier should have alphabetic characters only")); } - THIS->lexer_p_->set_identifier (ly_scm2string ($1), $4); + THIS->lexer_p_->set_identifier ($1, $4); /* TODO: devise standard for protection in parser. @@ -616,7 +612,7 @@ music_output_def_body: p = new Midi_def; $$ = p; - THIS->lexer_p_->scope_l_arr_.push (p->scope_p_); + THIS->lexer_p_->scope_l_arr_.push (p->variable_tab_); } | PAPER '{' { Music_output_def *id = unsmob_music_output_def (THIS->lexer_p_->lookup_identifier ("$defaultpaper")); @@ -625,20 +621,20 @@ music_output_def_body: p = dynamic_cast (id->clone ()); else p = new Paper_def; - THIS-> lexer_p_-> scope_l_arr_.push (p->scope_p_); + THIS-> lexer_p_-> scope_l_arr_.push (p->variable_tab_); $$ = p; } | PAPER '{' MUSIC_OUTPUT_DEF_IDENTIFIER { Music_output_def *p = unsmob_music_output_def ($3); p = p->clone (); - THIS->lexer_p_->scope_l_arr_.push (p->scope_p_); + THIS->lexer_p_->scope_l_arr_.push (p->variable_tab_); $$ = p; } | MIDI '{' MUSIC_OUTPUT_DEF_IDENTIFIER { Music_output_def *p = unsmob_music_output_def ($3); p = p->clone (); - THIS->lexer_p_->scope_l_arr_.push (p->scope_p_); + THIS->lexer_p_->scope_l_arr_.push (p->variable_tab_); $$ = p; } | music_output_def_body assignment { diff --git a/lily/scores.cc b/lily/scores.cc index db3e48736a..a8ef7d411f 100644 --- a/lily/scores.cc +++ b/lily/scores.cc @@ -19,7 +19,6 @@ #include "score.hh" #include "string.hh" #include "paper-def.hh" -#include "scope.hh" #include "debug.hh" #include "parray.hh" #include "file-path.hh" -- 2.39.5