2 paper-system-scheme.cc -- implement Prob bindings
4 source file of the GNU LilyPond music typesetter
6 (c) 2005--2006 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 Prob *ps = unsmob_prob (obj);
16 SCM_ASSERT_TYPE (ps, obj, SCM_ARG1, __FUNCTION__, "Prob");
17 SCM_ASSERT_TYPE (scm_is_symbol (sym), sym, SCM_ARG2, __FUNCTION__, "symbol");
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 Prob *ps = unsmob_prob (obj);
38 SCM_ASSERT_TYPE (ps, obj, SCM_ARG1, __FUNCTION__, "Prob");
39 SCM_ASSERT_TYPE (scm_is_symbol (sym), sym, SCM_ARG2, __FUNCTION__, "symbol");
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 "If 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),
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_paper_system_p, "ly:paper-system?",
84 return ly_prob_type_p (obj, ly_symbol2scm ("paper-system"));