]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/property-iterator.cc
Run grand replace for 2015.
[lilypond.git] / lily / property-iterator.cc
index 53d88d548ca6544f5f8c00ec075dcced72cf54ac..bb1d3b4c1853748a1bbc02df4c573865fc71228d 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 1997--2014 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  Copyright (C) 1997--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
   LilyPond is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -38,11 +38,9 @@ Property_iterator::process (Moment mom)
   bool once = to_boolean (m->get_property ("once"));
   SCM symbol = m->get_property ("symbol");
   SCM previous_value = SCM_UNDEFINED;
-  if (once) {
-    Context *w = o->where_defined (symbol, &previous_value);
-    if (o != w)
-      previous_value = SCM_UNDEFINED;
-  }
+  if (once)
+    o->here_defined (symbol, &previous_value);
+
   send_stream_event (o, "SetProperty", m->origin (),
                      ly_symbol2scm ("symbol"), symbol,
                      ly_symbol2scm ("value"), m->get_property ("value"));
@@ -52,30 +50,47 @@ Property_iterator::process (Moment mom)
   if (once)
     {
       Global_context *tg = get_outlet ()->get_global_context ();
-      tg->add_finalization (scm_list_n (once_finalization_proc,
+      tg->add_finalization (scm_list_4 (once_finalization_proc,
                                         o->self_scm (), m->self_scm (),
-                                        ly_quote_scm (previous_value), SCM_UNDEFINED));
+                                        previous_value));
     }
 
   Simple_music_iterator::process (mom);
 }
 
 void
-Property_unset_iterator::process (Moment m)
+Property_unset_iterator::process (Moment mom)
 {
-  SCM sym = get_music ()->get_property ("symbol");
-  send_stream_event (get_outlet (), "UnsetProperty", get_music ()->origin (),
-                     ly_symbol2scm ("symbol"), sym);
+  Context *o = get_outlet ();
+  Music *m = get_music ();
+  bool once = to_boolean (m->get_property ("once"));
+  SCM symbol = m->get_property ("symbol");
+  SCM previous_value = SCM_UNDEFINED;
+  if (once)
+    o->here_defined (symbol, &previous_value);
 
-  Simple_music_iterator::process (m);
+  send_stream_event (o, "UnsetProperty", m->origin (),
+                     ly_symbol2scm ("symbol"), symbol);
+
+  /* For \once \unset install a finalization hook to reset the property to the
+   * previous value after the timestep */
+  if (once && !SCM_UNBNDP (previous_value))
+    {
+      Global_context *tg = get_outlet ()->get_global_context ();
+      tg->add_finalization (scm_list_4 (Property_iterator::once_finalization_proc,
+                                        o->self_scm (), m->self_scm (),
+                                        previous_value));
+    }
+
+  Simple_music_iterator::process (mom);
 }
 
 MAKE_SCHEME_CALLBACK (Property_iterator, once_finalization, 3);
 SCM
 Property_iterator::once_finalization (SCM ctx, SCM music, SCM previous_value)
 {
-  Music *m = unsmob_music (music);
-  Context *c = unsmob_context (ctx);
+  Music *m = Music::unsmob (music);
+  Context *c = Context::unsmob (ctx);
 
   // Do not use UnsetProperty, which sets the default, but rather
   // cache the value before the \once \set command and restore it now
@@ -144,8 +159,8 @@ MAKE_SCHEME_CALLBACK (Push_property_iterator, once_finalization, 2);
 SCM
 Push_property_iterator::once_finalization (SCM ctx, SCM music)
 {
-  Music *mus = unsmob_music (music);
-  Context *c = unsmob_context (ctx);
+  Music *mus = Music::unsmob (music);
+  Context *c = Context::unsmob (ctx);
 
   SCM sym = mus->get_property ("symbol");
   if (check_grob (mus, sym))
@@ -168,8 +183,8 @@ Push_property_iterator::do_quit ()
       SCM music = get_music ()->self_scm ();
 
       Global_context *tg = get_outlet ()->get_global_context ();
-      tg->add_finalization (scm_list_n (once_finalization_proc,
-                                        trans, music, SCM_UNDEFINED));
+      tg->add_finalization (scm_list_3 (once_finalization_proc,
+                                        trans, music));
     }
 }