2 #include "context-def.hh"
5 LY_DEFINE(ly_context_id,
6 "ly:context-id", 1,0,0, (SCM context),
7 "Return the id string of @var{context}, i.e. for @code{\\context Voice "
8 "= one .. } it will return the string @code{one}.")
10 Context * tr = (unsmob_context (context));
11 SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Context");
13 return scm_makfrom0str (tr->id_string_. to_str0 ());
17 LY_DEFINE(ly_context_name,
18 "ly:context-name", 1,0,0, (SCM context),
19 "Return the name of @var{context}, i.e. for @code{\\context Voice "
20 "= one .. } it will return the symbol @code{Voice}.")
22 Context * tr = (unsmob_context (context));
23 SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Context");
25 return unsmob_context_def (tr->definition_)->get_context_name ();
29 LY_DEFINE(ly_context_pushpop_property,
30 "ly:context-pushpop-property", 3, 1, 0,
31 (SCM context, SCM grob, SCM eltprop, SCM val),
32 "Do a single @code{\\override} or @code{\\revert} operation "
33 "in @var{context}. The grob definition @code{grob} is extended with "
34 "@code{eltprop} (if @var{val} is specified) "
35 "or reverted (if unspecified).")
37 Context *tg = (unsmob_context (context));
39 SCM_ASSERT_TYPE(tg, context, SCM_ARG1, __FUNCTION__, "context");
40 SCM_ASSERT_TYPE(gh_symbol_p (grob), grob, SCM_ARG2, __FUNCTION__, "symbol");
41 SCM_ASSERT_TYPE(gh_symbol_p (eltprop), eltprop, SCM_ARG3, __FUNCTION__, "symbol");
43 execute_pushpop_property (tg, grob, eltprop, val);
49 LY_DEFINE(ly_get_context_property,
50 "ly:context-property", 2, 0, 0,
51 (SCM context, SCM name),
52 "retrieve the value of @var{name} from context @var{context}")
54 Context *t = unsmob_context (context);
56 SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Translator group");
57 SCM_ASSERT_TYPE(gh_symbol_p (name), name, SCM_ARG2, __FUNCTION__, "symbol");
59 return tr->internal_get_property (name);
63 LY_DEFINE(ly_set_context_property,
64 "ly:context-set-property!", 3, 0, 0,
65 (SCM context, SCM name, SCM val),
66 "set value of property @var{name} in context @var{context} to @var{val}.")
68 Context *t = unsmob_context (context);
71 SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Context");
72 SCM_ASSERT_TYPE(gh_symbol_p (name), name, SCM_ARG2, __FUNCTION__, "symbol");
74 tr->internal_set_property (name, val);
76 return SCM_UNSPECIFIED;
80 LY_DEFINE(ly_context_property_where_defined,
81 "ly:context-property-where-defined", 2, 0, 0,
82 (SCM context, SCM name),
83 "Return the context above @var{context} where @var{name} is defined.")
85 Context *t = unsmob_context (context);
87 SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Context");
88 SCM_ASSERT_TYPE(gh_symbol_p (name), name, SCM_ARG2, __FUNCTION__, "symbol");
91 tr = tr->where_defined (name);
94 return tr->self_scm();
99 LY_DEFINE(ly_unset_context_property,
100 "ly:unset-context-property", 2, 0, 0,
101 (SCM context, SCM name),
102 "Unset value of property @var{name} in context @var{context}.")
104 Context *t = unsmob_context (context);
106 SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Context");
107 SCM_ASSERT_TYPE(gh_symbol_p (name), name, SCM_ARG2, __FUNCTION__, "symbol");
109 tr->unset_property (name);
111 return SCM_UNSPECIFIED;
116 LY_DEFINE(ly_context_parent,
117 "ly:context-parent", 1, 0, 0,
119 "Return the parent of @var{context}, #f if none.")
121 Context *t = unsmob_context (context);
124 SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Context");
126 tr = tr->daddy_context_ ;
128 return tr->self_scm();
134 Todo: should support translator IDs, and creation?
136 LY_DEFINE(ly_translator_find,
137 "ly:translator-find", 2, 0,0,
138 (SCM context, SCM name),
139 "Find a parent of @var{context} that has name or alias @var{name}. "
140 "Return @code{#f} if not found." )
142 Context * tr= ( unsmob_context (context));
144 SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "context");
145 SCM_ASSERT_TYPE(gh_symbol_p (name), name, SCM_ARG2, __FUNCTION__, "symbol");
149 if (tr->is_alias (name))
150 return tr->self_scm();
151 tr = tr->daddy_context_ ;
158 LY_DEFINE(ly_context_properties,
159 "ly:context-properties", 1, 0, 0,
161 "Return all properties of @var{context} in an alist.")
163 Context *t = unsmob_context (context);
166 SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Context");
168 return tr->properties_as_alist ();