]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 3249: Make a PostEvents container class for packaging several postevents
authorDavid Kastrup <dak@gnu.org>
Sat, 16 Mar 2013 16:35:53 +0000 (17:35 +0100)
committerDavid Kastrup <dak@gnu.org>
Sun, 24 Mar 2013 11:06:48 +0000 (12:06 +0100)
Previously it was not possible to assign multiple postevents to a
single variable or pass them as the result of an event function.  This
patch wraps multiple events in such situations inside of a PostEvents
post-event and unwraps them when used again in the parser.

lily/parser.yy
scm/define-music-types.scm

index 79560ab1d7b52e346677809d0f54db18978dfdec..ee413b301feb33f4d16d4a372c4a4c4c0ccfd8bc 100644 (file)
@@ -596,7 +596,28 @@ identifier_init:
        | output_def
        | context_def_spec_block
        | music_assign
-       | post_event_nofinger
+       | post_event_nofinger post_events
+       {
+               $$ = scm_reverse_x ($2, SCM_EOL);
+               if (Music *m = unsmob_music ($1))
+               {
+                       if (m->is_mus_type ("post-event-wrapper"))
+                               $$ = scm_append
+                                       (scm_list_2 (m->get_property ("elements"),
+                                                    $$));
+                       else
+                               $$ = scm_cons ($1, $$);
+               }
+               if (scm_is_pair ($$)
+                   && scm_is_null (scm_cdr ($$)))
+                       $$ = scm_car ($$);
+               else
+               {
+                       Music * m = MY_MAKE_MUSIC ("PostEvents", @$);
+                       m->set_property ("elements", $$);
+                       $$ = m->unprotect ();
+               }
+       }
        | number_expression
        | FRACTION
        | string
@@ -2490,9 +2511,21 @@ post_events:
                $$ = SCM_EOL;
        }
        | post_events post_event {
-               if (unsmob_music ($2)) {
-                       unsmob_music ($2)->set_spot (@2);
-                       $$ = scm_cons ($2, $$);
+               $$ = $1;
+               if (Music *m = unsmob_music ($2))
+               {
+                       if (m->is_mus_type ("post-event-wrapper"))
+                       {
+                               for (SCM p = m->get_property ("elements");
+                                    scm_is_pair (p);
+                                    p = scm_cdr (p))
+                               {
+                                       $$ = scm_cons (scm_car (p), $$);
+                               }
+                       } else {
+                               m->set_spot (@2);
+                               $$ = scm_cons ($2, $$);
+                       }
                }
        }
        ;
index 6d40ce0f56d6e5c90b835e2168834f77f92b3fed..1090d332b49aec21b01fcf852f1f19fc158f7889 100644 (file)
@@ -437,6 +437,12 @@ Syntax: @var{note}@code{\\(} and @var{note}@code{\\)}")
        (types . (general-music post-event span-event event phrasing-slur-event))
        ))
 
+    (PostEvents
+     . ((description . "Container for several postevents.
+
+This can be used to package several events into a single one.  Should not be seen outside of the parser.")
+        (types . (post-event post-event-wrapper))))
+
     (PropertySet
      . ((description . "Set a context property.