]> git.donarmstrong.com Git - lilypond.git/commitdiff
*** empty log message ***
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 7 Jan 2005 12:27:05 +0000 (12:27 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 7 Jan 2005 12:27:05 +0000 (12:27 +0000)
lily/global-context-scheme.cc [new file with mode: 0644]
lily/global-context.cc
lily/paper-outputter-scheme.cc [new file with mode: 0644]
lily/paper-outputter.cc
lily/paper-system-scheme.cc [new file with mode: 0644]
lily/paper-system.cc

diff --git a/lily/global-context-scheme.cc b/lily/global-context-scheme.cc
new file mode 100644 (file)
index 0000000..c0f919f
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+  global-context-scheme.cc --  implement Global_context bindings
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+*/
+
+#include "warn.hh"
+#include "music-output.hh"
+#include "output-def.hh"
+#include "music-iterator.hh"
+#include "music.hh"
+#include "cpu-timer.hh"
+#include "global-context.hh"
+#include "object-key.hh"
+#include "main.hh"
+
+LY_DEFINE (ly_format_output, "ly:format-output",
+          2, 0, 0, (SCM context, SCM outname),
+          "Given a Score context in its final state,"
+           "process it and return the (rendered) result.")
+{
+  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 ();
+  progress_indication ("\n");
+  /* ugh, midi still wants outname  */
+  return output->process (ly_scm2string (outname));
+}
+
+
+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\nOptionally, 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);
+  Music *music = unsmob_music (mus);
+
+  if (!music
+      || !music->get_length ().to_bool ())
+    {
+      warning (_ ("Need music in a score"));
+      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;
+    }
+
+  progress_indication (_ ("Interpreting music... "));
+  
+  SCM protected_iter = Music_iterator::get_static_get_iterator (music);
+  Music_iterator * iter = unsmob_iterator (protected_iter);
+  iter->init_translator (music, trans);
+
+  iter->construct_children ();
+
+  if (!iter->ok ())
+    {
+      warning (_ ("Need music in a score"));
+      /* todo: should throw exception. */
+      return SCM_BOOL_F;
+    }
+
+  trans->run_iterator_on_me (iter);
+  iter->quit ();
+  scm_remember_upto_here_1 (protected_iter);
+  trans->finish ();
+
+  if (verbose_global_b)
+    progress_indication (_f ("elapsed time: %.2f seconds",  timer.read ()));
+  
+  return scm_gc_unprotect_object (trans->self_scm ());
+}
index ee26880d4deeb366207740e1d042c1b953850dc2..30966109663de6a3ef7ec243c5e9d830d9d36a08 100644 (file)
@@ -1,5 +1,5 @@
 /*
-  global-translator.cc -- implement global_context
+  global-context.cc -- implement Global_context
 
   source file of the GNU LilyPond music typesetter
 
diff --git a/lily/paper-outputter-scheme.cc b/lily/paper-outputter-scheme.cc
new file mode 100644 (file)
index 0000000..2dd5528
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+  paper-outputter-scheme.cc --  implement Paper_outputter bindings
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+*/
+
+#include "paper-outputter.hh"
+#include "warn.hh"
+#include "stencil.hh"
+
+LY_DEFINE (ly_make_paper_outputter, "ly:make-paper-outputter",
+          2, 0, 0, (SCM outname, SCM format),
+          "Create an outputter that evaluates within "
+          "@code{output-}@var{format}, writing to file @var{outname}.")
+{
+  SCM_ASSERT_TYPE(scm_is_string (outname), outname, SCM_ARG1, __FUNCTION__,
+                 "String");
+  SCM_ASSERT_TYPE(scm_is_string (format), format, SCM_ARG2, __FUNCTION__,
+                 "String");
+  
+  String outname_str = ly_scm2string (outname);
+  String f = ly_scm2string (format);
+
+  progress_indication (_f ("Layout output to `%s'...",
+                          outname_str == "-"
+                          ? String ("<stdout>")
+                          : outname_str));
+  progress_indication ("\n");
+  Paper_outputter *po = new Paper_outputter (outname_str, f);
+
+  scm_gc_unprotect_object (po->self_scm ());
+  return po->self_scm ();
+}
+
+/* FIXME: why is output_* wrapper called dump?  */
+LY_DEFINE (ly_outputter_dump_stencil, "ly:outputter-dump-stencil",
+          2, 0, 0, (SCM outputter, SCM stencil),
+          "Dump stencil @var{expr} onto @var{outputter}.")
+{
+  Paper_outputter *po = unsmob_outputter (outputter);
+  Stencil *st = unsmob_stencil (stencil);
+  SCM_ASSERT_TYPE (po, outputter, SCM_ARG1, __FUNCTION__, "Paper_outputter");
+  SCM_ASSERT_TYPE (st, stencil, SCM_ARG1, __FUNCTION__, "Paper_outputter");
+  po->output_stencil (*st);
+  return SCM_UNSPECIFIED;
+}
+
+LY_DEFINE (ly_outputter_dump_string, "ly:outputter-dump-string",
+          2, 0, 0, (SCM outputter, SCM str),
+          "Dump @var{str} onto @var{outputter}.")
+{
+  Paper_outputter *po = unsmob_outputter (outputter);
+  SCM_ASSERT_TYPE (po, outputter, SCM_ARG1, __FUNCTION__, "Paper_outputter");
+  SCM_ASSERT_TYPE (scm_is_string (str), str, SCM_ARG1, __FUNCTION__, "Paper_outputter");
+  
+  return po->dump_string (str);
+}
+
+
+LY_DEFINE (ly_outputter_close, "ly:outputter-close",
+          1, 0, 0, (SCM outputter),
+          "Close port of @var{outputter}.")
+{
+  Paper_outputter *po = unsmob_outputter (outputter);
+  SCM_ASSERT_TYPE (po, outputter, SCM_ARG1, __FUNCTION__, "Paper_outputter");
+
+  po->close ();
+  return SCM_UNSPECIFIED;
+}
index 74b2a5b2d05faf053b259f30d789d5e8cad6ad71..9651f5c806b8e095a116c976279dd7bc75ad1968 100644 (file)
@@ -107,66 +107,6 @@ Paper_outputter::output_stencil (Stencil stil)
                                 (void*) this, Offset (0,0));
 }
 
-LY_DEFINE (ly_make_paper_outputter, "ly:make-paper-outputter",
-          2, 0, 0, (SCM outname, SCM format),
-          "Create an outputter that evaluates within "
-          "@code{output-}@var{format}, writing to file @var{outname}.")
-{
-  SCM_ASSERT_TYPE(scm_is_string (outname), outname, SCM_ARG1, __FUNCTION__,
-                 "String");
-  SCM_ASSERT_TYPE(scm_is_string (format), format, SCM_ARG2, __FUNCTION__,
-                 "String");
-  
-  String outname_str = ly_scm2string (outname);
-  String f = ly_scm2string (format);
-
-  progress_indication (_f ("Layout output to `%s'...",
-                          outname_str == "-"
-                          ? String ("<stdout>")
-                          : outname_str));
-  progress_indication ("\n");
-  Paper_outputter *po = new Paper_outputter (outname_str, f);
-
-  scm_gc_unprotect_object (po->self_scm ());
-  return po->self_scm ();
-}
-
-/* FIXME: why is output_* wrapper called dump?  */
-LY_DEFINE (ly_outputter_dump_stencil, "ly:outputter-dump-stencil",
-          2, 0, 0, (SCM outputter, SCM stencil),
-          "Dump stencil @var{expr} onto @var{outputter}.")
-{
-  Paper_outputter *po = unsmob_outputter (outputter);
-  Stencil *st = unsmob_stencil (stencil);
-  SCM_ASSERT_TYPE (po, outputter, SCM_ARG1, __FUNCTION__, "Paper_outputter");
-  SCM_ASSERT_TYPE (st, stencil, SCM_ARG1, __FUNCTION__, "Paper_outputter");
-  po->output_stencil (*st);
-  return SCM_UNSPECIFIED;
-}
-
-LY_DEFINE (ly_outputter_dump_string, "ly:outputter-dump-string",
-          2, 0, 0, (SCM outputter, SCM str),
-          "Dump @var{str} onto @var{outputter}.")
-{
-  Paper_outputter *po = unsmob_outputter (outputter);
-  SCM_ASSERT_TYPE (po, outputter, SCM_ARG1, __FUNCTION__, "Paper_outputter");
-  SCM_ASSERT_TYPE (scm_is_string (str), str, SCM_ARG1, __FUNCTION__, "Paper_outputter");
-  
-  return po->dump_string (str);
-}
-
-
-LY_DEFINE (ly_outputter_close, "ly:outputter-close",
-          1, 0, 0, (SCM outputter),
-          "Close port of @var{outputter}.")
-{
-  Paper_outputter *po = unsmob_outputter (outputter);
-  SCM_ASSERT_TYPE (po, outputter, SCM_ARG1, __FUNCTION__, "Paper_outputter");
-
-  po->close ();
-  return SCM_UNSPECIFIED;
-}
-
 void
 Paper_outputter::close ()
 {
diff --git a/lily/paper-system-scheme.cc b/lily/paper-system-scheme.cc
new file mode 100644 (file)
index 0000000..46f984d
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+  paper-system-scheme.cc --  implement Paper_system bindings
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+*/
+
+#include "paper-system.hh"
+
+LY_DEFINE (ly_paper_system_height, "ly:paper-system-extent",
+          2, 0, 0, (SCM system, SCM axis),
+          "Return the extent of @var{system}.")
+{
+  Paper_system *ps = unsmob_paper_system (system);
+  SCM_ASSERT_TYPE (ps, system, SCM_ARG1, __FUNCTION__, "paper-system");
+  SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG2, __FUNCTION__, "axis");
+  Axis ax = (Axis)scm_to_int (axis);
+  return ly_interval2scm (ps->to_stencil().extent (ax));
+}
+
+
+
+LY_DEFINE (ly_paper_system_title_p, "ly:paper-system-title?",
+          1, 0, 0, (SCM system),
+          "Is  @var{system} a title system?")
+{
+  Paper_system *ps = unsmob_paper_system (system);
+  SCM_ASSERT_TYPE (ps, system, SCM_ARG1, __FUNCTION__, "paper-system");
+  return SCM_BOOL (ps->is_title ());
+}
+
+LY_DEFINE (ly_paper_system_number, "ly:paper-system-number",
+          1, 0, 0, (SCM system),
+          "Return the number of @var{system}.")
+{
+  Paper_system *ps = unsmob_paper_system (system);
+  SCM_ASSERT_TYPE (ps, system, SCM_ARG1, __FUNCTION__, "paper-system");
+  return scm_int2num (ps->number_);
+}
+
+LY_DEFINE (ly_paper_system_break_before_penalty, "ly:paper-system-break-before-penalty",
+          1, 0, 0, (SCM system),
+          "Return the score for page break after @var{system}.")
+{
+  Paper_system *ps = unsmob_paper_system (system);
+  SCM_ASSERT_TYPE (ps, system, SCM_ARG1, __FUNCTION__, "paper-system");
+  return scm_int2num (int (ps->break_before_penalty ()));
+}
+
+LY_DEFINE (ly_paper_system_stencil, "ly:paper-system-stencil",
+          1, 0, 0, (SCM system),
+          "Return the height of @var{system}.")
+{
+  Paper_system *ps = unsmob_paper_system (system);
+  SCM_ASSERT_TYPE (ps, system, SCM_ARG1, __FUNCTION__, "paper-system");
+  return ps->to_stencil ().smobbed_copy ();
+}
+
+
+
+LY_DEFINE (ly_paper_system_staff_extent, "ly:paper-system-staff-extents",
+          1, 0, 0, (SCM system),
+          "Return the top and bottom staff refpoint.")
+{
+  Paper_system *ps = unsmob_paper_system (system);
+  SCM_ASSERT_TYPE (ps, system, SCM_ARG1, __FUNCTION__, "paper-system");
+  return ly_interval2scm (ps->staff_refpoints_);
+}
+
index 49fe5cb0b726e686dd2904665535ccbb92793b70..d20b80cf9e5bbffe69348fe61a7bc2526272a5dc 100644 (file)
@@ -72,64 +72,3 @@ Paper_system::to_stencil () const
 {
   return stencil_;
 }
-
-LY_DEFINE (ly_paper_system_height, "ly:paper-system-extent",
-          2, 0, 0, (SCM system, SCM axis),
-          "Return the extent of @var{system}.")
-{
-  Paper_system *ps = unsmob_paper_system (system);
-  SCM_ASSERT_TYPE (ps, system, SCM_ARG1, __FUNCTION__, "paper-system");
-  SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG2, __FUNCTION__, "axis");
-  Axis ax = (Axis)scm_to_int (axis);
-  return ly_interval2scm (ps->to_stencil().extent (ax));
-}
-
-
-
-LY_DEFINE (ly_paper_system_title_p, "ly:paper-system-title?",
-          1, 0, 0, (SCM system),
-          "Is  @var{system} a title system?")
-{
-  Paper_system *ps = unsmob_paper_system (system);
-  SCM_ASSERT_TYPE (ps, system, SCM_ARG1, __FUNCTION__, "paper-system");
-  return SCM_BOOL (ps->is_title ());
-}
-
-LY_DEFINE (ly_paper_system_number, "ly:paper-system-number",
-          1, 0, 0, (SCM system),
-          "Return the number of @var{system}.")
-{
-  Paper_system *ps = unsmob_paper_system (system);
-  SCM_ASSERT_TYPE (ps, system, SCM_ARG1, __FUNCTION__, "paper-system");
-  return scm_int2num (ps->number_);
-}
-
-LY_DEFINE (ly_paper_system_break_before_penalty, "ly:paper-system-break-before-penalty",
-          1, 0, 0, (SCM system),
-          "Return the score for page break after @var{system}.")
-{
-  Paper_system *ps = unsmob_paper_system (system);
-  SCM_ASSERT_TYPE (ps, system, SCM_ARG1, __FUNCTION__, "paper-system");
-  return scm_int2num (int (ps->break_before_penalty ()));
-}
-
-LY_DEFINE (ly_paper_system_stencil, "ly:paper-system-stencil",
-          1, 0, 0, (SCM system),
-          "Return the height of @var{system}.")
-{
-  Paper_system *ps = unsmob_paper_system (system);
-  SCM_ASSERT_TYPE (ps, system, SCM_ARG1, __FUNCTION__, "paper-system");
-  return ps->to_stencil ().smobbed_copy ();
-}
-
-
-
-LY_DEFINE (ly_paper_system_staff_extent, "ly:paper-system-staff-extents",
-          1, 0, 0, (SCM system),
-          "Return the top and bottom staff refpoint.")
-{
-  Paper_system *ps = unsmob_paper_system (system);
-  SCM_ASSERT_TYPE (ps, system, SCM_ARG1, __FUNCTION__, "paper-system");
-  return ly_interval2scm (ps->staff_refpoints_);
-}
-