-/*
- group-interface.cc -- implement Pointer_group_interface
-
+/*
+ pointer-group-interface.cc -- implement Pointer_group_interface
+
source file of the GNU LilyPond music typesetter
-
- (c) 1999--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
-#include "group-interface.hh"
-#include "score-element.hh"
-/*
- UGH clean me .
- */
-Pointer_group_interface::Pointer_group_interface (Score_element * e)
-{
- elt_l_ = e;
- name_ = "elements";
-}
+ (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
+*/
-Pointer_group_interface::Pointer_group_interface (Score_element *e, String s)
-{
- elt_l_ =(Score_element*)e;
- name_ = s;
-}
+#include "pointer-group-interface.hh"
-/*
- duh.
- */
-bool
-Pointer_group_interface::has_interface ()
+#include "lily-proto.hh"
+#include "item.hh"
+#include "grob-array.hh"
+#include "grob.hh"
+
+int
+Pointer_group_interface::count (Grob *me, SCM sym)
{
- SCM el = elt_l_->get_elt_property (name_.ch_C());
+ Grob_array *arr = unsmob_grob_array (me->internal_get_object (sym));
+ return arr ? arr->size() : 0;
+}
- return el == SCM_EOL || gh_pair_p (el);
+void
+Pointer_group_interface::add_grob (Grob *me, SCM sym, SCM p)
+{
+ add_grob (me, sym, unsmob_grob (p));
}
void
-Pointer_group_interface::add_element (Score_element*p)
+Pointer_group_interface::add_grob (Grob *me, SCM sym, Grob *p)
{
- elt_l_->set_elt_property (name_.ch_C(),
- gh_cons (p->self_scm (),
- elt_l_->get_elt_property (name_.ch_C())));
+ SCM scm_arr = me->internal_get_object (sym);
+ Grob_array *arr = unsmob_grob_array (scm_arr);
+ if (!arr)
+ {
+ scm_arr = Grob_array::make_array ();
+ arr = unsmob_grob_array (scm_arr);
+ me->internal_set_object (sym, scm_arr);
+ }
+ arr->add (p);
}
+
+static Link_array<Grob> empty_array;
-int
-Pointer_group_interface::count ()
+Link_array<Grob> const &
+ly_scm2link_array (SCM x)
{
- return scm_ilength (elt_l_->get_elt_property (name_.ch_C()));
+ Grob_array *arr = unsmob_grob_array (x);
+ return arr ? arr->array () : empty_array;
}
+
+Link_array<Grob> const &
+internal_extract_grob_array (Grob const *elt, SCM symbol)
+{
+ return ly_scm2link_array (elt->internal_get_object (symbol));
+}
+Link_array<Item>
+internal_extract_item_array (Grob const *elt, SCM symbol)
+{
+ Grob_array *arr = unsmob_grob_array (elt->internal_get_object (symbol));
+ Link_array<Item> items;
+ for (int i = 0; arr && i < arr->size (); i++)
+ {
+ items.push (arr->item (i));
+ }
+
+ return items;
+}