X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fspanner-scheme.cc;h=b364f48177cbd9b9af867e802be4b333eecf478a;hb=47db9a3883d726ca53e2133a3b2298f78dd6a32e;hp=e5a33e0c4b45976ffc7f50907c5a592b25872931;hpb=5837be11cf336e61e7134097f507ad47e9bd9e68;p=lilypond.git diff --git a/lily/spanner-scheme.cc b/lily/spanner-scheme.cc index e5a33e0c4b..b364f48177 100644 --- a/lily/spanner-scheme.cc +++ b/lily/spanner-scheme.cc @@ -1,34 +1,58 @@ -/* - spanner-scheme.cc -- implement Spanner bindings. - - source file of the GNU LilyPond music typesetter - - (c) 2007 Han-Wen Nienhuys - +/* + This file is part of LilyPond, the GNU music typesetter. + + Copyright (C) 2007--2015 Han-Wen Nienhuys + + + 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 . */ #include "spanner.hh" #include "item.hh" -LY_DEFINE (ly_spanner_get_bound, "ly:spanner-bound", - 2, 0, 0, (SCM slur, SCM dir), - "Get one of the bounds of @var{spanner}. @var{dir} is @code{-1} " - "for left, and @code{1} for right.") +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.") { - Spanner *sl = dynamic_cast (unsmob_grob (slur)); - SCM_ASSERT_TYPE (sl, slur, SCM_ARG1, __FUNCTION__, "spanner grob"); - SCM_ASSERT_TYPE (is_direction (dir), slur, SCM_ARG2, __FUNCTION__, "dir"); - return sl->get_bound (to_dir (dir))->self_scm (); + LY_ASSERT_SMOB (Spanner, spanner, 1); + LY_ASSERT_TYPE (is_direction, dir, 2); + Item *bound = Spanner::unsmob (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); + + Spanner::unsmob (spanner)->set_bound (to_dir (dir), Item::unsmob (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}.") + 1, 0, 0, (SCM spanner), + "Return broken-into list for @var{spanner}.") { - Spanner *me = dynamic_cast (unsmob_grob (spanner)); - SCM_ASSERT_TYPE (me, spanner, SCM_ARG1, __FUNCTION__, "spanner"); + LY_ASSERT_TYPE (Spanner::unsmob, spanner, 1); + Spanner *me = dynamic_cast (Grob::unsmob (spanner)); SCM s = SCM_EOL; for (vsize i = me->broken_intos_.size (); i--;) @@ -37,10 +61,10 @@ LY_DEFINE (ly_spanner_broken_into, "ly:spanner-broken-into", } LY_DEFINE (ly_spanner_p, "ly:spanner?", - 1, 0, 0, (SCM g), - "Is @var{g} a spanner object?") + 1, 0, 0, (SCM g), + "Is @var{g} a spanner object?") { - Grob *me = unsmob_grob (g); + Grob *me = Grob::unsmob (g); bool b = dynamic_cast (me); return ly_bool2scm (b);