2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2005--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
20 #include "paper-outputter.hh"
22 #include "international.hh"
28 LY_DEFINE (ly_make_paper_outputter, "ly:make-paper-outputter",
29 2, 0, 0, (SCM port, SCM format),
30 "Create an outputter that evaluates within"
31 " @code{output-}@var{format}, writing to @var{port}.")
33 LY_ASSERT_TYPE (ly_is_port, port, 1);
34 LY_ASSERT_TYPE (ly_is_symbol, format, 2);
36 string f = ly_symbol2string (format);
37 string output_name = "<unknown>";
39 SCM port_name = scm_port_filename (port);
40 if (scm_is_string (port_name))
41 output_name = ly_scm2string (port_name);
43 message (_f ("Layout output to `%s'...",
44 output_name.c_str ()));
46 progress_indication ("\n");
47 Paper_outputter *po = new Paper_outputter (port, f);
50 return po->self_scm ();
53 /* FIXME: why is output_* wrapper called dump? */
54 LY_DEFINE (ly_outputter_dump_stencil, "ly:outputter-dump-stencil",
55 2, 0, 0, (SCM outputter, SCM stencil),
56 "Dump stencil @var{expr} onto @var{outputter}.")
59 LY_ASSERT_SMOB (Paper_outputter, outputter, 1);
60 LY_ASSERT_SMOB (Stencil, stencil, 2);
62 Paper_outputter *po = unsmob<Paper_outputter> (outputter);
63 Stencil *st = unsmob<Stencil> (stencil);
65 po->output_stencil (*st);
66 return SCM_UNSPECIFIED;
69 LY_DEFINE (ly_outputter_dump_string, "ly:outputter-dump-string",
70 2, 0, 0, (SCM outputter, SCM str),
71 "Dump @var{str} onto @var{outputter}.")
73 LY_ASSERT_SMOB (Paper_outputter, outputter, 1);
74 LY_ASSERT_TYPE (scm_is_string, str, 2);
76 Paper_outputter *po = unsmob<Paper_outputter> (outputter);
78 return po->dump_string (str);
81 LY_DEFINE (ly_outputter_port, "ly:outputter-port",
82 1, 0, 0, (SCM outputter),
83 "Return output port for @var{outputter}.")
85 LY_ASSERT_SMOB (Paper_outputter, outputter, 1);
86 Paper_outputter *po = unsmob<Paper_outputter> (outputter);
91 LY_DEFINE (ly_outputter_close, "ly:outputter-close",
92 1, 0, 0, (SCM outputter),
93 "Close port of @var{outputter}.")
95 LY_ASSERT_SMOB (Paper_outputter, outputter, 1);
96 Paper_outputter *po = unsmob<Paper_outputter> (outputter);
99 return SCM_UNSPECIFIED;
102 LY_DEFINE (ly_outputter_output_scheme, "ly:outputter-output-scheme",
103 2, 0, 0, (SCM outputter, SCM expr),
104 "Eval @var{expr} in module of @var{outputter}.")
106 LY_ASSERT_SMOB (Paper_outputter, outputter, 1);
107 Paper_outputter *po = unsmob<Paper_outputter> (outputter);
109 po->output_scheme (expr);
111 return SCM_UNSPECIFIED;
114 LY_DEFINE (ly_outputter_module, "ly:outputter-module",
115 1, 0, 0, (SCM outputter),
116 "Return output module of @var{outputter}.")
118 LY_ASSERT_SMOB (Paper_outputter, outputter, 1);
120 Paper_outputter *po = unsmob<Paper_outputter> (outputter);
121 return po->module ();