From c71b765b7beb840331f2bededdedddf162b13f98 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sun, 20 Aug 2006 00:26:16 +0000 Subject: [PATCH] * scm/define-music-types.scm (music-descriptions): use apply-output-event for ApplyOutputEvent * lily/output-property-engraver.cc (listen_apply_output): rename from listen_layout_instruction. * lily/piano-pedal-engraver.cc (struct Pedal_type_info): new function protect() --- ChangeLog | 11 ++++++++ lily/apply-context-iterator.cc | 3 --- lily/output-property-engraver.cc | 9 ++++--- lily/piano-pedal-engraver.cc | 43 ++++++++++++++++++++++++-------- scm/define-event-classes.scm | 1 + scm/define-music-types.scm | 4 +-- 6 files changed, 52 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index f2746e16ad..f013f38465 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2006-08-20 Han-Wen Nienhuys + + * scm/define-music-types.scm (music-descriptions): use + apply-output-event for ApplyOutputEvent + + * lily/output-property-engraver.cc (listen_apply_output): rename + from listen_layout_instruction. + + * lily/piano-pedal-engraver.cc (struct Pedal_type_info): new + function protect() + 2006-08-19 Han-Wen Nienhuys * scm/lily.scm (lilypond-all): option read-file-list: substitute diff --git a/lily/apply-context-iterator.cc b/lily/apply-context-iterator.cc index 0f6e6daff8..adf708da35 100644 --- a/lily/apply-context-iterator.cc +++ b/lily/apply-context-iterator.cc @@ -12,9 +12,6 @@ #include "music.hh" #include "simple-music-iterator.hh" -/** - Iterate a property. -*/ class Apply_context_iterator : public Simple_music_iterator { public: diff --git a/lily/output-property-engraver.cc b/lily/output-property-engraver.cc index 76a2b6cb3f..ca6f868732 100644 --- a/lily/output-property-engraver.cc +++ b/lily/output-property-engraver.cc @@ -20,15 +20,16 @@ class Output_property_engraver : public Engraver TRANSLATOR_DECLARATIONS (Output_property_engraver); protected: vector props_; + DECLARE_ACKNOWLEDGER (grob); - DECLARE_TRANSLATOR_LISTENER (layout_instruction); + DECLARE_TRANSLATOR_LISTENER (apply_output); void stop_translation_timestep (); }; -IMPLEMENT_TRANSLATOR_LISTENER (Output_property_engraver, layout_instruction); +IMPLEMENT_TRANSLATOR_LISTENER (Output_property_engraver, apply_output); void -Output_property_engraver::listen_layout_instruction (Stream_event *ev) +Output_property_engraver::listen_apply_output (Stream_event *ev) { /* UGH. Only swallow the output property event in the context @@ -73,7 +74,7 @@ ADD_TRANSLATOR (Output_property_engraver, "", /* accept */ - "layout-instruction-event", + "apply-output-event", /* read */ "", diff --git a/lily/piano-pedal-engraver.cc b/lily/piano-pedal-engraver.cc index 8e9b9252f0..90844c6d24 100644 --- a/lily/piano-pedal-engraver.cc +++ b/lily/piano-pedal-engraver.cc @@ -40,12 +40,27 @@ typedef enum Pedal_type {SOSTENUTO, SUSTAIN, UNA_CORDA, NUM_PEDAL_TYPES}; struct Pedal_type_info { string base_name_; - Protected_scm event_class_sym_; - Protected_scm style_sym_; - Protected_scm strings_sym_; + SCM event_class_sym_; + SCM style_sym_; + SCM strings_sym_; const char *pedal_line_spanner_c_str_; const char *pedal_c_str_; + + Pedal_type_info () + { + event_class_sym_ = SCM_EOL; + style_sym_ = SCM_EOL; + strings_sym_ = SCM_EOL; + pedal_line_spanner_c_str_ = 0; + pedal_c_str_ = 0; + } + void protect () + { + scm_gc_protect_object (event_class_sym_); + scm_gc_protect_object (style_sym_); + scm_gc_protect_object (strings_sym_); + } }; struct Pedal_info @@ -138,13 +153,21 @@ init_pedal_types () } base_ident += String_convert::to_lower (string (name, prev_pos, cur_pos - prev_pos)); - Pedal_type_info *tbl = &pedal_types_[i]; - tbl->base_name_ = name; - tbl->event_class_sym_ = scm_str2symbol ((base_ident + "-event").c_str ()); - tbl->pedal_line_spanner_c_str_ = strdup ((base_name + "PedalLineSpanner").c_str ()); - tbl->style_sym_ = scm_str2symbol (("pedal" + base_name + "Style").c_str ()); - tbl->strings_sym_ = scm_str2symbol (("pedal" + base_name + "Strings").c_str ()); - tbl->pedal_c_str_ = strdup ((base_name + "Pedal").c_str ()); + /* + be careful, as we don't want to loose references to the _sym_ members. + */ + Pedal_type_info info; + info.event_class_sym_ = scm_str2symbol ((base_ident + "-event").c_str ()); + info.style_sym_ = scm_str2symbol (("pedal" + base_name + "Style").c_str ()); + info.strings_sym_ = scm_str2symbol (("pedal" + base_name + "Strings").c_str ()); + + info.pedal_line_spanner_c_str_ = strdup ((base_name + "PedalLineSpanner").c_str ()); + info.base_name_ = name; + info.pedal_c_str_ = strdup ((base_name + "Pedal").c_str ()); + + info.protect (); + + pedal_types_[i] = info; } } ADD_SCM_INIT_FUNC (Piano_pedal_engraver_init_pedal_types_, init_pedal_types); diff --git a/scm/define-event-classes.scm b/scm/define-event-classes.scm index d8056ba6d8..b0fe109e2f 100644 --- a/scm/define-event-classes.scm +++ b/scm/define-event-classes.scm @@ -23,6 +23,7 @@ multi-measure-text-event note-grouping-event pes-or-flexa-event repeat-tie-event spacing-section-event layout-instruction-event)) + (layout-instruction-event . (apply-output-event)) (script-event . (articulation-event text-script-event)) (part-combine-event . (solo1-event solo2-event unisono-event)) (break-event . (line-break-event page-break-event page-turn-event)) diff --git a/scm/define-music-types.scm b/scm/define-music-types.scm index d72eea02a1..7a06764063 100644 --- a/scm/define-music-types.scm +++ b/scm/define-music-types.scm @@ -50,7 +50,7 @@ arguments to func are 1. the grob, 2. the originating context, 3. context where FUNC is called. ") - (types . (general-music event layout-instruction-event)) + (types . (general-music event apply-output-event)) )) (ArpeggioEvent . ( @@ -337,7 +337,7 @@ SYNTAX @code{\\override [ @var{Ctxt} . ] @var{Obj} @var{prop} = @var{val}} ") - (types . (general-music layout-instruction-event)) + (types . (general-music layout-instruction-event override-property-event)) (iterator-ctor . ,ly:push-property-iterator::constructor) )) (PageBreakEvent -- 2.39.2