]> git.donarmstrong.com Git - lilypond.git/blob - lily/group-interface.cc
* flower
[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--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "group-interface.hh"
10 #include "item.hh"
11
12 void
13 Group_interface::add_thing (Grob *me, SCM sym, SCM thing)
14 {
15   me->add_to_list_property (sym, thing);
16 }
17
18 int
19 Group_interface::count (Grob *me, SCM sym)
20 {
21   return scm_ilength (me->internal_get_property (sym));
22 }
23
24 void
25 Pointer_group_interface::add_grob (Grob *me, SCM name, Grob *p)
26 {
27   Group_interface::add_thing (me, name, p->self_scm ());
28 }
29
30 Link_array<Grob>
31 extract_grob_array (Grob const *elt, SCM symbol)
32 {
33   Link_array<Grob> arr;
34
35   for (SCM s = elt->internal_get_property (symbol); scm_is_pair (s); s = scm_cdr (s))
36     {
37       SCM e = scm_car (s);
38       arr.push (unsmob_grob (e));
39     }
40
41   arr.reverse ();
42   return arr;
43 }
44
45 Link_array<Item>
46 extract_item_array (Grob const *elt, SCM symbol)
47 {
48   Link_array<Item> arr;
49   for (SCM s = elt->internal_get_property (symbol); scm_is_pair (s); s = scm_cdr (s))
50     {
51       SCM e = scm_car (s);
52       arr.push (dynamic_cast<Item *> (unsmob_grob (e)));
53     }
54
55   arr.reverse ();
56   return arr;
57 }