]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/grob-property.cc: add scm debugging hooks into
authorJoe Neeman <joeneeman@gmail.com>
Sat, 23 Sep 2006 22:51:56 +0000 (22:51 +0000)
committerJoe Neeman <joeneeman@gmail.com>
Sat, 23 Sep 2006 22:51:56 +0000 (22:51 +0000)
property modification

* lily/context-property.cc:
* lily/engraver.cc:
rename make_foo_from_properties to internal_make_foo and
move it from context-property.cc to a member function of
Engraver.

* lily/include/lily-guile-macros.hh:
overload ly_symbol2scm macro so that there is no more need
to use internal_foo

* lily/volta-repeat-iterator.cc:
* lily/tweak-engraver.cc:
* lily/tuplet-bracket.cc:
* lily/span-bar-engraver.cc:
* lily/script-engraver.cc:
* lily/prob-scheme.cc:
* lily/pointer-group-interface.cc:
* lily/parser.yy:
* lily/grob-scheme.cc:
* lily/grob-property.cc:
* lily/context.cc:
* lily/context-property.cc:
* lily/break-substitution.cc:
* lily/break-align-engraver.cc:
* lily/axis-group-interface.cc:
* lily/align-interface.cc:
remove calls to internal_FOO

* lily/system-start-delimiter-engraver.cc:
* lily/parenthesis-engraver.cc:
* lily/accidental-engraver.cc:
remove calls to make_foo_from_properties

29 files changed:
ChangeLog
lily/accidental-engraver.cc
lily/align-interface.cc
lily/axis-group-interface.cc
lily/break-align-engraver.cc
lily/break-substitution.cc
lily/context-property.cc
lily/context-scheme.cc
lily/context.cc
lily/engraver.cc
lily/grob-closure.cc
lily/grob-property.cc
lily/grob-scheme.cc
lily/include/context.hh
lily/include/engraver.hh
lily/include/grob.hh
lily/include/lily-guile-macros.hh
lily/include/prob.hh
lily/parenthesis-engraver.cc
lily/parser.yy
lily/pointer-group-interface.cc
lily/prob-scheme.cc
lily/prob.cc
lily/script-engraver.cc
lily/span-bar-engraver.cc
lily/system-start-delimiter-engraver.cc
lily/tuplet-bracket.cc
lily/tweak-engraver.cc
lily/volta-repeat-iterator.cc

index 6afd20305c53efd793a455ab05fc570673923326..1b710a699f7e275a4760927b2fb28883a1b3a815 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,40 @@
+2006-09-24  Joe Neeman  <joeneeman@gmail.com>
+       * lily/grob-property.cc: add scm debugging hooks into
+       property modification
+
+       * lily/context-property.cc:
+       * lily/engraver.cc:
+       rename make_foo_from_properties to internal_make_foo and
+       move it from context-property.cc to a member function of
+       Engraver.
+
+       * lily/include/lily-guile-macros.hh:
+       overload ly_symbol2scm macro so that there is no more need
+       to use internal_foo
+
+       * lily/volta-repeat-iterator.cc:
+       * lily/tweak-engraver.cc:
+       * lily/tuplet-bracket.cc:
+       * lily/span-bar-engraver.cc:
+       * lily/script-engraver.cc:
+       * lily/prob-scheme.cc:
+       * lily/pointer-group-interface.cc:
+       * lily/parser.yy:
+       * lily/grob-scheme.cc:
+       * lily/grob-property.cc:
+       * lily/context.cc:
+       * lily/context-property.cc:
+       * lily/break-substitution.cc:
+       * lily/break-align-engraver.cc:
+       * lily/axis-group-interface.cc:
+       * lily/align-interface.cc:
+       remove calls to internal_FOO
+
+       * lily/system-start-delimiter-engraver.cc:
+       * lily/parenthesis-engraver.cc:
+       * lily/accidental-engraver.cc:
+       remove calls to make_foo_from_properties
+
 2006-09-23  Graham Percival  <gpermus@gmail.com>
 
        * Documentation/user/programming-iterfaces.itely: fix
index f6ea8e0e18a1bea149d3e3ab874df1404571af24..f1e0a270b722549cb1ff05262a9183016975fba4 100644 (file)
@@ -398,11 +398,7 @@ Accidental_engraver::make_standard_accidental (Stream_event *note,
     level, so that we get the property settings for
     Accidental from the respective Voice.
   */
-  Grob *a
-    = make_grob_from_properties (trans,
-                                ly_symbol2scm ("Accidental"),
-                                note_head->self_scm (),
-                                "Accidental");
+  Grob *a = trans->make_item ("Accidental", note_head->self_scm ());
 
   /*
     We add the accidentals to the support of the arpeggio,
@@ -438,11 +434,7 @@ Accidental_engraver::make_suggested_accidental (Stream_event *note,
                                                Engraver *trans)
 {
   (void) note;
-  Grob *a
-    = make_grob_from_properties (trans,
-                                ly_symbol2scm ("AccidentalSuggestion"),
-                                note_head->self_scm (),
-                                "AccidentalSuggestion");
+  Grob *a = trans->make_item ("AccidentalSuggestion", note_head->self_scm ());
 
   Side_position_interface::add_support (a, note_head);
   if (Grob *stem = unsmob_grob (a->get_object ("stem")))
index afe470251ccac043c57940e159483a4be3de383c..4f1e83d4fa8f742c0566b588a2e2cf80fdf2c27c 100644 (file)
@@ -323,7 +323,7 @@ Align_interface::add_element (Grob *me, Grob *element)
   SCM sym = axis_offset_symbol (a);
   SCM proc = axis_parent_positioning (a);
     
-  element->internal_set_property (sym, proc);
+  element->set_property (sym, proc);
   Axis_group_interface::add_element (me, element);
 }
 
index d74bf880e6d1f1a2e3c495adb180a98a01e52069..02e900164b642b1ba8f358994b7e9884edafa696 100644 (file)
@@ -34,10 +34,10 @@ Axis_group_interface::add_element (Grob *me, Grob *e)
       if (!e->get_parent (a))
        e->set_parent (me, a);
 
-      e->internal_set_object ((a == X_AXIS)
-                             ? ly_symbol2scm ("axis-group-parent-X")
-                             : ly_symbol2scm ("axis-group-parent-Y"),
-                             me->self_scm ());
+      e->set_object ((a == X_AXIS)
+                    ? ly_symbol2scm ("axis-group-parent-X")
+                    : ly_symbol2scm ("axis-group-parent-Y"),
+                    me->self_scm ());
     }
 
   /* must be ordered, because Align_interface also uses
index e6a7935c568c5283aeed26671cf39a7b1ec39c73..461ead59caec1cd409e34fe7df959ae5079abac9 100644 (file)
@@ -82,10 +82,7 @@ Break_align_engraver::acknowledge_break_aligned (Grob_info inf)
          /*
            Make left edge appear to come from same context as clef/bar-line etc.
          */
-         left_edge_ = make_item_from_properties (random_source,
-                                                 ly_symbol2scm ("LeftEdge"),
-                                                 SCM_EOL,
-                                                 "LeftEdge");
+         left_edge_ = random_source->make_item ("LeftEdge", SCM_EOL);
          add_to_group (left_edge_->get_property ("break-align-symbol"),
                        left_edge_);
        }
index 0c1e996580e7ca3826b8371ab72c489daf2b1079..b01f2421206f49824c1b0a348c075f63e0f21994 100644 (file)
@@ -397,7 +397,7 @@ Spanner::fast_substitute_grob_array (SCM sym,
       if (!unsmob_grob_array (newval))
        {
          newval = Grob_array::make_array ();
-         sc->internal_set_object (sym, newval);
+         sc->set_object (sym, newval);
        }
 
       Grob_array *new_array = unsmob_grob_array (newval);
@@ -500,14 +500,14 @@ Spanner::substitute_one_mutable_property (SCM sym,
            if (!unsmob_grob_array (newval))
              {
                newval = Grob_array::make_array ();
-               sc->internal_set_object (sym, newval);
+               sc->set_object (sym, newval);
              }
            substitute_grob_array (grob_array, unsmob_grob_array (newval));
          }
        else
          {
            SCM newval = do_break_substitution (val);
-           sc->internal_set_object (sym, newval);
+           sc->set_object (sym, newval);
          }
       }
 }
index 502fc92f11a3c3ef8902999eb7ad9022744c3825..851bbe0a413a94f3c1fd6590293f1b974f3b79e4 100644 (file)
@@ -118,7 +118,7 @@ execute_general_pushpop_property (Context *context,
        {
          SCM base = updated_grob_properties (context, context_property);
          current_context_val = scm_cons (base, base);
-         context->internal_set_property (context_property, current_context_val);
+         context->set_property (context_property, current_context_val);
        }
 
       if (!scm_is_pair (current_context_val))
@@ -180,7 +180,7 @@ execute_general_pushpop_property (Context *context,
       if (new_alist == daddy)
        context->unset_property (context_property);
       else
-       context->internal_set_property (context_property, scm_cons (new_alist, daddy));
+       context->set_property (context_property, scm_cons (new_alist, daddy));
     }
 }
 
@@ -224,7 +224,7 @@ apply_property_operations (Context *tg, SCM pre_init_ops)
          execute_general_pushpop_property (tg, context_prop, grob_prop_path, val);
        }
       else if (type == ly_symbol2scm ("assign"))
-       tg->internal_set_property (scm_car (entry), scm_cadr (entry));
+       tg->set_property (scm_car (entry), scm_cadr (entry));
     }
 }
 
@@ -274,51 +274,3 @@ updated_grob_properties (Context *tg, SCM sym)
       return copy;
     }
 }
-
-Grob *
-make_grob_from_properties (Engraver *tr, SCM symbol, SCM cause, char const *name)
-{
-  Context *context = tr->context ();
-
-  SCM props = updated_grob_properties (context, symbol);
-
-  Object_key const *key = context->get_grob_key (name);
-  Grob *grob = 0;
-
-  SCM handle = scm_sloppy_assq (ly_symbol2scm ("meta"), props);
-  SCM klass = scm_cdr (scm_sloppy_assq (ly_symbol2scm ("class"), scm_cdr (handle)));
-
-  if (klass == ly_symbol2scm ("Item"))
-    grob = new Item (props, key);
-  else if (klass == ly_symbol2scm ("Spanner"))
-    grob = new Spanner (props, key);
-  else if (klass == ly_symbol2scm ("Paper_column"))
-    grob = new Paper_column (props, key);
-
-  assert (grob);
-  dynamic_cast<Engraver *> (tr)->announce_grob (grob, cause);
-
-  return grob;
-}
-
-Item *
-make_item_from_properties (Engraver *tr, SCM x, SCM cause, char const *name)
-{
-  Item *it = dynamic_cast<Item *> (make_grob_from_properties (tr, x, cause, name));
-  assert (it);
-  return it;
-}
-
-Paper_column *
-make_paper_column_from_properties (Engraver *tr, SCM x, char const *name)
-{
-  return dynamic_cast<Paper_column *> (make_grob_from_properties (tr, x, SCM_EOL, name));
-}
-
-Spanner *
-make_spanner_from_properties (Engraver *tr, SCM x, SCM cause, char const *name)
-{
-  Spanner *sp = dynamic_cast<Spanner *> (make_grob_from_properties (tr, x, cause, name));
-  assert (sp);
-  return sp;
-}
index 92240a9b1d8dc1636d4cce9e89538eeda7a6ce95..9827c8bd417161bb65539c9ec46b249a35598e5b 100644 (file)
@@ -84,7 +84,7 @@ LY_DEFINE (ly_context_set_property, "ly:context-set-property!",
   SCM_ASSERT_TYPE (tr, context, SCM_ARG1, __FUNCTION__, "Context");
   SCM_ASSERT_TYPE (scm_is_symbol (name), name, SCM_ARG2, __FUNCTION__, "symbol");
 
-  tr->internal_set_property (name, val);
+  tr->set_property (name, val);
 
   return SCM_UNSPECIFIED;
 }
index d9c5f88129e9d746072252638fbb895c31e290f7..d8e5b7bfba32b341f2523cff06350e356d22cc5c 100644 (file)
@@ -238,7 +238,7 @@ Context::set_property_from_event (SCM sev)
       if (val != SCM_EOL)
        ok = type_check_assignment (sym, val, ly_symbol2scm ("translation-type?"));
       if (ok)
-       internal_set_property (sym, val);
+       set_property (sym, val);
     }
 }
 
@@ -444,7 +444,7 @@ Context::internal_send_stream_event (SCM type, Input *origin, SCM props[])
   Stream_event *e = new Stream_event (type, origin);
   for (int i = 0; props[i]; i += 2)
     {
-      e->internal_set_property (props[i], props[i+1]);
+      e->set_property (props[i], props[i+1]);
     }
   event_source_->broadcast (e);
   e->unprotect ();
@@ -469,11 +469,14 @@ Context::add_alias (SCM sym)
 }
 
 void
-Context::internal_set_property (SCM sym, SCM val)
-{
 #ifndef NDEBUG
+Context::internal_set_property (SCM sym, SCM val, char const *file, int line, char const *fun)
+{
   if (do_internal_type_checking_global)
     assert (type_check_assignment (sym, val, ly_symbol2scm ("translation-type?")));
+#else
+Context::internal_set_property (SCM sym, SCM val)
+{
 #endif
 
   properties_dict ()->set (sym, val);
@@ -723,7 +726,7 @@ measure_position (Context const *context)
 void
 set_context_property_on_children (Context *trans, SCM sym, SCM val)
 {
-  trans->internal_set_property (sym, ly_deep_copy (val));
+  trans->set_property (sym, ly_deep_copy (val));
   for (SCM p = trans->children_contexts (); scm_is_pair (p); p = scm_cdr (p))
     {
       Context *trg = unsmob_context (scm_car (p));
index cf2eebbe9b5c4a65515ba6a1fd3974ea656659a3..2453188fff76d573dc0584b024b039def46dacd8 100644 (file)
@@ -9,9 +9,11 @@
 #include "engraver.hh"
 
 #include "context.hh"
+#include "international.hh"
 #include "item.hh"
 #include "lilypond-key.hh"
 #include "music.hh"
+#include "paper-column.hh"
 #include "score-engraver.hh"
 #include "spanner.hh"
 #include "stream-event.hh"
@@ -86,6 +88,78 @@ Engraver::Engraver ()
 {
 }
 
+#ifndef NDEBUG
+static SCM creation_callback = SCM_EOL;
+LY_DEFINE (ly_set_grob_creation_callback, "ly:set-grob-creation-callback",
+          1, 0, 0, (SCM cb),
+          "Specify a procedure that will be called every time a new grob "
+          "is created. The callback will receive as arguments the grob "
+          "that was created, the name of the C++ source file that caused "
+          "the grob to be created and the corresponding line number in the "
+          "C++ source file.")
+{
+  if (!ly_is_procedure (cb))
+    warning (_ ("not setting creation callback: not a procedure"));
+  else
+    creation_callback = cb;
+
+  return SCM_EOL;
+}
+#endif
+
+Grob *
+Engraver::internal_make_grob (SCM symbol, SCM cause, char const *name, char const *file, int line, char const *fun)
+{
+  SCM props = updated_grob_properties (context (), symbol);
+
+  Object_key const *key = context ()->get_grob_key (name);
+  Grob *grob = 0;
+
+  SCM handle = scm_sloppy_assq (ly_symbol2scm ("meta"), props);
+  SCM klass = scm_cdr (scm_sloppy_assq (ly_symbol2scm ("class"), scm_cdr (handle)));
+
+  if (klass == ly_symbol2scm ("Item"))
+    grob = new Item (props, key);
+  else if (klass == ly_symbol2scm ("Spanner"))
+    grob = new Spanner (props, key);
+  else if (klass == ly_symbol2scm ("Paper_column"))
+    grob = new Paper_column (props, key);
+
+  assert (grob);
+  announce_grob (grob, cause);
+
+#ifndef NDEBUG
+  if (ly_is_procedure (creation_callback))
+    scm_apply_0 (creation_callback,
+                scm_list_n (grob->self_scm (), scm_makfrom0str (file),
+                            scm_from_int (line), scm_makfrom0str (fun), SCM_UNDEFINED));
+#endif
+
+  return grob;
+}
+
+Item *
+Engraver::internal_make_item (SCM x, SCM cause, char const *name, char const *file, int line, char const *fun)
+{
+  Item *it = dynamic_cast<Item *> (internal_make_grob (x, cause, name, file, line, fun));
+  assert (it);
+  return it;
+}
+
+Paper_column *
+Engraver::internal_make_column (SCM x, char const *name, char const *file, int line, char const *fun)
+{
+  return dynamic_cast<Paper_column *> (internal_make_grob (x, SCM_EOL, name, file, line, fun));
+}
+
+Spanner *
+Engraver::internal_make_spanner (SCM x, SCM cause, char const *name, char const *file, int line, char const *fun)
+{
+  Spanner *sp = dynamic_cast<Spanner *> (internal_make_grob (x, cause, name, file, line, fun));
+  assert (sp);
+  return sp;
+}
+
 #include "translator.icc"
 
 ADD_TRANSLATOR (Engraver,
index 81bd393adb98de880c1a05e26a77dc16b9fe30dc..9dddc0616f85a11241992a4e39d1a4967253e910 100644 (file)
@@ -37,8 +37,7 @@ add_offset_callback (Grob *g, SCM proc, Axis a)
       && !ly_is_procedure (data)
       && !is_simple_closure (data))
     {
-      g->internal_set_property (axis_offset_symbol (a),
-                               proc);
+      g->set_property (axis_offset_symbol (a), proc);
       return ;
     }
 
@@ -53,8 +52,7 @@ add_offset_callback (Grob *g, SCM proc, Axis a)
     proc = ly_make_simple_closure (scm_list_1 (proc));
   
   SCM expr = scm_list_3 (plus, proc, data);
-  g->internal_set_property (axis_offset_symbol (a),
-                           ly_make_simple_closure (expr));
+  g->set_property (axis_offset_symbol (a), ly_make_simple_closure (expr));
 }
 
 
@@ -81,9 +79,9 @@ chain_offset_callback (Grob *g, SCM proc, Axis a)
     data = scm_from_int (0);
   
   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 (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)));
 }
index cfa21832d8f03137ddab67cc1a3256996a70c9ee..3924f4ece9125b9c8935c194d890b6f0d40264d5 100644 (file)
 #include "paper-score.hh"
 #include "output-def.hh"
 #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"
+
+#ifndef NDEBUG
+static SCM modification_callback = SCM_EOL;
+
+LY_DEFINE (ly_set_grob_modification_callback, "ly:set-grob-modification-callback",
+          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 property to be changed and "
+          "the new value for the property.")
+{
+  if (!ly_is_procedure (cb))
+    warning (_ ("not setting modification callback: not a procedure"));
+  else
+    modification_callback = cb;
+  return SCM_EOL;
+}
+#endif
 
 SCM
 Grob::get_property_alist_chain (SCM def) const
@@ -31,9 +53,9 @@ Grob::get_property_alist_chain (SCM def) const
 extern void check_interfaces_for_property (Grob const *me, SCM sym);
 
 void
-Grob::internal_set_property (SCM sym, SCM v)
-{
 #ifndef NDEBUG
+Grob::internal_set_property (SCM sym, SCM v, char const *file, int line, char const *fun)
+{
   SCM grob_p = ly_lily_module_constant ("ly:grob?");
   SCM grob_list_p = ly_lily_module_constant ("grob-list?");
   SCM type = scm_object_property (sym, ly_symbol2scm ("backend-type?"));
@@ -45,6 +67,9 @@ Grob::internal_set_property (SCM sym, SCM v)
       scm_display (scm_list_2 (sym, type), scm_current_output_port ());
       assert (0);
     }
+#else
+Grob::internal_set_property (SCM sym, SCM v)
+{
 #endif
 
   /* Perhaps we simply do the assq_set, but what the heck. */
@@ -61,6 +86,16 @@ Grob::internal_set_property (SCM sym, SCM v)
       check_interfaces_for_property (this, sym);
     }
 
+#ifndef NDEBUG
+  if (ly_is_procedure (modification_callback))
+      scm_apply_0 (modification_callback,
+                  scm_list_n (self_scm (),
+                              scm_makfrom0str (file),
+                              scm_from_int (line),
+                              scm_makfrom0str (fun),
+                              sym, v, SCM_UNDEFINED));
+#endif
+
   mutable_property_alist_ = scm_assq_set_x (mutable_property_alist_, sym, v);
 }
 
@@ -155,7 +190,7 @@ Grob::try_callback (SCM sym, SCM proc)
        mutable_property_alist_ = scm_assq_remove_x (mutable_property_alist_, marker);
     }
   else
-    internal_set_property (sym, value);
+    set_property (sym, value);
          
   return value;
 }
@@ -171,7 +206,7 @@ Grob::internal_set_object (SCM s, SCM v)
 }
 
 void
-Grob::del_property (SCM sym)
+Grob::internal_del_property (SCM sym)
 {
   mutable_property_alist_ = scm_assq_remove_x (mutable_property_alist_, sym);
 }
index bca86f5a76f64cf358eb96055d2d8ea10aba159e..0c56e1fd1324c8524abbcdf0850f35f0ab182101 100644 (file)
@@ -42,7 +42,7 @@ LY_DEFINE (ly_grob_set_property_x, "ly:grob-set-property!",
       && !type_check_assignment (sym, val, ly_symbol2scm ("backend-type?")))
     error ("typecheck failed");
 
-  sc->internal_set_property (sym, val);
+  sc->set_property (sym, val);
   return SCM_UNSPECIFIED;
 }
 
index 6be715ce3de1e037b306ca243b68da27e600146d..fd3c75b3f0f5daa28ca22def92188c1bcc8bf319 100644 (file)
@@ -87,10 +87,15 @@ public:
   /* properties:  */
   SCM internal_get_property (SCM name_sym) const;
   SCM properties_as_alist () const;
-  void internal_set_property (SCM var_sym, SCM value);
   Context *where_defined (SCM name_sym, SCM *value) const;
   void unset_property (SCM var_sym);
 
+#ifndef NDEBUG
+  void internal_set_property (SCM var_sym, SCM value, char const *file, int line, char const *fun);
+#else
+  void internal_set_property (SCM var_sym, SCM value);
+#endif
+
   Context *create_context (Context_def *, string, SCM);
   DECLARE_LISTENER (create_context_from_event);
   DECLARE_LISTENER (acknowledge_infant);
index abbeb2eec9ad99500b94e577928b20b48f0f161f..493c9c98d870b70361c96d5364f716ed55d63434 100644 (file)
@@ -18,6 +18,8 @@
 */
 class Engraver : public Translator
 {
+  Grob *internal_make_grob (SCM sym, SCM cause, char const *name,
+                           char const *f, int l, char const *fun);
 
   friend class Engraver_group;
 protected:
@@ -39,18 +41,22 @@ public:
   void announce_grob (Grob *, SCM cause);
   void announce_end_grob (Grob *, SCM cause);
 
+  Item *internal_make_item (SCM sym, SCM cause, char const *name,
+                           char const *f, int l, char const *fun);
+  Spanner *internal_make_spanner (SCM sym, SCM cause, char const *name,
+                                 char const *f, int l, char const *fun);
+  Paper_column *internal_make_column (SCM sym, char const *name,
+                                     char const *f, int l, char const *fun);
+
   /**
      override other ctor
   */
   TRANSLATOR_DECLARATIONS (Engraver);
 };
 
-#define make_item(x, cause) make_item_from_properties (this, ly_symbol2scm (x), cause, x)
-#define make_spanner(x, cause) make_spanner_from_properties (this, ly_symbol2scm (x), cause, x)
-#define make_paper_column(x) make_paper_column_from_properties (this, ly_symbol2scm (x), x)
-Grob *make_grob_from_properties (Engraver *tr, SCM symbol, SCM cause, char const *name);
-Item *make_item_from_properties (Engraver *tg, SCM x, SCM cause, char const *name);
-Spanner *make_spanner_from_properties (Engraver *tg, SCM x, SCM cause, char const *name);
-Paper_column *make_paper_column_from_properties (Engraver *tg, SCM x, char const *name);
+#define make_item(x, cause) internal_make_item (ly_symbol2scm (x), cause, x, __FILE__, __LINE__, __FUNCTION__)
+#define make_spanner(x, cause) internal_make_spanner (ly_symbol2scm (x), cause, x, __FILE__, __LINE__, __FUNCTION__)
+#define make_paper_column(x) internal_make_column (ly_symbol2scm (x), x, __FILE__, __LINE__, __FUNCTION__)
+
 
 #endif // ENGRAVER_HH
index e2bc0157cccbbff9902473e6234303af52bfb1cf..eee95e9b98bc0b2ca35c3a021235c6dcc7c91cbc 100644 (file)
@@ -80,9 +80,14 @@ public:
   SCM internal_get_property (SCM symbol) const;
   SCM get_property_data (SCM symbol) const;
   SCM internal_get_object (SCM symbol) const;
-  void del_property (SCM symbol); 
-  void internal_set_property (SCM sym, SCM val);
   void internal_set_object (SCM sym, SCM val);
+  void internal_del_property (SCM symbol);
+
+#ifndef NDEBUG
+  void internal_set_property (SCM sym, SCM val, char const *file, int line, char const *fun);
+#else
+  void internal_set_property (SCM sym, SCM val);
+#endif
 
   /* messages */  
   void warning (string) const;
@@ -146,5 +151,4 @@ void chain_offset_callback (Grob *g, SCM proc, Axis a);
 SCM axis_offset_symbol (Axis a);
 SCM axis_parent_positioning (Axis a);
 
-
 #endif /* GROB_HH */
index ef0db4747900b271fe9c362d06eeefe9bdbbf020..8374b0e247a76ecc8dc076283352026c7036c4da 100644 (file)
 
 #ifdef CACHE_SYMBOLS
 
+/* this lets us "overload" macros such as get_property to take
+   symbols as well as strings */
+inline SCM
+scm_or_str2symbol (char const *c) { return scm_str2symbol (c); }
+
+inline SCM
+scm_or_str2symbol (SCM s) { return s; }
+
 /* Using this trick we cache the value of scm_str2symbol ("fooo") where
    "fooo" is a constant string. This is done at the cost of one static
    variable per ly_symbol2scm() use, and one boolean evaluation for
     if (__builtin_constant_p ((x)))                                    \
       {                                                                        \
        if (!cached)                                                    \
-         value = cached = scm_gc_protect_object (scm_str2symbol ((x))); \
+         value = cached = scm_gc_protect_object (scm_or_str2symbol (x)); \
       }                                                                        \
     else                                                               \
-      value = scm_str2symbol ((char *) (x));                           \
+      value = scm_or_str2symbol (x);                                   \
     value;                                                             \
   })
 #else
@@ -150,7 +158,13 @@ ly_add_function_documentation (SCM proc, char const *fname,
 
 #define get_property(x) internal_get_property (ly_symbol2scm (x))
 #define get_object(x) internal_get_object (ly_symbol2scm (x))
-#define set_property(x, y) internal_set_property (ly_symbol2scm (x), y)
 #define set_object(x, y) internal_set_object (ly_symbol2scm (x), y)
+#define del_property(x) internal_del_property (ly_symbol2scm (x))
+
+#ifndef NDEBUG
+#define set_property(x, y) internal_set_property (ly_symbol2scm (x), y, __FILE__, __LINE__, __FUNCTION__)
+#else
+#define set_property(x, y) internal_set_property (ly_symbol2scm (x), y)
+#endif
 
 #endif /* LILY_GUILE_MACROS_HH */
index 141aba49b396ddc502790972ea544dadd36ae26a..0b82c4629eb68912e2847366028d004e5c1eae91 100644 (file)
@@ -40,7 +40,12 @@ public:
   SCM type () const { return type_; }
   SCM get_property_alist (bool mutble) const;
   SCM internal_get_property (SCM sym) const;
+
+#ifndef NDEBUG
+  void internal_set_property (SCM sym, SCM val, const char *file, int line, char const *fun);
+#else
   void internal_set_property (SCM sym, SCM val);
+#endif
 };
 DECLARE_UNSMOB(Prob,prob);
 SCM ly_prob_set_property_x (SCM system, SCM sym, SCM value);
index 53d332427eeccfdfa33bf2e4ca238a35a5fb6fab..b9ef4d8dce34b774a66297d5cee92b48eaa73c9a 100644 (file)
@@ -40,10 +40,7 @@ Parenthesis_engraver::acknowledge_grob (Grob_info info)
          if (Item *victim = dynamic_cast<Item*> (info.grob ()))
            {
              Engraver *eng = dynamic_cast<Engraver*> (info.origin_translator ());
-             Item *paren = make_item_from_properties (eng,
-                                                      ly_symbol2scm ("ParenthesesItem"),
-                                                      victim->self_scm (),
-                                                      "ParenthesesItem");
+             Item *paren = eng->make_item ("ParenthesesItem", victim->self_scm ());
 
              Pointer_group_interface::add_grob (paren, ly_symbol2scm ("elements"), victim);
              
index 3f06738a64b0d7beaba98106a93d753cb529e87f..63f38ae6b173119e5d46ea8380d9e1911734fc99 100644 (file)
@@ -2471,7 +2471,7 @@ void
 set_music_properties (Music *p, SCM a)
 {
   for (SCM k = a; scm_is_pair (k); k = scm_cdr (k))
-       p->internal_set_property (scm_caar (k), scm_cdar (k));
+       p->set_property (scm_caar (k), scm_cdar (k));
 }
 
 
index 1ab1d02c6e8f73d8d36924d1dcf8d3cb2091c21b..2d58941b726405ec292f489a9bdecac6c4da1c69 100644 (file)
@@ -42,7 +42,7 @@ Pointer_group_interface::get_grob_array (Grob *me, SCM sym)
     {
       scm_arr = Grob_array::make_array ();
       arr = unsmob_grob_array (scm_arr);
-      me->internal_set_object (sym, scm_arr);
+      me->set_object (sym, scm_arr);
     }
   return arr;
 }
index ceadabdd69241283b98549d2c269a3e89e302aec..bfa355d9a2a616455fe805cb4d2b33223f889347 100644 (file)
@@ -16,7 +16,7 @@ LY_DEFINE (ly_prob_set_property_x, "ly:prob-set-property!",
   SCM_ASSERT_TYPE (ps, obj, SCM_ARG1, __FUNCTION__, "Prob");
   SCM_ASSERT_TYPE (scm_is_symbol (sym), sym, SCM_ARG2, __FUNCTION__, "symbol");
 
-  ps->internal_set_property (sym, value);
+  ps->set_property (sym, value);
   return SCM_UNSPECIFIED;
 }
 
@@ -70,7 +70,7 @@ LY_DEFINE (ly_make_prob, "ly:make-prob",
       SCM sym = scm_car (s);
       SCM val = scm_cadr (s);
 
-      pr->internal_set_property (sym, val);
+      pr->set_property (sym, val);
     }
   
   return pr->unprotect ();
index 2640bdf87094076079449ee50fe820d3169f7d2e..eecd1a4446878c768f7c4c07f16ef3037f7b4764 100644 (file)
@@ -99,7 +99,11 @@ Prob::internal_get_property (SCM sym) const
 }
 
 void
-Prob::internal_set_property (SCM sym, SCM val) 
+#ifndef NDEBUG
+Prob::internal_set_property (SCM sym, SCM val, char const *file, int line, char const *fun) 
+#else
+Prob::internal_set_property (SCM sym, SCM val)
+#endif
 {
   if (do_internal_type_checking_global)
     type_check_assignment (sym, val);
index f16bf4542aea921d9665dc6775b0d38a51c4e69e..e25405b7328dc84122f2f369f366fb166c379817 100644 (file)
@@ -81,7 +81,7 @@ copy_property (Grob *g, SCM sym, SCM alist)
     {
       SCM entry = scm_assoc (sym, alist);
       if (scm_is_pair (entry))
-       g->internal_set_property (sym, scm_cdr (entry));
+       g->set_property (sym, scm_cdr (entry));
     }
 }
 
@@ -133,7 +133,7 @@ make_script_from_event (Grob *p,  Context *tg,
       SCM preset = p->get_property_data (sym);
       if (val == SCM_EOL
          || scm_call_1 (type, preset) == SCM_BOOL_F)
-       p->internal_set_property (sym, val);
+       p->set_property (sym, val);
     }
 
   if (!priority_found)
index 503bdf265b5cbcae112ba6c3182d701eca7b36e3..c46b3d1db061f03f414beebf3410b8e71e966ec5 100644 (file)
@@ -65,7 +65,7 @@ Span_bar_engraver::stop_translation_timestep ()
       SCM vissym = ly_symbol2scm ("break-visibility");
       SCM vis = bars_[0]->internal_get_property (vissym);
       if (ly_is_equal (spanbar_->internal_get_property (vissym), vis))
-       spanbar_->internal_set_property (vissym, vis);
+       spanbar_->set_property (vissym, vis);
 
       spanbar_ = 0;
     }
index b03c1d20a4017f0adf8fb2eed1425c2645fe1dad..dd2151146d6d7cd724079d0f548126da61036f33 100644 (file)
@@ -76,8 +76,7 @@ void
 Bracket_nesting_group::create_grobs (Engraver *engraver, SCM default_type)
 {
   SCM type = scm_is_symbol (symbol_) ? symbol_ : default_type;
-  delimiter_ = make_spanner_from_properties (engraver, type,
-                                            SCM_EOL, ly_symbol2string (type).c_str ());
+  delimiter_ = engraver->make_spanner (ly_symbol2string (type).c_str (), SCM_EOL);
 
   for (vsize i = 0 ; i < children_.size (); i++)
     {
index fa5d9a9c1d9dc76c92c49fee9a982ea9663a4dcb..68852c8353cb867f48c8fb56f4c53d8ebd24da83 100644 (file)
@@ -70,7 +70,7 @@ flatten_number_pair_property (Grob *me,
     = robust_scm2drul (me->internal_get_property (sym), zero);
   pair[xdir] = 0.0;
   
-  me->internal_set_property (sym, ly_interval2scm (pair));
+  me->set_property (sym, ly_interval2scm (pair));
 }
 
 
index a851c5a8ef2a4aa7eef369f66a1f4870abc8d1e8..5fcf3981e4e5d5af2623fdb1bfc64e49d59fc8a0 100644 (file)
@@ -33,7 +33,7 @@ Tweak_engraver::acknowledge_grob (Grob_info info)
       for (SCM s = ev->get_property ("tweaks");
           scm_is_pair (s); s = scm_cdr (s))
        {
-         info.grob ()->internal_set_property (scm_caar (s), scm_cdar (s));
+         info.grob ()->set_property (scm_caar (s), scm_cdar (s));
        }
     }
 }
index 31f6295410f8cc5478850d88c0a6084776413105..1828dfdbca9b49d062752118c554abfc9cd7737d 100644 (file)
@@ -69,7 +69,7 @@ Volta_repeat_iterator::add_repeat_command (SCM what)
       && current_reps == SCM_EOL || scm_is_pair (current_reps))
     {
       current_reps = scm_cons (what, current_reps);
-      where->internal_set_property (reps, current_reps);
+      where->set_property (reps, current_reps);
     }
 }