(readPostTable): ugh. Kludge: nglyphs in maxp
[lilypond.git] / lily / grob-property.cc
blob67401f226e881a1e19fccf28377aec6d8f309bd6
1 /*
2 Implement storage and manipulation of grob properties.
3 */
5 #include <cstring>
6 #include <math.h>
8 #include "main.hh"
9 #include "input-smob.hh"
10 #include "group-interface.hh"
11 #include "misc.hh"
12 #include "paper-score.hh"
13 #include "output-def.hh"
14 #include "spanner.hh"
15 #include "item.hh"
16 #include "misc.hh"
17 #include "item.hh"
19 SCM
20 Grob::get_property_alist_chain (SCM def) const
22 return scm_list_n (mutable_property_alist_,
23 immutable_property_alist_,
24 def,
25 SCM_UNDEFINED);
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 ().
35 void
36 Grob::add_to_list_property (SCM sym, SCM thing)
38 SCM handle
39 = scm_sloppy_assq (sym, mutable_property_alist_);
41 if (handle != SCM_BOOL_F)
43 scm_set_cdr_x (handle, scm_cons (thing, scm_cdr (handle)));
45 else
48 There is no mutable prop yet, so create an entry, and put it in front of the
49 mutable prop list.
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);
62 void
63 Grob::internal_set_property (SCM s, SCM v)
65 /* Perhaps we simply do the assq_set, but what the heck. */
66 if (!is_live ())
67 return;
69 if (do_internal_type_checking_global)
71 if (!type_check_assignment (s, v, ly_symbol2scm ("backend-type?")))
72 abort ();
73 check_interfaces_for_property (this, s);
76 mutable_property_alist_ = scm_assq_set_x (mutable_property_alist_, s, v);
79 SCM
80 Grob::internal_get_property (SCM sym) const
82 SCM s = scm_sloppy_assq (sym, mutable_property_alist_);
83 if (s != SCM_BOOL_F)
84 return scm_cdr (s);
86 s = scm_sloppy_assq (sym, immutable_property_alist_);
88 if (do_internal_type_checking_global && scm_is_pair (s))
90 if (!type_check_assignment (sym, scm_cdr (s),
91 ly_symbol2scm ("backend-type?")))
92 abort ();
94 check_interfaces_for_property (this, sym);
97 return (s == SCM_BOOL_F) ? SCM_EOL : scm_cdr (s);
100 void
101 Grob::substitute_mutable_properties (SCM crit, SCM orig)
103 set_break_subsititution (crit);
104 mutable_property_alist_ = substitute_mutable_property_alist (orig);
107 bool
108 Grob::is_live () const
110 return immutable_property_alist_ != SCM_EOL;