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>
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
)
44 SCM retval
= ps
->internal_get_property (sym
);
45 if (retval
== SCM_EOL
)
51 LY_DEFINE (ly_prob_type_p
, "ly:prob-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",
62 (SCM type
, SCM init
, SCM rest
),
63 "Create a @code{Prob} object.")
65 Prob
*pr
= new Prob (type
, init
);
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",
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",
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);