]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/paper-outputter.cc
Merge branch 'lilypond/translation' of ssh://git.sv.gnu.org/srv/git/lilypond into...
[lilypond.git] / lily / paper-outputter.cc
index 5da3ca0607ed7b1981632248a261f480f77e0ce3..d366426093afcd737672c2cd38a6f46a93360303 100644 (file)
@@ -3,19 +3,21 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1997--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
   Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
 #include "paper-outputter.hh"
 
-#include <math.h>
+#include <cmath>
 #include <ctime>
 
+using namespace std;
+
 #include "dimensions.hh"
 #include "file-name.hh"
 #include "font-metric.hh"
-#include "input-smob.hh"
+#include "input.hh"
 #include "lily-version.hh"
 #include "main.hh"
 #include "output-def.hh"
 
 #include "ly-smobs.icc"
 
-Paper_outputter::Paper_outputter (String file_name, String format)
+Paper_outputter::Paper_outputter (SCM port, string format)
 {
-  file_ = SCM_EOL;
+  file_ = port;
   output_module_ = SCM_EOL;
   smobify_self ();
 
-  file_name_ = file_name;
-  String module_name = "scm output-" + format;
-  output_module_ = scm_c_resolve_module (module_name.to_str0 ());
+  string module_name = "scm output-" + format;
+  output_module_ = scm_c_resolve_module (module_name.c_str ());
+
+  /*
+    Enable errors for undefined stencil routines if
+     -dwarning-as-error is specified; else enable warnings.
+  */
+  SCM proc = ly_lily_module_constant ("backend-testing");
+  scm_call_1 (proc, output_module_);
 }
 
 Paper_outputter::~Paper_outputter ()
@@ -54,22 +62,17 @@ Paper_outputter::mark_smob (SCM x)
 }
 
 int
-Paper_outputter::print_smob (SCM x, SCM p, scm_print_state*)
+Paper_outputter::print_smob (SCM /* x */,
+                            SCM p,
+                            scm_print_state *)
 {
-  (void) x;
   scm_puts ("#<Paper_outputter>", p);
   return 1;
 }
 
 SCM
-Paper_outputter::file ()
+Paper_outputter::file () const
 {
-  if (file_ == SCM_EOL)
-    if (file_name_ == "-")
-      file_ = scm_current_output_port ();
-    else
-      file_ = scm_open_file (scm_makfrom0str (file_name_.to_str0 ()),
-                            scm_makfrom0str ("w"));
   return file_;
 }
 
@@ -109,5 +112,14 @@ void
 Paper_outputter::close ()
 {
   if (scm_port_p (file_) == SCM_BOOL_T)
-    scm_close_port (file_);
+    {
+      scm_close_port (file_);
+      /*
+       Remove the "warning" definitions for missing stencil
+       expressions so that we start fresh with the next \book
+       block.  --pmccarty
+      */
+      SCM proc = ly_lily_module_constant ("remove-stencil-warnings");
+      scm_call_1 (proc, output_module_);
+    }
 }