Bump version.
[lilypond.git] / lily / prob-scheme.cc
blob717e32a945985358af74ee08f379b372e4363294
1 /*
2 paper-system-scheme.cc -- implement Prob bindings
4 source file of the GNU LilyPond music typesetter
6 (c) 2005--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
9 #include "prob.hh"
11 LY_DEFINE (ly_prob_set_property_x, "ly:prob-set-property!",
12 2, 1, 0, (SCM obj, SCM sym, SCM value),
13 "Set property @var{sym} of @var{obj} to @var{value}.")
15 LY_ASSERT_SMOB (Prob, obj, 1);
16 Prob *ps = unsmob_prob (obj);
17 LY_ASSERT_TYPE (ly_is_symbol, sym, 2);
19 ps->set_property (sym, value);
20 return SCM_UNSPECIFIED;
24 Hmm, this is not orthogonal.
26 LY_DEFINE (ly_prob_property_p, "ly:prob-property?",
27 2, 1, 0, (SCM obj, SCM sym),
28 "Is boolean prop @var{sym} set?")
30 return scm_equal_p (SCM_BOOL_T, ly_prob_property (obj, sym, SCM_BOOL_F));
33 LY_DEFINE (ly_prob_property, "ly:prob-property",
34 2, 1, 0, (SCM obj, SCM sym, SCM dfault),
35 "Return the value for @var{sym}.")
37 LY_ASSERT_SMOB (Prob, obj, 1);
38 Prob *ps = unsmob_prob (obj);
39 LY_ASSERT_TYPE (ly_is_symbol, sym, 2);
41 if (dfault == SCM_UNDEFINED)
42 dfault = SCM_EOL;
44 SCM retval = ps->internal_get_property (sym);
45 if (retval == SCM_EOL)
46 return dfault;
47 else
48 return retval;
51 LY_DEFINE (ly_prob_type_p, "ly:prob-type?",
52 2, 0, 0,
53 (SCM obj, SCM type),
54 "Is @var{obj} the specified prob-type?")
56 Prob*prob = unsmob_prob (obj);
57 return scm_from_bool (prob && prob->type () == type);
60 LY_DEFINE (ly_make_prob, "ly:make-prob",
61 2, 0, 1,
62 (SCM type, SCM init, SCM rest),
63 "Create a @code{Prob} object.")
65 Prob *pr = new Prob (type, init);
67 for (SCM s = rest;
68 scm_is_pair (s) && scm_is_pair (scm_cdr (s)); s = scm_cddr (s))
70 SCM sym = scm_car (s);
71 SCM val = scm_cadr (s);
73 pr->set_property (sym, val);
76 return pr->unprotect ();
80 LY_DEFINE (ly_prob_mutable_properties, "ly:prob-mutable-properties",
81 1, 0, 0,
82 (SCM prob),
83 "Retrieve an alist of mutable properties.")
85 LY_ASSERT_SMOB (Prob, prob, 1);
86 Prob *ps = unsmob_prob (prob);
87 return ps->get_property_alist (true);
90 LY_DEFINE (ly_prob_immutable_properties, "ly:prob-immutable-properties",
91 1, 0, 0,
92 (SCM prob),
93 "Retrieve an alist of mutable properties.")
95 LY_ASSERT_SMOB (Prob, prob, 1);
96 Prob *ps = unsmob_prob (prob);
97 return ps->get_property_alist (false);