From: Joe Neeman Date: Sat, 23 Sep 2006 22:51:56 +0000 (+0000) Subject: * lily/grob-property.cc: add scm debugging hooks into X-Git-Tag: cvs/HEAD~64 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=0c5bcc9f980e3dc40b53543a957bbf353d7c2308;p=lilypond.git * 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 --- diff --git a/ChangeLog b/ChangeLog index 6afd20305c..1b710a699f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,40 @@ +2006-09-24 Joe Neeman + * 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 * Documentation/user/programming-iterfaces.itely: fix diff --git a/lily/accidental-engraver.cc b/lily/accidental-engraver.cc index f6ea8e0e18..f1e0a270b7 100644 --- a/lily/accidental-engraver.cc +++ b/lily/accidental-engraver.cc @@ -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"))) diff --git a/lily/align-interface.cc b/lily/align-interface.cc index afe470251c..4f1e83d4fa 100644 --- a/lily/align-interface.cc +++ b/lily/align-interface.cc @@ -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); } diff --git a/lily/axis-group-interface.cc b/lily/axis-group-interface.cc index d74bf880e6..02e900164b 100644 --- a/lily/axis-group-interface.cc +++ b/lily/axis-group-interface.cc @@ -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 diff --git a/lily/break-align-engraver.cc b/lily/break-align-engraver.cc index e6a7935c56..461ead59ca 100644 --- a/lily/break-align-engraver.cc +++ b/lily/break-align-engraver.cc @@ -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_); } diff --git a/lily/break-substitution.cc b/lily/break-substitution.cc index 0c1e996580..b01f242120 100644 --- a/lily/break-substitution.cc +++ b/lily/break-substitution.cc @@ -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); } } } diff --git a/lily/context-property.cc b/lily/context-property.cc index 502fc92f11..851bbe0a41 100644 --- a/lily/context-property.cc +++ b/lily/context-property.cc @@ -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 (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 (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 (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 (make_grob_from_properties (tr, x, cause, name)); - assert (sp); - return sp; -} diff --git a/lily/context-scheme.cc b/lily/context-scheme.cc index 92240a9b1d..9827c8bd41 100644 --- a/lily/context-scheme.cc +++ b/lily/context-scheme.cc @@ -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; } diff --git a/lily/context.cc b/lily/context.cc index d9c5f88129..d8e5b7bfba 100644 --- a/lily/context.cc +++ b/lily/context.cc @@ -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)); diff --git a/lily/engraver.cc b/lily/engraver.cc index cf2eebbe9b..2453188fff 100644 --- a/lily/engraver.cc +++ b/lily/engraver.cc @@ -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 (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 (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 (internal_make_grob (x, cause, name, file, line, fun)); + assert (sp); + return sp; +} + #include "translator.icc" ADD_TRANSLATOR (Engraver, diff --git a/lily/grob-closure.cc b/lily/grob-closure.cc index 81bd393adb..9dddc0616f 100644 --- a/lily/grob-closure.cc +++ b/lily/grob-closure.cc @@ -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))); } diff --git a/lily/grob-property.cc b/lily/grob-property.cc index cfa21832d8..3924f4ece9 100644 --- a/lily/grob-property.cc +++ b/lily/grob-property.cc @@ -11,12 +11,34 @@ #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); } diff --git a/lily/grob-scheme.cc b/lily/grob-scheme.cc index bca86f5a76..0c56e1fd13 100644 --- a/lily/grob-scheme.cc +++ b/lily/grob-scheme.cc @@ -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; } diff --git a/lily/include/context.hh b/lily/include/context.hh index 6be715ce3d..fd3c75b3f0 100644 --- a/lily/include/context.hh +++ b/lily/include/context.hh @@ -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); diff --git a/lily/include/engraver.hh b/lily/include/engraver.hh index abbeb2eec9..493c9c98d8 100644 --- a/lily/include/engraver.hh +++ b/lily/include/engraver.hh @@ -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 diff --git a/lily/include/grob.hh b/lily/include/grob.hh index e2bc0157cc..eee95e9b98 100644 --- a/lily/include/grob.hh +++ b/lily/include/grob.hh @@ -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 */ diff --git a/lily/include/lily-guile-macros.hh b/lily/include/lily-guile-macros.hh index ef0db47479..8374b0e247 100644 --- a/lily/include/lily-guile-macros.hh +++ b/lily/include/lily-guile-macros.hh @@ -29,6 +29,14 @@ #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 @@ -43,10 +51,10 @@ 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 */ diff --git a/lily/include/prob.hh b/lily/include/prob.hh index 141aba49b3..0b82c4629e 100644 --- a/lily/include/prob.hh +++ b/lily/include/prob.hh @@ -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); diff --git a/lily/parenthesis-engraver.cc b/lily/parenthesis-engraver.cc index 53d332427e..b9ef4d8dce 100644 --- a/lily/parenthesis-engraver.cc +++ b/lily/parenthesis-engraver.cc @@ -40,10 +40,7 @@ Parenthesis_engraver::acknowledge_grob (Grob_info info) if (Item *victim = dynamic_cast (info.grob ())) { Engraver *eng = dynamic_cast (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); diff --git a/lily/parser.yy b/lily/parser.yy index 3f06738a64..63f38ae6b1 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -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)); } diff --git a/lily/pointer-group-interface.cc b/lily/pointer-group-interface.cc index 1ab1d02c6e..2d58941b72 100644 --- a/lily/pointer-group-interface.cc +++ b/lily/pointer-group-interface.cc @@ -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; } diff --git a/lily/prob-scheme.cc b/lily/prob-scheme.cc index ceadabdd69..bfa355d9a2 100644 --- a/lily/prob-scheme.cc +++ b/lily/prob-scheme.cc @@ -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 (); diff --git a/lily/prob.cc b/lily/prob.cc index 2640bdf870..eecd1a4446 100644 --- a/lily/prob.cc +++ b/lily/prob.cc @@ -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); diff --git a/lily/script-engraver.cc b/lily/script-engraver.cc index f16bf4542a..e25405b732 100644 --- a/lily/script-engraver.cc +++ b/lily/script-engraver.cc @@ -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) diff --git a/lily/span-bar-engraver.cc b/lily/span-bar-engraver.cc index 503bdf265b..c46b3d1db0 100644 --- a/lily/span-bar-engraver.cc +++ b/lily/span-bar-engraver.cc @@ -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; } diff --git a/lily/system-start-delimiter-engraver.cc b/lily/system-start-delimiter-engraver.cc index b03c1d20a4..dd2151146d 100644 --- a/lily/system-start-delimiter-engraver.cc +++ b/lily/system-start-delimiter-engraver.cc @@ -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++) { diff --git a/lily/tuplet-bracket.cc b/lily/tuplet-bracket.cc index fa5d9a9c1d..68852c8353 100644 --- a/lily/tuplet-bracket.cc +++ b/lily/tuplet-bracket.cc @@ -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)); } diff --git a/lily/tweak-engraver.cc b/lily/tweak-engraver.cc index a851c5a8ef..5fcf3981e4 100644 --- a/lily/tweak-engraver.cc +++ b/lily/tweak-engraver.cc @@ -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)); } } } diff --git a/lily/volta-repeat-iterator.cc b/lily/volta-repeat-iterator.cc index 31f6295410..1828dfdbca 100644 --- a/lily/volta-repeat-iterator.cc +++ b/lily/volta-repeat-iterator.cc @@ -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); } }