X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=sidebyside;f=lily%2Fgrob-property.cc;h=bf1663e530e8527094dfc28b96af89bc3ea96cb5;hb=f1b93c0d52ef9229f8b58acc2ec8207ed50f5bee;hp=72353140f38e228d2c32674d998b7edd831cd538;hpb=664070d837cc4855091455892cb942cdcedeef0c;p=lilypond.git diff --git a/lily/grob-property.cc b/lily/grob-property.cc index 72353140f3..bf1663e530 100644 --- a/lily/grob-property.cc +++ b/lily/grob-property.cc @@ -1,22 +1,22 @@ /* Implement storage and manipulation of grob properties. - */ +*/ -#include +#include #include #include "main.hh" #include "input-smob.hh" -#include "group-interface.hh" +#include "pointer-group-interface.hh" #include "misc.hh" #include "paper-score.hh" #include "output-def.hh" -#include "grob.hh" #include "spanner.hh" #include "item.hh" #include "misc.hh" #include "item.hh" - +#include "program-option.hh" +#include "profile.hh" SCM Grob::get_property_alist_chain (SCM def) const @@ -27,26 +27,22 @@ Grob::get_property_alist_chain (SCM def) const SCM_UNDEFINED); } - - /* This special add_thing routine is slightly more efficient than - set_prop (name,cons (thing, get_prop (name))) + set_prop (name, cons (thing, get_prop (name))) since it can reuse the handle returned by scm_assq (). */ +// JUNKME. void -Grob::add_to_list_property (SCM sym, SCM thing) +Grob::add_to_list_property (SCM sym, SCM thing) { SCM handle - = scm_sloppy_assq (sym, mutable_property_alist_) - ; + = scm_sloppy_assq (sym, mutable_property_alist_); if (handle != SCM_BOOL_F) - { - scm_set_cdr_x (handle, scm_cons (thing, ly_cdr (handle))); - } + scm_set_cdr_x (handle, scm_cons (thing, scm_cdr (handle))); else { /* @@ -54,66 +50,107 @@ Grob::add_to_list_property (SCM sym, SCM thing) mutable prop list. */ handle = scm_sloppy_assq (sym, immutable_property_alist_); - SCM tail = (handle != SCM_BOOL_F) ? ly_cdr (handle) : SCM_EOL; + SCM tail = (handle != SCM_BOOL_F) ? scm_cdr (handle) : SCM_EOL; SCM val = scm_cons (thing, tail); mutable_property_alist_ = scm_cons (scm_cons (sym, val), - mutable_property_alist_); + mutable_property_alist_); } } - extern void check_interfaces_for_property (Grob const *me, SCM sym); void -Grob::internal_set_property (SCM s, SCM v) +Grob::internal_set_property (SCM sym, SCM v) { +#ifndef NDEBUG + 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?")); + + if (type == grob_p + || type == grob_list_p + || (unsmob_grob (v) && ly_symbol2scm ("cause") != sym)) + { + scm_display (scm_list_2 (sym, type), scm_current_output_port ()); + assert (0); + } +#endif + /* Perhaps we simply do the assq_set, but what the heck. */ - if (!live ()) + if (!is_live ()) return; - if (internal_type_checking_global_b) + if (do_internal_type_checking_global) { - if (!type_check_assignment (s, v, ly_symbol2scm ("backend-type?"))) + if (!type_check_assignment (sym, v, ly_symbol2scm ("backend-type?"))) abort (); - check_interfaces_for_property (this, s); + check_interfaces_for_property (this, sym); } - mutable_property_alist_ = scm_assq_set_x (mutable_property_alist_, s, v); + mutable_property_alist_ = scm_assq_set_x (mutable_property_alist_, sym, v); } +//#define PROFILE_PROPERTY_ACCESSES + SCM Grob::internal_get_property (SCM sym) const { +#ifndef NDEBUG + if (profile_property_accesses) + note_property_access (&grob_property_lookup_table, sym); +#endif + SCM s = scm_sloppy_assq (sym, mutable_property_alist_); if (s != SCM_BOOL_F) - return ly_cdr (s); + return scm_cdr (s); s = scm_sloppy_assq (sym, immutable_property_alist_); - - if (internal_type_checking_global_b && ly_c_pair_p (s)) + + if (do_internal_type_checking_global && scm_is_pair (s)) { - if (!type_check_assignment (sym, ly_cdr (s), + if (!type_check_assignment (sym, scm_cdr (s), ly_symbol2scm ("backend-type?"))) abort (); check_interfaces_for_property (this, sym); } - return (s == SCM_BOOL_F) ? SCM_EOL : ly_cdr (s); + return (s == SCM_BOOL_F) ? SCM_EOL : scm_cdr (s); } void -Grob::substitute_mutable_properties (SCM crit, SCM orig) +Grob::internal_set_object (SCM s, SCM v) { - set_break_subsititution (crit); - mutable_property_alist_ = substitute_mutable_property_alist (orig); + /* Perhaps we simply do the assq_set, but what the heck. */ + if (!is_live ()) + return; + + object_alist_ = scm_assq_set_x (object_alist_, s, v); +} + +SCM +Grob::internal_get_object (SCM sym) const +{ +#ifdef PROFILE_PROPERTY_ACCESSES + note_property_access (&grob_property_lookup_table, sym); +#endif + + SCM s = scm_sloppy_assq (sym, object_alist_); + + return (s == SCM_BOOL_F) ? SCM_EOL : scm_cdr (s); } +void +Grob::substitute_object_links (SCM crit, SCM orig) +{ + set_break_subsititution (crit); + object_alist_ = substitute_object_alist (orig, object_alist_); +} bool -Grob::live () const +Grob::is_live () const { return immutable_property_alist_ != SCM_EOL; }