Since voicify-music now uses the context alias `Bottom' to create the
appropriate voice-level contexts in a << { } \\ { } >> construct, the
context-id sent via context-spec-music is ignored.
* add context-id as arg to Global_context/Context::get_default_interpreter (),
with empty string as default
* pass context-id to Context::get_default_interpreter () so it can
be used in call to create_context () instead of empty string
* add regtest, which will fail to compile if context-id is invalid
--- /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);
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 (path.size ())
{
Context *current = this;
if (n == ly_symbol2scm ("Bottom"))
{
if (n == ly_symbol2scm ("Bottom"))
{
- Context *tg = get_default_interpreter ();
+ Context *tg = get_default_interpreter (id);
-Context::get_default_interpreter ()
+Context::get_default_interpreter (string context_id)
{
if (!is_bottom_context ())
{
{
if (!is_bottom_context ())
{
t = unsmob_context_def (this->definition_);
}
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);
-Global_context::get_default_interpreter ()
+Global_context::get_default_interpreter (string /* context_id */)
{
if (get_score_context ())
return get_score_context ()->get_default_interpreter ();
{
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_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);
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 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:
Moment previous_moment () const;
protected: