2 Implement storage and manipulation of grob properties.
9 #include "input-smob.hh"
10 #include "pointer-group-interface.hh"
12 #include "paper-score.hh"
13 #include "output-def.hh"
20 Grob::get_property_alist_chain (SCM def) const
22 return scm_list_n (mutable_property_alist_,
23 immutable_property_alist_,
29 This special add_thing routine is slightly more efficient than
31 set_prop (name, cons (thing, get_prop (name)))
33 since it can reuse the handle returned by scm_assq ().
37 Grob::add_to_list_property (SCM sym, SCM thing)
40 = scm_sloppy_assq (sym, mutable_property_alist_);
42 if (handle != SCM_BOOL_F)
44 scm_set_cdr_x (handle, scm_cons (thing, scm_cdr (handle)));
49 There is no mutable prop yet, so create an entry, and put it in front of the
52 handle = scm_sloppy_assq (sym, immutable_property_alist_);
53 SCM tail = (handle != SCM_BOOL_F) ? scm_cdr (handle) : SCM_EOL;
54 SCM val = scm_cons (thing, tail);
56 mutable_property_alist_ = scm_cons (scm_cons (sym, val),
57 mutable_property_alist_);
63 extern void check_interfaces_for_property (Grob const *me, SCM sym);
66 Grob::internal_set_property (SCM sym, SCM v)
69 SCM grob_p = ly_lily_module_constant ("ly:grob?");
70 SCM grob_list_p = ly_lily_module_constant ("grob-list?");
71 SCM type = scm_object_property (sym, ly_symbol2scm ("backend-type?"));
74 || type == grob_list_p
75 || (unsmob_grob (v) && ly_symbol2scm ("cause") != sym))
77 scm_display (scm_list_2 (sym, type), scm_current_output_port());
82 /* Perhaps we simply do the assq_set, but what the heck. */
86 if (do_internal_type_checking_global)
88 if (!type_check_assignment (sym, v, ly_symbol2scm ("backend-type?")))
90 check_interfaces_for_property (this, sym);
93 mutable_property_alist_ = scm_assq_set_x (mutable_property_alist_, sym, v);
96 Protected_scm property_lookup_table;
97 LY_DEFINE(ly_property_lookup_stats, "ly:property-lookup-stats",
101 return (SCM) property_lookup_table;
106 Grob::internal_get_property (SCM sym) const
109 SCM grob_p = ly_lily_module_constant ("ly:grob?");
110 SCM grob_list_p = ly_lily_module_constant ("grob-list?");
111 SCM type = scm_object_property (sym, ly_symbol2scm ("backend-type?"));
114 || type == grob_list_p)
116 scm_display (scm_list_2 (sym, type), scm_current_output_port());
123 Statistics: which properties are looked up?
125 if (scm_hash_table_p (property_lookup_table) != SCM_BOOL_T)
127 property_lookup_table = scm_c_make_hash_table (259);
130 SCM hashhandle = scm_hashq_get_handle (property_lookup_table, sym);
131 if (hashhandle == SCM_BOOL_F)
133 scm_hashq_set_x (property_lookup_table, sym, scm_from_int (0));
134 hashhandle = scm_hashq_get_handle (property_lookup_table, sym);
137 scm_set_cdr_x (hashhandle, scm_from_int (scm_to_int (scm_cdr (hashhandle)) + 1));
141 SCM s = scm_sloppy_assq (sym, mutable_property_alist_);
145 s = scm_sloppy_assq (sym, immutable_property_alist_);
147 if (do_internal_type_checking_global && scm_is_pair (s))
149 if (!type_check_assignment (sym, scm_cdr (s),
150 ly_symbol2scm ("backend-type?")))
153 check_interfaces_for_property (this, sym);
156 return (s == SCM_BOOL_F) ? SCM_EOL : scm_cdr (s);
162 Grob::internal_set_object (SCM s, SCM v)
164 /* Perhaps we simply do the assq_set, but what the heck. */
168 object_alist_ = scm_assq_set_x (object_alist_, s, v);
172 Grob::internal_get_object (SCM sym) const
174 SCM s = scm_sloppy_assq (sym, object_alist_);
176 return (s == SCM_BOOL_F) ? SCM_EOL : scm_cdr (s);
180 Grob::substitute_object_links (SCM crit, SCM orig)
182 set_break_subsititution (crit);
183 object_alist_ = substitute_object_alist (orig, object_alist_);
187 Grob::is_live () const
189 return immutable_property_alist_ != SCM_EOL;