2 Implement storage and manipulation of grob properties.
8 #include "input-smob.hh"
9 #include "pointer-group-interface.hh"
11 #include "paper-score.hh"
12 #include "output-def.hh"
17 #include "program-option.hh"
21 Grob::get_property_alist_chain (SCM def) const
23 return scm_list_n (mutable_property_alist_,
24 immutable_property_alist_,
30 This special add_thing routine is slightly more efficient than
32 set_prop (name, cons (thing, get_prop (name)))
34 since it can reuse the handle returned by scm_assq ().
38 Grob::add_to_list_property (SCM sym, SCM thing)
41 = scm_sloppy_assq (sym, mutable_property_alist_);
43 if (handle != SCM_BOOL_F)
44 scm_set_cdr_x (handle, scm_cons (thing, scm_cdr (handle)));
48 There is no mutable prop yet, so create an entry, and put it in front of the
51 handle = scm_sloppy_assq (sym, immutable_property_alist_);
52 SCM tail = (handle != SCM_BOOL_F) ? scm_cdr (handle) : SCM_EOL;
53 SCM val = scm_cons (thing, tail);
55 mutable_property_alist_ = scm_cons (scm_cons (sym, val),
56 mutable_property_alist_);
60 extern void check_interfaces_for_property (Grob const *me, SCM sym);
63 Grob::internal_set_property (SCM sym, SCM v)
66 SCM grob_p = ly_lily_module_constant ("ly:grob?");
67 SCM grob_list_p = ly_lily_module_constant ("grob-list?");
68 SCM type = scm_object_property (sym, ly_symbol2scm ("backend-type?"));
71 || type == grob_list_p
72 || (unsmob_grob (v) && ly_symbol2scm ("cause") != sym))
74 scm_display (scm_list_2 (sym, type), scm_current_output_port ());
79 /* Perhaps we simply do the assq_set, but what the heck. */
83 if (do_internal_type_checking_global)
85 if (!type_check_assignment (sym, v, ly_symbol2scm ("backend-type?")))
87 check_interfaces_for_property (this, sym);
90 mutable_property_alist_ = scm_assq_set_x (mutable_property_alist_, sym, v);
93 //#define PROFILE_PROPERTY_ACCESSES
97 Grob::internal_get_property (SCM sym) const
100 if (profile_property_accesses)
101 note_property_access (&grob_property_lookup_table, sym);
104 SCM s = scm_sloppy_assq (sym, mutable_property_alist_);
108 s = scm_sloppy_assq (sym, immutable_property_alist_);
110 if (do_internal_type_checking_global && scm_is_pair (s))
112 if (!type_check_assignment (sym, scm_cdr (s),
113 ly_symbol2scm ("backend-type?")))
116 check_interfaces_for_property (this, sym);
119 return (s == SCM_BOOL_F) ? SCM_EOL : scm_cdr (s);
123 Grob::internal_set_object (SCM s, SCM v)
125 /* Perhaps we simply do the assq_set, but what the heck. */
129 object_alist_ = scm_assq_set_x (object_alist_, s, v);
133 Grob::internal_get_object (SCM sym) const
135 #ifdef PROFILE_PROPERTY_ACCESSES
136 note_property_access (&grob_property_lookup_table, sym);
139 SCM s = scm_sloppy_assq (sym, object_alist_);
141 return (s == SCM_BOOL_F) ? SCM_EOL : scm_cdr (s);
145 Grob::substitute_object_links (SCM crit, SCM orig)
147 set_break_subsititution (crit);
148 object_alist_ = substitute_object_alist (orig, object_alist_);
152 Grob::is_live () const
154 return immutable_property_alist_ != SCM_EOL;