]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 5062: Redo send_stream_event in type-clean manner
authorDavid Kastrup <dak@gnu.org>
Tue, 7 Feb 2017 10:16:10 +0000 (11:16 +0100)
committerDavid Kastrup <dak@gnu.org>
Tue, 14 Feb 2017 09:10:57 +0000 (10:10 +0100)
lily/context.cc
lily/global-context-scheme.cc
lily/global-context.cc
lily/grace-iterator.cc
lily/include/context.hh

index a614146058f55273bc2070d0976c356d10d346b7..7dce3857cec672243312ec9a6defa0b58fc63cc5 100644 (file)
@@ -56,7 +56,7 @@ Context::check_removal ()
              Callback0_wrapper::make_smob
              <Translator_group, &Translator_group::finalize> (),
              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 ();
 }
index ea100c912aa703998cce74ebd0bfbe1ca6ace223..a8289d52cf549fcabc63e829ed08b3e7606dd44b 100644 (file)
@@ -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 ()));
 
index be523665b921911b0ffdffeef28cb675d2343c8d..f494ab4191e63c2b5025afe603aef5dacb14991e 100644 (file)
@@ -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 ();
     }
index daaaf855bf59216a1f1f90304e38fb1ca2435a09..4954dc914d2793c080967e235d8630605e321418 100644 (file)
@@ -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_;
 
index 2555bfe2b49e0e26519c2a1eac630a148d5026b3..42fb15aaa30fd93bcdec58cac74f978f5da057a2 100644 (file)
@@ -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);