The definition of a Bottom context previously was a context not
accepting any subcontexts. Now it is a context without a
\defaultchild. The defaultchild of a context previously was the first
found in the \accepts list (if necessary, moving it there). While
\defaultchild was tracked in context definitions, it was not explicit
in instantiated contexts.
Decoupling those makes for more flexible arrangements of contexts.
For example, one might let Voice accept a SubVoice context without
forcing SubVoice to be created when a Bottom context is called for
when in Voice, simply by not giving Voice a \defaultchild.
@unnumberedsubsubsec Bottom-level contexts - voices
Voice-level contexts initialise certain properties and start
@unnumberedsubsubsec Bottom-level contexts - voices
Voice-level contexts initialise certain properties and start
-appropriate engravers. Being bottom-level contexts, they cannot
-contain other contexts.
+appropriate engravers. A bottom-level context is one without
+@code{defaultchild}. While it is possible to let it
+accept/@/contain subcontexts, they can only be created and entered
+explicitly.
context->definition_mods_ = ops;
context->aliases_ = context_aliases_;
context->accepts_list_ = get_accepted (ops);
context->definition_mods_ = ops;
context->aliases_ = context_aliases_;
context->accepts_list_ = get_accepted (ops);
+ context->default_child_ = get_default_child (ops);
get_translator_names (SCM_EOL)), ell);
ell = scm_cons (scm_cons (ly_symbol2scm ("description"), description_), ell);
ell = scm_cons (scm_cons (ly_symbol2scm ("aliases"), context_aliases_), ell);
get_translator_names (SCM_EOL)), ell);
ell = scm_cons (scm_cons (ly_symbol2scm ("description"), description_), ell);
ell = scm_cons (scm_cons (ly_symbol2scm ("aliases"), context_aliases_), ell);
+ ell = scm_cons (scm_cons (ly_symbol2scm ("accepts"), get_accepted (SCM_EOL)),
+ ell);
+ if (scm_is_symbol (default_child_))
+ ell = scm_acons (ly_symbol2scm ("default-child"), default_child_, ell);
ell = scm_cons (scm_cons (ly_symbol2scm ("accepts"), get_accepted (SCM_EOL)),
ell);
ell = scm_cons (scm_cons (ly_symbol2scm ("property-ops"), property_ops_),
ell = scm_cons (scm_cons (ly_symbol2scm ("accepts"), get_accepted (SCM_EOL)),
ell);
ell = scm_cons (scm_cons (ly_symbol2scm ("property-ops"), property_ops_),
Context_def::is_alias (SCM sym) const
{
if (scm_is_eq (sym, ly_symbol2scm ("Bottom")))
Context_def::is_alias (SCM sym) const
{
if (scm_is_eq (sym, ly_symbol2scm ("Bottom")))
- return !scm_is_pair (get_accepted (SCM_EOL));
+ return !scm_is_symbol (get_default_child (SCM_EOL));
if (scm_is_eq (sym, get_context_name ()))
return true;
if (scm_is_eq (sym, get_context_name ()))
return true;
implementation_ = 0;
properties_scm_ = SCM_EOL;
accepts_list_ = SCM_EOL;
implementation_ = 0;
properties_scm_ = SCM_EOL;
accepts_list_ = SCM_EOL;
+ default_child_ = SCM_EOL;
context_list_ = SCM_EOL;
definition_ = SCM_EOL;
definition_mods_ = SCM_EOL;
context_list_ = SCM_EOL;
definition_ = SCM_EOL;
definition_mods_ = SCM_EOL;
SCM
Context::default_child_context_name () const
{
SCM
Context::default_child_context_name () const
{
- return scm_is_pair (accepts_list_)
- ? scm_car (accepts_list_)
- : SCM_EOL;
bool
Context::is_alias (SCM sym) const
{
bool
Context::is_alias (SCM sym) const
{
- if (sym == ly_symbol2scm ("Bottom")
- && !scm_is_pair (accepts_list_))
- return true;
- if (sym == unsmob_context_def (definition_)->get_context_name ())
+ if (scm_is_eq (sym, ly_symbol2scm ("Bottom")))
+ return is_bottom_context ();
+ if (scm_is_eq (sym, context_name_symbol ()))
return true;
return scm_c_memq (sym, aliases_) != SCM_BOOL_F;
return true;
return scm_c_memq (sym, aliases_) != SCM_BOOL_F;
scm_gc_mark (me->definition_mods_);
scm_gc_mark (me->properties_scm_);
scm_gc_mark (me->accepts_list_);
scm_gc_mark (me->definition_mods_);
scm_gc_mark (me->properties_scm_);
scm_gc_mark (me->accepts_list_);
+ scm_gc_mark (me->default_child_);
if (me->implementation_)
scm_gc_mark (me->implementation_->self_scm ());
if (me->implementation_)
scm_gc_mark (me->implementation_->self_scm ());
for (; scm_is_pair (p); p = scm_cdr (p))
scm_hashq_set_x (ancestor_lookup_, scm_caar (p), scm_car (p));
for (; scm_is_pair (p); p = scm_cdr (p))
scm_hashq_set_x (ancestor_lookup_, scm_caar (p), scm_car (p));
- accepts_list_ = scm_list_1 (ly_symbol2scm ("Score"));
+ default_child_ = ly_symbol2scm ("Score");
+ accepts_list_ = scm_list_1 (default_child_);
SCM properties_scm_;
SCM context_list_;
SCM accepts_list_;
SCM properties_scm_;
SCM context_list_;
SCM accepts_list_;
SCM aliases_;
Translator_group *implementation_;
string id_string_;
SCM aliases_;
Translator_group *implementation_;
string id_string_;
\context {
\name Global
\accepts Score
\context {
\name Global
\accepts Score
\description "Hard coded entry point for LilyPond. Cannot be tuned."
EventClasses = #all-event-classes
}
\description "Hard coded entry point for LilyPond. Cannot be tuned."
EventClasses = #all-event-classes
}
\type "Performer_group"
\consists "Staff_performer"
\accepts ChordNameVoice
\type "Performer_group"
\consists "Staff_performer"
\accepts ChordNameVoice
+ \defaultchild ChordNameVoice