]> git.donarmstrong.com Git - lilypond.git/commitdiff
Regularize score handling (origin and copying)
authorDavid Kastrup <dak@gnu.org>
Sat, 14 Dec 2013 21:29:12 +0000 (22:29 +0100)
committerDavid Kastrup <dak@gnu.org>
Thu, 19 Dec 2013 11:13:46 +0000 (12:13 +0100)
Scores get their origin set when score_body is called, and when encountered
in \xxx and  constructs, are properly copied.

lily/parser.yy

index ee705a57617e0bcab39a2c7d94db880d2a8a15ad..f32330b5b56ed64f964aef2a713201e100006dee 100644 (file)
@@ -874,6 +874,7 @@ bookpart_body:
 
 score_block:
        SCORE '{' score_body '}'        {
+               unsmob_score ($3)->origin ()->set_spot (@$);
                $$ = $3;
        }
        ;
@@ -918,7 +919,6 @@ score_body:
                SCM scorify = ly_lily_module_constant ("scorify-music");
                $$ = scm_call_2 (scorify, $2, parser->self_scm ());
 
-               unsmob_score ($$)->origin ()->set_spot (@2);
                if (scm_is_pair ($1) && ly_is_module (scm_car ($1)))
                {
                        unsmob_score ($$)->set_header (scm_car ($1));
@@ -932,15 +932,11 @@ score_body:
                }
        }
        | embedded_scm_active {
-               Score *score;
-               if (unsmob_score ($1))
-                       score = new Score (*unsmob_score ($1));
-               else {
-                       score = new Score;
+               if (!unsmob_score ($1))
+               {
+                       $$ = (new Score)->unprotect ();
                        parser->parser_error (@1, _("score expected"));
                }
-               unsmob_score ($$)->origin ()->set_spot (@$);
-               $$ = score->unprotect ();
        }
        | score_body
        {
@@ -3559,6 +3555,7 @@ markup_uncomposed_list:
                SCM nn = parser->lexer_->lookup_identifier ("pitchnames");
                parser->lexer_->push_note_state (nn);
        } '{' score_body '}' {
+               unsmob_score ($4)->origin ()->set_spot (@$);
                $$ = scm_list_1 (scm_list_2 (ly_lily_module_constant ("score-lines-markup-list"), $4));
                parser->lexer_->pop_state ();
        }
@@ -3635,6 +3632,7 @@ simple_markup:
                SCM nn = parser->lexer_->lookup_identifier ("pitchnames");
                parser->lexer_->push_note_state (nn);
        } '{' score_body '}' {
+               unsmob_score ($4)->origin ()->set_spot (@$);
                $$ = scm_list_2 (ly_lily_module_constant ("score-markup"), $4);
                parser->lexer_->pop_state ();
        }
@@ -3726,6 +3724,9 @@ Lily_lexer::try_special_identifiers (SCM *destination, SCM sid)
                *destination = p->self_scm ();
                p->unprotect ();
                return OUTPUT_DEF_IDENTIFIER;
+       } else if (unsmob_score (sid)) {
+               *destination = unsmob_score (sid)->clone ()->unprotect ();
+               return SCM_IDENTIFIER;
        }
 
        return -1;