[waffle] [PATCH 3/4] waffle: add waffle_string_to_enum()

Chad Versace chad.versace at intel.com
Tue May 5 21:37:20 PDT 2015


On Thu 23 Apr 2015, Emil Velikov wrote:
> On 22 April 2015 at 19:03, Frank Henigman <fjhenigman at google.com> wrote:
> > From: Frank Henigman <fjhenigman at gmail.com>
> >
> > Add waffle_string_to_enum() which, given a string, returns the
> > corresponding enum value.
> > Since the main use is expected to be parsing command lines,
> > the string case does not have to match, and some aliases exist.
> > For example "waffle_context_opengles2" will match WAFFLE_CONTEXT_OPENGL_ES2
> > (note additional underscore in the enum name).
> >
> > Signed-off-by: Frank Henigman <fjhenigman at google.com>
> > ---
> >  include/waffle/waffle.h      |  5 +++++
> >  man/waffle_enum.3.xml        | 24 ++++++++++++++++++++++++
> >  src/waffle/api/waffle_enum.c |  7 +++++++
> >  src/waffle/core/wcore_util.c | 36 ++++++++++++++++++++++++++++++++++++
> >  src/waffle/core/wcore_util.h |  3 +++
> >  src/waffle/waffle.def.in     |  1 +
> >  6 files changed, 76 insertions(+)


> > @@ -83,6 +92,14 @@ enum_cmp_value(const void *v1, const void *v2)
> >
> >  #define NAME_VALUE(name, value) { #name, value },
> >
> > +static struct enum_map_entry enum_map_name[] = {
> > +    WAFFLE_ENUM_LIST(NAME_VALUE)
> > +    // aliases
> > +    { "WAFFLE_CONTEXT_OPENGLES1", WAFFLE_CONTEXT_OPENGL_ES1 },
> > +    { "WAFFLE_CONTEXT_OPENGLES2", WAFFLE_CONTEXT_OPENGL_ES2 },
> > +    { "WAFFLE_CONTEXT_OPENGLES3", WAFFLE_CONTEXT_OPENGL_ES3 },

> What inspired you to add these aliases - was it wflinfo ? No
> objections here (actually I think it's a very nice idea) just curios.

I also like the aliases and the case insensitivity.


More information about the waffle mailing list