From: Han-Wen Nienhuys Date: Tue, 19 Feb 2008 03:22:31 +0000 (-0300) Subject: Encapsulate Score::header_ , and provide scheme binding for setting it. X-Git-Tag: release/2.11.41-1~38^2 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=94723aaac3a287339d4885336b38933c83d0dbf7;p=lilypond.git Encapsulate Score::header_ , and provide scheme binding for setting it. --- diff --git a/lily/book.cc b/lily/book.cc index 2a1038941b..335507601d 100644 --- a/lily/book.cc +++ b/lily/book.cc @@ -146,8 +146,8 @@ Book::process (Output_def *default_paper, paper_book->add_performance (perf->self_scm ()); else if (Paper_score *pscore = dynamic_cast (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 ()); } diff --git a/lily/include/score.hh b/lily/include/score.hh index d4f26da4d2..4f1933c8b5 100644 --- a/lily/include/score.hh +++ b/lily/include/score.hh @@ -22,12 +22,12 @@ class Score SCM music_; SCM input_location_; + SCM header_; public: Input *origin() const; vector 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); diff --git a/lily/parser.yy b/lily/parser.yy index 8fc0a89c1b..3b690e8980 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -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) diff --git a/lily/score-scheme.cc b/lily/score-scheme.cc index d52b25f096..2d54670650 100644 --- a/lily/score-scheme.cc +++ b/lily/score-scheme.cc @@ -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 (); } diff --git a/lily/score.cc b/lily/score.cc index 5b11a0d427..6e1a9ff3e0 100644 --- a/lily/score.cc +++ b/lily/score.cc @@ -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; +}