From 43ef79afba457b819dbcbe0d20ece3a4bab335d4 Mon Sep 17 00:00:00 2001 From: hanwen Date: Tue, 18 May 2004 20:36:31 +0000 Subject: [PATCH] * lily/book-paper-def.cc (Book_paper_def): add copy ctor. * lily/parser.yy (book_paper_head): \bookpaper {} * python/midi.c: remove config.h --- ChangeLog | 8 ++++++++ lily/book-paper-def.cc | 15 +++++++++++++++ lily/include/book-paper-def.hh | 3 ++- lily/my-lily-lexer.cc | 1 + lily/parser.yy | 35 +++++++++++++++++++++++++++++++++- python/midi.c | 1 - 6 files changed, 60 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 05882a70bf..1da1117208 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-05-18 Han-Wen Nienhuys + + * lily/book-paper-def.cc (Book_paper_def): add copy ctor. + + * lily/parser.yy (book_paper_head): \bookpaper {} + + * python/midi.c: remove config.h + 2004-05-18 Jan Nieuwenhuizen * scm/output-gnome.scm: Update. diff --git a/lily/book-paper-def.cc b/lily/book-paper-def.cc index ce9d872554..7aa837dc90 100644 --- a/lily/book-paper-def.cc +++ b/lily/book-paper-def.cc @@ -7,6 +7,7 @@ */ +#include "ly-module.hh" #include "paper-def.hh" #include "dimensions.hh" #include "book-paper-def.hh" @@ -22,8 +23,20 @@ Book_paper_def::Book_paper_def () { output_scale_ = 1.0; scaled_fonts_ = SCM_EOL; + scope_ = SCM_EOL; smobify_self (); scaled_fonts_ = scm_c_make_hash_table (11); + scope_ = ly_make_anonymous_module (false); +} + +Book_paper_def::Book_paper_def (Book_paper_def const & src) +{ + scope_ = SCM_EOL; + scaled_fonts_ = SCM_EOL; + smobify_self (); + scope_= ly_make_anonymous_module (false); + if (is_module (src.scope_)) + ly_import_module (scope_, src.scope_); } Book_paper_def::~Book_paper_def () @@ -34,6 +47,8 @@ SCM Book_paper_def::mark_smob (SCM m) { Book_paper_def *mo = (Book_paper_def*) SCM_CELL_WORD_1 (m); + + scm_gc_mark (mo->scope_); return mo->scaled_fonts_; } diff --git a/lily/include/book-paper-def.hh b/lily/include/book-paper-def.hh index 9482335e1e..144df004a7 100644 --- a/lily/include/book-paper-def.hh +++ b/lily/include/book-paper-def.hh @@ -19,7 +19,8 @@ class Book_paper_def public: VIRTUAL_COPY_CONSTRUCTOR (Book_paper_def, Book_paper_def); - + Book_paper_def(Book_paper_def const &); + SCM scope_; SCM scaled_fonts_; Real output_scale_; diff --git a/lily/my-lily-lexer.cc b/lily/my-lily-lexer.cc index 5acae67b8b..88661b346d 100644 --- a/lily/my-lily-lexer.cc +++ b/lily/my-lily-lexer.cc @@ -31,6 +31,7 @@ static Keyword_ent the_key_tab[] = { {"alternative", ALTERNATIVE}, {"bar", BAR}, {"book", BOOK}, + {"bookpaper", BOOKPAPER}, {"change", CHANGE}, {"chords", CHORDS}, {"clef", CLEF}, diff --git a/lily/parser.yy b/lily/parser.yy index 96b939419b..07562de665 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -194,6 +194,7 @@ of the parse stack onto the heap. */ %union { Book *book; + Book_paper_def *bookpaper; Music_output_def *outputdef; SCM scm; String *string; @@ -249,6 +250,7 @@ or %token ALTERNATIVE %token BAR %token BOOK +%token BOOKPAPER %token CHANGE %token CHORDMODIFIERS %token CHORDS @@ -362,6 +364,8 @@ or %type markup markup_line markup_list markup_list_body full_markup %type book_block book_body +%type book_paper_head book_paper_block book_paper_body + %type exclamations questions dots optional_rest %type bass_mod %type oct_check @@ -477,6 +481,10 @@ toplevel_expression: THIS->lexer_->set_identifier (id, $1->self_scm ()); scm_gc_unprotect_object ($1->self_scm ()); } + | book_paper_block { + THIS->lexer_->set_identifier (scm_makfrom0str ("$defaultbookpaper"), $1->self_scm ()); + scm_gc_unprotect_object ($1->self_scm ()); + } ; toplevel_music: @@ -606,6 +614,26 @@ context_def_spec_body: } ; + +book_paper_block: + book_paper_body '}' { + $$ = $1; + } + ; +book_paper_head: + BOOKPAPER '{' { + $$ = unsmob_book_paper_def (THIS->lexer_->lookup_identifier ("$defaultbookpaper"))->clone (); + THIS->lexer_->add_scope ($$->scope_); + } + ; + +book_paper_body: + book_paper_head + | book_paper_body assignment { } + ; + + + book_block: BOOK { THIS->push_spot (); @@ -623,7 +651,11 @@ book_body: { $$ = new Book; $$->set_spot (THIS->here_input ()); - $$->bookpaper_ = unsmob_book_paper_def (THIS->lexer_->lookup_identifier ("$defaultbookpaper")); + scm_gc_unprotect_object ($$->bookpaper_->self_scm ()); + } + | book_body book_paper_block { + $$->bookpaper_ = $2; + scm_gc_unprotect_object ($2->self_scm ()); } | book_body score_block { Score *score = $2; @@ -641,6 +673,7 @@ book_body: THIS->header_ = $1; } | book_body error { + } ; diff --git a/python/midi.c b/python/midi.c index f815a2ecba..fc2906cacd 100644 --- a/python/midi.c +++ b/python/midi.c @@ -18,7 +18,6 @@ midi.parse (s) */ -#include "config.h" #include #if 0 -- 2.39.2