Fixes Issue 1504, allowing feather beam line breaking.
[lilypond/patrick.git] / lily / paper-outputter.cc
blobe08cbd6590ea870c2e357b16943490a45f5fa25f
1 /*
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"
23 #include <cmath>
24 #include <ctime>
26 using namespace std;
28 #include "dimensions.hh"
29 #include "file-name.hh"
30 #include "font-metric.hh"
31 #include "input.hh"
32 #include "lily-version.hh"
33 #include "main.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"
39 #include "warn.hh"
41 #include "ly-smobs.icc"
43 Paper_outputter::Paper_outputter (SCM port, string format)
45 file_ = port;
46 output_module_ = SCM_EOL;
47 smobify_self ();
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);
67 SCM
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_);
72 return p->file_;
75 int
76 Paper_outputter::print_smob (SCM /* x */,
77 SCM p,
78 scm_print_state *)
80 scm_puts ("#<Paper_outputter>", p);
81 return 1;
84 SCM
85 Paper_outputter::file () const
87 return file_;
90 SCM
91 Paper_outputter::dump_string (SCM scm)
93 return scm_display (scm, file ());
96 SCM
97 Paper_outputter::scheme_to_string (SCM scm)
99 return scm_eval (scm, output_module_);
103 Paper_outputter::module () const
105 return output_module_;
108 void
109 Paper_outputter::output_scheme (SCM scm)
111 dump_string (scheme_to_string (scm));
114 void
115 paper_outputter_dump (void *po, SCM x)
117 Paper_outputter *me = (Paper_outputter *) po;
118 me->output_scheme (x);
121 void
122 Paper_outputter::output_stencil (Stencil stil)
124 interpret_stencil_expression (stil.expr (), paper_outputter_dump,
125 (void *) this, Offset (0, 0));
128 void
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
137 block. --pmccarty
139 SCM proc = ly_lily_module_constant ("remove-stencil-warnings");
140 scm_call_1 (proc, output_module_);