X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fgrob-closure.cc;h=124d1437932c034f7fa5e2ba1dd5195585dac6ad;hb=38408524c283578cff6d5475ac2776ef81a2dcde;hp=c1610e89d635ef699132615c40d6a91071bb0f50;hpb=0ada3837f91b0e14cf7c588351d020b88e50d604;p=lilypond.git diff --git a/lily/grob-closure.cc b/lily/grob-closure.cc index c1610e89d6..124d143793 100644 --- a/lily/grob-closure.cc +++ b/lily/grob-closure.cc @@ -1,10 +1,6 @@ #include "grob.hh" #include "simple-closure.hh" -/* - UGH : todo -> to different file. - */ - SCM axis_offset_symbol (Axis a) { @@ -37,22 +33,26 @@ void add_offset_callback (Grob *g, SCM proc, Axis a) { SCM data = g->get_property_data (axis_offset_symbol (a)); + if (!scm_is_number (data) + && !ly_is_procedure (data) + && !is_simple_closure (data)) + { + g->set_property (axis_offset_symbol (a), proc); + return ; + } + if (ly_is_procedure (data)) data = ly_make_simple_closure (scm_list_1 (data)); else if (is_simple_closure (data)) data = simple_closure_expression (data); - else if (!scm_is_number (data)) - g->internal_set_property (axis_offset_symbol (a), - proc); - else - { - SCM plus = ly_lily_module_constant ("+"); - SCM expr = scm_list_3 (plus, - ly_make_simple_closure (scm_list_1 (proc)), - data); - g->internal_set_property (axis_offset_symbol (a), - ly_make_simple_closure (expr)); - } + + SCM plus = ly_lily_module_constant ("+"); + + if (ly_is_procedure (proc)) + proc = ly_make_simple_closure (scm_list_1 (proc)); + + SCM expr = scm_list_3 (plus, proc, data); + g->set_property (axis_offset_symbol (a), ly_make_simple_closure (expr)); } @@ -67,21 +67,32 @@ add_offset_callback (Grob *g, SCM proc, Axis a) */ void -chain_offset_callback (Grob *g, SCM proc, Axis a) +chain_callback (Grob *g, SCM proc, SCM sym) { - SCM data = g->get_property_data (axis_offset_symbol (a)); + SCM data = g->get_property_data (sym); if (ly_is_procedure (data)) data = ly_make_simple_closure (scm_list_1 (data)); else if (is_simple_closure (data)) data = simple_closure_expression (data); - else if (!scm_is_number (data)) - data = scm_from_int (0); - + else + /* + Data may be nonnumber. In that case, it is assumed to be + undefined. + */ + + data = SCM_UNDEFINED; + SCM expr = scm_list_2 (proc, data); - g->internal_set_property (axis_offset_symbol (a), - - // twice: one as a wrapper for grob property routines, - // once for the actual delayed binding. - ly_make_simple_closure (ly_make_simple_closure (expr))); + g->set_property (sym, + + // twice: one as a wrapper for grob property routines, + // once for the actual delayed binding. + ly_make_simple_closure (ly_make_simple_closure (expr))); +} + +void +chain_offset_callback (Grob *g, SCM proc, Axis a) +{ + chain_callback (g, proc, axis_offset_symbol (a)); }