]> git.donarmstrong.com Git - lilypond.git/blob - lily/spring-smob.cc
dd5b22be1ce9d4b5b6c6f74ea0dd3cc6eef0cc79
[lilypond.git] / lily / spring-smob.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 1999--2014 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
6   LilyPond is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "spring.hh"
21 #include "warn.hh"
22
23
24
25
26 SCM
27 Spring::equal_p (SCM a, SCM b)
28 {
29   return a == b ? SCM_BOOL_T : SCM_BOOL_F;
30 }
31
32 LY_DEFINE (ly_make_spring, "ly:make-spring",
33            2, 0, 0, (SCM ideal, SCM min_dist),
34            "Make a spring.  @var{ideal} is the ideal distance of the"
35            " spring, and @var{min-dist} is the minimum distance.")
36 {
37   LY_ASSERT_TYPE (scm_is_number, ideal, 1);
38   LY_ASSERT_TYPE (scm_is_number, min_dist, 2);
39
40   Spring s (scm_to_double (ideal), scm_to_double (min_dist));
41
42   return s.smobbed_copy ();
43 }
44
45 LY_DEFINE (ly_spring_set_inverse_compress_strength_x, "ly:spring-set-inverse-compress-strength!",
46            2, 0, 0, (SCM spring, SCM strength),
47            "Set the inverse compress @var{strength} of @var{spring}.")
48 {
49   LY_ASSERT_SMOB (Spring, spring, 1);
50   LY_ASSERT_TYPE (scm_is_number, strength, 2);
51
52   Spring *s = Spring::unsmob (spring);
53   s->set_inverse_compress_strength (scm_to_double (strength));
54   return s->smobbed_copy ();
55 }
56
57 LY_DEFINE (ly_spring_set_inverse_stretch_strength_x, "ly:spring-set-inverse-stretch-strength!",
58            2, 0, 0, (SCM spring, SCM strength),
59            "Set the inverse stretch @var{strength} of @var{spring}.")
60 {
61   LY_ASSERT_SMOB (Spring, spring, 1);
62   LY_ASSERT_TYPE (scm_is_number, strength, 2);
63
64   Spring *s = Spring::unsmob (spring);
65   s->set_inverse_stretch_strength (scm_to_double (strength));
66   return s->smobbed_copy ();
67 }
68
69 const char Spring::type_p_name_[] = "ly:spring?";