-b eps -> -dbackend=eps
[lilypond.git] / lily / nested-property.cc
blobc1174b174d5a1bb156e59373b351e539090c7266
1 #include "context.hh"
2 #include "grob.hh"
4 SCM
5 evict_from_alist (SCM symbol,
6 SCM alist,
7 SCM alist_end)
9 SCM new_alist = SCM_EOL;
10 SCM *tail = &new_alist;
12 while (alist != alist_end)
14 if (ly_is_equal (scm_caar (alist), symbol))
16 alist = scm_cdr (alist);
17 break;
20 *tail = scm_cons (scm_car (alist), SCM_EOL);
21 tail = SCM_CDRLOC (*tail);
22 alist = scm_cdr (alist);
25 *tail = alist;
26 return new_alist;
30 PROP_PATH should be big-to-small ordering
32 SCM
33 nested_property_alist (SCM alist, SCM prop_path, SCM value)
35 SCM new_value = SCM_BOOL_F;
36 if (scm_is_pair (scm_cdr (prop_path)))
38 SCM sub_alist = ly_assoc_get (scm_car (prop_path), alist, SCM_EOL);
39 new_value = nested_property_alist (sub_alist, scm_cdr (prop_path), value);
41 else
43 new_value = value;
46 return scm_acons (scm_car (prop_path), new_value, alist);
49 SCM
50 nested_property_revert_alist (SCM alist, SCM prop_path)
52 SCM new_sub_alist = SCM_EOL;
53 SCM sym = scm_car (prop_path);
54 if (scm_is_pair (scm_cdr (prop_path)))
56 SCM sub_alist = ly_assoc_get (sym, alist, SCM_EOL);
57 new_sub_alist = nested_property_revert_alist (sub_alist, scm_cdr (prop_path));
59 else
61 new_sub_alist = evict_from_alist (sym, alist, SCM_EOL);
64 return scm_acons (sym, new_sub_alist, alist);
68 void
69 set_nested_property (Grob *me, SCM big_to_small, SCM value)
71 SCM alist = me->get_property (scm_car (big_to_small));
73 alist = nested_property_alist (alist, scm_cdr (big_to_small), value);
75 me->set_property (scm_car (big_to_small),
76 alist);