[waffle] [PATCH 1/4] waffle: put waffle_enum items in a macro
Emil Velikov
emil.l.velikov at gmail.com
Thu Apr 23 01:34:30 PDT 2015
On 23 April 2015 at 02:07, Frank Henigman <fjhenigman at google.com> wrote:
> On Wed, Apr 22, 2015 at 8:09 PM, Jordan Justen
> <jordan.l.justen at intel.com> wrote:
>> On 2015-04-22 11:03:47, Frank Henigman wrote:
>>> List all waffle_enum items in a big #define to avoid duplicating
>>> the list when a case is needed for each item, e.g. enum to string.
>>
>> This looks kind of yucky. :)
>>
>> When you recently mentioned the idea of changing wflinfo to be written
>> in python, it made me think about python bindings for waffle.
>>
>> This lead me to think that it might be nice if the waffle API was
>> defined by something like XML. This would allow us to generate
>> waffle.h, python bindings, and things like this enum to string
>> mapping.
>>
>> We do something similar (enum to string mapping) on the OpenGL API in
>> piglit.
>>
>> -Jordan
>
> There seem to be three ways to generate the desired code:
> - manually repeating lists of stuff
> - with the preprocessor, as in this patch
> - with external definitions and scripts
> What's the right tool for job? Repetition might be ok if you only
> need something in a couple places, but gets old fast if you have to
> edit six places every time you want to add an item to a list. XML and
> scripts might be appropriate if you need to do something complicated,
> something the preprocessor can't do.
> I chose middle ground here, to get rid of repetition as simply as possible.
> FWIW the macro list pattern has already been introduced to waffle.
> See wgbm_platform.h.
>
> Is your objection purely for aesthetic reasons or is there some
> technical drawback?
> If aesthetics are important, would it make any difference if we move
> the list macro out of the public header and into a private header?
> Then we'd be repeating the list once, but subsequent uses would employ
> the private macro. Though this would also deprive waffle users of the
> chance to use the macro.
>
> "Yucky" is in the eye of the beholder. (^:
>
FWIW I also find it yucky - be that here or in gbm_platform.h. I
withheld my objection in the latter as I felt that 1) it's an internal
header and 2) I may have been bashing a bit too much on your
contributions :-)
Although for a public header I would seriously object against this -
ideally something like XML can be used, although if you (or others)
feel like it's an overkill, I would be ok with moving it into internal
header.
-Emil
More information about the waffle
mailing list