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>
10 #include "grob-array.hh"
13 LY_DEFINE (ly_grob_array_length
, "ly:grob-array-length",
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",
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 ();