X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fglobal-context-scheme.cc;h=7eb5fb224aa67003a08b06fed3d10c588c58958e;hb=9f3572d98bb948c9689cd1f75401a029451fa001;hp=219dc267c1d3762f0a0c19f314f415833001f976;hpb=04265f11d1f21416ccebd2dcaa1d903dc781b36e;p=lilypond.git diff --git a/lily/global-context-scheme.cc b/lily/global-context-scheme.cc index 219dc267c1..7eb5fb224a 100644 --- a/lily/global-context-scheme.cc +++ b/lily/global-context-scheme.cc @@ -5,6 +5,7 @@ (c) 2005--2006 Han-Wen Nienhuys */ + #include "cpu-timer.hh" #include "global-context.hh" #include "international.hh" @@ -14,7 +15,6 @@ #include "music.hh" #include "object-key.hh" #include "output-def.hh" -#include "translator-group.hh" #include "warn.hh" LY_DEFINE (ly_format_output, "ly:format-output", @@ -27,63 +27,22 @@ LY_DEFINE (ly_format_output, "ly:format-output", SCM output = g->get_output (); progress_indication ("\n"); - - if (Music_output *od = unsmob_music_output (output)) - od->process (); - + unsmob_music_output (output)->process (); return output; } -LY_DEFINE (ly_make_global_translator, "ly:make-global-translator", - 1, 0, 0, (SCM global), - "Create a translator group and connect it to the global context\n" - "@var{global}. The translator group is returned.") -{ - Global_context *g = dynamic_cast (unsmob_context (global)); - SCM_ASSERT_TYPE (g, global, SCM_ARG1, __FUNCTION__, "Global context"); - - Translator_group *tg = new Translator_group (); - tg->connect_to_context (g); - g->implementation_ = tg; - - return tg->unprotect (); -} - -LY_DEFINE (ly_make_global_context, "ly:make-global-context", - 1, 1, 0, (SCM output_def, SCM key), - "Set up a global interpretation context, using the output\n" - "block @var{output_def}.\n" - "The context is returned.\n" - - "\n\nOptionally, this routine takes an Object-key to\n" +LY_DEFINE (ly_run_translator, "ly:run-translator", + 2, 1, 0, (SCM mus, SCM output_def, SCM key), + "Process @var{mus} according to @var{output_def}. \n" + "An interpretation context is set up,\n" + "and @var{mus} is interpreted with it. \n" + "The context is returned in its final state.\n" + "\n\n" + "Optionally, this routine takes an Object-key to\n" "to uniquely identify the Score block containing it.\n") { Output_def *odef = unsmob_output_def (output_def); - - SCM_ASSERT_TYPE (odef, output_def, SCM_ARG1, __FUNCTION__, - "Output definition"); - - Global_context *glob = new Global_context (odef, unsmob_key (key)); - - if (!glob) - { - programming_error ("no toplevel translator"); - return SCM_BOOL_F; - } - - return glob->unprotect (); -} - -LY_DEFINE (ly_interpret_music_expression, "ly:interpret-music-expression", - 2, 0, 0, (SCM mus, SCM ctx), - "Interpret the music expression @var{mus} in the\n" - "global context @var{ctx}. The context is returned in its\n" - "final state.\n") -{ Music *music = unsmob_music (mus); - Global_context *g = dynamic_cast (unsmob_context (ctx)); - SCM_ASSERT_TYPE (music, mus, SCM_ARG1, __FUNCTION__, "Music"); - SCM_ASSERT_TYPE (g, ctx, SCM_ARG2, __FUNCTION__, "Global context"); if (!music || !music->get_length ().to_bool ()) @@ -92,14 +51,25 @@ LY_DEFINE (ly_interpret_music_expression, "ly:interpret-music-expression", return SCM_BOOL_F; } + SCM_ASSERT_TYPE (music, mus, SCM_ARG1, __FUNCTION__, "Music"); + SCM_ASSERT_TYPE (odef, output_def, SCM_ARG2, __FUNCTION__, + "Output definition"); + Cpu_timer timer; + Global_context *trans = new Global_context (odef, music->get_length (), + unsmob_key (key)); + if (!trans) + { + programming_error ("no toplevel translator"); + return SCM_BOOL_F; + } + message (_ ("Interpreting music... ")); SCM protected_iter = Music_iterator::get_static_get_iterator (music); Music_iterator *iter = unsmob_iterator (protected_iter); - - iter->init_context (music, g); + iter->init_translator (music, trans); iter->construct_children (); if (!iter->ok ()) @@ -109,31 +79,13 @@ LY_DEFINE (ly_interpret_music_expression, "ly:interpret-music-expression", return SCM_BOOL_F; } - g->run_iterator_on_me (iter); - + trans->run_iterator_on_me (iter); iter->quit (); scm_remember_upto_here_1 (protected_iter); - - send_stream_event (g, "Finish", 0, 0); + trans->finish (); if (be_verbose_global) message (_f ("elapsed time: %.2f seconds", timer.read ())); - return ctx; -} - -LY_DEFINE (ly_run_translator, "ly:run-translator", - 2, 1, 0, (SCM mus, SCM output_def, SCM key), - "Process @var{mus} according to @var{output_def}. \n" - "An interpretation context is set up,\n" - "and @var{mus} is interpreted with it. \n" - "The context is returned in its final state.\n" - "\n\n" - "Optionally, this routine takes an Object-key to\n" - "to uniquely identify the Score block containing it.\n") -{ - SCM glob = ly_make_global_context (output_def, key); - ly_make_global_translator (glob); - ly_interpret_music_expression (mus, glob); - return glob; + return trans->unprotect (); }