* lexer-gcc-3.1.sh: Remove.
[lilypond/patrick.git] / lily / pointer-group-interface.cc
blob2d58941b726405ec292f489a9bdecac6c4da1c69
1 /*
2 pointer-group-interface.cc -- implement Pointer_group_interface
4 source file of the GNU LilyPond music typesetter
6 (c) 2005--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
9 #include "pointer-group-interface.hh"
11 #include "lily-proto.hh"
12 #include "item.hh"
13 #include "grob-array.hh"
14 #include "grob.hh"
16 int
17 Pointer_group_interface::count (Grob *me, SCM sym)
19 Grob_array *arr = unsmob_grob_array (me->internal_get_object (sym));
20 return arr ? arr->size () : 0;
23 void
24 Pointer_group_interface::add_grob (Grob *me, SCM sym, SCM p)
26 add_grob (me, sym, unsmob_grob (p));
29 void
30 Pointer_group_interface::set_ordered (Grob *me, SCM sym, bool ordered)
32 Grob_array *arr = get_grob_array (me, sym);
33 arr->set_ordered (ordered);
36 Grob_array *
37 Pointer_group_interface::get_grob_array (Grob *me, SCM sym)
39 SCM scm_arr = me->internal_get_object (sym);
40 Grob_array *arr = unsmob_grob_array (scm_arr);
41 if (!arr)
43 scm_arr = Grob_array::make_array ();
44 arr = unsmob_grob_array (scm_arr);
45 me->set_object (sym, scm_arr);
47 return arr;
50 void
51 Pointer_group_interface::add_grob (Grob *me, SCM sym, Grob *p)
53 Grob_array *arr = get_grob_array (me, sym);
54 arr->add (p);
57 void
58 Pointer_group_interface::add_unordered_grob (Grob *me, SCM sym, Grob *p)
60 Grob_array *arr = get_grob_array (me, sym);
61 arr->add (p);
62 arr->set_ordered (false);
65 static vector<Grob*> empty_array;
67 vector<Grob*> const &
68 ly_scm2link_array (SCM x)
70 Grob_array *arr = unsmob_grob_array (x);
71 return arr ? arr->array () : empty_array;
74 vector<Grob*> const &
75 internal_extract_grob_array (Grob const *elt, SCM symbol)
77 return ly_scm2link_array (elt->internal_get_object (symbol));
80 vector<Item*>
81 internal_extract_item_array (Grob const *elt, SCM symbol)
83 Grob_array *arr = unsmob_grob_array (elt->internal_get_object (symbol));
84 vector<Item*> items;
85 for (vsize i = 0; arr && i < arr->size (); i++)
86 items.push_back (arr->item (i));
88 return items;