X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fmusic-output-def.cc;h=068b8594cbc8805eb74b00439a820ba4d6857861;hb=6817805afca5e84e74479bdd951609b80210095b;hp=926989bdf14e75d4c39eb85d4f5119826b8cea77;hpb=2beb46604db29ec535c8bf512945cfc754aca33c;p=lilypond.git diff --git a/lily/music-output-def.cc b/lily/music-output-def.cc index 926989bdf1..068b8594cb 100644 --- a/lily/music-output-def.cc +++ b/lily/music-output-def.cc @@ -3,14 +3,14 @@ source file of the GNU LilyPond music typesetter - (c) 1997--2003 Han-Wen Nienhuys + (c) 1997--2004 Han-Wen Nienhuys */ #include "scm-hash.hh" #include "warn.hh" #include "music-output-def.hh" -#include "global-translator.hh" +#include "global-context.hh" #include "context-def.hh" #include "main.hh" #include "file-path.hh" @@ -25,13 +25,11 @@ Music_output_def::Music_output_def () translator_tab_ = new Scheme_hash_table; scope_ = SCM_EOL; smobify_self (); - scm_gc_unprotect_object (translator_tab_->self_scm ()); - scope_ = ly_make_anonymous_module(); + scm_gc_unprotect_object (translator_tab_->self_scm ()); + scope_ = ly_make_anonymous_module (); } - - Music_output_def::~Music_output_def () { } @@ -39,11 +37,11 @@ Music_output_def::~Music_output_def () Music_output_def::Music_output_def (Music_output_def const &s) { scope_ = SCM_EOL; - translator_tab_ = new Scheme_hash_table (*s.translator_tab_); - + translator_tab_ = 0; scaled_fonts_ = SCM_EOL; - smobify_self (); + + translator_tab_ = new Scheme_hash_table (*s.translator_tab_); scm_gc_unprotect_object (translator_tab_->self_scm ()); scaled_fonts_ = scm_list_copy (s.scaled_fonts_); @@ -61,7 +59,8 @@ SCM Music_output_def::mark_smob (SCM m) { Music_output_def * mo = (Music_output_def*) SCM_CELL_WORD_1 (m); - scm_gc_mark (mo->translator_tab_->self_scm ()); + if (mo->translator_tab_) + scm_gc_mark (mo->translator_tab_->self_scm ()); scm_gc_mark (mo->scope_); return mo->scaled_fonts_; @@ -78,37 +77,20 @@ Music_output_def::assign_translator (SCM transdef) String nm = ly_symbol2string (tp->get_context_name ()) + "Context"; - scm_module_define (scope_, ly_symbol2scm (nm.to_str0()), transdef); + scm_module_define (scope_, ly_symbol2scm (nm.to_str0 ()), transdef); } /* find the translator for NAME. NAME must be a symbol. - */ +*/ SCM -Music_output_def::find_translator (SCM name) const +Music_output_def::find_context_def (SCM name) const { SCM val =SCM_EOL; translator_tab_->try_retrieve (name, &val); return val; } - -Global_translator * -Music_output_def::get_global_translator () -{ - SCM key = ly_symbol2scm ("Score"); - Context_def * t = unsmob_context_def (find_translator (key)); - - if (!t) - error (_f ("can't find `%s' context", "Score")); - - Translator_group * tg = t->instantiate (this, SCM_EOL); - - tg->initialize (); - - return dynamic_cast (tg); -} - int Music_output_def::print_smob (SCM s, SCM p, scm_print_state *) { @@ -121,14 +103,12 @@ Music_output_def::print_smob (SCM s, SCM p, scm_print_state *) return 1; } - SCM Music_output_def::get_scmvar (String s) const { return lookup_variable (ly_symbol2scm (s.to_str0 ())); } - void Music_output_def::set_variable (SCM sym, SCM val) { @@ -143,50 +123,37 @@ Music_output_def::lookup_variable (SCM sym) const return scm_variable_ref (var); } -LY_DEFINE(ly_paper_lookup, - "ly:paper-lookup", - 2, 0,0, - (SCM pap, SCM sym), - "Lookup @var{sym} in @var{pap}. Return the value " - " or '() if undefined. " - ) +LY_DEFINE (ly_paper_lookup, "ly:paper-lookup", + 2, 0,0, (SCM pap, SCM sym), + "Lookup @var{sym} in @var{pap}. " + "Return the value or ' () if undefined.") { Music_output_def *op = unsmob_music_output_def (pap); SCM_ASSERT_TYPE (op, pap, SCM_ARG1, __FUNCTION__, "Paper"); SCM_ASSERT_TYPE (gh_symbol_p (sym), sym, SCM_ARG2, __FUNCTION__, "symbol"); - SCM v = op->lookup_variable (sym); - - if (SCM_VARIABLEP(v)) - return SCM_VARIABLE_REF(v); + SCM var = ly_module_lookup (op->scope_, sym); + if (SCM_VARIABLEP (var)) + return SCM_VARIABLE_REF (var); else return SCM_EOL; } -LY_DEFINE(ly_output_def_scope, - "ly:output-def-scope", - 1, 0,0, - (SCM def), - "Get the scope inside @var{def}." - ) +LY_DEFINE (ly_output_def_scope, "ly:output-def-scope", + 1, 0,0, (SCM def), + "Get the scope inside @var{def}.") { Music_output_def *op = unsmob_music_output_def (def); SCM_ASSERT_TYPE (op, def, SCM_ARG1, __FUNCTION__, "Output definition"); - return op->scope_; } - -LY_DEFINE(ly_output_def_clone, - "ly:output-def-clone", - 1, 0,0, - (SCM def), - "Clone @var{def}." - ) +LY_DEFINE (ly_output_def_clone, "ly:output-def-clone", + 1, 0, 0, (SCM def), + "Clone @var{def}.") { Music_output_def *op = unsmob_music_output_def (def); SCM_ASSERT_TYPE (op, def, SCM_ARG1, __FUNCTION__, "Output definition"); - SCM s = op->clone ()->self_scm (); scm_gc_unprotect_object (s); return s;