2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 1997--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
20 #include "property-iterator.hh"
22 #include "context-def.hh"
23 #include "global-context.hh"
24 #include "international.hh"
27 bool check_grob (Music *mus, SCM sym);
30 There is no real processing to a property: just lookup the
31 translation unit, and set the property.
34 Property_iterator::process (Moment mom)
36 Context *o = get_outlet ();
37 Music *m = get_music ();
39 send_stream_event (o, "SetProperty", m->origin (),
40 ly_symbol2scm ("symbol"), m->get_property ("symbol"),
41 ly_symbol2scm ("value"), m->get_property ("value"),
42 ly_symbol2scm ("once"), m->get_property ("once"));
44 Simple_music_iterator::process (mom);
48 Property_unset_iterator::process (Moment mom)
50 Context *o = get_outlet ();
51 Music *m = get_music ();
53 send_stream_event (o, "UnsetProperty", m->origin (),
54 ly_symbol2scm ("symbol"), m->get_property ("symbol"),
55 ly_symbol2scm ("once"), m->get_property ("once"));
57 Simple_music_iterator::process (mom);
61 check_grob (Music *mus, SCM sym)
63 bool g = to_boolean (scm_object_property (sym, ly_symbol2scm ("is-grob?")));
66 mus->origin ()->warning (_f ("not a grob name, `%s'",
67 ly_symbol2string (sym)));
73 get_property_path (Music *m)
75 SCM grob_property_path = m->get_property ("grob-property-path");
77 SCM eprop = m->get_property ("grob-property");
78 if (scm_is_symbol (eprop))
80 grob_property_path = scm_list_1 (eprop);
83 return grob_property_path;
87 Push_property_iterator::process (Moment m)
89 SCM sym = get_music ()->get_property ("symbol");
90 if (check_grob (get_music (), sym))
92 SCM grob_property_path = get_property_path (get_music ());
93 SCM val = get_music ()->get_property ("grob-value");
94 SCM once = get_music ()->get_property ("once");
96 if (to_boolean (get_music ()->get_property ("pop-first"))
97 && !to_boolean (once))
98 send_stream_event (get_outlet (), "Revert", get_music ()->origin (),
99 ly_symbol2scm ("symbol"), sym,
100 ly_symbol2scm ("property-path"), grob_property_path);
102 send_stream_event (get_outlet (), "Override", get_music ()->origin (),
103 ly_symbol2scm ("symbol"), sym,
104 ly_symbol2scm ("property-path"), grob_property_path,
105 ly_symbol2scm ("once"), once,
106 ly_symbol2scm ("value"), val);
108 Simple_music_iterator::process (m);
112 Pop_property_iterator::process (Moment mom)
114 Music *m = get_music ();
115 SCM sym = m->get_property ("symbol");
117 if (check_grob (m, sym))
119 SCM grob_property_path = get_property_path (m);
121 send_stream_event (get_outlet (), "Revert", m->origin (),
122 ly_symbol2scm ("symbol"), sym,
123 ly_symbol2scm ("once"), m->get_property ("once"),
124 ly_symbol2scm ("property-path"), grob_property_path);
126 Simple_music_iterator::process (mom);
129 IMPLEMENT_CTOR_CALLBACK (Pop_property_iterator);
130 IMPLEMENT_CTOR_CALLBACK (Push_property_iterator);
131 IMPLEMENT_CTOR_CALLBACK (Property_iterator);
132 IMPLEMENT_CTOR_CALLBACK (Property_unset_iterator);