2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 1997--2015 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"
40 #include "lily-imports.hh"
43 const char * const Paper_outputter::type_p_name_ = 0;
45 Paper_outputter::Paper_outputter (SCM port, const string &format)
48 output_module_ = SCM_EOL;
51 string module_name = "scm output-" + format;
52 output_module_ = scm_c_resolve_module (module_name.c_str ());
55 Enable errors for undefined stencil routines if
56 -dwarning-as-error is specified; else enable warnings.
58 Lily::backend_testing (output_module_);
61 Paper_outputter::~Paper_outputter ()
67 Paper_outputter::mark_smob () const
69 scm_gc_mark (output_module_);
74 Paper_outputter::file () const
80 Paper_outputter::dump_string (SCM scm)
82 return scm_display (scm, file ());
86 Paper_outputter::scheme_to_string (SCM scm)
88 return scm_eval (scm, output_module_);
92 Paper_outputter::module () const
94 return output_module_;
98 Paper_outputter::output_scheme (SCM scm)
100 SCM str = scheme_to_string (scm);
101 if (scm_is_string (str))
107 paper_outputter_dump (void *po, SCM x)
109 Paper_outputter *me = (Paper_outputter *) po;
110 return me->output_scheme (x);
114 Paper_outputter::output_stencil (Stencil stil)
116 interpret_stencil_expression (stil.expr (), paper_outputter_dump,
117 (void *) this, Offset (0, 0));
121 Paper_outputter::close ()
123 if (ly_is_port (file_))
125 scm_close_port (file_);
127 Remove the "warning" definitions for missing stencil
128 expressions so that we start fresh with the next \book
131 Lily::remove_stencil_warnings (output_module_);