--- /dev/null
+/*
+ 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 ());
+}
/*
- global-translator.cc -- implement global_context
+ global-context.cc -- implement Global_context
source file of the GNU LilyPond music typesetter
--- /dev/null
+/*
+ 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;
+}
(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 ()
{
--- /dev/null
+/*
+ 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_);
+}
+
{
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_);
-}
-