Update from Andrew: tweaks for cross-staff chords snippet.
[lilypond.git] / lily / grob-array-scheme.cc
blob49fac4c21ae76e5897de6815aecb30653821ba1a
1 /*
2 grob-array-scheme.cc -- implement Grob_array bindings.
4 source file of the GNU LilyPond music typesetter
6 (c) 2005--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
8 */
10 #include "grob-array.hh"
11 #include "grob.hh"
13 LY_DEFINE (ly_grob_array_length, "ly:grob-array-length",
14 1, 0, 0,
15 (SCM grob_arr),
16 "Return the length of @var{grob-arr}.")
18 LY_ASSERT_SMOB (Grob_array, grob_arr, 1);
20 Grob_array *me = unsmob_grob_array (grob_arr);
21 return scm_from_int (me->size ());
25 LY_DEFINE (ly_grob_array_ref, "ly:grob-array-ref",
26 2, 0, 0,
27 (SCM grob_arr, SCM index),
28 "Retrieve the @var{index}th element of @var{grob-arr}.")
30 Grob_array *me = unsmob_grob_array (grob_arr);
31 LY_ASSERT_SMOB (Grob_array, grob_arr, 1);
32 LY_ASSERT_TYPE (scm_is_integer, index, 2);
34 vsize i = scm_to_unsigned (index);
35 if (i == VPOS || i >= me->size ())
36 scm_out_of_range (NULL, scm_from_unsigned (i));
38 return me->grob (i)->self_scm ();