]> git.donarmstrong.com Git - lilypond.git/blob - lily/paper-outputter.cc
* scm/output-tex.scm (output-scopes): don't dump fraction exactly.
[lilypond.git] / lily / paper-outputter.cc
1 /*
2   paper-outputter.cc -- implement Paper_outputter
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   Jan Nieuwenhuizen <janneke@gnu.org>
8 */
9
10 #include <time.h>
11 #include <math.h>
12
13 #include "dimensions.hh"
14 #include "virtual-methods.hh"
15 #include "paper-outputter.hh"
16 #include "stencil.hh"
17 #include "array.hh"
18 #include "string-convert.hh"
19 #include "warn.hh"
20 #include "font-metric.hh"
21 #include "main.hh"
22 #include "scm-hash.hh"
23 #include "lily-version.hh"
24 #include "paper-def.hh"
25 #include "input-file-results.hh"
26 #include "ly-modules.hh"
27
28
29 Paper_outputter::Paper_outputter (String name)
30 {
31   if (safe_global_b)
32     {
33       gh_define ("security-paranoia", SCM_BOOL_T);      
34     }
35   
36   file_ = scm_open_file (scm_makfrom0str (name.to_str0 ()),
37                             scm_makfrom0str ("w"));
38
39   static SCM find_dumper;
40   if (!find_dumper)
41     find_dumper = scm_c_eval_string ("find-dumper");
42
43   
44   output_func_ = scm_call_1 (find_dumper,scm_makfrom0str (output_format_global.to_str0 ()));
45   output_scheme (gh_cons (ly_symbol2scm ("top-of-file"), SCM_EOL));
46 }
47
48 Paper_outputter::~Paper_outputter ()
49 {
50   scm_close_port (file_);
51   file_ = SCM_EOL;
52 }
53
54 void
55 Paper_outputter::output_scheme (SCM scm)
56 {
57   gh_call2 (output_func_, scm, file_);
58 }
59
60 void
61 Paper_outputter::output_metadata (SCM scopes)
62 {
63   SCM fields = SCM_EOL;
64   for (int i = dump_header_fieldnames_global.size (); i--;)
65     fields = gh_cons (ly_symbol2scm (dump_header_fieldnames_global[i].to_str0 ()),
66                                      fields);
67   
68   output_scheme (scm_list_n (ly_symbol2scm ("output-scopes"),
69                              scm_list_n (ly_symbol2scm ("quote"),
70                                          scopes, SCM_UNDEFINED),
71                              scm_list_n (ly_symbol2scm ("quote"),
72                                          fields, SCM_UNDEFINED),
73                              scm_makfrom0str (basename_.to_str0 ()), 
74                              SCM_UNDEFINED));
75 }
76
77
78 void
79 Paper_outputter::output_music_output_def (Music_output_def* odef)
80 {
81   output_scheme (scm_list_n (ly_symbol2scm ("output-paper-def"),
82                              odef->self_scm (), SCM_UNDEFINED));
83 }