tools/widl: Split expr_int_const off from expr

Gerald Pfeifer gerald at pfeifer.com
Mon Dec 21 03:26:52 CST 2009


Hi Rob, first of all sorry for the delay in getting back to this.  I
kept looking for alternative approaches, but now ended up figuring that
really laying down the issue at hand I was trying to solve in front of
everyone a priori will be the better approach.

Let me first respond to concrete feedback you provided, and than show
why I started down this road.

On Thu, 2 Jul 2009, Rob Shearman wrote:
> 2009/6/28 Gerald Pfeifer <gerald at pfeifer.com>:
>> diff --git a/tools/widl/parser.y b/tools/widl/parser.y
>> index c2f1abc..01aa060 100644
>> --- a/tools/widl/parser.y
>> +++ b/tools/widl/parser.y
>> @@ -622,56 +633,54 @@ m_expr:                                           { $$ = make_expr(EXPR_VOID); }
>>        | expr
>>        ;
>>
>> -expr:    aNUM                                  { $$ = make_exprl(EXPR_NUM, $1); }
>> -       | aHEXNUM                               { $$ = make_exprl(EXPR_HEXNUM, $1); }
>> +expr:  expr_int_const
>>        | aDOUBLE                               { $$ = make_exprd(EXPR_DOUBLE, $1); }
>> +       | '-' aDOUBLE                           { $$ = make_exprd(EXPR_DOUBLE, -($2)); }
> 
> This is covered by the production for the binary minus operator that
> already exists, so I'm not sure what you're trying to achieve here.

Yes, alas the current widl parser is somewhat special: it uses quite
general rules (too general rules, one could argue), only to perform
tighter checks later on, in the C component of the productions.

This basically combines the styles of bison parser with a recursive
descending parser (manually written), and I tried to clear this a bit.

> Using "expr_int_const" instead of "expr" here prevents a many forms of
> expressions from being parsed.

It did suffice to build all of Wine without problems, but if we expect
out of tree users, that could be a problem indeed.

> It looks like you'll have to find another way of fixing the issue you
> are trying to fix.

Okay, so here is the issue.  Wine kind of abuses enums a bit, injecting
additional values by means of #defines (that are not part of the enum 
proper) which will make GCC 4.5, without extra options!, issue the 
following litany of warnings:


utils.c:269:9: warning: case value '827606349' not in enumerated type 'WINED3DFORMAT'
utils.c:264:9: warning: case value '827611204' not in enumerated type 'WINED3DFORMAT'
utils.c:258:9: warning: case value '842094169' not in enumerated type 'WINED3DFORMAT'
utils.c:265:9: warning: case value '844388420' not in enumerated type 'WINED3DFORMAT'
utils.c:252:9: warning: case value '844715353' not in enumerated type 'WINED3DFORMAT'
utils.c:266:9: warning: case value '861165636' not in enumerated type 'WINED3DFORMAT'
utils.c:267:9: warning: case value '877942852' not in enumerated type 'WINED3DFORMAT'
utils.c:268:9: warning: case value '894720068' not in enumerated type 'WINED3DFORMAT'
utils.c:270:9: warning: case value '1111970375' not in enumerated type 'WINED3DFORMAT'
utils.c:271:9: warning: case value '1195525970' not in enumerated type 'WINED3DFORMAT'
utils.c:251:9: warning: case value '1498831189' not in enumerated type 'WINED3DFORMAT'
directx.c:2863:9: warning: case value '827611204' not in enumerated type 'WINED3DFORMAT'
directx.c:2864:9: warning: case value '844388420' not in enumerated type 'WINED3DFORMAT'
directx.c:2865:9: warning: case value '861165636' not in enumerated type 'WINED3DFORMAT'
directx.c:2866:9: warning: case value '877942852' not in enumerated type 'WINED3DFORMAT'
directx.c:2867:9: warning: case value '894720068' not in enumerated type 'WINED3DFORMAT'
directx.c:3116:9: warning: case value '827606349' not in enumerated type 'WINED3DFORMAT'
directx.c:3017:9: warning: case value '827611204' not in enumerated type 'WINED3DFORMAT'
directx.c:3060:9: warning: case value '842094169' not in enumerated type 'WINED3DFORMAT'
directx.c:3121:9: warning: case value '843666497' not in enumerated type 'WINED3DFORMAT'
directx.c:3018:9: warning: case value '844388420' not in enumerated type 'WINED3DFORMAT'
directx.c:3052:9: warning: case value '844715353' not in enumerated type 'WINED3DFORMAT'
directx.c:3019:9: warning: case value '861165636' not in enumerated type 'WINED3DFORMAT'
directx.c:3020:9: warning: case value '877942852' not in enumerated type 'WINED3DFORMAT'
directx.c:3021:9: warning: case value '894720068' not in enumerated type 'WINED3DFORMAT'
directx.c:3115:9: warning: case value '1111970375' not in enumerated type 'WINED3DFORMAT'
directx.c:3114:9: warning: case value '1195525970' not in enumerated type 'WINED3DFORMAT'
directx.c:3141:9: warning: case value '1397249614' not in enumerated type 'WINED3DFORMAT'
directx.c:3103:9: warning: case value '1414745673' not in enumerated type 'WINED3DFORMAT'
directx.c:3140:9: warning: case value '1430804046' not in enumerated type 'WINED3DFORMAT'
directx.c:3051:9: warning: case value '1498831189' not in enumerated type 'WINED3DFORMAT'
directx.c:3709:13: warning: case value '827611204' not in enumerated type 'WINED3DFORMAT'
directx.c:3710:13: warning: case value '844388420' not in enumerated type 'WINED3DFORMAT'
directx.c:3711:13: warning: case value '861165636' not in enumerated type 'WINED3DFORMAT'
directx.c:3712:13: warning: case value '877942852' not in enumerated type 'WINED3DFORMAT'
directx.c:3713:13: warning: case value '894720068' not in enumerated type 'WINED3DFORMAT'
utils.c:1227:5: warning: case value '827606349' not in enumerated type 'WINED3DFORMAT'
utils.c:1222:5: warning: case value '827611204' not in enumerated type 'WINED3DFORMAT'
utils.c:1221:5: warning: case value '842094169' not in enumerated type 'WINED3DFORMAT'
utils.c:1239:5: warning: case value '843666497' not in enumerated type 'WINED3DFORMAT'
utils.c:1223:5: warning: case value '844388420' not in enumerated type 'WINED3DFORMAT'
utils.c:1220:5: warning: case value '844715353' not in enumerated type 'WINED3DFORMAT'
utils.c:1224:5: warning: case value '861165636' not in enumerated type 'WINED3DFORMAT'
utils.c:1225:5: warning: case value '877942852' not in enumerated type 'WINED3DFORMAT'
utils.c:1226:5: warning: case value '894720068' not in enumerated type 'WINED3DFORMAT'
utils.c:1228:5: warning: case value '1111970375' not in enumerated type 'WINED3DFORMAT'
utils.c:1229:5: warning: case value '1195525970' not in enumerated type 'WINED3DFORMAT'
utils.c:1241:5: warning: case value '1397249614' not in enumerated type 'WINED3DFORMAT'
utils.c:1240:5: warning: case value '1430804046' not in enumerated type 'WINED3DFORMAT'
utils.c:1219:5: warning: case value '1498831189' not in enumerated type 'WINED3DFORMAT'
utils.c:1777:5: warning: case value '256' not in enumerated type 'WINED3DTRANSFORMSTATETYPE'


My original idea was to extend the syntax used by widl slightly to allow
for injecting those values more directly into the enum itself, and that
required changes to the parser which were hard without the changes I ended
up submitting.

How shall we best tackle this?

Gerald


More information about the wine-devel mailing list