2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2005--2011 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"
26 LY_DEFINE (ly_make_paper_outputter
, "ly:make-paper-outputter",
27 2, 0, 0, (SCM port
, SCM format
),
28 "Create an outputter that evaluates within"
29 " @code{output-}@var{format}, writing to @var{port}.")
31 LY_ASSERT_TYPE (ly_is_port
, port
, 1);
32 LY_ASSERT_TYPE (ly_is_symbol
, format
, 2);
34 string f
= ly_symbol2string (format
);
35 string output_name
= "<unknown>";
37 SCM port_name
= scm_port_filename (port
);
38 if (scm_is_string (port_name
))
39 output_name
= ly_scm2string (port_name
);
41 message (_f ("Layout output to `%s'...",
42 output_name
.c_str ()));
44 progress_indication ("\n");
45 Paper_outputter
*po
= new Paper_outputter (port
, f
);
48 return po
->self_scm ();
51 /* FIXME: why is output_* wrapper called dump? */
52 LY_DEFINE (ly_outputter_dump_stencil
, "ly:outputter-dump-stencil",
53 2, 0, 0, (SCM outputter
, SCM stencil
),
54 "Dump stencil @var{expr} onto @var{outputter}.")
57 LY_ASSERT_SMOB (Paper_outputter
, outputter
, 1);
58 LY_ASSERT_SMOB (Stencil
, stencil
, 2);
60 Paper_outputter
*po
= unsmob_outputter (outputter
);
61 Stencil
*st
= unsmob_stencil (stencil
);
63 po
->output_stencil (*st
);
64 return SCM_UNSPECIFIED
;
67 LY_DEFINE (ly_outputter_dump_string
, "ly:outputter-dump-string",
68 2, 0, 0, (SCM outputter
, SCM str
),
69 "Dump @var{str} onto @var{outputter}.")
71 LY_ASSERT_SMOB (Paper_outputter
, outputter
, 1);
72 LY_ASSERT_TYPE (scm_is_string
, str
, 2);
74 Paper_outputter
*po
= unsmob_outputter (outputter
);
76 return po
->dump_string (str
);
79 LY_DEFINE (ly_outputter_port
, "ly:outputter-port",
80 1, 0, 0, (SCM outputter
),
81 "Return output port for @var{outputter}.")
83 LY_ASSERT_SMOB (Paper_outputter
, outputter
, 1);
84 Paper_outputter
*po
= unsmob_outputter (outputter
);
89 LY_DEFINE (ly_outputter_close
, "ly:outputter-close",
90 1, 0, 0, (SCM outputter
),
91 "Close port of @var{outputter}.")
93 LY_ASSERT_SMOB (Paper_outputter
, outputter
, 1);
94 Paper_outputter
*po
= unsmob_outputter (outputter
);
97 return SCM_UNSPECIFIED
;
100 LY_DEFINE (ly_outputter_output_scheme
, "ly:outputter-output-scheme",
101 2, 0, 0, (SCM outputter
, SCM expr
),
102 "Eval @var{expr} in module of @var{outputter}.")
104 LY_ASSERT_SMOB (Paper_outputter
, outputter
, 1);
105 Paper_outputter
*po
= unsmob_outputter (outputter
);
107 po
->output_scheme (expr
);
109 return SCM_UNSPECIFIED
;
112 LY_DEFINE (ly_outputter_module
, "ly:outputter-module",
113 1, 0, 0, (SCM outputter
),
114 "Return output module of @var{outputter}.")
116 LY_ASSERT_SMOB (Paper_outputter
, outputter
, 1);
118 Paper_outputter
*po
= unsmob_outputter (outputter
);
119 return po
->module ();