From: David Kastrup Date: Tue, 21 Jul 2015 15:11:18 +0000 (+0200) Subject: Syntax::property_operation -> Syntax::property_{override,revert,set,unset} X-Git-Tag: release/2.19.25-1~46 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=d5a48e801bd400e47de34cdeb398fba3510d6940;p=lilypond.git Syntax::property_operation -> Syntax::property_{override,revert,set,unset} No point in joining and later splitting separate functions. The original motivation might have been to reduce name space pollution, but (scm ly-syntax-constructors) is a separate module by now. --- diff --git a/lily/include/lily-imports.hh b/lily/include/lily-imports.hh index 383896a021..c53ad421d8 100644 --- a/lily/include/lily-imports.hh +++ b/lily/include/lily-imports.hh @@ -121,7 +121,10 @@ namespace Syntax { extern Variable music_function_call_error; extern Variable partial_markup; extern Variable partial_music_function; - extern Variable property_operation; + extern Variable property_override; + extern Variable property_revert; + extern Variable property_set; + extern Variable property_unset; extern Variable repeat; extern Variable repetition_chord; extern Variable sequential_music; diff --git a/lily/lily-imports.cc b/lily/lily-imports.cc index 3a694f9d10..16087513df 100644 --- a/lily/lily-imports.cc +++ b/lily/lily-imports.cc @@ -114,7 +114,10 @@ namespace Syntax { Variable music_function_call_error ("music-function-call-error"); Variable partial_markup ("partial-markup"); Variable partial_music_function ("partial-music-function"); - Variable property_operation ("property-operation"); + Variable property_override ("property-override"); + Variable property_revert ("property-revert"); + Variable property_set ("property-set"); + Variable property_unset ("property-unset"); Variable repeat ("repeat"); Variable repetition_chord ("repetition-chord"); Variable sequential_music ("sequential-music"); diff --git a/lily/parser.yy b/lily/parser.yy index 48ada37566..552d699d25 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -2639,29 +2639,21 @@ music_property_def: OVERRIDE grob_prop_path '=' scalar { if (SCM_UNBNDP ($2)) $$ = MAKE_SYNTAX (void_music, @$); - else { - $$ = MAKE_SYNTAX (property_operation, @$, + else + $$ = MAKE_SYNTAX (property_override, @$, scm_car ($2), - ly_symbol2scm ("OverrideProperty"), - scm_cadr ($2), - $4, - scm_cddr ($2)); - } + scm_cdr ($2), + $4); } | REVERT simple_revert_context revert_arg { - $$ = MAKE_SYNTAX (property_operation, @$, - $2, - ly_symbol2scm ("RevertProperty"), - scm_car ($3), - scm_cdr ($3)); + $$ = MAKE_SYNTAX (property_revert, @$, $2, $3); } | SET context_prop_spec '=' scalar { if (SCM_UNBNDP ($2)) $$ = MAKE_SYNTAX (void_music, @$); else - $$ = MAKE_SYNTAX (property_operation, @$, + $$ = MAKE_SYNTAX (property_set, @$, scm_car ($2), - ly_symbol2scm ("PropertySet"), scm_cadr ($2), $4); } @@ -2669,9 +2661,8 @@ music_property_def: if (SCM_UNBNDP ($2)) $$ = MAKE_SYNTAX (void_music, @$); else - $$ = MAKE_SYNTAX (property_operation, @$, + $$ = MAKE_SYNTAX (property_unset, @$, scm_car ($2), - ly_symbol2scm ("PropertyUnset"), scm_cadr ($2)); } ; diff --git a/scm/ly-syntax-constructors.scm b/scm/ly-syntax-constructors.scm index 54cea850ec..0d37c0f766 100644 --- a/scm/ly-syntax-constructors.scm +++ b/scm/ly-syntax-constructors.scm @@ -213,26 +213,38 @@ into a @code{MultiMeasureTextEvent}." (set-object-property! chain 'markup-signature (list markup?)) chain)) -(define-public (property-operation ctx music-type symbol . args) - (let* ((props (case music-type - ((PropertySet) (list 'value (car args))) - ((PropertyUnset) '()) - ((OverrideProperty) (list 'grob-value (car args) - 'grob-property-path (if (list? (cadr args)) - (cadr args) - (cdr args)) - 'pop-first #t)) - ((RevertProperty) - (if (list? (car args)) - (list 'grob-property-path (car args)) - (list 'grob-property-path args))) - (else (ly:error (_ "Invalid property operation ~a") music-type)))) - (m (ly:set-origin! (apply make-music music-type - 'symbol symbol - props)))) - (ly:set-origin! (make-music 'ContextSpeccedMusic - 'element m - 'context-type ctx)))) +(define-public (property-set context property value) + (ly:set-origin! (context-spec-music + (ly:set-origin! + (make-music 'PropertySet + 'symbol property + 'value value)) + context))) + +(define-public (property-unset context property) + (ly:set-origin! (context-spec-music + (ly:set-origin! + (make-music 'PropertyUnset + 'symbol property)) + context))) + +(define-public (property-override context path value) + (ly:set-origin! (context-spec-music + (ly:set-origin! + (make-music 'OverrideProperty + 'symbol (car path) + 'grob-property-path (cdr path) + 'grob-value value + 'pop-first #t)) + context))) + +(define-public (property-revert context path) + (ly:set-origin! (context-spec-music + (ly:set-origin! + (make-music 'RevertProperty + 'symbol (car path) + 'grob-property-path (cdr path))) + context))) (define (get-first-context-id! mus) "Find the name of a ContextSpeccedMusic, possibly naming it"