From a7f82e4dc22fc6219a9fe0f6874f8c91e3f31f24 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Mon, 18 Jul 2005 23:37:26 +0000 Subject: [PATCH] * lily/include/translator.icc: new file. * lily/paper-column-engraver.cc (process_music): new file. Separate Paper_column factory from Score_engraver. * lily/vertically-spaced-context-engraver.cc: administer spaceable-staves property of System. * lily/translator-group-ctors.cc: new file. * lily/context-property.cc (make_grob_from_properties): construct the right Grob class programmatically, looking at the class entry for the meta property. * lily/break-align-engraver.cc (stop_translation_timestep): call Break_align_interface::add_element() directly. * lily/context.cc (measure_position): measure_position() is now a normal function. * lily/include/translator.hh (class Translator): rename process_acknowledged_grobs() to process_acknowledged() and move to Translator. * scm/define-grobs.scm (all-grob-descriptions): add a 'class meta field for each grob description. * lily/include/translator-group.hh (class Translator_group): change to base class. Separate class from Translator. This gets rid of virtual inheritance for Engravers/Performers. * lily/staff-performer.cc (class Staff_performer): derive Staff_performer from Performer, not Performer_group_performer * Lily/translator-group.cc (precomputed_recurse_over_translators): new function. (precompute_method_bindings): new function. Precompute lists of Translators, so we only call methods (process_music, start_translation_timestep, etc.) for Translators needing it. Also: dispose of pointer-to-member-function calls. * lily/engraver-group-engraver.cc: remove engraver_each, recurse_down_engravers () * lily/note-head.cc (internal_print): only call glyph-name-procedure if style != default. 3 % speed increase (wtk2-fugue1). --- ChangeLog | 49 ++ Documentation/user/advanced-notation.itely | 25 +- Documentation/user/basic-notation.itely | 2 +- Documentation/user/changing-defaults.itely | 19 +- lily/accidental-engraver.cc | 10 +- lily/ambitus-engraver.cc | 8 +- lily/arpeggio-engraver.cc | 6 +- lily/auto-beam-engraver.cc | 12 +- lily/axis-group-engraver.cc | 6 +- lily/axis-group-interface.cc | 1 + lily/bar-engraver.cc | 10 +- lily/bar-number-engraver.cc | 6 +- lily/beam-engraver.cc | 8 +- lily/beam-performer.cc | 6 +- lily/break-align-engraver.cc | 30 +- lily/break-align-interface.cc | 3 +- lily/breathing-sign-engraver.cc | 8 +- lily/chord-name-engraver.cc | 6 +- lily/chord-tremolo-engraver.cc | 8 +- lily/clef-engraver.cc | 6 +- lily/cluster-engraver.cc | 6 +- lily/coherent-ligature-engraver.cc | 2 + lily/collision-engraver.cc | 8 +- lily/completion-note-heads-engraver.cc | 8 +- lily/context-def.cc | 25 +- lily/context-property.cc | 50 +- lily/context.cc | 52 +- lily/custos-engraver.cc | 10 +- lily/dot-column-engraver.cc | 4 +- lily/dot-column.cc | 1 + lily/drum-note-engraver.cc | 6 +- lily/drum-note-performer.cc | 13 +- lily/dynamic-engraver.cc | 7 +- lily/dynamic-performer.cc | 4 +- lily/engraver-group-engraver.cc | 79 +--- lily/engraver.cc | 4 +- lily/extender-engraver.cc | 6 +- lily/figured-bass-engraver.cc | 6 +- lily/fingering-engraver.cc | 8 +- lily/font-size-engraver.cc | 2 + lily/forbid-break-engraver.cc | 4 +- lily/glissando-engraver.cc | 6 +- lily/grace-engraver.cc | 4 +- lily/gregorian-ligature-engraver.cc | 2 + lily/grid-line-span-engraver.cc | 4 +- lily/grid-point-engraver.cc | 4 +- lily/grob-pq-engraver.cc | 6 +- lily/hara-kiri-engraver.cc | 4 +- lily/hara-kiri-group-spanner.cc | 1 + lily/horizontal-bracket-engraver.cc | 6 +- lily/hyphen-engraver.cc | 6 +- lily/include/accidental-interface.hh | 3 +- lily/include/axis-group-engraver.hh | 4 +- lily/include/axis-group-interface.hh | 3 +- lily/include/context.hh | 3 + lily/include/engraver-group-engraver.hh | 9 +- lily/include/engraver.hh | 11 +- lily/include/gregorian-ligature-engraver.hh | 2 +- lily/include/ligature-engraver.hh | 4 +- lily/include/paper-column-engraver.hh | 46 ++ lily/include/performer-group-performer.hh | 9 +- lily/include/performer.hh | 2 +- lily/include/recording-group-engraver.hh | 31 ++ lily/include/score-engraver.hh | 12 +- lily/include/score-performer.hh | 3 +- lily/include/staff-symbol-engraver.hh | 4 +- lily/include/timing-translator.hh | 9 +- lily/include/translator-group.hh | 65 ++- lily/include/translator.hh | 85 ++-- lily/include/translator.icc | 109 +++++ lily/include/type-swallow-translator.hh | 2 +- lily/instrument-name-engraver.cc | 8 +- lily/item.cc | 1 - lily/key-engraver.cc | 8 +- lily/key-performer.cc | 4 +- lily/ledger-line-engraver.cc | 4 +- lily/ligature-bracket-engraver.cc | 2 + lily/ligature-engraver.cc | 2 + lily/lyric-engraver.cc | 6 +- lily/lyric-performer.cc | 4 +- lily/mark-engraver.cc | 6 +- lily/measure-grouping-engraver.cc | 4 +- lily/melisma-translator.cc | 6 +- lily/mensural-ligature-engraver.cc | 2 + lily/metronome-engraver.cc | 6 +- lily/multi-measure-rest-engraver.cc | 8 +- lily/new-fingering-engraver.cc | 4 +- lily/note-collision.cc | 1 + lily/note-column.cc | 1 + lily/note-head-line-engraver.cc | 8 +- lily/note-head.cc | 5 +- lily/note-heads-engraver.cc | 6 +- lily/note-name-engraver.cc | 6 +- lily/note-performer.cc | 4 +- lily/ottava-engraver.cc | 6 +- lily/output-property-engraver.cc | 4 +- lily/paper-column-engraver.cc | 235 +++++++++ lily/part-combine-engraver.cc | 6 +- lily/percent-repeat-engraver.cc | 8 +- lily/performer-group-performer.cc | 42 +- lily/performer.cc | 1 + lily/phrasing-slur-engraver.cc | 6 +- lily/piano-pedal-engraver.cc | 6 +- lily/piano-pedal-performer.cc | 6 +- lily/pitch-squash-engraver.cc | 2 + lily/pitched-trill-engraver.cc | 6 +- lily/recording-group-engraver.cc | 48 +- lily/repeat-acknowledge-engraver.cc | 7 +- lily/rest-collision-engraver.cc | 8 +- lily/rest-engraver.cc | 8 +- lily/rhythmic-column-engraver.cc | 8 +- lily/score-context.cc | 8 +- lily/score-engraver.cc | 202 ++------ lily/score-performer.cc | 18 +- lily/script-column-engraver.cc | 9 +- lily/script-engraver.cc | 6 +- lily/separating-line-group-engraver.cc | 12 +- lily/slash-repeat-engraver.cc | 8 +- lily/slur-engraver.cc | 6 +- lily/slur-performer.cc | 6 +- lily/spacing-engraver.cc | 8 +- lily/span-arpeggio-engraver.cc | 8 +- lily/span-bar-engraver.cc | 4 +- lily/span-bar.cc | 2 + lily/span-dynamic-performer.cc | 6 +- lily/spanner.cc | 2 - lily/staff-collecting-engraver.cc | 2 + lily/staff-performer.cc | 16 +- lily/staff-symbol-engraver.cc | 2 + lily/stanza-number-align-engraver.cc | 4 +- lily/stanza-number-engraver.cc | 6 +- lily/stem-engraver.cc | 4 +- lily/string-number-engraver.cc | 2 + lily/swallow-engraver.cc | 2 + lily/swallow-perf.cc | 2 + lily/system-start-delimiter-engraver.cc | 4 +- lily/system-start-delimiter.cc | 1 + lily/system.cc | 29 +- lily/tab-note-heads-engraver.cc | 6 +- lily/tab-staff-symbol-engraver.cc | 2 + lily/tempo-performer.cc | 4 +- lily/text-engraver.cc | 8 +- lily/text-spanner-engraver.cc | 6 +- lily/tie-engraver.cc | 8 +- lily/tie-performer.cc | 8 +- lily/time-signature-engraver.cc | 6 +- lily/time-signature-performer.cc | 4 +- lily/timing-engraver.cc | 66 +-- lily/timing-translator.cc | 28 +- lily/translator-group-ctors.cc | 36 ++ lily/translator-group.cc | 131 ++++- lily/translator-scheme.cc | 10 - lily/translator.cc | 24 +- lily/trill-spanner-engraver.cc | 6 +- lily/tuplet-engraver.cc | 6 +- lily/type-swallow-translator.cc | 12 +- lily/vaticana-ligature-engraver.cc | 2 + lily/vertical-align-engraver.cc | 4 +- lily/vertically-spaced-context-engraver.cc | 67 +++ lily/volta-engraver.cc | 6 +- ly/engraver-init.ly | 9 +- ly/performer-init.ly | 8 +- scm/define-context-properties.scm | 14 +- scm/define-grobs.scm | 498 ++++++++++++-------- scm/document-translation.scm | 10 +- scm/framework-scm.scm | 4 +- 166 files changed, 1919 insertions(+), 959 deletions(-) create mode 100644 lily/include/paper-column-engraver.hh create mode 100644 lily/include/recording-group-engraver.hh create mode 100644 lily/include/translator.icc create mode 100644 lily/paper-column-engraver.cc create mode 100644 lily/translator-group-ctors.cc create mode 100644 lily/vertically-spaced-context-engraver.cc diff --git a/ChangeLog b/ChangeLog index 8990771339..e28aa7f588 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,52 @@ +2005-07-19 Han-Wen Nienhuys + + * lily/include/translator.icc: new file. + + * lily/paper-column-engraver.cc (process_music): new + file. Separate Paper_column factory from Score_engraver. + + * lily/vertically-spaced-context-engraver.cc: administer + spaceable-staves property of System. + + * lily/translator-group-ctors.cc: new file. + + * lily/context-property.cc (make_grob_from_properties): construct + the right Grob class programmatically, looking at the class entry + for the meta property. + + * lily/break-align-engraver.cc (stop_translation_timestep): call + Break_align_interface::add_element() directly. + + * lily/context.cc (measure_position): measure_position() is now a + normal function. + + * lily/include/translator.hh (class Translator): rename + process_acknowledged_grobs() to process_acknowledged() and move to + Translator. + + * scm/define-grobs.scm (all-grob-descriptions): add a 'class meta + field for each grob description. + + * lily/include/translator-group.hh (class Translator_group): + change to base class. Separate class from Translator. This gets + rid of virtual inheritance for Engravers/Performers. + + * lily/staff-performer.cc (class Staff_performer): derive + Staff_performer from Performer, not Performer_group_performer + + * Lily/translator-group.cc (precomputed_recurse_over_translators): + new function. + (precompute_method_bindings): new function. Precompute lists of + Translators, so we only call methods (process_music, + start_translation_timestep, etc.) for Translators needing + it. Also: dispose of pointer-to-member-function calls. + + * lily/engraver-group-engraver.cc: remove engraver_each, + recurse_down_engravers () + + * lily/note-head.cc (internal_print): only call + glyph-name-procedure if style != default. 3 % speed increase (wtk2-fugue1). + 2005-07-16 Graham Percival * ly/titling-init.ly: add printallheaders option. diff --git a/Documentation/user/advanced-notation.itely b/Documentation/user/advanced-notation.itely index afd7e54352..b71f053475 100644 --- a/Documentation/user/advanced-notation.itely +++ b/Documentation/user/advanced-notation.itely @@ -1455,13 +1455,21 @@ tsMarkup =\markup { @end lilypond Each staff can also have its own time signature. This is done by -moving the @internalsref{Timing_engraver} to the @internalsref{Staff} +moving the @internalsref{Timing_translator} to the @internalsref{Staff} context. @example \layout @{ - \context @{ \Score \remove "Timing_engraver" @} - \context @{ \Staff \consists "Timing_engraver" @} + \context @{ \Score + \remove "Timing_translator" + \remove "Default_bar_line_engraver" + @} + \context @{ + \Staff + \consists "Timing_translator" + \consists "Default_bar_line_engraver" + @} + @} @end example @@ -1486,8 +1494,15 @@ Now, each staff has its own time signature. @lilypond[quote,raggedright] \layout{ - \context{ \Score \remove "Timing_engraver" } - \context{ \Staff \consists "Timing_engraver" } + \context{ + \Score + \remove "Timing_translator" + \remove "Default_bar_line_engraver" + } + \context{ \Staff + \consists "Timing_translator" + \consist "Default_bar_line_engraver" + } } \relative c' << diff --git a/Documentation/user/basic-notation.itely b/Documentation/user/basic-notation.itely index 7ab1949fe2..d5646c2ac8 100644 --- a/Documentation/user/basic-notation.itely +++ b/Documentation/user/basic-notation.itely @@ -1072,7 +1072,7 @@ measure is subdivided in 2, 2, 2 and 3. This is passed to @seealso -Program reference: @internalsref{TimeSignature}, and @internalsref{Timing_engraver}. +Program reference: @internalsref{TimeSignature}, and @internalsref{Timing_translator}. @refbugs diff --git a/Documentation/user/changing-defaults.itely b/Documentation/user/changing-defaults.itely index 58ae5e1833..526b8490ff 100644 --- a/Documentation/user/changing-defaults.itely +++ b/Documentation/user/changing-defaults.itely @@ -436,27 +436,30 @@ sophisticated method of blanking objects is shown in @ref{Common tweaks}. The next example shows a practical application. Bar lines and time signatures are normally synchronized across the score. This is done -by the @code{Timing_engraver}. This plug-in keeps an administration of -time signature, location within the measure, etc. By moving the -@code{Timing_engraver} engraver from @code{Score} to @code{Staff} -context, we can have a score where each staff has its own time -signature. +by the @code{Timing_translator} and @code{Default_bar_line_engraver}. +This plug-in keeps an administration of time signature, location +within the measure, etc. By moving thes engraver from @code{Score} to +@code{Staff} context, we can have a score where each staff has its own +time signature. @cindex polymetric scores @cindex Time signatures, multiple @lilypond[quote,relative=1,raggedright,verbatim,fragment] \new Score \with { - \remove "Timing_engraver" + \remove "Timing_translator" + \remove "Default_bar_line_engraver" } << \new Staff \with { - \consists "Timing_engraver" + \consists "Timing_translator" + \consists "Default_bar_line_engraver" } { \time 3/4 c4 c c c c c } \new Staff \with { - \consists "Timing_engraver" + \consists "Timing_translator" + \consists "Default_bar_line_engraver" } { \time 2/4 c4 c c c c c diff --git a/lily/accidental-engraver.cc b/lily/accidental-engraver.cc index 971f976239..6898520441 100644 --- a/lily/accidental-engraver.cc +++ b/lily/accidental-engraver.cc @@ -19,6 +19,8 @@ #include "music.hh" #include "pitch.hh" +#include "translator.icc" + class Accidental_entry { public: @@ -51,11 +53,11 @@ public: protected: TRANSLATOR_DECLARATIONS (Accidental_engraver); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void process_music (); virtual void acknowledge_grob (Grob_info); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); virtual void initialize (); - virtual void process_acknowledged_grobs (); + PRECOMPUTED_VIRTUAL void process_acknowledged (); virtual void finalize (); virtual void derived_mark () const; @@ -301,7 +303,7 @@ Accidental_engraver::get_bar_number () } void -Accidental_engraver::process_acknowledged_grobs () +Accidental_engraver::process_acknowledged () { if (accidentals_.size () && !accidentals_.top ().done_) { diff --git a/lily/ambitus-engraver.cc b/lily/ambitus-engraver.cc index a07b04fa05..82f05c3974 100644 --- a/lily/ambitus-engraver.cc +++ b/lily/ambitus-engraver.cc @@ -16,13 +16,15 @@ #include "axis-group-interface.hh" #include "side-position-interface.hh" +#include "translator.icc" + class Ambitus_engraver : public Engraver { public: TRANSLATOR_DECLARATIONS (Ambitus_engraver); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void process_music (); virtual void acknowledge_grob (Grob_info); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); virtual void finalize (); virtual void derived_mark () const; @@ -185,6 +187,8 @@ Ambitus_engraver::finalize () } } +#include "translator.icc" + ADD_TRANSLATOR (Ambitus_engraver, /* descr */ "", /* creats*/ "Ambitus AmbitusLine AmbitusNoteHead AmbitusAccidental", diff --git a/lily/arpeggio-engraver.cc b/lily/arpeggio-engraver.cc index fc324c1582..856b5a7303 100644 --- a/lily/arpeggio-engraver.cc +++ b/lily/arpeggio-engraver.cc @@ -15,6 +15,8 @@ #include "side-position-interface.hh" #include "note-column.hh" +#include "translator.icc" + class Arpeggio_engraver : public Engraver { public: @@ -22,8 +24,8 @@ public: protected: virtual void acknowledge_grob (Grob_info); - virtual void process_music (); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_music (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); virtual bool try_music (Music *); private: Item *arpeggio_; diff --git a/lily/auto-beam-engraver.cc b/lily/auto-beam-engraver.cc index 636caeae8a..a83b635329 100644 --- a/lily/auto-beam-engraver.cc +++ b/lily/auto-beam-engraver.cc @@ -18,19 +18,21 @@ #include "context.hh" #include "duration.hh" +#include "translator.icc" + class Auto_beam_engraver : public Engraver { TRANSLATOR_DECLARATIONS (Auto_beam_engraver); protected: - virtual void stop_translation_timestep (); - virtual void start_translation_timestep (); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void start_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_music (); virtual bool try_music (Music *); virtual void finalize (); virtual void acknowledge_grob (Grob_info); - virtual void process_acknowledged_grobs (); + PRECOMPUTED_VIRTUAL void process_acknowledged (); private: bool test_moment (Direction, Moment); @@ -367,7 +369,7 @@ Auto_beam_engraver::acknowledge_grob (Grob_info info) } void -Auto_beam_engraver::process_acknowledged_grobs () +Auto_beam_engraver::process_acknowledged () { if (extend_mom_ > now_mom ()) return ; diff --git a/lily/axis-group-engraver.cc b/lily/axis-group-engraver.cc index 965d16db4c..105c925397 100644 --- a/lily/axis-group-engraver.cc +++ b/lily/axis-group-engraver.cc @@ -9,12 +9,12 @@ #include "axis-group-engraver.hh" #include "spanner.hh" -#include "paper-column.hh" #include "axis-group-interface.hh" -#include "engraver-group-engraver.hh" #include "warn.hh" #include "context.hh" +#include "translator.icc" + Axis_group_engraver::Axis_group_engraver () { must_be_last_ = true; @@ -80,7 +80,7 @@ Axis_group_engraver::acknowledge_grob (Grob_info i) cyclic parent relationship if we have two Axis_group_engravers in the context. */ void -Axis_group_engraver::process_acknowledged_grobs () +Axis_group_engraver::process_acknowledged () { if (!staffline_) return; diff --git a/lily/axis-group-interface.cc b/lily/axis-group-interface.cc index 5de3914400..24838b9be0 100644 --- a/lily/axis-group-interface.cc +++ b/lily/axis-group-interface.cc @@ -8,6 +8,7 @@ #include "axis-group-interface.hh" +#include "pointer-group-interface.hh" #include "grob.hh" #include "hara-kiri-group-spanner.hh" #include "warn.hh" diff --git a/lily/bar-engraver.cc b/lily/bar-engraver.cc index dad72a4fe4..c67ee1a309 100644 --- a/lily/bar-engraver.cc +++ b/lily/bar-engraver.cc @@ -12,6 +12,8 @@ #include "warn.hh" #include "item.hh" +#include "translator.icc" + /* generate bars. Either user ("|:"), or default (new measure) */ @@ -23,8 +25,8 @@ public: protected: virtual void finalize (); - virtual void stop_translation_timestep (); - virtual void process_acknowledged_grobs (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_acknowledged (); private: void typeset_bar (); @@ -63,12 +65,12 @@ Bar_engraver::finalize () This is a little hairy : whichBar may be set by Repeat_acknowledge_engraver::process_music, which is at score context. This means that grobs could should be created after - process_music. We do stuff process_acknowledged_grobs (), just to be + process_music. We do stuff process_acknowledged (), just to be on the safe side. */ void -Bar_engraver::process_acknowledged_grobs () +Bar_engraver::process_acknowledged () { if (!bar_ && scm_is_string (get_property ("whichBar"))) create_bar (); diff --git a/lily/bar-number-engraver.cc b/lily/bar-number-engraver.cc index 9b3eedb1bf..7fc92c0a5d 100644 --- a/lily/bar-number-engraver.cc +++ b/lily/bar-number-engraver.cc @@ -13,6 +13,8 @@ #include "context.hh" #include "grob-array.hh" +#include "translator.icc" + /* TODO: detect the top staff (stavesFound), and acknowledge staff-group system-start-delims. If we find these, and the top staff is in the @@ -24,9 +26,9 @@ class Bar_number_engraver : public Engraver protected: Item *text_; protected: - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); virtual void acknowledge_grob (Grob_info); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void process_music (); void create_items (); TRANSLATOR_DECLARATIONS (Bar_number_engraver); }; diff --git a/lily/beam-engraver.cc b/lily/beam-engraver.cc index 8a9bb34b2d..da3354134a 100644 --- a/lily/beam-engraver.cc +++ b/lily/beam-engraver.cc @@ -19,6 +19,8 @@ #include "context.hh" #include "duration.hh" +#include "translator.icc" + class Beam_engraver : public Engraver { protected: @@ -46,13 +48,13 @@ protected: void set_melisma (bool); Moment last_stem_added_at_; - virtual void stop_translation_timestep (); - virtual void start_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void start_translation_timestep (); virtual void finalize (); virtual void acknowledge_grob (Grob_info); virtual bool try_music (Music *); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void process_music (); virtual bool valid_start_point (); virtual bool valid_end_point (); diff --git a/lily/beam-performer.cc b/lily/beam-performer.cc index 679bb6b352..861f66f35a 100644 --- a/lily/beam-performer.cc +++ b/lily/beam-performer.cc @@ -13,6 +13,8 @@ #include "warn.hh" #include "music.hh" +#include "translator.icc" + class Beam_performer : public Performer { public: @@ -20,8 +22,8 @@ public: protected: virtual bool try_music (Music *ev); - virtual void start_translation_timestep (); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void start_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_music (); void set_melisma (bool); private: Music *start_ev_; diff --git a/lily/break-align-engraver.cc b/lily/break-align-engraver.cc index 11cfa556c4..affc8a63a0 100644 --- a/lily/break-align-engraver.cc +++ b/lily/break-align-engraver.cc @@ -13,6 +13,8 @@ #include "context.hh" #include "translator-group.hh" +#include "translator.icc" + class Break_align_engraver : public Engraver { Item *align_; @@ -22,29 +24,15 @@ class Break_align_engraver : public Engraver void add_to_group (SCM, Item *); protected: virtual void acknowledge_grob (Grob_info i); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); virtual void derived_mark () const; - void add_column (SCM); - public: TRANSLATOR_DECLARATIONS (Break_align_engraver); }; -void -Break_align_engraver::add_column (SCM smob) -{ - Grob *e = unsmob_grob (smob); - Break_align_interface::add_element (align_, e); -} - void Break_align_engraver::stop_translation_timestep () { - for (SCM p = column_alist_; scm_is_pair (p); p = scm_cdr (p)) - { - SCM pair = scm_car (p); - add_column (scm_cdr (pair)); - } column_alist_ = SCM_EOL; align_ = 0; @@ -89,8 +77,14 @@ Break_align_engraver::acknowledge_grob (Grob_info inf) align_ = make_item ("BreakAlignment", SCM_EOL); Context *origin = inf.origin_contexts (this)[0]; - left_edge_ = make_item_from_properties (dynamic_cast - (origin->implementation ()), + + Translator_group *tg = origin ->implementation (); + Engraver *random_source = dynamic_cast (unsmob_translator (scm_car (tg->get_simple_trans_list ()))); + + /* + Make left edge appear to come from same context as clef/bar-line etc. + */ + left_edge_ = make_item_from_properties (random_source, ly_symbol2scm ("LeftEdge"), SCM_EOL, "LeftEdge"); @@ -121,6 +115,8 @@ Break_align_engraver::add_to_group (SCM align_name, Item *item) group->set_parent (align_, Y_AXIS); column_alist_ = scm_assoc_set_x (column_alist_, align_name, group->self_scm ()); + + Break_align_interface::add_element (align_, group); } Axis_group_interface::add_element (group, item); } diff --git a/lily/break-align-interface.cc b/lily/break-align-interface.cc index d9d977af51..7d377cefdd 100644 --- a/lily/break-align-interface.cc +++ b/lily/break-align-interface.cc @@ -9,8 +9,9 @@ #include #include "break-align-interface.hh" -#include "libc-extension.hh" // isinf +#include "libc-extension.hh" // isinf +#include "pointer-group-interface.hh" #include "self-alignment-interface.hh" #include "side-position-interface.hh" #include "axis-group-interface.hh" diff --git a/lily/breathing-sign-engraver.cc b/lily/breathing-sign-engraver.cc index ba23eede6d..32ba194d03 100644 --- a/lily/breathing-sign-engraver.cc +++ b/lily/breathing-sign-engraver.cc @@ -24,8 +24,8 @@ public: protected: virtual bool try_music (Music *req); - virtual void process_acknowledged_grobs (); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_acknowledged (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); private: Music *breathing_sign_req_; @@ -46,7 +46,7 @@ Breathing_sign_engraver::try_music (Music *r) } void -Breathing_sign_engraver::process_acknowledged_grobs () +Breathing_sign_engraver::process_acknowledged () { if (breathing_sign_req_ && ! breathing_sign_) { @@ -62,6 +62,8 @@ Breathing_sign_engraver::stop_translation_timestep () breathing_sign_req_ = 0; } +#include "translator.icc" + ADD_TRANSLATOR (Breathing_sign_engraver, /* descr */ "", /* creats*/ "BreathingSign", diff --git a/lily/chord-name-engraver.cc b/lily/chord-name-engraver.cc index d3109d4d14..8256b32aa0 100644 --- a/lily/chord-name-engraver.cc +++ b/lily/chord-name-engraver.cc @@ -22,8 +22,8 @@ class Chord_name_engraver : public Engraver { TRANSLATOR_DECLARATIONS (Chord_name_engraver); protected: - virtual void stop_translation_timestep (); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_music (); virtual bool try_music (Music *); virtual void finalize (); virtual void derived_mark () const; @@ -150,6 +150,8 @@ Chord_name_engraver::stop_translation_timestep () The READs description is not strictly accurate: which properties are read depend on the chord naming function active. */ +#include "translator.icc" + ADD_TRANSLATOR (Chord_name_engraver, /* descr */ "Catch note-events " "and generate the appropriate chordname.", diff --git a/lily/chord-tremolo-engraver.cc b/lily/chord-tremolo-engraver.cc index e3d3078ecc..7bb5d93a2b 100644 --- a/lily/chord-tremolo-engraver.cc +++ b/lily/chord-tremolo-engraver.cc @@ -57,9 +57,9 @@ protected: virtual void finalize (); virtual bool try_music (Music *); virtual void acknowledge_grob (Grob_info); - virtual void stop_translation_timestep (); - virtual void start_translation_timestep (); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void start_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_music (); }; Chord_tremolo_engraver::Chord_tremolo_engraver () @@ -207,6 +207,8 @@ Chord_tremolo_engraver::stop_translation_timestep () typeset_beam (); } +#include "translator.icc" + ADD_TRANSLATOR (Chord_tremolo_engraver, /* descr */ "Generates beams for tremolo repeats.", /* creats*/ "Beam", diff --git a/lily/clef-engraver.cc b/lily/clef-engraver.cc index e7a0d00304..090647ae71 100644 --- a/lily/clef-engraver.cc +++ b/lily/clef-engraver.cc @@ -25,8 +25,8 @@ public: Direction octave_dir_; protected: - virtual void stop_translation_timestep (); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_music (); virtual void acknowledge_grob (Grob_info); private: Item *clef_; @@ -182,6 +182,8 @@ Clef_engraver::stop_translation_timestep () } } +#include "translator.icc" + ADD_TRANSLATOR (Clef_engraver, /* descr */ "Determine and set reference point for pitches", /* creats*/ "Clef OctavateEight", diff --git a/lily/cluster-engraver.cc b/lily/cluster-engraver.cc index 838156145b..b64e80f8fb 100644 --- a/lily/cluster-engraver.cc +++ b/lily/cluster-engraver.cc @@ -19,9 +19,9 @@ class Cluster_spanner_engraver : public Engraver protected: TRANSLATOR_DECLARATIONS (Cluster_spanner_engraver); virtual bool try_music (Music *); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void process_music (); virtual void acknowledge_grob (Grob_info); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); virtual void finalize (); private: Link_array cluster_notes_; @@ -125,6 +125,8 @@ Cluster_spanner_engraver::acknowledge_grob (Grob_info info) } } +#include "translator.icc" + ADD_TRANSLATOR (Cluster_spanner_engraver, /* descr */ "Engraves a cluster using Spanner notation ", /* creats*/ "ClusterSpanner ClusterSpannerBeacon", diff --git a/lily/coherent-ligature-engraver.cc b/lily/coherent-ligature-engraver.cc index 9fd9930f7d..160ca72963 100644 --- a/lily/coherent-ligature-engraver.cc +++ b/lily/coherent-ligature-engraver.cc @@ -217,6 +217,8 @@ Coherent_ligature_engraver::typeset_ligature (Spanner *ligature, collect_accidentals (ligature, primitives); } +#include "translator.icc" + ADD_TRANSLATOR (Coherent_ligature_engraver, /* descr */ "This is an abstract class. Subclasses such as Gregorian_ligature_engraver handle ligatures by glueing special ligature heads together.", /* creats*/ "", diff --git a/lily/collision-engraver.cc b/lily/collision-engraver.cc index 66813fb37c..0c5b63b89c 100644 --- a/lily/collision-engraver.cc +++ b/lily/collision-engraver.cc @@ -19,14 +19,14 @@ class Collision_engraver : public Engraver protected: virtual void acknowledge_grob (Grob_info); - virtual void process_acknowledged_grobs (); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_acknowledged (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); public: TRANSLATOR_DECLARATIONS (Collision_engraver); }; void -Collision_engraver::process_acknowledged_grobs () +Collision_engraver::process_acknowledged () { if (col_ || note_columns_.size () < 2) return; @@ -64,6 +64,8 @@ Collision_engraver::Collision_engraver () col_ = 0; } +#include "translator.icc" + ADD_TRANSLATOR (Collision_engraver, /* descr */ "Collect NoteColumns, and as soon as there are two or more, put them in a NoteCollision object.", /* creats*/ "NoteCollision", diff --git a/lily/completion-note-heads-engraver.cc b/lily/completion-note-heads-engraver.cc index 88ca639052..23ab662adc 100644 --- a/lily/completion-note-heads-engraver.cc +++ b/lily/completion-note-heads-engraver.cc @@ -65,10 +65,10 @@ public: protected: virtual void initialize (); - virtual void start_translation_timestep (); + PRECOMPUTED_VIRTUAL void start_translation_timestep (); virtual bool try_music (Music *req); - virtual void process_music (); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_music (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); }; void @@ -312,6 +312,8 @@ Completion_heads_engraver::Completion_heads_engraver () { } +#include "translator.icc" + ADD_TRANSLATOR (Completion_heads_engraver, /* descr */ "This engraver replaces " "@code{Note_heads_engraver}. It plays some trickery to " diff --git a/lily/context-def.cc b/lily/context-def.cc index fc9466fb1a..43194b3cac 100644 --- a/lily/context-def.cc +++ b/lily/context-def.cc @@ -293,21 +293,18 @@ filter_engravers (SCM ell) Context * Context_def::instantiate (SCM ops, Object_key const *key) { - Context *tg = 0; + Context *context = 0; if (context_name_ == ly_symbol2scm ("Score")) - tg = new Score_context (key); + context = new Score_context (key); else - tg = new Context (key); + context = new Context (key); - tg->definition_ = self_scm (); + context->definition_ = self_scm (); SCM trans_names = get_translator_names (ops); - Translator_group *g = dynamic_cast - (get_translator (translator_group_type_)); - g = dynamic_cast (g->clone ()); - + Translator_group *g = get_translator_group (translator_group_type_); SCM trans_list = SCM_EOL; for (SCM s = trans_names; scm_is_pair (s); s = scm_cdr (s)) @@ -333,7 +330,7 @@ Context_def::instantiate (SCM ops, Object_key const *key) trans_list = scm_cons (str, trans_list); } - tr->daddy_context_ = tg; + tr->daddy_context_ = context; scm_gc_unprotect_object (str); } } @@ -346,20 +343,20 @@ Context_def::instantiate (SCM ops, Object_key const *key) g->simple_trans_list_ = trans_list; - tg->implementation_ = g->self_scm (); + context->implementation_ = g->self_scm (); if (dynamic_cast (g)) g->simple_trans_list_ = filter_performers (g->simple_trans_list_); else if (dynamic_cast (g)) g->simple_trans_list_ = filter_engravers (g->simple_trans_list_); - g->daddy_context_ = tg; - tg->aliases_ = context_aliases_; + g->context_ = context; + context->aliases_ = context_aliases_; scm_gc_unprotect_object (g->self_scm ()); - tg->accepts_list_ = get_accepted (ops); + context->accepts_list_ = get_accepted (ops); - return tg; + return context; } SCM diff --git a/lily/context-property.cc b/lily/context-property.cc index 15685b1c22..5c0789943e 100644 --- a/lily/context-property.cc +++ b/lily/context-property.cc @@ -13,6 +13,7 @@ #include "main.hh" #include "spanner.hh" #include "warn.hh" +#include "paper-column.hh" /* Grob descriptions (ie. alists with layout properties) are @@ -191,30 +192,51 @@ updated_grob_properties (Context *tg, SCM sym) } } -Item * -make_item_from_properties (Engraver *tr, SCM x, SCM cause, const char *name) +Grob * +make_grob_from_properties (Engraver *tr, SCM symbol, SCM cause, const char *name) { Context *context = tr->context (); - SCM props = updated_grob_properties (context, x); + SCM props = updated_grob_properties (context, symbol); Object_key const *key = context->get_grob_key (name); - Item *it = new Item (props, key); - - dynamic_cast (tr)->announce_grob (it, cause); + Grob *grob = 0; + + SCM handle = scm_sloppy_assq (ly_symbol2scm ("meta"), props); + SCM klass = scm_cdr (scm_sloppy_assq (ly_symbol2scm ("class"), scm_cdr (handle))); + + if (klass == ly_symbol2scm ("Item")) + grob = new Item (props, key); + else if (klass == ly_symbol2scm ("Spanner")) + grob = new Spanner (props, key); + else if (klass == ly_symbol2scm ("Paper_column")) + grob = new Paper_column (props, key); + + assert (grob); + dynamic_cast (tr)->announce_grob (grob, cause); + + return grob; +} +Item * +make_item_from_properties (Engraver *tr, SCM x, SCM cause, const char *name) +{ + Item *it = dynamic_cast (make_grob_from_properties (tr, x, cause, name)); + assert (it); return it; } -Spanner * -make_spanner_from_properties (Engraver *tr, SCM x, SCM cause, const char *name) +Paper_column * +make_paper_column_from_properties (Engraver *tr, SCM x, const char *name) { - Context *context = tr->context (); - - SCM props = updated_grob_properties (context, x); - Spanner *it = new Spanner (props, context->get_grob_key (name)); + return dynamic_cast (make_grob_from_properties (tr, x, SCM_EOL, name)); +} - dynamic_cast (tr)->announce_grob (it, cause); - return it; +Spanner * +make_spanner_from_properties (Engraver *tr, SCM x, SCM cause, const char *name) +{ + Spanner* sp = dynamic_cast (make_grob_from_properties (tr, x, cause, name)); + assert (sp); + return sp; } diff --git a/lily/context.cc b/lily/context.cc index 52b0b4332c..4efc562baf 100644 --- a/lily/context.cc +++ b/lily/context.cc @@ -36,7 +36,9 @@ Context::check_removal () trg->check_removal (); if (trg->is_removable ()) { - recurse_over_translators (trg, &Translator::finalize, UP); + recurse_over_translators (trg, &Translator::finalize, + &Translator_group::finalize, + UP); remove_context (trg); } } @@ -72,7 +74,10 @@ Context::add_context (Context *t) operations require that we are in the hierarchy. */ td->apply_default_property_operations (t); - recurse_over_translators (t, &Translator::initialize, DOWN); + recurse_over_translators (t, + &Translator::initialize, + &Translator_group::initialize, + DOWN); } } @@ -485,10 +490,10 @@ Context::print_smob (SCM s, SCM port, scm_print_state *) scm_display (d->get_context_name (), port); } - if (Context *td = dynamic_cast (sc)) + if (!sc->id_string_.is_empty ()) { scm_puts ("=", port); - scm_puts (td->id_string_.to_str0 (), port); + scm_puts (sc->id_string_.to_str0 (), port); } scm_puts (" ", port); @@ -523,7 +528,7 @@ IMPLEMENT_TYPE_P (Context, "ly:context?"); bool Context::try_music (Music *m) { - Translator *t = implementation (); + Translator_group *t = implementation (); if (!t) return false; @@ -556,7 +561,7 @@ Context::get_parent_context () const Translator_group * Context::implementation () const { - return dynamic_cast (unsmob_translator (implementation_)); + return dynamic_cast (unsmob_translator_group (implementation_)); } void @@ -572,3 +577,38 @@ Context::clear_key_disambiguations () unsmob_context (scm_car (s))->clear_key_disambiguations (); } } + + +/* + Ugh. Where to put this? +*/ +Rational +measure_length (Context const *context) +{ + SCM l = context->get_property ("measureLength"); + Rational length (1); + if (unsmob_moment (l)) + length = unsmob_moment (l)->main_part_; + return length; +} + +Moment +measure_position (Context const *context) +{ + SCM sm = context->get_property ("measurePosition"); + + Moment m = 0; + if (unsmob_moment (sm)) + { + m = *unsmob_moment (sm); + + if (m.main_part_ < Rational (0)) + { + Rational length (measure_length (context)); + while (m.main_part_ < Rational (0)) + m.main_part_ += length; + } + } + + return m; +} diff --git a/lily/custos-engraver.cc b/lily/custos-engraver.cc index 05532c117e..4343d696f8 100644 --- a/lily/custos-engraver.cc +++ b/lily/custos-engraver.cc @@ -26,10 +26,10 @@ class Custos_engraver : public Engraver { public: TRANSLATOR_DECLARATIONS (Custos_engraver); - virtual void start_translation_timestep (); + PRECOMPUTED_VIRTUAL void start_translation_timestep (); virtual void acknowledge_grob (Grob_info); - virtual void process_acknowledged_grobs (); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_acknowledged (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); virtual void finalize (); private: @@ -89,7 +89,7 @@ Custos_engraver::acknowledge_grob (Grob_info info) } void -Custos_engraver::process_acknowledged_grobs () +Custos_engraver::process_acknowledged () { if (scm_is_string (get_property ("whichBar"))) custos_permitted = true; @@ -133,6 +133,8 @@ Custos_engraver::finalize () custodes_.clear (); } +#include "translator.icc" + ADD_TRANSLATOR (Custos_engraver, /* descr */ "", /* creats*/ "Custos", diff --git a/lily/dot-column-engraver.cc b/lily/dot-column-engraver.cc index ddbae5bf33..48b4500600 100644 --- a/lily/dot-column-engraver.cc +++ b/lily/dot-column-engraver.cc @@ -22,7 +22,7 @@ public: protected: virtual void acknowledge_grob (Grob_info); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); }; Dot_column_engraver::Dot_column_engraver () @@ -66,6 +66,8 @@ Dot_column_engraver::acknowledge_grob (Grob_info info) } } +#include "translator.icc" + ADD_TRANSLATOR (Dot_column_engraver, /* descr */ "Engraves dots on dotted notes shifted to the right of the note.\n" "If omitted, then dots appear on top of the notes.", diff --git a/lily/dot-column.cc b/lily/dot-column.cc index 69566653b2..ec43a43735 100644 --- a/lily/dot-column.cc +++ b/lily/dot-column.cc @@ -19,6 +19,7 @@ #include "side-position-interface.hh" #include "axis-group-interface.hh" #include "stem.hh" +#include "pointer-group-interface.hh" /* TODO: let Dot_column communicate with stem via Note_column. diff --git a/lily/drum-note-engraver.cc b/lily/drum-note-engraver.cc index f002607f35..e88fd5e530 100644 --- a/lily/drum-note-engraver.cc +++ b/lily/drum-note-engraver.cc @@ -27,9 +27,9 @@ public: protected: virtual bool try_music (Music *ev); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void process_music (); virtual void acknowledge_grob (Grob_info); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); }; Drum_notes_engraver::Drum_notes_engraver () @@ -163,6 +163,8 @@ Drum_notes_engraver::stop_translation_timestep () events_.clear (); } +#include "translator.icc" + ADD_TRANSLATOR (Drum_notes_engraver, /* descr */ "Generate noteheads.", /* creats*/ "NoteHead Dots Script", diff --git a/lily/drum-note-performer.cc b/lily/drum-note-performer.cc index f913318735..2556a291fa 100644 --- a/lily/drum-note-performer.cc +++ b/lily/drum-note-performer.cc @@ -21,7 +21,7 @@ public: protected: virtual bool try_music (Music *ev); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); virtual void create_audio_elements (); private: @@ -29,6 +29,11 @@ private: Link_array notes_; }; + +Drum_note_performer::Drum_note_performer () +{ +} + void Drum_note_performer::create_audio_elements () { @@ -85,10 +90,8 @@ Drum_note_performer::try_music (Music *ev) return false; } +#include "translator.icc" + ADD_TRANSLATOR (Drum_note_performer, "Play drum notes.", "", "note-event busy-playing-event", "", "", ""); - -Drum_note_performer::Drum_note_performer () -{ -} diff --git a/lily/dynamic-engraver.cc b/lily/dynamic-engraver.cc index 2d56df20d3..97bafa4c00 100644 --- a/lily/dynamic-engraver.cc +++ b/lily/dynamic-engraver.cc @@ -20,6 +20,7 @@ #include "staff-symbol-referencer.hh" #include "warn.hh" #include "self-alignment-interface.hh" +#include "pointer-group-interface.hh" /* TODO: @@ -62,8 +63,8 @@ protected: virtual void finalize (); virtual void acknowledge_grob (Grob_info); virtual bool try_music (Music *req); - virtual void stop_translation_timestep (); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_music (); }; Dynamic_engraver::Dynamic_engraver () @@ -424,6 +425,8 @@ Dynamic_engraver::acknowledge_grob (Grob_info info) } } +#include "translator.icc" + ADD_TRANSLATOR (Dynamic_engraver, /* descr */ "This engraver creates hairpins, dynamic texts, and their vertical\n" diff --git a/lily/dynamic-performer.cc b/lily/dynamic-performer.cc index 3fda6d4dbe..b264e72edd 100644 --- a/lily/dynamic-performer.cc +++ b/lily/dynamic-performer.cc @@ -24,7 +24,7 @@ public: TRANSLATOR_DECLARATIONS (Dynamic_performer); protected: virtual bool try_music (Music *req); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); virtual void create_audio_elements (); private: @@ -125,6 +125,8 @@ Dynamic_performer::try_music (Music *r) return false; } +#include "translator.icc" + ADD_TRANSLATOR (Dynamic_performer, /*descr*/ "", /* creats*/ "", diff --git a/lily/engraver-group-engraver.cc b/lily/engraver-group-engraver.cc index d68e0579c1..ae3000aebf 100644 --- a/lily/engraver-group-engraver.cc +++ b/lily/engraver-group-engraver.cc @@ -18,7 +18,13 @@ void Engraver_group_engraver::announce_grob (Grob_info info) { announce_infos_.push (info); - get_daddy_engraver ()->announce_grob (info); + + Engraver_group_engraver * dad_eng = + context_->get_parent_context () + ? dynamic_cast (context_->get_parent_context ()->implementation ()) + : 0; + if (dad_eng) + dad_eng->announce_grob (info); } SCM find_acknowledge_engravers (SCM gravlist, SCM meta); @@ -30,7 +36,7 @@ Engraver_group_engraver::acknowledge_grobs () if (!announce_infos_.size ()) return; - SCM tab = get_property ("acknowledgeHashTable"); + SCM tab = context_->get_property ("acknowledgeHashTable"); SCM name_sym = ly_symbol2scm ("name"); SCM meta_sym = ly_symbol2scm ("meta"); @@ -59,7 +65,7 @@ Engraver_group_engraver::acknowledge_grobs () SCM acklist = scm_hashq_ref (tab, nm, SCM_UNDEFINED); if (acklist == SCM_BOOL_F) { - acklist = find_acknowledge_engravers (scm_cons (self_scm (), get_simple_trans_list ()), meta); + acklist = find_acknowledge_engravers (get_simple_trans_list (), meta); scm_hashq_set_x (tab, nm, acklist); } @@ -81,7 +87,7 @@ int Engraver_group_engraver::pending_grob_count () const { int count = announce_infos_.size (); - for (SCM s = context ()->children_contexts (); + for (SCM s = context_->children_contexts (); scm_is_pair (s); s = scm_cdr (s)) { Context *c = unsmob_context (scm_car (s)); @@ -111,9 +117,7 @@ Engraver_group_engraver::do_announces () while (1) { - engraver_each (get_simple_trans_list (), - &Engraver::process_acknowledged_grobs); - + precomputed_translator_foreach (PROCESS_ACKNOWLEDGED); if (announce_infos_.size () == 0) break; @@ -133,17 +137,20 @@ Engraver_group_engraver::initialize () Translator_group::initialize (); } -Engraver_group_engraver::Engraver_group_engraver () {} +Engraver_group_engraver::Engraver_group_engraver () +{ +} -ADD_TRANSLATOR (Engraver_group_engraver, - /* descr */ "A group of engravers taken together", - /* creats*/ "", - /* accepts */ "", - /* acks */ "", - /* reads */ "", - /* write */ ""); +#include "translator.icc" + +ADD_TRANSLATOR_GROUP (Engraver_group_engraver, + /* descr */ "A group of engravers taken together", + /* creats*/ "", + /* accepts */ "", + /* acks */ "", + /* reads */ "", + /* write */ ""); -/*****************/ bool engraver_valid (Translator *tr, SCM ifaces) @@ -172,43 +179,3 @@ find_acknowledge_engravers (SCM gravlist, SCM meta_alist) return l; } - -/* c&p engraver-group.cc */ -void -recurse_down_engravers (Context *c, Engraver_method ptr, bool context_first) -{ - Engraver_group_engraver *tg - = dynamic_cast (c->implementation ()); - - if (!context_first) - { - engraver_each (tg->get_simple_trans_list (), - ptr); - - (tg->*ptr) (); - } - - for (SCM s = c->children_contexts (); scm_is_pair (s); - s = scm_cdr (s)) - { - recurse_down_engravers (unsmob_context (scm_car (s)), ptr, context_first); - } - - if (context_first) - { - engraver_each (tg->get_simple_trans_list (), - ptr); - (tg->*ptr) (); - } -} - -void -engraver_each (SCM list, Engraver_method method) -{ - for (SCM p = list; scm_is_pair (p); p = scm_cdr (p)) - { - Engraver *e = dynamic_cast (unsmob_translator (scm_car (p))); - if (e) - (e->*method) (); - } -} diff --git a/lily/engraver.cc b/lily/engraver.cc index b7bc326c15..b1a11fcd3a 100644 --- a/lily/engraver.cc +++ b/lily/engraver.cc @@ -41,7 +41,7 @@ Engraver::announce_grob (Grob *e, SCM cause) Grob_info i (this, e); - Engraver *g = get_daddy_engraver (); + Engraver_group_engraver *g = get_daddy_engraver (); if (g) g->announce_grob (i); } @@ -56,6 +56,8 @@ Engraver::get_score_engraver () const return dynamic_cast (get_score_context ()->implementation ()); } +#include "translator.icc" + ADD_TRANSLATOR (Engraver, "", "", "", diff --git a/lily/extender-engraver.cc b/lily/extender-engraver.cc index e3fc6914d1..f44460530d 100644 --- a/lily/extender-engraver.cc +++ b/lily/extender-engraver.cc @@ -31,8 +31,8 @@ protected: virtual void acknowledge_grob (Grob_info); virtual void finalize (); virtual bool try_music (Music *); - virtual void stop_translation_timestep (); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_music (); }; Extender_engraver::Extender_engraver () @@ -148,6 +148,8 @@ Extender_engraver::finalize () } } +#include "translator.icc" + ADD_TRANSLATOR (Extender_engraver, /* descr */ "Create lyric extenders", /* creats*/ "LyricExtender", diff --git a/lily/figured-bass-engraver.cc b/lily/figured-bass-engraver.cc index a15b12c3e8..daddfaf972 100644 --- a/lily/figured-bass-engraver.cc +++ b/lily/figured-bass-engraver.cc @@ -21,8 +21,8 @@ protected: Grob *figure_; virtual bool try_music (Music *); - virtual void stop_translation_timestep (); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_music (); }; Figured_bass_engraver::Figured_bass_engraver () @@ -83,6 +83,8 @@ Figured_bass_engraver::process_music () } } +#include "translator.icc" + ADD_TRANSLATOR (Figured_bass_engraver, /* descr */ "Make figured bass numbers.", /* creats*/ "BassFigure", diff --git a/lily/fingering-engraver.cc b/lily/fingering-engraver.cc index 73e78489fe..c2db873a77 100644 --- a/lily/fingering-engraver.cc +++ b/lily/fingering-engraver.cc @@ -23,9 +23,9 @@ public: TRANSLATOR_DECLARATIONS (Fingering_engraver); protected: virtual bool try_music (Music *m); - virtual void stop_translation_timestep (); - virtual void start_translation_timestep (); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void start_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_music (); virtual void acknowledge_grob (Grob_info); private: @@ -143,6 +143,8 @@ Fingering_engraver::Fingering_engraver () { } +#include "translator.icc" + ADD_TRANSLATOR (Fingering_engraver, /* descr */ "Create fingering-scripts", /* creats*/ "Fingering", diff --git a/lily/font-size-engraver.cc b/lily/font-size-engraver.cc index d1ac0e634b..762226f2c9 100644 --- a/lily/font-size-engraver.cc +++ b/lily/font-size-engraver.cc @@ -42,6 +42,8 @@ Font_size_engraver::acknowledge_grob (Grob_info gi) } } +#include "translator.icc" + ADD_TRANSLATOR (Font_size_engraver, /* descr */ "Puts fontSize into font-relative-size grob property.", /* creats*/ "", diff --git a/lily/forbid-break-engraver.cc b/lily/forbid-break-engraver.cc index 4741887060..c51e0b0ff5 100644 --- a/lily/forbid-break-engraver.cc +++ b/lily/forbid-break-engraver.cc @@ -17,7 +17,7 @@ class Forbid_line_break_engraver : public Engraver { public: TRANSLATOR_DECLARATIONS (Forbid_line_break_engraver); - virtual void start_translation_timestep (); + PRECOMPUTED_VIRTUAL void start_translation_timestep (); }; Forbid_line_break_engraver::Forbid_line_break_engraver (){} @@ -45,6 +45,8 @@ Forbid_line_break_engraver::start_translation_timestep () } } +#include "translator.icc" + ADD_TRANSLATOR (Forbid_line_break_engraver, /* descr */ "Forbid line breaks when note heads are still playing at some point.", /* creats*/ "", diff --git a/lily/glissando-engraver.cc b/lily/glissando-engraver.cc index c1288efaf3..0ad3384bfa 100644 --- a/lily/glissando-engraver.cc +++ b/lily/glissando-engraver.cc @@ -23,9 +23,9 @@ public: protected: virtual void acknowledge_grob (Grob_info); virtual void finalize (); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); virtual bool try_music (Music *); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void process_music (); private: Spanner *line_; Spanner *last_line_; @@ -106,6 +106,8 @@ Glissando_engraver::finalize () } } +#include "translator.icc" + ADD_TRANSLATOR (Glissando_engraver, /* descr */ "Engrave a glissandi", /* creats*/ "Glissando", diff --git a/lily/grace-engraver.cc b/lily/grace-engraver.cc index 10b08cd1d6..25fe3dedec 100644 --- a/lily/grace-engraver.cc +++ b/lily/grace-engraver.cc @@ -14,7 +14,7 @@ class Grace_engraver : public Engraver { void consider_change_grace_settings (); protected: - virtual void start_translation_timestep (); + PRECOMPUTED_VIRTUAL void start_translation_timestep (); virtual void derived_mark () const; virtual void initialize (); @@ -105,6 +105,8 @@ Grace_engraver::start_translation_timestep () consider_change_grace_settings (); } +#include "translator.icc" + ADD_TRANSLATOR (Grace_engraver, /* descr */ "Set font size and other properties for grace notes.", /* creats*/ "", diff --git a/lily/gregorian-ligature-engraver.cc b/lily/gregorian-ligature-engraver.cc index 4840904b8e..b6f65b9fa8 100644 --- a/lily/gregorian-ligature-engraver.cc +++ b/lily/gregorian-ligature-engraver.cc @@ -273,6 +273,8 @@ Gregorian_ligature_engraver::stop_translation_timestep () pes_or_flexa_req_ = 0; } +#include "translator.icc" + ADD_TRANSLATOR (Gregorian_ligature_engraver, /* descr */ "This is an abstract class. Subclasses such as Vaticana_ligature_engraver handle ligatures by glueing special ligature heads together.", /* creats*/ "", diff --git a/lily/grid-line-span-engraver.cc b/lily/grid-line-span-engraver.cc index 5ad0bed8a0..9a49bdf58e 100644 --- a/lily/grid-line-span-engraver.cc +++ b/lily/grid-line-span-engraver.cc @@ -20,7 +20,7 @@ public: TRANSLATOR_DECLARATIONS (Grid_line_span_engraver); protected: virtual void acknowledge_grob (Grob_info); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); }; Grid_line_span_engraver::Grid_line_span_engraver () @@ -58,6 +58,8 @@ Grid_line_span_engraver::stop_translation_timestep () lines_.set_size (0); } +#include "translator.icc" + ADD_TRANSLATOR (Grid_line_span_engraver, /* descr */ "This engraver makes cross-staff linelines: It catches all normal " "line lines, and draws a single span-line across them.", diff --git a/lily/grid-point-engraver.cc b/lily/grid-point-engraver.cc index d7e019b70b..e28c30fbee 100644 --- a/lily/grid-point-engraver.cc +++ b/lily/grid-point-engraver.cc @@ -16,7 +16,7 @@ class Grid_point_engraver : public Engraver public: TRANSLATOR_DECLARATIONS (Grid_point_engraver); protected: - virtual void process_music (); + PRECOMPUTED_VIRTUAL void process_music (); }; void @@ -38,6 +38,8 @@ Grid_point_engraver::Grid_point_engraver () { } +#include "translator.icc" + ADD_TRANSLATOR (Grid_point_engraver, /* descr */ "generate grid points.", /* creats*/ "GridPoint", diff --git a/lily/grob-pq-engraver.cc b/lily/grob-pq-engraver.cc index 542880c184..08def8d83b 100644 --- a/lily/grob-pq-engraver.cc +++ b/lily/grob-pq-engraver.cc @@ -18,8 +18,8 @@ public: protected: virtual void initialize (); virtual void acknowledge_grob (Grob_info); - virtual void start_translation_timestep (); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void start_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); }; Grob_pq_engraver::Grob_pq_engraver () @@ -109,6 +109,8 @@ Grob_pq_engraver::start_translation_timestep () context ()->set_property ("busyGrobs", busy); } +#include "translator.icc" + ADD_TRANSLATOR (Grob_pq_engraver, /* descr */ "Administrate when certain grobs (eg. note heads) stop playing; this \ diff --git a/lily/hara-kiri-engraver.cc b/lily/hara-kiri-engraver.cc index 343bdb08c8..d6a28d4887 100644 --- a/lily/hara-kiri-engraver.cc +++ b/lily/hara-kiri-engraver.cc @@ -18,7 +18,7 @@ protected: virtual Spanner *get_spanner (); virtual void acknowledge_grob (Grob_info); virtual void add_element (Grob *e); - virtual void start_translation_timestep (); + PRECOMPUTED_VIRTUAL void start_translation_timestep (); SCM interesting_; public: @@ -66,6 +66,8 @@ Hara_kiri_engraver::Hara_kiri_engraver () interesting_ = SCM_EOL; } +#include "translator.icc" + ADD_TRANSLATOR (Hara_kiri_engraver, /* descr */ "Like Axis_group_engraver, but make a hara-kiri spanner, and add " "interesting items (ie. note heads, lyric syllables and normal rests) ", diff --git a/lily/hara-kiri-group-spanner.cc b/lily/hara-kiri-group-spanner.cc index accfe9c3b9..eac63e5093 100644 --- a/lily/hara-kiri-group-spanner.cc +++ b/lily/hara-kiri-group-spanner.cc @@ -9,6 +9,7 @@ #include "hara-kiri-group-spanner.hh" +#include "pointer-group-interface.hh" #include "axis-group-interface.hh" #include "spanner.hh" #include "warn.hh" diff --git a/lily/horizontal-bracket-engraver.cc b/lily/horizontal-bracket-engraver.cc index 9614c0f377..0a4a388fb9 100644 --- a/lily/horizontal-bracket-engraver.cc +++ b/lily/horizontal-bracket-engraver.cc @@ -22,11 +22,13 @@ public: int push_count_; virtual bool try_music (Music *); - virtual void stop_translation_timestep (); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_music (); virtual void acknowledge_grob (Grob_info); }; +#include "translator.icc" + ADD_TRANSLATOR (Horizontal_bracket_engraver, "Create horizontal brackets over notes for musical analysis purposes.", "HorizontalBracket", diff --git a/lily/hyphen-engraver.cc b/lily/hyphen-engraver.cc index 29857100fa..0e826430df 100644 --- a/lily/hyphen-engraver.cc +++ b/lily/hyphen-engraver.cc @@ -27,8 +27,8 @@ protected: virtual void acknowledge_grob (Grob_info); virtual void finalize (); virtual bool try_music (Music *); - virtual void stop_translation_timestep (); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_music (); private: }; @@ -136,6 +136,8 @@ Hyphen_engraver::stop_translation_timestep () ev_ = 0; } +#include "translator.icc" + ADD_TRANSLATOR (Hyphen_engraver, /* descr */ "Create lyric hyphens", /* creats*/ "LyricHyphen", diff --git a/lily/include/accidental-interface.hh b/lily/include/accidental-interface.hh index 835762d320..b5eac587db 100644 --- a/lily/include/accidental-interface.hh +++ b/lily/include/accidental-interface.hh @@ -21,7 +21,8 @@ public: static bool has_interface (Grob *); static String get_fontcharname (String style, int alteration); - static Array Accidental_interface::accurate_boxes (Grob *me, Grob **common); + static Array Accidental_interface::accurate_boxes (Grob *me, + Grob **common); }; #endif diff --git a/lily/include/axis-group-engraver.hh b/lily/include/axis-group-engraver.hh index b7dbd62719..131c6663d6 100644 --- a/lily/include/axis-group-engraver.hh +++ b/lily/include/axis-group-engraver.hh @@ -21,10 +21,10 @@ class Axis_group_engraver : public Engraver protected: Spanner *staffline_; Link_array elts_; - virtual void process_music (); + PRECOMPUTED_VIRTUAL void process_music (); virtual void finalize (); virtual void acknowledge_grob (Grob_info); - virtual void process_acknowledged_grobs (); + PRECOMPUTED_VIRTUAL void process_acknowledged (); virtual Spanner *get_spanner (); virtual void add_element (Grob *); public: diff --git a/lily/include/axis-group-interface.hh b/lily/include/axis-group-interface.hh index 5a220237be..75a5a2aa56 100644 --- a/lily/include/axis-group-interface.hh +++ b/lily/include/axis-group-interface.hh @@ -9,7 +9,8 @@ #ifndef AXIS_GROUP_INTERFACE_HH #define AXIS_GROUP_INTERFACE_HH -#include "pointer-group-interface.hh" +#include "lily-proto.hh" +#include "lily-guile.hh" /** */ diff --git a/lily/include/context.hh b/lily/include/context.hh index 07299a166c..de4f346fdc 100644 --- a/lily/include/context.hh +++ b/lily/include/context.hh @@ -110,5 +110,8 @@ Grob *get_current_note_head (Context *voice); Grob *get_current_rest (Context *voice); DECLARE_UNSMOB (Context, context); +Moment measure_position (Context const *context); +Rational measure_length (Context const *context); + #endif /* CONTEXT_HH */ diff --git a/lily/include/engraver-group-engraver.hh b/lily/include/engraver-group-engraver.hh index 63b126eabf..e235b96731 100644 --- a/lily/include/engraver-group-engraver.hh +++ b/lily/include/engraver-group-engraver.hh @@ -13,19 +13,18 @@ #include "engraver.hh" #include "translator-group.hh" -class Engraver_group_engraver : public virtual Engraver, - public virtual Translator_group +class Engraver_group_engraver : public virtual Translator_group { protected: Array announce_infos_; public: - TRANSLATOR_DECLARATIONS (Engraver_group_engraver); + VIRTUAL_COPY_CONSTRUCTOR ( Translator_group, Engraver_group_engraver); + Engraver_group_engraver (); virtual void initialize (); - virtual void do_announces (); + PRECOMPUTED_VIRTUAL void do_announces (); virtual void announce_grob (Grob_info); - int pending_grob_count () const; private: virtual void acknowledge_grobs (); diff --git a/lily/include/engraver.hh b/lily/include/engraver.hh index b3335bab41..54e4f28776 100644 --- a/lily/include/engraver.hh +++ b/lily/include/engraver.hh @@ -17,7 +17,7 @@ a struct which processes events, and creates the #Grob#s. It may use derived classes. */ -class Engraver : public virtual Translator +class Engraver : public Translator { friend class Engraver_group_engraver; @@ -29,13 +29,6 @@ protected: Default: ignore the info */ virtual void acknowledge_grob (Grob_info) {} - - /** Do things with stuff found in acknowledge_grob. Ugh. Should - be looped with acknowledge_grob. - - */ - virtual void process_acknowledged_grobs () {} - virtual void announce_grob (Grob_info); Engraver_group_engraver *get_daddy_engraver () const; @@ -54,7 +47,9 @@ public: #define make_item(x, cause) make_item_from_properties (this, ly_symbol2scm (x), cause, x) #define make_spanner(x, cause) make_spanner_from_properties (this, ly_symbol2scm (x), cause, x) +#define make_paper_column(x) make_paper_column_from_properties (this, ly_symbol2scm (x), x) Item *make_item_from_properties (Engraver *tg, SCM x, SCM cause, const char *name); Spanner *make_spanner_from_properties (Engraver *tg, SCM x, SCM cause, const char *name); +Paper_column *make_paper_column_from_properties (Engraver *tg, SCM x, const char *name); #endif // ENGRAVER_HH diff --git a/lily/include/gregorian-ligature-engraver.hh b/lily/include/gregorian-ligature-engraver.hh index 5ac0dd4e91..ab76c345e5 100644 --- a/lily/include/gregorian-ligature-engraver.hh +++ b/lily/include/gregorian-ligature-engraver.hh @@ -22,7 +22,7 @@ protected: virtual void build_ligature (Spanner *ligature, Array primitives); virtual void transform_heads (Spanner *ligature, Array primitives); /* abstract method */ - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); }; #endif // GREGORIAN_LIGATURE_ENGRAVER_HH diff --git a/lily/include/ligature-engraver.hh b/lily/include/ligature-engraver.hh index a7e32816ff..3b6f6c8c93 100644 --- a/lily/include/ligature-engraver.hh +++ b/lily/include/ligature-engraver.hh @@ -30,12 +30,12 @@ class Ligature_engraver : public Engraver { protected: - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); virtual void finalize (); virtual void acknowledge_grob (Grob_info); virtual bool try_music (Music *); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void process_music (); virtual Spanner *create_ligature_spanner (); /* abstract method */ virtual void typeset_ligature (Spanner *ligature, Array primitives); /* abstract method */ diff --git a/lily/include/paper-column-engraver.hh b/lily/include/paper-column-engraver.hh new file mode 100644 index 0000000000..fce678276a --- /dev/null +++ b/lily/include/paper-column-engraver.hh @@ -0,0 +1,46 @@ +/* + paper-column-engraver.hh -- declare Paper_column_engraver + + source file of the GNU LilyPond music typesetter + + (c) 2005 Han-Wen Nienhuys + +*/ + +#ifndef PAPER_COLUMN_ENGRAVER_HH +#define PAPER_COLUMN_ENGRAVER_HH + + +#include "engraver.hh" + + +class Paper_column_engraver : public Engraver +{ + void make_columns (); + void set_columns (Paper_column*, Paper_column*); + TRANSLATOR_DECLARATIONS(Paper_column_engraver); + +protected: + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void start_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_music (); + virtual void initialize (); + virtual void finalize (); + virtual bool try_music (Music*); + virtual void acknowledge_grob (Grob_info); + + System *system_; + Music *break_event_; + int breaks_; // used for stat printing + Paper_column *command_column_; + Paper_column *musical_column_; + Link_array items_; + bool first_; + Moment last_moment_; +public: + // ug.h + void forbid_breaks (); + +}; + +#endif /* PAPER_COLUMN_ENGRAVER_HH */ diff --git a/lily/include/performer-group-performer.hh b/lily/include/performer-group-performer.hh index 52939cf9ea..afaeb96c49 100644 --- a/lily/include/performer-group-performer.hh +++ b/lily/include/performer-group-performer.hh @@ -13,13 +13,16 @@ typedef void (Performer:: *Performer_method) (void); -class Performer_group_performer : public Performer, public virtual Translator_group +class Performer_group_performer : public virtual Translator_group { public: - TRANSLATOR_DECLARATIONS (Performer_group_performer); + VIRTUAL_COPY_CONSTRUCTOR (Translator_group,Performer_group_performer); - virtual void do_announces (); + PRECOMPUTED_VIRTUAL void do_announces (); virtual void announce_element (Audio_element_info); + virtual void play_element (Audio_element *p); + virtual int get_tempo () const; + protected: Array announce_infos_; diff --git a/lily/include/performer.hh b/lily/include/performer.hh index 9d224cc460..0473d1c181 100644 --- a/lily/include/performer.hh +++ b/lily/include/performer.hh @@ -14,7 +14,7 @@ /* Convert a music definition into a audio representation. A baseclass. */ -class Performer : public virtual Translator +class Performer : public Translator { public: VIRTUAL_COPY_CONSTRUCTOR (Translator, Performer); diff --git a/lily/include/recording-group-engraver.hh b/lily/include/recording-group-engraver.hh new file mode 100644 index 0000000000..efb77d974b --- /dev/null +++ b/lily/include/recording-group-engraver.hh @@ -0,0 +1,31 @@ +/* + recording-group-engraver.hh -- declare + + source file of the GNU LilyPond music typesetter + + (c) 2005 Han-Wen Nienhuys + +*/ + +#ifndef RECORDING_GROUP_ENGRAVER_HH +#define RECORDING_GROUP_ENGRAVER_HH + + +#include "engraver-group-engraver.hh" + +class Recording_group_engraver : public Engraver_group_engraver +{ +public: + VIRTUAL_COPY_CONSTRUCTOR (Translator_group, Recording_group_engraver); + virtual bool try_music (Music *m); + void add_music (SCM, SCM); + Recording_group_engraver (); + virtual void stop_translation_timestep (); + virtual void finalize (); + virtual void derived_mark () const; + virtual void fetch_precomputable_methods (Translator_group_void_method ptrs[]); + + SCM now_events_; + SCM accumulator_; +}; +#endif /* RECORDING_GROUP_ENGRAVER_HH */ diff --git a/lily/include/score-engraver.hh b/lily/include/score-engraver.hh index 6286759fee..c045994d5b 100644 --- a/lily/include/score-engraver.hh +++ b/lily/include/score-engraver.hh @@ -16,16 +16,12 @@ class Score_engraver : public virtual Score_translator, public virtual Engraver_group_engraver { System *system_; - int breaks_; // used for stat printing Link_array elems_; - Paper_column *command_column_; - Paper_column *musical_column_; Paper_score *pscore_; - void make_columns (); - void set_columns (Paper_column *, Paper_column *); void typeset_all (); + protected: /* Score_translator */ virtual void finish (); @@ -34,19 +30,19 @@ protected: /* Engraver_group_engraver interface */ - virtual void acknowledge_grob (Grob_info); virtual bool try_music (Music *); virtual void initialize (); virtual void finalize (); virtual void announce_grob (Grob_info); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); /* Translator interface */ virtual void derived_mark () const; + public: - TRANSLATOR_DECLARATIONS (Score_engraver); + Score_engraver (); void forbid_breaks (); virtual SCM get_output (); }; diff --git a/lily/include/score-performer.hh b/lily/include/score-performer.hh index cd3ebefa69..953127e132 100644 --- a/lily/include/score-performer.hh +++ b/lily/include/score-performer.hh @@ -17,10 +17,11 @@ class Score_performer : public Score_translator, public virtual Performer_group_performer { public: - TRANSLATOR_DECLARATIONS (Score_performer); + VIRTUAL_COPY_CONSTRUCTOR (Translator_group,Score_performer); ~Score_performer (); Performance *performance_; + Score_performer (); protected: virtual void prepare (Moment mom); virtual void finish (); diff --git a/lily/include/staff-symbol-engraver.hh b/lily/include/staff-symbol-engraver.hh index c588882071..7a67ca7851 100644 --- a/lily/include/staff-symbol-engraver.hh +++ b/lily/include/staff-symbol-engraver.hh @@ -30,12 +30,12 @@ protected: virtual void start_spanner (); virtual void stop_spanner (); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); virtual bool try_music (Music *); virtual ~Staff_symbol_engraver (); virtual void acknowledge_grob (Grob_info); virtual void finalize (); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void process_music (); }; #endif /* STAFF_SYMBOL_ENGRAVER_HH */ diff --git a/lily/include/timing-translator.hh b/lily/include/timing-translator.hh index f58489ea48..0477c16e45 100644 --- a/lily/include/timing-translator.hh +++ b/lily/include/timing-translator.hh @@ -14,18 +14,19 @@ #include "parray.hh" -class Timing_translator : public virtual Translator +class Timing_translator : public Translator { public: TRANSLATOR_DECLARATIONS (Timing_translator); protected: virtual void initialize (); - virtual void stop_translation_timestep (); - virtual void start_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void start_translation_timestep (); public: - Moment measure_position () const; Rational measure_length () const; }; + + #endif // TIMING_TRANSLATOR_HH diff --git a/lily/include/translator-group.hh b/lily/include/translator-group.hh index ed33f010e5..5f8a93ab3e 100644 --- a/lily/include/translator-group.hh +++ b/lily/include/translator-group.hh @@ -9,32 +9,83 @@ #ifndef TRANSLATOR_GROUP_HH #define TRANSLATOR_GROUP_HH - - #include "translator.hh" #include "parray.hh" typedef void (Translator:: *Translator_method) (void); +typedef void (Translator_group:: *Translator_group_method) (void); +typedef void (*Translator_group_void_method)(Translator_group*); -class Translator_group : public virtual Translator +struct Translator_method_binding { + Translator *translator_; + Translator_void_method_ptr method_; + + Translator_method_binding() + { + } + Translator_method_binding (Translator*tr, Translator_void_method_ptr ptr) + { + translator_ = tr; + method_ = ptr; + } + void invoke () + { + if (method_) + (*method_)(translator_); + } +}; + + +class Translator_group +{ +private: + void precompute_method_bindings (); + Array + precomputed_method_bindings_[TRANSLATOR_METHOD_PRECOMPUTE_COUNT]; + + Translator_group_void_method + precomputed_self_method_bindings_[TRANSLATOR_METHOD_PRECOMPUTE_COUNT]; + +public: + VIRTUAL_COPY_CONSTRUCTOR (Translator_group, Translator_group); + DECLARE_SMOBS (Translator_group, dummy); + public: - VIRTUAL_COPY_CONSTRUCTOR (Translator, Translator_group); virtual Translator_group *get_daddy_translator ()const; virtual SCM get_simple_trans_list (); virtual bool try_music (Music *req); virtual void initialize (); + virtual void finalize (); + + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void start_translation_timestep (); + + virtual void fetch_precomputable_methods (Translator_group_void_method[]); + Translator_group (); + void precomputed_translator_foreach (Translator_precompute_index); + void call_precomputed_self_method (Translator_precompute_index); + + + Context * context () const { return context_; } protected: SCM simple_trans_list_; - + Context *context_; + friend class Context_def; virtual void derived_mark () const; }; SCM names_to_translators (SCM namelist, Context *tg); -void recurse_over_translators (Context *c, Translator_method ptr, Direction); -void translator_each (SCM list, Translator_method method); +void recurse_over_translators (Context *c, Translator_method ptr, + Translator_group_method ptr2, Direction); +void precomputed_recurse_over_translators (Context *c, Translator_precompute_index idx, Direction dir); +Translator_group *get_translator_group (SCM sym); + +#define ADD_TRANSLATOR_GROUP(classname, desc, grobs, accepted, acked, read, write) \ + +DECLARE_UNSMOB (Translator_group, translator_group); #endif // TRANSLATOR_GROUP_HH diff --git a/lily/include/translator.hh b/lily/include/translator.hh index 7d965e4b5a..351149548c 100644 --- a/lily/include/translator.hh +++ b/lily/include/translator.hh @@ -16,19 +16,37 @@ #include "input.hh" #include "smobs.hh" -/* copied from lily-guile.hh */ -#ifndef get_property -#define get_property(x) internal_get_property (ly_symbol2scm (x)) -#endif + +typedef void (*Translator_void_method_ptr)(Translator*); + +#define DECLARE_STATIC_METHOD(x) static void x ## _static (Translator*) #define TRANSLATOR_DECLARATIONS(NAME) \ public: \ + DECLARE_STATIC_METHOD(start_translation_timestep); \ + DECLARE_STATIC_METHOD(stop_translation_timestep); \ + DECLARE_STATIC_METHOD(process_music); \ + DECLARE_STATIC_METHOD(process_acknowledged); \ NAME (); \ VIRTUAL_COPY_CONSTRUCTOR (Translator, NAME); \ static SCM static_description_; \ + virtual void fetch_precomputable_methods (Translator_void_method_ptr methods[]);\ virtual SCM static_translator_description () const; \ virtual SCM translator_description () const; + +enum Translator_precompute_index { + START_TRANSLATION_TIMESTEP, + STOP_TRANSLATION_TIMESTEP, + PROCESS_MUSIC, + PROCESS_ACKNOWLEDGED, + TRANSLATOR_METHOD_PRECOMPUTE_COUNT, +}; + +/* nothing */ +#define PRECOMPUTED_VIRTUAL + + /* Translate music into grobs. */ @@ -51,14 +69,17 @@ public: virtual Output_def *get_output_def () const; virtual Translator_group *get_daddy_translator ()const; virtual Moment now_mom () const; + virtual bool try_music (Music *req); - virtual void stop_translation_timestep (); - virtual void start_translation_timestep (); virtual void initialize (); - virtual void process_music (); - virtual void do_announces (); virtual void finalize (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void start_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_music (); + PRECOMPUTED_VIRTUAL void process_acknowledged (); + + Score_context *get_score_context () const; Global_context *get_global_context () const; @@ -71,54 +92,6 @@ protected: // should be private. friend class Context_def; friend class Context; }; - -/** - A macro to automate administration of translators. -*/ -#define ADD_THIS_TRANSLATOR(T) \ - SCM T::static_description_ = SCM_EOL; \ - static void _ ## T ## _adder () \ - { \ - T *t = new T; \ - T::static_description_ = t->static_translator_description (); \ - scm_permanent_object (T::static_description_); \ - add_translator (t); \ - } \ - SCM T::translator_description () const \ - { \ - return static_description_; \ - } \ - ADD_GLOBAL_CTOR (_ ## T ## _adder); - -#define ADD_TRANSLATOR(classname, desc, grobs, accepted, acked, read, write) \ - ADD_THIS_TRANSLATOR (classname); \ - SCM \ - classname::static_translator_description () const \ - { \ - SCM static_properties = SCM_EOL; \ - /* static_properties = acons (name , gh_str02scm (Translator::name (self_scm ())), \ - static_properties_); \ - */ \ - static_properties = scm_acons (ly_symbol2scm ("grobs-created"), \ - parse_symbol_list (grobs), static_properties); \ - \ - static_properties = scm_acons (ly_symbol2scm ("description"), \ - scm_makfrom0str (desc), static_properties); \ - \ - static_properties = scm_acons (ly_symbol2scm ("interfaces-acked"), \ - parse_symbol_list (acked), static_properties); \ - static_properties = scm_acons (ly_symbol2scm ("events-accepted"), \ - parse_symbol_list (accepted), static_properties); \ - \ - static_properties = scm_acons (ly_symbol2scm ("properties-read"), \ - parse_symbol_list (read), static_properties); \ - \ - static_properties = scm_acons (ly_symbol2scm ("properties-written"), \ - parse_symbol_list (write), static_properties); \ - \ - return static_properties; \ - } - void add_translator (Translator *trans); Translator *get_translator (SCM s); diff --git a/lily/include/translator.icc b/lily/include/translator.icc new file mode 100644 index 0000000000..5bffbf8d2a --- /dev/null +++ b/lily/include/translator.icc @@ -0,0 +1,109 @@ +/* + translator.icc -- declare Translator glue wiring. + + source file of the GNU LilyPond music typesetter + + (c) 2005 Han-Wen Nienhuys + +*/ + +#ifndef TRANSLATOR_ICC +#define TRANSLATOR_ICC + +/** + A macro to automate administration of translators. +*/ +#define ADD_THIS_TRANSLATOR(T) \ + SCM T::static_description_ = SCM_EOL; \ + static void _ ## T ## _adder () \ + { \ + T *t = new T; \ + T::static_description_ = t->static_translator_description (); \ + scm_permanent_object (T::static_description_); \ + add_translator (t); \ + } \ + SCM T::translator_description () const \ + { \ + return static_description_; \ + } \ + ADD_GLOBAL_CTOR (_ ## T ## _adder); + +#define ADD_TRANSLATOR(classname, desc, grobs, accepted, acked, read, write) \ + DEFINE_STATIC_METHODS(classname);\ + IMPLEMENT_FETCH_PRECOMPUTABLE_METHODS(classname); \ + ADD_THIS_TRANSLATOR (classname); \ + SCM \ + classname::static_translator_description () const \ + { \ + SCM static_properties = SCM_EOL; \ + /* static_properties = acons (name , gh_str02scm (Translator::name (self_scm ())), \ + static_properties_); \ + */ \ + static_properties = scm_acons (ly_symbol2scm ("grobs-created"), \ + parse_symbol_list (grobs), static_properties); \ + \ + static_properties = scm_acons (ly_symbol2scm ("description"), \ + scm_makfrom0str (desc), static_properties); \ + \ + static_properties = scm_acons (ly_symbol2scm ("interfaces-acked"), \ + parse_symbol_list (acked), static_properties); \ + static_properties = scm_acons (ly_symbol2scm ("events-accepted"), \ + parse_symbol_list (accepted), static_properties); \ + \ + static_properties = scm_acons (ly_symbol2scm ("properties-read"), \ + parse_symbol_list (read), static_properties); \ + \ + static_properties = scm_acons (ly_symbol2scm ("properties-written"), \ + parse_symbol_list (write), static_properties); \ + \ + return static_properties; \ + } + + +/* + FIXME: should be able to cast statically to (T*) -iow.- remove + Translator as a virtual base class. + */ +#define DEFINE_STATIC_METHOD(T, x) \ +void \ +T::x ## _static (Translator* tr) \ +{ \ + T * t_ptr = (T*) (tr); \ + t_ptr->x ();\ +} + +#define DEFINE_STATIC_METHODS(T) \ + DEFINE_STATIC_METHOD(T,start_translation_timestep)\ + DEFINE_STATIC_METHOD(T,stop_translation_timestep)\ + DEFINE_STATIC_METHOD(T,process_music)\ + DEFINE_STATIC_METHOD(T,process_acknowledged) + +#define IMPLEMENT_FETCH_PRECOMPUTABLE_METHODS(T) \ +void \ +T::fetch_precomputable_methods (Translator_void_method_ptr ptrs[])\ +{ \ + ptrs[START_TRANSLATION_TIMESTEP] = \ + ((Translator_void_method_ptr) &T::start_translation_timestep == \ + (Translator_void_method_ptr) &Translator::start_translation_timestep) \ + ? 0 \ + : &T::start_translation_timestep_static; \ + \ + ptrs[STOP_TRANSLATION_TIMESTEP] = \ + ((Translator_void_method_ptr) &T::stop_translation_timestep == (Translator_void_method_ptr) &Translator::stop_translation_timestep) \ + ? 0 \ + : &T::stop_translation_timestep_static; \ + \ + ptrs[PROCESS_MUSIC] = \ + ((Translator_void_method_ptr) &T::process_music == (Translator_void_method_ptr) &Translator::process_music) \ + ? 0 \ + : &T::process_music_static; \ + \ + ptrs[PROCESS_ACKNOWLEDGED] = \ + ((Translator_void_method_ptr) &T::process_acknowledged == (Translator_void_method_ptr) &Translator::process_acknowledged) \ + ? 0 \ + : &T::process_acknowledged_static; \ +} + + +#endif /* TRANSLATOR_ICC */ + diff --git a/lily/include/type-swallow-translator.hh b/lily/include/type-swallow-translator.hh index 700bef1f56..8b612f2a7e 100644 --- a/lily/include/type-swallow-translator.hh +++ b/lily/include/type-swallow-translator.hh @@ -14,7 +14,7 @@ /** eat a certain type of event (Duh, it's good for your skin) */ -class Type_swallow_translator : public virtual Translator +class Type_swallow_translator : public Translator { protected: String swallow_string_; diff --git a/lily/instrument-name-engraver.cc b/lily/instrument-name-engraver.cc index 8ded1dabca..f1182ea8b6 100644 --- a/lily/instrument-name-engraver.cc +++ b/lily/instrument-name-engraver.cc @@ -28,8 +28,8 @@ protected: virtual void create_text (); virtual void initialize (); virtual void acknowledge_grob (Grob_info); - virtual void stop_translation_timestep (); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_music (); }; @@ -129,6 +129,8 @@ Instrument_name_engraver::process_music () create_text (); } +#include "translator.icc" + ADD_TRANSLATOR (Instrument_name_engraver, /* descr */ " Prints the name of the instrument (specified by " " @code{Staff.instrument} and @code{Staff.instr}) " @@ -175,6 +177,8 @@ Vocal_name_engraver::create_text () text_->set_property ("text", txt); } +#include "translator.icc" + ADD_TRANSLATOR (Vocal_name_engraver, /* descr */ " Prints the name of the a lyric voice (specified by " " @code{Staff.vocalName} and @code{Staff.vocNam}) " diff --git a/lily/item.cc b/lily/item.cc index 973a574c57..fa591c9c54 100644 --- a/lily/item.cc +++ b/lily/item.cc @@ -25,7 +25,6 @@ Item::Item (SCM s, Object_key const *key) : Grob (s, key) { broken_to_drul_[LEFT] = broken_to_drul_[RIGHT] = 0; - interfaces_ = scm_cons (ly_symbol2scm ("item-interface"), interfaces_); } /** diff --git a/lily/key-engraver.cc b/lily/key-engraver.cc index acd5aaa68d..2ccdef5ec1 100644 --- a/lily/key-engraver.cc +++ b/lily/key-engraver.cc @@ -37,9 +37,9 @@ protected: virtual void initialize (); virtual void finalize (); virtual bool try_music (Music *ev); - virtual void stop_translation_timestep (); - virtual void start_translation_timestep (); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void start_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_music (); virtual void acknowledge_grob (Grob_info); }; @@ -180,6 +180,8 @@ Key_engraver::initialize () context ()->set_property ("tonic", p.smobbed_copy ()); } +#include "translator.icc" + ADD_TRANSLATOR (Key_engraver, /* descr */ "", /* creats*/ "KeySignature", diff --git a/lily/key-performer.cc b/lily/key-performer.cc index 3f7cc6ac2f..065dd57fcd 100644 --- a/lily/key-performer.cc +++ b/lily/key-performer.cc @@ -20,7 +20,7 @@ public: protected: virtual bool try_music (Music *ev); virtual void create_audio_elements (); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); private: Music *key_ev_; @@ -96,6 +96,8 @@ Key_performer::try_music (Music *ev) return true; } +#include "translator.icc" + ADD_TRANSLATOR (Key_performer, "", "", "key-change-event", diff --git a/lily/ledger-line-engraver.cc b/lily/ledger-line-engraver.cc index 11c496b299..32568dd309 100644 --- a/lily/ledger-line-engraver.cc +++ b/lily/ledger-line-engraver.cc @@ -20,7 +20,7 @@ public: protected: virtual void finalize (); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void process_music (); virtual void acknowledge_grob (Grob_info); void start_spanner (); @@ -86,6 +86,8 @@ Ledger_line_engraver::acknowledge_grob (Grob_info s) } } +#include "translator.icc" + ADD_TRANSLATOR (Ledger_line_engraver, "Creates the spanner to draw ledger lines, and notices objects that need ledger lines", /* creats*/ "LedgerLineSpanner", diff --git a/lily/ligature-bracket-engraver.cc b/lily/ligature-bracket-engraver.cc index 9eddeb71da..175f8d1269 100644 --- a/lily/ligature-bracket-engraver.cc +++ b/lily/ligature-bracket-engraver.cc @@ -50,6 +50,8 @@ Ligature_bracket_engraver::acknowledge_grob (Grob_info info) } } +#include "translator.icc" + ADD_TRANSLATOR (Ligature_bracket_engraver, /* descr */ "Handles Ligature_events by engraving Ligature brackets.", /* creats*/ "TupletBracket", diff --git a/lily/ligature-engraver.cc b/lily/ligature-engraver.cc index 70f490e3b4..2df8616c4e 100644 --- a/lily/ligature-engraver.cc +++ b/lily/ligature-engraver.cc @@ -285,6 +285,8 @@ Ligature_engraver::acknowledge_grob (Grob_info info) } } +#include "translator.icc" + ADD_TRANSLATOR (Ligature_engraver, /* descr */ "Abstract class; a concrete subclass handles Ligature_events by engraving Ligatures in a concrete style.", /* creats */ "", diff --git a/lily/lyric-engraver.cc b/lily/lyric-engraver.cc index 340a5d914c..75c28f9117 100644 --- a/lily/lyric-engraver.cc +++ b/lily/lyric-engraver.cc @@ -22,9 +22,9 @@ class Lyric_engraver : public Engraver { protected: - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); virtual bool try_music (Music *); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void process_music (); public: TRANSLATOR_DECLARATIONS (Lyric_engraver); @@ -144,6 +144,8 @@ Lyric_engraver::stop_translation_timestep () event_ = 0; } +#include "translator.icc" + ADD_TRANSLATOR (Lyric_engraver, /* descr */ "", /* creats*/ "LyricText", diff --git a/lily/lyric-performer.cc b/lily/lyric-performer.cc index 9d747f4e77..535801cb9f 100644 --- a/lily/lyric-performer.cc +++ b/lily/lyric-performer.cc @@ -17,7 +17,7 @@ public: protected: virtual bool try_music (Music *req); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); virtual void create_audio_elements (); private: @@ -68,4 +68,6 @@ Lyric_performer::try_music (Music *req) return false; } +#include "translator.icc" + ADD_TRANSLATOR (Lyric_performer, "", "", "lyric-event", "", "", ""); diff --git a/lily/mark-engraver.cc b/lily/mark-engraver.cc index a45c9c59bb..d938b39004 100644 --- a/lily/mark-engraver.cc +++ b/lily/mark-engraver.cc @@ -26,11 +26,11 @@ public: protected: Item *text_; protected: - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); virtual void acknowledge_grob (Grob_info); void create_items (Music *); virtual bool try_music (Music *ev); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void process_music (); private: Music *mark_ev_; @@ -130,6 +130,8 @@ Mark_engraver::process_music () } } +#include "translator.icc" + ADD_TRANSLATOR (Mark_engraver, /* descr */ "This engraver will create RehearsalMark objects. " "It puts them on top of all staves (which is taken from " diff --git a/lily/measure-grouping-engraver.cc b/lily/measure-grouping-engraver.cc index f44a8b3b5b..7a7ebd635d 100644 --- a/lily/measure-grouping-engraver.cc +++ b/lily/measure-grouping-engraver.cc @@ -20,7 +20,7 @@ protected: Spanner *grouping_; Rational stop_grouping_mom_; - virtual void process_music (); + PRECOMPUTED_VIRTUAL void process_music (); virtual void finalize (); virtual void acknowledge_grob (Grob_info); }; @@ -104,6 +104,8 @@ Measure_grouping_engraver::Measure_grouping_engraver () grouping_ = 0; } +#include "translator.icc" + ADD_TRANSLATOR (Measure_grouping_engraver, /* descr */ "Creates MeasureGrouping to indicate beat subdivision.", /* creats*/ "MeasureGrouping", diff --git a/lily/melisma-translator.cc b/lily/melisma-translator.cc index 3c24d3c771..1854911489 100644 --- a/lily/melisma-translator.cc +++ b/lily/melisma-translator.cc @@ -19,8 +19,8 @@ public: TRANSLATOR_DECLARATIONS (Melisma_translator); protected: virtual bool try_music (Music *); - virtual void process_music (); - virtual void start_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_music (); + PRECOMPUTED_VIRTUAL void start_translation_timestep (); Music *event_; }; @@ -65,6 +65,8 @@ Melisma_translator::Melisma_translator () event_ = 0; } +#include "translator.icc" + ADD_TRANSLATOR (Melisma_translator, /* descr */ "This translator collects melisma information about ties, beams, and user settings (@code{melismaBusy}, and signals it to the @code{\addlyrics} code. ", /* creats*/ "", diff --git a/lily/mensural-ligature-engraver.cc b/lily/mensural-ligature-engraver.cc index bca756e2f3..5a6c662f90 100644 --- a/lily/mensural-ligature-engraver.cc +++ b/lily/mensural-ligature-engraver.cc @@ -383,6 +383,8 @@ Mensural_ligature_engraver::build_ligature (Spanner *ligature, fold_up_primitives (primitives); } +#include "translator.icc" + ADD_TRANSLATOR (Mensural_ligature_engraver, /* descr */ "Handles Mensural_ligature_events by glueing special ligature heads together.", /* creats*/ "MensuralLigature", diff --git a/lily/metronome-engraver.cc b/lily/metronome-engraver.cc index 12020d306d..9535798f7a 100644 --- a/lily/metronome-engraver.cc +++ b/lily/metronome-engraver.cc @@ -29,9 +29,9 @@ protected: void create_items (Music *); protected: - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); virtual bool try_music (Music *ev); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void process_music (); }; Metronome_mark_engraver::Metronome_mark_engraver () @@ -85,6 +85,8 @@ Metronome_mark_engraver::process_music () } } +#include "translator.icc" + ADD_TRANSLATOR (Metronome_mark_engraver, /* descr */ "Engrave metro nome marking. This delegates the formatting work " "to the function in the metronomeMarkFormatter property. " diff --git a/lily/multi-measure-rest-engraver.cc b/lily/multi-measure-rest-engraver.cc index 399b94b6d8..b32ce988cb 100644 --- a/lily/multi-measure-rest-engraver.cc +++ b/lily/multi-measure-rest-engraver.cc @@ -22,9 +22,9 @@ public: protected: virtual bool try_music (Music *); - virtual void process_music (); - virtual void stop_translation_timestep (); - virtual void start_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_music (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void start_translation_timestep (); virtual void finalize (); private: @@ -246,6 +246,8 @@ Multi_measure_rest_engraver::finalize () { } +#include "translator.icc" + ADD_TRANSLATOR (Multi_measure_rest_engraver, /* descr */ "Engraves multi-measure rests that are produced with @code{R}. Reads " diff --git a/lily/new-fingering-engraver.cc b/lily/new-fingering-engraver.cc index a32d324f1f..6bed794981 100644 --- a/lily/new-fingering-engraver.cc +++ b/lily/new-fingering-engraver.cc @@ -49,7 +49,7 @@ class New_fingering_engraver : public Engraver public: TRANSLATOR_DECLARATIONS (New_fingering_engraver); protected: - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); virtual void acknowledge_grob (Grob_info); void add_fingering (Grob *, Music *, Music *); void add_script (Grob *, Music *, Music *); @@ -360,6 +360,8 @@ New_fingering_engraver::New_fingering_engraver () stem_ = 0; } +#include "translator.icc" + ADD_TRANSLATOR (New_fingering_engraver, /* descr */ "Create fingering-scripts for notes in a new chord. " "This engraver is ill-named, since it " diff --git a/lily/note-collision.cc b/lily/note-collision.cc index 9f2df90240..e1af7de632 100644 --- a/lily/note-collision.cc +++ b/lily/note-collision.cc @@ -19,6 +19,7 @@ #include "stem.hh" #include "side-position-interface.hh" #include "dot-column.hh" +#include "pointer-group-interface.hh" MAKE_SCHEME_CALLBACK (Note_collision_interface, force_shift_callback, 2); diff --git a/lily/note-column.cc b/lily/note-column.cc index 787773019e..4c81e4af06 100644 --- a/lily/note-column.cc +++ b/lily/note-column.cc @@ -18,6 +18,7 @@ #include "rest.hh" #include "note-head.hh" #include "accidental-placement.hh" +#include "pointer-group-interface.hh" /* TODO: figure out if we can prune this class. This is just an diff --git a/lily/note-head-line-engraver.cc b/lily/note-head-line-engraver.cc index 555ac18ec1..8dde1e8640 100644 --- a/lily/note-head-line-engraver.cc +++ b/lily/note-head-line-engraver.cc @@ -27,8 +27,8 @@ public: protected: virtual void acknowledge_grob (Grob_info); - virtual void process_acknowledged_grobs (); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_acknowledged (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); private: Spanner *line_; @@ -71,7 +71,7 @@ Note_head_line_engraver::acknowledge_grob (Grob_info info) } void -Note_head_line_engraver::process_acknowledged_grobs () +Note_head_line_engraver::process_acknowledged () { if (!line_ && follow_ && last_head_ && head_) { @@ -99,6 +99,8 @@ Note_head_line_engraver::stop_translation_timestep () head_ = 0; } +#include "translator.icc" + ADD_TRANSLATOR (Note_head_line_engraver, /* descr */ "Engrave a line between two note heads, for example a glissando. If " " followVoice is set, staff switches also generate a line.", diff --git a/lily/note-head.cc b/lily/note-head.cc index abf3599ac2..796e01b3a3 100644 --- a/lily/note-head.cc +++ b/lily/note-head.cc @@ -41,8 +41,9 @@ internal_print (Grob *me, String *font_char) SCM log = scm_int2num (Note_head::get_balltype (me)); SCM proc = me->get_property ("glyph-name-procedure"); - String suffix = to_string (robust_scm2int (me->get_property ("duration-log"), 2)); - if (ly_is_procedure (proc)) + String suffix = to_string (min (robust_scm2int (me->get_property ("duration-log"), 2), 2)); + if (style != ly_symbol2scm ("default") + && ly_is_procedure (proc)) suffix = ly_scm2string (scm_call_2 (proc, log, style)); Font_metric *fm = Font_interface::get_default_font (me); diff --git a/lily/note-heads-engraver.cc b/lily/note-heads-engraver.cc index b74d9faff1..91de2a5047 100644 --- a/lily/note-heads-engraver.cc +++ b/lily/note-heads-engraver.cc @@ -28,8 +28,8 @@ public: protected: virtual bool try_music (Music *ev); - virtual void process_music (); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_music (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); }; Note_heads_engraver::Note_heads_engraver () @@ -131,6 +131,8 @@ Note_heads_engraver::stop_translation_timestep () note_evs_.clear (); } +#include "translator.icc" + ADD_TRANSLATOR (Note_heads_engraver, /* descr */ "Generate noteheads.", /* creats*/ "NoteHead Dots", diff --git a/lily/note-name-engraver.cc b/lily/note-name-engraver.cc index 0a3814f477..a40cb2ac3f 100644 --- a/lily/note-name-engraver.cc +++ b/lily/note-name-engraver.cc @@ -17,8 +17,8 @@ public: Link_array events_; Link_array texts_; virtual bool try_music (Music *m); - virtual void process_music (); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_music (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); }; bool @@ -66,6 +66,8 @@ Note_name_engraver::Note_name_engraver () { } +#include "translator.icc" + ADD_TRANSLATOR (Note_name_engraver, /* descr */ "", /* creats*/ "NoteName", diff --git a/lily/note-performer.cc b/lily/note-performer.cc index 640449cc3a..333196f9bd 100644 --- a/lily/note-performer.cc +++ b/lily/note-performer.cc @@ -24,7 +24,7 @@ public: protected: virtual bool try_music (Music *ev); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); virtual void create_audio_elements (); private: @@ -88,6 +88,8 @@ Note_performer::try_music (Music *ev) return false; } +#include "translator.icc" + ADD_TRANSLATOR (Note_performer, "", "", "note-event busy-playing-event", "", "", ""); diff --git a/lily/ottava-engraver.cc b/lily/ottava-engraver.cc index f4da2e4153..44f3741c37 100644 --- a/lily/ottava-engraver.cc +++ b/lily/ottava-engraver.cc @@ -18,8 +18,8 @@ public: protected: virtual void finalize (); virtual void acknowledge_grob (Grob_info); - virtual void process_music (); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_music (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); virtual void derived_mark () const; private: Spanner *span_; @@ -121,6 +121,8 @@ Ottava_spanner_engraver::finalize () last_ottavation_ = SCM_EOL; } +#include "translator.icc" + ADD_TRANSLATOR (Ottava_spanner_engraver, /* descr */ "Create a text spanner when the ottavation property changes..", /* creats*/ "OttavaBracket", diff --git a/lily/output-property-engraver.cc b/lily/output-property-engraver.cc index 2400383e61..f31cd652fc 100644 --- a/lily/output-property-engraver.cc +++ b/lily/output-property-engraver.cc @@ -17,7 +17,7 @@ TRANSLATOR_DECLARATIONS (Output_property_engraver); protected: Link_array props_; - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); virtual void acknowledge_grob (Grob_info); virtual bool try_music (Music*); }; @@ -79,6 +79,8 @@ Output_property_engraver::Output_property_engraver () { } +#include "translator.icc" + ADD_TRANSLATOR (Output_property_engraver, /* descr */ "Interpret Music of Output_property type, and apply a function " " to any Graphic objects that satisfies the predicate.", diff --git a/lily/paper-column-engraver.cc b/lily/paper-column-engraver.cc new file mode 100644 index 0000000000..72e66f44e2 --- /dev/null +++ b/lily/paper-column-engraver.cc @@ -0,0 +1,235 @@ +/* + paper-column-engraver.cc -- implement Paper_column_engraver + + source file of the GNU LilyPond music typesetter + + (c) 2005 Han-Wen Nienhuys + +*/ + +#include "paper-column-engraver.hh" +#include "system.hh" +#include "item.hh" +#include "paper-column.hh" +#include "staff-spacing.hh" +#include "note-spacing.hh" +#include "pointer-group-interface.hh" +#include "context.hh" +#include "axis-group-interface.hh" +#include "warn.hh" + + + +Paper_column_engraver::Paper_column_engraver () +{ + command_column_ = 0; + musical_column_ = 0; + breaks_ = 0; + break_event_ = 0; + system_ = 0; + first_ = true; +} + +void +Paper_column_engraver::finalize () +{ + if ((breaks_ % 8)) + progress_indication ("[" + to_string (breaks_) + "]"); + + if (command_column_) + { + command_column_->set_property ("breakable", SCM_BOOL_T); + system_->set_bound (RIGHT, command_column_); + } +} + +void +Paper_column_engraver::make_columns () +{ + /* + ugh. + */ + Paper_column *p1 = make_paper_column ("NonMusicalPaperColumn"); + Paper_column *p2 = make_paper_column ("PaperColumn"); + + SCM m = now_mom().smobbed_copy(); + p1->set_property ("when", m); + p2->set_property ("when", m); + + set_columns (p1, p2); +} + + +void +Paper_column_engraver::initialize () +{ + system_ = dynamic_cast (unsmob_grob (get_property ("rootSystem"))); + make_columns (); + + + system_->set_bound (LEFT, command_column_); + command_column_->set_property ("breakable", SCM_BOOL_T); +} + +void +Paper_column_engraver::acknowledge_grob (Grob_info gi) +{ + Item *item = dynamic_cast (gi.grob ()); + if (!item) + { + programming_error ("Spanner found in Paper_column_engraver::acknowledge_grob()"); + return; + } + + items_.push (item); + + if (Staff_spacing::has_interface (item)) + { + Pointer_group_interface::add_grob (command_column_, + ly_symbol2scm ("spacing-wishes"), + gi.grob ()); + } + if (Note_spacing::has_interface (item)) + { + Pointer_group_interface::add_grob (musical_column_, + ly_symbol2scm ("spacing-wishes"), + gi.grob ()); + } +} + +void +Paper_column_engraver::set_columns (Paper_column *new_command, + Paper_column *new_musical) +{ + command_column_ = new_command; + musical_column_ = new_musical; + if (new_command) + { + context ()->set_property ("currentCommandColumn", new_command->self_scm ()); + } + + if (new_musical) + { + context ()->set_property ("currentMusicalColumn", new_musical->self_scm ()); + } + + system_->add_column (command_column_); + system_->add_column (musical_column_); +} + + +void +Paper_column_engraver::forbid_breaks () +{ + if (command_column_ && !first_) + command_column_->set_property ("breakable", SCM_EOL); +} + + +bool +Paper_column_engraver::try_music (Music *m) +{ + break_event_ = m; + + return true; +} + +void +Paper_column_engraver::process_music () +{ + if (break_event_) + { + SCM pen = command_column_->get_property ("penalty"); + Real total_penalty = scm_is_number (pen) ? scm_to_double (pen) : 0.0; + + SCM mpen = break_event_->get_property ("penalty"); + if (scm_is_number (mpen)) + total_penalty += scm_to_double (mpen); + + command_column_->set_property ("penalty", scm_make_real (total_penalty)); + + /* ugh. arbitrary, hardcoded */ + if (total_penalty > 10000.0) + forbid_breaks (); + + SCM page_pen = command_column_->get_property ("page-penalty"); + Real total_pp = scm_is_number (page_pen) ? scm_to_double (page_pen) : 0.0; + SCM mpage_pen = break_event_->get_property ("page-penalty"); + if (scm_is_number (mpage_pen)) + total_pp += scm_to_double (mpage_pen); + + command_column_->set_property ("page-penalty", scm_make_real (total_pp)); + } + + + bool start_of_measure = (last_moment_.main_part_ != now_mom ().main_part_ + && !measure_position (context ()).main_part_); + + /* + We can't do this in start_translation_timestep(), since time sig + changes won't have happened by then. + */ + if (start_of_measure) + { + Moment mlen = Moment (measure_length (context ())); + Grob * column = unsmob_grob (get_property ("currentCommandColumn")); + if (column) + column->set_property ("measure-length", mlen.smobbed_copy ()); + else + programming_error("No command column?"); + } +} + +void +Paper_column_engraver::stop_translation_timestep () +{ + for (int i = 0; i < items_.size (); i++) + { + Item *elem = items_[i]; + if (!elem->get_parent (X_AXIS) + || !unsmob_grob (elem->get_object ("axis-group-parent-X"))) + { + bool br = to_boolean (elem->get_property ("breakable")); + Axis_group_interface::add_element (br ? command_column_ : musical_column_, elem); + } + } + items_.clear (); + + if (to_boolean (command_column_->get_property ("breakable"))) + { + breaks_++; + if (! (breaks_%8)) + progress_indication ("[" + to_string (breaks_) + "]"); + } + + first_ = false; +} + +void +Paper_column_engraver::start_translation_timestep () +{ + /* + TODO: don't make columns when skipTypesetting is true. + */ + if (!first_) + make_columns (); +} + + + +#include "translator.icc" + +ADD_TRANSLATOR (Paper_column_engraver, + /* descr */ "Takes care of generating columns." + "\n\n " + "This engraver decides whether a column is breakable. The default is " + "that a column is always breakable. However, when every Bar_engraver " + "that does not have a barline at a certain point will call " + "Score_engraver::forbid_breaks to stop linebreaks. In practice, this " + "means that you can make a breakpoint by creating a barline (assuming " + "that there are no beams or notes that prevent a breakpoint.) ", + /* creats*/ "PaperColumn NonMusicalPaperColumn", + /* accepts */ "break-event", + /* acks */ "item-interface", + /* reads */ "", + /* write */ "currentCommandColumn currentMusicalColumn"); diff --git a/lily/part-combine-engraver.cc b/lily/part-combine-engraver.cc index 191fd30b52..6e4d63d12d 100644 --- a/lily/part-combine-engraver.cc +++ b/lily/part-combine-engraver.cc @@ -21,8 +21,8 @@ class Part_combine_engraver : public Engraver protected: virtual void acknowledge_grob (Grob_info); - virtual void process_music (); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_music (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); virtual bool try_music (Music *); private: Item *text_; @@ -92,6 +92,8 @@ Part_combine_engraver::stop_translation_timestep () event_ = 0; } +#include "translator.icc" + ADD_TRANSLATOR (Part_combine_engraver, /* descr */ "Part combine engraver for orchestral scores: " "Print markings a2, Solo, Solo II, and unisono ", diff --git a/lily/percent-repeat-engraver.cc b/lily/percent-repeat-engraver.cc index db9225a055..208ba3600f 100644 --- a/lily/percent-repeat-engraver.cc +++ b/lily/percent-repeat-engraver.cc @@ -57,9 +57,9 @@ protected: protected: virtual void finalize (); virtual bool try_music (Music *); - virtual void stop_translation_timestep (); - virtual void start_translation_timestep (); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void start_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_music (); }; Percent_repeat_engraver::Percent_repeat_engraver () @@ -198,6 +198,8 @@ Percent_repeat_engraver::stop_translation_timestep () typeset_perc (); } +#include "translator.icc" + ADD_TRANSLATOR (Percent_repeat_engraver, /* descr */ "Make whole bar and double bar repeats.", /* creats*/ "PercentRepeat DoublePercentRepeat", diff --git a/lily/performer-group-performer.cc b/lily/performer-group-performer.cc index 053a5f32fc..098def5c97 100644 --- a/lily/performer-group-performer.cc +++ b/lily/performer-group-performer.cc @@ -13,7 +13,9 @@ #include "audio-element.hh" #include "warn.hh" -ADD_TRANSLATOR (Performer_group_performer, +#include "translator.icc" + +ADD_TRANSLATOR_GROUP (Performer_group_performer, /* descr */ "", /* creats*/ "", /* accepts */ "", @@ -25,7 +27,7 @@ void Performer_group_performer::announce_element (Audio_element_info info) { announce_infos_.push (info); - Translator *t + Translator_group *t = context ()->get_parent_context ()->implementation (); if (Performer_group_performer *eg = dynamic_cast (t)) @@ -49,12 +51,22 @@ Performer_group_performer::acknowledge_audio_elements () } } +void +performer_each (SCM list, Performer_method method) +{ + for (SCM p = list; scm_is_pair (p); p = scm_cdr (p)) + { + Performer *e = dynamic_cast (unsmob_translator (scm_car (p))); + if (e) + (e->*method) (); + } +} + void Performer_group_performer::do_announces () { while (1) { - create_audio_elements (); performer_each (get_simple_trans_list (), &Performer::create_audio_elements); @@ -66,17 +78,27 @@ Performer_group_performer::do_announces () } } -Performer_group_performer::Performer_group_performer () + +void +Performer_group_performer::play_element (Audio_element *e) { + Context *c = context_->get_parent_context (); + if (c) + { + Performer_group_performer *pgp = dynamic_cast (c->implementation ()); + pgp->play_element (e); + } } -void -performer_each (SCM list, Performer_method method) +int +Performer_group_performer::get_tempo () const { - for (SCM p = list; scm_is_pair (p); p = scm_cdr (p)) + Context *c = context_->get_parent_context (); + if (c) { - Performer *e = dynamic_cast (unsmob_translator (scm_car (p))); - if (e) - (e->*method) (); + Performer_group_performer *pgp = dynamic_cast (c->implementation ()); + return pgp->get_tempo (); } + return 60; } + diff --git a/lily/performer.cc b/lily/performer.cc index 260c5d7154..f5e9e7f602 100644 --- a/lily/performer.cc +++ b/lily/performer.cc @@ -45,5 +45,6 @@ Performer::announce_element (Audio_element_info i) { if (!i.origin_trans_) i.origin_trans_ = this; + get_daddy_performer ()->announce_element (i); } diff --git a/lily/phrasing-slur-engraver.cc b/lily/phrasing-slur-engraver.cc index d4d064d451..333cba4e7b 100644 --- a/lily/phrasing-slur-engraver.cc +++ b/lily/phrasing-slur-engraver.cc @@ -28,9 +28,9 @@ class Phrasing_slur_engraver : public Engraver protected: virtual bool try_music (Music *); virtual void acknowledge_grob (Grob_info); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); virtual void finalize (); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void process_music (); public: TRANSLATOR_DECLARATIONS (Phrasing_slur_engraver); @@ -144,6 +144,8 @@ Phrasing_slur_engraver::stop_translation_timestep () events_[START] = events_[STOP] = 0; } +#include "translator.icc" + ADD_TRANSLATOR (Phrasing_slur_engraver, /* descr */ "Print phrasing slurs. Similar to @ref{Slur_engraver}", /* creats*/ "PhrasingSlur", diff --git a/lily/piano-pedal-engraver.cc b/lily/piano-pedal-engraver.cc index f6564f67b1..9f586a44ac 100644 --- a/lily/piano-pedal-engraver.cc +++ b/lily/piano-pedal-engraver.cc @@ -64,9 +64,9 @@ protected: virtual void initialize (); virtual void finalize (); virtual bool try_music (Music *); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); virtual void acknowledge_grob (Grob_info); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void process_music (); private: @@ -525,6 +525,8 @@ Piano_pedal_engraver::typeset_all (Pedal_info *p) } } +#include "translator.icc" + ADD_TRANSLATOR (Piano_pedal_engraver, /* descr */ "Engrave piano pedal symbols and brackets.", /* creats*/ "SostenutoPedal SustainPedal UnaCordaPedal SostenutoPedalLineSpanner SustainPedalLineSpanner UnaCordaPedalLineSpanner", diff --git a/lily/piano-pedal-performer.cc b/lily/piano-pedal-performer.cc index dd118981ab..554bbfab2c 100644 --- a/lily/piano-pedal-performer.cc +++ b/lily/piano-pedal-performer.cc @@ -30,8 +30,8 @@ protected: virtual void initialize (); virtual bool try_music (Music *); virtual void create_audio_elements (); - virtual void stop_translation_timestep (); - virtual void start_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void start_translation_timestep (); private: Link_array audios_; @@ -141,6 +141,8 @@ Piano_pedal_performer::try_music (Music *r) return false; } +#include "translator.icc" + ADD_TRANSLATOR (Piano_pedal_performer, "", "", "pedal-event", "", "", ""); diff --git a/lily/pitch-squash-engraver.cc b/lily/pitch-squash-engraver.cc index 870a5a9315..066c743d7c 100644 --- a/lily/pitch-squash-engraver.cc +++ b/lily/pitch-squash-engraver.cc @@ -32,6 +32,8 @@ Pitch_squash_engraver::Pitch_squash_engraver () { } +#include "translator.icc" + ADD_TRANSLATOR (Pitch_squash_engraver, /* descr */ "Set the vertical position of noteheads to " diff --git a/lily/pitched-trill-engraver.cc b/lily/pitched-trill-engraver.cc index 2af1190d81..38cba0810a 100644 --- a/lily/pitched-trill-engraver.cc +++ b/lily/pitched-trill-engraver.cc @@ -27,9 +27,9 @@ public: protected: virtual void acknowledge_grob (Grob_info); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void process_music (); virtual bool try_music (Music*); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); private: Item *trill_head_; Item *trill_group_; @@ -142,6 +142,8 @@ Pitched_trill_engraver::try_music (Music *) return false; } +#include "translator.icc" + ADD_TRANSLATOR (Pitched_trill_engraver, /* descr */ "Print the bracketed notehead after a notehead with trill.", /* creats*/ "TrillPitchHead TrillPitchAccidental TrillPitchGroup", diff --git a/lily/recording-group-engraver.cc b/lily/recording-group-engraver.cc index 5cf6c71304..f546ee4015 100644 --- a/lily/recording-group-engraver.cc +++ b/lily/recording-group-engraver.cc @@ -6,23 +6,9 @@ (c) 2003--2005 Han-Wen Nienhuys */ +#include "recording-group-engraver.hh" #include "context.hh" -#include "engraver-group-engraver.hh" -#include "protected-scm.hh" -class Recording_group_engraver : public Engraver_group_engraver -{ -public: - TRANSLATOR_DECLARATIONS (Recording_group_engraver); - virtual bool try_music (Music *m); - void add_music (SCM, SCM); - virtual void stop_translation_timestep (); - virtual void finalize (); - virtual void initialize (); - virtual void derived_mark () const; - SCM now_events_; - SCM accumulator_; -}; void Recording_group_engraver::derived_mark () const @@ -32,12 +18,6 @@ Recording_group_engraver::derived_mark () const scm_gc_mark (accumulator_); } -void -Recording_group_engraver::initialize () -{ - Engraver_group_engraver::initialize (); -} - Recording_group_engraver::Recording_group_engraver () { accumulator_ = SCM_EOL; @@ -53,10 +33,8 @@ Recording_group_engraver::add_music (SCM music, SCM success) void Recording_group_engraver::stop_translation_timestep () { - Engraver_group_engraver::stop_translation_timestep (); - - accumulator_ = scm_acons (scm_cons (now_mom ().smobbed_copy (), - get_property ("instrumentTransposition")), + accumulator_ = scm_acons (scm_cons (context ()->now_mom ().smobbed_copy (), + context ()->get_property ("instrumentTransposition")), now_events_, accumulator_); now_events_ = SCM_EOL; @@ -65,8 +43,7 @@ Recording_group_engraver::stop_translation_timestep () void Recording_group_engraver::finalize () { - Engraver_group_engraver::finalize (); - SCM proc = get_property ("recordEventSequence"); + SCM proc = context()->get_property ("recordEventSequence"); if (ly_is_procedure (proc)) scm_call_2 (proc, context ()->self_scm (), scm_cdr (accumulator_)); @@ -81,7 +58,22 @@ Recording_group_engraver::try_music (Music *m) return retval; } -ADD_TRANSLATOR (Recording_group_engraver, +void +recording_engraver (Translator_group *tg) +{ + Recording_group_engraver *rg = dynamic_cast (tg); + rg->stop_translation_timestep (); +} + +void +Recording_group_engraver::fetch_precomputable_methods (Translator_group_void_method ptrs[]) +{ + ptrs[STOP_TRANSLATION_TIMESTEP] = &recording_engraver; +} + +#include "translator.icc" + +ADD_TRANSLATOR_GROUP (Recording_group_engraver, "Engraver_group_engraver that records all music events " "for this context. Calls the procedure " "in @code{recordEventSequence} when finished.", diff --git a/lily/repeat-acknowledge-engraver.cc b/lily/repeat-acknowledge-engraver.cc index 77b840d597..7afe740b7a 100644 --- a/lily/repeat-acknowledge-engraver.cc +++ b/lily/repeat-acknowledge-engraver.cc @@ -11,6 +11,8 @@ #include "context.hh" #include "repeated-music.hh" +#include "translator.icc" + /* Objective: @@ -27,8 +29,8 @@ public: TRANSLATOR_DECLARATIONS (Repeat_acknowledge_engraver); protected: - virtual void start_translation_timestep (); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void start_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_music (); virtual void initialize (); }; @@ -105,6 +107,7 @@ Repeat_acknowledge_engraver::process_music () } } + ADD_TRANSLATOR (Repeat_acknowledge_engraver, /* descr */ "Acknowledge repeated music, and convert the contents of " "repeatCommands ainto an appropriate setting for whichBar.", diff --git a/lily/rest-collision-engraver.cc b/lily/rest-collision-engraver.cc index 2d718092f0..1f8c1c4555 100644 --- a/lily/rest-collision-engraver.cc +++ b/lily/rest-collision-engraver.cc @@ -18,8 +18,8 @@ class Rest_collision_engraver : public Engraver Link_array note_columns_; protected: virtual void acknowledge_grob (Grob_info); - virtual void process_acknowledged_grobs (); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_acknowledged (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); public: TRANSLATOR_DECLARATIONS (Rest_collision_engraver); }; @@ -31,7 +31,7 @@ Rest_collision_engraver::Rest_collision_engraver () } void -Rest_collision_engraver::process_acknowledged_grobs () +Rest_collision_engraver::process_acknowledged () { if (rest_collision_ || note_columns_.is_empty () @@ -65,6 +65,8 @@ Rest_collision_engraver::stop_translation_timestep () rest_count_ = 0; } +#include "translator.icc" + ADD_TRANSLATOR (Rest_collision_engraver, /* descr */ "Handles collisions of rests.", /* creats*/ "RestCollision", diff --git a/lily/rest-engraver.cc b/lily/rest-engraver.cc index 0116992b67..e276d303c8 100644 --- a/lily/rest-engraver.cc +++ b/lily/rest-engraver.cc @@ -23,9 +23,9 @@ class Rest_engraver : public Engraver Grob *rest_; protected: virtual bool try_music (Music *); - virtual void stop_translation_timestep (); - virtual void start_translation_timestep (); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void start_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_music (); public: TRANSLATOR_DECLARATIONS (Rest_engraver); @@ -106,6 +106,8 @@ Rest_engraver::try_music (Music *m) return false; } +#include "translator.icc" + ADD_TRANSLATOR (Rest_engraver, /* descr */ "", /* creats*/ "Rest Dots", diff --git a/lily/rhythmic-column-engraver.cc b/lily/rhythmic-column-engraver.cc index 3f059df4e2..de2fcc46fa 100644 --- a/lily/rhythmic-column-engraver.cc +++ b/lily/rhythmic-column-engraver.cc @@ -51,8 +51,8 @@ class Rhythmic_column_engraver : public Engraver protected: virtual void acknowledge_grob (Grob_info); - virtual void process_acknowledged_grobs (); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_acknowledged (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); }; Rhythmic_column_engraver::Rhythmic_column_engraver () @@ -66,7 +66,7 @@ Rhythmic_column_engraver::Rhythmic_column_engraver () } void -Rhythmic_column_engraver::process_acknowledged_grobs () +Rhythmic_column_engraver::process_acknowledged () { if (rheads_.size ()) { @@ -145,6 +145,8 @@ Rhythmic_column_engraver::stop_translation_timestep () stem_ = 0; } +#include "translator.icc" + ADD_TRANSLATOR (Rhythmic_column_engraver, /* descr */ "Generates NoteColumn, an objects that groups stems, noteheads and rests.", /* creats*/ "NoteColumn NoteSpacing", diff --git a/lily/score-context.cc b/lily/score-context.cc index 15e2e5e9fa..34f82cc247 100644 --- a/lily/score-context.cc +++ b/lily/score-context.cc @@ -13,7 +13,7 @@ void Score_context::prepare (Moment w) { - Translator *t = implementation (); + Translator_group *t = implementation (); Score_translator *s = dynamic_cast (t); s->prepare (w); @@ -22,7 +22,7 @@ Score_context::prepare (Moment w) void Score_context::finish () { - Translator *t = implementation (); + Translator_group *t = implementation (); Score_translator *s = dynamic_cast (t); s->finish (); @@ -31,7 +31,7 @@ Score_context::finish () void Score_context::one_time_step () { - Translator *t = implementation (); + Translator_group *t = implementation (); Score_translator *s = dynamic_cast (t); s->one_time_step (); } @@ -39,7 +39,7 @@ Score_context::one_time_step () SCM Score_context::get_output () { - Translator *t = implementation (); + Translator_group *t = implementation (); Score_translator *s = dynamic_cast (t); return s->get_output (); } diff --git a/lily/score-engraver.cc b/lily/score-engraver.cc index 985be103ae..658b44ac13 100644 --- a/lily/score-engraver.cc +++ b/lily/score-engraver.cc @@ -17,10 +17,9 @@ #include "output-def.hh" #include "axis-group-interface.hh" #include "context-def.hh" -#include "staff-spacing.hh" -#include "note-spacing.hh" #include "global-context.hh" #include "open-type-font.hh" +#include "paper-column-engraver.hh" /* TODO: the column creation logic is rather hairy. Revise it. @@ -28,9 +27,6 @@ Score_engraver::Score_engraver () { system_ = 0; - command_column_ = 0; - musical_column_ = 0; - breaks_ = 0; pscore_ = 0; } @@ -43,55 +39,21 @@ Score_engraver::derived_mark () const Engraver_group_engraver::derived_mark (); } -void -Score_engraver::make_columns () -{ - /* - ugh. - */ - if (!command_column_) - { - SCM nmp - = updated_grob_properties (context (), - ly_symbol2scm ("NonMusicalPaperColumn")); - - Object_key const *key1 = context ()->get_grob_key ("NonMusicalPaperColumn"); - - SCM pc = updated_grob_properties (context (), - ly_symbol2scm ("PaperColumn")); - Object_key const *key2 = context ()->get_grob_key ("PaperColumn"); - set_columns (new Paper_column (nmp, key1), new Paper_column (pc, key2)); - - Grob_info i1 (this, command_column_); - announce_grob (i1); - - Grob_info i2 (this, musical_column_); - announce_grob (i2); - } -} void Score_engraver::prepare (Moment m) { - /* - TODO: don't make columns when skipTypesetting is true. - */ - make_columns (); - - SCM w = m.smobbed_copy (); - command_column_->set_property ("when", w); - musical_column_->set_property ("when", w); - - recurse_over_translators (context (), &Translator::start_translation_timestep, DOWN); + (void) m; + + precomputed_recurse_over_translators (context (), START_TRANSLATION_TIMESTEP, DOWN); } void Score_engraver::finish () { - if ((breaks_ % 8)) - progress_indication ("[" + to_string (breaks_) + "]"); - - recurse_over_translators (context (), &Translator::finalize, UP); + recurse_over_translators (context (), &Translator::finalize, + &Translator_group::finalize, + UP); } #define MUSIC_FONT "emmentaler-20" @@ -114,19 +76,16 @@ Score_engraver::initialize () + _ ("Aborting")); } - pscore_ = new Paper_score (dynamic_cast (get_output_def ())); + pscore_ = new Paper_score (dynamic_cast (context ()->get_output_def ())); scm_gc_unprotect_object (pscore_->self_scm ()); SCM props = updated_grob_properties (context (), ly_symbol2scm ("System")); Object_key const *sys_key = context ()->get_grob_key ("System"); pscore_->typeset_system (new System (props, sys_key)); - system_ = pscore_->root_system (); - make_columns (); - system_->set_bound (LEFT, command_column_); - command_column_->set_property ("breakable", SCM_BOOL_T); - + context ()->set_property ("rootSystem", system_->self_scm ()); + Engraver_group_engraver::initialize (); } @@ -135,24 +94,20 @@ Score_engraver::finalize () { Score_translator::finalize (); - Grob *cc - = unsmob_grob (get_property ("currentCommandColumn")); - system_->set_bound (RIGHT, cc); - cc->set_property ("breakable", SCM_BOOL_T); - typeset_all (); } void Score_engraver::one_time_step () { - if (!to_boolean (get_property ("skipTypesetting"))) + if (!to_boolean (context ()->get_property ("skipTypesetting"))) { - recurse_over_translators (context (), &Engraver::process_music, UP); + precomputed_recurse_over_translators (context (), PROCESS_MUSIC, UP); Engraver_group_engraver::do_announces (); } - recurse_over_translators (context (), &Translator::stop_translation_timestep, UP); + precomputed_recurse_over_translators (context (), STOP_TRANSLATION_TIMESTEP, UP); + typeset_all (); } void @@ -170,68 +125,34 @@ Score_engraver::typeset_all () { Grob *elem = elems_[i]; - if (dynamic_cast (elem)) - { - if ((!elem->get_parent (X_AXIS) - || !unsmob_grob (elem->get_object ("axis-group-parent-X"))) - && elem != command_column_ - && elem != musical_column_) - { - bool br = to_boolean (elem->get_property ("breakable")); - Axis_group_interface::add_element (br ? command_column_ : musical_column_, elem); - } - } if (!elem->get_parent (Y_AXIS)) Axis_group_interface::add_element (system_, elem); } elems_.clear (); } -void -Score_engraver::stop_translation_timestep () +SCM +Score_engraver::get_output () { - // this generates all items. - Engraver_group_engraver::stop_translation_timestep (); - - typeset_all (); - if (to_boolean (command_column_->get_property ("breakable"))) - { - breaks_++; - if (! (breaks_%8)) - progress_indication ("[" + to_string (breaks_) + "]"); - } - - command_column_ = 0; - musical_column_ = 0; + Music_output *o = pscore_; + return o->self_scm (); } + +/* + UGH UGH + */ void -Score_engraver::set_columns (Paper_column *new_command, - Paper_column *new_musical) +Score_engraver::forbid_breaks () { - assert (!command_column_ && !musical_column_); - - command_column_ = new_command; - musical_column_ = new_musical; - if (new_command) - { - context ()->set_property ("currentCommandColumn", new_command->self_scm ()); - } - - if (new_musical) + for (SCM s = simple_trans_list_; scm_is_pair (s); s = scm_cdr (s)) { - context ()->set_property ("currentMusicalColumn", new_musical->self_scm ()); + Translator *tr = unsmob_translator (scm_car (s)); + if (Paper_column_engraver* pce = dynamic_cast (tr)) + { + pce->forbid_breaks (); + } } - - system_->add_column (command_column_); - system_->add_column (musical_column_); -} - -SCM -Score_engraver::get_output () -{ - Music_output *o = pscore_; - return o->self_scm (); } bool @@ -240,73 +161,12 @@ Score_engraver::try_music (Music *m) if (Engraver_group_engraver::try_music (m)) return true; - if (m->is_mus_type ("break-event")) - { - SCM pen = command_column_->get_property ("penalty"); - Real total_penalty = scm_is_number (pen) ? scm_to_double (pen) : 0.0; - - SCM mpen = m->get_property ("penalty"); - if (scm_is_number (mpen)) - total_penalty += scm_to_double (mpen); - - command_column_->set_property ("penalty", scm_make_real (total_penalty)); - - /* ugh. arbitrary, hardcoded */ - if (total_penalty > 10000.0) - forbid_breaks (); - - SCM page_pen = command_column_->get_property ("page-penalty"); - Real total_pp = scm_is_number (page_pen) ? scm_to_double (page_pen) : 0.0; - SCM mpage_pen = m->get_property ("page-penalty"); - if (scm_is_number (mpage_pen)) - total_pp += scm_to_double (mpage_pen); - - command_column_->set_property ("page-penalty", scm_make_real (total_pp)); - return true; - } return false; } -void -Score_engraver::forbid_breaks () -{ - if (command_column_) - command_column_->set_property ("breakable", SCM_EOL); -} - -void -Score_engraver::acknowledge_grob (Grob_info gi) -{ - if (Staff_spacing::has_interface (gi.grob ())) - { - Pointer_group_interface::add_grob (command_column_, - ly_symbol2scm ("spacing-wishes"), - gi.grob ()); - } - if (Note_spacing::has_interface (gi.grob ())) - { - Pointer_group_interface::add_grob (musical_column_, - ly_symbol2scm ("spacing-wishes"), - gi.grob ()); - } - - if (Axis_group_interface::has_interface (gi.grob ()) - && gi.grob ()->internal_has_interface (ly_symbol2scm ("vertically-spaceable-interface"))) - { - SCM spaceable = get_property ("verticallySpacedContexts"); - Context *orig = gi.origin_contexts (this)[0]; - - if (scm_memq (ly_symbol2scm (orig->context_name ().to_str0 ()), - spaceable) != SCM_BOOL_F) - { - Pointer_group_interface::add_grob (system_, - ly_symbol2scm ("spaceable-staves"), - gi.grob ()); - } - } -} +#include "translator.icc" -ADD_TRANSLATOR (Score_engraver, +ADD_TRANSLATOR_GROUP (Score_engraver, /* descr */ "Top level engraver. Takes care of generating columns and the complete system (ie. System) " "\n\n " "This engraver decides whether a column is breakable. The default is " diff --git a/lily/score-performer.cc b/lily/score-performer.cc index 0c341dd98c..a8784405f0 100644 --- a/lily/score-performer.cc +++ b/lily/score-performer.cc @@ -16,8 +16,9 @@ #include "warn.hh" #include "context-def.hh" #include "output-def.hh" +#include "context.hh" -ADD_TRANSLATOR (Score_performer, +ADD_TRANSLATOR_GROUP (Score_performer, /* descr */ "", /* creats*/ "", /* accepts */ "", @@ -55,21 +56,24 @@ Score_performer::prepare (Moment m) { audio_column_ = new Audio_column (m); play_element (audio_column_); - recurse_over_translators (context (), &Translator::start_translation_timestep, UP); + precomputed_recurse_over_translators (context (), START_TRANSLATION_TIMESTEP, UP); } void Score_performer::finish () { - recurse_over_translators (context (), &Translator::finalize, UP); + recurse_over_translators (context (), + &Translator::finalize, + &Translator_group::finalize, + UP); } void Score_performer::one_time_step () { - recurse_over_translators (context (), &Performer::process_music, UP); - recurse_over_translators (context (), &Performer::do_announces, UP); - recurse_over_translators (context (), &Translator::stop_translation_timestep, UP); + precomputed_recurse_over_translators (context (), PROCESS_MUSIC, UP); + do_announces (); + precomputed_recurse_over_translators (context (), STOP_TRANSLATION_TIMESTEP, UP); } int @@ -101,7 +105,7 @@ Score_performer::initialize () { performance_ = new Performance; scm_gc_unprotect_object (performance_->self_scm ()); - performance_->midi_ = get_output_def (); + performance_->midi_ = context ()->get_output_def (); Translator_group::initialize (); } diff --git a/lily/script-column-engraver.cc b/lily/script-column-engraver.cc index a7ae23ec4a..78cefe92f5 100644 --- a/lily/script-column-engraver.cc +++ b/lily/script-column-engraver.cc @@ -10,6 +10,9 @@ #include "script-column.hh" #include "side-position-interface.hh" +#include "translator.icc" + + /** Find potentially colliding scripts, and put them in a Script_column, that will fix the collisions. */ @@ -22,8 +25,8 @@ public: TRANSLATOR_DECLARATIONS (Script_column_engraver); protected: virtual void acknowledge_grob (Grob_info); - virtual void process_acknowledged_grobs (); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_acknowledged (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); }; Script_column_engraver::Script_column_engraver () @@ -53,7 +56,7 @@ Script_column_engraver::acknowledge_grob (Grob_info inf) } void -Script_column_engraver::process_acknowledged_grobs () +Script_column_engraver::process_acknowledged () { if (!scol_ && scripts_.size () > 1) { diff --git a/lily/script-engraver.cc b/lily/script-engraver.cc index f6dec3a7c4..9f2f760d9f 100644 --- a/lily/script-engraver.cc +++ b/lily/script-engraver.cc @@ -39,8 +39,8 @@ class Script_engraver : public Engraver protected: virtual bool try_music (Music *); - virtual void stop_translation_timestep (); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_music (); virtual void acknowledge_grob (Grob_info); public: @@ -237,6 +237,8 @@ Script_engraver::stop_translation_timestep () scripts_.clear (); } +#include "translator.icc" + ADD_TRANSLATOR (Script_engraver, /* descr */ "Handles note scripted articulations.", /* creats*/ "Script", diff --git a/lily/separating-line-group-engraver.cc b/lily/separating-line-group-engraver.cc index b3bfe12aef..b8b36943f3 100644 --- a/lily/separating-line-group-engraver.cc +++ b/lily/separating-line-group-engraver.cc @@ -6,16 +6,18 @@ (c) 1998--2005 Han-Wen Nienhuys */ +#include "engraver.hh" + #include "separating-group-spanner.hh" #include "separation-item.hh" #include "paper-column.hh" #include "output-def.hh" -#include "engraver.hh" #include "axis-group-interface.hh" #include "note-spacing.hh" #include "accidental-placement.hh" #include "context.hh" #include "grob-array.hh" +#include "pointer-group-interface.hh" struct Spacings { @@ -51,10 +53,10 @@ protected: Spanner *sep_span_; virtual void acknowledge_grob (Grob_info); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void process_music (); virtual void finalize (); - virtual void stop_translation_timestep (); - virtual void start_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void start_translation_timestep (); public: TRANSLATOR_DECLARATIONS (Separating_line_group_engraver); }; @@ -217,6 +219,8 @@ Separating_line_group_engraver::stop_translation_timestep () musical_item_ = 0; } +#include "translator.icc" + ADD_TRANSLATOR (Separating_line_group_engraver, /* descr */ "Generates objects for computing spacing parameters.", /* creats*/ "SeparationItem SeparatingGroupSpanner StaffSpacing", diff --git a/lily/slash-repeat-engraver.cc b/lily/slash-repeat-engraver.cc index ee1ea2fd44..74d1f52b9f 100644 --- a/lily/slash-repeat-engraver.cc +++ b/lily/slash-repeat-engraver.cc @@ -46,9 +46,9 @@ protected: Item *double_percent_; protected: virtual bool try_music (Music *); - virtual void stop_translation_timestep (); - virtual void start_translation_timestep (); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void start_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_music (); }; Slash_repeat_engraver::Slash_repeat_engraver () @@ -119,6 +119,8 @@ Slash_repeat_engraver::stop_translation_timestep () beat_slash_ = 0; } +#include "translator.icc" + ADD_TRANSLATOR (Slash_repeat_engraver, /* descr */ "Make beat repeats.", /* creats*/ "RepeatSlash", diff --git a/lily/slur-engraver.cc b/lily/slur-engraver.cc index f87e78279d..cb1da18560 100644 --- a/lily/slur-engraver.cc +++ b/lily/slur-engraver.cc @@ -30,9 +30,9 @@ class Slur_engraver : public Engraver protected: virtual bool try_music (Music *); virtual void acknowledge_grob (Grob_info); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); virtual void finalize (); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void process_music (); public: TRANSLATOR_DECLARATIONS (Slur_engraver); @@ -156,6 +156,8 @@ Slur_engraver::stop_translation_timestep () events_[START] = events_[STOP] = 0; } +#include "translator.icc" + ADD_TRANSLATOR (Slur_engraver, /* descr */ "Build slurs grobs from slur events", /* creats*/ "Slur", diff --git a/lily/slur-performer.cc b/lily/slur-performer.cc index eb879a7f99..9742d753d9 100644 --- a/lily/slur-performer.cc +++ b/lily/slur-performer.cc @@ -24,8 +24,8 @@ public: protected: virtual bool try_music (Music *ev); - virtual void start_translation_timestep (); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void start_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_music (); void set_melisma (bool); private: Music *start_ev_; @@ -89,6 +89,8 @@ Slur_performer::try_music (Music *m) return false; } +#include "translator.icc" + ADD_TRANSLATOR (Slur_performer, "", "", "slur-event", "", "", ""); diff --git a/lily/spacing-engraver.cc b/lily/spacing-engraver.cc index 5637e33551..b2b27ff282 100644 --- a/lily/spacing-engraver.cc +++ b/lily/spacing-engraver.cc @@ -47,9 +47,9 @@ class Spacing_engraver : public Engraver TRANSLATOR_DECLARATIONS (Spacing_engraver); protected: virtual void acknowledge_grob (Grob_info); - virtual void start_translation_timestep (); - virtual void stop_translation_timestep (); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void start_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_music (); virtual void finalize (); }; @@ -172,6 +172,8 @@ Spacing_engraver::start_translation_timestep () stopped_durations_.push (playing_durations_.get ()); } +#include "translator.icc" + ADD_TRANSLATOR (Spacing_engraver, /* descr */ "make a SpacingSpanner and do bookkeeping of shortest starting and playing notes ", /* creats*/ "SpacingSpanner", diff --git a/lily/span-arpeggio-engraver.cc b/lily/span-arpeggio-engraver.cc index 5f77670b3f..69736c2f83 100644 --- a/lily/span-arpeggio-engraver.cc +++ b/lily/span-arpeggio-engraver.cc @@ -25,8 +25,8 @@ public: protected: virtual void acknowledge_grob (Grob_info); - virtual void process_acknowledged_grobs (); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_acknowledged (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); private: Item *span_arpeggio_; @@ -49,7 +49,7 @@ Span_arpeggio_engraver::acknowledge_grob (Grob_info info) } void -Span_arpeggio_engraver::process_acknowledged_grobs () +Span_arpeggio_engraver::process_acknowledged () { /* connectArpeggios is slightly brusque; we should really read a grob @@ -98,6 +98,8 @@ Span_arpeggio_engraver::stop_translation_timestep () arpeggios_.clear (); } +#include "translator.icc" + ADD_TRANSLATOR (Span_arpeggio_engraver, /* descr */ "", /* creats*/ "Arpeggio", diff --git a/lily/span-bar-engraver.cc b/lily/span-bar-engraver.cc index 80339b3ce8..f98f8d3214 100644 --- a/lily/span-bar-engraver.cc +++ b/lily/span-bar-engraver.cc @@ -28,7 +28,7 @@ public: TRANSLATOR_DECLARATIONS (Span_bar_engraver); protected: virtual void acknowledge_grob (Grob_info); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); }; Span_bar_engraver::Span_bar_engraver () @@ -72,6 +72,8 @@ Span_bar_engraver::stop_translation_timestep () bars_.set_size (0); } +#include "translator.icc" + ADD_TRANSLATOR (Span_bar_engraver, /* descr */ "This engraver makes cross-staff barlines: It catches all normal " "bar lines, and draws a single span-bar across them.", diff --git a/lily/span-bar.cc b/lily/span-bar.cc index 261791f1d0..ae50a097f5 100644 --- a/lily/span-bar.cc +++ b/lily/span-bar.cc @@ -16,6 +16,8 @@ #include "axis-group-interface.hh" #include "bar-line.hh" #include "grob.hh" +#include "pointer-group-interface.hh" + void Span_bar::add_bar (Grob *me, Grob *b) diff --git a/lily/span-dynamic-performer.cc b/lily/span-dynamic-performer.cc index bb99c70487..7b367c2899 100644 --- a/lily/span-dynamic-performer.cc +++ b/lily/span-dynamic-performer.cc @@ -31,8 +31,8 @@ public: protected: virtual bool try_music (Music *); virtual void acknowledge_audio_element (Audio_element_info); - virtual void process_music (); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_music (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); private: Audio_dynamic *audio_; @@ -179,6 +179,8 @@ Span_dynamic_performer::try_music (Music *r) } return false; } +#include "translator.icc" + ADD_TRANSLATOR (Span_dynamic_performer, "", "", "crescendo-event decrescendo-event", diff --git a/lily/spanner.cc b/lily/spanner.cc index 776f4097d1..1909eee4fe 100644 --- a/lily/spanner.cc +++ b/lily/spanner.cc @@ -209,8 +209,6 @@ Spanner::Spanner (SCM s, Object_key const *key) break_index_ = 0; spanned_drul_[LEFT] = 0; spanned_drul_[RIGHT] = 0; - - interfaces_ = scm_cons (ly_symbol2scm ("spanner-interface"), interfaces_); } Spanner::Spanner (Spanner const &s, int count) diff --git a/lily/staff-collecting-engraver.cc b/lily/staff-collecting-engraver.cc index f9b97e4c67..5784dd79c7 100644 --- a/lily/staff-collecting-engraver.cc +++ b/lily/staff-collecting-engraver.cc @@ -34,6 +34,8 @@ Staff_collecting_engraver::acknowledge_grob (Grob_info gi) } } +#include "translator.icc" + ADD_TRANSLATOR (Staff_collecting_engraver, /* descr */ "Maintain the stavesFound variable", diff --git a/lily/staff-performer.cc b/lily/staff-performer.cc index 902744a6cc..a687a686e0 100644 --- a/lily/staff-performer.cc +++ b/lily/staff-performer.cc @@ -16,7 +16,7 @@ /** Perform a staff. Individual notes should have their instrument (staff-wide) set, so we override play_element () */ -class Staff_performer : public Performer_group_performer +class Staff_performer : public Performer { public: TRANSLATOR_DECLARATIONS (Staff_performer); @@ -26,11 +26,11 @@ public: String instrument_string_; protected: - virtual void play_element (Audio_element *p); + virtual void acknowledge_audio_element (Audio_element *p); virtual void finalize (); virtual void initialize (); virtual void create_audio_elements (); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); private: Audio_staff *audio_staff_; @@ -40,6 +40,8 @@ private: Audio_tempo *tempo_; }; +#include "translator.icc" + ADD_TRANSLATOR (Staff_performer, "", "", "", "", "", ""); @@ -68,8 +70,6 @@ Staff_performer::initialize () tempo_ = new Audio_tempo (get_tempo ()); announce_element (Audio_element_info (tempo_, 0)); - - Performer_group_performer::initialize (); } void @@ -89,7 +89,6 @@ Staff_performer::create_audio_elements () play_element (instrument_); play_element (instrument_name_); } - Performer_group_performer::create_audio_elements (); } void @@ -111,13 +110,11 @@ Staff_performer::stop_translation_timestep () } instrument_name_ = 0; instrument_ = 0; - Performer_group_performer::stop_translation_timestep (); } void Staff_performer::finalize () { - Performer_group_performer::finalize (); Performer::play_element (audio_staff_); audio_staff_ = 0; } @@ -138,12 +135,11 @@ Staff_performer::new_instrument_string () } void -Staff_performer::play_element (Audio_element *p) +Staff_performer::acknowledge_audio_element (Audio_element *p) { if (Audio_item *ai = dynamic_cast (p)) { audio_staff_->add_audio_item (ai); } - Performer::play_element (p); } diff --git a/lily/staff-symbol-engraver.cc b/lily/staff-symbol-engraver.cc index 8725390805..f9e79a6b94 100644 --- a/lily/staff-symbol-engraver.cc +++ b/lily/staff-symbol-engraver.cc @@ -108,6 +108,8 @@ Staff_symbol_engraver::acknowledge_grob (Grob_info s) } } +#include "translator.icc" + ADD_TRANSLATOR (Staff_symbol_engraver, /* descr */ "Create the constellation of five (default) " "staff lines.", diff --git a/lily/stanza-number-align-engraver.cc b/lily/stanza-number-align-engraver.cc index 0c9e40b6e2..5024f3423b 100644 --- a/lily/stanza-number-align-engraver.cc +++ b/lily/stanza-number-align-engraver.cc @@ -23,7 +23,7 @@ protected: Link_array lyrics_; Link_array stanza_numbers_; virtual void acknowledge_grob (Grob_info); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); }; Stanza_number_align_engraver::Stanza_number_align_engraver () @@ -52,6 +52,8 @@ Stanza_number_align_engraver::stop_translation_timestep () lyrics_.clear (); } +#include "translator.icc" + ADD_TRANSLATOR (Stanza_number_align_engraver, "This engraver ensures that stanza numbers are neatly aligned. ", "", diff --git a/lily/stanza-number-engraver.cc b/lily/stanza-number-engraver.cc index d74f0d8bcb..618add3881 100644 --- a/lily/stanza-number-engraver.cc +++ b/lily/stanza-number-engraver.cc @@ -21,8 +21,8 @@ class Stanza_number_engraver : public Engraver SCM last_stanza_; public: TRANSLATOR_DECLARATIONS (Stanza_number_engraver); - virtual void process_music (); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_music (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); virtual void acknowledge_grob (Grob_info); }; @@ -67,6 +67,8 @@ Stanza_number_engraver::stop_translation_timestep () text_ = 0; } +#include "translator.icc" + ADD_TRANSLATOR (Stanza_number_engraver, /* descr */ "", /* creats*/ "StanzaNumber", diff --git a/lily/stem-engraver.cc b/lily/stem-engraver.cc index 36e7661242..e9369c1842 100644 --- a/lily/stem-engraver.cc +++ b/lily/stem-engraver.cc @@ -34,7 +34,7 @@ protected: void make_stem (Grob_info); virtual void acknowledge_grob (Grob_info); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); virtual bool try_music (Music *); }; @@ -171,6 +171,8 @@ Stem_engraver::try_music (Music *m) return false; } +#include "translator.icc" + ADD_TRANSLATOR (Stem_engraver, /* descr */ "Create stems and single-stem tremolos. It also works together with " "the beam engraver for overriding beaming.", diff --git a/lily/string-number-engraver.cc b/lily/string-number-engraver.cc index 503445facb..c21eff2aa4 100644 --- a/lily/string-number-engraver.cc +++ b/lily/string-number-engraver.cc @@ -32,6 +32,8 @@ String_number_engraver::String_number_engraver () engraver should provide this functionality. */ +#include "translator.icc" + ADD_TRANSLATOR (String_number_engraver, /* descr */ "Swallow string-number-events - the purpose of this engraver is to" " process tab for normal notation. To provent warnings for unprocessed " diff --git a/lily/swallow-engraver.cc b/lily/swallow-engraver.cc index e9178e7142..9d51eb6edd 100644 --- a/lily/swallow-engraver.cc +++ b/lily/swallow-engraver.cc @@ -26,6 +26,8 @@ Swallow_engraver::Swallow_engraver () { } +#include "translator.icc" + ADD_TRANSLATOR (Swallow_engraver, /* descr */ "This engraver swallows everything given to it silently. The purpose of " "this is to prevent spurious \"event junked\" warnings.", diff --git a/lily/swallow-perf.cc b/lily/swallow-perf.cc index 3bf237d101..2c0dbad55c 100644 --- a/lily/swallow-perf.cc +++ b/lily/swallow-perf.cc @@ -31,6 +31,8 @@ Swallow_performer::try_music (Music *m) Swallow_performer::Swallow_performer () {} +#include "translator.icc" + ADD_TRANSLATOR (Swallow_performer, /* descr */ "", /* creats*/ "", diff --git a/lily/system-start-delimiter-engraver.cc b/lily/system-start-delimiter-engraver.cc index 4b4f33c17b..1646ee5477 100644 --- a/lily/system-start-delimiter-engraver.cc +++ b/lily/system-start-delimiter-engraver.cc @@ -22,7 +22,7 @@ public: protected: Spanner *delim_; virtual void acknowledge_grob (Grob_info); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void process_music (); virtual void finalize (); }; @@ -82,6 +82,8 @@ System_start_delimiter_engraver::finalize () } } +#include "translator.icc" + ADD_TRANSLATOR (System_start_delimiter_engraver, /* descr */ "Creates a system start delimiter (ie. SystemStart@{Bar, Brace, Bracket@} spanner", /* creats*/ "SystemStartBar SystemStartBrace SystemStartBracket", diff --git a/lily/system-start-delimiter.cc b/lily/system-start-delimiter.cc index e2d323b8c8..b49dc452e0 100644 --- a/lily/system-start-delimiter.cc +++ b/lily/system-start-delimiter.cc @@ -19,6 +19,7 @@ #include "lookup.hh" #include "item.hh" +#include "pointer-group-interface.hh" Stencil diff --git a/lily/system.cc b/lily/system.cc index 4cf4f13c47..73e65dfeb3 100644 --- a/lily/system.cc +++ b/lily/system.cc @@ -25,6 +25,7 @@ #include "paper-system.hh" #include "tweak-registration.hh" #include "grob-array.hh" +#include "pointer-group-interface.hh" System::System (System const &src, int count) : Spanner (src, count) @@ -428,22 +429,22 @@ Link_array System::columns () const { extract_grob_set (this, "columns", ro_columns); - Link_array columns (ro_columns); - - bool found = false; - for (int i = columns.size (); i--;) + + int last_breakable = ro_columns.size (); + + while (last_breakable --) { - bool brb = Item::is_breakable (columns[i]); - found = found || brb; - - /* - the last column should be breakable. Weed out any columns that - seem empty. We need to retain breakable columns, in case - someone forced a breakpoint. - */ - if (!found || !Paper_column::is_used (columns[i])) - columns.del (i); + if (Item::is_breakable (ro_columns [last_breakable])) + break; } + + Link_array columns; + for (int i = 0; i <= last_breakable; i++) + { + if (Paper_column::is_used (ro_columns[i])) + columns.push (ro_columns[i]); + } + return columns; } diff --git a/lily/tab-note-heads-engraver.cc b/lily/tab-note-heads-engraver.cc index d4210c42fc..3aab0a9e86 100644 --- a/lily/tab-note-heads-engraver.cc +++ b/lily/tab-note-heads-engraver.cc @@ -36,9 +36,9 @@ public: protected: virtual bool try_music (Music *event); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void process_music (); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); }; Tab_note_heads_engraver::Tab_note_heads_engraver () @@ -165,6 +165,8 @@ Tab_note_heads_engraver::stop_translation_timestep () tabstring_events_.clear (); } +#include "translator.icc" + ADD_TRANSLATOR (Tab_note_heads_engraver, /* descr */ "Generate one or more tablature noteheads from Music of type NoteEvent.", /* creats*/ "TabNoteHead Dots", diff --git a/lily/tab-staff-symbol-engraver.cc b/lily/tab-staff-symbol-engraver.cc index c6c22b519f..1227d2e0f0 100644 --- a/lily/tab-staff-symbol-engraver.cc +++ b/lily/tab-staff-symbol-engraver.cc @@ -35,6 +35,8 @@ Tab_staff_symbol_engraver::Tab_staff_symbol_engraver () { } +#include "translator.icc" + ADD_TRANSLATOR (Tab_staff_symbol_engraver, /* descr */ "Create a staff-symbol, but look at stringTunings for the number of lines." "staff lines.", diff --git a/lily/tempo-performer.cc b/lily/tempo-performer.cc index 58310da1dc..c58ba137f6 100644 --- a/lily/tempo-performer.cc +++ b/lily/tempo-performer.cc @@ -21,7 +21,7 @@ public: protected: virtual bool try_music (Music *req); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); virtual void create_audio_elements (); private: @@ -77,6 +77,8 @@ Tempo_performer::try_music (Music *req) return true; } +#include "translator.icc" + ADD_TRANSLATOR (Tempo_performer, "", "", "metronome-change-event", "", "", ""); diff --git a/lily/text-engraver.cc b/lily/text-engraver.cc index 1766ac64b7..b9f9509304 100644 --- a/lily/text-engraver.cc +++ b/lily/text-engraver.cc @@ -24,8 +24,8 @@ public: TRANSLATOR_DECLARATIONS (Text_engraver); protected: virtual bool try_music (Music *m); - virtual void stop_translation_timestep (); - virtual void process_acknowledged_grobs (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_acknowledged (); virtual void acknowledge_grob (Grob_info); }; @@ -72,7 +72,7 @@ Text_engraver::acknowledge_grob (Grob_info inf) } void -Text_engraver::process_acknowledged_grobs () +Text_engraver::process_acknowledged () { if (texts_.size ()) return; @@ -119,6 +119,8 @@ Text_engraver::Text_engraver () { } +#include "translator.icc" + ADD_TRANSLATOR (Text_engraver, /* descr */ "Create text-scripts", /* creats*/ "TextScript", diff --git a/lily/text-spanner-engraver.cc b/lily/text-spanner-engraver.cc index 5c177c5a96..69f4c55c84 100644 --- a/lily/text-spanner-engraver.cc +++ b/lily/text-spanner-engraver.cc @@ -18,8 +18,8 @@ protected: virtual void finalize (); virtual void acknowledge_grob (Grob_info); virtual bool try_music (Music *); - virtual void stop_translation_timestep (); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_music (); private: Spanner *span_; @@ -139,6 +139,8 @@ Text_spanner_engraver::finalize () } } +#include "translator.icc" + ADD_TRANSLATOR (Text_spanner_engraver, /* descr */ "Create text spanner from a Music.", /* creats*/ "TextSpanner", diff --git a/lily/tie-engraver.cc b/lily/tie-engraver.cc index 0705690f17..cf5364015c 100644 --- a/lily/tie-engraver.cc +++ b/lily/tie-engraver.cc @@ -53,12 +53,12 @@ class Tie_engraver : public Engraver Spanner *tie_column_; protected: - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); virtual void derived_mark () const; - virtual void start_translation_timestep (); + PRECOMPUTED_VIRTUAL void start_translation_timestep (); virtual void acknowledge_grob (Grob_info); virtual bool try_music (Music *); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void process_music (); void typeset_tie (Grob *); public: TRANSLATOR_DECLARATIONS (Tie_engraver); @@ -208,6 +208,8 @@ Tie_engraver::typeset_tie (Grob *her) index_set_cell (her->get_property ("head-pair"), RIGHT, new_head_drul[RIGHT]->self_scm ()); } +#include "translator.icc" + ADD_TRANSLATOR (Tie_engraver, /* descr */ "Generate ties between noteheads of equal pitch.", /* creats*/ "Tie TieColumn", diff --git a/lily/tie-performer.cc b/lily/tie-performer.cc index 7dc078bd95..f47e3ae597 100644 --- a/lily/tie-performer.cc +++ b/lily/tie-performer.cc @@ -24,11 +24,11 @@ class Tie_performer : public Performer bool ties_created_; protected: - virtual void stop_translation_timestep (); - virtual void start_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void start_translation_timestep (); virtual void acknowledge_audio_element (Audio_element_info); virtual bool try_music (Music *); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void process_music (); public: TRANSLATOR_DECLARATIONS (Tie_performer); }; @@ -108,6 +108,8 @@ Tie_performer::stop_translation_timestep () now_heads_.clear (); } +#include "translator.icc" + ADD_TRANSLATOR (Tie_performer, /* descr */ "Generate ties between noteheads of equal pitch.", /* creats*/ "", diff --git a/lily/time-signature-engraver.cc b/lily/time-signature-engraver.cc index 77fd444f12..c904595505 100644 --- a/lily/time-signature-engraver.cc +++ b/lily/time-signature-engraver.cc @@ -20,8 +20,8 @@ class Time_signature_engraver : public Engraver SCM last_time_fraction_; protected: - virtual void stop_translation_timestep (); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_music (); public: TRANSLATOR_DECLARATIONS (Time_signature_engraver); }; @@ -68,6 +68,8 @@ Time_signature_engraver::stop_translation_timestep () time_signature_ = 0; } +#include "translator.icc" + ADD_TRANSLATOR (Time_signature_engraver, /* descr */ "Create a TimeSignature whenever @code{timeSignatureFraction} changes", /* creats*/ "TimeSignature", diff --git a/lily/time-signature-performer.cc b/lily/time-signature-performer.cc index 072990db3f..45c74e208e 100644 --- a/lily/time-signature-performer.cc +++ b/lily/time-signature-performer.cc @@ -18,7 +18,7 @@ public: protected: - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); virtual void create_audio_elements (); virtual void derived_mark () const; SCM prev_fraction_; @@ -69,4 +69,6 @@ Time_signature_performer::stop_translation_timestep () } } +#include "translator.icc" + ADD_TRANSLATOR (Time_signature_performer, "", "", "", "", "", ""); diff --git a/lily/timing-engraver.cc b/lily/timing-engraver.cc index 1c30fcd34f..54c3543d71 100644 --- a/lily/timing-engraver.cc +++ b/lily/timing-engraver.cc @@ -1,81 +1,54 @@ /* - timing-engraver.cc -- implement Timing_engraver + timing-engraver.cc -- implement Default_bar_line_engraver source file of the GNU LilyPond music typesetter (c) 1997--2005 Han-Wen Nienhuys */ -#include "timing-translator.hh" #include "engraver.hh" - #include "context.hh" #include "multi-measure-rest.hh" #include "grob.hh" #include "warn.hh" -class Timing_engraver : public Timing_translator, public Engraver +class Default_bar_line_engraver : public Engraver { protected: /* Need to know whether we're advancing in grace notes, or not. */ Moment last_moment_; - virtual void start_translation_timestep (); - virtual void process_music (); - virtual void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void start_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); public: - TRANSLATOR_DECLARATIONS (Timing_engraver); + TRANSLATOR_DECLARATIONS (Default_bar_line_engraver); }; -ADD_TRANSLATOR (Timing_engraver, - /* descr */ " Responsible for synchronizing timing information from staves. " - "Normally in @code{Score}. In order to create polyrhythmic music, " - "this engraver should be removed from @code{Score} and placed in " - "@code{Staff}. " - "\n\nThis engraver adds the alias @code{Timing} to its containing context.", +#include "translator.icc" + +ADD_TRANSLATOR (Default_bar_line_engraver, + "This engraver determines what kind of automatic bar lines should be produced, " + "and sets @code{whichBar} accordingly. It should be at the same " + "level as @ref{Timing_translator}. ", /* creats*/ "", /* accepts */ "", /* acks */ "", - /* reads */ "automaticBars whichBar barAlways defaultBarType " - "skipBars timing measureLength measurePosition currentBarNumber", - /* write */ ""); + /* reads */ + "measurePosition automaticBars whichBar barAlways defaultBarType " + "measureLength", + /* write */ "automaticBars"); -Timing_engraver::Timing_engraver () +Default_bar_line_engraver::Default_bar_line_engraver () { last_moment_.main_part_ = Rational (-1); } void -Timing_engraver::process_music () +Default_bar_line_engraver::start_translation_timestep () { - Timing_translator::process_music (); - - bool start_of_measure = (last_moment_.main_part_ != now_mom ().main_part_ - && !measure_position ().main_part_); - - /* - We can't do this in start_translation_timestep(), since time sig - changes won't have happened by then. - */ - if (start_of_measure) - { - Moment mlen = Moment (measure_length ()); - Grob * column = unsmob_grob (get_property ("currentCommandColumn")); - if (column) - column->set_property ("measure-length", mlen.smobbed_copy ()); - else - programming_error("No command column?"); - } -} - -void -Timing_engraver::start_translation_timestep () -{ - Timing_translator::start_translation_timestep (); - SCM automatic_bars = get_property ("automaticBars"); Moment now = now_mom (); SCM which = get_property ("whichBar"); @@ -84,7 +57,7 @@ Timing_engraver::start_translation_timestep () if (!scm_is_string (which)) which = SCM_EOL; - Moment mp = measure_position (); + Moment mp = measure_position (context ()); bool start_of_measure = (last_moment_.main_part_ != now.main_part_ && !mp.main_part_); @@ -104,9 +77,8 @@ Timing_engraver::start_translation_timestep () } void -Timing_engraver::stop_translation_timestep () +Default_bar_line_engraver::stop_translation_timestep () { - Timing_translator::stop_translation_timestep (); context ()->set_property ("whichBar", SCM_EOL); last_moment_ = now_mom (); } diff --git a/lily/timing-translator.cc b/lily/timing-translator.cc index fc9ddc83a8..b105d17d60 100644 --- a/lily/timing-translator.cc +++ b/lily/timing-translator.cc @@ -28,7 +28,7 @@ Timing_translator::stop_translation_timestep () bool timb = to_boolean (tim); if (timb && allbars) { - Moment barleft = (measure_length () - measure_position ()); + Moment barleft = (measure_length () - measure_position (context ())); Moment now = now_mom (); if (barleft > Moment (0) @@ -76,21 +76,6 @@ Timing_translator::Timing_translator () { } -Moment -Timing_translator::measure_position () const -{ - SCM sm = get_property ("measurePosition"); - - Moment m = 0; - if (unsmob_moment (sm)) - { - m = *unsmob_moment (sm); - while (m.main_part_ < Rational (0)) - m.main_part_ += measure_length (); - } - - return m; -} void Timing_translator::start_translation_timestep () @@ -150,8 +135,17 @@ Timing_translator::start_translation_timestep () context ()->set_property ("measurePosition", measposp.smobbed_copy ()); } +#include "translator.icc" + ADD_TRANSLATOR (Timing_translator, "This engraver adds the alias " - "@code{Timing} to its containing context.", + "@code{Timing} to its containing context." + "Responsible for synchronizing timing information from staves. " + "Normally in @code{Score}. In order to create polyrhythmic music, " + "this engraver should be removed from @code{Score} and placed in " + "@code{Staff}. " + "\n\nThis engraver adds the alias @code{Timing} to its containing context." + + , "", "", "", "", ""); diff --git a/lily/translator-group-ctors.cc b/lily/translator-group-ctors.cc new file mode 100644 index 0000000000..ead329095b --- /dev/null +++ b/lily/translator-group-ctors.cc @@ -0,0 +1,36 @@ +/* + translator-group-ctors.cc -- implement Translator_group factory. + + source file of the GNU LilyPond music typesetter + + (c) 2005 Han-Wen Nienhuys + +*/ + + +#include "score-engraver.hh" +#include "score-performer.hh" +#include "engraver-group-engraver.hh" +#include "performer-group-performer.hh" +#include "recording-group-engraver.hh" + +/* + Quick & dirty. + */ +Translator_group * +get_translator_group (SCM sym) +{ + if (sym == ly_symbol2scm ("Engraver_group_engraver")) + return new Engraver_group_engraver (); + else if (sym == ly_symbol2scm ("Performer_group_performer")) + return new Performer_group_performer(); + else if (sym == ly_symbol2scm ("Score_engraver")) + return new Score_engraver(); + else if (sym == ly_symbol2scm ("Score_performer")) + return new Score_performer(); + else if (sym == ly_symbol2scm ("Recording_group_engraver")) + return new Recording_group_engraver(); + + assert (0); + return 0; +} diff --git a/lily/translator-group.cc b/lily/translator-group.cc index 1ec1f82163..c05c6226f9 100644 --- a/lily/translator-group.cc +++ b/lily/translator-group.cc @@ -16,6 +16,7 @@ #include "main.hh" #include "music.hh" + Translator_group * Translator_group::get_daddy_translator () const { @@ -32,10 +33,17 @@ translator_each (SCM list, Translator_method method) void Translator_group::initialize () { + precompute_method_bindings (); + SCM tab = scm_make_vector (scm_int2num (19), SCM_BOOL_F); context ()->set_property ("acceptHashTable", tab); } +void +Translator_group::finalize () +{ +} + bool translator_accepts_any_of (Translator *tr, SCM ifaces) { @@ -66,7 +74,7 @@ find_accept_translators (SCM gravlist, SCM ifaces) bool Translator_group::try_music (Music *m) { - SCM tab = get_property ("acceptHashTable"); + SCM tab = context ()->get_property ("acceptHashTable"); SCM name = scm_sloppy_assq (ly_symbol2scm ("name"), m->get_property_alist (false)); @@ -99,23 +107,47 @@ Translator_group::get_simple_trans_list () void -recurse_over_translators (Context *c, Translator_method ptr, Direction dir) +precomputed_recurse_over_translators (Context *c, Translator_precompute_index idx, Direction dir) { Translator_group *tg = dynamic_cast (c->implementation ()); if (dir == DOWN) { - translator_each (tg->get_simple_trans_list (), - ptr); + tg->precomputed_translator_foreach (idx); + tg->call_precomputed_self_method (idx); + } + + for (SCM s = c->children_contexts (); scm_is_pair (s); + s = scm_cdr (s)) + { + precomputed_recurse_over_translators (unsmob_context (scm_car (s)), idx, dir); + } + + if (dir == UP) + { + tg->precomputed_translator_foreach (idx); + tg->call_precomputed_self_method (idx); + } + +} - (tg->*ptr) (); +void +recurse_over_translators (Context *c, Translator_method ptr, Translator_group_method tg_ptr, Direction dir) +{ + Translator_group *tg + = dynamic_cast (c->implementation ()); + + if (dir == DOWN) + { + (tg->*tg_ptr) (); + translator_each (tg->get_simple_trans_list (), ptr); } for (SCM s = c->children_contexts (); scm_is_pair (s); s = scm_cdr (s)) { - recurse_over_translators (unsmob_context (scm_car (s)), ptr, dir); + recurse_over_translators (unsmob_context (scm_car (s)), ptr, tg_ptr, dir); } if (dir == UP) @@ -123,17 +155,100 @@ recurse_over_translators (Context *c, Translator_method ptr, Direction dir) translator_each (tg->get_simple_trans_list (), ptr); - (tg->*ptr) (); + (tg->*tg_ptr) (); } } Translator_group::Translator_group () { simple_trans_list_ = SCM_EOL; + context_ = 0; + smobify_self (); } void Translator_group::derived_mark () const { - scm_gc_mark (simple_trans_list_); } + + +void +Translator_group::precompute_method_bindings () +{ + for (SCM s = simple_trans_list_; scm_is_pair (s); s = scm_cdr (s)) + { + Translator *tr = unsmob_translator (scm_car (s)); + Translator_void_method_ptr ptrs[TRANSLATOR_METHOD_PRECOMPUTE_COUNT]; + tr->fetch_precomputable_methods (ptrs); + + assert (tr); + for (int i = 0; i < TRANSLATOR_METHOD_PRECOMPUTE_COUNT; i++) + { + if (ptrs[i]) + { + precomputed_method_bindings_[i].push (Translator_method_binding (tr, ptrs[i])); + } + } + } + + fetch_precomputable_methods (precomputed_self_method_bindings_); +} + +void +Translator_group::precomputed_translator_foreach (Translator_precompute_index idx) +{ + Array &bindings(precomputed_method_bindings_[idx]); + for (int i = 0; i < bindings.size (); i++) + { + bindings[i].invoke (); + } +} + +void +Translator_group::fetch_precomputable_methods (Translator_group_void_method ptrs[]) +{ + for (int i = 0; i < TRANSLATOR_METHOD_PRECOMPUTE_COUNT; i++) + ptrs[i] = 0; +} + +void +Translator_group::call_precomputed_self_method (Translator_precompute_index idx) +{ + if (precomputed_self_method_bindings_[idx]) + (*precomputed_self_method_bindings_[idx])(this); +} + + +Translator_group::~Translator_group () +{ +} + +#include "ly-smobs.icc" + +IMPLEMENT_SMOBS (Translator_group); +IMPLEMENT_DEFAULT_EQUAL_P (Translator_group); +IMPLEMENT_TYPE_P (Translator_group, "ly:translator-group?"); + + +int +Translator_group::print_smob (SCM s, SCM port, scm_print_state *) +{ + Translator_group *me = (Translator_group *) SCM_CELL_WORD_1 (s); + scm_puts ("#simple_trans_list_, port); + scm_puts (" >", port); + return 1; +} + + +SCM +Translator_group::mark_smob (SCM smob) +{ + Translator_group *me = (Translator_group*)SCM_CELL_WORD_1 (smob); + + me->derived_mark (); + + return me->simple_trans_list_; +} + diff --git a/lily/translator-scheme.cc b/lily/translator-scheme.cc index 6efd36b591..4266e5cf8e 100644 --- a/lily/translator-scheme.cc +++ b/lily/translator-scheme.cc @@ -30,13 +30,3 @@ LY_DEFINE (ly_translator_description, "ly:translator-description", return tr->translator_description (); } -int -Translator::print_smob (SCM s, SCM port, scm_print_state *) -{ - Translator *me = (Translator *) SCM_CELL_WORD_1 (s); - scm_puts ("#", port); - return 1; -} - diff --git a/lily/translator.cc b/lily/translator.cc index e1f3408a38..e67ffcda22 100644 --- a/lily/translator.cc +++ b/lily/translator.cc @@ -13,6 +13,7 @@ #include "context-def.hh" #include "global-context.hh" +#include "translator.icc" #include "ly-smobs.icc" Translator::~Translator () @@ -28,13 +29,14 @@ Translator::init () smobify_self (); } + void -Translator::do_announces () +Translator::process_music () { } void -Translator::process_music () +Translator::process_acknowledged () { } @@ -156,3 +158,21 @@ void Translator::derived_mark () const { } + +void +Translator::fetch_precomputable_methods (Translator_void_method_ptr ptrs[]) +{ + for (int i = 0; i < TRANSLATOR_METHOD_PRECOMPUTE_COUNT; i++) + ptrs[i] = 0; +} + +int +Translator::print_smob (SCM s, SCM port, scm_print_state *) +{ + Translator *me = (Translator *) SCM_CELL_WORD_1 (s); + scm_puts ("#", port); + return 1; +} + diff --git a/lily/trill-spanner-engraver.cc b/lily/trill-spanner-engraver.cc index 454227c297..b557218561 100644 --- a/lily/trill-spanner-engraver.cc +++ b/lily/trill-spanner-engraver.cc @@ -17,6 +17,8 @@ #include "side-position-interface.hh" #include "engraver.hh" +#include "translator.icc" + class Trill_spanner_engraver : public Engraver { public: @@ -25,8 +27,8 @@ protected: virtual void finalize (); virtual void acknowledge_grob (Grob_info); virtual bool try_music (Music *); - virtual void stop_translation_timestep (); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_music (); private: Spanner *span_; diff --git a/lily/tuplet-engraver.cc b/lily/tuplet-engraver.cc index 2b1df50fa2..7bec0b218e 100644 --- a/lily/tuplet-engraver.cc +++ b/lily/tuplet-engraver.cc @@ -12,6 +12,8 @@ #include "engraver.hh" #include "spanner.hh" +#include "translator.icc" + struct Tuplet_description { Music *music_; @@ -35,8 +37,8 @@ protected: virtual void acknowledge_grob (Grob_info); virtual bool try_music (Music *r); - virtual void start_translation_timestep (); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void start_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_music (); }; bool diff --git a/lily/type-swallow-translator.cc b/lily/type-swallow-translator.cc index 47c40fe0eb..2c29240727 100644 --- a/lily/type-swallow-translator.cc +++ b/lily/type-swallow-translator.cc @@ -9,7 +9,9 @@ #include "translator.hh" #include "music.hh" -class Skip_event_swallow_translator : public virtual Translator +#include "translator.icc" + +class Skip_event_swallow_translator : public Translator { protected: virtual bool try_music (Music *) { return true; } @@ -18,7 +20,7 @@ public: TRANSLATOR_DECLARATIONS (Skip_event_swallow_translator); }; -class Rest_swallow_translator : public virtual Translator +class Rest_swallow_translator : public Translator { protected: virtual bool try_music (Music *) { return true; } @@ -48,7 +50,7 @@ ADD_TRANSLATOR (Rest_swallow_translator, ""); -class Note_swallow_translator : public virtual Translator +class Note_swallow_translator : public Translator { protected: virtual bool try_music (Music *) { return true; } @@ -57,7 +59,9 @@ public: TRANSLATOR_DECLARATIONS (Note_swallow_translator); }; -Note_swallow_translator::Note_swallow_translator (){} +Note_swallow_translator::Note_swallow_translator () +{ +} ADD_TRANSLATOR (Note_swallow_translator, "Swallow notes", diff --git a/lily/vaticana-ligature-engraver.cc b/lily/vaticana-ligature-engraver.cc index e6b0f002b8..2804346e2e 100644 --- a/lily/vaticana-ligature-engraver.cc +++ b/lily/vaticana-ligature-engraver.cc @@ -16,6 +16,8 @@ #include "output-def.hh" #include "paper-column.hh" +#include "translator.icc" + /* * This class implements the notation specific aspects of Vaticana * style ligatures for Gregorian chant notation. diff --git a/lily/vertical-align-engraver.cc b/lily/vertical-align-engraver.cc index efcb08e794..8cf85f2572 100644 --- a/lily/vertical-align-engraver.cc +++ b/lily/vertical-align-engraver.cc @@ -16,6 +16,8 @@ #include "pointer-group-interface.hh" #include "grob-array.hh" +#include "translator.icc" + class Vertical_align_engraver : public Engraver { Spanner *valign_; @@ -28,7 +30,7 @@ public: protected: virtual void derived_mark () const; virtual void acknowledge_grob (Grob_info); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void process_music (); virtual void finalize (); virtual void initialize (); }; diff --git a/lily/vertically-spaced-context-engraver.cc b/lily/vertically-spaced-context-engraver.cc new file mode 100644 index 0000000000..f62fbe0ffe --- /dev/null +++ b/lily/vertically-spaced-context-engraver.cc @@ -0,0 +1,67 @@ +/* + vertically-spaced-contexts-engraver.cc -- implement Vertically_spaced_contexts_engraver + + source file of the GNU LilyPond music typesetter + + (c) 2005 Han-Wen Nienhuys + +*/ + +#include "engraver.hh" +#include "grob.hh" +#include "axis-group-interface.hh" +#include "context.hh" +#include "pointer-group-interface.hh" + +class Vertically_spaced_contexts_engraver : public Engraver +{ + TRANSLATOR_DECLARATIONS(Vertically_spaced_contexts_engraver); +protected: + virtual void acknowledge_grob (Grob_info); + virtual void initialize (); + +private: + Grob * system_; +}; + + + +Vertically_spaced_contexts_engraver::Vertically_spaced_contexts_engraver () +{ + system_ = 0; +} + +void +Vertically_spaced_contexts_engraver::initialize () +{ + system_ = unsmob_grob (get_property ("rootSystem")); +} + +void +Vertically_spaced_contexts_engraver::acknowledge_grob (Grob_info gi) +{ + if (Axis_group_interface::has_interface (gi.grob ()) + && gi.grob ()->internal_has_interface (ly_symbol2scm ("vertically-spaceable-interface"))) + { + SCM spaceable = get_property ("verticallySpacedContexts"); + Context *orig = gi.origin_contexts (this)[0]; + + if (scm_memq (ly_symbol2scm (orig->context_name ().to_str0 ()), + spaceable) != SCM_BOOL_F) + { + Pointer_group_interface::add_grob (system_, + ly_symbol2scm ("spaceable-staves"), + gi.grob ()); + } + } +} + +#include "translator.icc" + +ADD_TRANSLATOR (Vertically_spaced_contexts_engraver, + /* descr */ "", + /* creats*/ "", + /* accepts */ "", + /* acks */ "axis-group-interface", + /* reads */ "verticallySpacedContexts", + /* write */ "verticallySpacedContexts"); diff --git a/lily/volta-engraver.cc b/lily/volta-engraver.cc index 03e940650d..a344a8535d 100644 --- a/lily/volta-engraver.cc +++ b/lily/volta-engraver.cc @@ -15,6 +15,8 @@ #include "warn.hh" #include "staff-symbol.hh" +#include "translator.icc" + /* Create Volta spanners, by reading repeatCommands property, usually set by Unfolded_repeat_iterator. @@ -27,8 +29,8 @@ protected: virtual void acknowledge_grob (Grob_info); virtual void finalize (); - virtual void stop_translation_timestep (); - virtual void process_music (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); + PRECOMPUTED_VIRTUAL void process_music (); Moment started_mom_; Spanner *volta_span_; diff --git a/ly/engraver-init.ly b/ly/engraver-init.ly index ed3c6134fb..11ebe1013b 100644 --- a/ly/engraver-init.ly +++ b/ly/engraver-init.ly @@ -418,14 +418,17 @@ AncientRemoveEmptyStaffContext = \context { not contained in any other context). It is instantiated automatically when an output definition (a @code{\score} or @code{\layout} block) is processed." - + + + \consists "Paper_column_engraver" + \consists "Vertically_spaced_contexts_engraver" \consists "Repeat_acknowledge_engraver" \consists "Staff_collecting_engraver" %% move the alias along with the engraver. - \consists "Timing_engraver" - + \consists "Timing_translator" + \consists "Default_bar_line_engraver" \consists "Output_property_engraver" \consists "System_start_delimiter_engraver" \consists "Mark_engraver" diff --git a/ly/performer-init.ly b/ly/performer-init.ly index d667a12206..e38e1fae4e 100644 --- a/ly/performer-init.ly +++ b/ly/performer-init.ly @@ -4,10 +4,11 @@ % setup for Request->Element conversion. Guru-only % \context { - \type "Staff_performer" + \type "Performer_group_performer" \name Staff \accepts Voice - + + \consists "Staff_performer" \consists "Key_performer" \consists "Tempo_performer" \consists "Time_signature_performer" @@ -119,7 +120,8 @@ \context { - \type "Staff_performer" % Performer_group_performer ? + \type "Performer_group_performer" + \consists "Staff_performer" % Performer_group_performer ? \consists "Lyric_performer" \name Lyrics \consists "Time_signature_performer" diff --git a/scm/define-context-properties.scm b/scm/define-context-properties.scm index d15ed9b303..e63dd9675a 100644 --- a/scm/define-context-properties.scm +++ b/scm/define-context-properties.scm @@ -177,7 +177,7 @@ every bar line. (defaultBarType ,string? "Sets the default type of bar line. See @code{whichBar} for information on available bar types. -This variable is read by @internalsref{Timing_engraver} at +This variable is read by @internalsref{Timing_translator} at @internalsref{Score} level. ") @@ -300,13 +300,11 @@ sustain pedals: @code{text}, @code{bracket} or @code{mixed} (both).") (printKeyCancellation ,boolean? "Print restoration alterations before a key signature change. ") (printPartCombineTexts ,boolean? "set Solo/A due texts in the part combiner?") (printOctaveNames ,boolean? "Print octave marks for the NoteNames context.") - (recordEventSequence ,procedure? "When -@internalsref{Recording_group_engraver} is in this context, then upon -termination of the context, this function is called with current -context and a list of music objects. The list of contains entries -with start times, music objects and whether they are processed in this -context.") - + (recordEventSequence ,procedure? "When Recording_group_engraver +is in this context, then upon termination of the context, this +function is called with current context and a list of music objects. +The list of contains entries with start times, music objects and +whether they are processed in this context.") (rehearsalMark ,integer? "The last rehearsal mark printed.") (repeatCommands ,list? "This property is read to find any command of the form @code{(volta . @var{x})}, where @var{x} is a string or @code{#f}") diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 91dc17cc1e..48829773c9 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -23,7 +23,8 @@ (inside-slur . #t) (cautionary-style . parentheses) (after-line-breaking-callback . ,Accidental_interface::after_line_breaking) - (meta . ((interfaces . (item-interface accidental-interface + (meta . ((class . Item) + (interfaces . (accidental-interface font-interface)))) )) @@ -34,7 +35,8 @@ ;; this is quite small, but it is very ugly to have ;; accs closer to the previous note than to the next one. (right-padding . 0.15) - (meta . ((interfaces . (item-interface accidental-placement-interface)))) + (meta . ((class . Item) + (interfaces . (accidental-placement-interface)))) )) (Ambitus . ( @@ -51,19 +53,21 @@ (breakable . #t) (break-align-symbol . ambitus) (break-visibility . ,begin-of-line-visible) - (meta . ((interfaces . (axis-group-interface - break-aligned-interface ambitus-interface item-interface)))) + (meta . ((class . Item) + (interfaces . (axis-group-interface + break-aligned-interface ambitus-interface)))) )) (AmbitusLine . ( - (print-function . ,Ambitus::print) - (join-heads . #t) - (thickness . 2) - (X-offset-callbacks . (,Self_alignment_interface::centered_on_parent)) + (print-function . ,Ambitus::print) + (join-heads . #t) + (thickness . 2) + (X-offset-callbacks . (,Self_alignment_interface::centered_on_parent)) - (meta . ((interfaces . (ambitus-interface staff-symbol-referencer-interface item-interface font-interface)))) - )) + (meta . ((class . Item) + (interfaces . (ambitus-interface staff-symbol-referencer-interface font-interface)))) + )) (AmbitusAccidental . ( (print-function . ,Accidental_interface::print) @@ -73,7 +77,8 @@ (direction . -1) (cautionary-style . parentheses) (after-line-breaking-callback . ,Accidental_interface::after_line_breaking) - (meta . ((interfaces . (item-interface + (meta . ((class . Item) + (interfaces . (item-interface accidental-interface break-aligned-interface side-position-interface font-interface)))) )) @@ -84,12 +89,13 @@ (print-function . ,Note_head::print) (glyph-name-procedure . ,find-notehead-symbol) (Y-offset-callbacks . (,Staff_symbol_referencer::callback)) - (meta . ((interfaces . (font-interface note-head-interface + (meta . ((class . Item) + (interfaces . (font-interface note-head-interface ambitus-interface staff-symbol-referencer-interface rhythmic-head-interface ledgered-interface - item-interface )))) + )))) )) (Arpeggio @@ -101,9 +107,10 @@ (direction . -1) (padding . 0.5) (staff-position . 0.0) - (meta . ((interfaces . (arpeggio-interface + (meta . ((class . Item) + (interfaces . (arpeggio-interface staff-symbol-referencer-interface side-position-interface - item-interface font-interface)))) + font-interface)))) )) (BarLine @@ -137,8 +144,9 @@ (thin-kern . 3.0) (hair-thickness . 1.9) (thick-thickness . 6.0) - (meta . ((interfaces . (bar-line-interface - item-interface break-aligned-interface font-interface)))) + (meta . ((class . Item) + (interfaces . (bar-line-interface + break-aligned-interface font-interface)))) )) @@ -156,12 +164,13 @@ (self-alignment-X . 1) (meta . - ((interfaces . (side-position-interface + ((class . Item) + (interfaces . (side-position-interface text-interface self-alignment-interface - font-interface item-interface break-aligned-interface)))) + font-interface break-aligned-interface)))) - )) + )) (BassFigure . ( @@ -174,8 +183,9 @@ ;; layout16 become too small. (font-size . -4) (kern . 0.2) - (meta . ((interfaces . (text-interface - rhythmic-grob-interface bass-figure-interface item-interface + (meta . ((class . Item) + (interfaces . (text-interface + rhythmic-grob-interface bass-figure-interface self-alignment-interface font-interface)))) )) (Beam @@ -190,7 +200,7 @@ ,Beam::slope_damping ,Beam::shift_region_to_valid ,Beam::quanting - )) + )) ;; TODO: should be in SLT. (thickness . 0.48) ; in staff-space @@ -223,7 +233,8 @@ (font-family . roman) (space-function . ,Beam::space_function) - (meta . ((interfaces . (staff-symbol-referencer-interface beam-interface spanner-interface)))) + (meta . ((class . Spanner) + (interfaces . (staff-symbol-referencer-interface beam-interface)))) )) (BreakAlignment @@ -236,12 +247,12 @@ clef staff-bar key-cancellation key-signature time-signature custos) - ; unbroken + ; unbroken (instrument-name left-edge ambitus breathing-sign clef staff-bar key-cancellation key-signature staff time-signature custos) - ; begin of line + ; begin of line (instrument-name left-edge ambitus breathing-sign clef key-cancellation key-signature staff-bar time-signature custos) @@ -249,15 +260,17 @@ )) (axes . (0)) (X-extent-callback . ,Axis_group_interface::group_extent_callback) - (meta . ((interfaces . (break-alignment-interface item-interface axis-group-interface))))) - ) + (meta . ((class . Item) + (interfaces . (break-alignment-interface axis-group-interface))))) + ) (BreakAlignGroup . ( (axes . (0)) (X-offset-callbacks . (,Break_align_interface::alignment_callback)) (X-extent-callback . ,Axis_group_interface::group_extent_callback) - (meta . ((interfaces . (break-aligned-interface item-interface axis-group-interface item-interface )))) + (meta . ((class . Item) + (interfaces . (break-aligned-interface axis-group-interface )))) )) (BreathingSign @@ -277,7 +290,9 @@ (text . ,(make-musicglyph-markup "scripts.rcomma")) (Y-offset-callbacks . (,Breathing_sign::offset_callback)) (break-visibility . ,begin-of-line-invisible) - (meta . ((interfaces . (break-aligned-interface breathing-sign-interface text-interface font-interface item-interface )))) + (meta . ((class . Item) + (interfaces . (break-aligned-interface + breathing-sign-interface text-interface font-interface )))) )) (Clef @@ -298,16 +313,18 @@ (right-edge . (extra-space . 0.5)) )) (Y-offset-callbacks . (,Staff_symbol_referencer::callback)) - (meta . ((interfaces . (clef-interface + (meta . ((class . Item) + (interfaces . (clef-interface staff-symbol-referencer-interface font-interface - break-aligned-interface item-interface )))) + break-aligned-interface )))) )) (ClusterSpannerBeacon . ( (print-function . #f) (Y-extent-callback . ,Cluster_beacon::height) - (meta . ((interfaces . (cluster-beacon-interface item-interface)))) + (meta . ((class . Item) + (interfaces . (cluster-beacon-interface)))) )) (ClusterSpanner @@ -317,7 +334,8 @@ (minimum-length . 0.0) (padding . 0.25) (style . ramp) - (meta . ((interfaces . (cluster-interface spanner-interface)))) + (meta . ((class . Spanner) + (interfaces . (cluster-interface)))) )) @@ -328,7 +346,8 @@ (word-space . 0.0) (font-family . sans) (font-size . 1.5) - (meta . ((interfaces . (font-interface + (meta . ((class . Item) + (interfaces . (font-interface rhythmic-grob-interface text-interface chord-name-interface item-interface)))) )) @@ -346,9 +365,10 @@ ;; todo: add X self alignment? (baseline-skip . 2) (font-series . bold) - (meta . ((interfaces . (text-script-interface + (meta . ((class . Item) + (interfaces . (text-script-interface text-interface side-position-interface - font-interface item-interface )))) + font-interface )))) )) (Custos @@ -364,10 +384,11 @@ (first-note . (minimum-fixed-space . 0.0)) (right-edge . (extra-space . 0.1)) )) - (meta . ((interfaces + (meta . ((class . Item) + (interfaces . (custos-interface staff-symbol-referencer-interface font-interface - break-aligned-interface item-interface )))) + break-aligned-interface )))) )) (DotColumn @@ -376,15 +397,17 @@ (direction . ,RIGHT) (X-extent-callback . ,Axis_group_interface::group_extent_callback) (X-offset-callbacks . (,Dot_column::side_position)) - (meta . ((interfaces . (dot-column-interface axis-group-interface item-interface )))) + (meta . ((class . Item) + (interfaces . (dot-column-interface axis-group-interface )))) )) (Dots . ( (print-function . ,Dots::print) (dot-count . 1) - (meta . ((interfaces . (font-interface - staff-symbol-referencer-interface dots-interface item-interface )))) + (meta . ((class . Item) + (interfaces . (font-interface + staff-symbol-referencer-interface dots-interface )))) )) (DoublePercentRepeat @@ -397,9 +420,10 @@ (thickness . 0.48) (break-align-symbol . staff-bar) (break-visibility . ,begin-of-line-invisible) - (meta . ((interfaces . (font-interface + (meta . ((class . Item) + (interfaces . (font-interface break-aligned-interface - percent-repeat-interface item-interface )))) + percent-repeat-interface )))) )) (DynamicText @@ -414,27 +438,30 @@ (font-encoding . fetaDynamic) (font-shape . italic) (self-alignment-Y . 0) - (meta . ((interfaces . (font-interface text-interface self-alignment-interface - dynamic-interface script-interface item-interface)))) + (meta . ((class . Item) + (interfaces . (font-interface text-interface self-alignment-interface + dynamic-interface script-interface)))) )) + (DynamicTextSpanner . ((print-function . ,Dynamic_text_spanner::print) - -;; rather ugh with NCSB -; (font-series . bold) + + ;; rather ugh with NCSB + ; (font-series . bold) (font-shape . italic) (style . dashed-line) - ; need to blend with dynamic texts. + ; need to blend with dynamic texts. (font-size . 1) (bound-padding . 0.75) (dash-fraction . 0.2) (dash-period . 3.0) - (meta . ((interfaces . (font-interface + (meta . ((class . Spanner) + (interfaces . (font-interface text-interface dynamic-interface dynamic-text-spanner-interface - item-interface)))) - )) + spanner-interface)))) + )) (DynamicLineSpanner . ( @@ -446,14 +473,15 @@ (minimum-space . 1.2) (direction . -1) - (meta . ((interfaces . (dynamic-interface axis-group-interface - side-position-interface spanner-interface)))))) + (meta . ((class . Spanner) + (interfaces . (dynamic-interface axis-group-interface + side-position-interface)))))) (Fingering . ( (print-function . ,Text_interface::print) - ; sync with TextScript (?) + ; sync with TextScript (?) (padding . 0.5) (staff-padding . 0.5) (self-alignment-X . 0) @@ -461,7 +489,8 @@ (script-priority . 100) (font-encoding . fetaNumber) (font-size . -5) ; don't overlap when next to heads. - (meta . ((interfaces . (finger-interface + (meta . ((class . Item) + (interfaces . (finger-interface font-interface text-script-interface text-interface side-position-interface self-alignment-interface item-interface)))) @@ -476,14 +505,16 @@ (Y-extent-callback . #f) (after-line-breaking-callback . ,Line_spanner::after_line_breaking) (print-function . ,Line_spanner::print) - (meta . ((interfaces . (line-interface line-spanner-interface spanner-interface)))) + (meta . ((class . Spanner) + (interfaces . (line-interface line-spanner-interface)))) )) (GridPoint . ( (X-extent . (0 . 0)) (Y-extent . (0 . 0)) - (meta . ((interfaces . (grid-point-interface)))) + (meta . ((class . Item) + (interfaces . (grid-point-interface)))) )) (GridLine @@ -494,9 +525,10 @@ (X-offset-callbacks . (,Self_alignment_interface::aligned_on_self ,Self_alignment_interface::centered_on_parent)) (layer . 0) - (meta . ((interfaces . (self-alignment-interface grid-line-interface))) - ))) - + (meta . ((class . Spanner) + (interfaces . (self-alignment-interface grid-line-interface))) + ))) + (Hairpin . ( (print-function . ,Hairpin::print) @@ -508,7 +540,8 @@ (bound-padding . 1.0) (self-alignment-Y . 0) (Y-offset-callbacks . (,Self_alignment_interface::aligned_on_self)) - (meta . ((interfaces . (hairpin-interface + (meta . ((class . Spanner) + (interfaces . (hairpin-interface line-interface self-alignment-interface dynamic-interface spanner-interface)))) )) @@ -522,7 +555,8 @@ (staff-padding . 0.2) (direction . -1) (bracket-flare . (0.5 . 0.5)) - (meta . ((interfaces . (horizontal-bracket-interface + (meta . ((class . Spanner) + (interfaces . (horizontal-bracket-interface side-position-interface line-interface spanner-interface)))) @@ -544,9 +578,10 @@ (break-align-symbol . instrument-name) (break-visibility . ,begin-of-line-visible) (baseline-skip . 2) - (meta . ((interfaces . (font-interface + (meta . ((class . Item) + (interfaces . (font-interface self-alignment-interface side-position-interface text-interface - break-aligned-interface item-interface )))) + break-aligned-interface )))) )) (KeyCancellation @@ -564,8 +599,9 @@ (break-visibility . ,begin-of-line-invisible) (breakable . #t) - (meta . ((interfaces . (key-signature-interface font-interface - break-aligned-interface item-interface )))) + (meta . ((class . Item) + (interfaces . (key-signature-interface font-interface + break-aligned-interface )))) )) (KeySignature . ( @@ -581,8 +617,9 @@ (break-visibility . ,begin-of-line-visible) (breakable . #t) - (meta . ((interfaces . (key-signature-interface font-interface - break-aligned-interface item-interface )))) + (meta . ((class . Item) + (interfaces . (key-signature-interface font-interface + break-aligned-interface )))) )) (LedgerLineSpanner . ( @@ -594,7 +631,8 @@ (spacing-procedure . ,Ledger_line_spanner::set_spacing_rods) (print-function . ,Ledger_line_spanner::print) (layer . 0) - (meta . ((interfaces . (spanner-interface ledger-line-interface)))) + (meta . ((class . Spanner) + (interfaces . (ledger-line-interface)))) )) (LeftEdge @@ -616,7 +654,8 @@ (key-cancellation . (extra-space . 0.0)) )) - (meta . ((interfaces . (break-aligned-interface item-interface )))) + (meta . ((class . Item) + (interfaces . (break-aligned-interface )))) )) (LigatureBracket @@ -631,7 +670,8 @@ (before-line-breaking-callback . ,Tuplet_bracket::before_line_breaking) (after-line-breaking-callback . ,Tuplet_bracket::after_line_breaking) (print-function . ,Tuplet_bracket::print) - (meta . ((interfaces . (tuplet-bracket-interface line-interface spanner-interface)))) + (meta . ((class . Spanner) + (interfaces . (tuplet-bracket-interface line-interface)))) )) (LyricHyphen @@ -642,10 +682,11 @@ (length . 0.66) (minimum-length . 0.3) (padding . 0.07) -; (spacing-procedure . ,Hyphen_spanner::set_spacing_rods) + ; (spacing-procedure . ,Hyphen_spanner::set_spacing_rods) (print-function . ,Hyphen_spanner::print) (Y-extent . (0 . 0)) - (meta . ((interfaces . (lyric-interface lyric-hyphen-interface + (meta . ((class . Spanner) + (interfaces . (lyric-interface lyric-hyphen-interface spanner-interface)))) )) @@ -655,8 +696,9 @@ (thickness . 0.8) ; linethickness (minimum-length . 1.5) (Y-extent . (0 . 0)) - (meta . ((interfaces . (lyric-interface - lyric-extender-interface spanner-interface)))) + (meta . ((class . Spanner) + (interfaces . (lyric-interface + lyric-extender-interface)))) )) (LyricText @@ -666,10 +708,11 @@ (word-space . 0.6) (font-series . bold-narrow) (font-size . 1.0) - (meta . ((interfaces . (rhythmic-grob-interface + (meta . ((class . Item) + (interfaces . (rhythmic-grob-interface lyric-syllable-interface self-alignment-interface text-interface - font-interface item-interface )))) + font-interface )))) )) (MensuralLigature @@ -678,18 +721,20 @@ (flexa-width . 2.0) (ligature-primitive-callback . ,Mensural_ligature::brew_ligature_primitive) (print-function . ,Mensural_ligature::print) - (meta . ((interfaces . (mensural-ligature-interface font-interface)))) + (meta . ((class . Spanner) + (interfaces . (mensural-ligature-interface font-interface)))) )) - (MetronomeMark + (MetronomeMark . ( (print-function . ,Text_interface::print) (Y-offset-callbacks . (,Side_position_interface::aligned_side)) (direction . 1) (padding . 0.8) - (meta . ((interfaces . (text-interface + (meta . ((class . Item) + (interfaces . (text-interface side-position-interface font-interface - metronome-mark-interface item-interface)))) + metronome-mark-interface)))) )) (MeasureGrouping . ( @@ -700,7 +745,8 @@ (thickness . 1) (height . 2.0) (staff-padding . 3) - (meta . ((interfaces . (spanner-interface side-position-interface + (meta . ((class . Spanner) + (interfaces . (side-position-interface measure-grouping-interface)))) )) (MultiMeasureRest @@ -713,7 +759,8 @@ (thick-thickness . 6.6) (hair-thickness . 2.0) (padding . 1) - (meta . ((interfaces . (multi-measure-rest-interface + (meta . ((class . Spanner) + (interfaces . (multi-measure-rest-interface multi-measure-interface rest-interface font-interface staff-symbol-referencer-interface)))) )) @@ -729,9 +776,10 @@ (padding . 0.4) (staff-padding . 0.4) (font-encoding . fetaNumber) - (meta . ((interfaces . (side-position-interface + (meta . ((class . Spanner) + (interfaces . (side-position-interface multi-measure-interface self-alignment-interface - font-interface spanner-interface text-interface)))) + font-interface text-interface)))) )) (MultiMeasureRestText . ( @@ -743,9 +791,10 @@ (direction . 1) (padding . 0.2) (staff-padding . 0.25) - (meta . ((interfaces . (side-position-interface + (meta . ((class . Spanner) + (interfaces . (side-position-interface multi-measure-interface self-alignment-interface font-interface - spanner-interface text-interface)))) + text-interface)))) )) (NoteCollision @@ -753,7 +802,8 @@ (axes . (0 1)) (X-extent-callback . ,Axis_group_interface::group_extent_callback) (Y-extent-callback . ,Axis_group_interface::group_extent_callback) - (meta . ((interfaces . (note-collision-interface axis-group-interface item-interface )))) + (meta . ((class . Item) + (interfaces . (note-collision-interface axis-group-interface )))) )) (NoteColumn @@ -761,7 +811,8 @@ (axes . (0 1)) (X-extent-callback . ,Axis_group_interface::group_extent_callback) (Y-extent-callback . ,Axis_group_interface::group_extent_callback) - (meta . ((interfaces . (axis-group-interface note-column-interface item-interface )))) + (meta . ((class . Item) + (interfaces . (axis-group-interface note-column-interface )))) )) (NoteHead @@ -771,10 +822,11 @@ (glyph-name-procedure . ,find-notehead-symbol) (Y-offset-callbacks . (,Staff_symbol_referencer::callback)) (stem-attachment-function . ,note-head-style->attachment-coordinates) - (meta . ((interfaces . (rhythmic-grob-interface + (meta . ((class . Item) + (interfaces . (rhythmic-grob-interface rhythmic-head-interface font-interface note-head-interface ledgered-interface - staff-symbol-referencer-interface item-interface )))) + staff-symbol-referencer-interface )))) )) (NoteSpacing @@ -785,15 +837,17 @@ ;; If you ever change this back, please document! --hwn (knee-spacing-correction . 1.0) - (meta . ((interfaces . (spacing-interface note-spacing-interface item-interface )))) + (meta . ((class . Item) + (interfaces . (spacing-interface note-spacing-interface )))) )) (NoteName . ( (print-function . ,Text_interface::print) - (meta . ((interfaces . (note-name-interface - text-interface font-interface item-interface )))) + (meta . ((class . Item) + (interfaces . (note-name-interface + text-interface font-interface )))) )) (OctavateEight @@ -810,7 +864,8 @@ (padding . 0.6) (staff-padding . 0.2) (font-size . -4) - (meta . ((interfaces . (text-interface self-alignment-interface side-position-interface font-interface item-interface )))) + (meta . ((class . Item) + (interfaces . (text-interface self-alignment-interface side-position-interface font-interface )))) )) (OttavaBracket @@ -825,9 +880,10 @@ (dash-fraction . 0.3) (edge-height . (0 . 1.2)) (direction . 1) - (meta . ((interfaces . (ottava-bracket-interface + (meta . ((class . Spanner) + (interfaces . (ottava-bracket-interface line-interface side-position-interface - font-interface text-interface spanner-interface)))) + font-interface text-interface)))) )) (PaperColumn @@ -837,8 +893,9 @@ (X-extent-callback . ,Axis_group_interface::group_extent_callback) ;; debugging -;; (print-function . ,Paper_column::print) (font-size . -6) (font-name . "sans") (Y-extent-callback . #f) - (meta . ((interfaces . (paper-column-interface axis-group-interface spaceable-grob-interface item-interface )))) + ;; (print-function . ,Paper_column::print) (font-size . -6) (font-name . "sans") (Y-extent-callback . #f) + (meta . ((class . Paper_column) + (interfaces . (paper-column-interface axis-group-interface spaceable-grob-interface )))) )) (PhrasingSlur @@ -851,7 +908,8 @@ (Y-extent-callback . ,Slur::height) (height-limit . 2.0) (ratio . 0.333) - (meta . ((interfaces . (slur-interface spanner-interface)))) + (meta . ((class . Spanner) + (interfaces . (slur-interface)))) )) (NonMusicalPaperColumn @@ -862,10 +920,11 @@ (breakable . #t) ;; debugging stuff: print column number. -;; (print-function . ,Paper_column::print) (font-size . -6) (font-name . "sans") (Y-extent-callback . #f) + ;; (print-function . ,Paper_column::print) (font-size . -6) (font-name . "sans") (Y-extent-callback . #f) - (meta . ((interfaces . (paper-column-interface axis-group-interface spaceable-grob-interface item-interface )))) + (meta . ((class . Paper_column) + (interfaces . (paper-column-interface axis-group-interface spaceable-grob-interface )))) )) (PercentRepeat @@ -875,7 +934,9 @@ (slope . 1.0) (thickness . 0.48) (font-encoding . fetaMusic) - (meta . ((interfaces . (multi-measure-rest-interface spanner-interface font-interface percent-repeat-interface)))) + (meta . ((class . Spanner) + (interfaces . (multi-measure-rest-interface + font-interface percent-repeat-interface)))) )) ;; an example of a text spanner @@ -889,8 +950,9 @@ (edge-height . (1.0 . 1.0)) (shorten-pair . (0.0 . 0.0)) (thickness . 1.0) - (meta . ((interfaces . (line-interface - piano-pedal-interface piano-pedal-bracket-interface spanner-interface)))) + (meta . ((class . Spanner) + (interfaces . (line-interface + piano-pedal-interface piano-pedal-bracket-interface)))) )) (RehearsalMark @@ -906,9 +968,10 @@ (baseline-skip . 2) (break-visibility . ,end-of-line-invisible) (padding . 0.8) - (meta . ((interfaces . (text-interface + (meta . ((class . Item) + (interfaces . (text-interface side-position-interface font-interface mark-interface - self-alignment-interface item-interface )))) + self-alignment-interface )))) )) @@ -917,9 +980,10 @@ (Y-offset-callbacks . (,Hara_kiri_group_spanner::force_hara_kiri_callback)) (Y-extent-callback . ,Hara_kiri_group_spanner::y_extent) (axes . (1)) - (meta . ((interfaces . (axis-group-interface + (meta . ((class . Spanner) + (interfaces . (axis-group-interface vertically-spaceable-interface hara-kiri-group-interface - item-interface spanner-interface)))) + spanner-interface)))) )) (RepeatSlash @@ -927,7 +991,8 @@ (print-function . ,Percent_repeat_item_interface::beat_slash) (thickness . 0.48) (slope . 1.7) - (meta . ((interfaces . (percent-repeat-interface item-interface )))) + (meta . ((class . Item) + (interfaces . (percent-repeat-interface )))) )) (Rest . ( @@ -939,17 +1004,19 @@ ,Rest::polyphonic_offset_callback )) (minimum-distance . 0.25) - (meta . ((interfaces . (font-interface + (meta . ((class . Item) + (interfaces . (font-interface rhythmic-head-interface rhythmic-grob-interface staff-symbol-referencer-interface - rest-interface item-interface )) - )))) + rest-interface )) + )))) (RestCollision . ( (minimum-distance . 0.75) - (meta . ((interfaces . (rest-collision-interface item-interface )))) + (meta . ((class . Item) + (interfaces . (rest-collision-interface )))) )) (Script @@ -965,14 +1032,16 @@ (X-offset-callbacks . (,Self_alignment_interface::centered_on_parent)) (before-line-breaking-callback . ,Script_interface::before_line_breaking) (font-encoding . fetaMusic) - (meta . ((interfaces . (script-interface - side-position-interface font-interface item-interface )))) + (meta . ((class . Item) + (interfaces . (script-interface + side-position-interface font-interface )))) )) (ScriptColumn . ( (before-line-breaking-callback . ,Script_column::before_line_breaking) - (meta . ((interfaces . (script-column-interface item-interface )))) + (meta . ((class . Item) + (interfaces . (script-column-interface )))) )) @@ -980,13 +1049,15 @@ . ( (X-extent-callback . #f) (Y-extent-callback . #f) - (meta . ((interfaces . (spacing-interface separation-item-interface item-interface )))) + (meta . ((class . Item) + (interfaces . (spacing-interface separation-item-interface )))) )) (SeparatingGroupSpanner . ( (spacing-procedure . ,Separating_group_spanner::set_spacing_rods) - (meta . ((interfaces . (only-prebreak-interface spacing-interface separation-spanner-interface spanner-interface)))) + (meta . ((class . Spanner) + (interfaces . (only-prebreak-interface spacing-interface separation-spanner-interface)))) )) (Slur @@ -1000,7 +1071,8 @@ ; Slur::height) (height-limit . 2.0) (ratio . 0.25) - (meta . ((interfaces . (slur-interface spanner-interface)))) + (meta . ((class . Spanner) + (interfaces . (slur-interface)))) )) (SpacingSpanner @@ -1010,7 +1082,8 @@ (shortest-duration-space . 2.0) (spacing-increment . 1.2) (base-shortest-duration . ,(ly:make-moment 3 16)) - (meta . ((interfaces . (spacing-interface spacing-spanner-interface spanner-interface)))) + (meta . ((class . Spanner) + (interfaces . (spacing-interface spacing-spanner-interface)))) )) (SpanBar @@ -1032,8 +1105,9 @@ (thin-kern . 3.0) (hair-thickness . 1.6) (thick-thickness . 6.0) - (meta . ((interfaces . (span-bar-interface font-interface - bar-line-interface item-interface )))) + (meta . ((class . Item) + (interfaces . (span-bar-interface font-interface + bar-line-interface )))) )) (StanzaNumber @@ -1042,8 +1116,9 @@ (padding . 1.0) (X-offset-callbacks . (,Side_position_interface::aligned_side)) (direction . ,LEFT) - (meta . ((interfaces . (side-position-interface - stanza-number-interface text-interface font-interface item-interface )))) + (meta . ((class . Item) + (interfaces . (side-position-interface + stanza-number-interface text-interface font-interface )))) )) (StringNumber @@ -1056,7 +1131,8 @@ (script-priority . 100) (font-encoding . fetaNumber) (font-size . -5) ; don't overlap when next to heads. - (meta . ((interfaces . (string-number-interface + (meta . ((class . Item) + (interfaces . (string-number-interface font-interface text-script-interface text-interface side-position-interface self-alignment-interface item-interface)))) @@ -1067,7 +1143,8 @@ (breakable . #t) (stem-spacing-correction . 0.4) - (meta . ((interfaces . (spacing-interface staff-spacing-interface item-interface )))) + (meta . ((class . Item) + (interfaces . (spacing-interface staff-spacing-interface )))) )) (SostenutoPedal @@ -1079,8 +1156,9 @@ (padding . 0.0) ;; padding relative to SostenutoPedalLineSpanner (font-shape . italic) (self-alignment-X . 0) - (meta . ((interfaces . (text-interface - self-alignment-interface font-interface item-interface)))) + (meta . ((class . Item) + (interfaces . (text-interface + self-alignment-interface font-interface)))) )) (SostenutoPedalLineSpanner @@ -1093,8 +1171,9 @@ (padding . 1.2) (minimum-space . 1.0) (direction . -1) - (meta . ((interfaces . (piano-pedal-interface - axis-group-interface side-position-interface spanner-interface)))) + (meta . ((class . Spanner) + (interfaces . (piano-pedal-interface + axis-group-interface side-position-interface)))) )) (StaffSymbol @@ -1103,9 +1182,10 @@ (line-count . 5) (ledger-line-thickness . (1.0 . 0.1)) (layer . 0) - (meta . ((interfaces . (staff-symbol-interface spanner-interface)))) + (meta . ((class . Spanner) + (interfaces . (staff-symbol-interface)))) )) - + (Stem . ( ;; this list is rather long. Trim --hwn @@ -1141,7 +1221,7 @@ ;; The 'normal' minima (beamed-minimum-free-lengths . (1.83 1.5 1.25)) - ;(beamed-minimum-free-lengths . (2.0 1.83 1.25)) + ;(beamed-minimum-free-lengths . (2.0 1.83 1.25)) ;; The 'extreme case' minima (beamed-extreme-minimum-free-lengths . (2.0 1.25)) @@ -1150,7 +1230,8 @@ (X-extent-callback . ,Stem::width_callback) (Y-extent-callback . ,Stem::height) (Y-offset-callbacks . (,Staff_symbol_referencer::callback)) - (meta . ((interfaces . (stem-interface font-interface item-interface )))) + (meta . ((class . Item) + (interfaces . (stem-interface font-interface )))) )) (StemTremolo @@ -1161,7 +1242,8 @@ (beam-width . 1.6) ; staff-space (beam-thickness . 0.48) ; staff-space - (meta . ((interfaces . (stem-tremolo-interface item-interface )))) + (meta . ((class . Item) + (interfaces . (stem-tremolo-interface )))) )) (SustainPedal @@ -1172,9 +1254,10 @@ (direction . 1) (padding . 0.0) ;; padding relative to SustainPedalLineSpanner (X-offset-callbacks . (,Self_alignment_interface::aligned_on_self)) - (meta . ((interfaces . (piano-pedal-interface + (meta . ((class . Item) + (interfaces . (piano-pedal-interface text-spanner-interface text-interface self-alignment-interface - font-interface item-interface)))) + font-interface)))) )) (SustainPedalLineSpanner @@ -1187,8 +1270,9 @@ (staff-padding . 1.2) (minimum-space . 1.0) (direction . -1) - (meta . ((interfaces . (piano-pedal-interface - axis-group-interface side-position-interface spanner-interface)))) + (meta . ((class . Spanner) + (interfaces . (piano-pedal-interface + axis-group-interface side-position-interface)))) )) (System @@ -1196,7 +1280,8 @@ (axes . (0 1)) (X-extent-callback . ,Axis_group_interface::group_extent_callback) (Y-extent-callback . ,Axis_group_interface::group_extent_callback) - (meta . ((interfaces . (system-interface axis-group-interface spanner-interface)))) + (meta . ((class . System) + (interfaces . (system-interface axis-group-interface)))) )) (SystemStartBrace @@ -1206,7 +1291,8 @@ (collapse-height . 5.0) (font-encoding . fetaBraces) (Y-extent-callback . #f) - (meta . ((interfaces . (system-start-delimiter-interface font-interface)))) + (meta . ((class . Spanner) + (interfaces . (system-start-delimiter-interface font-interface)))) )) (SystemStartBracket @@ -1217,8 +1303,9 @@ (glyph . "bracket") (collapse-height . 1) (thickness . 0.45) - (meta . ((interfaces . (font-interface system-start-delimiter-interface - spanner-interface)))) + (meta . ((class . Spanner) + (interfaces . (font-interface system-start-delimiter-interface + )))) )) (SystemStartBar @@ -1228,7 +1315,8 @@ (glyph . "bar-line") (thickness . 1.6) (after-line-breaking-callback . ,System_start_delimiter::after_line_breaking) - (meta . ((interfaces . (system-start-delimiter-interface spanner-interface)))) + (meta . ((class . Spanner) + (interfaces . (system-start-delimiter-interface)))) )) @@ -1239,11 +1327,12 @@ (font-size . -2) (stem-attachment-function . ,tablature-stem-attachment-function) (font-series . bold) - (meta . ((interfaces + (meta . ((class . Item) + (interfaces . (rhythmic-head-interface font-interface note-head-interface staff-symbol-referencer-interface - text-interface item-interface )))) + text-interface )))) )) @@ -1254,14 +1343,15 @@ (X-offset-callbacks . (,Self_alignment_interface::aligned_on_self)) (direction . -1) - ; sync with Fingering ? + ; sync with Fingering ? (padding . 0.5) (staff-padding . 0.5) (script-priority . 200) ;; todo: add X self alignment? - (meta . ((interfaces . (text-script-interface + (meta . ((class . Item) + (interfaces . (text-script-interface text-interface side-position-interface font-interface - item-interface )))) + )))) )) (TextSpanner @@ -1273,7 +1363,9 @@ (dash-fraction . 0.2) (dash-period . 3.0) (direction . 1) - (meta . ((interfaces . (text-spanner-interface side-position-interface font-interface spanner-interface)))) + (meta . ((class . Spanner) + (interfaces . (text-spanner-interface + side-position-interface font-interface)))) )) @@ -1287,7 +1379,8 @@ (x-gap . -0.1) (y-offset . 0.6) (minimum-length . 2.5) - (meta . ((interfaces . (tie-interface spanner-interface)))) + (meta . ((class . Spanner) + (interfaces . (tie-interface)))) )) (TieColumn @@ -1296,7 +1389,8 @@ (before-line-breaking-callback . ,Tie_column::before_line_breaking) (X-extent-callback . #f) (Y-extent-callback . #f) - (meta . ((interfaces . (tie-column-interface spanner-interface)))) + (meta . ((class . Spanner) + (interfaces . (tie-column-interface)))) )) (TimeSignature @@ -1311,7 +1405,8 @@ )) (breakable . #t) (style . C) - (meta . ((interfaces . (time-signature-interface break-aligned-interface font-interface item-interface )))) + (meta . ((class . Item) + (interfaces . (time-signature-interface break-aligned-interface font-interface )))) )) @@ -1325,7 +1420,8 @@ (padding . 0.5) (direction . 1) (Y-offset-callbacks . (,Side_position_interface::aligned_side)) - (meta . ((interfaces . (text-spanner-interface side-position-interface font-interface spanner-interface)))) + (meta . ((class . Spanner) + (interfaces . (text-spanner-interface side-position-interface font-interface)))) )) (TrillPitchAccidental @@ -1334,7 +1430,8 @@ (direction . ,LEFT) (font-size . -4) (print-function . ,Accidental_interface::print) - (meta . ((interfaces . (item-interface + (meta . ((class . Item) + (interfaces . (item-interface accidental-interface side-position-interface font-interface)))) )) @@ -1346,10 +1443,11 @@ (print-function . ,parenthesize-elements) (direction . ,RIGHT) (padding . 0.3) - (meta . ((interfaces . (side-position-interface + (meta . ((class . Item) + (interfaces . (side-position-interface note-head-interface rhythmic-head-interface font-interface accidental-interface - item-interface axis-group-interface)))) + axis-group-interface)))) )) (TrillPitchHead @@ -1357,7 +1455,8 @@ (duration-log . 2) (Y-offset-callbacks . (,Staff_symbol_referencer::callback)) (font-size . -4) - (meta . ((interfaces . (item-interface + (meta . ((class . Item) + (interfaces . (item-interface rhythmic-head-interface font-interface pitched-trill-interface ledgered-interface staff-symbol-referencer-interface)))) @@ -1375,9 +1474,10 @@ (font-shape . italic) (font-size . -2) - (meta . ((interfaces . (text-interface line-interface + (meta . ((class . Spanner) + (interfaces . (text-interface line-interface tuplet-bracket-interface - font-interface spanner-interface)))) + font-interface)))) )) (UnaCordaPedal @@ -1389,7 +1489,8 @@ (direction . 1) (padding . 0.0) ;; padding relative to UnaCordaPedalLineSpanner (X-offset-callbacks . (,Self_alignment_interface::aligned_on_self)) - (meta . ((interfaces . (text-interface self-alignment-interface font-interface item-interface )))) + (meta . ((class . Item) + (interfaces . (text-interface self-alignment-interface font-interface )))) )) (UnaCordaPedalLineSpanner @@ -1401,7 +1502,8 @@ (staff-padding . 1.2) (minimum-space . 1.0) (direction . -1) - (meta . ((interfaces . (piano-pedal-interface axis-group-interface side-position-interface spanner-interface)))) + (meta . ((class . Spanner) + (interfaces . (piano-pedal-interface axis-group-interface side-position-interface)))) )) (VaticanaLigature @@ -1410,7 +1512,8 @@ (flexa-width . 2.0) (ligature-primitive-callback . ,Vaticana_ligature::brew_ligature_primitive) (print-function . ,Vaticana_ligature::print) - (meta . ((interfaces . (vaticana-ligature-interface font-interface)))) + (meta . ((class . Spanner) + (interfaces . (vaticana-ligature-interface font-interface)))) )) @@ -1420,7 +1523,8 @@ (Y-extent-callback . ,Axis_group_interface::group_extent_callback) (X-extent-callback . ,Axis_group_interface::group_extent_callback) (stacking-dir . -1) - (meta . ((interfaces . (align-interface axis-group-interface spanner-interface)))) + (meta . ((class . Spanner) + (interfaces . (align-interface axis-group-interface)))) )) (VerticalAxisGroup @@ -1429,8 +1533,9 @@ (Y-extent-callback . ,Axis_group_interface::group_extent_callback) (X-extent-callback . ,Axis_group_interface::group_extent_callback) - (meta . ((interfaces . (axis-group-interface - vertically-spaceable-interface spanner-interface)))) + (meta . ((class . Spanner) + (interfaces . (axis-group-interface + vertically-spaceable-interface)))) )) (VocalName @@ -1445,10 +1550,11 @@ (break-align-symbol . clef) (break-visibility . ,begin-of-line-visible) (baseline-skip . 2) - (meta . ((interfaces . (font-interface + (meta . ((class . Item) + (interfaces . (font-interface self-alignment-interface side-position-interface text-interface - break-aligned-interface item-interface )))) + break-aligned-interface)))) )) (VoltaBracket @@ -1462,9 +1568,10 @@ (height . 2.0) ;; staffspace; (minimum-space . 5) (font-size . -4) - (meta . ((interfaces . (volta-bracket-interface + (meta . ((class . Spanner) + (interfaces . (volta-bracket-interface line-interface text-interface - side-position-interface font-interface spanner-interface)))) + side-position-interface font-interface)))) )) @@ -1477,24 +1584,45 @@ (Y-extent-callback . #f) (print-function . ,Line_spanner::print) (after-line-breaking-callback . ,Line_spanner::after_line_breaking) - (meta . ((interfaces . (line-spanner-interface line-interface spanner-interface)))) + (meta . ((class . Spanner) + (interfaces . (line-spanner-interface line-interface)))) )) - )) + )) (define (completize-grob-entry x) - "transplant assoc key into 'name entry of 'meta of X + "transplant assoc key into 'name entry of 'meta of X. Set interfaces for Item, Spanner etc. " +;; (display (car x)) +;; (newline) (let* ((name-sym (car x)) (grob-entry (cdr x)) - (metaentry (cdr (assoc 'meta grob-entry))) + (meta-entry (cdr (assoc 'meta grob-entry))) + (class (cdr (assoc 'class meta-entry))) (ifaces-entry - (cdr (assoc 'interfaces metaentry))) - - ) - (set! metaentry (assoc-set! metaentry 'name name-sym)) - (set! metaentry (assoc-set! metaentry 'interfaces - (cons 'grob-interface ifaces-entry))) - (set! grob-entry (assoc-set! grob-entry 'meta metaentry)) + (cdr (assoc 'interfaces meta-entry))) + ) + + (cond + ((eq? 'Item class) + (set! ifaces-entry (cons 'item-interface ifaces-entry))) + ((eq? 'Spanner class) + (set! ifaces-entry (cons 'spanner-interface ifaces-entry))) + ((eq? 'Paper_column class) + (set! ifaces-entry (cons 'item-interface + (cons 'paper-column-interface ifaces-entry)))) + ((eq? 'System class) + (set! ifaces-entry (cons 'system-interface + (cons 'spanner-interface ifaces-entry)))) + (else + (ly:warning "Unknown class ~a" class))) + + + (set! ifaces-entry (cons 'grob-interface ifaces-entry)) + + (set! meta-entry (assoc-set! meta-entry 'name name-sym)) + (set! meta-entry (assoc-set! meta-entry 'interfaces + ifaces-entry)) + (set! grob-entry (assoc-set! grob-entry 'meta meta-entry)) (cons name-sym grob-entry))) (set! all-grob-descriptions (map completize-grob-entry all-grob-descriptions)) @@ -1512,3 +1640,5 @@ all-grob-descriptions) (set! all-grob-descriptions (sort all-grob-descriptions aliststring name)) "}") (engraver-doc-string eg #f)))) @@ -149,12 +150,7 @@ (cdr desc-handle) "(not documented)")) (accepts (cdr (assoc 'accepts context-desc))) - (group (assq-ref context-desc 'group-type)) - - (consists (append - (if group (list group) - '()) - (cdr (assoc 'consists context-desc)))) + (consists (cdr (assoc 'consists context-desc))) (props (cdr (assoc 'property-ops context-desc))) (grobs (context-grobs context-desc)) (grob-refs (map (lambda (x) (ref-ify x)) grobs))) diff --git a/scm/framework-scm.scm b/scm/framework-scm.scm index d1ee804cd8..058217e0b3 100644 --- a/scm/framework-scm.scm +++ b/scm/framework-scm.scm @@ -22,7 +22,9 @@ (lambda (page) (display ";;;;;;;;;;;;;;;;;;;;;;;;;;\n;;;PAGE\n" file) - (pretty-print (ly:stencil-expr page) file)) +; (pretty-print (ly:stencil-expr page) file) + (write (ly:stencil-expr page) file) + ) (ly:paper-book-pages book)))) (define-public output-classic-framework output-framework) -- 2.39.2