1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
/*
This file is part of LilyPond, the GNU music typesetter.
Copyright (C) 2007--2015 Han-Wen Nienhuys <hanwen@lilypond.org>
LilyPond is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
LilyPond is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
*/
#include "spanner.hh"
#include "item.hh"
LY_DEFINE (ly_spanner_bound, "ly:spanner-bound",
2, 0, 0, (SCM spanner, SCM dir),
"Get one of the bounds of @var{spanner}. @var{dir} is @w{@code{-1}}"
" for left, and @code{1} for right.")
{
LY_ASSERT_SMOB (Spanner, spanner, 1);
LY_ASSERT_TYPE (is_direction, dir, 2);
Item *bound = unsmob<Spanner> (spanner)->get_bound (to_dir (dir));
return bound ? bound->self_scm () : SCM_EOL;
}
LY_DEFINE (ly_spanner_set_bound_x, "ly:spanner-set-bound!",
3, 0, 0, (SCM spanner, SCM dir, SCM item),
"Set grob @var{item} as bound in direction @var{dir} for"
" @var{spanner}.")
{
LY_ASSERT_SMOB (Spanner, spanner, 1);
LY_ASSERT_TYPE (is_direction, dir, 2);
LY_ASSERT_SMOB (Item, item, 3);
unsmob<Spanner> (spanner)->set_bound (to_dir (dir), unsmob<Item> (item));
return SCM_UNSPECIFIED;
}
/* TODO: maybe we should return a vector -- random access is more
logical for this list? */
LY_DEFINE (ly_spanner_broken_into, "ly:spanner-broken-into",
1, 0, 0, (SCM spanner),
"Return broken-into list for @var{spanner}.")
{
LY_ASSERT_TYPE (unsmob<Spanner>, spanner, 1);
Spanner *me = unsmob<Spanner> (spanner);
SCM s = SCM_EOL;
for (vsize i = me->broken_intos_.size (); i--;)
s = scm_cons (me->broken_intos_[i]->self_scm (), s);
return s;
}
LY_DEFINE (ly_spanner_p, "ly:spanner?",
1, 0, 0, (SCM g),
"Is @var{g} a spanner object?")
{
Grob *me = unsmob<Grob> (g);
bool b = dynamic_cast<Spanner *> (me);
return ly_bool2scm (b);
}
|