]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/grob-property.cc
Merge branch 'issue4609' into HEAD
[lilypond.git] / lily / grob-property.cc
index 1c755bf7b08ece8a52b194ffddcdcb881102e77d..e21ccf479d32e5f337cd37abd6a6fd0ed1771a47 100644 (file)
@@ -13,8 +13,6 @@
 #include "spanner.hh"
 #include "international.hh"
 #include "item.hh"
-#include "misc.hh"
-#include "item.hh"
 #include "program-option.hh"
 #include "profile.hh"
 #include "simple-closure.hh"
 #include "warn.hh"
 #include "protected-scm.hh"
 
-Protected_scm grob_property_callback_stack = SCM_EOL;
+Protected_scm grob_property_callback_stack (SCM_EOL);
 
 extern bool debug_property_callbacks;
 
-#ifndef NDEBUG
+#ifdef DEBUG
 static void
 print_property_callback_stack ()
 {
@@ -36,8 +34,8 @@ print_property_callback_stack ()
 }
 #endif
 
-static Protected_scm modification_callback = SCM_EOL;
-static Protected_scm cache_callback = SCM_EOL;
+static Protected_scm modification_callback (SCM_EOL);
+static Protected_scm cache_callback (SCM_EOL);
 
 /*
 FIXME: this should use ly:set-option interface instead.
@@ -77,7 +75,7 @@ Grob::instrumented_set_property (SCM sym, SCM v,
                                  int line,
                                  char const *fun)
 {
-#ifndef NDEBUG
+#ifdef DEBUG
   if (ly_is_procedure (modification_callback))
     scm_apply_0 (modification_callback,
                  scm_list_n (self_scm (),
@@ -123,8 +121,8 @@ Grob::internal_set_value_on_alist (SCM *alist, SCM sym, SCM v)
   if (do_internal_type_checking_global)
     {
       if (!ly_is_procedure (v)
-          && !Simple_closure::is_smob (v)
-          && !Unpure_pure_container::is_smob (v)
+          && !unsmob<Simple_closure> (v)
+          && !unsmob<Unpure_pure_container> (v)
           && !scm_is_eq (v, ly_symbol2scm ("calculation-in-progress")))
         type_check_assignment (sym, v, ly_symbol2scm ("backend-type?"));
 
@@ -137,7 +135,7 @@ Grob::internal_set_value_on_alist (SCM *alist, SCM sym, SCM v)
 SCM
 Grob::internal_get_property_data (SCM sym) const
 {
-#ifndef NDEBUG
+#ifdef DEBUG
   if (profile_property_accesses)
     note_property_access (&grob_property_lookup_table, sym);
 #endif
@@ -151,8 +149,8 @@ Grob::internal_get_property_data (SCM sym) const
   if (do_internal_type_checking_global && scm_is_pair (handle))
     {
       SCM val = scm_cdr (handle);
-      if (!ly_is_procedure (val) && !Simple_closure::is_smob (val)
-          && !Unpure_pure_container::is_smob (val))
+      if (!ly_is_procedure (val) && !unsmob<Simple_closure> (val)
+          && !unsmob<Unpure_pure_container> (val))
         type_check_assignment (sym, val, ly_symbol2scm ("backend-type?"));
 
       check_interfaces_for_property (this, sym);
@@ -166,7 +164,7 @@ Grob::internal_get_property (SCM sym) const
 {
   SCM val = get_property_data (sym);
 
-#ifndef NDEBUG
+#ifdef DEBUG
   if (scm_is_eq (val, ly_symbol2scm ("calculation-in-progress")))
     {
       programming_error (to_string ("cyclic dependency: calculation-in-progress encountered for #'%s (%s)",
@@ -180,11 +178,11 @@ Grob::internal_get_property (SCM sym) const
     }
 #endif
 
-  if (Unpure_pure_container *upc = Unpure_pure_container::unsmob (val))
+  if (Unpure_pure_container *upc = unsmob<Unpure_pure_container> (val))
     val = upc->unpure_part ();
 
   if (ly_is_procedure (val)
-      || Simple_closure::is_smob (val))
+      || unsmob<Simple_closure> (val))
     {
       Grob *me = ((Grob *)this);
       val = me->try_callback_on_alist (&me->mutable_property_alist_, sym, val);
@@ -201,7 +199,7 @@ Grob::internal_get_pure_property (SCM sym, int start, int end) const
   if (ly_is_procedure (val))
     return call_pure_function (val, scm_list_1 (self_scm ()), start, end);
 
-  if (Unpure_pure_container *upc = Unpure_pure_container::unsmob (val)) {
+  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);
@@ -209,7 +207,7 @@ Grob::internal_get_pure_property (SCM sym, int start, int end) const
       return call_pure_function (val, scm_list_1 (self_scm ()), start, end);
   }
 
-  if (Simple_closure *sc = Simple_closure::unsmob (val))
+  if (Simple_closure *sc = unsmob<Simple_closure> (val))
     return evaluate_with_simple_closure (self_scm (),
                                          sc->expression (),
                                          true, start, end);
@@ -232,7 +230,7 @@ Grob::try_callback_on_alist (SCM *alist, SCM sym, SCM proc)
   */
   *alist = scm_assq_set_x (*alist, sym, marker);
 
-#ifndef NDEBUG
+#ifdef DEBUG
   if (debug_property_callbacks)
     grob_property_callback_stack = scm_cons (scm_list_3 (self_scm (), sym, proc), grob_property_callback_stack);
 #endif
@@ -240,14 +238,14 @@ Grob::try_callback_on_alist (SCM *alist, SCM sym, SCM proc)
   SCM value = SCM_EOL;
   if (ly_is_procedure (proc))
     value = scm_call_1 (proc, self_scm ());
-  else if (Simple_closure *sc = Simple_closure::unsmob (proc))
+  else if (Simple_closure *sc = unsmob<Simple_closure> (proc))
     {
       value = evaluate_with_simple_closure (self_scm (),
                                             sc->expression (),
                                             false, 0, 0);
     }
 
-#ifndef NDEBUG
+#ifdef DEBUG
   if (debug_property_callbacks)
     grob_property_callback_stack = scm_cdr (grob_property_callback_stack);
 #endif
@@ -261,7 +259,7 @@ Grob::try_callback_on_alist (SCM *alist, SCM sym, SCM proc)
     }
   else
     {
-#ifndef NDEBUG
+#ifdef DEBUG
       if (ly_is_procedure (cache_callback))
         scm_apply_0 (cache_callback,
                      scm_list_n (self_scm (),
@@ -304,8 +302,8 @@ Grob::internal_get_object (SCM sym) const
     {
       SCM val = scm_cdr (s);
       if (ly_is_procedure (val)
-          || Simple_closure::is_smob (val)
-          || Unpure_pure_container::is_smob (val))
+          || unsmob<Simple_closure> (val)
+          || unsmob<Unpure_pure_container> (val))
         {
           Grob *me = ((Grob *)this);
           val = me->try_callback_on_alist (&me->object_alist_, sym, val);
@@ -332,11 +330,11 @@ Grob::internal_has_interface (SCM k)
 SCM
 call_pure_function (SCM unpure, SCM args, int start, int end)
 {
-  if (Unpure_pure_container *upc = Unpure_pure_container::unsmob (unpure))
+  if (Unpure_pure_container *upc = unsmob<Unpure_pure_container> (unpure))
     {
       SCM pure = upc->pure_part ();
 
-      if (Simple_closure *sc = Simple_closure::unsmob (pure))
+      if (Simple_closure *sc = unsmob<Simple_closure> (pure))
         {
           SCM expr = sc->expression ();
           return evaluate_with_simple_closure (scm_car (args), expr, true, start, end);
@@ -352,7 +350,7 @@ call_pure_function (SCM unpure, SCM args, int start, int end)
       return pure;
     }
 
-  if (Simple_closure *sc = Simple_closure::unsmob (unpure))
+  if (Simple_closure *sc = unsmob<Simple_closure> (unpure))
     {
       SCM expr = sc->expression ();
       return evaluate_with_simple_closure (scm_car (args), expr, true, start, end);