From e37010af17faa8b185de836664b6544bd29dc1d0 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Mon, 16 Feb 2004 02:29:01 +0000 Subject: [PATCH] * lily/include/grob-info.hh: origin_contexts() now does not include the originating engraver * lily/translator-group.cc (translator_each): clean up contents, remove superfluous stubs. Engraver_group_engraver and Performer_group_performer are the only classes using multiple inheritance. * lily/include/score-context.hh (class Score_context): interface between Score_{engraver,performer} and Global_context. * lily/include/global-context.hh (Context): change from global-translator. This is the entry point for contexts; it is not tweakable using \translator{}. Score is no longer the top context, but sits underneath Global. * lily/include/context.hh (class Context): brain surgery: split out Context functionality from Translator_group. Context is now a separate type from Translator. --- ChangeLog | 42 +- Documentation/user/cheatsheet.itely | 10 +- Documentation/user/lilypond-book.itely | 14 +- Documentation/user/refman.itely | 21 +- VERSION | 2 +- input/regression/lyric-hyphen.ly | 4 +- input/regression/mmrest-collision.ly | 29 - input/regression/tuplet-rest.ly | 6 +- input/screech-boink.ly | 14 +- lily/accidental-engraver.cc | 43 +- lily/accidental-placement.cc | 2 +- lily/align-interface.cc | 7 +- lily/ambitus.cc | 2 +- lily/apply-context-iterator.cc | 2 +- lily/audio-element-info.cc | 13 +- lily/auto-beam-engraver.cc | 3 +- lily/auto-change-iterator.cc | 17 +- lily/axis-group-engraver.cc | 3 +- lily/axis-group-interface.cc | 10 +- lily/bar-check-iterator.cc | 4 +- lily/bar-engraver.cc | 2 +- lily/bar-number-engraver.cc | 2 +- lily/beam-engraver.cc | 11 +- lily/beam-performer.cc | 4 +- lily/beam.cc | 26 +- lily/break-align-interface.cc | 10 +- lily/change-iterator.cc | 18 +- lily/chord-name-engraver.cc | 4 +- lily/chord-name.cc | 2 +- lily/chord-tremolo-iterator.cc | 2 +- lily/clef-engraver.cc | 8 +- lily/cluster.cc | 18 +- lily/completion-note-heads-engraver.cc | 4 +- lily/context-def.cc | 35 +- lily/context-specced-music-iterator.cc | 6 +- lily/context.cc | 321 ++++++++-- lily/custos.cc | 2 +- lily/dot-column.cc | 6 +- lily/dots.cc | 8 +- lily/drum-note-engraver.cc | 2 +- lily/drum-note-performer.cc | 22 +- lily/dynamic-engraver.cc | 6 +- lily/engraver-group-engraver.cc | 106 ++-- lily/engraver.cc | 36 +- lily/event-chord-iterator.cc | 4 +- lily/figured-bass-engraver.cc | 4 +- lily/folded-repeat-iterator.cc | 6 +- lily/font-size-engraver.cc | 2 +- lily/forbid-break-engraver.cc | 2 +- lily/global-context.cc | 184 ++++++ lily/global-translator.cc | 162 ----- lily/grace-iterator.cc | 2 +- lily/grob-info.cc | 14 +- lily/grob-pq-engraver.cc | 8 +- lily/grob-scheme.cc | 16 +- lily/grob.cc | 8 +- lily/hairpin.cc | 2 +- lily/hara-kiri-group-spanner.cc | 10 +- lily/include/audio-element-info.hh | 8 +- lily/include/chord-tremolo-iterator.hh | 2 +- lily/include/context-def.hh | 6 +- lily/include/context.hh | 91 +++ lily/include/engraver-group-engraver.hh | 15 +- lily/include/engraver.hh | 16 +- lily/include/event-chord-iterator.hh | 2 +- lily/include/folded-repeat-iterator.hh | 2 +- ...global-translator.hh => global-context.hh} | 24 +- lily/include/grob-info.hh | 4 +- lily/include/grob.hh | 4 +- lily/include/interpretation-context-handle.hh | 8 +- lily/include/lily-proto.hh | 4 +- lily/include/ly-smobs.icc | 2 +- lily/include/music-iterator.hh | 10 +- lily/include/music-output-def.hh | 5 +- lily/include/music-wrapper-iterator.hh | 2 +- lily/include/percent-repeat-iterator.hh | 2 +- lily/include/performer-group-performer.hh | 10 +- lily/include/performer.hh | 3 +- lily/include/score-context.hh | 27 + lily/include/score-engraver.hh | 15 +- lily/include/score-performer.hh | 7 +- lily/include/script.hh | 2 +- lily/include/sequential-iterator.hh | 2 +- lily/include/simultaneous-music-iterator.hh | 2 +- lily/include/translation-property.hh | 3 - lily/include/translator-group.hh | 69 +-- lily/include/translator.hh | 26 +- lily/instrument-name-engraver.cc | 6 +- lily/interpretation-context-handle.cc | 8 +- lily/key-engraver.cc | 14 +- lily/ligature-engraver.cc | 11 +- lily/line-interface.cc | 6 +- lily/line-spanner.cc | 12 +- lily/lookup.cc | 5 +- lily/lyric-combine-music-iterator.cc | 12 +- lily/lyric-phrasing-engraver.cc | 24 +- lily/mark-engraver.cc | 8 +- lily/measure-grouping-engraver.cc | 5 +- lily/measure-grouping-spanner.cc | 3 +- lily/melisma-engraver.cc | 3 +- lily/metronome-engraver.cc | 3 +- lily/moment.cc | 2 +- lily/music-iterator.cc | 12 +- lily/music-output-def.cc | 22 +- lily/music-wrapper-iterator.cc | 2 +- lily/music.cc | 26 +- lily/new-accidental-engraver.cc | 553 ------------------ lily/new-fingering-engraver.cc | 2 +- lily/new-lyric-combine-music-iterator.cc | 46 +- lily/new-part-combine-iterator.cc | 40 +- lily/note-head-line-engraver.cc | 12 +- lily/note-performer.cc | 23 +- lily/note-spacing.cc | 2 +- lily/output-property-engraver.cc | 11 +- lily/paper-column.cc | 32 +- lily/paper-score.cc | 2 +- lily/parser.yy | 24 +- lily/percent-repeat-engraver.cc | 11 +- lily/percent-repeat-iterator.cc | 2 +- lily/performer-group-performer.cc | 94 ++- lily/performer.cc | 21 +- lily/phrasing-slur-engraver.cc | 3 +- lily/piano-pedal-bracket.cc | 3 +- lily/piano-pedal-engraver.cc | 3 +- lily/pitch.cc | 17 +- lily/property-iterator.cc | 15 +- lily/recording-group-engraver.cc | 9 +- lily/repeat-acknowledge-engraver.cc | 10 +- lily/rest.cc | 2 +- lily/score-context.cc | 49 ++ lily/score-engraver.cc | 71 +-- lily/score-performer.cc | 32 +- lily/score.cc | 15 +- lily/script-column.cc | 2 +- lily/script-engraver.cc | 7 +- lily/self-aligment-interface.cc | 17 +- lily/separating-line-group-engraver.cc | 9 +- lily/sequential-iterator.cc | 12 +- lily/sequential-music-iterator.cc | 4 +- lily/side-position-interface.cc | 4 +- lily/simultaneous-music-iterator.cc | 8 +- lily/slash-repeat-engraver.cc | 9 +- lily/slur-engraver.cc | 5 +- lily/slur-performer.cc | 4 +- lily/spaceable-grob.cc | 8 +- lily/span-arpeggio-engraver.cc | 4 +- lily/span-bar-engraver.cc | 5 +- lily/staff-collecting-engraver.cc | 5 +- lily/staff-performer.cc | 3 +- lily/staff-symbol-referencer.cc | 8 +- lily/staff-symbol.cc | 2 +- lily/stem-engraver.cc | 9 +- lily/stem-tremolo.cc | 2 +- lily/stem.cc | 7 + lily/stencil-scheme.cc | 46 +- lily/system-start-delimiter-engraver.cc | 2 +- lily/system-start-delimiter.cc | 2 +- lily/system.cc | 6 +- lily/text-item.cc | 2 +- lily/tie-engraver.cc | 7 +- lily/tie-performer.cc | 4 +- lily/time-scaled-music-iterator.cc | 3 +- lily/timing-engraver.cc | 7 +- lily/timing-translator.cc | 38 +- lily/translator-group.cc | 219 ++----- lily/translator-property.cc | 21 +- lily/translator-scheme.cc | 190 +----- lily/translator.cc | 72 ++- lily/unfolded-repeat-iterator.cc | 4 +- lily/vertical-align-engraver.cc | 12 +- lily/volta-engraver.cc | 2 +- ly/engraver-init.ly | 10 +- ly/performer-init.ly | 5 +- scm/define-grob-interfaces.scm | 2 +- scm/define-grob-properties.scm | 10 +- scm/define-grobs.scm | 1 + scm/define-music-properties.scm | 4 +- scm/lily.scm | 3 +- scm/music-functions.scm | 3 +- scripts/convert-ly.py | 5 + 180 files changed, 1604 insertions(+), 2204 deletions(-) delete mode 100644 input/regression/mmrest-collision.ly create mode 100644 lily/global-context.cc rename lily/include/{global-translator.hh => global-context.hh} (69%) create mode 100644 lily/include/score-context.hh delete mode 100644 lily/new-accidental-engraver.cc create mode 100644 lily/score-context.cc diff --git a/ChangeLog b/ChangeLog index 36a35e0eba..07b3b2e3aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,39 @@ +2004-02-16 Han-Wen Nienhuys + + * lily/include/grob-info.hh: origin_contexts() now does not + include the originating engraver + + * lily/translator-group.cc (translator_each): clean up contents, + remove superfluous stubs. Engraver_group_engraver and + Performer_group_performer are the only classes using multiple + inheritance. + + * lily/include/score-context.hh (class Score_context): interface + between Score_{engraver,performer} and Global_context. + + * lily/include/global-context.hh (Context): change from + global-translator. This is the entry point for contexts; it is not + tweakable using \translator{}. Score is no longer the top context, + but sits underneath Global. + + * lily/include/context.hh (class Context): brain surgery: split + out Context functionality from Translator_group. Context is now a + separate type from Translator. + +2004-02-15 Han-Wen Nienhuys + + * lily/include/translator.hh (class Translator): make + get_score_context() and get_global_translator (), and use the one + which is appropriate. + + * lily/context.cc: partially put functionality of Translator_group + into Context. + + * lily/include/context.hh (Translator): new class: put between + Translator and Translator_group. + + * lily/new-accidental-engraver.cc: remove file. + 2004-02-16 Heikki Junes * input/regression/{many}.ly: improve descriptions: use complete @@ -17,6 +53,10 @@ 2004-02-15 Han-Wen Nienhuys + * lily/music.cc (LY_DEFINE): rename to ly:music-list? + + * scripts/convert-ly.py (conv): add ly:music-list change. + * lily/grob.cc: edit doc string. * scm/define-grob-properties.scm (all-user-grob-properties): @@ -63,7 +103,7 @@ * input/test/maximum-rest-count.ly: remove file. * scripts/convert-ly.py (FatalConversionError.subst_in_trans): - conversion rule for \translator{}. Apply everywhere. + conversion rule for \translator { }. Apply everywhere. * lily/parser.yy (music_property_def): set property for \once in the PropertyMusic itself, not the ContextSpec. diff --git a/Documentation/user/cheatsheet.itely b/Documentation/user/cheatsheet.itely index b07f0a5213..b39f168d15 100644 --- a/Documentation/user/cheatsheet.itely +++ b/Documentation/user/cheatsheet.itely @@ -221,13 +221,19 @@ a\> a a\! \context Voice { \grace b16 c4 } @end lilypond -@item @code{\lyrics @{ @dots{} @}} +@item @code{\lyrics @{ twinkle @}} @tab entering lyrics @tab -@item @code{\context Lyrics} + +@item @code{\new Lyrics} @tab printing lyrics @tab +twinkle +@c cheating .. +@c@li lypond[fragment] +@c \lyrics \new Lyrics { twinkle } +@c @end lilypond @item @code{twin -- kle} @tab lyric hyphen diff --git a/Documentation/user/lilypond-book.itely b/Documentation/user/lilypond-book.itely index e0ad3a271e..f553978e8a 100644 --- a/Documentation/user/lilypond-book.itely +++ b/Documentation/user/lilypond-book.itely @@ -254,8 +254,8 @@ following options: @table @code @item verbatim -CONTENTS is copied into the source enclosed in a verbatim block, -followed by any text given with the @code{intertext} option, then +@var{contents} is copied into the source, enclosed in a verbatim block; +followed by any text given with the @code{intertext} option; then the actual music is displayed. This option does not work with the short version of the music blocks: @@ -287,12 +287,12 @@ prevents printing time signature. @item fragment @item nofragment overrides @command{lilypond-book} auto detection of what type of code is -in the LilyPond block, voice contents or complete code. +in the LilyPond block, voice contents, or complete code. @item indent=@var{size}\\@var{unit} sets indentation of the first music system to @var{size}, where @var{unit} = cm, mm, in, or pt. This option affects LilyPond, -not the text layout. For single-line fragments the default is to +not the text layout. For single-line fragments, the default is to use no indentation. For example @@ -324,7 +324,7 @@ documents are composed from small @file{.ly} files in this way: @item relative, relative=@var{N} uses relative octave mode. By default, notes are specified relative -central C. The optional integer argument specifies the octave of the +to central C. The optional integer argument specifies the octave of the starting note, where the default @code{1} is central C. @end table @@ -342,7 +342,7 @@ cd out && lilypond-book ../yourfile.tex @noindent or to use the @option{--output} command line option, and change to -that director before running La@TeX{} or @file{makeinfo}: +that directory before running La@TeX{} or @file{makeinfo}: @example lilypond-book --output=out yourfile.lytex @@ -382,7 +382,7 @@ Place generated files in @var{dir}. @item @option{-P @var{process}}, @option{--process=@var{COMMAND}} Process lilypond snippets using @var{command}. The default command is -@var{lilypon-bin}. +@var{lilypond-bin}. @item @option{--verbose} Be verbose. diff --git a/Documentation/user/refman.itely b/Documentation/user/refman.itely index 7332b0b489..165fc001cc 100644 --- a/Documentation/user/refman.itely +++ b/Documentation/user/refman.itely @@ -3524,11 +3524,14 @@ The complete example is shown here: << \notes \relative c'' \context Voice = duet { \time 3/4 g2 e4 a2 f4 g2. } \lyrics << \lyricsto "duet" \new Lyrics { - \set stanza = "1" + \set stanza = "B." + \set vocName = "Bert" Hi, my name is bert. } \lyricsto "duet" \new Lyrics { - \set stanza = "2" - Ooooo, ch\'e -- ri, je t'aime. } + \set stanza = "E." + \set vocName = "Ernie" + Ooooo, ch\'e -- ri, je t'aime. + } >> >> } @end lilypond @@ -3540,19 +3543,19 @@ The complete example is shown here: Stanza numbers can be added by setting @code{stanza}, e.g. @example - \set stanza = "Bert" + \set stanza = "B." @dots{} - \set stanza = "Ernie" + \set stanza = "E." @end example Notice how dots are surrounded with spaces in @code{\lyrics} mode, to prevent @code{stanza} being interpreted as a single string. -Names of the singers should be added using @code{Lyrics -. vocalName} and @code{Lyrics . vocNam}, analogous to instrument -annotations for staves. - +This example also demonstrates how names of the singers can be added +using @code{vocalName} analogous to instrument annotations for staves. +A short version may be entered as @code{vocNam}. + To make empty spaces in lyrics, use @code{\skip}. diff --git a/VERSION b/VERSION index ed63965fde..ef10a17901 100644 --- a/VERSION +++ b/VERSION @@ -2,5 +2,5 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=2 MINOR_VERSION=1 PATCH_LEVEL=23 -MY_PATCH_LEVEL= +MY_PATCH_LEVEL=hwn2 diff --git a/input/regression/lyric-hyphen.ly b/input/regression/lyric-hyphen.ly index 3e4f5afeb9..4dc26dabd7 100644 --- a/input/regression/lyric-hyphen.ly +++ b/input/regression/lyric-hyphen.ly @@ -1,5 +1,7 @@ \version "2.1.22" -\header {texidoc="In lyrics, hyphens may be used."} +\header { + texidoc = "In lyrics, hyphens may be used." +} \score{ << \context Staff \notes { c' (c') (c') c' } diff --git a/input/regression/mmrest-collision.ly b/input/regression/mmrest-collision.ly deleted file mode 100644 index 26e92bad90..0000000000 --- a/input/regression/mmrest-collision.ly +++ /dev/null @@ -1,29 +0,0 @@ -\version "2.1.23" -\header { texidoc = "Collision between multimeasure rests in different voices -may be avoided. " } -\score { - \context Staff \notes << - \new Voice { - \override MultiMeasureRest #'staff-position = #3 - R1 - } - \new Voice { - \override MultiMeasureRest #'staff-position = #-3 - R1 - } - >> - \paper { - \translator { - \StaffContext - \remove Multi_measure_rest_engraver - \remove Bar_engraver - } - \translator { - \VoiceContext - \consists Multi_measure_rest_engraver - \consists Bar_engraver - } - raggedright = ##t - } -} - diff --git a/input/regression/tuplet-rest.ly b/input/regression/tuplet-rest.ly index f35bf4a14a..a3cdf4850b 100644 --- a/input/regression/tuplet-rest.ly +++ b/input/regression/tuplet-rest.ly @@ -1,6 +1,10 @@ \version "2.1.22" -\header {texidoc = "Tuplets may contain rests. "} +\header { + + texidoc = "Tuplets may contain rests. " + +} \score { \context Voice \notes \relative c'' { diff --git a/input/screech-boink.ly b/input/screech-boink.ly index f574fa4586..17e5f897b3 100644 --- a/input/screech-boink.ly +++ b/input/screech-boink.ly @@ -52,12 +52,14 @@ } >> - \paper { linewidth = -1.0 + \paper { + raggedright = ##t - \translator { - \StaffContext - \consists Horizontal_bracket_engraver } - - } + \translator { + \StaffContext + \consists Horizontal_bracket_engraver + } + + } \midi { \tempo 8 = 60 } } diff --git a/lily/accidental-engraver.cc b/lily/accidental-engraver.cc index e20730bb99..ae3fe262a8 100644 --- a/lily/accidental-engraver.cc +++ b/lily/accidental-engraver.cc @@ -7,6 +7,7 @@ #include "event.hh" + #include "item.hh" #include "tie.hh" #include "rhythmic-head.hh" @@ -16,7 +17,7 @@ #include "engraver.hh" #include "arpeggio.hh" #include "warn.hh" -#include "translator-group.hh" +#include "context.hh" #include "protected-scm.hh" /** @@ -30,7 +31,7 @@ struct Accidental_entry { bool done_; Music * melodic_; Grob * accidental_; - Translator_group *origin_; + Context *origin_; Grob* head_; Accidental_entry(); }; @@ -75,13 +76,14 @@ public: static void -set_property_on_children (Translator_group * trans, const char * sym, SCM val) +set_property_on_children (Context * trans, const char * sym, SCM val) { trans->set_property (sym, val); - for (SCM p = trans->trans_group_list_; gh_pair_p (p); p = ly_cdr(p)) { - Translator_group *trg = dynamic_cast (unsmob_translator (ly_car (p))); - set_property_on_children(trg,sym,ly_deep_copy(val)); - } + for (SCM p = trans->context_list_; gh_pair_p (p); p = ly_cdr(p)) + { + Context *trg = unsmob_context (ly_car (p)); + set_property_on_children(trg, sym, ly_deep_copy(val)); + } } Accidental_engraver::Accidental_engraver () @@ -95,13 +97,14 @@ Accidental_engraver::initialize () { last_keysig_ = get_property ("keySignature"); - Translator_group * trans_ = daddy_trans_; + Context * trans_ = daddy_context_; while (trans_) { - trans_ -> set_property ("localKeySignature", ly_deep_copy (last_keysig_)); - trans_ = trans_->daddy_trans_; + trans_ -> set_property ("localKeySignature", + ly_deep_copy (last_keysig_)); + trans_ = trans_->daddy_context_; } - set_property_on_children (daddy_trans_,"localKeySignature", last_keysig_); + set_property_on_children (daddy_context_,"localKeySignature", last_keysig_); } /* @@ -157,7 +160,7 @@ number_accidentals_from_sig (SCM sig, Music *, Pitch *pitch, SCM curbarnum, SCM } static int -number_accidentals (Music * note, Pitch *pitch, Translator_group * origin, +number_accidentals (Music * note, Pitch *pitch, Context * origin, SCM accidentals, SCM curbarnum) { int number = 0; @@ -200,9 +203,9 @@ number_accidentals (Music * note, Pitch *pitch, Translator_group * origin, */ else if (gh_symbol_p (rule)) { - Translator_group * dad = origin; + Context * dad = origin; while (dad && !dad->is_alias (rule)) - dad = dad->daddy_trans_; + dad = dad->daddy_context_; if (dad) origin = dad; @@ -234,7 +237,7 @@ Accidental_engraver::process_acknowledged_grobs () accidentals_[i].done_ = true; Grob * support = accidentals_[i].head_; Music * note = accidentals_[i].melodic_; - Translator_group * origin = accidentals_[i].origin_; + Context * origin = accidentals_[i].origin_; Pitch * pitch = unsmob_pitch (note->get_mus_property ("pitch")); if (!pitch) @@ -384,7 +387,7 @@ Accidental_engraver::process_acknowledged_grobs () (localsig, on_s, gh_cons (scm_int2num (a), barnum)); } origin->set_property ("localKeySignature", localsig); - origin = origin->daddy_trans_; + origin = origin->daddy_context_; } } } @@ -434,7 +437,7 @@ Accidental_engraver::acknowledge_grob (Grob_info info) { Accidental_entry entry ; entry.head_ = info.grob_; - entry.origin_ = info.origin_trans_->daddy_trans_; + entry.origin_ = info.origin_trans_->daddy_context_; entry.melodic_ = note; accidentals_.push (entry); @@ -463,13 +466,13 @@ Accidental_engraver::process_music () */ if (last_keysig_ != sig) { - Translator_group * trans_ = daddy_trans_; + Context * trans_ = daddy_context_; while (trans_) { trans_ -> set_property ("localKeySignature", ly_deep_copy (sig)); - trans_ = trans_->daddy_trans_; + trans_ = trans_->daddy_context_; } - set_property_on_children(daddy_trans_,"localKeySignature", sig); + set_property_on_children(daddy_context_,"localKeySignature", sig); last_keysig_ = sig; } diff --git a/lily/accidental-placement.cc b/lily/accidental-placement.cc index e9d0817695..c0f3b6ae67 100644 --- a/lily/accidental-placement.cc +++ b/lily/accidental-placement.cc @@ -444,5 +444,5 @@ Accidental_placement::position_accidentals (Grob * me) ADD_INTERFACE(Accidental_placement, "accidental-placement-interface", - "Take care of complex accidental collisions.", + "Resolve accidental collisions.", "left-padding padding right-padding accidental-grobs positioning-done") diff --git a/lily/align-interface.cc b/lily/align-interface.cc index 4bddc8327f..47d90b7b24 100644 --- a/lily/align-interface.cc +++ b/lily/align-interface.cc @@ -266,8 +266,11 @@ find_fixed_alignment_parent (Grob *g) ADD_INTERFACE (Align_interface, "align-interface", - " Order grobs top to bottom/left to right/right to left etc.", - "forced-distance stacking-dir align-dir threshold positioning-done center-element elements axes"); + "Order grobs from top to bottom, left to right, right to left or bottom" + "to top." + , + "forced-distance stacking-dir align-dir threshold positioning-done " + "center-element elements axes"); struct Foobar diff --git a/lily/ambitus.cc b/lily/ambitus.cc index 75e3dff62d..eaf006feb0 100644 --- a/lily/ambitus.cc +++ b/lily/ambitus.cc @@ -254,5 +254,5 @@ Ambitus::print (SCM smob) } ADD_INTERFACE (Ambitus, "ambitus-interface", - "An ambitus represents the pitch range of a voice.", + "An object that represents the pitch range of a voice.", "c0-position pitch-min pitch-max accidentals note-head-style join-heads"); diff --git a/lily/apply-context-iterator.cc b/lily/apply-context-iterator.cc index e08887c6f9..d8541f98c0 100644 --- a/lily/apply-context-iterator.cc +++ b/lily/apply-context-iterator.cc @@ -1,5 +1,5 @@ #include "simple-music-iterator.hh" -#include "translator-group.hh" +#include "context.hh" #include "music.hh" /** diff --git a/lily/audio-element-info.cc b/lily/audio-element-info.cc index 9a079a1425..a2bf63233a 100644 --- a/lily/audio-element-info.cc +++ b/lily/audio-element-info.cc @@ -8,6 +8,7 @@ #include "audio-element-info.hh" #include "translator-group.hh" +#include "context.hh" Audio_element_info::Audio_element_info (Audio_element*s, Music *r) { @@ -25,15 +26,15 @@ Audio_element_info::Audio_element_info () } -Link_array -Audio_element_info::origin_transes (Translator* end) const +Link_array +Audio_element_info::origin_contexts (Translator* end) const { - Translator * t = origin_trans_; - Link_array r; + Context * t = origin_trans_->daddy_context_; + Link_array r; do { r.push (t); - t = t->daddy_trans_; - } while (t && t != end->daddy_trans_); + t = t->daddy_context_; + } while (t && t != end->daddy_context_); return r; } diff --git a/lily/auto-beam-engraver.cc b/lily/auto-beam-engraver.cc index 5696550ffb..ffdfe43140 100644 --- a/lily/auto-beam-engraver.cc +++ b/lily/auto-beam-engraver.cc @@ -19,6 +19,7 @@ #include "item.hh" #include "spanner.hh" #include "duration.hh" +#include "context.hh" /* TODO: figure what to do in grace? @@ -278,7 +279,7 @@ Auto_beam_engraver::begin_beam () stems_ = new Link_array; grouping_ = new Beaming_info_list; - beam_settings_ = updated_grob_properties (daddy_trans_, ly_symbol2scm ("Beam")); + beam_settings_ = updated_grob_properties (daddy_context_, ly_symbol2scm ("Beam")); beam_start_moment_ = now_mom (); beam_start_location_ = *unsmob_moment (get_property ("measurePosition")); diff --git a/lily/auto-change-iterator.cc b/lily/auto-change-iterator.cc index 30c7b69bbf..81dcdaa1c4 100644 --- a/lily/auto-change-iterator.cc +++ b/lily/auto-change-iterator.cc @@ -8,7 +8,7 @@ */ #include "music.hh" -#include "translator-group.hh" +#include "context.hh" #include "event.hh" #include "music-wrapper-iterator.hh" #include "direction.hh" @@ -36,8 +36,8 @@ void Auto_change_iterator::change_to (Music_iterator *it, SCM to_type_sym, String to_id) { - Translator_group * current = it->get_outlet (); - Translator_group * last = 0; + Context * current = it->get_outlet (); + Context * last = 0; /* Cut & Paste from Change_iterator (ugh). @@ -52,7 +52,7 @@ Auto_change_iterator::change_to (Music_iterator *it, SCM to_type_sym, while (current && !current->is_alias (to_type_sym)) { last = current; - current = current->daddy_trans_; + current = current->daddy_context_; } if (current && current->id_string_ == to_id) @@ -64,10 +64,10 @@ Auto_change_iterator::change_to (Music_iterator *it, SCM to_type_sym, if (current) if (last) { - Translator_group * dest = - it->get_outlet ()->find_create_translator (to_type_sym, to_id, SCM_EOL); - current->remove_translator (last); - dest->add_used_group_translator (last); + Context * dest = + it->get_outlet ()->find_create_context (to_type_sym, to_id, SCM_EOL); + current->remove_context (last); + dest->add_context (last); } else { @@ -86,7 +86,6 @@ void Auto_change_iterator::process (Moment m) { Music_wrapper_iterator::process (m); - Moment now = get_outlet ()->now_mom (); Moment *splitm = 0; diff --git a/lily/axis-group-engraver.cc b/lily/axis-group-engraver.cc index 401653e69f..7c509ca9bb 100644 --- a/lily/axis-group-engraver.cc +++ b/lily/axis-group-engraver.cc @@ -12,6 +12,7 @@ #include "engraver.hh" #include "engraver-group-engraver.hh" #include "warn.hh" +#include "context.hh" /** Put stuff in a Spanner with an Axis_group_interface. @@ -68,7 +69,7 @@ Axis_group_engraver::finalize () if (!staffline_) return ; - String type = get_daddy_grav ()->context_name (); + String type = daddy_context_->context_name (); SCM dims = get_property ("verticalExtent"); if (is_number_pair (dims)) diff --git a/lily/axis-group-interface.cc b/lily/axis-group-interface.cc index 3758ee9abb..f5bc52ced3 100644 --- a/lily/axis-group-interface.cc +++ b/lily/axis-group-interface.cc @@ -33,8 +33,8 @@ Axis_group_interface::axis_b (Grob*me,Axis a) */ - return me->has_extent_callback_b (group_extent_callback_proc, a) || - (me->has_extent_callback_b (Hara_kiri_group_spanner::y_extent_proc, a)); + return me->has_extent_callback (group_extent_callback_proc, a) || + (me->has_extent_callback (Hara_kiri_group_spanner::y_extent_proc, a)); } Interval @@ -93,9 +93,9 @@ Axis_group_interface::set_axes (Grob*me,Axis a1, Axis a2) /* why so convoluted ? (fixme/documentme?) */ - if (me->has_extent_callback_b (Grob::stencil_extent_proc, a1)) + if (me->has_extent_callback (Grob::stencil_extent_proc, a1)) me->set_extent (Axis_group_interface::group_extent_callback_proc,a1); - if (me->has_extent_callback_b (Grob::stencil_extent_proc, a2)) + if (me->has_extent_callback (Grob::stencil_extent_proc, a2)) me->set_extent (Axis_group_interface::group_extent_callback_proc,a2); } @@ -121,5 +121,5 @@ Axis_group_interface::get_children (Grob*me) ADD_INTERFACE (Axis_group_interface, "axis-group-interface", - "a group of coupled grobs", + "An object that groups other layout objects.", "axes"); diff --git a/lily/bar-check-iterator.cc b/lily/bar-check-iterator.cc index dc3e27feac..343bcd229b 100644 --- a/lily/bar-check-iterator.cc +++ b/lily/bar-check-iterator.cc @@ -10,7 +10,7 @@ #include "simple-music-iterator.hh" #include "event.hh" -#include "translator-group.hh" +#include "context.hh" /* Check bar checks. We do this outside the engravers so that you can @@ -36,7 +36,7 @@ Bar_check_iterator::process (Moment m) Simple_music_iterator::process(m); if (!m.to_bool ()) { - Translator_group *tr = get_outlet (); + Context *tr = get_outlet (); SCM mp = tr->get_property ("measurePosition"); SCM sync= tr->get_property ("barCheckSynchronize"); diff --git a/lily/bar-engraver.cc b/lily/bar-engraver.cc index f3b94b2532..2d519a7f65 100644 --- a/lily/bar-engraver.cc +++ b/lily/bar-engraver.cc @@ -101,7 +101,7 @@ Bar_engraver::stop_translation_timestep () { if (!bar_) { - top_engraver ()->forbid_breaks (); // guh. Use properties! + get_score_engraver ()->forbid_breaks (); // guh. Use properties! } else typeset_bar (); diff --git a/lily/bar-number-engraver.cc b/lily/bar-number-engraver.cc index bfdba32328..67c7fc909d 100644 --- a/lily/bar-number-engraver.cc +++ b/lily/bar-number-engraver.cc @@ -14,7 +14,7 @@ #include "item.hh" #include "moment.hh" #include "engraver.hh" -#include "translator-group.hh" +#include "context.hh" /* diff --git a/lily/beam-engraver.cc b/lily/beam-engraver.cc index 868ddcbfc9..bd25a47df4 100644 --- a/lily/beam-engraver.cc +++ b/lily/beam-engraver.cc @@ -6,7 +6,7 @@ (c) 1998--2004 Han-Wen Nienhuys */ -#include "engraver-group-engraver.hh" + #include "engraver.hh" #include "event.hh" #include "beam.hh" @@ -18,6 +18,7 @@ #include "drul-array.hh" #include "item.hh" #include "spanner.hh" +#include "context.hh" class Beam_engraver : public Engraver { @@ -46,7 +47,7 @@ protected: void set_melisma (bool); Moment last_stem_added_at_; - virtual void stop_translation_timestep (); + virtual void stop_translation_timestep (); virtual void start_translation_timestep (); virtual void finalize (); @@ -58,7 +59,7 @@ protected: virtual bool valid_end_point (); public: - TRANSLATOR_DECLARATIONS( Beam_engraver ); + TRANSLATOR_DECLARATIONS(Beam_engraver); }; @@ -120,7 +121,7 @@ Beam_engraver::set_melisma (bool ml) { SCM b = get_property ("autoBeaming"); if (!to_boolean (b)) - daddy_trans_->set_property ("beamMelismaBusy", ml ? SCM_BOOL_T :SCM_BOOL_F); + daddy_context_->set_property ("beamMelismaBusy", ml ? SCM_BOOL_T :SCM_BOOL_F); } void @@ -128,7 +129,7 @@ Beam_engraver::process_music () { if (beam_ && !to_boolean (get_property ("allowBeamBreak"))) { - top_engraver ()->forbid_breaks (); + get_score_engraver ()->forbid_breaks (); } if (start_ev_) diff --git a/lily/beam-performer.cc b/lily/beam-performer.cc index 4010502032..427946738d 100644 --- a/lily/beam-performer.cc +++ b/lily/beam-performer.cc @@ -10,7 +10,7 @@ #include "event.hh" #include "audio-item.hh" #include "audio-column.hh" -#include "global-translator.hh" +#include "global-context.hh" #include "warn.hh" class Beam_performer : public Performer { @@ -49,7 +49,7 @@ Beam_performer::set_melisma (bool ml) { SCM b = get_property ("autoBeaming"); if (!to_boolean (b)) - daddy_trans_->set_property ("beamMelismaBusy", ml ? SCM_BOOL_T :SCM_BOOL_F); + daddy_context_->set_property ("beamMelismaBusy", ml ? SCM_BOOL_T :SCM_BOOL_F); } void diff --git a/lily/beam.cc b/lily/beam.cc index 0d34e2ff72..4d8564075d 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -1566,22 +1566,14 @@ Beam::get_direction_beam_count (Grob *me, Direction d ) ADD_INTERFACE (Beam, "beam-interface", - "A beam. \n\n" -" " -"#'thickness= weight of beams, in staffspace " -" " -" " -"We take the least squares line through the ideal-length stems, and " -"then damp that using " -" \n" -" damped = tanh (slope) \n" -" \n" -"this gives an unquantized left and right position for the beam end. " -"Then we take all combinations of quantings near these left and right " -"positions, and give them a score (according to how close they are to " -"the ideal slope, how close the result is to the ideal stems, etc.). We " -"take the best scoring combination. " -, - "knee positioning-done position-callbacks concaveness-gap concaveness-threshold dir-function quant-score auto-knee-gap gap gap-count chord-tremolo beamed-stem-shorten shorten least-squares-dy damping flag-width-function neutral-direction positions space-function thickness"); + "A beam. \n\n" + "The @code{thickness} property is the weight of beams, and is measured " + "in staffspace" + , + "knee positioning-done position-callbacks concaveness-gap " + "concaveness-threshold dir-function quant-score auto-knee-gap gap " + "gap-count chord-tremolo beamed-stem-shorten shorten least-squares-dy " + "damping flag-width-function neutral-direction positions space-function " + "thickness"); diff --git a/lily/break-align-interface.cc b/lily/break-align-interface.cc index de8ba98a11..91cf8a8745 100644 --- a/lily/break-align-interface.cc +++ b/lily/break-align-interface.cc @@ -233,8 +233,8 @@ Break_align_interface::do_alignment (Grob *me) ADD_INTERFACE (Break_aligned_interface, "break-aligned-interface", "Items that are aligned in prefatory matter.\n" "\n" - "The spacing of these items is controlled by the space-alist\n" - "property. It contains a list break-align-symbols with a specification\n" + "The spacing of these items is controlled by the @code{space-alist}\n" + "property. It contains a list @code{break-align-symbol}s with a specification\n" "of the associated space. The space specification can be " "@table @code\n" "@item (minimum-space . @var{spc}))\n" @@ -248,7 +248,7 @@ ADD_INTERFACE (Break_aligned_interface, "break-aligned-interface", " Add @var{spc} amount of space.\n" "@end table\n" "\n" - "Special keys for the alist are 'first-note and 'next-note, signifying\n" + "Special keys for the alist are @code{first-note} and @code{next-note}, signifying\n" "the first note on a line, and the next note halfway a line.\n" "\n" "Rules for this spacing are much more complicated than this. \n" @@ -256,8 +256,8 @@ ADD_INTERFACE (Break_aligned_interface, "break-aligned-interface", "break-align-symbol space-alist"); ADD_INTERFACE (Break_align_interface, "break-alignment-interface", - "See @ref{break-aligned-interface}.", - "positioning-done"); + "The object that performs break aligment. See @ref{break-aligned-interface}.", + "positioning-done"); diff --git a/lily/change-iterator.cc b/lily/change-iterator.cc index 82ce6d6673..0060d4a0ad 100644 --- a/lily/change-iterator.cc +++ b/lily/change-iterator.cc @@ -7,10 +7,10 @@ */ #include "change-iterator.hh" -#include "translator-group.hh" +#include "context.hh" #include "music.hh" #include "warn.hh" - +#include "input.hh" void @@ -38,8 +38,8 @@ Change_iterator::error (String reason) void Change_iterator::process (Moment m) { - Translator_group * current = get_outlet (); - Translator_group * last = 0; + Context * current = get_outlet (); + Context * last = 0; SCM to_type = get_music ()->get_mus_property ("change-to-type"); String to_id = ly_scm2string (get_music ()->get_mus_property ("change-to-id")); @@ -52,7 +52,7 @@ Change_iterator::process (Moment m) while (current && !current->is_alias (to_type)) { last = current; - current = current->daddy_trans_; + current = current->daddy_context_; } if (current && current->id_string_ == to_id) @@ -64,10 +64,10 @@ Change_iterator::process (Moment m) if (current) if (last) { - Translator_group * dest = - get_outlet ()->find_create_translator (to_type, to_id, SCM_EOL); - current->remove_translator (last); - dest->add_used_group_translator (last); + Context * dest = + get_outlet ()->find_create_context (to_type, to_id, SCM_EOL); + current->remove_context (last); + dest->add_context (last); } else { diff --git a/lily/chord-name-engraver.cc b/lily/chord-name-engraver.cc index 0b8fd2d88d..9d88608406 100644 --- a/lily/chord-name-engraver.cc +++ b/lily/chord-name-engraver.cc @@ -16,7 +16,7 @@ #include "item.hh" #include "pitch.hh" #include "protected-scm.hh" -#include "translator-group.hh" +#include "context.hh" #include "warn.hh" class Chord_name_engraver : public Engraver @@ -102,7 +102,7 @@ Chord_name_engraver::process_music () SCM name_proc = get_property ("chordNameFunction"); SCM markup = scm_call_4 (name_proc, pitches, bass, inversion, - daddy_trans_->self_scm()); + daddy_context_->self_scm ()); /* Ugh. diff --git a/lily/chord-name.cc b/lily/chord-name.cc index 1077e3ec6f..84909fadf4 100644 --- a/lily/chord-name.cc +++ b/lily/chord-name.cc @@ -35,6 +35,6 @@ Chord_name::after_line_breaking (SCM smob) ADD_INTERFACE (Chord_name, "chord-name-interface", - "generate a chord name", + "A chord name.", "begin-of-line-visible"); diff --git a/lily/chord-tremolo-iterator.cc b/lily/chord-tremolo-iterator.cc index 6887ce67c4..050d5043ce 100644 --- a/lily/chord-tremolo-iterator.cc +++ b/lily/chord-tremolo-iterator.cc @@ -46,7 +46,7 @@ Chord_tremolo_iterator::derived_mark () const } void -Chord_tremolo_iterator::derived_substitute (Translator_group*f, Translator_group*t) +Chord_tremolo_iterator::derived_substitute (Context *f, Context *t) { if (child_iter_) child_iter_->substitute_outlet (f,t); diff --git a/lily/clef-engraver.cc b/lily/clef-engraver.cc index 76c814444f..a9c93ba42c 100644 --- a/lily/clef-engraver.cc +++ b/lily/clef-engraver.cc @@ -10,7 +10,7 @@ #include -#include "translator-group.hh" +#include "context.hh" #include "bar-line.hh" #include "staff-symbol-referencer.hh" #include "engraver.hh" @@ -61,8 +61,8 @@ Clef_engraver::set_glyph () SCM basic = ly_symbol2scm ("Clef"); - execute_pushpop_property (daddy_trans_, basic, glyph_sym, SCM_UNDEFINED); - execute_pushpop_property (daddy_trans_, basic, glyph_sym, glyph); + execute_pushpop_property (daddy_context_, basic, glyph_sym, SCM_UNDEFINED); + execute_pushpop_property (daddy_context_, basic, glyph_sym, glyph); } /** @@ -149,7 +149,7 @@ Clef_engraver::inspect_clef_properties () if (to_boolean (force_clef)) { - Translator_group * w = daddy_trans_->where_defined (ly_symbol2scm ("forceClef")); + Context * w = daddy_context_->where_defined (ly_symbol2scm ("forceClef")); w->set_property ("forceClef", SCM_EOL); } } diff --git a/lily/cluster.cc b/lily/cluster.cc index fedaaf4d79..d1794a908a 100644 --- a/lily/cluster.cc +++ b/lily/cluster.cc @@ -218,16 +218,12 @@ Cluster::print (SCM smob) } ADD_INTERFACE (Cluster,"cluster-interface", - "A graphically drawn musical cluster. " -"\n\n" -"@code{padding} adds to the vertical extent of the shape (top and " -"bottom) and is expressed in units of staffspace. Since the pitch " -"range of a single pitch is infinitely small, if padding is set to " -"@code{0.0}, this possibly results in an invisible shape, if you,for " -"example, say @code{c-\\startCluster d e-\\endCluster}. The default " -"value for @code{padding} therefore is @code{0.25}, such that a single " -"pitch roughly shows the same height as a note head. " -"\n\n" -"@code{style} controls the shape of cluster segments. Valid values include 'leftsided-stairs', 'rightsided-stairs', 'centered-stairs', and 'ramp'.\n" + "A graphically drawn musical cluster. " + "\n\n" + "@code{padding} adds to the vertical extent of the shape (top and " + "bottom). \n\n" + "The property @code{style} controls the shape of cluster segments. Valid values " + "include @code{leftsided-stairs}, @code{rightsided-stairs}, @code{centered-stairs}, " + "and @code{ramp}.\n" , "style padding columns"); diff --git a/lily/completion-note-heads-engraver.cc b/lily/completion-note-heads-engraver.cc index 93f3a60604..bbe14d260d 100644 --- a/lily/completion-note-heads-engraver.cc +++ b/lily/completion-note-heads-engraver.cc @@ -17,6 +17,7 @@ #include "warn.hh" #include "spanner.hh" #include "tie.hh" +#include "global-context.hh" /* @@ -181,7 +182,8 @@ Completion_heads_engraver::process_music () Moment next = now; next.main_part_ += note_dur.get_length (); - top_engraver ()->add_moment_to_process (next); + + get_global_context ()->add_moment_to_process (next); do_nothing_until_ = next.main_part_; } diff --git a/lily/context-def.cc b/lily/context-def.cc index f48e78d3aa..6fcee6e2de 100644 --- a/lily/context-def.cc +++ b/lily/context-def.cc @@ -13,6 +13,7 @@ #include "warn.hh" #include "music-output-def.hh" #include "ly-smobs.icc" +#include "score-context.hh" int Context_def::print_smob (SCM smob, SCM port, scm_print_state*) @@ -163,7 +164,7 @@ Context_def::get_accepted (SCM user_mod) const Link_array -Context_def::path_to_acceptable_translator (SCM type_sym, Music_output_def* odef) const +Context_def::path_to_acceptable_context (SCM type_sym, Music_output_def* odef) const { assert (gh_symbol_p (type_sym)); @@ -172,7 +173,7 @@ Context_def::path_to_acceptable_translator (SCM type_sym, Music_output_def* odef Link_array accepteds; for (SCM s = accepted; gh_pair_p (s); s = ly_cdr (s)) { - Context_def *t = unsmob_context_def (odef->find_translator (ly_car (s))); + Context_def *t = unsmob_context_def (odef->find_context_def (ly_car (s))); if (!t) continue; accepteds.push (t); @@ -197,7 +198,7 @@ Context_def::path_to_acceptable_translator (SCM type_sym, Music_output_def* odef Context_def * g = accepteds[i]; Link_array result - = g->path_to_acceptable_translator (type_sym, odef); + = g->path_to_acceptable_context (type_sym, odef); if (result.size () && result.size () < best_depth) { result.insert (g,0); @@ -218,8 +219,6 @@ IMPLEMENT_SMOBS (Context_def); IMPLEMENT_DEFAULT_EQUAL_P (Context_def); - - SCM Context_def::get_translator_names (SCM user_mod) const { @@ -252,18 +251,32 @@ Context_def::get_translator_names (SCM user_mod) const } -Translator_group * +Context * Context_def::instantiate (SCM ops) { - Translator * g = get_translator (translator_group_type_); - g = g->clone (); + Context * tg = 0; - Translator_group *tg = dynamic_cast (g); + if (context_name_ == ly_symbol2scm ("Score")) + tg = new Score_context (); + else + tg = new Context (); + + tg->definition_ = self_scm (); SCM trans_names = get_translator_names (ops); - tg->simple_trans_list_ = names_to_translators (trans_names, tg); + + Translator * g = get_translator (translator_group_type_); + g = g->clone (); + + g->simple_trans_list_ = names_to_translators (trans_names, tg); + tg->implementation_ = g->self_scm (); + g->daddy_context_ = tg; + + scm_gc_unprotect_object (g->self_scm ()); + tg->accepts_list_ = get_accepted (ops); + return tg; } @@ -285,7 +298,7 @@ Context_def::make_scm () } void -Context_def::apply_default_property_operations (Translator_group *tg) +Context_def::apply_default_property_operations (Context *tg) { apply_property_operations (tg , property_ops_); } diff --git a/lily/context-specced-music-iterator.cc b/lily/context-specced-music-iterator.cc index fd4cd1eaf9..050d704abf 100644 --- a/lily/context-specced-music-iterator.cc +++ b/lily/context-specced-music-iterator.cc @@ -9,7 +9,7 @@ */ #include "music-wrapper-iterator.hh" -#include "translator-group.hh" +#include "context.hh" class Context_specced_music_iterator : public Music_wrapper_iterator { @@ -29,8 +29,8 @@ Context_specced_music_iterator::construct_children () c_id = ly_scm2string (ci); SCM ops = get_music ()->get_mus_property ("property-operations"); - Translator_group* a - = get_outlet ()->find_create_translator (ct, c_id, ops); + Context * a + = get_outlet ()->find_create_context (ct, c_id, ops); if (a) set_translator (a); diff --git a/lily/context.cc b/lily/context.cc index bbf12d4b18..df3766b82a 100644 --- a/lily/context.cc +++ b/lily/context.cc @@ -1,44 +1,130 @@ +/* + context.cc -- implement Context + + source file of the GNU LilyPond music typesetter + + (c) 2004 Han-Wen Nienhuys + +*/ + #include "translator-group.hh" #include "context-def.hh" +#include "context.hh" #include "warn.hh" #include "music-output-def.hh" #include "scm-hash.hh" #include "main.hh" +#include "ly-smobs.icc" +#include "score-context.hh" bool -Translator_group::is_removable () const +Context::is_removable () const +{ + return context_list_ == SCM_EOL && ! iterator_count_ && + !dynamic_cast (this) + ; +} + + +void +Context::check_removal () +{ + for (SCM p = context_list_; gh_pair_p (p); p = gh_cdr (p)) + { + Context *trg = unsmob_context (ly_car (p)); + + trg->check_removal (); + if (trg->is_removable ()) + { + recurse_down_translators (trg, &Translator::finalize, false); + remove_context (trg); + } + } +} + +Context::Context (Context const&) +{ + assert (false); +} + +Scheme_hash_table* +Context::properties_dict () const { - return trans_group_list_ == SCM_EOL && ! iterator_count_; + return Scheme_hash_table::unsmob (properties_scm_); } -Translator_group * -Translator_group::find_existing_translator (SCM n, String id) +void +Context::add_context (Context*t) +{ + SCM ts = t->self_scm (); + context_list_ = gh_append2 (context_list_, + gh_cons (ts, SCM_EOL)); + + t->daddy_context_ = this; + if (!t->init_) + { + t->init_ = true; + + scm_gc_unprotect_object (ts); + Context_def * td = unsmob_context_def (t->definition_); + + /* + this can not move before add_context(), because \override + operations require that we are in the hierarchy. + */ + td->apply_default_property_operations (t); + + recurse_down_translators (t, &Translator::initialize, true); + } +} + +Context::Context () +{ + daddy_context_ = 0; + init_ = false; + iterator_count_ = 0; + implementation_ = SCM_EOL; + properties_scm_ = SCM_EOL; + accepts_list_ = SCM_EOL; + context_list_ = SCM_EOL; + definition_ = SCM_EOL; + + smobify_self (); + + Scheme_hash_table *tab = new Scheme_hash_table ; + properties_scm_ = tab->self_scm (); + scm_gc_unprotect_object (tab->self_scm ()); +} + +Context * +Context::find_existing_context (SCM n, String id) { if ((is_alias (n) && (id_string_ == id || id.is_empty ())) || n == ly_symbol2scm ("Current")) return this; - Translator_group* r = 0; - for (SCM p = trans_group_list_; !r && gh_pair_p (p); p = ly_cdr (p)) + Context* r = 0; + for (SCM p = context_list_; !r && gh_pair_p (p); p = ly_cdr (p)) { - Translator * t = unsmob_translator (ly_car (p)); + Context * t = unsmob_context (ly_car (p)); - r = dynamic_cast (t)->find_existing_translator (n, id); + r = dynamic_cast (t)->find_existing_context (n, id); } return r; } -Translator_group* -Translator_group::find_create_translator (SCM n, String id, SCM operations) +Context* +Context::find_create_context (SCM n, String id, + SCM operations) { - Translator_group * existing = find_existing_translator (n,id); + Context * existing = find_existing_context (n,id); if (existing) return existing; if (n == ly_symbol2scm ("Bottom")) { - Translator_group* tg = get_default_interpreter (); + Context* tg = get_default_interpreter (); tg->id_string_ = id; return tg; } @@ -47,18 +133,18 @@ Translator_group::find_create_translator (SCM n, String id, SCM operations) TODO: use accepts_list_. */ Link_array path - = unsmob_context_def (definition_)->path_to_acceptable_translator (n, get_output_def ()); + = unsmob_context_def (definition_)->path_to_acceptable_context (n, get_output_def ()); if (path.size ()) { - Translator_group * current = this; + Context * current = this; // start at 1. The first one (index 0) will be us. for (int i=0; i < path.size (); i++) { SCM ops = (i == path.size () -1) ? operations : SCM_EOL; - Translator_group * new_group + Context * new_group = path[i]->instantiate (ops); if (i == path.size () -1) @@ -66,7 +152,7 @@ Translator_group::find_create_translator (SCM n, String id, SCM operations) new_group->id_string_ = id; } - current->add_fresh_group_translator (new_group); + current->add_context (new_group); apply_property_operations (new_group, ops); current = new_group; @@ -75,9 +161,9 @@ Translator_group::find_create_translator (SCM n, String id, SCM operations) return current; } - Translator_group *ret = 0; - if (daddy_trans_) - ret = daddy_trans_->find_create_translator (n, id, operations); + Context *ret = 0; + if (daddy_context_) + ret = daddy_context_->find_create_context (n, id, operations); else { warning (_f ("Cannot find or create `%s' called `%s'", @@ -92,7 +178,7 @@ Translator_group::find_create_translator (SCM n, String id, SCM operations) none. */ SCM -default_child_context_name (Translator_group const *tg) +default_child_context_name (Context const *tg) { return gh_pair_p (tg->accepts_list_) ? ly_car (scm_last_pair (tg->accepts_list_)) @@ -101,18 +187,18 @@ default_child_context_name (Translator_group const *tg) bool -Translator_group::is_bottom_context () const +Context::is_bottom_context () const { return !gh_symbol_p (default_child_context_name (this)); } -Translator_group* -Translator_group::get_default_interpreter () +Context* +Context::get_default_interpreter () { if (!is_bottom_context ()) { SCM nm = default_child_context_name (this); - SCM st = get_output_def ()->find_translator (nm); + SCM st = get_output_def ()->find_context_def (nm); Context_def *t = unsmob_context_def (st); if (!t) @@ -120,8 +206,8 @@ Translator_group::get_default_interpreter () warning (_f ("can't find or create: `%s'", ly_symbol2string (nm).to_str0 ())); t = unsmob_context_def (this->definition_); } - Translator_group *tg = t->instantiate (SCM_EOL); - add_fresh_group_translator (tg); + Context *tg = t->instantiate (SCM_EOL); + add_context (tg); if (!tg->is_bottom_context ()) return tg->get_default_interpreter (); else @@ -133,35 +219,35 @@ Translator_group::get_default_interpreter () /* PROPERTIES */ -Translator_group* -Translator_group::where_defined (SCM sym) const +Context* +Context::where_defined (SCM sym) const { if (properties_dict ()->contains (sym)) { - return (Translator_group*)this; + return (Context*)this; } - return (daddy_trans_) ? daddy_trans_->where_defined (sym) : 0; + return (daddy_context_) ? daddy_context_->where_defined (sym) : 0; } /* return SCM_EOL when not found. */ SCM -Translator_group::internal_get_property (SCM sym) const +Context::internal_get_property (SCM sym) const { SCM val =SCM_EOL; if (properties_dict ()->try_retrieve (sym, &val)) return val; - if (daddy_trans_) - return daddy_trans_->internal_get_property (sym); + if (daddy_context_) + return daddy_context_->internal_get_property (sym); return val; } bool -Translator_group::is_alias (SCM sym) const +Context::is_alias (SCM sym) const { if (sym == ly_symbol2scm ("Bottom") && !gh_pair_p (accepts_list_)) @@ -170,7 +256,7 @@ Translator_group::is_alias (SCM sym) const } void -Translator_group::internal_set_property (SCM sym, SCM val) +Context::internal_set_property (SCM sym, SCM val) { #ifndef NDEBUG if (internal_type_checking_global_b) @@ -184,8 +270,171 @@ Translator_group::internal_set_property (SCM sym, SCM val) TODO: look up to check whether we have inherited var? */ void -Translator_group::unset_property (SCM sym) +Context::unset_property (SCM sym) { properties_dict ()->remove (sym); } +/** + Remove a context from the hierarchy. + */ +Context * +Context::remove_context (Context*trans) +{ + assert (trans); + + context_list_ = scm_delq_x (trans->self_scm (), context_list_); + trans->daddy_context_ = 0; + return trans; +} + +/* + ID == "" means accept any ID. + */ +Context * +find_context_below (Context * where, + String type, String id) +{ + if (where->is_alias (ly_symbol2scm (type.to_str0 ()))) + { + if (id == "" || where->id_string_ == id) + return where; + } + + Context * found = 0; + for (SCM s = where->context_list_; + !found && gh_pair_p (s); s = gh_cdr (s)) + { + Context * tr = unsmob_context (gh_car (s)); + + found = find_context_below (tr, type, id); + } + + return found; +} + +SCM +Context::properties_as_alist () const +{ + return properties_dict()->to_alist(); +} + +String +Context::context_name () const +{ + Context_def * td = unsmob_context_def (definition_ ); + return ly_symbol2string (td->get_context_name ()); +} + + +Score_context* +Context::get_score_context () const +{ + if (Score_context *sc =dynamic_cast ((Context*)this)) + return sc; + else if (daddy_context_) + return daddy_context_->get_score_context (); + else + return 0; +} + +Music_output_def * +Context::get_output_def () const +{ + return (daddy_context_) + ? daddy_context_->get_output_def () : 0; +} + +Context::~Context() +{ + +} + +Moment +Context::now_mom () const +{ + return daddy_context_->now_mom(); +} + +int +Context::print_smob (SCM s, SCM port, scm_print_state *) +{ + Context *sc = (Context *) ly_cdr (s); + + scm_puts ("#<", port); + scm_puts (classname (sc), port); + if (Context_def *d=unsmob_context_def (sc->definition_)) + { + scm_puts (" ", port); + scm_display (d->get_context_name (), port); + } + + if (Context *td=dynamic_cast (sc)) + { + scm_puts ("=", port); + scm_puts (td->id_string_.to_str0 (), port); + } + + + scm_puts (" ", port); + scm_display (sc->implementation_, port); + +#if 0 + Translator * tr = unsmob_translator (sc->implementation_); + if (Translator_group *tg = dynamic_cast (tr)) + scm_display (tg->get_simple_trans_list (), port); +#endif + + /* + don't try to print properties, that is too much hassle. + */ + scm_puts (" >", port); + + return 1; +} + +SCM +Context::mark_smob (SCM sm) +{ + Context * me = (Context*) SCM_CELL_WORD_1 (sm); + + scm_gc_mark (me->context_list_); + scm_gc_mark (me->definition_); + scm_gc_mark (me->properties_scm_); + scm_gc_mark (me->accepts_list_); + scm_gc_mark (me->implementation_); + + return me->properties_scm_; +} + +IMPLEMENT_SMOBS (Context); +IMPLEMENT_DEFAULT_EQUAL_P (Context); +IMPLEMENT_TYPE_P(Context,"ly:context?"); + +bool +Context::try_music (Music* m) +{ + Translator* t = unsmob_translator (implementation_); + if (!t) + return false; + + bool b = t->try_music (m); + if (!b && daddy_context_) + b = daddy_context_->try_music (m); + + return b; +} + + +Global_context* +Context::get_global_context () const +{ + if (dynamic_cast((Context*) this)) + return dynamic_cast ((Context*) this); + + if (daddy_context_) + return daddy_context_->get_global_context (); + + programming_error ("No Global context!"); + return 0; +} diff --git a/lily/custos.cc b/lily/custos.cc index 7b2300ca7e..80071f70b4 100644 --- a/lily/custos.cc +++ b/lily/custos.cc @@ -109,5 +109,5 @@ Custos::print (SCM smob) } ADD_INTERFACE (Custos, "custos-interface", - "Engrave custodes", + "A custos object.", "style adjust-if-on-staffline neutral-direction neutral-position"); diff --git a/lily/dot-column.cc b/lily/dot-column.cc index 4cb993c719..cb7e96c56c 100644 --- a/lily/dot-column.cc +++ b/lily/dot-column.cc @@ -310,6 +310,8 @@ Dot_column::add_head (Grob * me, Grob *rh) ADD_INTERFACE (Dot_column, "dot-column-interface", - "Interface that groups dots so they form a column", - "positioning-done direction stem"); + "Groups dot objects so they form a column, and position dots so they do not " + "clash with staff lines " + , + "positioning-done direction stem"); diff --git a/lily/dots.cc b/lily/dots.cc index f87c719e3b..049ec03026 100644 --- a/lily/dots.cc +++ b/lily/dots.cc @@ -53,9 +53,9 @@ Dots::print (SCM d) ADD_INTERFACE (Dots, "dots-interface", - "The dots to go with a notehead/rest. A separate interface, since they " -" are a party in collision resolution. " -" #'direction is the Direction to handle staff-line collisions in.", - "direction dot-count"); + "The dots to go with a notehead or rest." + "@code{direction} sets the preferred direction to move in case of staff " + "line collisions.", + "direction dot-count"); diff --git a/lily/drum-note-engraver.cc b/lily/drum-note-engraver.cc index 54cc484539..834b7fd74a 100644 --- a/lily/drum-note-engraver.cc +++ b/lily/drum-note-engraver.cc @@ -106,7 +106,7 @@ Drum_notes_engraver::process_music () Item *p = make_item ("Script"); SCM desc = SCM_EOL; make_script_from_event (p, &desc, - daddy_trans_, script, + daddy_context_, script, 0); if (p->get_grob_property ("follow-into-staff")) diff --git a/lily/drum-note-performer.cc b/lily/drum-note-performer.cc index 6532e48f43..dcbc4f3320 100644 --- a/lily/drum-note-performer.cc +++ b/lily/drum-note-performer.cc @@ -10,7 +10,7 @@ #include "event.hh" #include "audio-item.hh" #include "audio-column.hh" -#include "global-translator.hh" +#include "global-context.hh" #include "warn.hh" class Drum_note_performer : public Performer { @@ -21,8 +21,6 @@ protected: virtual bool try_music (Music *ev) ; virtual void stop_translation_timestep (); virtual void create_audio_elements (); - - Global_translator* get_global_translator (); private: Link_array note_evs_; Link_array notes_; @@ -57,28 +55,12 @@ Drum_note_performer::create_audio_elements () note_evs_.clear (); } -Global_translator* -Drum_note_performer::get_global_translator () -{ - Translator *t = this; - Global_translator *global =0; - do - { - t = t->daddy_trans_ ; - global = dynamic_cast (t); - } - while (!global); - - return global; -} - - void Drum_note_performer::stop_translation_timestep () { // why don't grace notes show up here? // --> grace notes effectively do not get delayed - Global_translator* global = get_global_translator (); + Global_context * global = get_global_context (); for (int i=0; i < notes_.size (); i++) { Audio_note* n = notes_[i]; diff --git a/lily/dynamic-engraver.cc b/lily/dynamic-engraver.cc index cec29c0867..e2b73d2890 100644 --- a/lily/dynamic-engraver.cc +++ b/lily/dynamic-engraver.cc @@ -16,7 +16,7 @@ #include "engraver.hh" #include "group-interface.hh" #include "directional-element-interface.hh" -#include "translator-group.hh" +#include "context.hh" #include "axis-group-interface.hh" #include "script.hh" @@ -239,7 +239,7 @@ Dynamic_engraver::process_music () { cresc_ = make_spanner ("TextSpanner"); cresc_->set_grob_property ("style", s); - daddy_trans_->set_property ((start_type + daddy_context_->set_property ((start_type + "Spanner").to_str0 (), SCM_EOL); s = get_property ((start_type + "Text").to_str0 ()); /* @@ -249,7 +249,7 @@ Dynamic_engraver::process_music () { cresc_->set_grob_property ("edge-text", gh_cons (s, scm_makfrom0str (""))); - daddy_trans_->set_property ((start_type + "Text").to_str0 (), + daddy_context_->set_property ((start_type + "Text").to_str0 (), SCM_EOL); } } diff --git a/lily/engraver-group-engraver.cc b/lily/engraver-group-engraver.cc index 0cbdd68c08..26201fb3be 100644 --- a/lily/engraver-group-engraver.cc +++ b/lily/engraver-group-engraver.cc @@ -12,25 +12,17 @@ #include "warn.hh" #include "paper-score.hh" #include "grob.hh" +#include "context.hh" + + void Engraver_group_engraver::announce_grob (Grob_info info) { announce_infos_.push (info); - Engraver::announce_grob (info); + get_daddy_engraver ()->announce_grob (info); } -void -Engraver_group_engraver::process_acknowledged_grobs_in_simple_children () -{ - for (SCM p = get_simple_trans_list (); gh_pair_p (p); p = ly_cdr (p)) - { - Translator * t = unsmob_translator (ly_car (p)); - Engraver * eng = dynamic_cast (t); - if (eng) - eng->process_acknowledged_grobs (); - } -} SCM find_acknowledge_engravers (SCM gravlist, SCM meta); SCM find_accept_engravers (SCM gravlist, SCM music_descr); @@ -79,66 +71,37 @@ Engraver_group_engraver::acknowledge_grobs () { Translator * t = unsmob_translator (ly_car (p)); Engraver * eng = dynamic_cast (t); - if (eng && eng!= info.origin_trans_) + if (eng && eng != info.origin_trans_) eng->acknowledge_grob (info); } } } + void Engraver_group_engraver::do_announces () { - for (SCM p = trans_group_list_; gh_pair_p (p); p =ly_cdr (p)) + do { - Translator * t = unsmob_translator (ly_car (p)); - dynamic_cast (t)->do_announces (); - } + engraver_each (get_simple_trans_list (), + &Engraver::process_acknowledged_grobs); + + if (!announce_infos_.size()) + break; - process_acknowledged_grobs_in_simple_children (); - - do - { acknowledge_grobs (); announce_infos_.clear (); - process_acknowledged_grobs_in_simple_children (); } - while (announce_infos_.size ()); + while (1); } -/* - order is : top to bottom (as opposed to do_announces) - */ -void -Engraver_group_engraver::process_music () -{ - for (SCM p = get_simple_trans_list (); gh_pair_p (p); p =ly_cdr (p)) - { - Translator * t = unsmob_translator (ly_car (p)); - Engraver * eng = dynamic_cast (t); - - if (eng) - eng->process_music (); - } - for (SCM p = trans_group_list_; gh_pair_p (p); p =ly_cdr (p)) - { - Translator * t = unsmob_translator (ly_car (p)); - Engraver*eng = dynamic_cast (t); - if (eng) - eng->process_music (); - } -} - void Engraver_group_engraver::initialize () { - /* - docme: why bool_f. - - */ SCM tab = scm_make_vector (gh_int2scm (61), SCM_BOOL_F); - set_property ("acknowledgeHashTable", tab); + daddy_context_->set_property ("acknowledgeHashTable", tab); Translator_group::initialize (); } @@ -189,3 +152,44 @@ find_acknowledge_engravers (SCM gravlist, SCM meta_alist) } +/* c&p engraver-group.cc */ +void +recurse_down_engravers (Context * c, Engraver_method ptr, bool context_first) +{ + Engraver_group_engraver * tg + = dynamic_cast (unsmob_translator (c->implementation_)); + + + if (!context_first) + { + engraver_each (tg->get_simple_trans_list (), + ptr); + + (tg->*ptr) (); + } + + for (SCM s = c->context_list_ ; gh_pair_p (s); + s =gh_cdr (s)) + { + recurse_down_engravers (unsmob_context (gh_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; gh_pair_p (p); p = ly_cdr (p)) + { + Engraver * e = dynamic_cast(unsmob_translator (ly_car (p))); + if (e) + (e->*method) (); + } +} diff --git a/lily/engraver.cc b/lily/engraver.cc index d8338972c9..201f44655f 100644 --- a/lily/engraver.cc +++ b/lily/engraver.cc @@ -14,13 +14,22 @@ #include "warn.hh" #include "spanner.hh" #include "item.hh" +#include "context.hh" +#include "score-context.hh" + +Engraver_group_engraver* +Engraver::get_daddy_engraver () const +{ + return dynamic_cast (get_daddy_translator ()); +} void Engraver::announce_grob (Grob_info inf) { - get_daddy_grav ()->announce_grob (inf); + get_daddy_engraver ()->announce_grob (inf); } + /* CAUSE is the object (typically a Music object) that was the reason for making E. @@ -40,9 +49,7 @@ Engraver::announce_grob (Grob* e, SCM cause) if (!i.origin_trans_) i.origin_trans_ = this; - - - get_daddy_grav ()->announce_grob (i); + get_daddy_engraver ()->announce_grob (i); } @@ -50,17 +57,11 @@ Engraver::announce_grob (Grob* e, SCM cause) void Engraver::typeset_grob (Grob*p) { - get_daddy_grav ()->typeset_grob (p); + Engraver *dad = get_daddy_engraver (); + dad->typeset_grob (p); } -Engraver_group_engraver* -Engraver::get_daddy_grav () const -{ - return (daddy_trans_) - ? dynamic_cast (daddy_trans_) - : 0; -} void Engraver::process_music () @@ -73,9 +74,16 @@ Engraver::Engraver() Score_engraver* -Engraver::top_engraver () const +Engraver::get_score_engraver () const +{ + SCM t = get_score_context ()->implementation_; + return dynamic_cast (unsmob_translator (t)); +} + + +void +Engraver::do_announces () { - return dynamic_cast (top_translator()); } ENTER_DESCRIPTION(Engraver, diff --git a/lily/event-chord-iterator.cc b/lily/event-chord-iterator.cc index 29713a52dc..09a847bb24 100644 --- a/lily/event-chord-iterator.cc +++ b/lily/event-chord-iterator.cc @@ -6,7 +6,7 @@ (c) 1997--2004 Han-Wen Nienhuys */ -#include "translator-group.hh" +#include "context.hh" #include "warn.hh" #include "event-chord-iterator.hh" #include "music-list.hh" @@ -16,7 +16,7 @@ Event_chord_iterator::Event_chord_iterator () { } -Translator_group* +Context * Event_chord_iterator::get_req_translator () { assert (get_outlet ()); diff --git a/lily/figured-bass-engraver.cc b/lily/figured-bass-engraver.cc index dcd9e4ed20..91023c09a6 100644 --- a/lily/figured-bass-engraver.cc +++ b/lily/figured-bass-engraver.cc @@ -11,7 +11,7 @@ source file of the GNU LilyPond music typesetter #include "text-item.hh" #include "event.hh" #include "item.hh" -#include "translator-group.hh" +#include "context.hh" class Figured_bass_engraver : public Engraver { @@ -82,7 +82,7 @@ Figured_bass_engraver::process_music () for (int i = 0; i self_scm(), l); - SCM markup = scm_call_2 (proc, l, daddy_trans_->self_scm ()); + SCM markup = scm_call_2 (proc, l, daddy_context_->self_scm ()); figure_ = make_item ("BassFigure"); figure_->set_grob_property ("text", markup); diff --git a/lily/folded-repeat-iterator.cc b/lily/folded-repeat-iterator.cc index 8f0a89f0ce..4767976066 100644 --- a/lily/folded-repeat-iterator.cc +++ b/lily/folded-repeat-iterator.cc @@ -7,12 +7,12 @@ */ - +#include "input.hh" #include "folded-repeat-iterator.hh" #include "repeated-music.hh" #include "music-list.hh" #include "simultaneous-music-iterator.hh" -#include "translator-group.hh" +#include "context.hh" Folded_repeat_iterator::Folded_repeat_iterator () { @@ -140,7 +140,7 @@ Folded_repeat_iterator::derived_mark()const } void -Folded_repeat_iterator::derived_substitute (Translator_group*f, Translator_group*t) +Folded_repeat_iterator::derived_substitute (Context *f, Context *t) { if (main_iter_) main_iter_->substitute_outlet (f,t); diff --git a/lily/font-size-engraver.cc b/lily/font-size-engraver.cc index 7ef99111b4..dfc08b45c4 100644 --- a/lily/font-size-engraver.cc +++ b/lily/font-size-engraver.cc @@ -33,7 +33,7 @@ Font_size_engraver::acknowledge_grob (Grob_info gi) /* We only want to process a grob once. */ - if (gi.origin_trans_->daddy_trans_ != daddy_trans_) + if (gi.origin_trans_->daddy_context_ != daddy_context_) return ; if (gh_number_p (sz) && gh_scm2double (sz)) diff --git a/lily/forbid-break-engraver.cc b/lily/forbid-break-engraver.cc index 461b55e9d8..dbaad08568 100644 --- a/lily/forbid-break-engraver.cc +++ b/lily/forbid-break-engraver.cc @@ -38,7 +38,7 @@ Forbid_line_break_engraver::start_translation_timestep() Grob *g = unsmob_grob (gh_cdar (busy)); if (Rhythmic_head::has_interface (g)) { - top_engraver()->forbid_breaks(); + get_score_engraver()->forbid_breaks(); } busy = gh_cdr(busy); } diff --git a/lily/global-context.cc b/lily/global-context.cc new file mode 100644 index 0000000000..154aca011d --- /dev/null +++ b/lily/global-context.cc @@ -0,0 +1,184 @@ +/* + global-translator.cc -- implement global_context + + source file of the GNU LilyPond music typesetter + + (c) 1997--2004 Han-Wen Nienhuys +*/ +#include + +#include "warn.hh" +#include "music.hh" +#include "event.hh" +#include "music-list.hh" +#include "music-iterator.hh" +#include "global-context.hh" +#include "score-context.hh" +#include "context-def.hh" +#include "music-output-def.hh" + +Global_context::Global_context (Music_output_def*o) +{ + output_def_ = o; + accepts_list_ = scm_list_n (ly_symbol2scm ("Score"), + SCM_UNDEFINED); + definition_ = o->find_context_def (ly_symbol2scm ("Global")); +} + +Music_output_def* +Global_context::get_output_def () const +{ + return output_def_; +} + +void +Global_context::add_moment_to_process (Moment m) +{ + if (m > final_mom_) + return; + + if (m < now_mom_) + programming_error ("Trying to freeze in time."); + + for (int i=0; i < extra_mom_pq_.size (); i++) + if (extra_mom_pq_[i] == m) + return; + extra_mom_pq_.insert (m); +} + +Moment +Global_context::sneaky_insert_extra_moment (Moment w) +{ + while (extra_mom_pq_.size () && extra_mom_pq_.front () <= w) + w = extra_mom_pq_.get (); + return w; +} + +int +Global_context::get_moments_left () const +{ + return extra_mom_pq_.size (); +} + +void +Global_context::prepare (Moment m) +{ + prev_mom_ = now_mom_; + now_mom_ = m; + + if (get_score_context ()) + get_score_context ()->prepare (m); +} + +Moment +Global_context::now_mom () const +{ + return now_mom_; +} + +Score_context* +Global_context::get_score_context () const +{ + return (gh_pair_p (context_list_)) + ? dynamic_cast (unsmob_context (gh_car (context_list_))) + : 0; +} + +Music_output* +Global_context::get_output () +{ + return get_score_context ()->get_output (); +} + +void +Global_context::one_time_step () +{ + get_score_context ()->one_time_step (); + apply_finalizations (); + check_removal (); +} + +void +Global_context::finish () +{ + if (get_score_context ()) + get_score_context ()->finish (); +} + +void +Global_context::run_iterator_on_me (Music_iterator * iter) +{ + if (iter-> ok ()) + prev_mom_ = now_mom_ = iter->pending_moment (); + + bool first = true; + while (iter->ok () || get_moments_left ()) + { + Moment w; + w.set_infinite (1); + if (iter->ok ()) + { + w = iter->pending_moment (); + } + + w = sneaky_insert_extra_moment (w); + if (w.main_part_.is_infinity ()) + break ; + +#if 0 + // printf ("proccing %s\n ", w.to_string ().to_str0 ()); + if (first) + { + /* + Huh? + */ + set_property ("measurePosition", w.smobbed_copy ()); + } +#endif + + prepare (w); + + if (iter->ok ()) + iter->process (w); + + if (!get_score_context ()) + { + SCM key = ly_symbol2scm ("Score"); + Context_def * t = unsmob_context_def (get_output_def () + ->find_context_def (key)); + if (!t) + error (_f ("can't find `%s' context", "Score")); + + add_context (t->instantiate (SCM_EOL)); + + Score_context *sc = dynamic_cast (t); + sc->prepare (w); + } + + one_time_step (); + first = false; + } +} + +void +Global_context::apply_finalizations () +{ + SCM lst = get_property ("finalizations"); + set_property ("finalizations" , SCM_EOL); + for (SCM s = lst ; gh_pair_p (s); s = gh_cdr (s)) + { + scm_primitive_eval (gh_car (s)); + } +} + +/* + Add a function to execute before stepping to the next time step. + */ +void +Global_context::add_finalization (SCM x) +{ + SCM lst = get_property ("finalizations"); + lst = scm_cons (x, lst); + set_property ("finalizations" ,lst); +} + diff --git a/lily/global-translator.cc b/lily/global-translator.cc index 1edda61cbb..e69de29bb2 100644 --- a/lily/global-translator.cc +++ b/lily/global-translator.cc @@ -1,162 +0,0 @@ -/* - global-translator.cc -- implement Global_translator - - source file of the GNU LilyPond music typesetter - - (c) 1997--2004 Han-Wen Nienhuys -*/ -#include - -#include "warn.hh" -#include "music.hh" -#include "event.hh" -#include "music-list.hh" -#include "music-iterator.hh" -#include "global-translator.hh" - -Global_translator::Global_translator () -{ - output_def_ = 0; -} - -Music_output_def* -Global_translator::get_output_def () const -{ - return output_def_; -} - -void -Global_translator::add_moment_to_process (Moment m) -{ - if (m > final_mom_) - return; - - if (m < now_mom_) - programming_error ("Trying to freeze in time."); - - for (int i=0; i < extra_mom_pq_.size (); i++) - if (extra_mom_pq_[i] == m) - return; - extra_mom_pq_.insert (m); -} - -Moment -Global_translator::sneaky_insert_extra_moment (Moment w) -{ - while (extra_mom_pq_.size () && extra_mom_pq_.front () <= w) - w = extra_mom_pq_.get (); - return w; -} - -int -Global_translator::get_moments_left () const -{ - return extra_mom_pq_.size (); -} - -void -Global_translator::prepare (Moment m) -{ - prev_mom_ = now_mom_; - now_mom_ = m; -} - -Moment -Global_translator::now_mom () const -{ - return now_mom_; -} - - - -Music_output* -Global_translator::get_output () -{ - return 0; -} - -void -Global_translator::one_time_step () -{ -} - -void -Global_translator::start () -{ -} -void -Global_translator::finish () -{ -} - -void -Global_translator::run_iterator_on_me (Music_iterator * iter) -{ - if (iter-> ok ()) - prev_mom_ = now_mom_ = iter->pending_moment (); - - bool first = true; - while (iter->ok () || get_moments_left ()) - { - Moment w; - w.set_infinite (1); - if (iter->ok ()) - { - w = iter->pending_moment (); - } - - w = sneaky_insert_extra_moment (w); - if (w.main_part_.is_infinity ()) - break ; - - - // printf ("proccing %s\n ", w.to_string ().to_str0 ()); - if (first) - { - first = false; - set_property ("measurePosition", w.smobbed_copy ()); - } - - prepare (w); - if (iter->ok ()) - iter->process (w); - - one_time_step (); - } -} - -void -Global_translator::apply_finalizations () -{ - SCM lst = get_property ("finalizations"); - set_property ("finalizations" , SCM_EOL); - for (SCM s = lst ; gh_pair_p (s); s = gh_cdr (s)) - { - scm_primitive_eval (gh_car (s)); - } -} - -/* - Add a function to execute before stepping to the next time step. - */ -void -Global_translator::add_finalization (SCM x) -{ - SCM lst = get_property ("finalizations"); - lst = scm_cons (x, lst); - set_property ("finalizations" ,lst); -} - - -Global_translator * -Translator::top_translator()const -{ - if (dynamic_cast((Translator*)this)) - return dynamic_cast ((Translator*)this); - - if (daddy_trans_) - return daddy_trans_->top_translator (); - - programming_error ("No top translator!"); - return 0; -} diff --git a/lily/grace-iterator.cc b/lily/grace-iterator.cc index 9f394c6176..3611d5fcac 100644 --- a/lily/grace-iterator.cc +++ b/lily/grace-iterator.cc @@ -11,7 +11,7 @@ #include "grace-iterator.hh" -#include "global-translator.hh" +#include "global-context.hh" #include "warn.hh" void diff --git a/lily/grob-info.cc b/lily/grob-info.cc index 6d57705f9f..f4042ec296 100644 --- a/lily/grob-info.cc +++ b/lily/grob-info.cc @@ -10,7 +10,7 @@ #include "grob-info.hh" #include "music.hh" #include "translator-group.hh" - +#include "context.hh" Grob_info::Grob_info () { @@ -25,15 +25,15 @@ Grob_info::music_cause () return unsmob_music (cause); } -Link_array -Grob_info::origin_transes (Translator* end) const +Link_array +Grob_info::origin_contexts (Translator* end) const { - Translator * t = origin_trans_; - Link_array r; + Context * t = origin_trans_->daddy_context_; + Link_array r; do { r.push (t); - t = t->daddy_trans_; - } while (t && t != end->daddy_trans_); + t = t->daddy_context_; + } while (t && t != end->daddy_context_); return r; } diff --git a/lily/grob-pq-engraver.cc b/lily/grob-pq-engraver.cc index c681814026..4fdf5d2b4f 100644 --- a/lily/grob-pq-engraver.cc +++ b/lily/grob-pq-engraver.cc @@ -6,7 +6,7 @@ (c) 2001--2004 Han-Wen Nienhuys */ -#include "translator-group.hh" +#include "context.hh" #include "engraver.hh" #include "grob.hh" #include "warn.hh" @@ -56,7 +56,7 @@ Grob_pq_engraver::Grob_pq_engraver() void Grob_pq_engraver::initialize () { - daddy_trans_->set_property ("busyGrobs", SCM_EOL); + daddy_context_->set_property ("busyGrobs", SCM_EOL); } void @@ -117,7 +117,7 @@ Grob_pq_engraver::stop_translation_timestep () busy = scm_merge_x (current_list, busy, ly_grob_pq_less_p_proc); current_grobs_.clear (); - daddy_trans_->set_property ("busyGrobs", busy); + daddy_context_->set_property ("busyGrobs", busy); } void @@ -139,7 +139,7 @@ Grob_pq_engraver::start_translation_timestep () } if (start_busy != busy) - daddy_trans_->set_property ("busyGrobs", busy); + daddy_context_->set_property ("busyGrobs", busy); } diff --git a/lily/grob-scheme.cc b/lily/grob-scheme.cc index 53d2c608f4..ca3c5ef046 100644 --- a/lily/grob-scheme.cc +++ b/lily/grob-scheme.cc @@ -29,20 +29,6 @@ LY_DEFINE (ly_get_grob_property, "Grob properties are stored as GUILE association lists, with symbols as\n" "keys. All lookup functions identify undefined properties with\n" "end-of-list (i.e. @code{'()} in Scheme or @code{SCM_EOL} in C)\n" -"\n" -"Properties are stored in two ways:\n" -"@itemize @bullet\n" -"@item mutable properties.\n" -"Grob properties that change from object to object. The storage of\n" -"these are private to a grob. For example pointers to other grobs are\n" -"always stored in the mutable properties.\n" -"\n" -"@item immutable properties.\n" -"Grob properties that are shared across different grobs of the same\n" -"type. The storage is shared, and hence it is read-only. Typically, this\n" -"is used to store function callbacks, and default settings. They are\n" -"initially read from @file{scm/grob-description.scm}.\n" -"@end itemize\n" "\n") { Grob * sc = unsmob_grob (grob); @@ -135,7 +121,7 @@ LY_DEFINE (ly_get_system, LY_DEFINE (ly_get_original, "ly:get-original", 1, 0, 0, (SCM grob), - "Return the original Grob of @var{grob}") + "Return the unbroken original Grob of @var{grob}.") { Grob *me = unsmob_grob (grob); SCM_ASSERT_TYPE (me, grob, SCM_ARG1, __FUNCTION__, "grob"); diff --git a/lily/grob.cc b/lily/grob.cc index 57d0b00a33..60acbdb54f 100644 --- a/lily/grob.cc +++ b/lily/grob.cc @@ -599,7 +599,7 @@ Grob::name () const void Grob::add_offset_callback (SCM cb, Axis a) { - if (!has_offset_callback_b (cb, a)) + if (!has_offset_callback (cb, a)) { dim_cache_[a].offset_callbacks_ = gh_cons (cb, dim_cache_[a].offset_callbacks_); dim_cache_[a].offsets_left_ ++; @@ -607,14 +607,14 @@ Grob::add_offset_callback (SCM cb, Axis a) } bool -Grob::has_extent_callback_b (SCM cb, Axis a)const +Grob::has_extent_callback (SCM cb, Axis a)const { return scm_equal_p (cb, dim_cache_[a].dimension_) == SCM_BOOL_T; } bool -Grob::has_offset_callback_b (SCM cb, Axis a)const +Grob::has_offset_callback (SCM cb, Axis a)const { return scm_memq (cb, dim_cache_[a].offset_callbacks_) != SCM_BOOL_F; } @@ -819,7 +819,7 @@ ADD_INTERFACE (Grob, "grob-interface", "\n" "Grobs have a properties: Scheme variables, that can be read and set. " "They have two types. Immutable variables " - "define the default style and behavior. They are shared between many objects " + "define the default style and behavior. They are shared between many objects. " "They can be changed using @code{\\override} and @code{\\revert}. " "\n\n" "Mutable properties are variables that are specific to one grob. Typically, " diff --git a/lily/hairpin.cc b/lily/hairpin.cc index fcb3c621da..42bd74e54e 100644 --- a/lily/hairpin.cc +++ b/lily/hairpin.cc @@ -135,6 +135,6 @@ Hairpin::print (SCM smob) ADD_INTERFACE (Hairpin, "hairpin-interface", - "hairpin crescendo.", + "A hairpin (de)crescendo.", "grow-direction height if-text-padding"); diff --git a/lily/hara-kiri-group-spanner.cc b/lily/hara-kiri-group-spanner.cc index b5071cc815..eacd67fd7a 100644 --- a/lily/hara-kiri-group-spanner.cc +++ b/lily/hara-kiri-group-spanner.cc @@ -101,9 +101,9 @@ Hara_kiri_group_spanner::add_interesting_item (Grob* me,Grob* n) ADD_INTERFACE (Hara_kiri_group_spanner,"hara-kiri-group-interface", - " As Vertical_group_spanner, but keep track of interesting items. If \ -we don't contain any interesting items after linebreaking, then \ -gracefully commit suicide. Objective: don't disgrace Lily by \ -typesetting empty lines in orchestral scores.", \ - "items-worth-living remove-first"); + "A group spanner that keeps track of interesting items. If it " + "doesn't contain any after linebreaking, then it " + "will remove itself and all its children." + , + "items-worth-living remove-first"); diff --git a/lily/include/audio-element-info.hh b/lily/include/audio-element-info.hh index 1d3479ecaa..bc95f413c8 100644 --- a/lily/include/audio-element-info.hh +++ b/lily/include/audio-element-info.hh @@ -16,11 +16,13 @@ /** Data container for broadcasts */ -struct Audio_element_info { +class Audio_element_info { +public: Audio_element * elem_; Music *event_; - Translator * origin_trans_; - Link_array origin_transes (Translator*) const; + Translator *origin_trans_; + + Link_array origin_contexts (Translator*) const; Audio_element_info (Audio_element*, Music*); Audio_element_info (); diff --git a/lily/include/chord-tremolo-iterator.hh b/lily/include/chord-tremolo-iterator.hh index 667b8e02d6..233af0a9bc 100644 --- a/lily/include/chord-tremolo-iterator.hh +++ b/lily/include/chord-tremolo-iterator.hh @@ -19,7 +19,7 @@ public: Chord_tremolo_iterator (); Chord_tremolo_iterator (Chord_tremolo_iterator const & ); protected: - virtual void derived_substitute (Translator_group*f, Translator_group*t) ; + virtual void derived_substitute (Context *f, Context *t) ; virtual void derived_mark () const; virtual Moment pending_moment () const; diff --git a/lily/include/context-def.hh b/lily/include/context-def.hh index 0011b7c7c8..a1d9bc3d93 100644 --- a/lily/include/context-def.hh +++ b/lily/include/context-def.hh @@ -41,15 +41,15 @@ public: SCM get_translator_names (SCM) const; void set_acceptor (SCM accepts, bool add); - Link_array path_to_acceptable_translator (SCM type_string, Music_output_def* odef) const; - Translator_group * instantiate (SCM extra_ops); + Link_array path_to_acceptable_context (SCM type_string, Music_output_def* odef) const; + Context * instantiate (SCM extra_ops); SCM to_alist () const; bool is_alias (SCM) const; static SCM make_scm () ; SCM clone_scm ()const; - void apply_default_property_operations (Translator_group*); + void apply_default_property_operations (Context *); private: DECLARE_SMOBS (Context_def,foo); Context_def (); diff --git a/lily/include/context.hh b/lily/include/context.hh index e69de29bb2..09015d26ec 100644 --- a/lily/include/context.hh +++ b/lily/include/context.hh @@ -0,0 +1,91 @@ +/* + context.hh -- declare Context + + source file of the GNU LilyPond music typesetter + + (c) 2004 Han-Wen Nienhuys + */ + +#ifndef CONTEXT_HH +#define CONTEXT_HH + +#include "moment.hh" +#include "lily-proto.hh" + + +class Context +{ + Scheme_hash_table *properties_dict () const; + Context (Context const &src); + + DECLARE_SMOBS (Context, dummy); + + void terminate (); +public: + SCM definition_; + SCM properties_scm_; + SCM context_list_; + SCM accepts_list_; + Context * daddy_context_; + + Context (); + void execute_pushpop_property (SCM prop, SCM sym, SCM val); + SCM internal_get_property (SCM name_sym) const; + + Context *remove_context (Context*trans); + void check_removal (); + + SCM properties_as_alist () const; + void unset_property (SCM var_sym); + void internal_set_property (SCM var_sym, SCM value); + + Context *where_defined (SCM name_sym) const; + String context_name () const; + Global_context * get_global_context () const; + + virtual Score_context * get_score_context () const; + bool is_alias (SCM) const; + void add_context (Context *trans); + bool is_bottom_context () const; + bool is_removable () const; + bool try_music (Music *); + + virtual Music_output_def *get_output_def () const; + virtual Moment now_mom () const; + Context *find_existing_context (SCM context_name, String id); + Context *find_create_context (SCM context_name, + String id, SCM ops); + Link_array path_to_acceptable_context (SCM alias, + Music_output_def*) const; + Context *get_default_interpreter (); + String id_string_; + + SCM implementation_; +private: + friend class Interpretation_context_handle; + int iterator_count_; + bool init_; +}; + +/* + Context arg? + */ + +void apply_property_operations (Context*tg, SCM pre_init_ops); +void execute_pushpop_property (Context * trg, SCM prop, SCM eltprop, SCM val); +SCM updated_grob_properties (Context* tg, SCM sym); +Context * find_context_below (Context * where, + String type, String id); + +Context * unsmob_context (SCM); + +#define set_property(x,y) internal_set_property(ly_symbol2scm(x),y) + +/* + C&P! + */ +#define get_property(x) internal_get_property(ly_symbol2scm(x)) +DECLARE_UNSMOB(Context,context); + +#endif /* CONTEXT_HH */ + diff --git a/lily/include/engraver-group-engraver.hh b/lily/include/engraver-group-engraver.hh index 4b1da55e8c..f18a60f15f 100644 --- a/lily/include/engraver-group-engraver.hh +++ b/lily/include/engraver-group-engraver.hh @@ -18,17 +18,11 @@ #include "translator-group.hh" -/** - Group a number of engravers. Usually delegates everything to its contents. - Postfix: group - */ -class Engraver_group_engraver : public Engraver, +class Engraver_group_engraver : public virtual Engraver, public virtual Translator_group { protected: Array announce_infos_; - - public: TRANSLATOR_DECLARATIONS(Engraver_group_engraver); @@ -36,12 +30,15 @@ public: virtual void initialize (); virtual void do_announces (); virtual void announce_grob (Grob_info); - virtual void process_music (); private: virtual void acknowledge_grobs (); - virtual void process_acknowledged_grobs_in_simple_children (); }; +typedef void (Engraver::*Engraver_method) (void); + +void recurse_down_engravers (Context * c, Engraver_method ptr, bool context_first); +void engraver_each (SCM list, Engraver_method method); + #endif // ENGRAVERGROUP_HH diff --git a/lily/include/engraver.hh b/lily/include/engraver.hh index 63928813f5..b7dcefb83f 100644 --- a/lily/include/engraver.hh +++ b/lily/include/engraver.hh @@ -48,22 +48,22 @@ protected: virtual void announce_grob (Grob*, SCM cause); virtual void announce_grob (Grob_info); virtual void process_music (); - - Score_engraver * top_engraver () const; - + virtual void do_announces (); + Engraver_group_engraver*get_daddy_engraver () const; public: - Engraver_group_engraver * get_daddy_grav () const; + Score_engraver * get_score_engraver () const; /** override other ctor */ TRANSLATOR_DECLARATIONS(Engraver); }; -#define make_item(x) make_item_from_properties (daddy_trans_, ly_symbol2scm (x)) -#define make_spanner(x) make_spanner_from_properties (daddy_trans_, ly_symbol2scm (x)) -Item* make_item_from_properties (Translator_group* tg, SCM x); -Spanner* make_spanner_from_properties (Translator_group * tg, SCM x); +#define make_item(x) make_item_from_properties (daddy_context_, ly_symbol2scm (x)) +#define make_spanner(x) make_spanner_from_properties (daddy_context_, ly_symbol2scm (x)) +Item* make_item_from_properties (Context * tg, SCM x); +Spanner* make_spanner_from_properties (Context * tg, SCM x); + diff --git a/lily/include/event-chord-iterator.hh b/lily/include/event-chord-iterator.hh index 2dce5d8b3b..27dac49179 100644 --- a/lily/include/event-chord-iterator.hh +++ b/lily/include/event-chord-iterator.hh @@ -21,7 +21,7 @@ class Event_chord_iterator : public Simple_music_iterator /** Find a bottom notation context to deliver events to. */ - virtual Translator_group* get_req_translator (); + virtual Context * get_req_translator (); /* diff --git a/lily/include/folded-repeat-iterator.hh b/lily/include/folded-repeat-iterator.hh index 4ae007d8de..793ef3740a 100644 --- a/lily/include/folded-repeat-iterator.hh +++ b/lily/include/folded-repeat-iterator.hh @@ -24,7 +24,7 @@ public: Folded_repeat_iterator (Folded_repeat_iterator const &src); Folded_repeat_iterator (); virtual void derived_mark () const; - virtual void derived_substitute (Translator_group*f, Translator_group*t) ; + virtual void derived_substitute (Context *f, Context *t) ; virtual void construct_children (); diff --git a/lily/include/global-translator.hh b/lily/include/global-context.hh similarity index 69% rename from lily/include/global-translator.hh rename to lily/include/global-context.hh index 979e398a7b..ba75d26087 100644 --- a/lily/include/global-translator.hh +++ b/lily/include/global-context.hh @@ -1,5 +1,5 @@ /* - global-translator.hh -- declare Global_translator + global-context.hh -- declare Global_context source file of the GNU LilyPond music typesetter @@ -7,35 +7,33 @@ */ -#ifndef GLOBAL_TRANSLATOR_HH -#define GLOBAL_TRANSLATOR_HH +#ifndef GLOBAL_CONTEXT_HH +#define GLOBAL_CONTEXT_HH -#include "translator-group.hh" -#include "moment.hh" +#include "context.hh" #include "pqueue.hh" -class Global_translator : public virtual Translator_group +class Global_context : public virtual Context { PQueue extra_mom_pq_; Music_output_def* output_def_; + friend class Music_output_def; public: - VIRTUAL_COPY_CONS (Translator); - Global_translator (); - + Global_context (Music_output_def*); int get_moments_left () const; Moment sneaky_insert_extra_moment (Moment); void add_moment_to_process (Moment); void run_iterator_on_me (Music_iterator*); - + virtual Score_context*get_score_context () const; + void apply_finalizations (); void add_finalization (SCM); - + virtual Music_output *get_output (); virtual void prepare (Moment); virtual void one_time_step (); virtual void finish (); - virtual void start (); virtual Music_output_def* get_output_def () const; virtual Moment now_mom () const; @@ -47,4 +45,4 @@ protected: -#endif // GLOBAL_TRANSLATOR_HH +#endif // GLOBAL_CONTEXT_HH diff --git a/lily/include/grob-info.hh b/lily/include/grob-info.hh index 0e9de960d2..833aa94158 100644 --- a/lily/include/grob-info.hh +++ b/lily/include/grob-info.hh @@ -14,7 +14,7 @@ #include "lily-proto.hh" #include "parray.hh" -/** +/* Data container for broadcasts. */ struct Grob_info { @@ -25,7 +25,7 @@ struct Grob_info { public: Music * music_cause (); - Link_array origin_transes (Translator*) const; + Link_array origin_contexts (Translator*) const; Grob_info (); }; diff --git a/lily/include/grob.hh b/lily/include/grob.hh index 4a111b233d..f5d47300d5 100644 --- a/lily/include/grob.hh +++ b/lily/include/grob.hh @@ -143,9 +143,9 @@ public: // duh. slim down interface here. (todo) - bool has_offset_callback_b (SCM callback, Axis)const; + bool has_offset_callback (SCM callback, Axis)const; void add_offset_callback (SCM callback, Axis); - bool has_extent_callback_b (SCM, Axis)const; + bool has_extent_callback (SCM, Axis)const; void set_extent (SCM , Axis); Real get_offset (Axis a) const; diff --git a/lily/include/interpretation-context-handle.hh b/lily/include/interpretation-context-handle.hh index b228881730..fef9776023 100644 --- a/lily/include/interpretation-context-handle.hh +++ b/lily/include/interpretation-context-handle.hh @@ -17,18 +17,18 @@ public: ~Interpretation_context_handle (); Interpretation_context_handle (); Interpretation_context_handle* clone () const; - void set_translator (Translator_group*); + void set_translator (Context *); bool try_music (Music *); void operator = (Interpretation_context_handle const&); Interpretation_context_handle (Interpretation_context_handle const&); - Translator_group * get_outlet () const; + Context * get_outlet () const; int get_count () const; void quit (); private: - Translator_group * outlet_; + Context * outlet_; void down (); - void up (Translator_group*); + void up (Context *); }; #endif /* INTERPRETATION_CONTEXT_HANDLE_HH */ diff --git a/lily/include/lily-proto.hh b/lily/include/lily-proto.hh index 659a6b606b..57863cdb80 100644 --- a/lily/include/lily-proto.hh +++ b/lily/include/lily-proto.hh @@ -43,6 +43,7 @@ class Change_translator; class Chord_tremolo_iterator; class Cluster_engraver; class Column_x_positions; +class Context; class Context_specced_music; class Engraver; class Engraver; @@ -50,7 +51,7 @@ class Engraver_group_engraver; class Folded_repeat_iterator; class Font_metric; class Font_size_engraver; -class Global_translator; +class Global_context; class Gourlay_breaking; class Grace_engraver_group; class Grace_iterator; @@ -130,6 +131,7 @@ class Scheme_hash_table; class Score; class Grob; class Score_engraver; +class Score_context; class Score_performer; class Sequential_music; class Sequential_music_iterator; diff --git a/lily/include/ly-smobs.icc b/lily/include/ly-smobs.icc index 4259b862f1..59429c2517 100644 --- a/lily/include/ly-smobs.icc +++ b/lily/include/ly-smobs.icc @@ -16,7 +16,7 @@ void init_type_ ## CL ()\ {\ SCM subr = scm_c_define_gsubr (FUNCNAME, 1, 0, 0, (Scheme_function_unknown) CL::smob_p);\ - ly_add_function_documentation (subr, FUNCNAME, "(SCM x)", "Check if @var{x} is a " #CL " object");\ + ly_add_function_documentation (subr, FUNCNAME, "(SCM x)", "Check if @var{x} is a @code{" #CL "} object");\ scm_c_export (FUNCNAME, NULL);\ }\ ADD_SCM_INIT_FUNC (init_type_ ## CL, init_type_ ## CL) diff --git a/lily/include/music-iterator.hh b/lily/include/music-iterator.hh index 7d7c5eef2a..b482b7ccc5 100644 --- a/lily/include/music-iterator.hh +++ b/lily/include/music-iterator.hh @@ -74,18 +74,18 @@ public: /** The translation unit that we this iterator is reporting to now. */ - Translator_group* get_outlet () const; + Context * get_outlet () const; - void set_translator (Translator_group*); + void set_translator (Context *); /** Get an iterator matching the type of MUS, and use TRANS to find an accompanying translation unit */ static SCM get_static_get_iterator (Music * mus); - void init_translator (Music *, Translator_group *); + void init_translator (Music *, Context *); void quit (); - void substitute_outlet (Translator_group* from, Translator_group *to); - virtual void derived_substitute (Translator_group*, Translator_group*); + void substitute_outlet (Context * from, Context *to); + virtual void derived_substitute (Context *, Context *); virtual Moment pending_moment () const; virtual bool ok () const; diff --git a/lily/include/music-output-def.hh b/lily/include/music-output-def.hh index 9a004b389c..9a6e2d4844 100644 --- a/lily/include/music-output-def.hh +++ b/lily/include/music-output-def.hh @@ -31,10 +31,9 @@ public: Music_output_def (Music_output_def const&); Music_output_def (); - Global_translator *get_global_translator (); - Translator_group *get_group_translator (String type) const; + Context *get_group_translator (String type) const; void assign_translator (SCM transdef); - SCM find_translator (SCM name) const; + SCM find_context_def (SCM name) const; String outname_string () ; SCM get_scmvar (String id)const; SCM lookup_variable (SCM sym) const; diff --git a/lily/include/music-wrapper-iterator.hh b/lily/include/music-wrapper-iterator.hh index 006d3dce14..0befe300b0 100644 --- a/lily/include/music-wrapper-iterator.hh +++ b/lily/include/music-wrapper-iterator.hh @@ -24,7 +24,7 @@ public: DECLARE_SCHEME_CALLBACK(constructor, ()); Music_wrapper_iterator (); - virtual void derived_substitute (Translator_group*f, Translator_group*t) ; + virtual void derived_substitute (Context *f, Context *t) ; virtual void derived_mark () const; virtual void construct_children () ; diff --git a/lily/include/percent-repeat-iterator.hh b/lily/include/percent-repeat-iterator.hh index 2caee1e3b4..6fec818e84 100644 --- a/lily/include/percent-repeat-iterator.hh +++ b/lily/include/percent-repeat-iterator.hh @@ -18,7 +18,7 @@ public: DECLARE_SCHEME_CALLBACK(constructor, ()); Percent_repeat_iterator (); protected: - virtual void derived_substitute (Translator_group*f, Translator_group*t) ; + virtual void derived_substitute (Context *f, Context *t) ; virtual void derived_mark () const; virtual Moment pending_moment () const; diff --git a/lily/include/performer-group-performer.hh b/lily/include/performer-group-performer.hh index 4a52277351..a8d607526e 100644 --- a/lily/include/performer-group-performer.hh +++ b/lily/include/performer-group-performer.hh @@ -13,24 +13,24 @@ #include "performer.hh" #include "translator-group.hh" -/** - Group a number of performers. Usually delegates everything to its contents. -*/ +typedef void (Performer::*Performer_method) (void); class Performer_group_performer : public Performer, public virtual Translator_group { public: TRANSLATOR_DECLARATIONS(Performer_group_performer); virtual void do_announces (); - virtual void process_music (); virtual void announce_element (Audio_element_info); protected: Array announce_infos_; - void create_audio_elements (); private: void acknowledge_audio_elements (); }; +void recurse_down_performers (Context * c, Performer_method ptr, + bool context_first); +void performer_each (SCM list, Performer_method method); + #endif // PERFORMER_GROUP_PERFORMER_HH diff --git a/lily/include/performer.hh b/lily/include/performer.hh index de5731a207..2fc46d3a1d 100644 --- a/lily/include/performer.hh +++ b/lily/include/performer.hh @@ -23,7 +23,7 @@ class Performer : public virtual Translator public: VIRTUAL_COPY_CONS (Translator); friend class Performer_group_performer; - Performer_group_performer* get_daddy_perf () const; + Performer_group_performer* get_daddy_performer () const; protected: virtual void announce_element (Audio_element_info); @@ -32,6 +32,7 @@ protected: virtual int get_tempo () const; virtual void play_element (Audio_element * elem ); virtual void process_music (); + virtual void do_announces (); }; diff --git a/lily/include/score-context.hh b/lily/include/score-context.hh new file mode 100644 index 0000000000..796fbee32d --- /dev/null +++ b/lily/include/score-context.hh @@ -0,0 +1,27 @@ +/* +score-context.hh -- declare Score_notation_context + +source file of the GNU LilyPond music typesetter + +(c) 2004 Han-Wen Nienhuys + + */ + +#ifndef SCORE_CONTEXT_HH +#define SCORE_CONTEXT_HH + +#include "global-context.hh" + + +class Score_context : public Context +{ + public: + virtual Music_output *get_output (); + virtual void prepare (Moment); + virtual void finish (); + virtual void one_time_step (); +}; + + + +#endif /* SCORE_CONTEXT_HH */ diff --git a/lily/include/score-engraver.hh b/lily/include/score-engraver.hh index 5168f9c72c..bb9af2f5a4 100644 --- a/lily/include/score-engraver.hh +++ b/lily/include/score-engraver.hh @@ -11,13 +11,10 @@ #define SCORE_ENGRAVER_HH #include "engraver-group-engraver.hh" -#include "global-translator.hh" +#include "score-translator.hh" -/** - Top level engraver. Puts elements into appropriate columns. - */ -class Score_engraver : - public Engraver_group_engraver, public Global_translator +class Score_engraver : public virtual Score_translator, + public virtual Engraver_group_engraver { System *system_; int breaks_; // used for stat printing @@ -31,11 +28,11 @@ class Score_engraver : void set_columns (Paper_column*,Paper_column*); void typeset_all (); protected: - /* Global_translator */ - virtual void prepare (Moment); + /* Score_translator */ virtual void finish (); + virtual void prepare (Moment); virtual void one_time_step (); - + /* Engraver_group_engraver interface */ virtual void acknowledge_grob (Grob_info); virtual bool try_music (Music*); diff --git a/lily/include/score-performer.hh b/lily/include/score-performer.hh index 29de4d2c3f..ecd7b1101c 100644 --- a/lily/include/score-performer.hh +++ b/lily/include/score-performer.hh @@ -9,13 +9,12 @@ #define SCORE_PERFORMER_HH #include "performer-group-performer.hh" -#include "global-translator.hh" +#include "score-translator.hh" /** Top level performer. Completely takes care of MIDI output */ -class Score_performer: - public Performer_group_performer, public Global_translator +class Score_performer : public Score_translator, public virtual Performer_group_performer { public: TRANSLATOR_DECLARATIONS(Score_performer); @@ -23,10 +22,8 @@ public: Performance *performance_; protected: - virtual void finish (); virtual void prepare (Moment mom); virtual void one_time_step (); - virtual void start (); virtual void initialize (); virtual void announce_element (Audio_element_info); virtual int get_tempo () const; diff --git a/lily/include/script.hh b/lily/include/script.hh index 4417e9f233..6a741548c6 100644 --- a/lily/include/script.hh +++ b/lily/include/script.hh @@ -29,7 +29,7 @@ public: }; void make_script_from_event (Grob *p, - SCM * descr, Translator_group*tg, + SCM * descr, Context *tg, SCM type, int index); #endif /* Stem_SCRIPT_HH */ diff --git a/lily/include/sequential-iterator.hh b/lily/include/sequential-iterator.hh index 1ee4526dce..b8bf6354f7 100644 --- a/lily/include/sequential-iterator.hh +++ b/lily/include/sequential-iterator.hh @@ -56,7 +56,7 @@ public: DECLARE_SCHEME_CALLBACK(constructor, ()); Sequential_iterator (); Sequential_iterator (Sequential_iterator const&); - virtual void derived_substitute (Translator_group*f, Translator_group*t) ; + virtual void derived_substitute (Context *f, Context *t) ; virtual void derived_mark () const; diff --git a/lily/include/simultaneous-music-iterator.hh b/lily/include/simultaneous-music-iterator.hh index 237885d2b1..a351ef50aa 100644 --- a/lily/include/simultaneous-music-iterator.hh +++ b/lily/include/simultaneous-music-iterator.hh @@ -17,7 +17,7 @@ class Simultaneous_music_iterator : public Music_iterator public: Simultaneous_music_iterator (); Simultaneous_music_iterator (Simultaneous_music_iterator const&); - virtual void derived_substitute (Translator_group*f, Translator_group*t) ; + virtual void derived_substitute (Context *f, Context *t) ; virtual void derived_mark () const; DECLARE_SCHEME_CALLBACK(constructor, ()); diff --git a/lily/include/translation-property.hh b/lily/include/translation-property.hh index d5dc380628..aacb932b9d 100644 --- a/lily/include/translation-property.hh +++ b/lily/include/translation-property.hh @@ -58,9 +58,6 @@ public: }; -void apply_push_property (Translator_group*trans, SCM syms, SCM eprop, SCM val); -void apply_pop_property (Translator_group*trans, SCM syms, SCM eprop); - #endif // PROPERTY_HH #endif diff --git a/lily/include/translator-group.hh b/lily/include/translator-group.hh index 36ac26cf2f..851c8f5a57 100644 --- a/lily/include/translator-group.hh +++ b/lily/include/translator-group.hh @@ -17,76 +17,25 @@ #include "parray.hh" #include "smobs.hh" -// egcs -typedef void (Translator::*Method_pointer) (void); -#define set_property(x,y) internal_set_property(ly_symbol2scm(x),y) +typedef void (Translator::*Translator_method) (void); -class Scheme_hash_table; - - -/** Make some kind of Elements from Events. Elements are made by - hierarchically grouped Translators - */ class Translator_group : public virtual Translator { -public: - String id_string_; -private: - int iterator_count_; - friend class Interpretation_context_handle; - - Scheme_hash_table *properties_dict () const; - SCM add_translator (SCM, Translator*); protected: - ~Translator_group (); - - virtual SCM get_simple_trans_list (); - + public: - void execute_pushpop_property (SCM prop, SCM sym, SCM val); - SCM internal_get_property (SCM name_sym) const; - SCM properties_as_alist () const; - void unset_property (SCM var_sym); - void internal_set_property (SCM var_sym, SCM value); - - Translator_group *where_defined (SCM name_sym) const; - String context_name () const; - Translator_group (Translator_group const &); - Translator_group (); - - bool is_alias (SCM) const; - void add_fresh_group_translator (Translator *trans); - void add_used_group_translator (Translator *trans); - bool is_bottom_context () const; - bool is_removable () const; - void terminate_translator (Translator*r); - Translator *remove_translator (Translator*trans); - void check_removal (); - Translator_group *find_existing_translator (SCM context_name, String id); - Translator_group *find_create_translator (SCM context_name, - String id, SCM ops); - Link_array - path_to_acceptable_translator (SCM alias, - Music_output_def*) const; - Translator_group*get_default_interpreter (); VIRTUAL_COPY_CONS (Translator); + public: - bool try_music_on_nongroup_children (Music *m); - - virtual void do_announces (); + virtual Translator_group* get_daddy_translator ()const; + virtual SCM get_simple_trans_list (); virtual bool try_music (Music* req); - virtual void stop_translation_timestep (); - virtual void start_translation_timestep (); virtual void initialize (); - virtual void finalize (); - virtual void each (Method_pointer); }; -bool melisma_busy (Translator* tr); // where to put this? --hwn -void apply_property_operations (Translator_group*tg, SCM pre_init_ops); -SCM names_to_translators (SCM namelist, Translator_group*tg); -void execute_pushpop_property (Translator_group * trg, - SCM prop, SCM eltprop, SCM val); -SCM updated_grob_properties (Translator_group* tg, SCM sym); +SCM names_to_translators (SCM namelist, Context*tg); +void recurse_down_translators (Context * c, Translator_method ptr, bool context_first); +void translator_each (SCM list, Translator_method method); + #endif // TRANSLATOR_GROUP_HH diff --git a/lily/include/translator.hh b/lily/include/translator.hh index fe4d51aaa5..3178beff9e 100644 --- a/lily/include/translator.hh +++ b/lily/include/translator.hh @@ -39,46 +39,31 @@ public: Music_output_def * output_def_; Translator (Translator const &); + Context * daddy_context_ ; - - Translator_group * daddy_trans_ ; void removal_processing (); virtual Music_output_def *get_output_def () const; - SCM internal_get_property (SCM symbol) const; - + virtual Translator_group* get_daddy_translator ()const; virtual Moment now_mom () const; - /* - ugh: bubbled up. - */ - SCM definition_; - SCM properties_scm_; - SCM trans_group_list_; - SCM accepts_list_; - virtual SCM get_simple_trans_list (); public: DECLARE_SMOBS (Translator, dummy); -private: - /* - ugh: bubbled up from Translator_group. - */ - protected: // should be private. SCM simple_trans_list_; friend class Context_def; public: - Global_translator * top_translator () const; + Score_context * get_score_context () const; + Global_context * get_global_context () const; + TRANSLATOR_DECLARATIONS(Translator); virtual bool try_music (Music *req); virtual void stop_translation_timestep (); virtual void start_translation_timestep (); - virtual void do_announces () ; virtual void initialize () ; virtual void finalize (); }; - /** A macro to automate administration of translators. */ @@ -134,4 +119,5 @@ void add_translator (Translator*trans); Translator*get_translator (SCM s); DECLARE_UNSMOB(Translator,translator); +bool melisma_busy (Translator*); #endif // TRANSLATOR_HH diff --git a/lily/instrument-name-engraver.cc b/lily/instrument-name-engraver.cc index 34e49abede..5b2ab6b198 100644 --- a/lily/instrument-name-engraver.cc +++ b/lily/instrument-name-engraver.cc @@ -14,7 +14,7 @@ #include "side-position-interface.hh" #include "align-interface.hh" #include "axis-group-interface.hh" -#include "translator-group.hh" +#include "context.hh" #include "text-item.hh" class Instrument_name_engraver : public Engraver @@ -42,7 +42,7 @@ Instrument_name_engraver::Instrument_name_engraver () void Instrument_name_engraver::initialize () { - daddy_trans_->set_property ("instrumentSupport", SCM_EOL); + daddy_context_->set_property ("instrumentSupport", SCM_EOL); } void @@ -111,7 +111,7 @@ Instrument_name_engraver::acknowledge_grob (Grob_info i) SCM nl = gh_cons (i.grob_->self_scm (), get_property ("instrumentSupport")); - daddy_trans_->set_property ("instrumentSupport", nl); + daddy_context_->set_property ("instrumentSupport", nl); } } diff --git a/lily/interpretation-context-handle.cc b/lily/interpretation-context-handle.cc index 9f2242203d..bb8175bc02 100644 --- a/lily/interpretation-context-handle.cc +++ b/lily/interpretation-context-handle.cc @@ -7,7 +7,7 @@ */ #include "interpretation-context-handle.hh" -#include "translator-group.hh" +#include "context.hh" Interpretation_context_handle::Interpretation_context_handle () { @@ -42,7 +42,7 @@ Interpretation_context_handle::~Interpretation_context_handle () } void -Interpretation_context_handle::up (Translator_group*t) +Interpretation_context_handle::up (Context *t) { outlet_ = t; t->iterator_count_ ++; @@ -78,7 +78,7 @@ Interpretation_context_handle::operator = (Interpretation_context_handle const & } void -Interpretation_context_handle::set_translator (Translator_group*trans) +Interpretation_context_handle::set_translator (Context *trans) { if (outlet_ ==trans) return; @@ -88,7 +88,7 @@ Interpretation_context_handle::set_translator (Translator_group*trans) up (trans); } -Translator_group* +Context * Interpretation_context_handle::get_outlet () const { diff --git a/lily/key-engraver.cc b/lily/key-engraver.cc index 061e154477..41aeaffbdb 100644 --- a/lily/key-engraver.cc +++ b/lily/key-engraver.cc @@ -12,7 +12,7 @@ #include "item.hh" #include "bar-line.hh" #include "staff-symbol-referencer.hh" -#include "translator-group.hh" +#include "context.hh" #include "engraver.hh" #include "pitch.hh" #include "protected-scm.hh" @@ -168,8 +168,8 @@ Key_engraver::read_ev (Key_change_ev const * r) if (gh_scm2int (ly_cdar (s))) accs = gh_cons (ly_car (s), accs); - daddy_trans_->set_property ("keySignature", accs); - daddy_trans_->set_property ("tonic" , + daddy_context_->set_property ("keySignature", accs); + daddy_context_->set_property ("tonic" , r->get_mus_property ("tonic")); } @@ -178,18 +178,18 @@ void Key_engraver::start_translation_timestep () { key_ev_ = 0; - daddy_trans_->set_property ("lastKeySignature", get_property ("keySignature")); + daddy_context_->set_property ("lastKeySignature", get_property ("keySignature")); } void Key_engraver::initialize () { - daddy_trans_->set_property ("keySignature", SCM_EOL); - daddy_trans_->set_property ("lastKeySignature", SCM_EOL); + daddy_context_->set_property ("keySignature", SCM_EOL); + daddy_context_->set_property ("lastKeySignature", SCM_EOL); Pitch p(0,0,0); - daddy_trans_->set_property ("tonic", p.smobbed_copy ()); + daddy_context_->set_property ("tonic", p.smobbed_copy ()); } diff --git a/lily/ligature-engraver.cc b/lily/ligature-engraver.cc index a026118b98..8501e4c5d6 100644 --- a/lily/ligature-engraver.cc +++ b/lily/ligature-engraver.cc @@ -12,7 +12,8 @@ #include "note-head.hh" #include "rest.hh" #include "warn.hh" -#include "translator-group.hh" +#include "context.hh" + /* * This abstract class provides the general framework for ligatures of @@ -114,9 +115,9 @@ Ligature_engraver::override_stencil_callback () { SCM target_callback = ly_symbol2scm ("print-function"); SCM source_callback = ly_symbol2scm ("ligature-primitive-callback"); - SCM noteHeadProperties = updated_grob_properties (daddy_trans_, ly_symbol2scm ("NoteHead")); + SCM noteHeadProperties = updated_grob_properties (daddy_context_, ly_symbol2scm ("NoteHead")); SCM value = ly_cdr (scm_sloppy_assq (source_callback, noteHeadProperties)); - execute_pushpop_property (daddy_trans_, ly_symbol2scm ("NoteHead"), + execute_pushpop_property (daddy_context_, ly_symbol2scm ("NoteHead"), target_callback, value); } @@ -138,7 +139,7 @@ Ligature_engraver::revert_stencil_callback () { SCM symbol = ly_symbol2scm ("NoteHead"); SCM key = ly_symbol2scm ("print-function"); - execute_pushpop_property (daddy_trans_, symbol, key, SCM_UNDEFINED); + execute_pushpop_property (daddy_context_, symbol, key, SCM_UNDEFINED); } void @@ -173,7 +174,7 @@ Ligature_engraver::process_music () if (ligature_) { // TODO: maybe forbid breaks only if not transcribing - top_engraver ()->forbid_breaks (); + get_score_engraver ()->forbid_breaks (); } if (reqs_drul_[START]) diff --git a/lily/line-interface.cc b/lily/line-interface.cc index 091eac7cf1..cc8c17b851 100644 --- a/lily/line-interface.cc +++ b/lily/line-interface.cc @@ -98,10 +98,10 @@ Line_interface::line (Grob *me, Offset from, Offset to) ADD_INTERFACE(Line_interface, "line-interface", "Generic line objects. Any object using lines supports this. Normally," - "you get a straight line. If dash-period is defined, a dashed line is " - "produced; the length of the dashes is tuned with" + "you get a straight line. If @code{dash-period} is defined, a dashed line is " + "produced; the length of the dashes is tuned with " "@code{dash-fraction}. If the latter is set to 0, a dotted line is " - "produced. If @code{dash-fraction} is negative, the line is set " + "produced. If @code{dash-fraction} is negative, the line is made " "transparent.", "dash-period dash-fraction thickness style") diff --git a/lily/line-spanner.cc b/lily/line-spanner.cc index 2f91fd7aa5..2207d85a44 100644 --- a/lily/line-spanner.cc +++ b/lily/line-spanner.cc @@ -290,10 +290,12 @@ Line_spanner::print (SCM smob) ADD_INTERFACE (Line_spanner, "line-spanner-interface", - "Generic line drawn between two objects, eg. for use with glissandi.\n" -"gap is measured in staff-spaces.\n" -"The property 'type is one of: line, dashed-line, trill, dotted-line or zigzag.\n" -"\n", - "gap zigzag-width zigzag-length thickness"); + "Generic line drawn between two objects, e.g. for use with glissandi.\n" + "The property @code{style} can be @code{line}, " + "@code{dashed-line}, @code{trill}, \n" + "@code{dotted-line} or @code{zigzag}.\n" + "\n" + , + "gap zigzag-width zigzag-length thickness"); diff --git a/lily/lookup.cc b/lily/lookup.cc index 667aef9431..f9753cfad4 100644 --- a/lily/lookup.cc +++ b/lily/lookup.cc @@ -728,7 +728,10 @@ LY_DEFINE(ly_bracket ,"ly:bracket", LY_DEFINE(ly_filled_box ,"ly:round-filled-box", 3, 0, 0, (SCM xext, SCM yext, SCM blot), - "Make a filled-box of dimensions @var{xext}, @var{yext} and roundness @var{blot}.") + "Make a @code{Stencil} " + " that prints a filled-box of dimensions @var{xext}, " + "@var{yext} and roundness @var{blot}." + ) { SCM_ASSERT_TYPE(is_number_pair (xext), xext, SCM_ARG1, __FUNCTION__, "number pair") ; SCM_ASSERT_TYPE(is_number_pair (yext), yext, SCM_ARG2, __FUNCTION__, "number pair") ; diff --git a/lily/lyric-combine-music-iterator.cc b/lily/lyric-combine-music-iterator.cc index 938a7a9c2d..1783677b82 100644 --- a/lily/lyric-combine-music-iterator.cc +++ b/lily/lyric-combine-music-iterator.cc @@ -7,7 +7,7 @@ */ -#include "translator-group.hh" +#include "context.hh" #include "lyric-combine-music.hh" #include "event.hh" #include "note-head.hh" @@ -29,7 +29,7 @@ protected: virtual bool ok () const; virtual void derived_mark () const; - virtual void derived_substitute (Translator_group*,Translator_group*) ; + virtual void derived_substitute (Context *,Context *) ; private: bool get_busy_status ()const ; bool melisma_busy (); @@ -39,10 +39,12 @@ private: }; +#include "translator.hh" + bool melisma_busy (Translator* tr) { - SCM melisma_properties = tr->get_property ("melismaBusyProperties"); + SCM melisma_properties = tr->daddy_context_->get_property ("melismaBusyProperties"); bool busy = false; for (; gh_pair_p (melisma_properties); @@ -97,7 +99,7 @@ Lyric_combine_music_iterator::derived_mark()const } void -Lyric_combine_music_iterator::derived_substitute (Translator_group*f,Translator_group* t) +Lyric_combine_music_iterator::derived_substitute (Context *f,Context * t) { if (music_iter_) music_iter_->substitute_outlet (f,t); @@ -124,7 +126,7 @@ Lyric_combine_music_iterator::get_busy_status () const if (try_music (busy_req)) return true; - Translator_group * tr = music_iter_->get_outlet (); + Context * tr = music_iter_->get_outlet (); SCM grobs = tr->get_property ("busyGrobs"); Moment now = tr->now_mom(); diff --git a/lily/lyric-phrasing-engraver.cc b/lily/lyric-phrasing-engraver.cc index 1ad79cdf56..3396fe1940 100644 --- a/lily/lyric-phrasing-engraver.cc +++ b/lily/lyric-phrasing-engraver.cc @@ -8,7 +8,7 @@ source file of the GNU LilyPond music typesetter */ -#include "translator-group.hh" +#include "context.hh" #include "engraver.hh" #include "note-head.hh" #include "lyric-extender.hh" @@ -50,7 +50,7 @@ private: void add_lyric_extender (Grob_info); void add_stanza_number (Grob_info); Phrasing_association *get_phrasing_assoc (String nm); - String get_voice_name_for_lyric (Translator_group*tr); + String get_voice_name_for_lyric (Context *tr); Link_array assocs_; }; @@ -95,12 +95,12 @@ Lyric_phrasing_engraver::get_phrasing_assoc (String nm) String -Lyric_phrasing_engraver::get_voice_name_for_lyric (Translator_group*tr) +Lyric_phrasing_engraver::get_voice_name_for_lyric (Context *tr) { SCM voice_context = tr->get_property ("associatedVoiceContext"); if (Translator *vc = unsmob_translator (voice_context)) { - return dynamic_cast (vc)->id_string_; + return dynamic_cast (vc)->id_string_; } SCM voice = tr->get_property ("associatedVoice"); @@ -121,9 +121,9 @@ Lyric_phrasing_engraver::get_voice_name_for_lyric (Translator_group*tr) void Lyric_phrasing_engraver::add_lyric_extender (Grob_info inf) { - Translator_group * tr = inf.origin_trans_->daddy_trans_; + Context * tr = inf.origin_trans_->daddy_context_; while (tr && !tr->is_alias (ly_symbol2scm ("Lyrics"))) - tr = tr->daddy_trans_; + tr = tr->daddy_context_; if (!tr) return; @@ -136,9 +136,9 @@ Lyric_phrasing_engraver::add_lyric_extender (Grob_info inf) void Lyric_phrasing_engraver::add_stanza_number (Grob_info inf) { - Translator_group * tr = inf.origin_trans_->daddy_trans_; + Context * tr = inf.origin_trans_->daddy_context_; while (tr && !tr->is_alias (ly_symbol2scm ("Lyrics"))) - tr = tr->daddy_trans_; + tr = tr->daddy_context_; if (!tr) return; @@ -150,9 +150,9 @@ Lyric_phrasing_engraver::add_stanza_number (Grob_info inf) void Lyric_phrasing_engraver::add_voice_phrasing (Grob_info inf) { - Translator_group * tr = inf.origin_trans_->daddy_trans_; + Context * tr = inf.origin_trans_->daddy_context_; while (tr && !tr->is_alias (ly_symbol2scm ("Voice"))) - tr = tr->daddy_trans_; + tr = tr->daddy_context_; if (!tr) return; @@ -165,9 +165,9 @@ Lyric_phrasing_engraver::add_voice_phrasing (Grob_info inf) void Lyric_phrasing_engraver::add_lyric_phrasing (Grob_info inf) { - Translator_group * tr = inf.origin_trans_->daddy_trans_; + Context * tr = inf.origin_trans_->daddy_context_; while (tr && !tr->is_alias (ly_symbol2scm ("Lyrics"))) - tr = tr->daddy_trans_; + tr = tr->daddy_context_; if (!tr) return; diff --git a/lily/mark-engraver.cc b/lily/mark-engraver.cc index 82d27d3643..5016287dec 100644 --- a/lily/mark-engraver.cc +++ b/lily/mark-engraver.cc @@ -9,7 +9,7 @@ #include #include "bar-line.hh" - +#include "context.hh" #include "engraver-group-engraver.hh" #include "engraver.hh" #include "item.hh" @@ -127,12 +127,12 @@ Mark_engraver::process_music () { int mark_count = gh_scm2int (m); mark_count ++; - daddy_trans_->set_property ("rehearsalMark", - gh_int2scm (mark_count)); + daddy_context_->set_property ("rehearsalMark", + gh_int2scm (mark_count)); } if (gh_number_p (m)) - m = scm_call_2 (proc, m, daddy_trans_->self_scm ()); + m = scm_call_2 (proc, m, daddy_context_->self_scm ()); else warning ("rehearsalMark does not have integer value."); } diff --git a/lily/measure-grouping-engraver.cc b/lily/measure-grouping-engraver.cc index 45dd6ff0cd..df169a9474 100644 --- a/lily/measure-grouping-engraver.cc +++ b/lily/measure-grouping-engraver.cc @@ -6,10 +6,11 @@ (c) 2002--2004 Han-Wen Nienhuys */ -#include "score-engraver.hh" #include "spanner.hh" #include "warn.hh" #include "side-position-interface.hh" +#include "global-context.hh" +#include "engraver.hh" class Measure_grouping_engraver : public Engraver { @@ -92,7 +93,7 @@ Measure_grouping_engraver::process_music () stop_grouping_mom_ = now.main_part_ + Rational(grouplen - 1) * bl ; - top_engraver ()->add_moment_to_process (Moment (stop_grouping_mom_)); + get_global_context ()->add_moment_to_process (Moment (stop_grouping_mom_)); if (grouplen == 3) grouping_->set_grob_property ("style", ly_symbol2scm ("triangle")); diff --git a/lily/measure-grouping-spanner.cc b/lily/measure-grouping-spanner.cc index 2896a3d8e8..d6b4b6f6ce 100644 --- a/lily/measure-grouping-spanner.cc +++ b/lily/measure-grouping-spanner.cc @@ -59,7 +59,8 @@ Measure_grouping::print (SCM grob) } ADD_INTERFACE (Measure_grouping,"measure-grouping-interface", - "indicate groups of beats. Valid choices for 'type are 'bracket and 'triangle.", + "This objectt indicates groups of beats. " + "Valid choices for @code{style} are @code{bracket} and @code{triangle}.", "thickness style height"); diff --git a/lily/melisma-engraver.cc b/lily/melisma-engraver.cc index 7513fb4e22..f8b9a5e68b 100644 --- a/lily/melisma-engraver.cc +++ b/lily/melisma-engraver.cc @@ -13,7 +13,8 @@ #include "engraver.hh" #include "event.hh" #include "grob.hh" -#include "translator-group.hh" +#include "context.hh" + /** Signal existence of melismas. diff --git a/lily/metronome-engraver.cc b/lily/metronome-engraver.cc index 058994f906..b892ed32c7 100644 --- a/lily/metronome-engraver.cc +++ b/lily/metronome-engraver.cc @@ -13,6 +13,7 @@ #include "engraver.hh" #include "engraver-group-engraver.hh" #include "item.hh" +#include "context.hh" /** put stuff over or next to bars. Examples: bar numbers, marginal notes, @@ -100,7 +101,7 @@ Metronome_mark_engraver::process_music () SCM proc = get_property ("metronomeMarkFormatter"); SCM result= scm_call_2 (proc, mark_ev_->self_scm (), - daddy_trans_->self_scm()); + daddy_context_->self_scm()); text_->set_grob_property ("text", result); } diff --git a/lily/moment.cc b/lily/moment.cc index 9b52517e3c..39c509f734 100644 --- a/lily/moment.cc +++ b/lily/moment.cc @@ -103,7 +103,7 @@ LY_DEFINE (div_moment,"ly:div-moment", 2,0,0, (SCM a, SCM b), } LY_DEFINE (ly_moment_less_p,"ly:momenttry_retrieve (name, &val); @@ -91,24 +91,6 @@ Music_output_def::find_translator (SCM name) const } -Global_translator * -Music_output_def::get_global_translator () -{ - SCM key = ly_symbol2scm ("Score"); - Context_def * t = unsmob_context_def (find_translator (key)); - - if (!t) - error (_f ("can't find `%s' context", "Score")); - - Translator_group * tg = t->instantiate (SCM_EOL); - dynamic_cast (tg)->output_def_ = this; - - - tg->initialize (); - - return dynamic_cast (tg); -} - int Music_output_def::print_smob (SCM s, SCM p, scm_print_state *) { diff --git a/lily/music-wrapper-iterator.cc b/lily/music-wrapper-iterator.cc index 4e264db187..e88f773d90 100644 --- a/lily/music-wrapper-iterator.cc +++ b/lily/music-wrapper-iterator.cc @@ -29,7 +29,7 @@ Music_wrapper_iterator::derived_mark () const } void -Music_wrapper_iterator::derived_substitute (Translator_group*f,Translator_group*t) +Music_wrapper_iterator::derived_substitute (Context *f,Context *t) { if (child_iter_) diff --git a/lily/music.cc b/lily/music.cc index fefeda054d..9514210f33 100644 --- a/lily/music.cc +++ b/lily/music.cc @@ -292,15 +292,13 @@ LY_DEFINE(ly_music_name, "ly:music-name", 1, 0, 0, // to do property args LY_DEFINE(ly_extended_make_music, "ly:make-bare-music", 2, 0, 0, (SCM type, SCM props), - "Make a music object/expression of type @var{type}, init with\n" -"@var{props}. Warning: this interface will likely change in the near\n" -"future.\n" -"\n" -"Music is the data type that music expressions are stored in. The data\n" -"type does not yet offer many manipulations.\n" -"\n" -"WARNING: only for internal use. Please use make-music-by-name. \n" -) + "Make a C++ music object of type @var{type}, initialize with\n" + "@var{props}. \n\n" + "" + "This function is for internal use, and is only called by " + "@code{make-music-by-name}, which is the preferred interface " + "for creating music objects. " + ) { SCM_ASSERT_TYPE(gh_string_p (type), type, SCM_ARG1, __FUNCTION__, "string"); @@ -313,10 +311,10 @@ LY_DEFINE(ly_extended_make_music, // to do property args LY_DEFINE(ly_get_mutable_properties, "ly:get-mutable-properties", 1, 0, 0, (SCM mus), -"Return an alist signifying the mutable properties of @var{mus}.\n" -"The immutable properties are not available; they should be initialized\n" -"by the functions make-music-by-name function.\n" -) + "Return an alist containing the mutable properties of @var{mus}.\n" + "The immutable properties are not available; they should be initialized\n" + "by the @code{make-music-by-name} function.\n" + ) { Music *m = unsmob_music (mus); SCM_ASSERT_TYPE(m, mus, SCM_ARG1, __FUNCTION__, "music"); @@ -324,7 +322,7 @@ LY_DEFINE(ly_get_mutable_properties, return m->get_property_alist (true); } -LY_DEFINE(ly_music_list_p,"music-list?", 1, 0, 0, +LY_DEFINE(ly_music_list_p,"ly:music-list?", 1, 0, 0, (SCM l),"Type predicate: return true if @var{l} is a list of music objects.") { if (scm_list_p (l) != SCM_BOOL_T) diff --git a/lily/new-accidental-engraver.cc b/lily/new-accidental-engraver.cc deleted file mode 100644 index 9b3d6a04ee..0000000000 --- a/lily/new-accidental-engraver.cc +++ /dev/null @@ -1,553 +0,0 @@ -/* - new-accidental-engraver.cc -- implement new_accidental_engraver - - (c) 1997--2004 Han-Wen Nienhuys - Modified 2001--2004 by Rune Zedeler - - This is an experimental file - producing correct accidentals but - unfortunately ruining the spacing. -rz - -*/ - -#include "event.hh" - -#include "item.hh" -#include "tie.hh" -#include "rhythmic-head.hh" -#include "engraver-group-engraver.hh" -#include "accidental-placement.hh" -#include "side-position-interface.hh" -#include "engraver.hh" -#include "arpeggio.hh" -#include "warn.hh" - -#include "translator-group.hh" - -/** - - -FIXME: should not compute vertical positioning of accidentals, but -get them from the noteheads - -The algorithm for accidentals should be documented, and made -tweakable. - -*/ - -struct New_accidental_entry { - int pass_done_; - int number_accidentals_; - int number_cautionaries_; - bool different_; - Music * melodic_; - Grob * accidental_; - Translator_group *origin_; - Grob* head_; - New_accidental_entry(); -}; - -New_accidental_entry::New_accidental_entry() -{ - pass_done_ = 0; - number_accidentals_ = 0; - number_cautionaries_ = 0; - different_ = false; - melodic_ = 0; - accidental_ = 0; - origin_ = 0; - head_ = 0; -} - -struct New_accidental_engraver : Engraver { -protected: - TRANSLATOR_DECLARATIONS (New_accidental_engraver); - virtual void process_music (); - virtual void acknowledge_grob (Grob_info); - virtual void stop_translation_timestep (); - virtual void process_acknowledged_grobs (); - virtual void finalize (); - virtual void process_grobs_first_pass (); - virtual void process_grobs_second_pass (); - - public: - - /* - TODO -> property. - - This is not a property, and it is not protected. This poses a - very small risk of the value being GC'd from under us. - */ - SCM last_keysig_; - - /* - Urgh. Since the accidentals depend on lots of variables, we have to - store all information before we can really create the accidentals. - */ - Link_array arpeggios_; - - Grob * accidental_placement_; - - - /* - The next - */ - Array accidentals_; - - Link_array ties_; - - -}; - - -New_accidental_engraver::New_accidental_engraver () -{ - last_keysig_ = SCM_BOOL_F; - accidental_placement_ = 0; -} - -/* inserts the source alist into the destination alist, erasing old entries. - result is: dest = merged -*/ -static SCM merge_alists_front_x (SCM src, SCM dest) { - if(gh_pair_p(src)) { - dest = merge_alists_front_x(ly_cdr(src),dest); - dest = ly_assoc_front_x(dest, ly_caar(src), ly_cdar(src)); - } - return dest; -} - -static void merge_property_on_children (Translator_group * trans, - const char * from_sym, const char * to_sym) -{ - SCM from = trans->get_property(from_sym); - SCM to = trans->get_property(to_sym); - to = merge_alists_front_x(from, to); - trans->set_property (to_sym, to); - trans->set_property (from_sym, SCM_EOL); - for (SCM p = trans -> trans_group_list_; gh_pair_p (p); p = ly_cdr(p)) { - Translator_group *trg = dynamic_cast (unsmob_translator (ly_car (p))); - merge_property_on_children(trg, from_sym, to_sym); - } -} - -static void merge_property_on_family (Translator_group * trans, - const char * from_sym, const char * to_sym) -{ - merge_property_on_children (trans, from_sym, to_sym); - trans = trans->daddy_trans_; - while (trans) - { - SCM from = trans->get_property(from_sym); - SCM to = trans->get_property(to_sym); - to = merge_alists_front_x(from, to); - trans->set_property (to_sym, to); - trans->set_property (from_sym, SCM_EOL); - trans = trans->daddy_trans_; - } -} - -static void set_property_on_children (Translator_group * trans, const char * sym, SCM val) -{ - trans->set_property (sym, val); - for (SCM p = trans -> trans_group_list_; gh_pair_p (p); p = ly_cdr(p)) { - Translator_group *trg = dynamic_cast (unsmob_translator (ly_car (p))); - set_property_on_children(trg,sym,ly_deep_copy(val)); - } -} - -static void set_property_on_family(Translator_group * trans, const char * sym, SCM val) -{ - set_property_on_children (trans, sym, val); - trans = trans->daddy_trans_; - while (trans) - { - trans -> set_property (sym, ly_deep_copy (val)); - trans = trans->daddy_trans_; - } -} - -/* -calculates the number of accidentals on basis of the current local key sig - (passed as argument) - Returns number of accidentals (0, 1 or 2). - Negative (-1 or -2) if accidental has changed. - -*/ -static int -number_accidentals (SCM sig, Music * note, Pitch *pitch, SCM curbarnum, SCM lazyness, - bool ignore_octave_b) -{ - int n = pitch->get_notename (); - int o = pitch->get_octave (); - int a = pitch->get_alteration (); - int curbarnum_i = gh_scm2int (curbarnum); - int accbarnum_i = 0; - - SCM prev; - if (ignore_octave_b) - prev = ly_assoc_cdr (gh_int2scm (n), sig); - else - prev = scm_assoc (gh_cons (gh_int2scm (o), gh_int2scm (n)), sig); - - /* should really be true unless prev == SCM_BOOL_F */ - if (gh_pair_p (prev) && gh_pair_p (ly_cdr (prev))) - { - accbarnum_i = gh_scm2int (ly_cddr (prev)); - prev = gh_cons (ly_car (prev), ly_cadr (prev)); - } - - /* If an accidental was not found or the accidental was too old */ - if (prev == SCM_BOOL_F || - (gh_number_p (lazyness) && curbarnum_i > accbarnum_i + gh_scm2int (lazyness))) - prev = scm_assoc (gh_int2scm (n), sig); - - - SCM prev_acc = (prev == SCM_BOOL_F) ? gh_int2scm (0) : ly_cdr (prev); - - int p = gh_number_p (prev_acc) ? gh_scm2int (prev_acc) : 0; - - int num; - if (a == p - && !to_boolean (note->get_mus_property ("force-accidental")) - && gh_number_p (prev_acc)) - num = 0; - else if ( (abs (a)get_property ("localKeySignature"); - - bool same_octave_b = - gh_eq_p (ly_symbol2scm ("same-octave"), type); - bool any_octave_b = - gh_eq_p (ly_symbol2scm ("any-octave"), type); - - if (same_octave_b || any_octave_b) - { - int n = number_accidentals - (localsig, note, pitch, curbarnum, lazyness, any_octave_b); - diff = diff || (n < 0); - number = max (number, abs (n)); - } - else - warning (_f ("unknown accidental typesetting: %s. Ignored", - ly_symbol2string (type).to_str0 ())); - } - - - /* - if symbol then it is a context name. Scan parent contexts to find it. - */ - else if (gh_symbol_p (ly_car (accidentals))) - { - SCM context = ly_car (accidentals); - - while (origin && !origin->is_alias (context)) - origin = origin->daddy_trans_; - - if (!origin) - warning (_f ("Symbol is not a parent context: %s. Ignored", - ly_symbol2string (context).to_str0 ())); - } - else warning (_f ("Accidental typesetting must be pair or context-name: %s", - ly_scm2string (ly_car (accidentals)).to_str0 ())); - - accidentals = ly_cdr (accidentals); - } - return diff ? -number : number; -} - - -/* - Perhaps one should join the two functions into one function taking an - argument (pass). - OTOH even though code would be smaller, spaghetti-level would increase. -*/ -void -New_accidental_engraver::process_grobs_first_pass () -{ - SCM accidentals = get_property ("autoAccidentals"); - SCM cautionaries = get_property ("autoCautionaries"); - SCM barnum = get_property ("currentBarNumber"); - - for (int i = 0; i < accidentals_.size (); i++) - { - if (accidentals_[i].pass_done_ >= 1) - continue; - accidentals_[i].pass_done_ = 1; - - Grob * support = accidentals_[i].head_; - Music * note = accidentals_[i].melodic_; - Translator_group * origin = accidentals_[i].origin_; - Pitch * pitch = unsmob_pitch (note->get_mus_property ("pitch")); - - int num; - num = number_accidentals (note, pitch, origin, accidentals, barnum); - accidentals_[i].number_accidentals_ = abs(num); - accidentals_[i].different_ = num<0; - - num = number_accidentals (note, pitch, origin, cautionaries, barnum); - accidentals_[i].number_cautionaries_ = abs(num); - accidentals_[i].different_ = accidentals_[i].different_ || num<0; - - bool tie_changes = false; - for (int j = 0; j < ties_.size (); j++) - if (support == Tie::head (ties_[j], RIGHT)) - tie_changes = accidentals_[i].different_; - int n = pitch->get_notename (); - int o = pitch->get_octave (); - int a = pitch->get_alteration (); - SCM o_s = gh_int2scm (o); - SCM n_s = gh_int2scm (n); - SCM on_s = gh_cons (o_s,n_s); - - while (origin) - { - SCM sigch = origin->get_property ("localKeySignatureChanges"); - SCM alt; - if (tie_changes) - /* - Remember an alteration that is different both from - that of the tied note and of the key signature. - */ - alt = SCM_BOOL_T; - else - alt = gh_int2scm (a); - bool other_alt_same_oct = false; - bool other_alt_any_oct = false; - for (SCM j = sigch; gh_pair_p(j); j = ly_cdr(j)) { - SCM entry = ly_car(j); - /* if same notename has a different alt already recorded: */ - if(gh_equal_p(ly_cdar(entry),n_s) && !gh_equal_p(ly_cadr(entry),alt)) - { - /* if it is also in same octave */ - if(gh_equal_p(ly_caar(entry),o_s)) - other_alt_same_oct = true; - else - other_alt_any_oct = true; - } - } - if(other_alt_same_oct) - alt = SCM_BOOL_T; - sigch = ly_assoc_front_x (sigch, on_s, gh_cons(alt,barnum)); - if(other_alt_any_oct && !other_alt_same_oct) { - sigch = ly_assoc_front_x (sigch, on_s, gh_cons(SCM_BOOL_T,barnum)); - } - origin->set_property ("localKeySignatureChanges", sigch); - origin = origin->daddy_trans_; - } - } -} - -void -New_accidental_engraver::process_grobs_second_pass () -{ - SCM accidentals = get_property ("autoAccidentals"); - SCM cautionaries = get_property ("autoCautionaries"); - SCM barnum = get_property ("currentBarNumber"); - - bool extra_natural_b = get_property ("extraNatural") == SCM_BOOL_T; - for (int i = 0; i < accidentals_.size (); i++) - { - if (accidentals_[i].pass_done_ >= 2) - continue; - accidentals_[i].pass_done_ = 2; - Grob * support = accidentals_[i].head_; - Music * note = accidentals_[i].melodic_; - Translator_group * origin = accidentals_[i].origin_; - - Pitch * pitch = unsmob_pitch (note->get_mus_property ("pitch")); - - int num; - num = number_accidentals (note, pitch, origin, accidentals, barnum); - accidentals_[i].number_accidentals_ = - max (accidentals_[i].number_accidentals_, abs(num)); - accidentals_[i].different_ = accidentals_[i].different_ || num<0; - - num = number_accidentals (note, pitch, origin, cautionaries, barnum); - accidentals_[i].number_cautionaries_ = - max (accidentals_[i].number_cautionaries_, abs(num)); - accidentals_[i].different_ = accidentals_[i].different_ || num<0; - - - bool cautionary = to_boolean (note->get_mus_property ("cautionary")); - - if (accidentals_[i].number_cautionaries_ >accidentals_[i].number_accidentals_ ) - { - num = accidentals_[i].number_cautionaries_; - cautionary = true; - } - else - num = accidentals_[i].number_accidentals_; - - bool tie_changes = false; - Grob *tie_break_reminder = 0; - for (int j = 0; j < ties_.size (); j++) - if (support == Tie::head (ties_[j], RIGHT)) - { - tie_changes = accidentals_[i].different_; - tie_break_reminder = ties_[j]; - } - - if (num) - { - Grob * a = make_item ("Accidental"); - a->set_parent (support, Y_AXIS); - - if (!accidental_placement_) - { - accidental_placement_ = make_item ("AccidentalPlacement"); - announce_grob (accidental_placement_, a->self_scm()); - } - - Accidental_placement::add_accidental (accidental_placement_, a); - announce_grob (a, SCM_EOL); - - - SCM accs = gh_cons (gh_int2scm (pitch->get_alteration ()), SCM_EOL); - if (num == 2 && extra_natural_b) - accs = gh_cons (gh_int2scm (0), accs); - - if (cautionary) - { - a->set_grob_property ("cautionary", SCM_BOOL_T); - } - - if (tie_break_reminder) - { - a->set_grob_property ("tie", tie_break_reminder->self_scm()); - } - - - support->set_grob_property ("accidental-grob", a->self_scm ()); - - a->set_grob_property ("accidentals", accs); - accidentals_[i].accidental_ = a; - /* - We add the accidentals to the support of the arpeggio, so it is - put left of the accidentals. - */ - for (int i = 0; i < arpeggios_.size (); i++) - Side_position_interface::add_support (arpeggios_[i], a); - } - } -} - -void -New_accidental_engraver::process_acknowledged_grobs () -{ - if (accidentals_.size () && accidentals_.top().pass_done_ < 1) - process_grobs_first_pass (); -} - -void -New_accidental_engraver::finalize () -{ - -} - -void -New_accidental_engraver::stop_translation_timestep () -{ - merge_property_on_family(daddy_trans_, "localKeySignatureChanges", "localKeySignature"); - if (accidentals_.size () && accidentals_.top().pass_done_ < 2) - process_grobs_second_pass (); - - for (int i = 0; i < accidentals_.size(); i++) - { - Grob *a = accidentals_[i].accidental_; - if (a) - { - typeset_grob (a); - } - } - - if (accidental_placement_) - typeset_grob(accidental_placement_); - accidental_placement_ = 00; - - set_property_on_family(daddy_trans_, "localKeySignatureChanges", SCM_EOL); - accidentals_.clear(); - arpeggios_.clear (); - ties_.clear (); -} - -void -New_accidental_engraver::acknowledge_grob (Grob_info info) -{ - Music * note = info.music_cause (); - - if (note - && note->is_mus_type ("note-event") - && Rhythmic_head::has_interface (info.grob_)) - { - New_accidental_entry entry ; - entry.head_ = info.grob_; - entry.origin_ = info.origin_trans_->daddy_trans_; - entry.melodic_ = note; - - accidentals_.push (entry); - } - else if (Tie::has_interface (info.grob_)) - { - ties_.push (info.grob_); - } - else if (Arpeggio::has_interface (info.grob_)) - { - arpeggios_.push (info.grob_); - } - -} - -void -New_accidental_engraver::process_music () -{ - SCM sig = get_property ("keySignature"); - - /* Detect key sig changes. - Update all parents and children - */ - if (last_keysig_ != sig) - { - set_property_on_family(daddy_trans_, "localKeySignature", sig); - set_property_on_family(daddy_trans_, "localKeySignatureChanges", SCM_EOL); //This souldn't be neccesary - last_keysig_ = sig; - } -} - - - - - -ENTER_DESCRIPTION (New_accidental_engraver, -"Make accidentals. Catches note heads, ties and notices key-change " -"events. Due to interaction with ties (which don't come together " -"with note heads), this needs to be in a context higher than Tie_engraver.", - - "Accidental", -/* accepts */ "", - "rhythmic-head-interface tie-interface arpeggio-interface", - "localKeySignature localKeySignatureChanges extraNatural autoAccidentals autoCautionaries", - "localKeySignature localKeySignatureChanges"); diff --git a/lily/new-fingering-engraver.cc b/lily/new-fingering-engraver.cc index 35e7e3328e..9af231f9e9 100644 --- a/lily/new-fingering-engraver.cc +++ b/lily/new-fingering-engraver.cc @@ -112,7 +112,7 @@ New_fingering_engraver::add_script (Grob * head, Finger_tuple ft ; Grob * g= make_item ("Script"); - make_script_from_event (g, &ft.description_, daddy_trans_, + make_script_from_event (g, &ft.description_, daddy_context_, event->get_mus_property ("articulation-type"), 0); if (g) { diff --git a/lily/new-lyric-combine-music-iterator.cc b/lily/new-lyric-combine-music-iterator.cc index 43660044ad..0278c0eaf2 100644 --- a/lily/new-lyric-combine-music-iterator.cc +++ b/lily/new-lyric-combine-music-iterator.cc @@ -7,7 +7,7 @@ source file of the GNU LilyPond music typesetter */ -#include "translator-group.hh" +#include "context.hh" #include "lyric-combine-music.hh" #include "event.hh" #include "grob.hh" @@ -29,14 +29,14 @@ protected: virtual bool run_always ()const; virtual bool ok () const; virtual void derived_mark () const; - virtual void derived_substitute (Translator_group*,Translator_group*); + virtual void derived_substitute (Context *,Context *); private: bool start_new_syllable () ; void find_voice (); bool made_association_; - Translator_group * lyrics_context_; - Translator_group* music_context_; + Context * lyrics_context_; + Context * music_context_; Music_iterator * lyric_iter_; }; @@ -123,7 +123,7 @@ New_lyric_combine_music_iterator::derived_mark()const } void -New_lyric_combine_music_iterator::derived_substitute (Translator_group*f, Translator_group*t) +New_lyric_combine_music_iterator::derived_substitute (Context *f, Context *t) { if (lyric_iter_) lyric_iter_->substitute_outlet (f,t); @@ -133,32 +133,6 @@ New_lyric_combine_music_iterator::derived_substitute (Translator_group*f, Transl music_context_ = t; } -/* - ID == "" means accept any ID. - */ -Translator_group * -find_context_below (Translator_group * where, - String type, String id) -{ - if (where->is_alias (ly_symbol2scm (type.to_str0 ()))) - { - if (id == "" || where->id_string_ == id) - return where; - } - - Translator_group * found = 0; - for (SCM s = where->trans_group_list_; - !found && gh_pair_p (s); s = gh_cdr (s)) - { - Translator_group * tr = dynamic_cast (unsmob_translator (gh_car (s))); - - found = find_context_below (tr, type, id); - } - - return found; -} - - void New_lyric_combine_music_iterator::construct_children () @@ -188,12 +162,12 @@ New_lyric_combine_music_iterator::find_voice () if (gh_string_p (voice_name)) { - Translator_group *t = get_outlet (); - while (t && t->daddy_trans_) - t = t->daddy_trans_; + Context *t = get_outlet (); + while (t && t->daddy_context_) + t = t->daddy_context_; String name = ly_scm2string (voice_name); - Translator_group *voice = find_context_below (t, "Voice", name); + Context *voice = find_context_below (t, "Voice", name); if (!voice) get_music ()->origin ()->warning (_f ("cannot find Voice: %s\n", name.to_str0 ())); @@ -221,7 +195,7 @@ New_lyric_combine_music_iterator::process (Moment ) if (!music_context_) return ; - if (!music_context_->daddy_trans_) + if (!music_context_->daddy_context_) { /* The melody has died. diff --git a/lily/new-part-combine-iterator.cc b/lily/new-part-combine-iterator.cc index c45b7fd463..79e3e7c889 100644 --- a/lily/new-part-combine-iterator.cc +++ b/lily/new-part-combine-iterator.cc @@ -6,7 +6,7 @@ (c) 2004 Han-Wen Nienhuys */ -#include "translator-group.hh" +#include "context.hh" #include "event.hh" #include "music-sequence.hh" #include "lily-guile.hh" @@ -21,7 +21,7 @@ public: DECLARE_SCHEME_CALLBACK(constructor, ()); protected: - virtual void derived_substitute (Translator_group*f, Translator_group*t) ; + virtual void derived_substitute (Context *f, Context *t) ; virtual void derived_mark () const; New_pc_iterator (New_pc_iterator const &); @@ -57,10 +57,10 @@ private: Interpretation_context_handle shared_; Interpretation_context_handle solo_; - void substitute_both (Translator_group * to1, - Translator_group * to2); + void substitute_both (Context * to1, + Context * to2); - void kill_mmrest (Translator_group*); + void kill_mmrest (Context *); void chords_together (); void solo1 (); void solo2 (); @@ -88,8 +88,8 @@ New_pc_iterator::derived_mark () const } void -New_pc_iterator::derived_substitute (Translator_group*f, - Translator_group*t) +New_pc_iterator::derived_substitute (Context *f, + Context *t) { if (first_iter_) first_iter_->substitute_outlet (f,t); @@ -147,7 +147,7 @@ New_pc_iterator::chords_together () void -New_pc_iterator::kill_mmrest (Translator_group * tg) +New_pc_iterator::kill_mmrest (Context * tg) { static Music * mmrest; if (!mmrest) @@ -186,10 +186,10 @@ New_pc_iterator::solo1 () } void -New_pc_iterator::substitute_both (Translator_group * to1, - Translator_group * to2) +New_pc_iterator::substitute_both (Context * to1, + Context * to2) { - Translator_group *tos[] = {to1,to2}; + Context *tos[] = {to1,to2}; Music_iterator *mis[] = {first_iter_, second_iter_}; Interpretation_context_handle *hs[] = { &null_, @@ -207,7 +207,7 @@ New_pc_iterator::substitute_both (Translator_group * to1, for (int j = 0; hs[j]; j++) { - Translator_group* t = hs[j]->get_outlet (); + Context * t = hs[j]->get_outlet (); if (t != to1 && t != to2) kill_mmrest (t); } @@ -293,8 +293,8 @@ New_pc_iterator::construct_children () SCM_UNDEFINED); - Translator_group *tr - = get_outlet ()->find_create_translator (ly_symbol2scm ("Voice"), + Context *tr + = get_outlet ()->find_create_context (ly_symbol2scm ("Voice"), "shared",props); shared_.set_translator (tr); @@ -304,14 +304,14 @@ New_pc_iterator::construct_children () */ set_translator (tr); - Translator_group *solo_tr - = get_outlet ()->find_create_translator (ly_symbol2scm ("Voice"), + Context *solo_tr + = get_outlet ()->find_create_context (ly_symbol2scm ("Voice"), "solo",props); solo_ .set_translator (solo_tr); - Translator_group *null - = get_outlet ()->find_create_translator (ly_symbol2scm ("Devnull"), + Context *null + = get_outlet ()->find_create_context (ly_symbol2scm ("Devnull"), "", SCM_EOL); if (!null) @@ -319,7 +319,7 @@ New_pc_iterator::construct_children () null_.set_translator (null); - Translator_group *one = tr->find_create_translator (ly_symbol2scm ("Voice"), + Context *one = tr->find_create_context (ly_symbol2scm ("Voice"), "one", props); one_.set_translator (one); @@ -328,7 +328,7 @@ New_pc_iterator::construct_children () first_iter_ = unsmob_iterator (get_iterator (unsmob_music (gh_car (lst)))); - Translator_group *two = tr->find_create_translator (ly_symbol2scm ("Voice"), + Context *two = tr->find_create_context (ly_symbol2scm ("Voice"), "two", props); two_.set_translator (two); set_translator (two); diff --git a/lily/note-head-line-engraver.cc b/lily/note-head-line-engraver.cc index e2eb02f043..6cb90f4e71 100644 --- a/lily/note-head-line-engraver.cc +++ b/lily/note-head-line-engraver.cc @@ -15,7 +15,8 @@ #include "rhythmic-head.hh" #include "side-position-interface.hh" #include "staff-symbol-referencer.hh" -#include "translator-group.hh" +#include "context.hh" + /** Create line-spanner grobs for lines that connect note heads. @@ -36,7 +37,7 @@ protected: private: Spanner* line_; - Translator* last_staff_; + Context* last_staff_; bool follow_; Grob* head_; Grob* last_head_; @@ -59,11 +60,12 @@ Note_head_line_engraver::acknowledge_grob (Grob_info info) head_ = info.grob_; if (to_boolean (get_property ("followVoice"))) { - Translator_group * tr = daddy_trans_; + Context * tr = daddy_context_; while (tr && !tr->is_alias (ly_symbol2scm ( "Staff"))) - tr = tr->daddy_trans_ ; + tr = tr->daddy_context_ ; - if (tr && tr->is_alias (ly_symbol2scm ("Staff")) && tr != last_staff_) + if (tr + && tr->is_alias (ly_symbol2scm ("Staff")) && tr != last_staff_) { if (last_head_) follow_ = true; diff --git a/lily/note-performer.cc b/lily/note-performer.cc index 22df5b0fb8..cab4f8e287 100644 --- a/lily/note-performer.cc +++ b/lily/note-performer.cc @@ -10,7 +10,7 @@ #include "event.hh" #include "audio-item.hh" #include "audio-column.hh" -#include "global-translator.hh" +#include "global-context.hh" #include "warn.hh" /** @@ -25,8 +25,7 @@ protected: virtual void stop_translation_timestep (); virtual void create_audio_elements (); - Global_translator* get_global_translator (); - + private: Link_array note_evs_; Link_array notes_; @@ -61,29 +60,13 @@ Note_performer::create_audio_elements () } } -Global_translator* -Note_performer::get_global_translator () -{ - Translator *t = this; - Global_translator *global =0; - do - { - t = t->daddy_trans_ ; - global = dynamic_cast (t); - } - while (!global); - - return global; -} - void Note_performer::stop_translation_timestep () { - // why don't grace notes show up here? // --> grace notes effectively do not get delayed - Global_translator* global = get_global_translator (); + Global_context * global = get_global_context (); for (int i=0; i < notes_.size (); i++) { Audio_note* n = notes_[i]; diff --git a/lily/note-spacing.cc b/lily/note-spacing.cc index 40cb91d5ba..6a8600e7d4 100644 --- a/lily/note-spacing.cc +++ b/lily/note-spacing.cc @@ -448,6 +448,6 @@ Note_spacing::stem_dir_correction (Grob*me, Item * rcolumn, ADD_INTERFACE (Note_spacing,"note-spacing-interface", - "", + "This object calculates spacing wishes for individual voices.", "left-items right-items stem-spacing-correction knee-spacing-correction"); diff --git a/lily/output-property-engraver.cc b/lily/output-property-engraver.cc index 3d43a85a6e..7af3914c8e 100644 --- a/lily/output-property-engraver.cc +++ b/lily/output-property-engraver.cc @@ -9,7 +9,8 @@ #include "engraver.hh" #include "grob.hh" -#include "translator-group.hh" +#include "context.hh" + class Output_property_engraver : public Engraver { @@ -59,17 +60,17 @@ Output_property_engraver::acknowledge_grob (Grob_info inf) } else { - Translator_group * d = - dynamic_cast (inf.origin_trans_); + Context * d = + dynamic_cast (inf.origin_trans_); if (!d) - d = dynamic_cast (inf.origin_trans_->daddy_trans_); + d = dynamic_cast (inf.origin_trans_->daddy_context_); SCM proc = o->get_mus_property ("procedure"); scm_call_3 (proc, inf.grob_->self_scm(), d->self_scm(), - daddy_trans_->self_scm()); + daddy_context_->self_scm()); } } } diff --git a/lily/paper-column.cc b/lily/paper-column.cc index af24691999..9de3eda80e 100644 --- a/lily/paper-column.cc +++ b/lily/paper-column.cc @@ -22,23 +22,21 @@ ADD_INTERFACE (Paper_column, "paper-column-interface", - " Paper_columns form the top-most item parent. (The Paper_columns X\n" -" parent is System, which is a spanner.)\n" -"\n" -" Paper_columns form the units for the spacing engine. They are\n" -" numbered, the first (leftmost) is column 0. Numbering happens before\n" -" line-breaking, and columns are not renumbered after line breaking.\n" -"\n" -" Since many columns go unused, you should only use the rank field to\n" -" get ordering information. Two adjacent columns may have\n" -" non-adjacent numbers.\n" -"\n" -" Don't be confused by right-items: each spacing wish can also contain\n" -" a number of items, with which a spacing constraint may be kept. It's\n" -" a little baroque, but it might come in handy later on?\n" -"\n", - "between-cols between-system-string when bounded-by-me shortest-playing-duration shortest-starter-duration"); - + "@code{Paper_column} objects form the top-most X-parents for items. " + " The are two types of columns: musical columns, where are attached to, and " + " non-musical columns, where bar-lines, clefs etc. are attached to. " + " The spacing engine determines the X-positions of these objects." + "\n\n" + "They are\n" + " numbered, the first (leftmost) is column 0. Numbering happens before\n" + " line-breaking, and columns are not renumbered after line breaking.\n" + " Since many columns go unused, you should only use the rank field to\n" + " get ordering information. Two adjacent columns may have\n" + " non-adjacent numbers.\n" + "\n" + , + "between-cols between-system-string when bounded-by-me " + "shortest-playing-duration shortest-starter-duration"); void Paper_column::do_break_processing () diff --git a/lily/paper-score.cc b/lily/paper-score.cc index ac8af7494b..31f2dd7a63 100644 --- a/lily/paper-score.cc +++ b/lily/paper-score.cc @@ -83,7 +83,7 @@ Paper_score::process (String outname) /* Be sure to set breakability on first & last column. */ - { + { /* doubly, also done in Score_engraver */ Link_array pc (system_->columns ()); pc[0]->set_grob_property ("breakable", SCM_BOOL_T); diff --git a/lily/parser.yy b/lily/parser.yy index 9f0096c2f5..a7ba07ef8b 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -1386,25 +1386,21 @@ command_element: | BAR STRING { Music *t = set_property_music (ly_symbol2scm ("whichBar"), $2); - Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic"); - csm->set_mus_property ("element", t->self_scm ()); - scm_gc_unprotect_object (t->self_scm ()); - - $$ = csm; + Music *csm = context_spec_music (ly_symbol2scm ("Timing"), SCM_UNDEFINED, + t, SCM_EOL); + $$ = context_spec_music (ly_symbol2scm ("Score"), SCM_UNDEFINED, csm, SCM_EOL); $$->set_spot (THIS->here_input ()); - - csm->set_mus_property ("context-type", ly_symbol2scm ("Timing")); + t->set_spot (THIS->here_input ()); } | PARTIAL duration_length { Moment m = - unsmob_duration ($2)->get_length (); Music * p = set_property_music (ly_symbol2scm ( "measurePosition"),m.smobbed_copy ()); - - Music * sp = MY_MAKE_MUSIC("ContextSpeccedMusic"); - sp->set_mus_property ("element", p->self_scm ()); - scm_gc_unprotect_object (p->self_scm ()); - - $$ =sp ; - sp-> set_mus_property ("context-type", ly_symbol2scm ("Timing")); + p->set_spot (THIS->here_input ()); + p = context_spec_music (ly_symbol2scm ("Timing"), SCM_UNDEFINED, + p, SCM_EOL); + p = context_spec_music (ly_symbol2scm ("Score"), SCM_UNDEFINED, + p, SCM_EOL); + $$ =p ; } | CLEF STRING { static SCM proc ; diff --git a/lily/percent-repeat-engraver.cc b/lily/percent-repeat-engraver.cc index 09009b0baf..87e08fa3ec 100644 --- a/lily/percent-repeat-engraver.cc +++ b/lily/percent-repeat-engraver.cc @@ -10,7 +10,7 @@ #include "engraver.hh" #include "repeated-music.hh" #include "engraver-group-engraver.hh" -#include "global-translator.hh" +#include "global-context.hh" #include "warn.hh" #include "misc.hh" #include "spanner.hh" @@ -19,7 +19,8 @@ #include "bar-line.hh" #include "score-engraver.hh" -#include "translator-group.hh" +#include "context.hh" + /** This acknowledges repeated music with "percent" style. It typesets @@ -113,7 +114,7 @@ Percent_repeat_engraver::try_music (Music * m) repeat_ = rp; - Global_translator *global =top_engraver(); + Global_context *global = get_global_context (); for (int i = 0; i < count; i++) global->add_moment_to_process (next_moment_ + Moment (i) * body_length_); @@ -146,11 +147,11 @@ Percent_repeat_engraver::process_music () forbid breaks on a % line. Should forbid all breaks, really. */ - top_engraver()->forbid_breaks (); // guh. Use properties! + get_score_engraver ()->forbid_breaks (); // guh. Use properties! } next_moment_ = next_moment_ + body_length_; - top_engraver()->add_moment_to_process (next_moment_); + get_global_context ()->add_moment_to_process (next_moment_); } } diff --git a/lily/percent-repeat-iterator.cc b/lily/percent-repeat-iterator.cc index e2358a03e4..8bb34c4e66 100644 --- a/lily/percent-repeat-iterator.cc +++ b/lily/percent-repeat-iterator.cc @@ -86,7 +86,7 @@ Percent_repeat_iterator::derived_mark()const } void -Percent_repeat_iterator::derived_substitute(Translator_group*f,Translator_group*t ) +Percent_repeat_iterator::derived_substitute(Context *f,Context *t ) { if (child_iter_) child_iter_->substitute_outlet (f,t); diff --git a/lily/performer-group-performer.cc b/lily/performer-group-performer.cc index 55776074c0..9002977250 100644 --- a/lily/performer-group-performer.cc +++ b/lily/performer-group-performer.cc @@ -8,7 +8,7 @@ */ #include "performer-group-performer.hh" - +#include "context.hh" #include "audio-element.hh" #include "warn.hh" @@ -27,21 +27,11 @@ void Performer_group_performer::announce_element (Audio_element_info info) { announce_infos_.push (info); - Performer::announce_element (info); -} - - + Translator *t + = unsmob_translator (daddy_context_->daddy_context_->implementation_); -void -Performer_group_performer::create_audio_elements () -{ - for (SCM p = get_simple_trans_list (); gh_pair_p (p); p = ly_cdr (p)) - { - Translator * t = unsmob_translator (ly_car (p)); - Performer * eng = dynamic_cast (t); - if (eng) - eng->create_audio_elements (); - } + if (Performer_group_performer * eg = dynamic_cast (t)) + eg->announce_element (info); } void @@ -64,29 +54,16 @@ Performer_group_performer::acknowledge_audio_elements () void Performer_group_performer::do_announces () { - for (SCM p = trans_group_list_; gh_pair_p (p); p =ly_cdr (p)) + while (1) { - Translator * t = unsmob_translator (ly_car (p)); - dynamic_cast (t)->do_announces (); - } - + performer_each (get_simple_trans_list (), + &Performer::create_audio_elements); - create_audio_elements (); - - while (announce_infos_.size ()) - { + if (!announce_infos_.size ()) + break ; + acknowledge_audio_elements (); announce_infos_.clear (); - create_audio_elements (); - } - - if (announce_infos_.size ()) - { -#if 0 //printf? -> include - printf ("do_announces: elt: %s\n", - classname (announce_infos_[0].elem_)); -#endif - announce_infos_.clear (); } } @@ -94,27 +71,44 @@ Performer_group_performer::Performer_group_performer() { } -/* - C & P from Engraver. - - Should move into Translator ? - */ +/* c&p engraver-group.cc */ void -Performer_group_performer::process_music () +recurse_down_performers (Context * c, Performer_method ptr, bool context_first) { - for (SCM p = get_simple_trans_list (); gh_pair_p (p); p =ly_cdr (p)) + Performer_group_performer * tg + = dynamic_cast (unsmob_translator (c->implementation_)); + + + if (!context_first) { - Translator * t = unsmob_translator (ly_car (p)); - Performer * eng = dynamic_cast (t); + performer_each (tg->get_simple_trans_list (), + ptr); - if (eng) - eng->process_music (); + (tg->*ptr) (); } - for (SCM p = trans_group_list_; gh_pair_p (p); p =ly_cdr (p)) + + for (SCM s = c->context_list_ ; gh_pair_p (s); + s =gh_cdr (s)) + { + recurse_down_performers (unsmob_context (gh_car (s)), ptr, context_first); + } + + if (context_first) + { + performer_each (tg->get_simple_trans_list (), + ptr); + (tg->*ptr) (); + } +} + + +void +performer_each (SCM list, Performer_method method) +{ + for (SCM p = list; gh_pair_p (p); p = ly_cdr (p)) { - Translator * t = unsmob_translator (ly_car (p)); - Performer*eng = dynamic_cast (t); - if (eng) - eng->process_music (); + Performer * e = dynamic_cast(unsmob_translator (ly_car (p))); + if (e) + (e->*method) (); } } diff --git a/lily/performer.cc b/lily/performer.cc index 6d618346ea..ebf5a030fb 100644 --- a/lily/performer.cc +++ b/lily/performer.cc @@ -7,28 +7,32 @@ Jan Nieuwenhuizen */ - +#include "context.hh" #include "performer-group-performer.hh" #include "warn.hh" +void +Performer::do_announces () +{ +} + void Performer::play_element (Audio_element* p) { - get_daddy_perf ()->play_element (p); + get_daddy_performer ()->play_element (p); } int Performer::get_tempo () const { - return get_daddy_perf ()->get_tempo (); + return get_daddy_performer ()->get_tempo (); } Performer_group_performer* -Performer::get_daddy_perf () const +Performer::get_daddy_performer () const { - return (daddy_trans_) - ?dynamic_cast (daddy_trans_) - : 0; + return + dynamic_cast (get_daddy_translator ()); } void @@ -47,10 +51,9 @@ Performer::announce_element (Audio_element_info i) { if (!i.origin_trans_) i.origin_trans_= this; - get_daddy_perf ()->announce_element (i); + get_daddy_performer ()->announce_element (i); } - void Performer::process_music () { diff --git a/lily/phrasing-slur-engraver.cc b/lily/phrasing-slur-engraver.cc index b3aa443e9a..80baaabdd1 100644 --- a/lily/phrasing-slur-engraver.cc +++ b/lily/phrasing-slur-engraver.cc @@ -8,7 +8,8 @@ #include "slur.hh" #include "warn.hh" #include "note-column.hh" -#include "translator-group.hh" +#include "context.hh" + #include "engraver.hh" #include "spanner.hh" diff --git a/lily/piano-pedal-bracket.cc b/lily/piano-pedal-bracket.cc index fb9a2ac4f6..7ec72e0ca6 100644 --- a/lily/piano-pedal-bracket.cc +++ b/lily/piano-pedal-bracket.cc @@ -87,5 +87,6 @@ Piano_pedal_bracket::print (SCM smob) ADD_INTERFACE (Piano_pedal_bracket,"piano-pedal-bracket-interface", - "The bracket of the piano pedal. It can be tuned through the regular bracket properties (bracket-flare, edge-height, shorten-pair).", + "The bracket of the piano pedal. It can be tuned through the regular " + "bracket properties.", "edge-height shorten-pair bracket-flare pedal-text"); diff --git a/lily/piano-pedal-engraver.cc b/lily/piano-pedal-engraver.cc index 77283f3bce..f4663da8c6 100644 --- a/lily/piano-pedal-engraver.cc +++ b/lily/piano-pedal-engraver.cc @@ -18,7 +18,8 @@ #include "staff-symbol-referencer.hh" #include "item.hh" #include "axis-group-interface.hh" -#include "translator-group.hh" +#include "context.hh" + #include "directional-element-interface.hh" #include "note-column.hh" #include "warn.hh" diff --git a/lily/pitch.cc b/lily/pitch.cc index 76ab39c9e2..e01026da3d 100644 --- a/lily/pitch.cc +++ b/lily/pitch.cc @@ -309,17 +309,17 @@ Pitch::less_p (SCM p1, SCM p2) */ LY_DEFINE(make_pitch, "ly:make-pitch", 3, 0, 0, - (SCM o, SCM n, SCM a), + (SCM octave, SCM note, SCM alter), "@var{octave} is specified by an integer, zero for the octave containing " "middle C. @var{note} is a number from 0 to 6, with 0 corresponding to C " - "and 6 corresponding to B. The shift is zero for a natural, negative for " + "and 6 corresponding to B. The @var{alter} is zero for a natural, negative for " "flats, or positive for sharps. ") { - SCM_ASSERT_TYPE(gh_number_p (o), o, SCM_ARG1, __FUNCTION__, "number"); - SCM_ASSERT_TYPE(gh_number_p (n), n, SCM_ARG2, __FUNCTION__, "number"); - SCM_ASSERT_TYPE(gh_number_p (a), a, SCM_ARG3, __FUNCTION__, "number"); + SCM_ASSERT_TYPE(scm_integer_p (octave)== SCM_BOOL_T , octave, SCM_ARG1, __FUNCTION__, "integer"); + SCM_ASSERT_TYPE(scm_integer_p (note)== SCM_BOOL_T, note, SCM_ARG2, __FUNCTION__, "integer"); + SCM_ASSERT_TYPE(scm_integer_p (alter)== SCM_BOOL_T, alter, SCM_ARG3, __FUNCTION__, "integer"); - Pitch p (gh_scm2int (o), gh_scm2int (n), gh_scm2int (a)); + Pitch p (gh_scm2int (octave), gh_scm2int (note), gh_scm2int (alter)); return p.smobbed_copy (); } @@ -407,8 +407,9 @@ LY_DEFINE(pitch_less, "ly:pitch (unsmob_translator (translator)); + Context * tg + = dynamic_cast (unsmob_context (translator)); SCM sym = m->get_mus_property ("symbol"); tg->unset_property (sym); @@ -66,8 +64,7 @@ Property_iterator::do_quit () SCM trans = get_outlet ()->self_scm(); SCM music = get_music()->self_scm(); - Global_translator * tg= get_outlet ()->top_translator (); - + Global_context * tg = get_outlet ()->get_global_context (); tg->add_finalization (scm_list_n (once_finalization_proc, trans, music, SCM_UNDEFINED)); } @@ -123,7 +120,7 @@ SCM Push_property_iterator::once_finalization (SCM trans, SCM music) { Music * mus = unsmob_music (music); - Translator_group * tg = dynamic_cast (unsmob_translator (trans)); + Context * tg = dynamic_cast (unsmob_context (trans)); SCM sym = mus->get_mus_property ("symbol"); if (check_grob (mus, sym)) @@ -143,7 +140,7 @@ Push_property_iterator::do_quit () SCM trans = get_outlet ()->self_scm(); SCM music = get_music ()->self_scm(); - Global_translator * tg= get_outlet ()->top_translator (); + Global_context * tg= get_outlet ()->get_global_context (); tg->add_finalization (scm_list_n (once_finalization_proc, trans, music, SCM_UNDEFINED)); } diff --git a/lily/recording-group-engraver.cc b/lily/recording-group-engraver.cc index 1deac7f2b7..2a0970b509 100644 --- a/lily/recording-group-engraver.cc +++ b/lily/recording-group-engraver.cc @@ -65,13 +65,10 @@ Recording_group_engraver::finalize () bool Recording_group_engraver::try_music (Music *m) { - bool here_success = Translator_group::try_music_on_nongroup_children (m); - bool retval = here_success; - if (!here_success && daddy_trans_) - retval = daddy_trans_->try_music (m); - + bool retval = Translator_group::try_music (m); + SCM seq = gh_cdar (accumulator_); - seq = gh_cons (gh_cons (m->self_scm(), gh_bool2scm (here_success)), + seq = gh_cons (gh_cons (m->self_scm(), gh_bool2scm (retval)), seq); scm_set_cdr_x (gh_car (accumulator_), seq); diff --git a/lily/repeat-acknowledge-engraver.cc b/lily/repeat-acknowledge-engraver.cc index 18907b15b3..11619e2b78 100644 --- a/lily/repeat-acknowledge-engraver.cc +++ b/lily/repeat-acknowledge-engraver.cc @@ -6,8 +6,10 @@ (c) 2000--2004 Han-Wen Nienhuys */ + #include "engraver.hh" #include "translator-group.hh" +#include "context.hh" #include "repeated-music.hh" @@ -36,7 +38,7 @@ public: void Repeat_acknowledge_engraver::initialize () { - daddy_trans_->set_property ("repeatCommands", SCM_EOL); + daddy_context_->set_property ("repeatCommands", SCM_EOL); } @@ -47,9 +49,9 @@ Repeat_acknowledge_engraver::Repeat_acknowledge_engraver () void Repeat_acknowledge_engraver::start_translation_timestep () { - Translator_group * tr = daddy_trans_->where_defined (ly_symbol2scm ("repeatCommands")); + Context * tr = daddy_context_->where_defined (ly_symbol2scm ("repeatCommands")); if (!tr) - tr = daddy_trans_; + tr = daddy_context_; tr->set_property ("repeatCommands", SCM_EOL); } @@ -102,7 +104,7 @@ Repeat_acknowledge_engraver::process_music () { if (s != "" || (volta_found && !gh_string_p (wb))) { - daddy_trans_->set_property ("whichBar", scm_makfrom0str (s.to_str0 ())); + daddy_context_->set_property ("whichBar", scm_makfrom0str (s.to_str0 ())); } } } diff --git a/lily/rest.cc b/lily/rest.cc index ffc32784b5..a349217c29 100644 --- a/lily/rest.cc +++ b/lily/rest.cc @@ -173,6 +173,6 @@ Rest::polyphonic_offset_callback (SCM smob, SCM) } ADD_INTERFACE (Rest,"rest-interface", - "a rest", + "A rest symbol.", "style minimum-distance"); diff --git a/lily/score-context.cc b/lily/score-context.cc new file mode 100644 index 0000000000..fe78acdf5a --- /dev/null +++ b/lily/score-context.cc @@ -0,0 +1,49 @@ +/* +score-context.cc -- implement + +source file of the GNU LilyPond music typesetter + +(c) 2004 Han-Wen Nienhuys + + */ + + +#include "score-context.hh" +#include "score-translator.hh" + + +void +Score_context::prepare (Moment w) +{ + Translator* t = unsmob_translator (implementation_); + Score_translator * s = dynamic_cast (t); + + s->prepare (w); +} + +void +Score_context::finish () +{ + Translator* t = unsmob_translator (implementation_); + Score_translator * s = dynamic_cast (t); + + s->finish (); +} + +void +Score_context::one_time_step () +{ + Translator* t = unsmob_translator (implementation_); + Score_translator * s = dynamic_cast (t); + s->one_time_step(); +} + + +Music_output* +Score_context::get_output () +{ + Translator* t = unsmob_translator (implementation_); + Score_translator * s = dynamic_cast (t); + return s->get_output (); +} + diff --git a/lily/score-engraver.cc b/lily/score-engraver.cc index a100c17d04..c6748a3452 100644 --- a/lily/score-engraver.cc +++ b/lily/score-engraver.cc @@ -15,13 +15,16 @@ #include "score-engraver.hh" #include "paper-score.hh" #include "paper-column.hh" - #include "paper-def.hh" #include "axis-group-interface.hh" #include "context-def.hh" - #include "staff-spacing.hh" #include "note-spacing.hh" +#include "context.hh" +#include "global-context.hh" + + + /* TODO: the column creation logic is rather hairy. Revise it. @@ -44,15 +47,12 @@ Score_engraver::make_columns () if (!command_column_) { SCM nmp - = updated_grob_properties (this, + = updated_grob_properties (daddy_context_, ly_symbol2scm ("NonMusicalPaperColumn")); - SCM pc = updated_grob_properties (this, + SCM pc = updated_grob_properties (daddy_context_, ly_symbol2scm ("PaperColumn")); set_columns (new Paper_column (nmp), new Paper_column (pc)); - - command_column_->set_grob_property ("breakable", SCM_BOOL_T); - Grob_info i1; i1.grob_ = command_column_; @@ -69,20 +69,18 @@ Score_engraver::make_columns () } void -Score_engraver::prepare (Moment w) +Score_engraver::prepare (Moment m) { - Global_translator::prepare (w); - /* TODO: don't make columns when skipTypesetting is true. */ make_columns (); - - command_column_->set_grob_property ("when", now_mom_.smobbed_copy ()); - musical_column_->set_grob_property ("when", now_mom_.smobbed_copy ()); + SCM w = m.smobbed_copy (); + command_column_->set_grob_property ("when", w); + musical_column_->set_grob_property ("when", w); - Translator_group::start_translation_timestep(); + recurse_down_translators (daddy_context_, &Translator::start_translation_timestep, false); } void @@ -90,9 +88,8 @@ Score_engraver::finish () { if ((breaks_%8)) progress_indication ("[" + to_string (breaks_) + "]"); - - check_removal (); - finalize (); + + recurse_down_translators (daddy_context_, &Translator::finalize, true); } /* @@ -106,13 +103,11 @@ Score_engraver::initialize () error (_f ("can't find `%s'", "feta20.afm") + "\n" +_ ("Fonts have not been installed properly. Aborting")); - unsmob_context_def (definition_)->apply_default_property_operations (this); - assert (!daddy_trans_); pscore_ = new Paper_score; pscore_->paper_ = dynamic_cast (get_output_def ()); - SCM props = updated_grob_properties (this, ly_symbol2scm ("System")); + SCM props = updated_grob_properties (daddy_context_, ly_symbol2scm ("System")); pscore_->typeset_line (new System (props)); @@ -128,7 +123,7 @@ Score_engraver::initialize () void Score_engraver::finalize () { - Engraver_group_engraver::finalize (); + Score_translator::finalize (); Grob * cc = unsmob_grob (get_property ("currentCommandColumn")); @@ -138,33 +133,17 @@ Score_engraver::finalize () typeset_all (); } + void Score_engraver::one_time_step () { if (!to_boolean (get_property ("skipTypesetting"))) { - process_music (); - do_announces (); + recurse_down_engravers (daddy_context_, &Engraver::process_music, false); + recurse_down_engravers (daddy_context_, &Engraver::do_announces, true); } - stop_translation_timestep (); - - apply_finalizations (); - check_removal (); - - - for (int i = announce_infos_.size(); i--;) - { - Grob *g = announce_infos_[i].grob_; - if (!dynamic_cast (g)) // ugh. - { - String msg= "Grob " - + g->name() - + " was created too late!"; - g->programming_error (msg); - } - } - announce_infos_.clear (); + recurse_down_translators (daddy_context_, &Translator::stop_translation_timestep, true); } void @@ -262,12 +241,12 @@ Score_engraver::set_columns (Paper_column *new_command, musical_column_ = new_musical; if (new_command) { - set_property ("currentCommandColumn", new_command->self_scm ()); + daddy_context_->set_property ("currentCommandColumn", new_command->self_scm ()); } if (new_musical) { - set_property ("currentMusicalColumn", new_musical->self_scm ()); + daddy_context_->set_property ("currentMusicalColumn", new_musical->self_scm ()); } } @@ -307,15 +286,9 @@ Score_engraver::try_music (Music*r) return gotcha; } -/* - TODO: use property Score.breakForbidden = #t - */ void Score_engraver::forbid_breaks () { - /* - result is junked. - */ if (command_column_) command_column_->set_grob_property ("breakable", SCM_EOL); } diff --git a/lily/score-performer.cc b/lily/score-performer.cc index 9c1e55f3c2..d44a836e35 100644 --- a/lily/score-performer.cc +++ b/lily/score-performer.cc @@ -51,54 +51,31 @@ void Score_performer::announce_element (Audio_element_info info) { announce_infos_.push (info); - - - /* - huh? - copied from score-engraver, but - this way staff gets in list twice - if (Audio_item* i = dynamic_cast (info.elem_)) - performance_->add_element (i); - */ } void Score_performer::prepare (Moment m) { - Global_translator::prepare (m); audio_column_ = new Audio_column (m); play_element (audio_column_); - start_translation_timestep (); + recurse_down_translators (daddy_context_, &Translator::start_translation_timestep, true); } void Score_performer::one_time_step () { - process_music (); - do_announces (); - stop_translation_timestep (); - check_removal (); -} - -void -Score_performer::start () -{ + recurse_down_performers (daddy_context_, &Performer::process_music, false); + recurse_down_performers (daddy_context_, &Performer::do_announces, true); + recurse_down_translators (daddy_context_, &Translator::stop_translation_timestep, false); } - int Score_performer::get_tempo () const { return performance_->midi_->get_tempo (Moment (Rational (1, 4))); } -void -Score_performer::finish () -{ - check_removal (); - finalize (); -} Music_output * Score_performer::get_output () @@ -111,7 +88,6 @@ Score_performer::get_output () void Score_performer::initialize () { - unsmob_context_def (definition_)->apply_default_property_operations (this); performance_ = new Performance; performance_->midi_ = dynamic_cast (get_output_def ()); diff --git a/lily/score.cc b/lily/score.cc index eabb2fde90..04f0aa013e 100644 --- a/lily/score.cc +++ b/lily/score.cc @@ -16,7 +16,7 @@ #include "music-output.hh" #include "music-iterator.hh" #include "music.hh" -#include "global-translator.hh" +#include "global-context.hh" #include "scm-hash.hh" #include "cpu-timer.hh" #include "main.hh" @@ -112,7 +112,9 @@ LY_DEFINE(ly_run_translator, "ly:run-translator", SCM_ASSERT_TYPE (odef, output_def, SCM_ARG2, __FUNCTION__, "Output definition"); Cpu_timer timer; - Global_translator * trans = odef->get_global_translator (); + + Global_context * trans = new Global_context (odef); + if (!trans) { programming_error ("no toplevel translator"); @@ -133,7 +135,6 @@ LY_DEFINE(ly_run_translator, "ly:run-translator", return SCM_BOOL_F; // todo: shoudl throw exception. } - trans->start (); trans->run_iterator_on_me (iter); iter->quit(); scm_remember_upto_here_1 (protected_iter); @@ -154,11 +155,10 @@ LY_DEFINE(ly_render_output, "ly:render-output", "and dump the result to @var{out-filename}, using " "@var{header} for the bibliographic information.") { - Translator *tr = unsmob_translator (context); - Global_translator * gt = dynamic_cast (tr); + Global_context * gt = dynamic_cast (unsmob_context (context)); SCM_ASSERT_TYPE(gt, context, SCM_ARG1, __FUNCTION__, - "Score context"); + "Global context"); SCM_ASSERT_TYPE(ly_module_p(header), header, SCM_ARG2, __FUNCTION__, "module"); SCM_ASSERT_TYPE(gh_string_p (out_filename), out_filename, SCM_ARG3, __FUNCTION__, @@ -181,6 +181,7 @@ default_rendering (SCM mus, SCM outdef, SCM head, SCM outname) { SCM context = ly_run_translator (mus, outdef); - if (unsmob_translator (context)) + if (unsmob_context (context)) ly_render_output (context, head, outname); } + diff --git a/lily/script-column.cc b/lily/script-column.cc index 7d8ca6fcfe..56248d3b2b 100644 --- a/lily/script-column.cc +++ b/lily/script-column.cc @@ -51,7 +51,7 @@ Script_column::before_line_breaking (SCM smob) { Grob *sc = unsmob_grob (gh_car (s)); - if (!sc->has_offset_callback_b (Side_position_interface::aligned_side_proc, X_AXIS)) + if (!sc->has_offset_callback (Side_position_interface::aligned_side_proc, X_AXIS)) staff_sided.push (sc); } diff --git a/lily/script-engraver.cc b/lily/script-engraver.cc index e313e0a0e0..ac3c720d1d 100644 --- a/lily/script-engraver.cc +++ b/lily/script-engraver.cc @@ -11,7 +11,8 @@ #include "rhythmic-head.hh" #include "engraver.hh" #include "note-column.hh" -#include "translator-group.hh" +#include "context.hh" + #include "warn.hh" struct Script_tuple @@ -83,7 +84,7 @@ copy_property (Grob * g , SCM sym, SCM alist) ScriptStaccato , ScriptMarcato, etc. ) */ void make_script_from_event (Grob *p, - SCM * descr, Translator_group*tg, + SCM * descr, Context *tg, SCM art_type, int index) { @@ -133,7 +134,7 @@ Script_engraver::process_music () Grob * p = make_item ("Script"); - make_script_from_event (p, &scripts_[i].description_, daddy_trans_, + make_script_from_event (p, &scripts_[i].description_, daddy_context_, l->get_mus_property ("articulation-type"), i); diff --git a/lily/self-aligment-interface.cc b/lily/self-aligment-interface.cc index 010b48bf2a..917dfabc79 100644 --- a/lily/self-aligment-interface.cc +++ b/lily/self-aligment-interface.cc @@ -105,6 +105,19 @@ Self_alignment_interface::aligned_on_self (SCM element_smob, SCM axis) ADD_INTERFACE (Self_alignment_interface, "self-alignment-interface", - "Position self using some alignment", - "self-alignment-X self-alignment-Y"); + "Position this object on itself and/or on its parent. To this end, the following functions " + " are provided: \n" + "@table @code \n" + "@item Self_alignment_interface::aligned_on_self\n" + " Align self on reference point, using @code{self-alignment-X} and " + "@code{self-alignment-Y}." + "@item Self_alignment_interface::aligned_on_parent\n" + "@item Self_alignment_interface::centered_on_parent\n" + " Shift the object so its own reference point is centered on the " + " extent of the parent \n" + "@item Self_alignment_interface::centered_on_other_axis_parent\n" + " For X-axis, center on the Y-parent, and vice versa.\n " + "@end table\n" + , + "self-alignment-X self-alignment-Y"); diff --git a/lily/separating-line-group-engraver.cc b/lily/separating-line-group-engraver.cc index aef4a23a66..5f97221900 100644 --- a/lily/separating-line-group-engraver.cc +++ b/lily/separating-line-group-engraver.cc @@ -16,7 +16,8 @@ #include "note-spacing.hh" #include "group-interface.hh" #include "accidental-placement.hh" -#include "translator-group.hh" +#include "context.hh" + struct Spacings @@ -115,7 +116,7 @@ Separating_line_group_engraver::acknowledge_grob (Grob_info i) return; if (it->get_parent (X_AXIS) && it->get_parent (X_AXIS) - ->has_extent_callback_b(Axis_group_interface::group_extent_callback_proc, X_AXIS)) + ->has_extent_callback(Axis_group_interface::group_extent_callback_proc, X_AXIS)) return; @@ -139,7 +140,7 @@ Separating_line_group_engraver::acknowledge_grob (Grob_info i) if (ib) { p_ref_->set_grob_property ("breakable", SCM_BOOL_T); - daddy_trans_->set_property ("breakableSeparationItem", p_ref_->self_scm ()); + daddy_context_->set_property ("breakableSeparationItem", p_ref_->self_scm ()); } announce_grob(p_ref_, SCM_EOL); @@ -178,7 +179,7 @@ void Separating_line_group_engraver::start_translation_timestep () { if (break_item_) - daddy_trans_->unset_property (ly_symbol2scm ("breakableSeparationItem")); + daddy_context_->unset_property (ly_symbol2scm ("breakableSeparationItem")); break_item_ =0; } diff --git a/lily/sequential-iterator.cc b/lily/sequential-iterator.cc index e0fef5778b..c63d812ccb 100644 --- a/lily/sequential-iterator.cc +++ b/lily/sequential-iterator.cc @@ -7,7 +7,7 @@ */ #include "translator-group.hh" - +#include "context.hh" #include "sequential-iterator.hh" #include "music-list.hh" @@ -72,7 +72,7 @@ Sequential_iterator::derived_mark ()const void -Sequential_iterator::derived_substitute (Translator_group*f,Translator_group*t) +Sequential_iterator::derived_substitute (Context *f,Context *t) { if (iter_) iter_->substitute_outlet (f,t); @@ -215,13 +215,13 @@ Sequential_iterator::next_element (bool) void Sequential_iterator::descend_to_child () { - Translator_group * child_report = child_report = iter_->get_outlet (); - Translator_group * me_report = get_outlet (); + Context * child_report = child_report = iter_->get_outlet (); + Context * me_report = get_outlet (); - Translator_group * c = child_report; + Context * c = child_report; while (c && c != me_report) { - c= c->daddy_trans_; + c= c->daddy_context_; } if (c == me_report) diff --git a/lily/sequential-music-iterator.cc b/lily/sequential-music-iterator.cc index c309287699..775318febe 100644 --- a/lily/sequential-music-iterator.cc +++ b/lily/sequential-music-iterator.cc @@ -6,7 +6,9 @@ (c) 1997--2004 Han-Wen Nienhuys */ -#include "translator-group.hh" +#include "context.hh" + + #include "warn.hh" #include "sequential-music-iterator.hh" #include "music-list.hh" diff --git a/lily/side-position-interface.cc b/lily/side-position-interface.cc index a974a44958..9efea370b3 100644 --- a/lily/side-position-interface.cc +++ b/lily/side-position-interface.cc @@ -244,8 +244,8 @@ Side_position_interface::set_axis (Grob*me, Axis a) Axis Side_position_interface::get_axis (Grob*me) { - if (me->has_offset_callback_b (Side_position_interface::aligned_side_proc, X_AXIS) - || me->has_offset_callback_b (Side_position_interface::aligned_side_proc , X_AXIS)) + if (me->has_offset_callback (Side_position_interface::aligned_side_proc, X_AXIS) + || me->has_offset_callback (Side_position_interface::aligned_side_proc , X_AXIS)) return X_AXIS; diff --git a/lily/simultaneous-music-iterator.cc b/lily/simultaneous-music-iterator.cc index df3c947ba6..a60735b306 100644 --- a/lily/simultaneous-music-iterator.cc +++ b/lily/simultaneous-music-iterator.cc @@ -6,7 +6,7 @@ (c) 1997--2004 Han-Wen Nienhuys */ -#include "translator-group.hh" +#include "context.hh" #include "warn.hh" #include "simultaneous-music-iterator.hh" #include "music-list.hh" @@ -27,7 +27,7 @@ Simultaneous_music_iterator::derived_mark()const } void -Simultaneous_music_iterator::derived_substitute(Translator_group*f,Translator_group*t) +Simultaneous_music_iterator::derived_substitute(Context *f,Context *t) { for (SCM s = children_list_; gh_pair_p (s); s = gh_cdr(s)) unsmob_iterator (gh_car (s))-> substitute_outlet (f,t); @@ -53,8 +53,8 @@ Simultaneous_music_iterator::construct_children () number number as name */ SCM name = unsmob_context_def (get_outlet ()->definition_)->get_context_name (); - Translator_group * t = (j && separate_contexts_b_) - ? get_outlet ()->find_create_translator (name, to_string (j), SCM_EOL) + Context * t = (j && separate_contexts_b_) + ? get_outlet ()->find_create_context (name, to_string (j), SCM_EOL) : get_outlet (); if (!t) diff --git a/lily/slash-repeat-engraver.cc b/lily/slash-repeat-engraver.cc index 3ca67f6e72..3fabaad0ce 100644 --- a/lily/slash-repeat-engraver.cc +++ b/lily/slash-repeat-engraver.cc @@ -10,7 +10,7 @@ #include "engraver.hh" #include "repeated-music.hh" #include "engraver-group-engraver.hh" -#include "global-translator.hh" +#include "global-context.hh" #include "warn.hh" #include "misc.hh" #include "spanner.hh" @@ -19,7 +19,8 @@ #include "bar-line.hh" #include "score-engraver.hh" -#include "translator-group.hh" +#include "context.hh" + /** This acknowledges repeated music with "percent" style. It typesets @@ -94,7 +95,7 @@ Slash_repeat_engraver::try_music (Music * m) else return false; - Global_translator *global =top_engraver(); + Global_context *global =get_global_context (); for (int i = 0; i < count; i++) global->add_moment_to_process (next_moment_ + Moment (i) * body_length_); @@ -113,7 +114,7 @@ Slash_repeat_engraver::process_music () announce_grob(beat_slash_, repeat_->self_scm()); next_moment_ = next_moment_ + body_length_; - top_engraver()->add_moment_to_process (next_moment_); + get_global_context ()->add_moment_to_process (next_moment_); } } diff --git a/lily/slur-engraver.cc b/lily/slur-engraver.cc index 172a9ff42e..3daf274d6b 100644 --- a/lily/slur-engraver.cc +++ b/lily/slur-engraver.cc @@ -8,7 +8,8 @@ #include "slur.hh" #include "warn.hh" #include "note-column.hh" -#include "translator-group.hh" +#include "context.hh" + #include "engraver.hh" #include "spanner.hh" @@ -87,7 +88,7 @@ Slur_engraver::try_music (Music *ev) void Slur_engraver::set_melisma (bool m) { - daddy_trans_->set_property ("slurMelismaBusy", m ? SCM_BOOL_T :SCM_BOOL_F); + daddy_context_->set_property ("slurMelismaBusy", m ? SCM_BOOL_T :SCM_BOOL_F); } void diff --git a/lily/slur-performer.cc b/lily/slur-performer.cc index ac086bee88..43d538b4ce 100644 --- a/lily/slur-performer.cc +++ b/lily/slur-performer.cc @@ -10,7 +10,7 @@ #include "event.hh" #include "audio-item.hh" #include "audio-column.hh" -#include "global-translator.hh" +#include "global-context.hh" #include "warn.hh" /* @@ -51,7 +51,7 @@ Slur_performer::process_music () void Slur_performer::set_melisma (bool ml) { - daddy_trans_->set_property ("slurMelismaBusy", ml ? SCM_BOOL_T :SCM_BOOL_F); + daddy_context_->set_property ("slurMelismaBusy", ml ? SCM_BOOL_T :SCM_BOOL_F); } void diff --git a/lily/spaceable-grob.cc b/lily/spaceable-grob.cc index 87df4b7154..2c40260f23 100644 --- a/lily/spaceable-grob.cc +++ b/lily/spaceable-grob.cc @@ -102,8 +102,8 @@ Spaceable_grob::remove_interface (Grob*me) ADD_INTERFACE (Spaceable_grob,"spaceable-grob-interface", - "A grob (a Paper_column) that takes part in the \n" - "spacing problem. ", - "measure-length spacing-wishes penalty minimum-distances ideal-distances " -"left-neighbors right-neighbors"); + "A layout object that takes part in the spacing problem. " + , + "measure-length spacing-wishes penalty minimum-distances ideal-distances " + "left-neighbors right-neighbors"); diff --git a/lily/span-arpeggio-engraver.cc b/lily/span-arpeggio-engraver.cc index 9b33ae95f3..763f7c5c1a 100644 --- a/lily/span-arpeggio-engraver.cc +++ b/lily/span-arpeggio-engraver.cc @@ -45,8 +45,8 @@ Span_arpeggio_engraver::Span_arpeggio_engraver () void Span_arpeggio_engraver::acknowledge_grob (Grob_info info) { - if (info.origin_transes (this).size () - && Arpeggio::has_interface (info.grob_)) + if (Arpeggio::has_interface (info.grob_) + && info.origin_contexts (this).size ()) // huh? what's this test for? { arpeggios_.push (info.grob_); } diff --git a/lily/span-bar-engraver.cc b/lily/span-bar-engraver.cc index 0738451478..f8e7b445b1 100644 --- a/lily/span-bar-engraver.cc +++ b/lily/span-bar-engraver.cc @@ -47,9 +47,8 @@ Span_bar_engraver::Span_bar_engraver () void Span_bar_engraver::acknowledge_grob (Grob_info i) { - int depth = i.origin_transes (this).size (); - if (depth > 1 - && Bar_line::has_interface (i.grob_)) + int depth = i.origin_contexts (this).size (); + if (depth && Bar_line::has_interface (i.grob_)) { Item * it = dynamic_cast (i.grob_); bars_.push (it); diff --git a/lily/staff-collecting-engraver.cc b/lily/staff-collecting-engraver.cc index be285af113..553e0a2d75 100644 --- a/lily/staff-collecting-engraver.cc +++ b/lily/staff-collecting-engraver.cc @@ -9,7 +9,8 @@ source file of the GNU LilyPond music typesetter #include "staff-symbol.hh" #include "engraver.hh" #include "grob.hh" -#include "translator-group.hh" +#include "context.hh" + class Staff_collecting_engraver : public Engraver { @@ -31,7 +32,7 @@ Staff_collecting_engraver::acknowledge_grob (Grob_info gi) SCM staffs = get_property ("stavesFound"); staffs = gh_cons (gi.grob_->self_scm (), staffs); - daddy_trans_->set_property ("stavesFound", staffs); + daddy_context_->set_property ("stavesFound", staffs); } } diff --git a/lily/staff-performer.cc b/lily/staff-performer.cc index 1c5e99f066..f7ff09da20 100644 --- a/lily/staff-performer.cc +++ b/lily/staff-performer.cc @@ -12,6 +12,7 @@ #include "audio-item.hh" #include "audio-staff.hh" #include "performer-group-performer.hh" +#include "context.hh" /** Perform a staff. Individual notes should have their instrument (staff-wide) set, so we override play_element () @@ -64,7 +65,7 @@ Staff_performer::initialize () audio_staff_ = new Audio_staff; announce_element (Audio_element_info (audio_staff_, 0)); - name_ = new Audio_text (Audio_text::TRACK_NAME, id_string_); + name_ = new Audio_text (Audio_text::TRACK_NAME, daddy_context_->id_string_); announce_element (Audio_element_info (name_, 0)); tempo_ = new Audio_tempo (get_tempo ()); diff --git a/lily/staff-symbol-referencer.cc b/lily/staff-symbol-referencer.cc index cd4295e9af..78fc02ad2a 100644 --- a/lily/staff-symbol-referencer.cc +++ b/lily/staff-symbol-referencer.cc @@ -149,7 +149,7 @@ Staff_symbol_referencer::set_position (Grob*me,Real p) } - if (me->has_offset_callback_b (Staff_symbol_referencer::callback_proc, Y_AXIS)) + if (me->has_offset_callback (Staff_symbol_referencer::callback_proc, Y_AXIS)) return ; me->add_offset_callback (Staff_symbol_referencer::callback_proc, Y_AXIS); @@ -173,8 +173,8 @@ compare_position (Grob *const &a, Grob * const &b) } ADD_INTERFACE (Staff_symbol_referencer,"staff-symbol-referencer-interface", - "Object whose Y position is meant relative to a staff " - "symbol. These objects usually have " - "Staff_symbol_referencer::callback in their Y-offset-callback. " + "An object whose Y position is meant relative to a staff " + "symbol. These usually have " + "@code{Staff_symbol_referencer::callback} in their @code{Y-offset-callbacks}. " , "staff-position"); diff --git a/lily/staff-symbol.cc b/lily/staff-symbol.cc index bb0a9674c0..f6e8d6890f 100644 --- a/lily/staff-symbol.cc +++ b/lily/staff-symbol.cc @@ -123,7 +123,7 @@ Staff_symbol::get_ledger_line_thickness (Grob * me) ADD_INTERFACE (Staff_symbol,"staff-symbol-interface", "This spanner draws the lines of a staff. " - "A staff symbol definines a vertical unit, the staff space " + "A staff symbol definines a vertical unit, the staff space. " "Quantities that go by a half staff space are called positions " "The center (i.e. middle line " "or space) is position 0. The length of the symbol may be set by hand " diff --git a/lily/stem-engraver.cc b/lily/stem-engraver.cc index f8d19adcbe..ddd5c55154 100644 --- a/lily/stem-engraver.cc +++ b/lily/stem-engraver.cc @@ -13,7 +13,8 @@ #include "misc.hh" #include "stem-tremolo.hh" #include "item.hh" -#include "translator-group.hh" +#include "context.hh" + #include "engraver.hh" @@ -87,7 +88,7 @@ Stem_engraver::acknowledge_grob (Grob_info i) else requested_type = 8; else - daddy_trans_->set_property ("tremoloFlags", gh_int2scm (requested_type)); + daddy_context_->set_property ("tremoloFlags", gh_int2scm (requested_type)); int tremolo_flags = intlog2 (requested_type) - 2 - (duration_log > 2 ? duration_log - 2 : 0); @@ -147,13 +148,13 @@ Stem_engraver::stop_translation_timestep () if (gh_number_p (prop)) { Stem::set_beaming (stem_,gh_scm2int (prop),LEFT); - daddy_trans_->unset_property (ly_symbol2scm ("stemLeftBeamCount")); + daddy_context_->unset_property (ly_symbol2scm ("stemLeftBeamCount")); } prop = get_property ("stemRightBeamCount"); if (gh_number_p (prop)) { Stem::set_beaming (stem_,gh_scm2int (prop), RIGHT); - daddy_trans_->unset_property (ly_symbol2scm ("stemRightBeamCount")); + daddy_context_->unset_property (ly_symbol2scm ("stemRightBeamCount")); } typeset_grob (stem_); diff --git a/lily/stem-tremolo.cc b/lily/stem-tremolo.cc index 327433bbdb..2445018e08 100644 --- a/lily/stem-tremolo.cc +++ b/lily/stem-tremolo.cc @@ -199,5 +199,5 @@ Stem_tremolo::set_stem (Grob*me,Grob *s) ADD_INTERFACE (Stem_tremolo,"stem-tremolo-interface", - "", + "A beam slashing a stem to indicate a tremolo.", "stem beam-width beam-thickness flag-count"); diff --git a/lily/stem.cc b/lily/stem.cc index 50c3b49fa0..993e6253f6 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -851,6 +851,13 @@ void Stem::calc_stem_info (Grob *me) { Direction my_dir = get_grob_direction (me); + + if (!my_dir) + { + programming_error ("No stem dir set?"); + my_dir = UP; + } + Real staff_space = Staff_symbol_referencer::staff_space (me); Grob *beam = get_beam (me); Real beam_translation = Beam::get_beam_translation (beam); diff --git a/lily/stencil-scheme.cc b/lily/stencil-scheme.cc index 9f2f06567c..40905bfdeb 100644 --- a/lily/stencil-scheme.cc +++ b/lily/stencil-scheme.cc @@ -12,11 +12,8 @@ LY_DEFINE(ly_stencil_set_extent_x,"ly:stencil-set-extent!", 3 , 0, 0, (SCM mol, SCM axis, SCM np), "Set the extent (@var{extent} must be a pair of numbers) of @var{mol} in \n" -"@var{axis} direction (0 or 1 for x- and y-axis respectively).\n" -"\n" -"Note that an extent @code{(A . B)} is an interval and hence @code{A} is\n" -"smaller than @code{B}, and is often negative.\n" -) + "@var{axis} direction (0 or 1 for x- and y-axis respectively).\n" + ) { Stencil* m = unsmob_stencil (mol); SCM_ASSERT_TYPE (m, mol, SCM_ARG1, __FUNCTION__, "stencil"); @@ -151,37 +148,14 @@ LY_DEFINE(ly_stencil_add , LY_DEFINE(ly_make_stencil, "ly:make-stencil", 3, 0, 0, (SCM expr, SCM xext, SCM yext), " \n" -"The objective of any typesetting system is to put ink on paper in the \n" -"right places. For LilyPond, this final stage is left to the @TeX{} and \n" -"the printer subsystem. For lily, the last stage in processing a score is \n" -"outputting a description of what to put where. This description roughly \n" -"looks like \n" -"@example \n" -" PUT glyph AT (x,y) \n" -" PUT glyph AT (x,y) \n" -" PUT glyph AT (x,y) \n" -"@end example \n" -"you merely have to look at the tex output of lily to see this. \n" -"Internally these instructions are encoded in Stencils.@footnote{At some \n" -"point LilyPond also contained Atom-objects, but they have been replaced \n" -"by Scheme expressions, making the name outdated.} A stencil is \n" -"what-to-print-where information that also contains dimension information \n" -"(how large is this glyph?). \n" -" \n" -"Conceptually, Stencils can be constructed from Scheme code, by \n" -"translating a Stencil and by combining two stencils. In BNF \n" -"notation: \n" -" \n" -"@example \n" -"Stencil :: COMBINE Stencil Stencil \n" -" | TRANSLATE Offset Stencil \n" -" | GLYPH-DESCRIPTION \n" -" ; \n" -"@end example \n" -" \n" -"If you are interested in seeing how this information is stored, you \n" -"can run with the @code{-f scm} option. The scheme expressions are then \n" -"dumped in the output file.") + "Stencils are a device independent output expressions." + "They carry two pieces of information: \n\n" + "1: a specification of how to print this object. " + "This specification is processed by the output backends, for example " + "@file{scm/output-tex.scm}.\n\n" + "2: the vertical and horizontal extents of the object.\n\n" + + ) { SCM_ASSERT_TYPE (is_number_pair (xext), xext, SCM_ARG2, __FUNCTION__, "number pair"); SCM_ASSERT_TYPE (is_number_pair (yext), yext, SCM_ARG3, __FUNCTION__, "number pair"); diff --git a/lily/system-start-delimiter-engraver.cc b/lily/system-start-delimiter-engraver.cc index 967fc24d5f..3dc7288556 100644 --- a/lily/system-start-delimiter-engraver.cc +++ b/lily/system-start-delimiter-engraver.cc @@ -73,7 +73,7 @@ System_start_delimiter_engraver::process_music () if (!delim_) { SCM delim_name =get_property ("systemStartDelimiter"); - delim_ = make_spanner_from_properties (daddy_trans_, delim_name); + delim_ = make_spanner_from_properties (daddy_context_, delim_name); delim_->set_bound (LEFT, unsmob_grob (get_property ("currentCommandColumn"))); announce_grob (delim_, SCM_EOL); diff --git a/lily/system-start-delimiter.cc b/lily/system-start-delimiter.cc index f01ef8a37a..baf283a501 100644 --- a/lily/system-start-delimiter.cc +++ b/lily/system-start-delimiter.cc @@ -184,7 +184,7 @@ System_start_delimiter::staff_brace (Grob*me, Real y) ADD_INTERFACE (System_start_delimiter,"system-start-delimiter-interface", "The brace, bracket or bar in front of the system. " - "It is implemented as a spanner" + "It is implemented as a spanner." , "collapse-height thickness " "arch-height arch-angle arch-thick arch-width bracket-thick glyph"); diff --git a/lily/system.cc b/lily/system.cc index 1d0c28ae4c..aaad06c870 100644 --- a/lily/system.cc +++ b/lily/system.cc @@ -466,14 +466,12 @@ System::post_processing (bool last_line) /* generate all stencils to trigger all font loads. - - (ugh. This is not very memory efficient.) */ - + */ SCM all = get_grob_property ("all-elements") ; all = uniquify_list (all); /* - triger font loads first. + trigger font loads first. This might seem inefficient, but Stencils are cached per grob anyway. diff --git a/lily/text-item.cc b/lily/text-item.cc index 3fe2d788f5..0b81994daa 100644 --- a/lily/text-item.cc +++ b/lily/text-item.cc @@ -79,7 +79,7 @@ Text_item::markup_p (SCM x) } ADD_INTERFACE (Text_item,"text-interface", - "A scheme markup text, see @usermanref{Text markup}.", + "A scheme markup text, see @usermanref{Text-markup}.", "text baseline-skip word-space"); diff --git a/lily/tie-engraver.cc b/lily/tie-engraver.cc index 7b4232d2ff..78a5e49ec5 100644 --- a/lily/tie-engraver.cc +++ b/lily/tie-engraver.cc @@ -9,7 +9,8 @@ #include "event.hh" #include "tie.hh" -#include "translator-group.hh" +#include "context.hh" + #include "spanner.hh" #include "tie-column.hh" #include "engraver.hh" @@ -83,7 +84,7 @@ void Tie_engraver::process_music () { if (event_) - daddy_trans_->set_property ("tieMelismaBusy", SCM_BOOL_T); + daddy_context_->set_property ("tieMelismaBusy", SCM_BOOL_T); } void @@ -132,7 +133,7 @@ Tie_engraver::acknowledge_grob (Grob_info i) void Tie_engraver::start_translation_timestep () { - daddy_trans_->set_property ("tieMelismaBusy", + daddy_context_->set_property ("tieMelismaBusy", gh_bool2scm (heads_to_tie_.size ())); } diff --git a/lily/tie-performer.cc b/lily/tie-performer.cc index 5d16b88b01..40b265f9ae 100644 --- a/lily/tie-performer.cc +++ b/lily/tie-performer.cc @@ -7,7 +7,7 @@ */ -#include "translator-group.hh" +#include "context.hh" #include "audio-item.hh" #include "event.hh" #include "pqueue.hh" @@ -64,7 +64,7 @@ void Tie_performer::process_music () { if (event_) - daddy_trans_->set_property ("tieMelismaBusy", SCM_BOOL_T); + daddy_context_->set_property ("tieMelismaBusy", SCM_BOOL_T); } diff --git a/lily/time-scaled-music-iterator.cc b/lily/time-scaled-music-iterator.cc index 7bd174bc02..df703cbb33 100644 --- a/lily/time-scaled-music-iterator.cc +++ b/lily/time-scaled-music-iterator.cc @@ -10,8 +10,7 @@ #include "time-scaled-music-iterator.hh" #include "time-scaled-music.hh" #include "event.hh" -#include "translator-group.hh" - +#include "context.hh" void Time_scaled_music_iterator::process (Moment m) diff --git a/lily/timing-engraver.cc b/lily/timing-engraver.cc index c9139b95bb..83ff379f51 100644 --- a/lily/timing-engraver.cc +++ b/lily/timing-engraver.cc @@ -5,8 +5,7 @@ (c) 1997--2004 Han-Wen Nienhuys */ -#include "translator-group.hh" - +#include "context.hh" #include "grob-info.hh" #include "multi-measure-rest.hh" #include "timing-translator.hh" @@ -74,14 +73,14 @@ Timing_engraver::start_translation_timestep () } } - daddy_trans_->set_property ("whichBar", which); + daddy_context_->set_property ("whichBar", which); } void Timing_engraver::stop_translation_timestep () { Timing_translator::stop_translation_timestep (); - daddy_trans_->set_property ("whichBar", SCM_EOL); + daddy_context_->set_property ("whichBar", SCM_EOL); last_moment_ = now_mom (); } diff --git a/lily/timing-translator.cc b/lily/timing-translator.cc index 80e71deadf..f2ff5c4fea 100644 --- a/lily/timing-translator.cc +++ b/lily/timing-translator.cc @@ -11,21 +11,14 @@ #include "timing-translator.hh" #include "translator-group.hh" -#include "global-translator.hh" +#include "global-context.hh" #include "multi-measure-rest.hh" void Timing_translator::stop_translation_timestep () { - Translator *t = this; - Global_translator *global =0; - do - { - t = t->daddy_trans_ ; - global = dynamic_cast (t); - } - while (!global); + Global_context *global = get_global_context (); /* allbars == ! skipbars */ SCM sb = get_property ("skipBars"); @@ -57,14 +50,14 @@ Timing_translator::initialize () move this to engraver-init.ly? */ - daddy_trans_->set_property ("timing" , SCM_BOOL_T); - daddy_trans_->set_property ("currentBarNumber" , gh_int2scm (1)); + daddy_context_->set_property ("timing" , SCM_BOOL_T); + daddy_context_->set_property ("currentBarNumber" , gh_int2scm (1)); - daddy_trans_->set_property ("timeSignatureFraction", + daddy_context_->set_property ("timeSignatureFraction", gh_cons (gh_int2scm (4), gh_int2scm (4))); - daddy_trans_->set_property ("measurePosition", Moment (Rational (0)).smobbed_copy ()); - daddy_trans_->set_property ("measureLength", Moment (Rational (1)).smobbed_copy ()); - daddy_trans_->set_property ("beatLength", Moment (Rational (1,4)).smobbed_copy ()); + daddy_context_->set_property ("measurePosition", Moment (Rational (0)).smobbed_copy ()); + daddy_context_->set_property ("measureLength", Moment (Rational (1)).smobbed_copy ()); + daddy_context_->set_property ("beatLength", Moment (Rational (1,4)).smobbed_copy ()); } Rational @@ -101,14 +94,7 @@ Timing_translator::measure_position () const void Timing_translator::start_translation_timestep () { - Translator *t = this; - Global_translator *global =0; - do - { - t = t->daddy_trans_ ; - global = dynamic_cast (t); - } - while (!global); + Global_context *global =get_global_context (); Moment now = global->now_mom_; Moment dt = now - global->prev_mom_; @@ -136,7 +122,7 @@ Timing_translator::start_translation_timestep () else { measposp = now; - daddy_trans_->set_property ("measurePosition", measposp.smobbed_copy ()); + daddy_context_->set_property ("measurePosition", measposp.smobbed_copy ()); } measposp += dt; @@ -158,8 +144,8 @@ Timing_translator::start_translation_timestep () b ++; } - daddy_trans_->set_property ("currentBarNumber", gh_int2scm (b)); - daddy_trans_->set_property ("measurePosition", measposp.smobbed_copy ()); + daddy_context_->set_property ("currentBarNumber", gh_int2scm (b)); + daddy_context_->set_property ("measurePosition", measposp.smobbed_copy ()); } ENTER_DESCRIPTION(Timing_translator,"","","","","",""); diff --git a/lily/translator-group.cc b/lily/translator-group.cc index cc09ca0668..10806b34c0 100644 --- a/lily/translator-group.cc +++ b/lily/translator-group.cc @@ -13,184 +13,34 @@ #include "moment.hh" #include "scm-hash.hh" #include "context-def.hh" +#include "context.hh" #include "main.hh" #include "music.hh" -Translator_group::Translator_group (Translator_group const&s) - : Translator (s) +Translator_group* +Translator_group::get_daddy_translator () const { - iterator_count_ =0; - - Scheme_hash_table * tab = new Scheme_hash_table (*s.properties_dict ()); - properties_scm_ = tab->self_scm (); - scm_gc_unprotect_object (tab->self_scm ()); -} - -Scheme_hash_table* -Translator_group::properties_dict () const -{ - return Scheme_hash_table::unsmob (properties_scm_); -} - -Translator_group::~Translator_group () -{ - - //assert (is_removable ()); -} - - -Translator_group::Translator_group () -{ - iterator_count_ = 0; - Scheme_hash_table *tab = new Scheme_hash_table ; - properties_scm_ = tab->self_scm (); - - scm_gc_unprotect_object (tab->self_scm ()); -} - -void -Translator_group::check_removal () -{ - SCM next = SCM_EOL; - for (SCM p = trans_group_list_; gh_pair_p (p); p = next) - { - next = ly_cdr (p); - - Translator_group *trg = dynamic_cast (unsmob_translator (ly_car (p))); - - trg->check_removal (); - if (trg->is_removable ()) - terminate_translator (trg); - } -} - -SCM -Translator_group::add_translator (SCM list, Translator *t) -{ - /* - Must append, since list ordering must be preserved. - */ - list = gh_append2 (list, gh_cons (t->self_scm (), SCM_EOL)); - t->daddy_trans_ = this; - t->output_def_ = output_def_; - - return list; -} - - -void -Translator_group::add_used_group_translator (Translator *t) -{ - trans_group_list_ = add_translator (trans_group_list_,t); + Translator *t + = unsmob_translator (daddy_context_->daddy_context_->implementation_); + return dynamic_cast (t); } void -Translator_group::add_fresh_group_translator (Translator*t) -{ - Translator_group*tg = dynamic_cast (t); - trans_group_list_ = add_translator (trans_group_list_,t); - scm_gc_unprotect_object (t->self_scm ()); - - Context_def * td = unsmob_context_def (tg->definition_); - - /* - this can not move before add_translator(), because \override - operations require that we are in the hierarchy. - */ - td->apply_default_property_operations (tg); - - t->initialize (); -} - -bool -Translator_group::try_music (Music* m) -{ - bool hebbes_b = try_music_on_nongroup_children (m); - - if (!hebbes_b && daddy_trans_) - hebbes_b = daddy_trans_->try_music (m); - - return hebbes_b ; -} - -void -Translator_group::terminate_translator (Translator*r) -{ - r->finalize (); - /* - Return value ignored. GC does the rest. - */ - remove_translator (r); -} - - -/** - Remove a translator from the hierarchy. - */ -Translator * -Translator_group::remove_translator (Translator*trans) -{ - assert (trans); - - trans_group_list_ = scm_delq_x (trans->self_scm (), trans_group_list_); - trans->daddy_trans_ = 0; - return trans; -} - - -static void -static_each (SCM list, Method_pointer method) +translator_each (SCM list, Translator_method method) { for (SCM p = list; gh_pair_p (p); p = ly_cdr (p)) (unsmob_translator (ly_car (p))->*method) (); - -} - -void -Translator_group::each (Method_pointer method) -{ - static_each (get_simple_trans_list (), method); - static_each (trans_group_list_, method); } - - -/* - STUBS -*/ -void -Translator_group::stop_translation_timestep () -{ - each (&Translator::stop_translation_timestep); -} - -void -Translator_group::start_translation_timestep () -{ - each (&Translator::start_translation_timestep); -} - -void -Translator_group::do_announces () -{ - each (&Translator::do_announces); -} - void Translator_group::initialize () { SCM tab = scm_make_vector (gh_int2scm (19), SCM_BOOL_F); - set_property ("acceptHashTable", tab); - each (&Translator::initialize); + daddy_context_->set_property ("acceptHashTable", tab); } -void -Translator_group::finalize () -{ - each (&Translator::finalize); -} bool translator_accepts_any_of (Translator*tr, SCM ifaces) @@ -220,7 +70,7 @@ find_accept_translators (SCM gravlist, SCM ifaces) } bool -Translator_group::try_music_on_nongroup_children (Music *m ) +Translator_group::try_music (Music* m) { SCM tab = get_property ("acceptHashTable"); SCM name = scm_sloppy_assq (ly_symbol2scm ("name"), @@ -248,22 +98,7 @@ Translator_group::try_music_on_nongroup_children (Music *m ) } SCM -Translator_group::properties_as_alist () const -{ - return properties_dict()->to_alist(); -} - -String -Translator_group::context_name () const -{ - Context_def * td = unsmob_context_def (definition_ ); - return ly_symbol2string (td->get_context_name ()); -} - - - -SCM -names_to_translators (SCM namelist, Translator_group*tg) +names_to_translators (SCM namelist, Context*tg) { SCM l = SCM_EOL; for (SCM s = namelist; gh_pair_p (s) ; s = ly_cdr (s)) @@ -277,9 +112,7 @@ names_to_translators (SCM namelist, Translator_group*tg) SCM str = tr->self_scm (); l = gh_cons (str, l); - tr->daddy_trans_ = tg; - tr->output_def_ = tg->output_def_; - + tr->daddy_context_ = tg; scm_gc_unprotect_object (str); } } @@ -293,3 +126,33 @@ Translator_group::get_simple_trans_list () return simple_trans_list_; } + +void +recurse_down_translators (Context * c, Translator_method ptr, bool context_first) +{ + Translator_group * tg + = dynamic_cast (unsmob_translator (c->implementation_)); + + + if (!context_first) + { + translator_each (tg->get_simple_trans_list (), + ptr); + + (tg->*ptr) (); + } + + for (SCM s = c->context_list_ ; gh_pair_p (s); + s =gh_cdr (s)) + { + recurse_down_translators (unsmob_context (gh_car (s)), ptr, context_first); + } + + if (context_first) + { + translator_each (tg->get_simple_trans_list (), + ptr); + + (tg->*ptr) (); + } +} diff --git a/lily/translator-property.cc b/lily/translator-property.cc index eaf82c3166..3b793713d1 100644 --- a/lily/translator-property.cc +++ b/lily/translator-property.cc @@ -9,7 +9,7 @@ */ #include "main.hh" -#include "translator-group.hh" +#include "context.hh" #include "warn.hh" #include "item.hh" #include "spanner.hh" @@ -29,7 +29,7 @@ void -execute_pushpop_property (Translator_group * trg, +execute_pushpop_property (Context * trg, SCM prop, SCM eltprop, SCM val) { if (gh_symbol_p (prop) && gh_symbol_p (eltprop)) @@ -37,7 +37,7 @@ execute_pushpop_property (Translator_group * trg, if (val != SCM_UNDEFINED) { SCM prev = SCM_EOL; - Translator_group * where = trg->where_defined (prop); + Context * where = trg->where_defined (prop); /* Don't mess with MIDI. @@ -113,7 +113,7 @@ execute_pushpop_property (Translator_group * trg, PRE_INIT_OPS is in the order specified, and hence must be reversed. */ void -apply_property_operations (Translator_group*tg, SCM pre_init_ops) +apply_property_operations (Context *tg, SCM pre_init_ops) { SCM correct_order = scm_reverse (pre_init_ops); for (SCM s = correct_order; gh_pair_p (s); s = ly_cdr (s)) @@ -141,14 +141,17 @@ apply_property_operations (Translator_group*tg, SCM pre_init_ops) contexts has changed. The alist is updated if necessary. */ SCM -updated_grob_properties (Translator_group* tg, SCM sym) +updated_grob_properties (Context * tg, SCM sym) { assert (gh_symbol_p (sym)); tg = tg->where_defined (sym); + if (!tg) + return SCM_EOL; + SCM daddy_props - = (tg->daddy_trans_) - ? updated_grob_properties (tg->daddy_trans_, sym) + = (tg->daddy_context_) + ? updated_grob_properties (tg->daddy_context_, sym) : SCM_EOL; SCM props = tg->internal_get_property (sym); @@ -184,14 +187,14 @@ updated_grob_properties (Translator_group* tg, SCM sym) } Item* -make_item_from_properties (Translator_group* tg, SCM x) +make_item_from_properties (Context * tg, SCM x) { SCM props = updated_grob_properties (tg, x); return new Item (props); } Spanner* -make_spanner_from_properties (Translator_group *tg, SCM x) +make_spanner_from_properties (Context *tg, SCM x) { SCM props = updated_grob_properties (tg, x); return new Spanner (props); diff --git a/lily/translator-scheme.cc b/lily/translator-scheme.cc index 1ccee6c729..6df422ae5f 100644 --- a/lily/translator-scheme.cc +++ b/lily/translator-scheme.cc @@ -13,127 +13,6 @@ #include "translator-group.hh" #include "lily-guile.hh" -LY_DEFINE(ly_get_context_property, - "ly:get-context-property", 2, 0, 0, - (SCM context, SCM name), - "retrieve the value of @var{name} from context @var{context}") -{ - Translator *t = unsmob_translator (context); - Translator_group* tr= dynamic_cast (t); - SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Translator group"); - SCM_ASSERT_TYPE(gh_symbol_p (name), name, SCM_ARG2, __FUNCTION__, "symbol"); - - return tr->internal_get_property (name); - -} - -LY_DEFINE(ly_set_context_property, - "ly:set-context-property!", 3, 0, 0, - (SCM context, SCM name, SCM val), - "set value of property @var{name} in context @var{context} to @var{val}.") -{ - Translator *t = unsmob_translator (context); - Translator_group* tr= dynamic_cast (t); - - SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Context"); - SCM_ASSERT_TYPE(gh_symbol_p (name), name, SCM_ARG2, __FUNCTION__, "symbol"); - - tr->internal_set_property (name, val); - - return SCM_UNSPECIFIED; -} - - -LY_DEFINE(ly_context_property_where_defined, - "ly:context-property-where-defined", 2, 0, 0, - (SCM context, SCM name), - "Return the context above @var{context} where @var{name} is defined.") -{ - Translator *t = unsmob_translator (context); - Translator_group* tr = dynamic_cast (t); - SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Context"); - SCM_ASSERT_TYPE(gh_symbol_p (name), name, SCM_ARG2, __FUNCTION__, "symbol"); - - - tr = tr->where_defined (name); - - if (tr) - return tr->self_scm(); - - return SCM_EOL; -} - -LY_DEFINE(ly_unset_context_property, - "ly:unset-context-property", 2, 0, 0, - (SCM context, SCM name), - "Unset value of property @var{name} in context @var{context}.") -{ - Translator *t = unsmob_translator (context); - Translator_group* tr = dynamic_cast (t); - SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Context"); - SCM_ASSERT_TYPE(gh_symbol_p (name), name, SCM_ARG2, __FUNCTION__, "symbol"); - - tr->unset_property (name); - - return SCM_UNSPECIFIED; -} - - - -LY_DEFINE(ly_context_parent, - "ly:context-parent", 1, 0, 0, - (SCM context), - "Return the parent of @var{context}, #f if none.") -{ - Translator *t = unsmob_translator (context); - Translator_group* tr= dynamic_cast (t); - - SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Context"); - - tr = tr->daddy_trans_ ; - if (tr) - return tr->self_scm(); - else - return SCM_BOOL_F; -} - -/* - Todo: should support translator IDs, and creation? - */ -LY_DEFINE(ly_translator_find, - "ly:translator-find", 2, 0,0, - (SCM context, SCM name), - "Find a parent of @var{context} that has name or alias @var{name}. " - "Return @code{#f} if not found." ) -{ - Translator_group* tr= dynamic_cast ( unsmob_translator (context)); - - SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "context"); - SCM_ASSERT_TYPE(gh_symbol_p (name), name, SCM_ARG2, __FUNCTION__, "symbol"); - - while (tr) - { - if (tr->is_alias (name)) - return tr->self_scm(); - tr = tr->daddy_trans_ ; - } - - return SCM_BOOL_F; -} - - -LY_DEFINE(ly_context_properties, - "ly:context-properties", 1, 0, 0, - (SCM context), - "Return all properties of @var{context} in an alist.") -{ - Translator *t = unsmob_translator (context); - Translator_group* tr= dynamic_cast (t); - - SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Context"); - - return tr->properties_as_alist (); -} @@ -149,30 +28,6 @@ LY_DEFINE(ly_translator_name, } -LY_DEFINE(ly_context_id, - "ly:context-id", 1,0,0, (SCM context), - "Return the id string of @var{context}, i.e. for @code{\\context Voice " -"= one .. } it will return the string @code{one}.") -{ - Translator_group* tr = dynamic_cast (unsmob_translator (context)); - SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Context"); - - return scm_makfrom0str (tr->id_string_. to_str0 ()); -} - - -LY_DEFINE(ly_context_name, - "ly:context-name", 1,0,0, (SCM context), - "Return the name of @var{context}, i.e. for @code{\\context Voice " -"= one .. } it will return the symbol @code{Voice}.") -{ - Translator_group* tr = dynamic_cast (unsmob_translator (context)); - SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Context"); - - return unsmob_context_def (tr->definition_)->get_context_name (); -} - - LY_DEFINE(ly_translator_description, "ly:translator-description", 1,0,0, (SCM me), @@ -185,56 +40,13 @@ LY_DEFINE(ly_translator_description, } -LY_DEFINE(ly_context_pushpop_property, - "ly:context-pushpop-property", 3, 1, 0, - (SCM context, SCM grob, SCM eltprop, SCM val), - "Do a single @code{\\override} or @code{\\revert} operation " - "in @var{context}. The grob definition @code{grob} is extended with " - "@code{eltprop} (if @var{val} is specified) " - "or reverted (if unspecified).") -{ - Translator_group *tg = dynamic_cast (unsmob_translator (context)); - - SCM_ASSERT_TYPE(tg, context, SCM_ARG1, __FUNCTION__, "context"); - SCM_ASSERT_TYPE(gh_symbol_p (grob), grob, SCM_ARG2, __FUNCTION__, "symbol"); - SCM_ASSERT_TYPE(gh_symbol_p (eltprop), eltprop, SCM_ARG3, __FUNCTION__, "symbol"); - - execute_pushpop_property (tg, grob, eltprop, val); - - return SCM_UNDEFINED; -} - -LY_DEFINE(ly_context_p, - "ly:context?", 1, 0, 0, - (SCM x), - "Type predicate: is @var{x} a context?") -{ - Translator_group *tg = dynamic_cast (unsmob_translator (x)); - - return SCM_BOOL (tg); -} - - int Translator::print_smob (SCM s, SCM port, scm_print_state *) { Translator *sc = (Translator *) ly_cdr (s); scm_puts ("#definition_)) - { - scm_display (d->get_context_name (), port); - } - else - scm_display (ly_translator_name (s), port); - - if (Translator_group *td=dynamic_cast (sc)) - { - scm_puts ("=", port); - scm_puts (td->id_string_.to_str0 (), port); - } - - scm_display (sc->simple_trans_list_, port); + scm_puts (classname (sc), port); /* don't try to print properties, that is too much hassle. diff --git a/lily/translator.cc b/lily/translator.cc index c4ab9083ab..ee0709fbe1 100644 --- a/lily/translator.cc +++ b/lily/translator.cc @@ -11,8 +11,9 @@ #include "warn.hh" #include "translator-group.hh" #include "context-def.hh" - +#include "global-context.hh" #include "moment.hh" +#include "context.hh" #include "ly-smobs.icc" @@ -23,32 +24,22 @@ Translator::~Translator () void Translator::init () { + self_scm_ = SCM_EOL; simple_trans_list_ = SCM_BOOL_F; - trans_group_list_ = SCM_EOL; - properties_scm_ = SCM_EOL; - definition_ = SCM_EOL; - daddy_trans_ =0; - accepts_list_ = SCM_EOL; + daddy_context_ =0; + smobify_self (); } Translator::Translator () { - self_scm_ = SCM_EOL; init (); - output_def_ = 0; - smobify_self (); } -Translator::Translator (Translator const &s) +Translator::Translator (Translator const &) { - self_scm_ = SCM_EOL; init (); - output_def_ = s.output_def_; - - smobify_self (); } - bool Translator::try_music (Music *) { @@ -59,27 +50,29 @@ Translator::try_music (Music *) Moment Translator::now_mom () const { - return daddy_trans_->now_mom (); + return daddy_context_->now_mom (); } -void -Translator::do_announces () +Music_output_def * +Translator::get_output_def () const { + return daddy_context_->get_output_def (); } -Music_output_def * -Translator::get_output_def () const + +Translator_group* +Translator::get_daddy_translator () const { - return - (daddy_trans_) - ? daddy_trans_->get_output_def () - : 0; + Translator *t + = unsmob_translator (daddy_context_->implementation_); + return dynamic_cast (t); } + SCM Translator::internal_get_property (SCM sym) const { - return daddy_trans_->internal_get_property (sym); + return daddy_context_->internal_get_property (sym); } void @@ -121,13 +114,7 @@ SCM Translator::mark_smob (SCM sm) { Translator * me = (Translator*) SCM_CELL_WORD_1 (sm); - scm_gc_mark (me->simple_trans_list_); - scm_gc_mark (me->trans_group_list_); - scm_gc_mark (me->definition_); - scm_gc_mark (me->properties_scm_); - scm_gc_mark (me->accepts_list_); - - return me->properties_scm_; + return me->simple_trans_list_; } SCM @@ -136,6 +123,21 @@ Translator::translator_description () const return SCM_EOL; } + +Global_context * +Translator::get_global_context () const +{ + return daddy_context_ ->get_global_context (); +} + + +Score_context * +Translator::get_score_context () const +{ + return daddy_context_->get_score_context (); +} + + SCM Translator::static_translator_description ()const { @@ -146,9 +148,3 @@ Translator::static_translator_description ()const IMPLEMENT_SMOBS (Translator); IMPLEMENT_DEFAULT_EQUAL_P (Translator); IMPLEMENT_TYPE_P(Translator,"ly:translator?"); - -SCM -Translator::get_simple_trans_list() -{ - return SCM_EOL; -} diff --git a/lily/unfolded-repeat-iterator.cc b/lily/unfolded-repeat-iterator.cc index a963311538..b1b261d800 100644 --- a/lily/unfolded-repeat-iterator.cc +++ b/lily/unfolded-repeat-iterator.cc @@ -10,7 +10,7 @@ source file of the GNU LilyPond music typesetter #include "music.hh" #include "sequential-iterator.hh" -#include "translator-group.hh" +#include "context.hh" class Unfolded_repeat_iterator : public Sequential_iterator { @@ -107,7 +107,7 @@ Volta_repeat_iterator::add_repeat_command (SCM what) SCM reps = ly_symbol2scm ("repeatCommands"); SCM current_reps = get_outlet ()->internal_get_property (reps); - Translator_group * where = get_outlet ()->where_defined (reps); + Context * where = get_outlet ()->where_defined (reps); if (where && current_reps == SCM_EOL || gh_pair_p (current_reps)) { diff --git a/lily/vertical-align-engraver.cc b/lily/vertical-align-engraver.cc index 0007e6cb5e..97681de90a 100644 --- a/lily/vertical-align-engraver.cc +++ b/lily/vertical-align-engraver.cc @@ -5,7 +5,7 @@ (c) 1997--2004 Han-Wen Nienhuys */ -#include "translator-group.hh" +#include "context.hh" #include "paper-column.hh" #include "align-interface.hh" #include "span-bar.hh" @@ -16,7 +16,7 @@ class Vertical_align_engraver : public Engraver { Spanner * valign_; - bool qualifies_b (Grob_info) const; + bool qualifies (Grob_info) const; public: TRANSLATOR_DECLARATIONS(Vertical_align_engraver); protected: @@ -53,18 +53,18 @@ Vertical_align_engraver::finalize () } bool -Vertical_align_engraver::qualifies_b (Grob_info i) const +Vertical_align_engraver::qualifies (Grob_info i) const { - int sz = i.origin_transes ((Translator*)this).size () ; + int sz = i.origin_contexts ((Translator*)this).size () ; - return sz > 1 && Axis_group_interface::has_interface (i.grob_) + return sz > 0 && Axis_group_interface::has_interface (i.grob_) && !i.grob_->get_parent (Y_AXIS) && Axis_group_interface::axis_b (i.grob_, Y_AXIS); } void Vertical_align_engraver::acknowledge_grob (Grob_info i) { - if (qualifies_b (i)) + if (qualifies (i)) { Align_interface::add_element (valign_,i.grob_, get_property ("verticalAlignmentChildCallback")); } diff --git a/lily/volta-engraver.cc b/lily/volta-engraver.cc index 7e2b3376a3..0a33d68e76 100644 --- a/lily/volta-engraver.cc +++ b/lily/volta-engraver.cc @@ -8,7 +8,7 @@ */ #include "engraver.hh" -#include "translator-group.hh" +#include "context.hh" #include "volta-bracket.hh" #include "item.hh" #include "note-column.hh" diff --git a/ly/engraver-init.ly b/ly/engraver-init.ly index 3c59e9bdbd..08e3ff8d67 100644 --- a/ly/engraver-init.ly +++ b/ly/engraver-init.ly @@ -1,5 +1,11 @@ \version "2.1.23" +\translator { + \name Global + + % nothing else needed -- tweaks are ignored anyway. + \accepts Score + } % % setup for Request->Element conversion. Guru-only @@ -210,9 +216,7 @@ \name DrumVoice \alias Voice - \description " A voice on a percussion staff." - - + \description "A voice on a percussion staff." \remove "Arpeggio_engraver" \consists "Multi_measure_rest_engraver" \consists "Text_spanner_engraver" diff --git a/ly/performer-init.ly b/ly/performer-init.ly index daba5a3261..5538b8324b 100644 --- a/ly/performer-init.ly +++ b/ly/performer-init.ly @@ -11,8 +11,11 @@ \consists "Key_performer" \consists "Tempo_performer" \consists "Time_signature_performer" - } +\translator { + \name Global + \accepts Score + } \translator { \StaffContext \name DrumStaff diff --git a/scm/define-grob-interfaces.scm b/scm/define-grob-interfaces.scm index 529433ae54..7bd3be3f46 100644 --- a/scm/define-grob-interfaces.scm +++ b/scm/define-grob-interfaces.scm @@ -66,7 +66,7 @@ extents of a cluster spanner at this X position. (ly:add-interface 'multi-measure-interface - "Multi measure rest, and friends (mmrest number, mmrest text)." + "Multi measure rest, and the text or number that is printed over it." '()) diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index f3f0ec9583..9b9cb21e60 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -31,7 +31,7 @@ (X-extent-callback ,procedure? "Procedure that calculates the extent of this object. If this value is set to @code{#f}, the object is empty in the X direction. The procedure takes a grob and axis -argument, and returns a a number-pair. +argument, and returns a number-pair. ") (X-offset-callbacks ,list? "A list of functions determining this @@ -561,7 +561,8 @@ paper-columns or note-column objects.") (dependencies ,grob-list? "list of score-grob pointers that indicate who to compute first for certain global passes.") (elements ,grob-list? "list of grobs, type depending on the Grob where this is set in.") (heads ,grob-list? "List of note heads.") - (items-worth-living ,grob-list? "list of interesting items. If empty in a particular system, clear that system.") + (items-worth-living ,grob-list? "A list of interesting items. If +empty in a particular staff, then that staff is erased.") (details ,list? "alist of parameters for detailed grob behavior.") (note-heads ,grob-list? "List of note head grobs") (side-support-elements ,grob-list? "the support, a list of grobs.") @@ -583,10 +584,11 @@ columns. (positioning-done ,boolean? "Used to signal that a positioning element -did it's job. This ensures that a positioning is only done once.") +did its job. This ensures that a positioning is only done once.") - (script-stencil ,pair? "Index code for script -- internal, see script.cc.") + (script-stencil ,pair? "Pair (@code{type} . @code{arg}), which +acts as an index for looking up a Stencil object.") (meta ,list? "Contains meta information. It is an alist with the entries @code{name} and @code{interfaces}.") diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 8419b2528c..2326ae35f7 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -721,6 +721,7 @@ (axes . (0)) (X-extent-callback . ,Axis_group_interface::group_extent_callback) (before-line-breaking-callback . ,Paper_column::before_line_breaking) + (breakable . #t) ;; debugging stuff: print column number. ; (print-function . ,Paper_column::print) (font-name . "cmr8") (Y-extent-callback . #f) diff --git a/scm/define-music-properties.scm b/scm/define-music-properties.scm index 2fd7a35326..0c70e7a78e 100644 --- a/scm/define-music-properties.scm +++ b/scm/define-music-properties.scm @@ -30,7 +30,7 @@ TODO: consider making type into symbol") (absolute-octave ,integer? "The absolute octave for a octave check note.") - (articulations ,music-list? + (articulations ,ly:music-list? "Articulation events specifically for this note.") (articulation-type ,string? "key for script definitions alist. @@ -56,7 +56,7 @@ eg. @code{\\tag #'part ...} could tag a piece of music as only being active in a (tempo-unit ,ly:duration? "The unit for the metronome count.") (tonic ,ly:pitch? "Base of the scale") (element ,ly:music? "The single child of a Music_wrapper music object, or the body of a repeat.") - (elements ,music-list? "A list of elements for sequential of simultaneous music, or the alternatives of repeated music. ") + (elements ,ly:music-list? "A list of elements for sequential of simultaneous music, or the alternatives of repeated music. ") (force-accidental ,boolean? "If set, a cautionary accidental should always be printed on this note") (grob-property ,symbol? "The symbol of the grob property to set. ") (grob-value ,scheme? "The value of the grob property to set") diff --git a/scm/lily.scm b/scm/lily.scm index 4b21833762..ab4066cd91 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -451,7 +451,6 @@ L1 is copied, L2 not. (,ly:duration? . "duration") (,ly:grob? . "layout object") (,ly:input-location? . "input location") - (,ly:input-location? . "input location") (,ly:moment? . "moment") (,ly:music? . "music") (,ly:pitch? . "pitch") @@ -459,7 +458,7 @@ L1 is copied, L2 not. (,ly:font-metric? . "font metric") (,markup-list? . "list of markups") (,markup? . "markup") - (,music-list? . "list of music") + (,ly:music-list? . "list of music") (,number-or-grob? . "number or grob") (,number-or-string? . "number or string") (,number-pair? . "pair of numbers") diff --git a/scm/music-functions.scm b/scm/music-functions.scm index 29194e3326..34b02c98c8 100644 --- a/scm/music-functions.scm +++ b/scm/music-functions.scm @@ -428,7 +428,8 @@ Rest can contain a list of beat groupings (basic (list set1 set2 set3 set4))) (context-spec-music - (make-sequential-music basic) 'Timing))) + (context-spec-music + (make-sequential-music basic) 'Timing) 'Score))) (define-public (make-mark-set label) "make the music for the \\mark command." diff --git a/scripts/convert-ly.py b/scripts/convert-ly.py index e396af4823..fddb60115a 100644 --- a/scripts/convert-ly.py +++ b/scripts/convert-ly.py @@ -1892,6 +1892,11 @@ def conv (str): return str conversions.append (((2,1,23), conv, """Property setting syntax in \\translator{ }""")) +def conv (str): + str = re.sub (r'music-list\?', 'ly:music-list?', str) + return str + +conversions.append (((2,1,24), conv, """music-list? -> ly:music-list?""")) ################################ -- 2.39.2