From 1122f75e54e1a8e833f699cdab09e27157ea77a4 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Tue, 3 May 2005 12:13:28 +0000 Subject: [PATCH] * Documentation/user/basic-notation.itely (Explicitly instantiating voices): idem. * Documentation/user/advanced-notation.itely (Text spanners): remove stray { } * lily/context.cc (default_child_context_name): the default child is now first in accepts_list_. * ly/engraver-init.ly (RemoveEmptyRhythmicStaffContext): add \defaultchild to all relevant contexts. This fixes default voices for \drums { } . Most probably, this also fixes similar problems with ancient transcriptions getting CueVoices instead of the desired voices. * lily/context-def.cc (get_default_child): new function. (get_accepted): place default child in front of list. * lily/parser.yy (FIXME): add DEFAULTCHILD token. * lily/include/context-def.hh (struct Context_def): add default_accept_ --- ChangeLog | 25 +++++++++++ Documentation/user/advanced-notation.itely | 6 +-- Documentation/user/basic-notation.itely | 2 +- lily/context-def.cc | 48 +++++++++++++++++++++- lily/context.cc | 2 +- lily/include/context-def.hh | 7 ++-- lily/include/context.hh | 1 + lily/lily-lexer.cc | 1 + lily/note-heads-engraver.cc | 5 ++- lily/parser.yy | 2 + ly/engraver-init.ly | 15 ++++++- 11 files changed, 101 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 621feac57a..8e2d08de70 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,28 @@ +2005-05-03 Han-Wen Nienhuys + + * Documentation/user/basic-notation.itely (Explicitly + instantiating voices): idem. + + * Documentation/user/advanced-notation.itely (Text spanners): + remove stray { } + + * lily/context.cc (default_child_context_name): the default child + is now first in accepts_list_. + + * ly/engraver-init.ly (RemoveEmptyRhythmicStaffContext): add + \defaultchild to all relevant contexts. This fixes default voices + for \drums { } . Most probably, this also fixes similar problems + with ancient transcriptions getting CueVoices instead of the + desired voices. + + * lily/context-def.cc (get_default_child): new function. + (get_accepted): place default child in front of list. + + * lily/parser.yy (FIXME): add DEFAULTCHILD token. + + * lily/include/context-def.hh (struct Context_def): add + default_accept_ + 2005-05-03 Graham Percival * scm/define-grobs.scm: remove "remove-first" line, since diff --git a/Documentation/user/advanced-notation.itely b/Documentation/user/advanced-notation.itely index e22b0272d7..2b3c258dca 100644 --- a/Documentation/user/advanced-notation.itely +++ b/Documentation/user/advanced-notation.itely @@ -103,11 +103,11 @@ c2\startTextSpan b c\stopTextSpan a @refcommands -@cindex{textSpannerUp} +@cindex textSpannerUp @code{textSpannerUp}, -@cindex{textSpannerDown} +@cindex textSpannerDown @code{textSpannerDown}, -@cindex{textSpannerNeutral} +@cindex textSpannerNeutral @code{textSpannerNeutral}. @seealso diff --git a/Documentation/user/basic-notation.itely b/Documentation/user/basic-notation.itely index 6eb5060eef..e2ff5f3a9a 100644 --- a/Documentation/user/basic-notation.itely +++ b/Documentation/user/basic-notation.itely @@ -2267,7 +2267,7 @@ voice in the first @code{<< \\ >>} construct is effective in the second @end lilypond Polyphony does not change the relationship of notes within a -@code{\relative{ }} block. Each note is calculated relative +@code{\relative @{ @}} block. Each note is calculated relative to the note immediately preceding it. @example diff --git a/lily/context-def.cc b/lily/context-def.cc index 67e5f2a21d..cf01d38dcd 100644 --- a/lily/context-def.cc +++ b/lily/context-def.cc @@ -26,6 +26,7 @@ Context_def::Context_def () translator_mods_ = SCM_EOL; property_ops_ = SCM_EOL; context_name_ = SCM_EOL; + default_child_ = SCM_EOL; description_ = SCM_EOL; smobify_self (); @@ -43,10 +44,12 @@ Context_def::Context_def (Context_def const &s) property_ops_ = SCM_EOL; context_name_ = SCM_EOL; description_ = SCM_EOL; + default_child_ = SCM_EOL; smobify_self (); description_ = s.description_; + default_child_ = s.default_child_; accept_mods_ = s.accept_mods_; property_ops_ = s.property_ops_; translator_mods_ = s.translator_mods_; @@ -85,6 +88,7 @@ Context_def::mark_smob (SCM smob) scm_gc_mark (me->translator_mods_); scm_gc_mark (me->property_ops_); scm_gc_mark (me->translator_group_type_); + scm_gc_mark (me->default_child_); return me->context_name_; } @@ -99,11 +103,18 @@ Context_def::add_context_mod (SCM mod) return; } + /* + other modifiers take symbols as argument. + */ SCM sym = scm_cadr (mod); if (scm_is_string (sym)) sym = scm_string_to_symbol (sym); - if (ly_symbol2scm ("consists") == tag + if (ly_symbol2scm ("default-child") == tag) + { + default_child_ = scm_cadr (mod); + } + else if (ly_symbol2scm ("consists") == tag || ly_symbol2scm ("consists-end") == tag || ly_symbol2scm ("remove") == tag) { @@ -152,9 +163,36 @@ Context_def::get_accepted (SCM user_mod) const else if (tag == ly_symbol2scm ("denies")) acc = scm_delete_x (sym, acc); } + + SCM def = get_default_child (user_mod); + if (scm_is_symbol (def)) + { + if (scm_memq (def, acc)) + acc = scm_delete_x (def, acc); + acc = scm_cons (def, acc); + } + return acc; } + +SCM +Context_def::get_default_child (SCM user_mod) const +{ + SCM name = default_child_; + for (SCM s = user_mod; scm_is_pair (s); s = scm_cdr (s)) + { + SCM entry = scm_car (s); + if (scm_car (entry) == ly_symbol2scm ("default-child")) + { + name = scm_cadr (entry); + break; + } + } + + return name; +} + Link_array Context_def::path_to_acceptable_context (SCM type_sym, Output_def *odef) const { @@ -306,6 +344,12 @@ Context_def::instantiate (SCM ops, Object_key const *key) } } + + /* + Ugh, todo: should just make a private + copy of Context_def with the user mods. + */ + g->simple_trans_list_ = trans_list; tg->implementation_ = g->self_scm (); @@ -320,7 +364,7 @@ Context_def::instantiate (SCM ops, Object_key const *key) scm_gc_unprotect_object (g->self_scm ()); tg->accepts_list_ = get_accepted (ops); - + return tg; } diff --git a/lily/context.cc b/lily/context.cc index a14b25e836..dc38796158 100644 --- a/lily/context.cc +++ b/lily/context.cc @@ -276,7 +276,7 @@ SCM Context::default_child_context_name () const { return scm_is_pair (accepts_list_) - ? scm_car (scm_last_pair (accepts_list_)) + ? scm_car (accepts_list_) : SCM_EOL; } diff --git a/lily/include/context-def.hh b/lily/include/context-def.hh index 5d45e6c088..22a4c63995 100644 --- a/lily/include/context-def.hh +++ b/lily/include/context-def.hh @@ -30,12 +30,13 @@ private: SCM context_name_; SCM context_aliases_; SCM translator_group_type_; - + SCM default_child_; + public: void add_context_mod (SCM); - SCM default_child_context_name (); + SCM get_default_child (SCM user_mods) const; SCM get_context_name () const; - SCM get_accepted (SCM) const; + SCM get_accepted (SCM user_mods) const; SCM get_property_ops () const { return property_ops_; } SCM get_translator_names (SCM) const; void set_acceptor (SCM accepts, bool add); diff --git a/lily/include/context.hh b/lily/include/context.hh index e17af62e1e..db69518d27 100644 --- a/lily/include/context.hh +++ b/lily/include/context.hh @@ -35,6 +35,7 @@ protected: Object_key const *key_; Context *daddy_context_; SCM definition_; + SCM properties_scm_; SCM context_list_; SCM accepts_list_; diff --git a/lily/lily-lexer.cc b/lily/lily-lexer.cc index c81f27ef3e..a22086b676 100644 --- a/lily/lily-lexer.cc +++ b/lily/lily-lexer.cc @@ -36,6 +36,7 @@ static Keyword_ent the_key_tab[] {"consists", CONSISTS}, {"context", CONTEXT}, {"default", DEFAULT}, + {"defaultchild", DEFAULTCHILD}, {"denies", DENIES}, {"description", DESCRIPTION}, {"drummode", DRUMMODE}, diff --git a/lily/note-heads-engraver.cc b/lily/note-heads-engraver.cc index 73a467c1d7..4d9c630b3d 100644 --- a/lily/note-heads-engraver.cc +++ b/lily/note-heads-engraver.cc @@ -74,7 +74,10 @@ Note_heads_engraver::process_music () } Pitch *pit = unsmob_pitch (ev->get_property ("pitch")); - + if (!pit) + { + ev->origin ()->warning (_ ("NoteEvent without pitch")); + } int pos = pit ? pit->steps () : 0; SCM c0 = get_property ("middleCPosition"); if (scm_is_number (c0)) diff --git a/lily/parser.yy b/lily/parser.yy index db3f0ce8f9..b771f9bb4b 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -279,6 +279,7 @@ or %token CONSISTS "\\consists" %token CONTEXT "\\context" %token DEFAULT "\\default" +%token DEFAULTCHILD "\\defaultchild" %token DENIES "\\denies" %token DESCRIPTION "\\description" %token DRUMMODE "\\drummode" @@ -1423,6 +1424,7 @@ context_def_mod: | REMOVE { $$ = ly_symbol2scm ("remove"); } | ACCEPTS { $$ = ly_symbol2scm ("accepts"); } + | DEFAULTCHILD { $$ = ly_symbol2scm ("default-child"); } | DENIES { $$ = ly_symbol2scm ("denies"); } | ALIAS { $$ = ly_symbol2scm ("alias"); } diff --git a/ly/engraver-init.ly b/ly/engraver-init.ly index 4091ec98fd..f058624211 100644 --- a/ly/engraver-init.ly +++ b/ly/engraver-init.ly @@ -4,6 +4,7 @@ \name Global \accepts Score + \defaultchild Score \description "Hard coded entry point for LilyPond. Cannot be tuned." \grobdescriptions #all-grob-descriptions } @@ -50,6 +51,7 @@ instrument = #'() instr = #'() + \defaultchild "Voice" \accepts "Voice" \accepts "CueVoice" @@ -63,7 +65,6 @@ \type "Engraver_group_engraver" \name DrumStaff \alias Staff - \remove "Accidental_engraver" \remove "Ottava_spanner_engraver" \remove "Key_engraver" @@ -74,6 +75,7 @@ \denies Voice \accepts DrumVoice + \defaultchild DrumVoice clefGlyph = #"clefs.percussion" clefPosition = #0 @@ -94,12 +96,14 @@ \accepts "PianoStaff" \accepts "Lyrics" \accepts "ChordNames" + \defaultchild "Staff" } \context { \InnerChoirStaff \name ChoirStaff + \defaultchild "InnerChoirStaff" \accepts "InnerChoirStaff" \accepts "InnerStaffGroup" \description "Identical to @code{StaffGroup} except that the @@ -142,6 +146,7 @@ contained staves are not connected vertically." \consists "Axis_group_engraver" \accepts "Voice" \accepts "CueVoice" + \defaultchild "Voice" \description " A context like @code{Staff} but for printing rhythms. Pitches are ignored; the notes are printed on one line. @@ -428,6 +433,7 @@ AncientRemoveEmptyStaffContext = \context { \consists "Bar_number_engraver" \consists "Span_arpeggio_engraver" + \defaultchild "Staff" \accepts "Staff" \accepts "TabStaff" \accepts "VaticanaStaff" @@ -579,12 +585,12 @@ EasyNotation = \context { %% TODO: why \context override? \context { \type "Engraver_group_engraver" \name FiguredBass + \consists "Figured_bass_engraver" \consists "Rest_swallow_translator" \consists "Note_swallow_translator" \consists "Skip_event_swallow_translator" \consists "Separating_line_group_engraver" - \consists "Hara_kiri_engraver" } @@ -639,6 +645,7 @@ EasyNotation = \context { %% TODO: why \context override? \description "Context for generating tablature. [DOCME]" \accepts "TabVoice" + \defaultchild "TabVoice" %% 6 strings \override StaffSymbol #'staff-space = #1.5 @@ -713,6 +720,8 @@ EasyNotation = \context { %% TODO: why \context override? \alias "Staff" \denies "Voice" \accepts "VaticanaVoice" + \defaultchild "VaticanaVoice" + \description "Same as @code{Staff} context, except that it is accommodated for tyepsetting Gregorian Chant in the notational style of Editio Vaticana." \remove "Time_signature_engraver" @@ -787,6 +796,7 @@ EasyNotation = \context { %% TODO: why \context override? \alias "Staff" \denies "Voice" \accepts "GregorianTranscriptionVoice" + \defaultchild "GregorianTranscriptionVoice" %% We can not remove Bar_engraver; otherwise clefs and custodes will %% not show up any more among other line breaking issues. @@ -816,6 +826,7 @@ EasyNotation = \context { %% TODO: why \context override? \name "MensuralStaff" \alias "Staff" \denies "Voice" + \defaultchild "MensuralVoice" \accepts "MensuralVoice" \description "Same as @code{Staff} context, except that it is accommodated for tyepsetting a piece in mensural style." -- 2.39.2