]> git.donarmstrong.com Git - lilypond.git/blob - lily/grob-array-scheme.cc
add vcs lines to debian/control
[lilypond.git] / lily / grob-array-scheme.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2005--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
6
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.
11
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.
16
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/>.
19 */
20
21 #include "grob-array.hh"
22 #include "grob.hh"
23
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}.")
28 {
29   LY_ASSERT_SMOB (Grob_array, grob_arr, 1);
30
31   Grob_array *me = unsmob_grob_array (grob_arr);
32   return  scm_from_int (me->size ());
33 }
34
35
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}.")
40 {
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);
44
45   vsize i = scm_to_uint (index);
46   if (i == VPOS || i >= me->size ())
47     scm_out_of_range (NULL, scm_from_unsigned_integer (i)); 
48   
49   return me->grob (i)->self_scm ();
50 }
51
52 LY_DEFINE (ly_grob_array_2_list, "ly:grob-array->list",
53            1, 0, 0,
54            (SCM grob_arr),
55            "Return the elements of @var{grob-arr} as a Scheme list.")
56 {
57   Grob_array *me = unsmob_grob_array (grob_arr);
58   LY_ASSERT_SMOB (Grob_array, grob_arr, 1);
59
60   return grob_array_to_list (me);
61 }