]> git.donarmstrong.com Git - lilypond.git/blob - lily/paper-outputter-scheme.cc
unsmob_pitch -> Pitch::unsmob and related
[lilypond.git] / lily / paper-outputter-scheme.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2005--2014 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
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.
10
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.
15
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/>.
18 */
19
20 #include "paper-outputter.hh"
21
22 #include "international.hh"
23 #include "stencil.hh"
24 #include "warn.hh"
25
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}.")
30 {
31   LY_ASSERT_TYPE (ly_is_port, port, 1);
32   LY_ASSERT_TYPE (ly_is_symbol, format, 2);
33
34   string f = ly_symbol2string (format);
35   string output_name = "<unknown>";
36
37   SCM port_name = scm_port_filename (port);
38   if (scm_is_string (port_name))
39     output_name = ly_scm2string (port_name);
40
41   message (_f ("Layout output to `%s'...",
42                output_name.c_str ()));
43
44   progress_indication ("\n");
45   Paper_outputter *po = new Paper_outputter (port, f);
46
47   po->unprotect ();
48   return po->self_scm ();
49 }
50
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}.")
55 {
56
57   LY_ASSERT_SMOB (Paper_outputter, outputter, 1);
58   LY_ASSERT_SMOB (Stencil, stencil, 2);
59
60   Paper_outputter *po = Paper_outputter::unsmob (outputter);
61   Stencil *st = Stencil::unsmob (stencil);
62
63   po->output_stencil (*st);
64   return SCM_UNSPECIFIED;
65 }
66
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}.")
70 {
71   LY_ASSERT_SMOB (Paper_outputter, outputter, 1);
72   LY_ASSERT_TYPE (scm_is_string, str, 2);
73
74   Paper_outputter *po = Paper_outputter::unsmob (outputter);
75
76   return po->dump_string (str);
77 }
78
79 LY_DEFINE (ly_outputter_port, "ly:outputter-port",
80            1, 0, 0, (SCM outputter),
81            "Return output port for @var{outputter}.")
82 {
83   LY_ASSERT_SMOB (Paper_outputter, outputter, 1);
84   Paper_outputter *po = Paper_outputter::unsmob (outputter);
85
86   return po->file ();
87 }
88
89 LY_DEFINE (ly_outputter_close, "ly:outputter-close",
90            1, 0, 0, (SCM outputter),
91            "Close port of @var{outputter}.")
92 {
93   LY_ASSERT_SMOB (Paper_outputter, outputter, 1);
94   Paper_outputter *po = Paper_outputter::unsmob (outputter);
95
96   po->close ();
97   return SCM_UNSPECIFIED;
98 }
99
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}.")
103 {
104   LY_ASSERT_SMOB (Paper_outputter, outputter, 1);
105   Paper_outputter *po = Paper_outputter::unsmob (outputter);
106
107   po->output_scheme (expr);
108
109   return SCM_UNSPECIFIED;
110 }
111
112 LY_DEFINE (ly_outputter_module, "ly:outputter-module",
113            1, 0, 0, (SCM outputter),
114            "Return output module of @var{outputter}.")
115 {
116   LY_ASSERT_SMOB (Paper_outputter, outputter, 1);
117
118   Paper_outputter *po = Paper_outputter::unsmob (outputter);
119   return po->module ();
120 }