source file of the GNU LilyPond music typesetter
- (c) 2000--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ (c) 2000--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
*/
/* TODO: should junk this class an replace by
context_name_ = SCM_EOL;
default_child_ = SCM_EOL;
description_ = SCM_EOL;
+ input_location_ = SCM_EOL;
smobify_self ();
+ input_location_ = make_input (Input ());
context_name_ = ly_symbol2scm ("");
}
+Input *
+Context_def::origin () const
+{
+ return unsmob_input (input_location_);
+}
+
Context_def::Context_def (Context_def const &s)
- : Input (s)
{
context_aliases_ = SCM_EOL;
translator_group_type_ = SCM_EOL;
context_name_ = SCM_EOL;
description_ = SCM_EOL;
default_child_ = SCM_EOL;
-
+ input_location_ = SCM_EOL;
smobify_self ();
- description_ = s.description_;
+ description_ = s.description_;
+ input_location_ = make_input (*s.origin ());
default_child_ = s.default_child_;
accept_mods_ = s.accept_mods_;
property_ops_ = s.property_ops_;
SCM
Context_def::mark_smob (SCM smob)
{
+ ASSERT_LIVE_IS_ALLOWED ();
+
Context_def *me = (Context_def *) SCM_CELL_WORD_1 (smob);
scm_gc_mark (me->description_);
scm_gc_mark (me->property_ops_);
scm_gc_mark (me->translator_group_type_);
scm_gc_mark (me->default_child_);
+ scm_gc_mark (me->input_location_);
return me->context_name_;
}
return name;
}
+/*
+ Given a name of a context that we want to create, finds a list of context
+ definitions such that:
+ - the first element in the list defines a context that is a valid child of
+ the context defined by this Context_def
+ - each subsequent element in the list defines a context that is a valid child
+ of the the context defined by the preceding element in the list
+ - the last element in the list defines a context with the given name
+
+ The ADDITIONAL_ACCEPTS parameter is a list of additional contexts that this
+ specific context def (but not any of the child context defs) should accept.
+*/
vector<Context_def*>
-Context_def::path_to_acceptable_context (SCM type_sym, Output_def *odef) const
+Context_def::path_to_acceptable_context (SCM type_sym, Output_def *odef, SCM additional_accepts) const
{
assert (scm_is_symbol (type_sym));
- SCM accepted = get_accepted (SCM_EOL);
+ SCM accepted = get_accepted (additional_accepts);
vector<Context_def*> accepteds;
for (SCM s = accepted; scm_is_pair (s); s = scm_cdr (s))
Context_def *g = accepteds[i];
vector<Context_def*> result
- = g->path_to_acceptable_context (type_sym, odef);
+ = g->path_to_acceptable_context (type_sym, odef, SCM_EOL);
if (result.size () && result.size () < best_depth)
{
best_depth = result.size ();
}
Context *
-Context_def::instantiate (SCM ops, Object_key const *key)
+Context_def::instantiate (SCM ops)
{
- Context *context = new Context (key);
+ Context *context = new Context ();
context->definition_ = self_scm ();
context->definition_mods_ = ops;