]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/score.cc (default_rendering): Protect paper-book members.
authorJan Nieuwenhuizen <janneke@gnu.org>
Tue, 9 Mar 2004 22:35:48 +0000 (22:35 +0000)
committerJan Nieuwenhuizen <janneke@gnu.org>
Tue, 9 Mar 2004 22:35:48 +0000 (22:35 +0000)
* lily/paper-def.cc (smobbed_copy): New method.

ChangeLog
lily/include/paper-book.hh
lily/include/paper-def.hh
lily/input-file-results.cc
lily/lexer.ll
lily/paper-book.cc
lily/paper-def.cc
lily/parser.yy
lily/score.cc
scm/output-ps.scm

index 7fe6375e3aff25665e7db412a8f941d1bb0243de..244859490ab69c5b1f297e847476c6bfff33626e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2004-03-09  Jan Nieuwenhuizen  <janneke@gnu.org>
 
+       * lily/score.cc (default_rendering): Protect paper-book members.
+
+       * lily/paper-def.cc (smobbed_copy): New method.
+
        * lily/include/paper-book.hh (PAGE_LAYOUT): Define as "ps"; make
        switch runtime.
 
index 0a18454979cf902d3512506db329aa849adedc9d..1f481c2dd40114b8bced83baaff7e92d117b8041 100644 (file)
 #include "lily-guile.hh"
 #include "parray.hh"
 #include "protected-scm.hh"
+#include "smobs.hh"
 
 #define PAGE_LAYOUT "ps"
 
 class Paper_book
 {
 public:
+  Protected_scm protect_;
   Array<SCM> headers_;
+  Array<SCM> global_headers_;
   Link_array<Paper_def> papers_;
   Array<SCM> scores_;
 
@@ -28,7 +31,14 @@ public:
   Stencil* get_title (int);
   void output (String);
   void classic_output (String);
+
+  SCM smobbed_copy () const;
+
+private:
+  DECLARE_SIMPLE_SMOBS (Paper_book, )
 };
 
+DECLARE_UNSMOB (Paper_book, paper_book)
+
 #endif /* PAPER_BOOK_HH */
 
index aad477aaf43c3ffa8c0573ba5c7fa9eba15fe0da..06b9761e7978243f0c805b3da08c25581ce6f2db 100644 (file)
@@ -49,31 +49,28 @@ protected:
   VIRTUAL_COPY_CONSTRUCTOR (Music_output_def, Paper_def);
 
 public:    
-  Paper_outputter* get_paper_outputter (String)  const;
-
-  SCM font_descriptions ()const;
-  virtual ~Paper_def ();
   static int score_count_;
   
-  /*
-    JUNKME
-   */
-  Real get_realvar (SCM symbol) const;
-  void reinit ();
   Paper_def ();
   Paper_def (Paper_def const&);
-
+  virtual ~Paper_def ();
+  
+  Paper_outputter* get_paper_outputter (String) const;
+  SCM font_descriptions () const;
+  void reinit ();
   Interval line_dimensions_int (int) const;
-
   void output_settings (Paper_outputter*) const;
-
-  Font_metric * find_font (SCM name, Real mag);
+  Font_metric *find_font (SCM name, Real mag);
+  
+  /* JUNKME   */
+  Real get_realvar (SCM symbol) const;
+  
+  SCM smobbed_copy () const;
   
-  // urg
   friend int yyparse (void*);
 };
 
 Paper_def * unsmob_paper (SCM x);
 Font_metric *select_font (Paper_def *paper, SCM chain);
 
-#endif // Paper_def_HH
+#endif /* PAPER_DEF_HH */
index 17a67cba57f16716a7a0602960dc4aea41f1aa3d..05729cf669faa9f41cd014d614a963aafa2b1124 100644 (file)
@@ -123,7 +123,7 @@ Input_file_results::~Input_file_results ()
   if (header_)
     header_ = SCM_EOL;
 
-  global_input_file =0;
+  global_input_file = 0;
 
   ly_clear_anonymous_modules ();
 }
index 70e62160f91002ba4777cce7f530d6c63210ee5d..ea5ed739e491d5ddd6bc09801bdc6e500272ab53 100644 (file)
@@ -230,7 +230,7 @@ HYPHEN              --
        String s (YYText ()+1);
        s = s.left_string (s.index_last ('"'));
 
-       new_input (s, &global_input_file->sources_ );
+       new_input (s, &global_input_file->sources_);
        yy_pop_state ();
 }
 <incl>\\{BLACK}*;?{WHITE} { /* got the include identifier */
index 0aa137a6b7a8778a09eb00b40f0165fecd005612..0394a1c3c92df147c20a8b8ccafb65146ce63183 100644 (file)
@@ -8,7 +8,6 @@
 
 #include <stdio.h>
 
-#include "input-file-results.hh"
 #include "ly-module.hh"
 #include "main.hh"
 #include "paper-book.hh"
@@ -85,6 +84,7 @@ Paper_book *paper_book;
 
 Paper_book::Paper_book ()
 {
+  protect_ = SCM_EOL;
 }
 
 void
@@ -110,8 +110,8 @@ Paper_book::get_scopes (int i)
   SCM scopes = SCM_EOL;
   if (headers_[i])
     scopes = scm_cons (headers_[i], scopes);
-  if (global_input_file->header_ && global_input_file->header_ != headers_[i])
-    scopes = scm_cons (global_input_file->header_, scopes);
+  if (global_headers_[i] && global_headers_[i] != headers_[i])
+    scopes = scm_cons (global_headers_[i], scopes);
   return scopes;
 }
 
@@ -231,3 +231,36 @@ Paper_book::classic_output (String outname)
   out->output_scheme (scm_list_1 (ly_symbol2scm ("end-output")));
   progress_indication ("\n");
 }
+
+
+#include "ly-smobs.icc"
+
+IMPLEMENT_DEFAULT_EQUAL_P (Paper_book);
+IMPLEMENT_SIMPLE_SMOBS (Paper_book)
+IMPLEMENT_TYPE_P (Paper_book, "ly:paper_book?")
+
+SCM
+Paper_book::mark_smob (SCM)
+{
+  return SCM_EOL;
+}
+
+int
+Paper_book::print_smob (SCM smob, SCM port, scm_print_state*)
+{
+  Paper_book *b = (Paper_book*) ly_cdr (smob);
+     
+  scm_puts ("#<", port);
+  scm_puts (classname (b), port);
+  scm_puts (" ", port);
+  //scm_puts (b->, port);
+  scm_puts (">", port);
+  return 1;
+}
+
+SCM
+Paper_book::smobbed_copy () const
+{
+  Paper_book *b = new Paper_book (*this);
+  return b->smobbed_self ();
+}
index 3d325428682c1446c1e9e2fea54cb4c4cfcfaabe..198cd00e6ed4adab5f7bc6bc5d1b944b062c01ed 100644 (file)
@@ -150,4 +150,10 @@ unsmob_paper (SCM x)
   return dynamic_cast<Paper_def*> (unsmob_music_output_def (x));
 }
 
+SCM
+Paper_def::smobbed_copy () const
+{
+  Paper_def *p = new Paper_def (*this);
+  return p->smobbed_self ();
+}
   
index fed1f4469c3fd894d448e93067bc9e94f8972f08..d60f1f6590709db0e742257ddd843ba405cee266 100644 (file)
@@ -492,7 +492,7 @@ lilypond_header_body:
 
 lilypond_header:
        HEADER '{' lilypond_header_body '}'     {
-               $$ = THIS->lexer_-> remove_scope ();
+               $$ = THIS->lexer_->remove_scope ();
        }
        ;
 
index a83573b7b21e229761a172a21fe71d556f9c2ccd..089d4b5df1ed41970e9818fba09cdcda1ea04477 100644 (file)
@@ -24,6 +24,7 @@
 #include "ly-module.hh"
 #include "paper-book.hh"
 #include "paper-score.hh"
+#include "input-file-results.hh"
 
 
 /*
@@ -174,10 +175,19 @@ default_rendering (SCM music, SCM outdef, SCM header, SCM outname)
       Music_output *output = g->get_output ();
       if (systems != SCM_UNDEFINED)
        {
-         paper_book->scores_.push (systems);
-         paper_book->headers_.push (header);
          Paper_score *ps = dynamic_cast<Paper_score*> (output);
+         // Hmmr
+         paper_book->protect_ = scm_cons (systems, paper_book->protect_);
+         paper_book->protect_ = scm_cons (global_input_file->header_,
+                                          paper_book->protect_);
+         paper_book->protect_ = scm_cons (header, paper_book->protect_);
+         paper_book->protect_ = scm_cons (ps->paper_->smobbed_copy (),
+                                          paper_book->protect_);
+
          paper_book->papers_.push (ps->paper_);
+         paper_book->scores_.push (systems);
+         paper_book->global_headers_.push (global_input_file->header_);
+         paper_book->headers_.push (header);
          if (output_format_global != PAGE_LAYOUT)
            paper_book->classic_output (ly_scm2string (outname));
        }
index 7553e2f1de4a357eca3fbfeb2979172bed41609a..ffc971cc8fd02512f5eb531e97d36d2a6f502f42 100644 (file)
          (begin
            (ly:warn
             (format "Programming error: No such font: ~S" name-mag-pair))
+           (write font-name-alist)
            ""))))
   
   (string-append (select-font name-mag-pair) exp))