]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/global-context-scheme.cc
* input/regression/beam-quant-standard.ly: reindent, set
[lilypond.git] / lily / global-context-scheme.cc
index c543d736484723f836c9373d2fa8f1380afd67c1..914b1c7d3bda895cb5edd99f39bd6d5195e6f251 100644 (file)
@@ -4,7 +4,6 @@
   source file of the GNU LilyPond music typesetter
 
   (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
 */
 
 #include "warn.hh"
 #include "main.hh"
 
 LY_DEFINE (ly_format_output, "ly:format-output",
-          2, 0, 0, (SCM context, SCM outname),
+          1, 0, 0, (SCM context),
           "Given a Global context in its final state, "
-           "process it and return the (rendered) result.")
+          "process it and return the @code{Music_output} object in its final state.")
 {
-  Global_context *g = dynamic_cast<Global_context*> (unsmob_context (context));
+  Global_context *g = dynamic_cast<Global_context *> (unsmob_context (context));
   SCM_ASSERT_TYPE (g, context, SCM_ARG1, __FUNCTION__, "Global context");
-  SCM_ASSERT_TYPE (scm_is_string (outname), outname, SCM_ARG2, __FUNCTION__, "output file name");
 
-  Music_output *output = g->get_output ();
+  SCM output = g->get_output ();
   progress_indication ("\n");
-  /* ugh, midi still wants outname  */
-  return output->process (ly_scm2string (outname));
+  unsmob_music_output (output)->process ();
+  return output;
 }
 
-
-LY_DEFINE (ly_run_translator, "ly:run-translator", 
+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"
@@ -49,35 +46,34 @@ LY_DEFINE (ly_run_translator, "ly:run-translator",
   if (!music
       || !music->get_length ().to_bool ())
     {
-      warning (_ ("Need music in a score"));
+      warning (_ ("no music found in score"));
       return SCM_BOOL_F;
     }
-  
-  SCM_ASSERT_TYPE (music, mus, SCM_ARG1,
-                  __FUNCTION__, "Music");
+
+  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) );
+
+  Global_context *trans = new Global_context (odef, music->get_length (), unsmob_key (key));
   if (!trans)
     {
       programming_error ("no toplevel translator");
       return SCM_BOOL_F;
     }
 
-  progress_indication (_ ("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_iterator (protected_iter);
   iter->init_translator (music, trans);
 
   iter->construct_children ();
 
   if (!iter->ok ())
     {
-      warning (_ ("Need music in a score"));
+      warning (_ ("no music found in score"));
       /* todo: should throw exception. */
       return SCM_BOOL_F;
     }
@@ -88,7 +84,7 @@ LY_DEFINE (ly_run_translator, "ly:run-translator",
   trans->finish ();
 
   if (be_verbose_global)
-    progress_indication (_f ("elapsed time: %.2f seconds",  timer.read ()));
-  
-  return scm_gc_unprotect_object (trans->self_scm ());
+    message (_f ("elapsed time: %.2f seconds", timer.read ()));
+
+  return trans->unprotect ();
 }