Tidy music-functions-init.ly.
[lilypond/mpolesky.git] / lily / grob-array-scheme.cc
blob1c10f6488a9b9c74250b64fcdcd0192d5cfa26d5
1 /*
2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2005--2010 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"
22 #include "grob.hh"
24 LY_DEFINE (ly_grob_array_length, "ly:grob-array-length",
25 1, 0, 0,
26 (SCM grob_arr),
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 ());
36 LY_DEFINE (ly_grob_array_ref, "ly:grob-array-ref",
37 2, 0, 0,
38 (SCM grob_arr, SCM index),
39 "Retrieve the @var{index}th element of @var{grob-arr}.")
41 Grob_array *me = unsmob_grob_array (grob_arr);
42 LY_ASSERT_SMOB (Grob_array, grob_arr, 1);
43 LY_ASSERT_TYPE (scm_is_integer, index, 2);
45 vsize i = scm_to_unsigned (index);
46 if (i == VPOS || i >= me->size ())
47 scm_out_of_range (NULL, scm_from_unsigned (i));
49 return me->grob (i)->self_scm ();