]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/grob-property.cc
Merge remote-tracking branch 'origin/translation' into staging
[lilypond.git] / lily / grob-property.cc
index db16f2a54af248e4818f6cb7d9188ed3d28a2972..32ff49124dff37919c6e21b5b8778874338c188b 100644 (file)
@@ -170,7 +170,7 @@ Grob::internal_get_property (SCM sym) const
     {
       programming_error (to_string ("cyclic dependency: calculation-in-progress encountered for #'%s (%s)",
                                     ly_symbol2string (sym).c_str (),
-                                    name ().c_str ()));
+                                    name ().c_str ()));//assert (1==0);
       if (debug_property_callbacks)
         {
           message ("backtrace: ");
@@ -181,6 +181,7 @@ Grob::internal_get_property (SCM sym) const
 
   if (is_unpure_pure_container (val))
     val = unpure_pure_container_unpure_part (val);
+
   if (ly_is_procedure (val)
       || is_simple_closure (val))
     {
@@ -196,8 +197,17 @@ SCM
 Grob::internal_get_pure_property (SCM sym, int start, int end) const
 {
   SCM val = internal_get_property_data (sym);
-  if (ly_is_procedure (val) || is_unpure_pure_container (val))
+  if (ly_is_procedure (val))
     return call_pure_function (val, scm_list_1 (self_scm ()), start, end);
+
+  if (is_unpure_pure_container (val)) {
+    // Do cache, if the function ignores 'start' and 'end'
+    if (is_unchanging_unpure_pure_container (val))
+      return internal_get_property (sym);
+    else
+      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),
@@ -241,11 +251,6 @@ Grob::try_callback_on_alist (SCM *alist, SCM sym, SCM proc)
     grob_property_callback_stack = scm_cdr (grob_property_callback_stack);
 #endif
 
-  /*
-    If the function returns SCM_UNSPECIFIED, we assume the
-    property has been set with an explicit set_property ()
-    call.
-  */
   if (value == SCM_UNSPECIFIED)
     {
       value = get_property_data (sym);
@@ -326,9 +331,35 @@ Grob::internal_has_interface (SCM k)
 SCM
 call_pure_function (SCM unpure, SCM args, int start, int end)
 {
-  SCM scm_call_pure_function = ly_lily_module_constant ("call-pure-function");
+  if (is_unpure_pure_container (unpure))
+    {
+      SCM pure = unpure_pure_container_pure_part (unpure);
+
+      if (is_simple_closure (pure))
+        {
+          SCM expr = simple_closure_expression (pure);
+          return evaluate_with_simple_closure (scm_car (args), expr, true, start, end);
+        }
+
+      if (ly_is_procedure (pure))
+        return scm_apply_0 (pure,
+                            scm_append (scm_list_2 (scm_list_3 (scm_car (args),
+                                                                scm_from_int (start),
+                                                                scm_from_int (end)),
+                                                    scm_cdr (args))));
+
+      return pure;
+    }
+
+  if (is_simple_closure (unpure))
+    {
+      SCM expr = simple_closure_expression (unpure);
+      return evaluate_with_simple_closure (scm_car (args), expr, true, start, end);
+    }
+
+  if (!ly_is_procedure (unpure))
+    return unpure;
 
-  return scm_apply_0 (scm_call_pure_function,
-                      scm_list_4 (unpure, args, scm_from_int (start), scm_from_int (end)));
+  return SCM_BOOL_F;
 }