]> git.donarmstrong.com Git - lilypond.git/blob - lily/paper-outputter-scheme.cc
Issue 4550 (1/2) Avoid "using namespace std;" in included files
[lilypond.git] / lily / paper-outputter-scheme.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2005--2015 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 using std::string;
27
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}.")
32 {
33   LY_ASSERT_TYPE (ly_is_port, port, 1);
34   LY_ASSERT_TYPE (ly_is_symbol, format, 2);
35
36   string f = ly_symbol2string (format);
37   string output_name = "<unknown>";
38
39   SCM port_name = scm_port_filename (port);
40   if (scm_is_string (port_name))
41     output_name = ly_scm2string (port_name);
42
43   message (_f ("Layout output to `%s'...",
44                output_name.c_str ()));
45
46   progress_indication ("\n");
47   Paper_outputter *po = new Paper_outputter (port, f);
48
49   po->unprotect ();
50   return po->self_scm ();
51 }
52
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}.")
57 {
58
59   LY_ASSERT_SMOB (Paper_outputter, outputter, 1);
60   LY_ASSERT_SMOB (Stencil, stencil, 2);
61
62   Paper_outputter *po = unsmob<Paper_outputter> (outputter);
63   Stencil *st = unsmob<Stencil> (stencil);
64
65   po->output_stencil (*st);
66   return SCM_UNSPECIFIED;
67 }
68
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}.")
72 {
73   LY_ASSERT_SMOB (Paper_outputter, outputter, 1);
74   LY_ASSERT_TYPE (scm_is_string, str, 2);
75
76   Paper_outputter *po = unsmob<Paper_outputter> (outputter);
77
78   return po->dump_string (str);
79 }
80
81 LY_DEFINE (ly_outputter_port, "ly:outputter-port",
82            1, 0, 0, (SCM outputter),
83            "Return output port for @var{outputter}.")
84 {
85   LY_ASSERT_SMOB (Paper_outputter, outputter, 1);
86   Paper_outputter *po = unsmob<Paper_outputter> (outputter);
87
88   return po->file ();
89 }
90
91 LY_DEFINE (ly_outputter_close, "ly:outputter-close",
92            1, 0, 0, (SCM outputter),
93            "Close port of @var{outputter}.")
94 {
95   LY_ASSERT_SMOB (Paper_outputter, outputter, 1);
96   Paper_outputter *po = unsmob<Paper_outputter> (outputter);
97
98   po->close ();
99   return SCM_UNSPECIFIED;
100 }
101
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}.")
105 {
106   LY_ASSERT_SMOB (Paper_outputter, outputter, 1);
107   Paper_outputter *po = unsmob<Paper_outputter> (outputter);
108
109   po->output_scheme (expr);
110
111   return SCM_UNSPECIFIED;
112 }
113
114 LY_DEFINE (ly_outputter_module, "ly:outputter-module",
115            1, 0, 0, (SCM outputter),
116            "Return output module of @var{outputter}.")
117 {
118   LY_ASSERT_SMOB (Paper_outputter, outputter, 1);
119
120   Paper_outputter *po = unsmob<Paper_outputter> (outputter);
121   return po->module ();
122 }