From: David Kastrup Date: Tue, 7 Feb 2017 10:16:10 +0000 (+0100) Subject: Issue 5062: Redo send_stream_event in type-clean manner X-Git-Url: https://git.donarmstrong.com/lilypond.git?a=commitdiff_plain;h=311355be32c8dc71a41398ce93cdb298bd2d8213;p=lilypond.git Issue 5062: Redo send_stream_event in type-clean manner --- diff --git a/lily/context.cc b/lily/context.cc index a614146058..7dce3857ce 100644 --- a/lily/context.cc +++ b/lily/context.cc @@ -56,7 +56,7 @@ Context::check_removal () Callback0_wrapper::make_smob (), UP); - send_stream_event (ctx, "RemoveContext", 0, 0); + send_stream_event (ctx, "RemoveContext", 0); } } } @@ -526,18 +526,62 @@ Context::internal_get_property (SCM sym) const } /* -Called by the send_stream_event macro. props is a 0-terminated array of -properties and corresponding values, interleaved. This method should not -be called from any other place than the send_stream_event macro. +These methods should not be called from any other place than the +send_stream_event macro. */ + void -Context::internal_send_stream_event (SCM type, Input *origin, SCM props[]) +Context::internal_send_stream_event (SCM type, Input *origin) { Stream_event *e = new Stream_event (Lily::ly_make_event_class (type), origin); - for (int i = 0; props[i]; i += 2) - { - e->set_property (props[i], props[i + 1]); - } + event_source_->broadcast (e); + e->unprotect (); +} + +void +Context::internal_send_stream_event (SCM type, Input *origin, + SCM prop, SCM val) +{ + Stream_event *e = new Stream_event (Lily::ly_make_event_class (type), origin); + e->set_property (prop, val); + event_source_->broadcast (e); + e->unprotect (); +} + +void +Context::internal_send_stream_event (SCM type, Input *origin, + SCM prop, SCM val, SCM prop2, SCM val2) +{ + Stream_event *e = new Stream_event (Lily::ly_make_event_class (type), origin); + e->set_property (prop, val); + e->set_property (prop2, val2); + event_source_->broadcast (e); + e->unprotect (); +} + +void +Context::internal_send_stream_event (SCM type, Input *origin, + SCM prop, SCM val, SCM prop2, SCM val2, + SCM prop3, SCM val3) +{ + Stream_event *e = new Stream_event (Lily::ly_make_event_class (type), origin); + e->set_property (prop, val); + e->set_property (prop2, val2); + e->set_property (prop3, val3); + event_source_->broadcast (e); + e->unprotect (); +} + +void +Context::internal_send_stream_event (SCM type, Input *origin, + SCM prop, SCM val, SCM prop2, SCM val2, + SCM prop3, SCM val3, SCM prop4, SCM val4) +{ + Stream_event *e = new Stream_event (Lily::ly_make_event_class (type), origin); + e->set_property (prop, val); + e->set_property (prop2, val2); + e->set_property (prop3, val3); + e->set_property (prop4, val4); event_source_->broadcast (e); e->unprotect (); } diff --git a/lily/global-context-scheme.cc b/lily/global-context-scheme.cc index ea100c912a..a8289d52cf 100644 --- a/lily/global-context-scheme.cc +++ b/lily/global-context-scheme.cc @@ -120,7 +120,7 @@ LY_DEFINE (ly_interpret_music_expression, "ly:interpret-music-expression", iter->quit (); scm_remember_upto_here_1 (protected_iter); - send_stream_event (g, "Finish", 0, 0); + send_stream_event (g, "Finish", 0); debug_output (_f ("elapsed time: %.2f seconds", timer.read ())); diff --git a/lily/global-context.cc b/lily/global-context.cc index be523665b9..f494ab4191 100644 --- a/lily/global-context.cc +++ b/lily/global-context.cc @@ -180,7 +180,7 @@ Global_context::run_iterator_on_me (Music_iterator *iter) if (iter->ok ()) iter->process (w); - send_stream_event (this, "OneTimeStep", 0, 0); + send_stream_event (this, "OneTimeStep", 0); apply_finalizations (); check_removal (); } diff --git a/lily/grace-iterator.cc b/lily/grace-iterator.cc index daaaf855bf..4954dc914d 100644 --- a/lily/grace-iterator.cc +++ b/lily/grace-iterator.cc @@ -31,7 +31,7 @@ Grace_iterator::process (Moment m) // to distinguish \stemNeutral \grace { ... and \grace { \stemNeutral ... if (in_grace_ != bool (m.grace_part_) && child_iter_ && child_iter_->get_outlet ()) { - send_stream_event (child_iter_->get_outlet (), "GraceChange", get_music ()->origin (), 0); + send_stream_event (child_iter_->get_outlet (), "GraceChange", get_music ()->origin ()); } in_grace_ = m.grace_part_; diff --git a/lily/include/context.hh b/lily/include/context.hh index 2555bfe2b4..42fb15aaa3 100644 --- a/lily/include/context.hh +++ b/lily/include/context.hh @@ -90,8 +90,17 @@ public: Dispatcher *event_source () const { return event_source_; } Dispatcher *events_below () const { return events_below_; } - void internal_send_stream_event (SCM type, Input *origin, SCM props[]); - + void internal_send_stream_event (SCM type, Input *origin); + void internal_send_stream_event (SCM type, Input *origin, + SCM prop, SCM val); + void internal_send_stream_event (SCM type, Input *origin, + SCM prop, SCM val, SCM prop2, SCM val2); + void internal_send_stream_event (SCM type, Input *origin, + SCM prop, SCM val, SCM prop2, SCM val2, + SCM prop3, SCM val3); + void internal_send_stream_event (SCM type, Input *origin, + SCM prop, SCM val, SCM prop2, SCM val2, + SCM prop3, SCM val3, SCM prop4, SCM val4); SCM get_definition () const { return definition_; } SCM get_definition_mods () const { return definition_mods_; } @@ -188,10 +197,7 @@ void set_context_property_on_children (Context *trans, SCM sym, SCM val); /* Shorthand for creating and broadcasting stream events. */ #define send_stream_event(ctx, type, origin, ...) \ - do { \ - SCM props[] = { __VA_ARGS__, 0 }; \ - ctx->internal_send_stream_event (ly_symbol2scm (type), origin, props); \ - } while (0) + ctx->internal_send_stream_event (ly_symbol2scm (type), origin, ##__VA_ARGS__) SCM nested_property_alist (SCM alist, SCM prop_path, SCM value); SCM nested_property (SCM alist, SCM prop_path, SCM fallback = SCM_EOL);