From: Han-Wen Nienhuys Date: Tue, 30 May 2006 23:42:07 +0000 (+0000) Subject: * lily/parser.yy (simple_markup): replace THIS with PARSER. X-Git-Tag: release/2.8.4~15 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=54b45bd53b651e561cd12634f0c578c4513a38dd;p=lilypond.git * lily/parser.yy (simple_markup): replace THIS with PARSER. * ly/Welcome-to-LilyPond-MacOS.ly: include in LilyPond, so version number stays up to date. * buildscripts/output-distance.py (ComparisonData.create_html_result_page): new routine: summarise results in HTML page with images. (ComparisonData.create_text_result_page): create summary text files too. * GNUmakefile.in (web-ext): package .signature files too. They compress well. * scm/stencil.scm (write-system-signature): typo. * GNUmakefile.in: create web-root/VERSION to help upload scripts. * scm/stencil.scm (write-system-signature): better escaping. only write signature for music systems, not for markup systems. * scm/framework-ps.scm (output-framework): dump-signatures support for plain output. * make/lilypond-vars.make (LILYPOND_BOOK_FLAGS): add -ddump-signatures. * scm/framework-ps.scm (write-preamble): redefine mark_URI to nop for -dno-point-and-click * lily/grob.cc (get_print_stencil): don't read point_and_click_global to determine whether to set grob-cause. * buildscripts/output-distance.py (main): new function. (ComparisonData): new class. * lily/system.cc (get_paper_system): remove 3 layer limit. * buildscripts/output-distance.py (SystemLink.distance): new file. Compare signatures. * python/safeeval.py (SafeEval.visitUnarySub): new file. * lily/grob-array.cc (remove_duplicates): rename from uniq(). Sort before calling uniq() so it actually works. * lily/system.cc (get_paper_systems): uniq all_elements_ , to prevent duplicated broken items in output. * scm/framework-eps.scm (output-classic-framework): only dump if dump-signatures is set. * scm/lily.scm (define-scheme-options): add dump-signatures option. * scm/stencil.scm (write-system-signature): new routine: write python parseable signature of a separate paper system. * lily/stanza-number-engraver.cc (process_music): use is_markup() iso is_string(). include header. * stepmake/aclocal.m4: STEPMAKE_PYTHON(): clear cached value since arg 2 might point us to a new binary (patch by Karl Hammar) --- diff --git a/ChangeLog b/ChangeLog index aa457b332c..3c133e4130 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,80 @@ +2006-05-31 Han-Wen Nienhuys + + * lily/parser.yy (simple_markup): replace THIS with PARSER. + + * ly/Welcome-to-LilyPond-MacOS.ly: include in LilyPond, so version + number stays up to date. + + * buildscripts/output-distance.py + (ComparisonData.create_html_result_page): new routine: summarise + results in HTML page with images. + (ComparisonData.create_text_result_page): create summary text files too. + + * GNUmakefile.in (web-ext): package .signature files too. They + compress well. + + * scm/stencil.scm (write-system-signature): typo. + + * GNUmakefile.in: create web-root/VERSION to help upload scripts. + + * scm/stencil.scm (write-system-signature): better escaping. + only write signature for music systems, not for markup systems. + + * scm/framework-ps.scm (output-framework): dump-signatures support + for plain output. + + * make/lilypond-vars.make (LILYPOND_BOOK_FLAGS): add -ddump-signatures. + + * scm/framework-ps.scm (write-preamble): redefine mark_URI to nop + for -dno-point-and-click + + * lily/grob.cc (get_print_stencil): don't read + point_and_click_global to determine whether to set grob-cause. + + * buildscripts/output-distance.py (main): new function. + (ComparisonData): new class. + + * lily/ledger-line-engraver.cc (acknowledge_staff_symbol): be more + careful with generating new LedgerLineSpanners. + + * lily/ledger-line-spanner.cc (set_spacing_rods): suicide if no staff. + + * ly/engraver-init.ly: remove Ledger_line_engraver from Voice + context. This fixes double ledger lines in output. + + * lily/system.cc (get_paper_system): remove 3 layer limit. + + * buildscripts/output-distance.py (SystemLink.distance): new + file. Compare signatures. + + * python/safeeval.py (SafeEval.visitUnarySub): new file. + + * lily/grob-array.cc (remove_duplicates): rename from + uniq(). Sort before calling uniq() so it actually works. + + * scripts/lilypond-book.py (Lilypond_file_snippet.ly): strip + \version from lilypond file snippet. + (Lilypond_file_snippet.ly): oops. typo. + (find_toplevel_snippets): urgh. again. + + * lily/system.cc (get_paper_systems): uniq all_elements_ , to + prevent duplicated broken items in output. + + * scm/framework-eps.scm (output-classic-framework): only dump if + dump-signatures is set. + + * scm/lily.scm (define-scheme-options): add dump-signatures option. + + * scm/stencil.scm (write-system-signature): new routine: write + python parseable signature of a separate paper system. + + * lily/stanza-number-engraver.cc (process_music): use is_markup() + iso is_string(). + include header. + + * stepmake/aclocal.m4: STEPMAKE_PYTHON(): clear cached value since + arg 2 might point us to a new binary (patch by Karl Hammar) + 2006-05-25 Joe Neeman * lily/stem-tremolo.cc (print): fix whole note tremolo placement diff --git a/GNUmakefile.in b/GNUmakefile.in index 5f28601d9f..9e68971f0d 100644 --- a/GNUmakefile.in +++ b/GNUmakefile.in @@ -57,7 +57,7 @@ local-install: final-install: @true -web-ext = html midi pdf png txt ly +web-ext = html midi pdf png txt ly signature footify = $(PYTHON) $(step-bindir)/add-html-footer.py --name $(PACKAGE_NAME) --version $(TOPLEVEL_VERSION) footifymail = MAILADDRESS='http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs' @@ -80,14 +80,17 @@ local-WWW-post: ## rewrite file names so we lose out-www rm -rf $(outdir)/web-root/ - mkdir $(outdir)/web-root/ + mkdir $(outdir)/web-root/ cat $(outdir)/weblist | (cd $(top-build-dir); tar -cf- -T- ) | \ tar -C $(outdir)/web-root/ -xf - - cd $(outdir)/web-root/ && \ + for dir in $(outdir)/web-root/ ; do \ + cd $$dir && \ for a in `find . -name out-www`; do \ rsync -a --link-dest $$a/ $$a/ $$a/.. ; \ rm -rf $$a ; \ - done + done \ + done + echo $(TOPLEVEL_VERSION) > $(outdir)/web-root/VERSION tree-prefix = $(outdir) tree-bin = $(tree-prefix)/bin diff --git a/lily/grob-array.cc b/lily/grob-array.cc index 7b462cbba2..dff5102a83 100644 --- a/lily/grob-array.cc +++ b/lily/grob-array.cc @@ -82,6 +82,15 @@ Grob_array::clear () grobs_.clear (); } +void +Grob_array::remove_duplicates () +{ + assert (!ordered_); + + vector_sort (grobs_, default_compare); + ::uniq (grobs_); +} + bool Grob_array::empty () const { @@ -108,3 +117,4 @@ grob_list_to_grob_array (SCM lst) ga->add (unsmob_grob (scm_car (s))); return arr_scm; } + diff --git a/lily/grob.cc b/lily/grob.cc index fc49f16d4d..493a9c2144 100644 --- a/lily/grob.cc +++ b/lily/grob.cc @@ -114,9 +114,8 @@ Grob::get_print_stencil () const else { SCM expr = m->expr (); - if (point_and_click_global) - expr = scm_list_3 (ly_symbol2scm ("grob-cause"), - self_scm (), expr); + expr = scm_list_3 (ly_symbol2scm ("grob-cause"), + self_scm (), expr); retval = Stencil (m->extent_box (), expr); } diff --git a/lily/include/grob-array.hh b/lily/include/grob-array.hh index 47580b38d1..ac4ba3e0c9 100644 --- a/lily/include/grob-array.hh +++ b/lily/include/grob-array.hh @@ -29,6 +29,7 @@ public: Grob *grob (vsize i) { return grobs_.at (i); } vsize size () const { return grobs_.size (); } bool empty () const; + void remove_duplicates (); void clear (); void add (Grob *x) { grobs_.push_back (x); } void set_array (vector const &src); diff --git a/lily/input-scheme.cc b/lily/input-scheme.cc index a13ca876e7..6e954ef162 100644 --- a/lily/input-scheme.cc +++ b/lily/input-scheme.cc @@ -13,7 +13,7 @@ implemented separately from the class. */ LY_DEFINE (ly_input, "ly:input-location?", 1, 0, 0, (SCM x), - "Return #t if @var{x} is an input location.") + "Is @var{x} an @code{input-location}?") { return unsmob_input (x) ? SCM_BOOL_T : SCM_BOOL_F; } @@ -34,13 +34,18 @@ LY_DEFINE (ly_input_message, "ly:input-message", 2, 0, 1, (SCM sip, SCM msg, SCM return SCM_UNSPECIFIED; } -LY_DEFINE (ly_input_file_line_column, "ly:input-file-line-char-column", 1, 0, 0, (SCM sip), + +LY_DEFINE (ly_input_file_line_column, + "ly:input-file-line-char-column", + 1, 0, 0, (SCM sip), "Return input location in @var{sip} as (file-name line char column).") { Input *ip = unsmob_input (sip); SCM_ASSERT_TYPE (ip, sip, SCM_ARG1, __FUNCTION__, "input location"); - int l, ch, col; + int l = 0; + int ch = 0; + int col = 0; ip->get_counts (&l, &ch, &col); return scm_list_4 (scm_makfrom0str (ip->file_string ().c_str ()), scm_from_int (l), @@ -48,8 +53,11 @@ LY_DEFINE (ly_input_file_line_column, "ly:input-file-line-char-column", 1, 0, 0, scm_from_int (col)); } -LY_DEFINE (ly_input_both_locations, "ly:input-both-locations", 1, 0, 0, (SCM sip), - "Return input location in @var{sip} as (file-name first-line first-column last-line last-column).") +LY_DEFINE (ly_input_both_locations, + "ly:input-both-locations", + 1, 0, 0, (SCM sip), + "Return input location in @var{sip} as " + "(file-name first-line first-column last-line last-column).") { Input *ip = unsmob_input (sip); SCM_ASSERT_TYPE (ip, sip, SCM_ARG1, __FUNCTION__, "input location"); diff --git a/lily/parser.yy b/lily/parser.yy index 02599215fd..8675a9f43d 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -12,10 +12,10 @@ #define YYERROR_VERBOSE 1 #define YYPARSE_PARAM my_lily_parser #define YYLEX_PARAM my_lily_parser -#define THIS\ +#define PARSER\ ((Lily_parser *) my_lily_parser) -#define yyerror THIS->parser_error +#define yyerror PARSER->parser_error /* We use custom location type: Input objects */ #define YYLTYPE Input @@ -436,10 +436,10 @@ lilypond: /* empty */ | lilypond assignment { } | lilypond error { - THIS->error_level_ = 1; + PARSER->error_level_ = 1; } | lilypond INVALID { - THIS->error_level_ = 1; + PARSER->error_level_ = 1; } ; @@ -450,30 +450,30 @@ object_id_setting: toplevel_expression: lilypond_header { - THIS->lexer_->set_identifier (ly_symbol2scm ("$defaultheader"), $1); + PARSER->lexer_->set_identifier (ly_symbol2scm ("$defaultheader"), $1); } | book_block { Book *book = $1; - SCM proc = THIS->lexer_->lookup_identifier ("toplevel-book-handler"); - scm_call_2 (proc, THIS->self_scm (), book->self_scm ()); + SCM proc = PARSER->lexer_->lookup_identifier ("toplevel-book-handler"); + scm_call_2 (proc, PARSER->self_scm (), book->self_scm ()); book->unprotect (); } | score_block { Score *score = $1; - SCM proc = THIS->lexer_->lookup_identifier ("toplevel-score-handler"); - scm_call_2 (proc, THIS->self_scm (), score->self_scm ()); + SCM proc = PARSER->lexer_->lookup_identifier ("toplevel-score-handler"); + scm_call_2 (proc, PARSER->self_scm (), score->self_scm ()); score->unprotect (); } | toplevel_music { Music *music = $1; - SCM proc = THIS->lexer_->lookup_identifier ("toplevel-music-handler"); - scm_call_2 (proc, THIS->self_scm (), music->self_scm ()); + SCM proc = PARSER->lexer_->lookup_identifier ("toplevel-music-handler"); + scm_call_2 (proc, PARSER->self_scm (), music->self_scm ()); music->unprotect (); } | full_markup { - SCM proc = THIS->lexer_->lookup_identifier ("toplevel-text-handler"); - scm_call_2 (proc, THIS->self_scm (), $1); + SCM proc = PARSER->lexer_->lookup_identifier ("toplevel-text-handler"); + scm_call_2 (proc, PARSER->self_scm (), $1); } | output_def { SCM id = SCM_EOL; @@ -486,7 +486,7 @@ toplevel_expression: else if ($1->c_variable ("is-layout") == SCM_BOOL_T) id = ly_symbol2scm ("$defaultlayout"); - THIS->lexer_->set_identifier (id, od->self_scm ()); + PARSER->lexer_->set_identifier (id, od->self_scm ()); od->unprotect(); } ; @@ -504,8 +504,8 @@ embedded_scm: lilypond_header_body: { - $$ = get_header(THIS); - THIS->lexer_->add_scope ($$); + $$ = get_header(PARSER); + PARSER->lexer_->add_scope ($$); } | lilypond_header_body assignment { @@ -514,7 +514,7 @@ lilypond_header_body: lilypond_header: HEADER '{' lilypond_header_body '}' { - $$ = THIS->lexer_->remove_scope (); + $$ = PARSER->lexer_->remove_scope (); } ; @@ -537,7 +537,7 @@ assignment: } - THIS->lexer_->set_identifier ($1, $3); + PARSER->lexer_->set_identifier ($1, $3); /* TODO: devise standard for protection in parser. @@ -639,9 +639,9 @@ book_body: { $$ = new Book; $$->set_spot (@$); - $$->paper_ = dynamic_cast (unsmob_output_def (THIS->lexer_->lookup_identifier ("$defaultpaper"))->clone ()); + $$->paper_ = dynamic_cast (unsmob_output_def (PARSER->lexer_->lookup_identifier ("$defaultpaper"))->clone ()); $$->paper_->unprotect (); - $$->header_ = THIS->lexer_->lookup_identifier ("$defaultheader"); + $$->header_ = PARSER->lexer_->lookup_identifier ("$defaultheader"); } | BOOK_IDENTIFIER { $$ = unsmob_book ($1); @@ -682,7 +682,7 @@ score_body: SCM m = $1->self_scm (); $1->unprotect(); SCM scorify = ly_lily_module_constant ("scorify-music"); - SCM score = scm_call_2 (scorify, m, THIS->self_scm ()); + SCM score = scm_call_2 (scorify, m, PARSER->self_scm ()); // pass ownernship to C++ again. $$ = unsmob_score (score); @@ -702,7 +702,7 @@ score_body: | score_body output_def { if ($2->lookup_variable (ly_symbol2scm ("is-paper")) == SCM_BOOL_T) { - THIS->parser_error (@2, _("\\paper cannot be used in \\score, use \\layout instead")); + PARSER->parser_error (@2, _("\\paper cannot be used in \\score, use \\layout instead")); } else @@ -726,8 +726,8 @@ paper_block: $$ = $1; if ($$->lookup_variable (ly_symbol2scm ("is-paper")) != SCM_BOOL_T) { - THIS->parser_error (@1, _ ("need \\paper for paper block")); - $$ = get_paper (THIS); + PARSER->parser_error (@1, _ ("need \\paper for paper block")); + $$ = get_paper (PARSER); } } ; @@ -737,33 +737,33 @@ output_def: output_def_body '}' { $$ = $1; - THIS->lexer_->remove_scope (); - THIS->lexer_->pop_state (); + PARSER->lexer_->remove_scope (); + PARSER->lexer_->pop_state (); } ; output_def_head: PAPER { - $$ = get_paper (THIS); + $$ = get_paper (PARSER); $$->input_origin_ = @$; - THIS->lexer_->add_scope ($$->scope_); + PARSER->lexer_->add_scope ($$->scope_); } | MIDI { - Output_def *p = get_midi (THIS); + Output_def *p = get_midi (PARSER); $$ = p; - THIS->lexer_->add_scope (p->scope_); + PARSER->lexer_->add_scope (p->scope_); } | LAYOUT { - Output_def *p = get_layout (THIS); + Output_def *p = get_layout (PARSER); - THIS->lexer_->add_scope (p->scope_); + PARSER->lexer_->add_scope (p->scope_); $$ = p; } ; output_def_head_with_mode_switch: output_def_head { - THIS->lexer_->push_initial_state (); + PARSER->lexer_->push_initial_state (); $$ = $1; } ; @@ -778,8 +778,8 @@ output_def_body: Output_def *o = unsmob_output_def ($3); o->input_origin_.set_spot (@$); $$ = o; - THIS->lexer_->remove_scope (); - THIS->lexer_->add_scope (o->scope_); + PARSER->lexer_->remove_scope (); + PARSER->lexer_->add_scope (o->scope_); } | output_def_body assignment { @@ -964,10 +964,10 @@ Simple_music: optional_context_mod: /**/ { $$ = SCM_EOL; } - | WITH { THIS->lexer_->push_initial_state (); } + | WITH { PARSER->lexer_->push_initial_state (); } '{' context_mod_list '}' { - THIS->lexer_->pop_state (); + PARSER->lexer_->pop_state (); $$ = $4; } ; @@ -1056,7 +1056,7 @@ optional_id: Prefix_composite_music: Generic_prefix_music_scm { - $$ = run_music_function (THIS, $1); + $$ = run_music_function (PARSER, $1); } | CONTEXT simple_string optional_id optional_context_mod Music { $$ = context_spec_music ($2, $3, $5, $4, false); @@ -1104,7 +1104,7 @@ Prefix_composite_music: { $$ = $2; } - THIS->lexer_->pop_state (); + PARSER->lexer_->pop_state (); } | mode_changing_head_with_context optional_context_mod Grouped_music_list { $$ = context_spec_music ($1, SCM_UNDEFINED, $3, $2, true); @@ -1115,7 +1115,7 @@ Prefix_composite_music: $$->unprotect(); $$ = chm; } - THIS->lexer_->pop_state (); + PARSER->lexer_->pop_state (); } | relative_music { $$ = $1; } | re_rhythmed_music { $$ = $1; } @@ -1123,58 +1123,58 @@ Prefix_composite_music: mode_changing_head: NOTEMODE { - SCM nn = THIS->lexer_->lookup_identifier ("pitchnames"); - THIS->lexer_->push_note_state (alist_to_hashq (nn)); + SCM nn = PARSER->lexer_->lookup_identifier ("pitchnames"); + PARSER->lexer_->push_note_state (alist_to_hashq (nn)); $$ = ly_symbol2scm ("notes"); } | DRUMMODE { - SCM nn = THIS->lexer_->lookup_identifier ("drumPitchNames"); - THIS->lexer_->push_note_state (alist_to_hashq (nn)); + SCM nn = PARSER->lexer_->lookup_identifier ("drumPitchNames"); + PARSER->lexer_->push_note_state (alist_to_hashq (nn)); $$ = ly_symbol2scm ("drums"); } | FIGUREMODE { - THIS->lexer_->push_figuredbass_state (); + PARSER->lexer_->push_figuredbass_state (); $$ = ly_symbol2scm ("figures"); } | CHORDMODE { - SCM nn = THIS->lexer_->lookup_identifier ("chordmodifiers"); - THIS->lexer_->chordmodifier_tab_ = alist_to_hashq (nn); - nn = THIS->lexer_->lookup_identifier ("pitchnames"); - THIS->lexer_->push_chord_state (alist_to_hashq (nn)); + SCM nn = PARSER->lexer_->lookup_identifier ("chordmodifiers"); + PARSER->lexer_->chordmodifier_tab_ = alist_to_hashq (nn); + nn = PARSER->lexer_->lookup_identifier ("pitchnames"); + PARSER->lexer_->push_chord_state (alist_to_hashq (nn)); $$ = ly_symbol2scm ("chords"); } | LYRICMODE - { THIS->lexer_->push_lyric_state (); + { PARSER->lexer_->push_lyric_state (); $$ = ly_symbol2scm ("lyrics"); } ; mode_changing_head_with_context: DRUMS { - SCM nn = THIS->lexer_->lookup_identifier ("drumPitchNames"); - THIS->lexer_->push_note_state (alist_to_hashq (nn)); + SCM nn = PARSER->lexer_->lookup_identifier ("drumPitchNames"); + PARSER->lexer_->push_note_state (alist_to_hashq (nn)); $$ = ly_symbol2scm ("DrumStaff"); } | FIGURES { - THIS->lexer_->push_figuredbass_state (); + PARSER->lexer_->push_figuredbass_state (); $$ = ly_symbol2scm ("FiguredBass"); } | CHORDS { - SCM nn = THIS->lexer_->lookup_identifier ("chordmodifiers"); - THIS->lexer_->chordmodifier_tab_ = alist_to_hashq (nn); - nn = THIS->lexer_->lookup_identifier ("pitchnames"); - THIS->lexer_->push_chord_state (alist_to_hashq (nn)); + SCM nn = PARSER->lexer_->lookup_identifier ("chordmodifiers"); + PARSER->lexer_->chordmodifier_tab_ = alist_to_hashq (nn); + nn = PARSER->lexer_->lookup_identifier ("pitchnames"); + PARSER->lexer_->push_chord_state (alist_to_hashq (nn)); $$ = ly_symbol2scm ("ChordNames"); } | LYRICS - { THIS->lexer_->push_lyric_state (); + { PARSER->lexer_->push_lyric_state (); $$ = ly_symbol2scm ("Lyrics"); } ; @@ -1197,19 +1197,19 @@ relative_music: ; new_lyrics: - ADDLYRICS { THIS->lexer_->push_lyric_state (); } + ADDLYRICS { PARSER->lexer_->push_lyric_state (); } /*cont */ Grouped_music_list { /* Can also use Music at the expensive of two S/Rs similar to \repeat \alternative */ - THIS->lexer_->pop_state (); + PARSER->lexer_->pop_state (); $$ = scm_cons ($3->self_scm (), SCM_EOL); } | new_lyrics ADDLYRICS { - THIS->lexer_->push_lyric_state (); + PARSER->lexer_->push_lyric_state (); } Grouped_music_list { - THIS->lexer_->pop_state (); + PARSER->lexer_->pop_state (); $$ = scm_cons ($4->self_scm (), $1); } ; @@ -1244,9 +1244,9 @@ re_rhythmed_music: voice->unprotect (); } | LYRICSTO simple_string { - THIS->lexer_->push_lyric_state (); + PARSER->lexer_->push_lyric_state (); } Music { - THIS->lexer_->pop_state (); + PARSER->lexer_->pop_state (); Music *music = $4; SCM name = $2; $$ = make_lyric_combine_music (name, music); @@ -1543,7 +1543,7 @@ chord_body_element: $$ = n; } | music_function_chord_body { - $$ = run_music_function (THIS, $1); + $$ = run_music_function (PARSER, $1); $$->set_spot (@$); } ; @@ -1609,7 +1609,7 @@ command_element: $$->set_spot (@$); } | '|' { - SCM pipe = THIS->lexer_->lookup_identifier ("pipeSymbol"); + SCM pipe = PARSER->lexer_->lookup_identifier ("pipeSymbol"); if (Music * m = unsmob_music (pipe)) $$ = m->clone (); @@ -1678,7 +1678,7 @@ command_event: key->set_property ("tonic", Pitch (0, 0, 0).smobbed_copy ()); key->transpose (* unsmob_pitch ($2)); } else { - THIS->parser_error (@3, _ ("second argument must be pitch list")); + PARSER->parser_error (@3, _ ("second argument must be pitch list")); } $$ = key; @@ -1715,18 +1715,18 @@ post_event: $$ = $1; } | '-' music_function_event { - Music *mus = run_music_function (THIS, $2); + Music *mus = run_music_function (PARSER, $2); mus->set_spot (@1); $$ = mus; } | HYPHEN { - if (!THIS->lexer_->is_lyric_state ()) - THIS->parser_error (@1, _ ("have to be in Lyric mode for lyrics")); + if (!PARSER->lexer_->is_lyric_state ()) + PARSER->parser_error (@1, _ ("have to be in Lyric mode for lyrics")); $$ = MY_MAKE_MUSIC ("HyphenEvent"); } | EXTENDER { - if (!THIS->lexer_->is_lyric_state ()) - THIS->parser_error (@1, _ ("have to be in Lyric mode for lyrics")); + if (!PARSER->lexer_->is_lyric_state ()) + PARSER->parser_error (@1, _ ("have to be in Lyric mode for lyrics")); $$ = MY_MAKE_MUSIC ("ExtenderEvent"); } | script_dir direction_reqd_event { @@ -1786,7 +1786,7 @@ direction_less_char: direction_less_event: direction_less_char { - SCM predefd = THIS->lexer_->lookup_identifier_symbol ($1); + SCM predefd = PARSER->lexer_->lookup_identifier_symbol ($1); Music * m = 0; if (unsmob_music (predefd)) { @@ -1815,11 +1815,11 @@ direction_reqd_event: $$ = $1; } | script_abbreviation { - SCM s = THIS->lexer_->lookup_identifier ("dash" + ly_scm2string ($1)); + SCM s = PARSER->lexer_->lookup_identifier ("dash" + ly_scm2string ($1)); Music *a = MY_MAKE_MUSIC ("ArticulationEvent"); if (scm_is_string (s)) a->set_property ("articulation-type", s); - else THIS->parser_error (@1, _ ("expecting string as script definition")); + else PARSER->parser_error (@1, _ ("expecting string as script definition")); $$ = a; } ; @@ -1965,12 +1965,12 @@ duration_length: optional_notemode_duration: { - Duration dd = THIS->default_duration_; + Duration dd = PARSER->default_duration_; $$ = dd.smobbed_copy (); } | multiplied_duration { $$ = $1; - THIS->default_duration_ = *unsmob_duration ($$); + PARSER->default_duration_ = *unsmob_duration ($$); } ; @@ -1978,7 +1978,7 @@ steno_duration: bare_unsigned dots { int len = 0; if (!is_duration ($1)) - THIS->parser_error (@1, _f ("not a duration: %d", $1)); + PARSER->parser_error (@1, _f ("not a duration: %d", $1)); else len = intlog2 ($1); @@ -2028,7 +2028,7 @@ tremolo_type: } | ':' bare_unsigned { if (!is_duration ($2)) - THIS->parser_error (@2, _f ("not a duration: %d", $2)); + PARSER->parser_error (@2, _f ("not a duration: %d", $2)); $$ = $2; } ; @@ -2150,8 +2150,8 @@ optional_rest: simple_element: pitch exclamations questions octave_check optional_notemode_duration optional_rest { - if (!THIS->lexer_->is_note_state ()) - THIS->parser_error (@1, _ ("have to be in Note mode for notes")); + if (!PARSER->lexer_->is_note_state ()) + PARSER->parser_error (@1, _ ("have to be in Note mode for notes")); Music *n = 0; if ($6) @@ -2231,8 +2231,8 @@ simple_element: } | lyric_element optional_notemode_duration { - if (!THIS->lexer_->is_lyric_state ()) - THIS->parser_error (@1, _ ("have to be in Lyric mode for lyrics")); + if (!PARSER->lexer_->is_lyric_state ()) + PARSER->parser_error (@1, _ ("have to be in Lyric mode for lyrics")); Music *levent = MY_MAKE_MUSIC ("LyricEvent"); levent->set_property ("text", $1); @@ -2244,8 +2244,8 @@ simple_element: $$= velt; } | new_chord { - if (!THIS->lexer_->is_chord_state ()) - THIS->parser_error (@1, _ ("have to be in Chord mode for chords")); + if (!PARSER->lexer_->is_chord_state ()) + PARSER->parser_error (@1, _ ("have to be in Chord mode for chords")); $$ = unsmob_music ($1); } ; @@ -2407,10 +2407,10 @@ lyric_markup: $$ = $1; } | LYRIC_MARKUP - { THIS->lexer_->push_markup_state (); } + { PARSER->lexer_->push_markup_state (); } markup_top { $$ = $3; - THIS->lexer_->pop_state (); + PARSER->lexer_->pop_state (); } ; @@ -2419,10 +2419,10 @@ full_markup: $$ = $1; } | MARKUP - { THIS->lexer_->push_markup_state (); } + { PARSER->lexer_->push_markup_state (); } markup_top { $$ = $3; - THIS->lexer_->pop_state (); + PARSER->lexer_->pop_state (); } ; @@ -2505,13 +2505,13 @@ simple_markup: $$ = $1; } | SCORE { - SCM nn = THIS->lexer_->lookup_identifier ("pitchnames"); - THIS->lexer_->push_note_state (alist_to_hashq (nn)); + SCM nn = PARSER->lexer_->lookup_identifier ("pitchnames"); + PARSER->lexer_->push_note_state (alist_to_hashq (nn)); } '{' score_body '}' { Score * sc = $4; $$ = scm_list_2 (ly_lily_module_constant ("score-markup"), sc->self_scm ()); sc->unprotect (); - THIS->lexer_->pop_state (); + PARSER->lexer_->pop_state (); } | MARKUP_HEAD_SCM0 embedded_scm { $$ = scm_list_2 ($1, $2); diff --git a/lily/stanza-number-engraver.cc b/lily/stanza-number-engraver.cc index ed82060e68..efbcc6d26c 100644 --- a/lily/stanza-number-engraver.cc +++ b/lily/stanza-number-engraver.cc @@ -8,6 +8,7 @@ #include "engraver.hh" #include "side-position-interface.hh" +#include "text-interface.hh" class Stanza_number_engraver : public Engraver { @@ -45,7 +46,8 @@ Stanza_number_engraver::process_music () { SCM stanza = get_property ("stanza"); - if (scm_is_string (stanza) && stanza != last_stanza_) + if (Text_interface::is_markup (stanza) + && stanza != last_stanza_) { last_stanza_ = stanza; diff --git a/lily/system.cc b/lily/system.cc index d9b2122c3b..6e83dfc5da 100644 --- a/lily/system.cc +++ b/lily/system.cc @@ -47,13 +47,14 @@ System::init_elements () { SCM scm_arr = Grob_array::make_array (); all_elements_ = unsmob_grob_array (scm_arr); + all_elements_->set_ordered (false); set_object ("all-elements", scm_arr); } Grob * -System::clone (int count) const +System::clone (int index) const { - return new System (*this, count); + return new System (*this, index); } int @@ -163,27 +164,22 @@ System::get_paper_systems () handle_broken_dependencies (); -#if 0 /* FIXME: strange side effects. */ - /* Because the this->get_property (all-elements) contains items in 3 versions, handle_broken_dependencies () will leave duplicated items in all-elements. Strictly speaking this is harmless, but - it leads to duplicated symbols in the output. ly_list_qsort_uniq_x () - makes sure that no duplicates are in the list. */ - for (int i = 0; i < line_count; i++) + it leads to duplicated symbols in the output. uniq makes sure + that no duplicates are in the list. */ + for (vsize i = 0; i < broken_intos_.size (); i++) { - SCM all = broken_intos_[i]->get_object ("all-elements"); - all = ly_list_qsort_uniq_x (all); + System *child = dynamic_cast (broken_intos_[i]); + child->all_elements_->remove_duplicates (); } -#endif if (be_verbose_global) message (_f ("Element count %d.", count + element_count ())); - int line_count = broken_intos_.size (); - SCM lines = scm_c_make_vector (line_count, SCM_EOL); - - for (int i = 0; i < line_count; i++) + SCM lines = scm_c_make_vector (broken_intos_.size (), SCM_EOL); + for (vsize i = 0; i < broken_intos_.size (); i++) { if (be_verbose_global) progress_indication ("["); @@ -328,42 +324,61 @@ System::post_processing () } } +struct Layer_entry +{ + Grob *grob_; + int layer_; +}; + +bool +operator< (Layer_entry const &a, + Layer_entry const &b) +{ + return a.layer_ < b.layer_; +} + + SCM System::get_paper_system () { - static int const LAYER_COUNT = 3; - SCM exprs = SCM_EOL; SCM *tail = &exprs; - /* Output stencils in three layers: 0, 1, 2. Default layer: 1. */ - for (int i = 0; i < LAYER_COUNT; i++) - for (vsize j = all_elements_->size (); j--;) - { - Grob *g = all_elements_->grob (j); - Stencil st = g->get_print_stencil (); + vector entries; + for (vsize j = 0; j < all_elements_->size (); j++) + { + Layer_entry e; + e.grob_ = all_elements_->grob (j); + e.layer_ = robust_scm2int (e.grob_->get_property ("layer"), 1); + + entries.push_back (e); + } - /* Skip empty stencils and grobs that are not in this layer. */ - if (st.expr() == SCM_EOL - || robust_scm2int (g->get_property ("layer"), 1) != i) - continue; + vector_sort (entries, default_compare); + for (vsize j = 0; j < entries.size (); j++) + { + Grob *g = entries[j].grob_; + Stencil st = g->get_print_stencil (); - Offset o; - for (int a = X_AXIS; a < NO_AXES; a++) - o[Axis (a)] = g->relative_coordinate (this, Axis (a)); + if (st.expr() == SCM_EOL) + continue; + + Offset o; + for (int a = X_AXIS; a < NO_AXES; a++) + o[Axis (a)] = g->relative_coordinate (this, Axis (a)); - Offset extra = robust_scm2offset (g->get_property ("extra-offset"), - Offset (0, 0)) - * Staff_symbol_referencer::staff_space (g); + Offset extra = robust_scm2offset (g->get_property ("extra-offset"), + Offset (0, 0)) + * Staff_symbol_referencer::staff_space (g); - /* Must copy the stencil, for we cannot change the stencil - cached in G. */ + /* Must copy the stencil, for we cannot change the stencil + cached in G. */ - st.translate (o + extra); + st.translate (o + extra); - *tail = scm_cons (st.expr (), SCM_EOL); - tail = SCM_CDRLOC (*tail); - } + *tail = scm_cons (st.expr (), SCM_EOL); + tail = SCM_CDRLOC (*tail); + } if (Stencil *me = get_stencil ()) exprs = scm_cons (me->expr (), exprs); @@ -386,7 +401,7 @@ System::get_paper_system () Interval staff_refpoints; staff_refpoints.set_empty (); extract_grob_set (this, "spaceable-staves", staves); - for (vsize i = staves.size (); i--;) + for (vsize i = 0; i < staves.size (); i++) { Grob *g = staves[i]; staff_refpoints.add_point (g->relative_coordinate (this, Y_AXIS)); diff --git a/make/lilypond-vars.make b/make/lilypond-vars.make index 9f6ef3f97e..1dd53512b8 100644 --- a/make/lilypond-vars.make +++ b/make/lilypond-vars.make @@ -25,7 +25,7 @@ CONVERT_LY = $(script-dir)/convert-ly.py LILYPOND_BOOK = $(script-dir)/lilypond-book.py LILYPOND_BOOK_INCLUDES = -I $(src-dir)/ -I $(outdir) -I $(input-dir) -I $(input-dir)/regression/ -I $(input-dir)/test/ -I $(input-dir)/tutorial/ -I $(top-build-dir)/mf/$(outconfbase)/ -I $(top-build-dir)/mf/out/ LILYPOND_BOOK_LILYPOND_FLAGS=-dgs-font-load -LILYPOND_BOOK_FLAGS = --process="$(LILYPOND_BINARY) --backend=eps --formats=ps,png --header=texidoc -I $(top-src-dir)/input/test -dinternal-type-checking -danti-alias-factor=2 $(LILYPOND_BOOK_LILYPOND_FLAGS)" +LILYPOND_BOOK_FLAGS = --process="$(LILYPOND_BINARY) --backend=eps --formats=ps,png --header=texidoc -I $(top-src-dir)/input/test -dinternal-type-checking -ddump-signatures -danti-alias-factor=2 $(LILYPOND_BOOK_LILYPOND_FLAGS)" TEXINPUTS=$(top-src-dir)/tex/:: export TEXINPUTS diff --git a/mf/feta-nummer-code.mf b/mf/feta-nummer-code.mf index 1574669256..ae264fa503 100644 --- a/mf/feta-nummer-code.mf +++ b/mf/feta-nummer-code.mf @@ -242,13 +242,6 @@ dot_diam# = 7/8 flare#; define_pixels (dot_diam); -code := 31; % , 32 - -fet_beginchar ("Space", "space"); - set_char_box (0, space#, 0, height#); -fet_endchar; - - code := 42; % , 43 fet_beginchar ("Plus", "plus"); @@ -734,16 +727,18 @@ fet_beginchar ("Numeral 7", "seven"); save tolerance; save alpha, beta, gamma, delta; save bow; + save x_overshoot; + path bow; - set_char_box (0, 11/15 height# * widen, 0, height#); + set_char_box (0, 11/15 height# * widen - thin#, 0, height#); + overshoot_x = .75 thin; message "w:" & decimal w; message "h:" & decimal h; alpha = -180; -if true: penpos1 (3/2 thick, 180 + alpha); penpos2 (hair, 180 + alpha - 45); penpos3 (hair, 180 + alpha + 45); @@ -751,16 +746,12 @@ if true: z2 = z1l + (1/4 sqrt (2) * hair) * dir (alpha - 135); z3 = z1r + (1/4 sqrt (2) * hair) * dir (alpha - 45); z4 = z1 + kuulleke * dir (alpha - 90); -else: - % does not work - calc_kuulleke (3/2 thick, -alpha); -fi; z1l = (thin, 0); beta = 55; penpos5 (thin, 90 + beta); - z5 = (w, h) + (1/2 sqrt (2) * thin) * dir (-135); + z5 = (w, h) + (1/2 sqrt (2) * thin) * dir (-135) + (overshoot_x, 0); gamma = angle (length (z1r - z1), 2 kuulleke); delta = 12; diff --git a/scm/framework-eps.scm b/scm/framework-eps.scm index 9a7036df36..930ac51bf1 100644 --- a/scm/framework-eps.scm +++ b/scm/framework-eps.scm @@ -95,8 +95,13 @@ stencil, so LaTeX includegraphics doesn't fuck up the alignment." (postprocess-output book framework-eps-module (format "~a.eps" basename) (ly:output-formats))) + + (define-public (output-classic-framework basename book scopes fields) (output-scopes scopes fields basename) + + (if (ly:get-option 'dump-signatures) + (write-system-signatures basename (ly:paper-book-systems book) 0)) (dump-stencils-as-EPSes (map paper-system-stencil (ly:paper-book-systems book)) diff --git a/scm/framework-ps.scm b/scm/framework-ps.scm index 69c1e4617d..99e4b31204 100644 --- a/scm/framework-ps.scm +++ b/scm/framework-ps.scm @@ -431,6 +431,9 @@ (display (procset "music-drawing-routines.ps") port) (display (procset "lilyponddefs.ps") port) + (if (not (ly:get-option 'point-and-click)) + (display "/mark_URI { pop pop pop pop pop } bind def\n" port)) + (display "%%EndProlog\n" port) (display "%%BeginSetup\ninit-lilypond-parameters\n%%EndSetup\n\n" port)) @@ -444,6 +447,7 @@ (open-file filename "wb") "ps")) (paper (ly:paper-book-paper book)) + (systems (ly:paper-book-systems book)) (page-stencils (map page-stencil (ly:paper-book-pages book))) (landscape? (eq? (ly:output-def-lookup paper 'landscape) #t)) @@ -451,6 +455,9 @@ (page-count (length page-stencils)) (port (ly:outputter-port outputter))) + (if (ly:get-option 'dump-signatures) + (write-system-signatures basename (ly:paper-book-systems book) 0)) + (output-scopes scopes fields basename) (display (file-header paper page-count #t) port) (display "\n%%BeginDefaults diff --git a/scm/layout-page-layout.scm b/scm/layout-page-layout.scm index a0a35027a3..8a7628af85 100644 --- a/scm/layout-page-layout.scm +++ b/scm/layout-page-layout.scm @@ -318,7 +318,7 @@ is what have collected so far, and has ascending page numbers." (cons force positions))) - (define (walk-paths done-lines best-paths current-lines last? current-best) + (define (walk-paths done-lines best-paths current-lines last? current-best) "Return the best optimal-page-break-node that contains CURRENT-LINES. DONE-LINES.reversed ++ CURRENT-LINES is a consecutive ascending range of lines, and BEST-PATHS contains the optimal breaks @@ -343,6 +343,7 @@ CURRENT-BEST is the best result sofar, or #f." last?))) (height (page-printable-height this-page)) (vertical-spacing (space-systems height current-lines ragged?)) + (satisfied-constraints (car vertical-spacing)) (force (if satisfied-constraints (if (and last? ragged-last?) diff --git a/scm/lily.scm b/scm/lily.scm index 3c05c97dfa..fd7e285b64 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -13,6 +13,7 @@ `((point-and-click #t "use point & click") (paper-size "a4" "the default paper size") (midi-debug #f "generate human readable MIDI") + (dump-signatures #f "dump output signatures of each system (EPS backend)") (internal-type-checking #f "check every property assignment for types") (parse-protect #t "continue when finding errors in inline scheme are caught in the parser. If off, halt @@ -41,8 +42,7 @@ similar to chord syntax") "dump GC protection info") (show-available-fonts #f "List font names available.") - ) - )) + ))) ;; need to do this in the beginning. Other parts of the diff --git a/scm/paper-system.scm b/scm/paper-system.scm index 70985aae66..d414285d9d 100644 --- a/scm/paper-system.scm +++ b/scm/paper-system.scm @@ -17,6 +17,9 @@ (define-public (paper-system-stencil system) (ly:prob-property system 'stencil)) +(define-public (paper-system-system-grob paper-system) + (ly:prob-property paper-system 'system-grob)) + (define-public (paper-system-extent system axis) (ly:stencil-extent (paper-system-stencil system) axis)) diff --git a/scm/stencil.scm b/scm/stencil.scm index 541b4bf28e..c47baa3815 100644 --- a/scm/stencil.scm +++ b/scm/stencil.scm @@ -261,3 +261,120 @@ EndEPSF")) (ly:make-stencil "" '(0 . 0) '(0 . 0))) )) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; output signatures. + +(define-public (write-system-signatures basename paper-systems count) + (if (pair? paper-systems) + (begin + (let* + ((outname (format "~a-~a.signature" basename count)) ) + + (ly:message "Writing ~a" outname) + (write-system-signature outname (car paper-systems)) + (write-system-signatures basename (cdr paper-systems) (1+ count)))))) + + +(define-public (write-system-signature filename paper-system) + (define (float? x) + (and (number? x) (inexact? x))) + + (define system-grob + (paper-system-system-grob paper-system)) + + (define output (open-output-file filename)) + + (define (strip-floats expr) + "Replace floats by #f" + (cond + ((float? expr) #f) + ((ly:font-metric? expr) (ly:font-name expr)) + ((pair? expr) (cons (strip-floats (car expr)) + (strip-floats (cdr expr)))) + (else expr))) + + (define (fold-false-pairs expr) + "Try to remove lists of #f as much as possible." + (if (pair? expr) + (let* + ((first (car expr)) + (rest (fold-false-pairs (cdr expr)))) + + (if first + (cons (fold-false-pairs first) rest) + rest)) + expr)) + + (define (music-cause grob) + (let* + ((cause (ly:grob-property grob 'cause))) + + (cond + ((ly:music? cause) cause) + ((ly:grob? cause) (music-cause cause)) + (else #f)))) + + (define (pythonic-string expr) + "escape quotes and slashes for python consumption" + (regexp-substitute/global #f "([\\\\'\"])" (format "~a" expr) 'pre "\\" 1 'post)) + + (define (pythonic-pair expr) + (format "(~a,~a)" + (car expr) (cdr expr))) + + (define (found-grob expr) + (let* + ((grob (car expr)) + (rest (cdr expr)) + (collected '()) + (cause (music-cause grob)) + (input (if (ly:music? cause) (ly:music-property cause 'origin) #f)) + (location (if (ly:input-location? input) (ly:input-file-line-char-column input) '())) + + (x-ext (ly:grob-extent grob system-grob X)) + (y-ext (ly:grob-extent grob system-grob Y)) + ) + + (interpret-for-signature #f (lambda (e) + (set! collected (cons e collected))) + rest) + + (format output + "['~a', '~a', ~a, ~a, '~a'],\n" + (cdr (assq 'name (ly:grob-property grob 'meta) )) + (pythonic-string location) + (pythonic-pair (if (interval-empty? x-ext) '(0 . 0) x-ext)) + (pythonic-pair (if (interval-empty? y-ext) '(0 . 0) y-ext)) + (pythonic-string collected)) + )) + + (define (interpret-for-signature escape collect expr) + (define (interpret expr) + (let* + ((head (if (pair? expr) + (car expr) + #f))) + + (cond + ((eq? head 'grob-cause) (escape (cdr expr))) + ((eq? head 'color) (interpret (caddr expr))) + ((eq? head 'rotate-stencil) (interpret (caddr expr))) + ((eq? head 'translate-stencil) (interpret (caddr expr))) + ((eq? head 'combine-stencil) + (for-each (lambda (e) (interpret e)) (cdr expr))) + (else + (collect (fold-false-pairs (strip-floats expr)))) + + ))) + + (interpret expr)) + + (if (ly:grob? system-grob) + (begin + (display (format "# Output signature\n# Generated by LilyPond ~a\n" (lilypond-version)) + output) + (interpret-for-signature found-grob (lambda (x) #f) + (ly:stencil-expr + (paper-system-stencil paper-system)))))) + diff --git a/stepmake/aclocal.m4 b/stepmake/aclocal.m4 index 3ae4f92df6..5a9e739ad9 100644 --- a/stepmake/aclocal.m4 +++ b/stepmake/aclocal.m4 @@ -994,6 +994,9 @@ AC_DEFUN(STEPMAKE_PYTHON, [ if test -n "$pv"; then STEPMAKE_ADD_ENTRY($1, $pv) fi + # clear cached value since arg 2 might point us to a new binary + unset ac_cv_path_PYTHON + AC_PATH_PROG(PYTHON, $PYTHON) AC_SUBST(PYTHON) ])