Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2729)

Issue 475041: Context mods stored in variable, can be inserted into \with or \context (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
14 years, 1 month ago by Reinhold
Modified:
14 years ago
Reviewers:
Neil Puttock
CC:
lilypond-devel_gnu.org, reinhold_kainhofer.com
Visibility:
Public.

Description

Context mods stored in variable, can be inserted into \with or \context -) Context-Modifications: create C++ class to store them -) context modifications lists are stored in a dedicated simple scheme object (C++ class Context_mod) -) Changes to the parser: -) context_modifications objects (stored in variables) are now also allowed with \with clauses -) context_modifications objects are also allowed inside \context -) this allows us to rewrite \RemoveEmptyStaffContext (unfortunately with a little different syntax, since we no longer store \Staff inside the \RESC command) so that it no longer erases previous settings to the Staff context. Now, instead of \context { \RemoveEmptyStaffContext } one can do \context { \Staff \RemoveEmptyStaves } with the same effect and preserve previous changes to the Staff context. (The same applies of course to \DrumStaff, \RhythmicStaff, etc. as well) -) Adjusted engraver-init.ly and the regtests accordingly; Also added regtest that checks for RESC not discarding previous settings to the Staff context

Patch Set 1 #

Total comments: 14

Patch Set 2 : Include Neils suggestions, fix version numbers, parse context_mod_list in initial state #

Unified diffs Side-by-side diffs Delta from patch set Stats (+401 lines, -56 lines) Patch
A input/regression/context-mod-context.ly View 1 1 chunk +44 lines, -0 lines 0 comments Download
A input/regression/context-mod-with.ly View 1 1 chunk +46 lines, -0 lines 0 comments Download
M input/regression/hara-kiri-drumstaff.ly View 1 2 chunks +3 lines, -2 lines 0 comments Download
A input/regression/hara-kiri-keep-previous-settings.ly View 1 1 chunk +43 lines, -0 lines 0 comments Download
M input/regression/hara-kiri-percent-repeat.ly View 1 2 chunks +7 lines, -8 lines 0 comments Download
M input/regression/hara-kiri-pianostaff.ly View 1 2 chunks +3 lines, -2 lines 0 comments Download
M input/regression/hara-kiri-rhythmicstaff.ly View 1 2 chunks +3 lines, -2 lines 0 comments Download
M input/regression/hara-kiri-tabstaff.ly View 1 2 chunks +3 lines, -2 lines 0 comments Download
A lily/context-mod.cc View 1 1 chunk +76 lines, -0 lines 0 comments Download
A lily/include/context-mod.hh View 1 1 chunk +58 lines, -0 lines 0 comments Download
M lily/include/lily-proto.hh View 1 chunk +1 line, -0 lines 0 comments Download
M lily/lily-lexer.cc View 1 1 chunk +1 line, -0 lines 0 comments Download
M lily/parser.yy View 1 10 chunks +79 lines, -21 lines 0 comments Download
M ly/engraver-init.ly View 1 2 chunks +22 lines, -18 lines 0 comments Download
M python/convertrules.py View 1 chunk +12 lines, -1 line 0 comments Download

Messages

Total messages: 2
Neil Puttock
Hi Reinhold, LGTM. You need to check your indentation in parser.yy, since you're adding spaces ...
14 years, 1 month ago (2010-03-13 23:24:24 UTC) #1
Reinhold
14 years, 1 month ago (2010-03-14 00:17:46 UTC) #2
http://codereview.appspot.com/475041/diff/1/10
File lily/context-mod.cc (right):

http://codereview.appspot.com/475041/diff/1/10#newcode73
lily/context-mod.cc:73: Context_mod::to_alist () const
On 2010/03/13 23:24:24, Neil Puttock wrote:
> I'd name this something like get_mods (), otherwise it implies you're building
> an alist to return (which obviously isn't the case)

Yes, of course. I simply copied Context_def (where we really return an alist)
and adjusted the code, but overlooked this little detail...

http://codereview.appspot.com/475041/diff/1/10#newcode75
lily/context-mod.cc:75: return mods_;
reverse is missing here (each new mod is prepended!). At first look it might not
make a difference, but it does if a block contains two conflicting settings.
Inside \context, the last one is applied, if we don't reverse mods_ here, the
first takes precedence!

In particular, if we have
    \remove "Clef_engraver"
    \consists "Clef_engraver"
inside a \context {\Staff ...} block, the staff will contain the clef engraver,
while inside a \with block, it would be removed...

http://codereview.appspot.com/475041/diff/1/11
File lily/include/context-mod.hh (right):

http://codereview.appspot.com/475041/diff/1/11#newcode30
lily/include/context-mod.hh:30: // #include "lily-proto.hh"
On 2010/03/13 23:24:24, Neil Puttock wrote:
> Add prototype for Context_mod to lily-proto.hh ?

Hmm, you are right, that might be a good idea (just in case some class later on
will work with pointers to Context_mod...). Should I then include lily-proto.hh,
even if technically not required?

http://codereview.appspot.com/475041/diff/1/11#newcode49
lily/include/context-mod.hh:49: VIRTUAL_COPY_CONSTRUCTOR(Context_mod,
Context_mod);
On 2010/03/13 23:24:24, Neil Puttock wrote:
> VIRTUAL_COPY_CONSTRUCTOR (

Hehe, that's copied verbatim from Context_def...
(BTW, a grep shows 157 lines with missing spaces just in lily/*.cc, and 203
lines with missing spaces in lily/include/*.hh -- Shall we fix them all in one
go?)

http://codereview.appspot.com/475041/diff/1/12
File lily/lily-lexer.cc (right):

http://codereview.appspot.com/475041/diff/1/12#newcode52
lily/lily-lexer.cc:52: {"contextModifications", CONTEXT_MOD},
On 2010/03/13 23:24:24, Neil Puttock wrote:
> contextmodifications (all the parser keywords are lower case)

That keywords looks absolutely awkward. Maybe we should revisit that
convention... The alternative would be to not introduce a new parser keyword at
all and simply use \with instead (although that does not describe what the
following block is supposed to do when assigned to a variable, i.e. "mymods =
\with { \consists.... }"

http://codereview.appspot.com/475041/diff/1/13
File lily/parser.yy (right):

http://codereview.appspot.com/475041/diff/1/13#newcode1069
lily/parser.yy:1069: context_mod_list:
Unfortunately something here breaks \consists Some_engraver (without quotes!).
The parser now tries to evaluate Some as a variable rather than interpret
"Some_engraver" as a string...

http://codereview.appspot.com/475041/diff/1/14
File ly/engraver-init.ly (right):

http://codereview.appspot.com/475041/diff/1/14#newcode466
ly/engraver-init.ly:466: }
Shall we add a convert-ly rule for \RemoveEmptyStaffContext ->
\Staff\RemoveEmptyStaves ? Of course, a simplar rule for the other
RemoveEmpty*StaffContext's is needed, too.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b