]> git.donarmstrong.com Git - lilypond.git/blob - lily/property-iterator.cc
release: 1.3.81
[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--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "property-iterator.hh"
10 #include "translation-property.hh"
11 #include "translator-group.hh"
12
13 /**
14   There is no real processing to a property: just lookup the
15   translation unit, and set the property.
16   */
17 void
18 Property_iterator::do_process_and_next (Moment m)
19 {
20   SCM sym = music_l_->get_mus_property ("symbol");
21   if (gh_symbol_p(sym))
22     report_to_l ()->set_property (sym, music_l_->get_mus_property ("value"));
23   Music_iterator::do_process_and_next (m);
24 }
25
26
27 void
28 Push_property_iterator::do_process_and_next (Moment m)
29 {
30   SCM syms = music_l_->get_mus_property ("symbols");
31   SCM  eprop = music_l_->get_mus_property ("element-property");
32   SCM val = music_l_->get_mus_property ("element-value");
33
34   for (SCM s = syms; gh_pair_p (s); s = gh_cdr (s))
35     {
36       SCM sym = gh_car (s);
37       if (gh_symbol_p(sym))
38       {
39         SCM prev = report_to_l ()->get_property (sym);
40
41         prev = gh_cons (gh_cons (eprop, val), prev);
42         report_to_l ()->set_property (gh_car (s), prev);
43       }
44     }
45   Music_iterator::do_process_and_next (m);
46 }
47
48 void
49 Pop_property_iterator::do_process_and_next (Moment m)
50 {
51   SCM syms = music_l_->get_mus_property ("symbols");
52   SCM eprop = music_l_->get_mus_property ("element-property");
53   for (SCM s = syms; gh_pair_p (s); s = gh_cdr (s)) 
54     {
55     SCM sym = gh_car (s);
56     if (gh_symbol_p(sym))
57       {
58         SCM prev = report_to_l ()->get_property (sym);
59
60         SCM newprops= SCM_EOL ;
61         while (gh_pair_p (prev) && gh_caar (prev) != eprop)
62           {
63             newprops = gh_cons (gh_car (prev), newprops);
64             prev = gh_cdr (prev);
65           }
66
67         newprops = scm_reverse_x (newprops, gh_cdr (prev));
68         report_to_l ()->set_property (sym, newprops);
69       }
70     }
71   Music_iterator::do_process_and_next (m);
72 }