2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 1997--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
5 Jan Nieuwenhuizen <janneke@gnu.org>
7 LilyPond is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 LilyPond is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
21 #include "paper-outputter.hh"
28 #include "dimensions.hh"
29 #include "file-name.hh"
30 #include "font-metric.hh"
32 #include "lily-version.hh"
34 #include "output-def.hh"
35 #include "paper-book.hh"
36 #include "paper-system.hh"
37 #include "scm-hash.hh"
38 #include "string-convert.hh"
41 #include "ly-smobs.icc"
43 Paper_outputter::Paper_outputter (SCM port
, string format
)
46 output_module_
= SCM_EOL
;
49 string module_name
= "scm output-" + format
;
50 output_module_
= scm_c_resolve_module (module_name
.c_str ());
53 Enable errors for undefined stencil routines if
54 -dwarning-as-error is specified; else enable warnings.
56 SCM proc
= ly_lily_module_constant ("backend-testing");
57 scm_call_1 (proc
, output_module_
);
60 Paper_outputter::~Paper_outputter ()
64 IMPLEMENT_SMOBS (Paper_outputter
);
65 IMPLEMENT_DEFAULT_EQUAL_P (Paper_outputter
);
68 Paper_outputter::mark_smob (SCM x
)
70 Paper_outputter
*p
= (Paper_outputter
*) SCM_CELL_WORD_1 (x
);
71 scm_gc_mark (p
->output_module_
);
76 Paper_outputter::print_smob (SCM
/* x */,
80 scm_puts ("#<Paper_outputter>", p
);
85 Paper_outputter::file () const
91 Paper_outputter::dump_string (SCM scm
)
93 return scm_display (scm
, file ());
97 Paper_outputter::scheme_to_string (SCM scm
)
99 return scm_eval (scm
, output_module_
);
103 Paper_outputter::module () const
105 return output_module_
;
109 Paper_outputter::output_scheme (SCM scm
)
111 dump_string (scheme_to_string (scm
));
115 paper_outputter_dump (void *po
, SCM x
)
117 Paper_outputter
*me
= (Paper_outputter
*) po
;
118 me
->output_scheme (x
);
122 Paper_outputter::output_stencil (Stencil stil
)
124 interpret_stencil_expression (stil
.expr (), paper_outputter_dump
,
125 (void *) this, Offset (0, 0));
129 Paper_outputter::close ()
131 if (scm_port_p (file_
) == SCM_BOOL_T
)
133 scm_close_port (file_
);
135 Remove the "warning" definitions for missing stencil
136 expressions so that we start fresh with the next \book
139 SCM proc
= ly_lily_module_constant ("remove-stencil-warnings");
140 scm_call_1 (proc
, output_module_
);