2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2005--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 LilyPond is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 LilyPond is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
21 #include "grob-array.hh"
24 LY_DEFINE (ly_grob_array_length, "ly:grob-array-length",
27 "Return the length of @var{grob-arr}.")
29 LY_ASSERT_SMOB (Grob_array, grob_arr, 1);
31 Grob_array *me = unsmob_grob_array (grob_arr);
32 return scm_from_int (me->size ());
35 LY_DEFINE (ly_grob_array_ref, "ly:grob-array-ref",
37 (SCM grob_arr, SCM index),
38 "Retrieve the @var{index}th element of @var{grob-arr}.")
40 Grob_array *me = unsmob_grob_array (grob_arr);
41 LY_ASSERT_SMOB (Grob_array, grob_arr, 1);
42 LY_ASSERT_TYPE (scm_is_integer, index, 2);
44 vsize i = scm_to_uint (index);
45 if (i == VPOS || i >= me->size ())
46 scm_out_of_range (NULL, scm_from_unsigned_integer (i));
48 return me->grob (i)->self_scm ();
51 LY_DEFINE (ly_grob_array_2_list, "ly:grob-array->list",
54 "Return the elements of @var{grob-arr} as a Scheme list.")
56 Grob_array *me = unsmob_grob_array (grob_arr);
57 LY_ASSERT_SMOB (Grob_array, grob_arr, 1);
59 return grob_array_to_list (me);