- 1, 0, 0, (SCM cb),
- "Specify a procedure that will be called every time LilyPond"
- " modifies a grob property. The callback will receive as"
- " arguments the grob that is being modified, the name of the"
- " C++ file in which the modification was requested, the line"
- " number in the C++ file in which the modification was requested,"
- " the name of the function in which the modification was"
- " requested, the property to be changed, and the new value for"
- " the property.")
+ 1, 0, 0, (SCM cb),
+ "Specify a procedure that will be called every time LilyPond"
+ " modifies a grob property. The callback will receive as"
+ " arguments the grob that is being modified, the name of the"
+ " C++ file in which the modification was requested, the line"
+ " number in the C++ file in which the modification was requested,"
+ " the name of the function in which the modification was"
+ " requested, the property to be changed, and the new value for"
+ " the property.")
- 1, 0, 0, (SCM cb),
- "Specify a procedure that will be called whenever lilypond"
- " calculates a callback function and caches the result. The"
- " callback will receive as arguments the grob whose property it"
- " is, the name of the property, the name of the callback that"
- " calculated the property, and the new (cached) value of the"
- " property.")
+ 1, 0, 0, (SCM cb),
+ "Specify a procedure that will be called whenever lilypond"
+ " calculates a callback function and caches the result. The"
+ " callback will receive as arguments the grob whose property it"
+ " is, the name of the property, the name of the callback that"
+ " calculated the property, and the new (cached) value of the"
+ " property.")
if (ly_is_procedure (modification_callback))
scm_apply_0 (modification_callback,
if (ly_is_procedure (modification_callback))
scm_apply_0 (modification_callback,
- scm_list_n (self_scm (),
- scm_from_locale_string (file),
- scm_from_int (line),
- scm_from_locale_string (fun),
- sym, v, SCM_UNDEFINED));
+ scm_list_n (self_scm (),
+ scm_from_locale_string (file),
+ scm_from_int (line),
+ scm_from_ascii_string (fun),
+ sym, v, SCM_UNDEFINED));
internal_set_property (sym, v);
}
SCM
Grob::get_property_alist_chain (SCM def) const
{
internal_set_property (sym, v);
}
SCM
Grob::get_property_alist_chain (SCM def) const
{
- return scm_list_n (mutable_property_alist_,
- immutable_property_alist_,
- def,
- SCM_UNDEFINED);
+ return scm_list_3 (mutable_property_alist_,
+ immutable_property_alist_,
+ def);
Grob::internal_set_property (SCM sym, SCM v)
{
internal_set_value_on_alist (&mutable_property_alist_,
Grob::internal_set_property (SCM sym, SCM v)
{
internal_set_value_on_alist (&mutable_property_alist_,
- && !is_simple_closure (v)
- && v != ly_symbol2scm ("calculation-in-progress"))
- type_check_assignment (sym, v, ly_symbol2scm ("backend-type?"));
+ && !unsmob<Unpure_pure_container> (v)
+ && !scm_is_eq (v, ly_symbol2scm ("calculation-in-progress")))
+ type_check_assignment (sym, v, ly_symbol2scm ("backend-type?"));
if (profile_property_accesses)
note_property_access (&grob_property_lookup_table, sym);
#endif
if (profile_property_accesses)
note_property_access (&grob_property_lookup_table, sym);
#endif
- if (!ly_is_procedure (val) && !is_simple_closure (val))
- type_check_assignment (sym, val, ly_symbol2scm ("backend-type?"));
+ if (!ly_is_procedure (val)
+ && !unsmob<Unpure_pure_container> (val))
+ type_check_assignment (sym, val, ly_symbol2scm ("backend-type?"));
- programming_error (_f ("cyclic dependency: calculation-in-progress encountered for #'%s (%s)",
- ly_symbol2string (sym).c_str (),
- name ().c_str ()));
+ programming_error (to_string ("cyclic dependency: calculation-in-progress encountered for #'%s (%s)",
+ ly_symbol2string (sym).c_str (),
+ name ().c_str ()));//assert (1==0);
-
- if (ly_is_procedure (val)
- || is_simple_closure (val))
+
+ if (Unpure_pure_container *upc = unsmob<Unpure_pure_container> (val))
+ val = upc->unpure_part ();
+
+ if (ly_is_procedure (val))
SCM val = internal_get_property_data (sym);
if (ly_is_procedure (val))
return call_pure_function (val, scm_list_1 (self_scm ()), start, end);
SCM val = internal_get_property_data (sym);
if (ly_is_procedure (val))
return call_pure_function (val, scm_list_1 (self_scm ()), start, end);
- if (is_simple_closure (val))
- return evaluate_with_simple_closure (self_scm (),
- simple_closure_expression (val),
- true, start, end);
+
+ if (Unpure_pure_container *upc = unsmob<Unpure_pure_container> (val)) {
+ // Do cache, if the function ignores 'start' and 'end'
+ if (upc->is_unchanging ())
+ return internal_get_property (sym);
+ else
+ return call_pure_function (val, scm_list_1 (self_scm ()), start, end);
+ }
+
SCM marker = ly_symbol2scm ("calculation-in-progress");
/*
need to put a value in SYM to ensure that we don't get a
SCM marker = ly_symbol2scm ("calculation-in-progress");
/*
need to put a value in SYM to ensure that we don't get a
if (debug_property_callbacks)
grob_property_callback_stack = scm_cons (scm_list_3 (self_scm (), sym, proc), grob_property_callback_stack);
#endif
if (debug_property_callbacks)
grob_property_callback_stack = scm_cons (scm_list_3 (self_scm (), sym, proc), grob_property_callback_stack);
#endif
SCM value = SCM_EOL;
if (ly_is_procedure (proc))
value = scm_call_1 (proc, self_scm ());
SCM value = SCM_EOL;
if (ly_is_procedure (proc))
value = scm_call_1 (proc, self_scm ());
-
- /*
- If the function returns SCM_UNSPECIFIED, we assume the
- property has been set with an explicit set_property ()
- call.
- */
- if (value == SCM_UNSPECIFIED)
+
+ if (scm_is_eq (value, SCM_UNSPECIFIED))
- assert (value == SCM_EOL || value == marker);
- if (value == marker)
- *alist = scm_assq_remove_x (*alist, marker);
+ assert (scm_is_null (value) || scm_is_eq (value, marker));
+ if (scm_is_eq (value, marker))
+ *alist = scm_assq_remove_x (*alist, sym);
note_property_access (&grob_property_lookup_table, sym);
SCM s = scm_sloppy_assq (sym, object_alist_);
note_property_access (&grob_property_lookup_table, sym);
SCM s = scm_sloppy_assq (sym, object_alist_);
- || is_simple_closure (val))
- {
- Grob *me = ((Grob*)this);
- val = me->try_callback_on_alist (&me->object_alist_, sym, val);
- }
-
+ || unsmob<Unpure_pure_container> (val))
+ {
+ Grob *me = ((Grob *)this);
+ val = me->try_callback_on_alist (&me->object_alist_, sym, val);
+ }
+
-call_pure_function (SCM unpure, SCM args, int start, int end)
+call_pure_function (SCM value, SCM args, int start, int end)
- SCM scm_call_pure_function = ly_lily_module_constant ("call-pure-function");
+ if (Unpure_pure_container *upc = unsmob<Unpure_pure_container> (value))
+ {
+ if (upc->is_unchanging ())
+ {
+ // Don't bother forming an Unpure_pure_call here.
+ value = upc->unpure_part ();
+
+ if (ly_is_procedure (value))
+ return scm_apply_0 (value, args);
+ return value;
+ }
+
+ value = upc->pure_part ();
+
+ if (ly_is_procedure (value))
+ return scm_apply_3 (value,
+ scm_car (args),
+ scm_from_int (start),
+ scm_from_int (end),
+ scm_cdr (args));
+
+ return value;
+ }
- return scm_apply_0 (scm_call_pure_function,
- scm_list_4 (unpure, args, scm_from_int (start), scm_from_int (end)));
-}
+ if (!ly_is_procedure (value))
+ return value;