]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/paper-outputter.cc
release: 1.1.50
[lilypond.git] / lily / paper-outputter.cc
index 96ba69012f78fb24a8d4891b999c0a0614ae2808..d22f151e1c321245d45f688822f4b76d1ecd8daa 100644 (file)
 #include "lily-version.hh"
 #include "atom.hh"
 
+// urg
+static SCM port = 0;
+
 Paper_outputter::Paper_outputter (Paper_stream *s)
 {
+  port = 0;
   outstream_l_ = s;
   output_header ();
 }
@@ -36,6 +40,16 @@ Paper_outputter::~Paper_outputter ()
 {
   SCM scm = gh_list (ly_symbol ("end-output"), SCM_UNDEFINED);
   output_scheme (scm);
+
+  if (String (output_global_ch) == "scm")
+    {
+#if 1
+      scm_display (gh_str02scm (")))\n"), port);
+      scm_fflush (port);
+#else
+      *outstream_l_->os << ")";
+#endif
+    }
 }
 
 void
@@ -47,7 +61,7 @@ Paper_outputter::output_header ()
       //      gh_eval_str ("(set! security-paranoia #t)");
     }
   String s = String ("(eval (") + output_global_ch + "-scm 'all-definitions))";
-  gh_eval_str (s.ch_C());
+  gh_eval_str (s.ch_C ());
   
   String creator;
   if (no_timestamps_global_b)
@@ -158,7 +172,11 @@ Paper_outputter::output_scheme (SCM scm)
 {
   if (String (output_global_ch) == "scm")
     {
-      static SCM port = 0;
+#if 1
+      /*
+       we'd rather use C++ i/o iso Guile's, but how?
+       and: they can't be mixed (or synchronised) easily?
+       */
 
       // urg
       if (!port)
@@ -169,13 +187,58 @@ Paper_outputter::output_scheme (SCM scm)
            fd = of->rdbuf()->fd();
          FILE *file = fdopen (fd, "a");
          port = scm_standard_stream_to_port (file, "a", "");
-         scm_display (gh_str02scm ("(load 'lily.scm)\n"), port);
+         scm_display (gh_str02scm (
+           "(primitive-load-path 'lily.scm)\n"
+           "(eval (tex-scm 'all-definitions))\n"
+           ";(eval (ps-scm 'all-definitions))\n"
+           "(display (map (lambda (x) (string-append (eval x) \"%\\n\")) '(\n"
+           ), port);
        }
 
-      scm_display (gh_str02scm ("("), port);
       scm_write (scm, port);
-      scm_display (gh_str02scm (")\n"),port);
+      // duh
+      scm_display (gh_str02scm ("\n"), port);
       scm_fflush (port);
+#else
+      static bool first = true;
+      if (first)
+        {
+         *outstream_l_->os << ""
+           "(primitive-load-path 'lily.scm)\n"
+           "(eval (tex-scm 'all-definitions))\n"
+           ";(eval (ps-scm 'all-definitions))\n"
+           "(display (map (lambda (x) (string-append (eval x) \"\\n\")) '(\n"
+           ;
+       }
+
+      /*
+        why doesn't this work?
+
+       ERROR: In procedure gh_scm2newstr:
+       ERROR: Wrong type argument in position 3: 
+         (header "GNU LilyPond 1.1.49.jcn1" ", at Tue Jun 22 20:58:17 1999")
+
+       or:
+
+       ERROR: In procedure symbol->string:
+       ERROR: Wrong type argument in position 1: 
+         (header "GNU LilyPond 1.1.49.jcn2" ", at Wed Jun 23 18:42:14 1999")
+
+       eg, two ways to print '(foo bar)'
+
+        SCM scm = gh_list (ly_symbol ("foo"), gh_str2scm ("bar"), SCM_UNDEFINED);
+       scm_write (scm, port);
+        puts (gh_xxx2newstr (scm, 0));
+       */
+
+      char* p;
+      //p = gh_scm2newstr (scm, 0);
+      //p = gh_symbol2newstr (scm, 0);
+      //p = gh_scm2newstr (scm_symbol_to_string (scm), 0);
+      //p = gh_symbol2newstr (scm_symbol_to_string (scm), 0);
+      //*outstream_l_->os << p << endl;
+      *outstream_l_->os << symbol_to_string (scm) << endl;
+#endif
     }
   else
     {