]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/grob-closure.cc
Web: Introduction.itexi - updated 'Productions'
[lilypond.git] / lily / grob-closure.cc
index 124d1437932c034f7fa5e2ba1dd5195585dac6ad..ee4d1b04076c6e8d434d9333102e1af1b1e59d5f 100644 (file)
@@ -1,24 +1,23 @@
 #include "grob.hh"
 #include "simple-closure.hh"
+#include "unpure-pure-container.hh"
 
 SCM
 axis_offset_symbol (Axis a)
 {
   return a == X_AXIS
-    ? ly_symbol2scm ("X-offset")
-    : ly_symbol2scm ("Y-offset");
+         ? ly_symbol2scm ("X-offset")
+         : ly_symbol2scm ("Y-offset");
 }
 
 SCM
 axis_parent_positioning (Axis a)
 {
   return (a == X_AXIS)
-    ? Grob::x_parent_positioning_proc
-    : Grob::y_parent_positioning_proc;
+         ? Grob::x_parent_positioning_proc
+         : Grob::y_parent_positioning_proc;
 }
 
-
-
 /*
   Replace
 
@@ -27,7 +26,6 @@ axis_parent_positioning (Axis a)
   by
 
   (+ (PROC GROB) (orig-proc GROB))
-  
 */
 void
 add_offset_callback (Grob *g, SCM proc, Axis a)
@@ -35,27 +33,26 @@ 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))
+      && !Simple_closure::is_smob (data))
     {
       g->set_property (axis_offset_symbol (a), proc);
-      return ;
+      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);
+  if (ly_is_procedure (data) || Unpure_pure_container::is_smob (data))
+    data = Simple_closure::make_smob (scm_list_1 (data));
+  else if (Simple_closure *sc = Simple_closure::unsmob (data))
+    data = sc->expression ();
 
   SCM plus = ly_lily_module_constant ("+");
 
   if (ly_is_procedure (proc))
-    proc = ly_make_simple_closure (scm_list_1 (proc));
-  
+    proc = Simple_closure::make_smob (scm_list_1 (proc));
+
   SCM expr = scm_list_3 (plus, proc, data);
-  g->set_property (axis_offset_symbol (a), ly_make_simple_closure (expr));
+  g->set_property (axis_offset_symbol (a), Simple_closure::make_smob (expr));
 }
 
-
 /*
   replace
 
@@ -63,18 +60,17 @@ add_offset_callback (Grob *g, SCM proc, Axis a)
 
   by
 
-  (PROC GROB (orig-proc GROB)) 
-
+  (PROC GROB (orig-proc GROB))
 */
 void
 chain_callback (Grob *g, SCM proc, SCM sym)
 {
   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);
+  if (ly_is_procedure (data) || Unpure_pure_container::is_smob (data))
+    data = Simple_closure::make_smob (scm_list_1 (data));
+  else if (Simple_closure *sc = Simple_closure::unsmob (data))
+    data = sc->expression ();
   else
     /*
       Data may be nonnumber. In that case, it is assumed to be
@@ -85,10 +81,10 @@ chain_callback (Grob *g, SCM proc, SCM sym)
 
   SCM expr = scm_list_2 (proc, data);
   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)));
+
+                   // twice: one as a wrapper for grob property routines,
+                   // once for the actual delayed binding.
+                   Simple_closure::make_smob (Simple_closure::make_smob (expr)));
 }
 
 void