]> git.donarmstrong.com Git - lilypond.git/commitdiff
Encapsulate Score::header_ , and provide scheme binding for setting it.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Tue, 19 Feb 2008 03:22:31 +0000 (00:22 -0300)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Tue, 19 Feb 2008 03:22:31 +0000 (00:22 -0300)
lily/book.cc
lily/include/score.hh
lily/parser.yy
lily/score-scheme.cc
lily/score.cc

index 2a1038941b8e630904c2f4abce75174991f966c4..335507601d37fc46d3e1fa381e904b4b27421f82 100644 (file)
@@ -146,8 +146,8 @@ Book::process (Output_def *default_paper,
                paper_book->add_performance (perf->self_scm ());
              else if (Paper_score *pscore = dynamic_cast<Paper_score *> (output))
                {
-                 if (ly_is_module (score->header_))
-                   paper_book->add_score (score->header_);
+                 if (ly_is_module (score->get_header ()))
+                   paper_book->add_score (score->get_header ());
                  paper_book->add_score (pscore->self_scm ());
                }
 
index d4f26da4d22c5227b87aae787cf2e0904dda3fb1..4f1933c8b537efc504b1bcd44b5a00b9ed17d062 100644 (file)
@@ -22,12 +22,12 @@ class Score
 
   SCM music_;
   SCM input_location_;
+  SCM header_;
 public:
   Input *origin() const;
  
   vector<Output_def*> defs_;
   string user_key_;
-  SCM header_;
   bool error_found_;
 
   Score ();
@@ -39,6 +39,8 @@ public:
   void add_output_def (Output_def *def);
   void set_music (SCM music);
   SCM book_rendering (Output_def *, Output_def *);
+  SCM get_header () const;
+  void set_header (SCM module);
 };
 
 DECLARE_UNSMOB (Score, score);
index 8fc0a89c1b417a394c9f027eb0f756baf4d49dca..3b690e8980890b7ef3900723e8bf97ec8b6c7c60 100644 (file)
@@ -720,7 +720,7 @@ score_body:
                $$->user_key_ = ly_scm2string ($2);
        }
        | score_body lilypond_header    {
-               $$->header_ = $2;
+               $$->set_header ($2);
        }
        | score_body output_def {
                if ($2->lookup_variable (ly_symbol2scm ("is-paper")) == SCM_BOOL_T)
index d52b25f0961b90b88b7138aaab1cb9456d23d8dc..2d546706502c81367caab29d3bf1546aadf04392 100644 (file)
@@ -59,7 +59,20 @@ LY_DEFINE (ly_score_header, "ly:score-header",
 {
   LY_ASSERT_SMOB (Score, score, 1);
   Score *sc = unsmob_score (score);
-  return sc->header_;
+  return sc->get_header ();
+}
+
+
+LY_DEFINE (ly_score_set_header_x, "ly:score-set-header!",
+          2, 0, 0, (SCM score, SCM module),
+          "Set the score header.")
+{
+  LY_ASSERT_SMOB (Score, score, 1);
+  SCM_ASSERT_TYPE (ly_is_module (module), module, SCM_ARG2, __FUNCTION__,
+                  "module");
+  
+  Score *sc = unsmob_score (score);
+  return sc->get_header ();
 }
 
 
index 5b11a0d4271b34534a809ce84f1ac68183278c83..6e1a9ff3e0d1f9af30063b2f5ec9322f77fa2f77 100644 (file)
@@ -193,3 +193,16 @@ Score::add_output_def (Output_def *def)
 {
   defs_.push_back (def);
 }
+
+SCM
+Score::get_header () const
+{
+  return header_;
+}
+
+void
+Score::set_header (SCM module)
+{
+  assert (ly_is_module (module));
+  header_ = module;
+}