X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fglobal-context-scheme.cc;h=a8289d52cf549fcabc63e829ed08b3e7606dd44b;hb=90e4d7057f3857da049dfda3d130017d4719bd6b;hp=18d1d807124b61deb5e5fc848ab5776f7d1bc5f5;hpb=3f8485925e8c879fe4c9ae86acef9804126c3b91;p=lilypond.git diff --git a/lily/global-context-scheme.cc b/lily/global-context-scheme.cc index 18d1d80712..a8289d52cf 100644 --- a/lily/global-context-scheme.cc +++ b/lily/global-context-scheme.cc @@ -1,9 +1,20 @@ /* - global-context-scheme.cc -- implement Global_context bindings + This file is part of LilyPond, the GNU music typesetter. - source file of the GNU LilyPond music typesetter + Copyright (C) 2005--2015 Han-Wen Nienhuys - (c) 2005--2007 Han-Wen Nienhuys + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . */ #include "cpu-timer.hh" @@ -18,30 +29,31 @@ #include "warn.hh" LY_DEFINE (ly_format_output, "ly:format-output", - 1, 0, 0, (SCM context), - "Given a Global context in its final state, " - "process it and return the @code{Music_output} object in its final state.") + 1, 0, 0, (SCM context), + "Given a global context in its final state," + " process it and return the @code{Music_output} object" + " in its final state.") { - Global_context *g = dynamic_cast (unsmob_context (context)); - - LY_ASSERT_TYPE (unsmob_global_context, context, 1) + Global_context *g = unsmob (context); + + LY_ASSERT_SMOB (Global_context, context, 1); SCM output = g->get_output (); progress_indication ("\n"); - if (Music_output *od = unsmob_music_output (output)) + if (Music_output *od = unsmob (output)) od->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.") + 1, 0, 0, (SCM global), + "Create a translator group and connect it to the global context" + " @var{global}. The translator group is returned.") { - Global_context *g = dynamic_cast (unsmob_context (global)); - LY_ASSERT_TYPE (unsmob_global_context, global, 1) + Global_context *g = unsmob (global); + LY_ASSERT_SMOB (Global_context, global, 1); Translator_group *tg = new Translator_group (); tg->connect_to_context (g); @@ -51,14 +63,12 @@ LY_DEFINE (ly_make_global_translator, "ly:make-global-translator", } LY_DEFINE (ly_make_global_context, "ly:make-global-context", - 1, 0, 0, (SCM output_def), - "Set up a global interpretation context, using the output\n" - "block @var{output_def}.\n" - "The context is returned.\n" - ) + 1, 0, 0, (SCM output_def), + "Set up a global interpretation context, using the output" + " block @var{output-def}. The context is returned.") { LY_ASSERT_SMOB (Output_def, output_def, 1); - Output_def *odef = unsmob_output_def (output_def); + Output_def *odef = unsmob (output_def); Global_context *glob = new Global_context (odef); @@ -72,30 +82,28 @@ LY_DEFINE (ly_make_global_context, "ly:make-global-context", } 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") + 2, 0, 0, (SCM mus, SCM ctx), + "Interpret the music expression @var{mus} in the global context" + " @var{ctx}. The context is returned in its final state.") { LY_ASSERT_SMOB (Music, mus, 1); - LY_ASSERT_TYPE (unsmob_global_context, ctx, 2); + LY_ASSERT_SMOB (Global_context, ctx, 2); - Music *music = unsmob_music (mus); - if (!music - || !music->get_length ().to_bool ()) + Music *music = unsmob (mus); + if (!music) { warning (_ ("no music found in score")); return SCM_BOOL_F; } - Global_context *g = dynamic_cast (unsmob_context (ctx)); + Global_context *g = unsmob (ctx); Cpu_timer timer; - message (_ ("Interpreting music... ")); + message (_ ("Interpreting music...")); SCM protected_iter = Music_iterator::get_static_get_iterator (music); - Music_iterator *iter = unsmob_iterator (protected_iter); + Music_iterator *iter = unsmob (protected_iter); iter->init_context (music, g); iter->construct_children (); @@ -112,23 +120,22 @@ LY_DEFINE (ly_interpret_music_expression, "ly:interpret-music-expression", iter->quit (); scm_remember_upto_here_1 (protected_iter); - send_stream_event (g, "Finish", 0, 0); + send_stream_event (g, "Finish", 0); - if (be_verbose_global) - message (_f ("elapsed time: %.2f seconds", timer.read ())); + debug_output (_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), - "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") + 2, 1, 0, (SCM mus, SCM output_def), + "Process @var{mus} according to @var{output-def}. An" + " interpretation context is set up, and @var{mus} is" + " interpreted with it. The context is returned in its" + " final state.\n" + "\n" + "Optionally, this routine takes an object-key to" + " to uniquely identify the score block containing it.") { LY_ASSERT_SMOB (Music, mus, 1); LY_ASSERT_SMOB (Output_def, output_def, 2);