X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=sidebyside;f=lily%2Fcontext-property.cc;h=534fced49aacc813db06a76a0d63c4768516fc14;hb=450dba56eaa24cd58f9d9d3c4ab5c73bd4c57742;hp=446306cd5d0ec3e6b65f4a816374fbff80d9bc57;hpb=66f2e4d70f2ca06003240100b3305b91ba504354;p=lilypond.git diff --git a/lily/context-property.cc b/lily/context-property.cc index 446306cd5d..534fced49a 100644 --- a/lily/context-property.cc +++ b/lily/context-property.cc @@ -24,7 +24,6 @@ #include "international.hh" #include "item.hh" #include "main.hh" -#include "simple-closure.hh" #include "smobs.hh" #include "spanner.hh" #include "unpure-pure-container.hh" @@ -59,7 +58,6 @@ typecheck_grob (SCM symbol, SCM value) return typecheck_grob (symbol, upc->unpure_part ()) && typecheck_grob (symbol, upc->pure_part ()); return ly_is_procedure (value) - || unsmob (value) || type_check_assignment (symbol, value, ly_symbol2scm ("backend-type?")); } @@ -238,6 +236,59 @@ Grob_property_info::push (SCM grob_property_path, SCM new_value) return SCM_EOL; } +// Used for \once \override, returns a token for matched_pop +SCM +Grob_property_info::temporary_override (SCM grob_property_path, SCM new_value) +{ + SCM cell = push (grob_property_path, new_value); + if (!scm_is_pair (cell)) + return cell; + if (scm_is_symbol (scm_car (cell))) + props_->nested_++; + cell = scm_cons (SCM_BOOL_T, cell); + props_->alist_ = scm_cons (cell, scm_cdr (props_->alist_)); + return cell; +} + +// Used for \once \revert, returns a token for matched_pop +SCM +Grob_property_info::temporary_revert (SCM grob_property_path) +{ + if (!check ()) + return SCM_EOL; + + SCM current_alist = props_->alist_; + SCM daddy = props_->based_on_; + SCM tail = SCM_EOL; + + if (!scm_is_pair (grob_property_path) + || !scm_is_symbol (scm_car (grob_property_path))) + { + programming_error ("Grob property path should be list of symbols."); + return SCM_EOL; + } + + if (scm_is_pair (scm_cdr (grob_property_path))) + { + tail = assoc_tail (grob_property_path, current_alist, daddy); + if (scm_is_false (tail)) + return SCM_EOL; + } + else + { + tail = assq_tail (scm_car (grob_property_path), current_alist, daddy); + if (scm_is_false (tail)) + return SCM_EOL; + ++props_->nested_; + } + + SCM cell = scm_cons (SCM_BOOL_F, scm_car (tail)); + props_->alist_ = partial_list_copy (current_alist, tail, + scm_cons (cell, scm_cdr (tail))); + return cell; +} + + void Grob_property_info::matched_pop (SCM cell) { @@ -251,6 +302,17 @@ Grob_property_info::matched_pop (SCM cell) { if (scm_is_eq (scm_car (p), cell)) { + SCM key = scm_car (cell); + if (scm_is_false (key)) + { + // temporary revert, reactivate + cell = scm_cdr (cell); + if (scm_is_symbol (scm_car (cell))) + props_->nested_--; + props_->alist_ = partial_list_copy (current_alist, p, + scm_cons (cell, scm_cdr (p))); + return; + } if (!scm_is_symbol (key)) props_->nested_--; props_->alist_ = partial_list_copy (current_alist, p, scm_cdr (p)); @@ -341,7 +403,7 @@ apply_property_operations (Context *tg, SCM pre_init_ops) else if (scm_is_eq (type, ly_symbol2scm ("assign"))) tg->set_property (scm_car (entry), scm_cadr (entry)); else if (scm_is_eq (type, ly_symbol2scm ("apply"))) - scm_apply_1 (scm_car (entry), tg->self_scm (), scm_cdr (entry)); + scm_apply_1 (scm_car (entry), tg->self_scm (), scm_cdr (entry)); else if (scm_is_eq (type, ly_symbol2scm ("unset"))) tg->unset_property (scm_car (entry)); }