]> git.donarmstrong.com Git - lilypond.git/blob - lily/property-iterator.cc
release: 1.5.0
[lilypond.git] / lily / property-iterator.cc
1 /*
2   property-iterator.cc -- implement Property_iterator
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "property-iterator.hh"
10 #include "music.hh"
11 #include "translator-def.hh"
12 #include "translator-group.hh"
13
14 /**
15   There is no real processing to a property: just lookup the
16   translation unit, and set the property.
17   */
18 void
19 Property_iterator::process (Moment m)
20 {
21   SCM sym = music_l ()->get_mus_property ("symbol");
22   if (gh_symbol_p (sym))
23     {
24       SCM val = music_l ()->get_mus_property ("value");
25       bool ok= true;
26       if (val != SCM_EOL)
27         ok = type_check_assignment (val, sym, ly_symbol2scm ("translation-type?"));
28       if (ok)
29         report_to_l ()->set_property (sym, val);
30     }
31   Simple_music_iterator::process (m);
32 }
33
34 void
35 Property_unset_iterator::process (Moment m)
36 {
37   SCM sym = music_l ()->get_mus_property ("symbol");
38   if (gh_symbol_p (sym))
39     {
40       report_to_l ()->unset_property (sym);
41     }
42   Simple_music_iterator::process (m);
43 }
44
45
46 void
47 Push_property_iterator::process (Moment m)
48 {
49   SCM syms = music_l ()->get_mus_property ("symbols");
50   SCM eprop = music_l ()->get_mus_property ("grob-property");
51   SCM val = music_l ()->get_mus_property ("grob-value");
52
53   if (to_boolean (music_l ()->get_mus_property ("pop-first")))
54     Translator_def::apply_pushpop_property (report_to_l (),
55                                             syms, eprop, SCM_UNDEFINED);
56
57   Translator_def::apply_pushpop_property (report_to_l (), syms, eprop, val);
58   
59   Simple_music_iterator::process (m);
60 }
61
62 void
63 Pop_property_iterator::process (Moment m)
64 {
65   SCM syms = music_l ()->get_mus_property ("symbols");
66   SCM eprop = music_l ()->get_mus_property ("grob-property");
67   Translator_def::apply_pushpop_property (report_to_l (), syms, eprop, SCM_UNDEFINED);
68   
69   Simple_music_iterator::process (m);
70 }
71
72
73 IMPLEMENT_CTOR_CALLBACK (Pop_property_iterator);
74 IMPLEMENT_CTOR_CALLBACK (Push_property_iterator);
75 IMPLEMENT_CTOR_CALLBACK (Property_iterator);
76 IMPLEMENT_CTOR_CALLBACK (Property_unset_iterator);