]> git.donarmstrong.com Git - lilypond.git/blob - lily/group-interface.cc
release: 1.5.24
[lilypond.git] / lily / group-interface.cc
1 /*   
2   group-interface.cc --  implement Group_interface
3   
4   source file of the GNU LilyPond music typesetter
5   
6   (c) 1999--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   
8  */
9 #include "group-interface.hh"
10 #include "grob.hh"
11
12
13 /*
14   This special add_thing routine is slightly more efficient than
15
16     set_prop (name,cons (thing, get_prop (name)))
17
18   since it can reuse the handle returned by scm_assq().
19 */
20
21 void
22 Group_interface::add_thing (Grob*me, SCM sym, SCM thing)
23 {
24   SCM handle = scm_sloppy_assq (sym, me->mutable_property_alist_);
25   if (handle != SCM_BOOL_F)
26     {
27       gh_set_cdr_x (handle, gh_cons (thing, gh_cdr (handle)));
28       
29     }
30   else
31     {
32       /*
33         There is no mutable prop yet, so create an entry, and put it in front of the
34         mutable prop list.
35       */
36       handle = scm_sloppy_assq (sym, me->immutable_property_alist_);
37       SCM tail = (handle != SCM_BOOL_F) ? gh_cdr(handle) : SCM_EOL;
38       me->mutable_property_alist_ = gh_cons (gh_cons (sym, gh_cons (thing, tail)),
39                                              me->mutable_property_alist_);
40     }
41 }
42
43 void
44 Group_interface::add_thing (Grob*me, String name, SCM thing)
45 {
46   add_thing (me, ly_symbol2scm (name.ch_C()), thing);
47 }
48
49 int
50 Group_interface::count (Grob *me, String name)
51 {
52   return scm_ilength (me->get_grob_property (name.ch_C ()));
53 }
54
55
56 void
57 Pointer_group_interface::add_element (Grob*me, SCM name, Grob*p) 
58 {
59   Group_interface::add_thing (me, name, p->self_scm ());
60 }