2 paper-system-scheme.cc -- implement Prob bindings
4 source file of the GNU LilyPond music typesetter
6 (c) 2005--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
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 prob
, SCM sym
, SCM val
),
35 "Return the value for property @var{sym} of Prob object"
36 " @var{prob}. If no value is found, return @var{val} or"
37 " @code{'()} if @var{val} is not specified.")
39 LY_ASSERT_SMOB (Prob
, prob
, 1);
40 Prob
*ps
= unsmob_prob (prob
);
41 LY_ASSERT_TYPE (ly_is_symbol
, sym
, 2);
43 if (val
== SCM_UNDEFINED
)
46 SCM retval
= ps
->internal_get_property (sym
);
47 if (retval
== SCM_EOL
)
53 LY_DEFINE (ly_prob_type_p
, "ly:prob-type?",
56 "Is @var{obj} the specified prob-type?")
58 Prob
*prob
= unsmob_prob (obj
);
59 return scm_from_bool (prob
&& prob
->type () == type
);
62 LY_DEFINE (ly_make_prob
, "ly:make-prob",
64 (SCM type
, SCM init
, SCM rest
),
65 "Create a @code{Prob} object.")
67 Prob
*pr
= new Prob (type
, init
);
70 scm_is_pair (s
) && scm_is_pair (scm_cdr (s
)); s
= scm_cddr (s
))
72 SCM sym
= scm_car (s
);
73 SCM val
= scm_cadr (s
);
75 pr
->set_property (sym
, val
);
78 return pr
->unprotect ();
82 LY_DEFINE (ly_prob_mutable_properties
, "ly:prob-mutable-properties",
85 "Retrieve an alist of mutable properties.")
87 LY_ASSERT_SMOB (Prob
, prob
, 1);
88 Prob
*ps
= unsmob_prob (prob
);
89 return ps
->get_property_alist (true);
92 LY_DEFINE (ly_prob_immutable_properties
, "ly:prob-immutable-properties",
95 "Retrieve an alist of mutable properties.")
97 LY_ASSERT_SMOB (Prob
, prob
, 1);
98 Prob
*ps
= unsmob_prob (prob
);
99 return ps
->get_property_alist (false);