On Wed, Apr 22, 2015 at 8:09 PM, Jordan Justen
<jordan.l.jus...@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.  (^:
_______________________________________________
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle

Reply via email to