X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fnested-property.cc;h=9c3cc73387a74dbd2533206b8148a03308871225;hb=b51ccf16e888af1e16b5c6fe733a04e7349de06a;hp=c59671814439db7da1fa7fadfdcc9230a456e646;hpb=d88df37f2e5d1ff28d6c7528f076d59a77e0dfcd;p=lilypond.git diff --git a/lily/nested-property.cc b/lily/nested-property.cc index c596718144..9c3cc73387 100644 --- a/lily/nested-property.cc +++ b/lily/nested-property.cc @@ -1,7 +1,6 @@ #include "context.hh" #include "grob.hh" - /* Drop symbol from the list alist..alist_end. */ @@ -14,10 +13,10 @@ evict_from_alist (SCM symbol, SCM alist, SCM alist_end) while (alist != alist_end) { if (ly_is_equal (scm_caar (alist), symbol)) - { - alist = scm_cdr (alist); - break; - } + { + alist = scm_cdr (alist); + break; + } *tail = scm_cons (scm_car (alist), SCM_EOL); tail = SCM_CDRLOC (*tail); @@ -31,7 +30,7 @@ evict_from_alist (SCM symbol, SCM alist, SCM alist_end) /* PROP_PATH should be big-to-small ordering */ -SCM +SCM nested_property_alist (SCM alist, SCM prop_path, SCM value) { SCM new_value = SCM_BOOL_F; @@ -52,17 +51,17 @@ nested_property_alist (SCM alist, SCM prop_path, SCM value) Recursively purge alist of prop_path: revert ((sym, val) : L, [sym]) = L - revert ((sym, val) : L, sym : props) = + revert ((sym, val) : L, sym : props) = (sym, revert (val, rest-props)) ++ L revert ((sym, val) : L, p ++ rest-props) = (sym, val) : revert (L, p ++ rest-props) */ -SCM +SCM nested_property_revert_alist (SCM alist, SCM prop_path) { - assert(scm_is_pair (prop_path)); - + assert (scm_is_pair (prop_path)); + SCM wanted_sym = scm_car (prop_path); SCM new_list = SCM_EOL; @@ -70,29 +69,29 @@ nested_property_revert_alist (SCM alist, SCM prop_path) for (SCM s = alist; scm_is_pair (s); s = scm_cdr (s)) { SCM sub_sym = scm_caar (s); - SCM old_val = scm_cadr (s); + SCM old_val = scm_cdar (s); if (sub_sym == wanted_sym) - { - if (scm_is_pair (scm_cdr (prop_path))) - { - SCM new_val = nested_property_revert_alist (old_val, scm_cdr (prop_path)); - - /* nothing changed: drop newly constructed list. */ - if (old_val == new_val) - return alist; - - *tail = scm_acons (sub_sym, new_val, SCM_EOL); - tail = SCM_CDRLOC(*tail); - } - else - { - /* old value is dropped. */ - } - - *tail = scm_cdr (s); - return new_list; - } + { + if (scm_is_pair (scm_cdr (prop_path))) + { + SCM new_val = nested_property_revert_alist (old_val, scm_cdr (prop_path)); + + /* nothing changed: drop newly constructed list. */ + if (old_val == new_val) + return alist; + + *tail = scm_acons (sub_sym, new_val, SCM_EOL); + tail = SCM_CDRLOC (*tail); + } + else + { + /* old value is dropped. */ + } + + *tail = scm_cdr (s); + return new_list; + } *tail = scm_acons (sub_sym, old_val, SCM_EOL); tail = SCM_CDRLOC (*tail); @@ -102,14 +101,12 @@ nested_property_revert_alist (SCM alist, SCM prop_path) return alist; } - void set_nested_property (Grob *me, SCM big_to_small, SCM value) { SCM alist = me->get_property (scm_car (big_to_small)); alist = nested_property_alist (alist, scm_cdr (big_to_small), value); - + me->set_property (scm_car (big_to_small), alist); } -