return SCM_UNSPECIFIED;
}
+LY_DEFINE (ly_book_add_score_x, "ly:book-add-score!",
+ 2, 0, 0, (SCM book_smob, SCM score),
+ "Add @var{score} to @var{book_smob} score list.")
+{
+ LY_ASSERT_SMOB (Book, book_smob, 1);
+ Book *book = unsmob_book (book_smob);
+ book->add_score (score);
+ return SCM_UNSPECIFIED;
+}
$2->unprotect ();
}
| book_body score_block {
- SCM s = $2->self_scm ();
- $$->add_score (s);
- $2->unprotect();
+ Score *score = $2;
+ SCM proc = PARSER->lexer_->lookup_identifier ("book-score-handler");
+ scm_call_2 (proc, $$->self_scm (), score->self_scm ());
+ score->unprotect ();
+ }
+ | book_body composite_music {
+ Music *music = unsmob_music ($2);
+ SCM proc = PARSER->lexer_->lookup_identifier ("book-music-handler");
+ scm_call_3 (proc, PARSER->self_scm (), $$->self_scm (), music->self_scm ());
}
| book_body full_markup {
- $$->add_score ($2);
+ SCM proc = PARSER->lexer_->lookup_identifier ("book-text-handler");
+ scm_call_2 (proc, $$->self_scm (), $2);
}
| book_body lilypond_header {
$$->header_ = $2;
#(define toplevel-score-handler collect-scores-for-book)
#(define toplevel-text-handler collect-scores-for-book)
+#(define book-music-handler collect-book-music-for-book)
+#(define book-score-handler ly:book-add-score!)
+#(define book-text-handler ly:book-add-score!)
parser 'toplevel-scores
(cons score (ly:parser-lookup parser 'toplevel-scores))))
-(define-public (collect-music-for-book parser music)
+(define (collect-music-aux score-handler parser music)
(define (music-property symbol)
(let ((value (ly:music-property music symbol)))
(if (not (null? value))
(for-each (lambda (symbol)
(let ((permission (music-property symbol)))
(if (symbol? permission)
- (collect-scores-for-book
- parser
+ (score-handler
(ly:make-page-marker symbol
(if (eqv? 'forbid permission)
'()
permission))))))
(list 'line-break-permission 'page-break-permission
- 'page-turn-permission)))
+ 'page-turn-permission)))
((not (music-property 'void))
;; a regular music expression: make a score with this music
;; void music is discarded
- (collect-scores-for-book parser (scorify-music music parser)))))
+ (score-handler (scorify-music music parser)))))
+
+(define-public (collect-music-for-book parser music)
+ "Top-level music handler"
+ (collect-music-aux (lambda (score)
+ (collect-scores-for-book parser score))
+ parser
+ music))
+
+(define-public (collect-book-music-for-book parser book music)
+ "Book music handler"
+ (collect-music-aux (lambda (score)
+ (ly:book-add-score! book score))
+ parser
+ music))
(define-public (scorify-music music parser)
"Preprocess MUSIC."