]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-1.5.47
authorfred <fred>
Wed, 27 Mar 2002 02:07:25 +0000 (02:07 +0000)
committerfred <fred>
Wed, 27 Mar 2002 02:07:25 +0000 (02:07 +0000)
15 files changed:
lily/include/lily-proto.hh
lily/include/music-output-def.hh
lily/include/music-output.hh
lily/include/my-lily-lexer.hh
lily/include/my-lily-parser.hh
lily/include/paper-outputter.hh
lily/midi-def.cc
lily/music-output-def.cc
lily/my-lily-lexer.cc
lily/my-lily-parser.cc
lily/paper-def.cc
lily/paper-outputter.cc
lily/paper-score.cc
lily/parser.yy
lily/scores.cc

index e250a6a7efd3c266ff37b9615cb802067cc02037..329d08cefa4c5a0e80b4be7952bfe88804c8ef64 100644 (file)
@@ -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;
index 8015d6079041c6b33e3c7cd3dfc7c2354a7bf788..54b8954c53d17fbda85aa22a43422a8403788acd 100644 (file)
 
 /**
   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_;
index 19723a0c454dd82c8ee339fba890f09eec429287..c15ac41ff579e706339f376594fdea569ab570a2 100644 (file)
@@ -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_;
index 9868a3f68614b9a613ebc6963e3a83e9463447a9..40701e2355c893a10513519b9fffb854c5211003 100644 (file)
@@ -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> scope_l_arr_;
+  Link_array<Scheme_hash_table> 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;
index ddb7038294af0564451a9820b73924d301a90458..47b85c5799d64e5a52cee7212a55e557a01c7777 100644 (file)
@@ -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_;
index bccde18b7fc8f692b6393f29288285531ebc9525..56defcc3b211408c523780f6d487880ed8eb1cd2 100644 (file)
@@ -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
index 5d76f00341a457c83d15f83f8a9f720258b628c4..2f2479815d7f3ee82a82d0f7b8a2d11a81a2472f 100644 (file)
@@ -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 ());
 }
 
 
index 10d883e24a9565e20b2c574422d3bade6b24d428..f2f3195b6e4a66c5f7264548607c9cbfd6a95159 100644 (file)
@@ -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);
 }
 
 /*
index 767ebf54a2b9a34514609ccf297fe922b4e18bd1..59e8d2f4a346347d6c481b58a4b81fd7a97f80b7 100644 (file)
@@ -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_ ;
 }
 
 
index 730a6db3430f9cbfbdc1c768369742de5ede32cd..ff1baa364288c6c592f02d1191ce5f59856bb325 100644 (file)
@@ -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<Paper_def*> (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))
     {
index 03766359ef5b5db684d72970a22335c0dd55a241..f0518445324f6782a737c5c8fa0eb700b96cd670 100644 (file)
@@ -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);
     }
index 1c0681010ada3952fbd63298c384f1f5eddb8d75..7f1cfaac4ca19bdf2739895846cdf5f0e4a2419e 100644 (file)
@@ -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 ())
     {
index 2154b40bf5a01063cc2d2d771999d3536e0c025a..a6f1168049d46dd06a76ae816d97f61c065bf7dc 100644 (file)
@@ -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);
index 9459adbf57d80f1c92edd4869d74ab273cb8819e..ae165c9c218afdb04f7fa771f6a1b7efaf991662 100644 (file)
@@ -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<Paper_def*> ($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<Midi_def*> ($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<Paper_def*> (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  {
index db3e48736a7ba9ca9324e4d16cdd59e3821aa160..a8ef7d411fe25286be27e98a46c75240d64afdf2 100644 (file)
@@ -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"