X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fpaper-outputter-scheme.cc;h=706ef0a1f7329009bebe6faf9e3aa5d37901fc31;hb=75482cfd6b33d261633cdff0e81e19cde090c5d2;hp=4c61c6df5e8324f841d0c1d7086e480ef8b7f104;hpb=f0fbdbd14441baade7e044c094d8c620f73d8dda;p=lilypond.git diff --git a/lily/paper-outputter-scheme.cc b/lily/paper-outputter-scheme.cc index 4c61c6df5e..706ef0a1f7 100644 --- a/lily/paper-outputter-scheme.cc +++ b/lily/paper-outputter-scheme.cc @@ -1,10 +1,9 @@ /* - paper-outputter-scheme.cc -- implement Paper_outputter bindings + paper-outputter-scheme.cc -- implement Paper_outputter bindings source file of the GNU LilyPond music typesetter (c) 2005 Han-Wen Nienhuys - */ #include "paper-outputter.hh" @@ -12,26 +11,30 @@ #include "stencil.hh" LY_DEFINE (ly_make_paper_outputter, "ly:make-paper-outputter", - 2, 0, 0, (SCM outname, SCM format), + 2, 0, 0, (SCM port, SCM format), "Create an outputter that evaluates within " - "@code{output-}@var{format}, writing to file @var{outname}.") + "@code{output-}@var{format}, writing to @var{port}.") { - 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); + SCM_ASSERT_TYPE (ly_is_port (port), port, SCM_ARG1, __FUNCTION__, + "port"); + SCM_ASSERT_TYPE (scm_is_string (format), format, SCM_ARG2, __FUNCTION__, + "String"); + String f = ly_scm2string (format); - progress_indication (_f ("Layout output to `%s'...", - outname_str == "-" - ? String ("") - : outname_str)); + String output_name = ""; + + SCM port_name = scm_port_filename (port); + if (scm_is_string (port_name)) + output_name = ly_scm2string (port_name); + + message (_f ("Layout output to `%s'...", + output_name.to_str0 ())); + progress_indication ("\n"); - Paper_outputter *po = new Paper_outputter (outname_str, f); + Paper_outputter *po = new Paper_outputter (port, f); - scm_gc_unprotect_object (po->self_scm ()); + po->unprotect (); return po->self_scm (); } @@ -55,18 +58,17 @@ LY_DEFINE (ly_outputter_dump_string, "ly:outputter-dump-string", 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_port, "ly:outputter-port", 1, 0, 0, (SCM outputter), "Return output port for @var{outputter}.") { Paper_outputter *po = unsmob_outputter (outputter); SCM_ASSERT_TYPE (po, outputter, SCM_ARG1, __FUNCTION__, "Paper_outputter"); - + return po->file (); } @@ -80,3 +82,15 @@ LY_DEFINE (ly_outputter_close, "ly:outputter-close", po->close (); return SCM_UNSPECIFIED; } + +LY_DEFINE (ly_outputter_output_scheme, "ly:outputter-output-scheme", + 2, 0, 0, (SCM outputter, SCM expr), + "Eval @var{expr} in module of @var{outputter}.") +{ + Paper_outputter *po = unsmob_outputter (outputter); + SCM_ASSERT_TYPE (po, outputter, SCM_ARG1, __FUNCTION__, "Paper_outputter"); + + po->output_scheme (expr); + + return SCM_UNSPECIFIED; +}