2 property-iterator.cc -- implement Property_iterator
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "property-iterator.hh"
11 #include "translator-def.hh"
12 #include "translator-group.hh"
15 bool check_grob(Music *mus, SCM sym);
18 There is no real processing to a property: just lookup the
19 translation unit, and set the property.
22 Property_iterator::process (Moment m)
24 SCM sym = music_l ()->get_mus_property ("symbol");
25 if (gh_symbol_p (sym))
27 SCM val = music_l ()->get_mus_property ("value");
30 ok = type_check_assignment (sym, val, ly_symbol2scm ("translation-type?"));
32 report_to_l ()->internal_set_property (sym, val);
34 Simple_music_iterator::process (m);
38 Property_unset_iterator::process (Moment m)
40 SCM sym = music_l ()->get_mus_property ("symbol");
41 type_check_assignment (sym, SCM_EOL, ly_symbol2scm ("translation-type?"));
42 report_to_l ()->unset_property (sym);
44 Simple_music_iterator::process (m);
51 check_grob(Music *mus, SCM sym)
55 list_p = gh_eval_str ("list?");
59 SCM type_p = scm_object_property (sym, ly_symbol2scm ("translation-type?"));
60 bool ok = type_p == list_p;
64 mus->origin()->warning (_f("Not a grob name, `%s'." , ly_symbol2string (sym)));
70 Push_property_iterator::process (Moment m)
72 SCM sym = music_l ()->get_mus_property ("symbol");
73 if (check_grob (music_l (), sym))
75 SCM eprop = music_l ()->get_mus_property ("grob-property");
76 SCM val = music_l ()->get_mus_property ("grob-value");
78 if (to_boolean (music_l ()->get_mus_property ("pop-first")))
79 Translator_def::apply_pushpop_property (report_to_l (),
80 sym, eprop, SCM_UNDEFINED);
82 Translator_def::apply_pushpop_property (report_to_l (), sym, eprop, val);
84 Simple_music_iterator::process (m);
88 Pop_property_iterator::process (Moment m)
90 SCM sym = music_l ()->get_mus_property ("symbol");
91 if (check_grob (music_l (), sym))
93 SCM eprop = music_l ()->get_mus_property ("grob-property");
94 Translator_def::apply_pushpop_property (report_to_l (), sym, eprop, SCM_UNDEFINED);
96 Simple_music_iterator::process (m);
100 IMPLEMENT_CTOR_CALLBACK (Pop_property_iterator);
101 IMPLEMENT_CTOR_CALLBACK (Push_property_iterator);
102 IMPLEMENT_CTOR_CALLBACK (Property_iterator);
103 IMPLEMENT_CTOR_CALLBACK (Property_unset_iterator);