2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2005--2010 Han-Wen Nienhuys <hanwen@xs4all.nl>
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.
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.
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/>.
22 LY_DEFINE (ly_prob_set_property_x
, "ly:prob-set-property!",
23 2, 1, 0, (SCM obj
, SCM sym
, SCM value
),
24 "Set property @var{sym} of @var{obj} to @var{value}.")
26 LY_ASSERT_SMOB (Prob
, obj
, 1);
27 Prob
*ps
= unsmob_prob (obj
);
28 LY_ASSERT_TYPE (ly_is_symbol
, sym
, 2);
30 ps
->set_property (sym
, value
);
31 return SCM_UNSPECIFIED
;
35 Hmm, this is not orthogonal.
37 LY_DEFINE (ly_prob_property_p
, "ly:prob-property?",
38 2, 1, 0, (SCM obj
, SCM sym
),
39 "Is boolean prop @var{sym} set?")
41 return scm_equal_p (SCM_BOOL_T
, ly_prob_property (obj
, sym
, SCM_BOOL_F
));
44 LY_DEFINE (ly_prob_property
, "ly:prob-property",
45 2, 1, 0, (SCM prob
, SCM sym
, SCM val
),
46 "Return the value for property @var{sym} of Prob object"
47 " @var{prob}. If no value is found, return @var{val} or"
48 " @code{'()} if @var{val} is not specified.")
50 LY_ASSERT_SMOB (Prob
, prob
, 1);
51 Prob
*ps
= unsmob_prob (prob
);
52 LY_ASSERT_TYPE (ly_is_symbol
, sym
, 2);
54 if (val
== SCM_UNDEFINED
)
57 SCM retval
= ps
->internal_get_property (sym
);
58 if (retval
== SCM_EOL
)
64 LY_DEFINE (ly_prob_type_p
, "ly:prob-type?",
67 "Is @var{obj} the specified prob-type?")
69 Prob
*prob
= unsmob_prob (obj
);
70 return scm_from_bool (prob
&& prob
->type () == type
);
73 LY_DEFINE (ly_make_prob
, "ly:make-prob",
75 (SCM type
, SCM init
, SCM rest
),
76 "Create a @code{Prob} object.")
78 Prob
*pr
= new Prob (type
, init
);
81 scm_is_pair (s
) && scm_is_pair (scm_cdr (s
)); s
= scm_cddr (s
))
83 SCM sym
= scm_car (s
);
84 SCM val
= scm_cadr (s
);
86 pr
->set_property (sym
, val
);
89 return pr
->unprotect ();
93 LY_DEFINE (ly_prob_mutable_properties
, "ly:prob-mutable-properties",
96 "Retrieve an alist of mutable properties.")
98 LY_ASSERT_SMOB (Prob
, prob
, 1);
99 Prob
*ps
= unsmob_prob (prob
);
100 return ps
->get_property_alist (true);
103 LY_DEFINE (ly_prob_immutable_properties
, "ly:prob-immutable-properties",
106 "Retrieve an alist of mutable properties.")
108 LY_ASSERT_SMOB (Prob
, prob
, 1);
109 Prob
*ps
= unsmob_prob (prob
);
110 return ps
->get_property_alist (false);