]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/group-interface.cc
Handle unwritable midi file.
[lilypond.git] / lily / group-interface.cc
index 9bb660cb6cd37341bbed11d253ab931c42d185a9..9fbd329e7cf15aacabab9acdca993c4f0a81a57b 100644 (file)
@@ -1,60 +1,57 @@
-/*   
-  group-interface.cc --  implement Group_interface
-  
-  source file of the GNU LilyPond music typesetter
-  
-  (c) 1999--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-  
- */
-#include "group-interface.hh"
-#include "grob.hh"
-
-
 /*
-  This special add_thing routine is slightly more efficient than
+  group-interface.cc -- implement Group_interface
 
-    set_prop (name,cons (thing, get_prop (name)))
+  source file of the GNU LilyPond music typesetter
 
-  since it can reuse the handle returned by scm_assq().
+  (c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
-void
-Group_interface::add_thing (Grob*me, SCM sym, SCM thing)
-{
-  SCM handle = scm_sloppy_assq (sym, me->mutable_property_alist_);
-  if (handle != SCM_BOOL_F)
-    {
-      gh_set_cdr_x (handle, gh_cons (thing, gh_cdr (handle)));
-      
-    }
-  else
-    {
-      /*
-       There is no mutable prop yet, so create an entry, and put it in front of the
-       mutable prop list.
-      */
-      handle = scm_sloppy_assq (sym, me->immutable_property_alist_);
-      SCM tail = (handle != SCM_BOOL_F) ? gh_cdr(handle) : SCM_EOL;
-      me->mutable_property_alist_ = gh_cons (gh_cons (sym, gh_cons (thing, tail)),
-                                            me->mutable_property_alist_);
-    }
-}
+#include "group-interface.hh"
+#include "item.hh"
 
 void
-Group_interface::add_thing (Grob*me, String name, SCM thing)
+Group_interface::add_thing (Grob *me, SCM sym, SCM thing)
 {
-  add_thing (me, ly_symbol2scm (name.ch_C()), thing);
+  me->add_to_list_property (sym, thing);
 }
 
 int
-Group_interface::count (Grob *me, String name)
+Group_interface::count (Grob *me, SCM sym)
 {
-  return scm_ilength (me->get_grob_property (name.ch_C ()));
+  return scm_ilength (me->internal_get_property (sym));
 }
 
-
 void
-Pointer_group_interface::add_grob (Grob*me, SCM name, Grob*p) 
+Pointer_group_interface::add_grob (Grob *me, SCM name, Grob *p)
 {
   Group_interface::add_thing (me, name, p->self_scm ());
 }
+
+Link_array<Grob>
+extract_grob_array (Grob const *elt, SCM symbol)
+{
+  Link_array<Grob> arr;
+
+  for (SCM s = elt->internal_get_property (symbol); scm_is_pair (s); s = scm_cdr (s))
+    {
+      SCM e = scm_car (s);
+      arr.push (unsmob_grob (e));
+    }
+
+  arr.reverse ();
+  return arr;
+}
+
+Link_array<Item>
+extract_item_array (Grob const *elt, SCM symbol)
+{
+  Link_array<Item> arr;
+  for (SCM s = elt->internal_get_property (symbol); scm_is_pair (s); s = scm_cdr (s))
+    {
+      SCM e = scm_car (s);
+      arr.push (dynamic_cast<Item *> (unsmob_grob (e)));
+    }
+
+  arr.reverse ();
+  return arr;
+}