--- /dev/null
+\version "2.13.12"
+
+\header {
+ texidoc = "The bottom-level contexts in polyphony shorthand are
+allocated a context id in order of creation, starting with
+@code{\"1\"}.
+This snippet will fail to compile if either voice has an invalid
+@code{context-id} string.
+"
+}
+
+assertContextId =
+#(define-music-function (parser location id) (string?)
+ (let ((music (make-music 'ApplyContext
+ 'procedure
+ (lambda (ctx)
+ (and
+ (not (string=? (ly:context-id ctx) id))
+ (ly:error "context-id mismatch found: expecting ~s, got ~s"
+ id
+ (ly:context-id ctx)))))))
+ music))
+
+\relative c'' {
+ <<
+ {
+ \assertContextId "1"
+ c4 d e2
+ }
+ \\
+ {
+ \assertContextId "2"
+ a,4 b c2
+ }
+ >>
+}
if (gthis && gthis->get_score_context ())
return gthis->get_score_context ()->create_unique_context (name, id, operations);
- vector<Context_def*> path = path_to_acceptable_context (name);
+ vector<Context_def *> path = path_to_acceptable_context (name);
if (path.size ())
{
Context *current = this;
if (n == ly_symbol2scm ("Bottom"))
{
- Context *tg = get_default_interpreter ();
+ Context *tg = get_default_interpreter (id);
return tg;
}
}
Context *
-Context::get_default_interpreter ()
+Context::get_default_interpreter (string context_id)
{
if (!is_bottom_context ())
{
t = unsmob_context_def (this->definition_);
}
- Context *tg = create_context (t, "", SCM_EOL);
- return tg->get_default_interpreter ();
+ Context *tg = create_context (t, context_id, SCM_EOL);
+ return tg->get_default_interpreter (context_id);
}
return this;
}
}
Context *
-Global_context::get_default_interpreter ()
+Global_context::get_default_interpreter (string /* context_id */)
{
if (get_score_context ())
return get_score_context ()->get_default_interpreter ();
virtual Context *get_score_context () const;
virtual Output_def *get_output_def () const;
virtual Moment now_mom () const;
- virtual Context *get_default_interpreter ();
+ virtual Context *get_default_interpreter (string context_id = "");
bool is_alias (SCM) const;
void add_alias (SCM);
virtual SCM get_output ();
virtual Output_def *get_output_def () const;
virtual Moment now_mom () const;
- virtual Context *get_default_interpreter ();
+ virtual Context *get_default_interpreter (string context_id = "");
Moment previous_moment () const;
protected: