On 18 February 2015 at 22:32, Jordan Justen <[email protected]> wrote:
> Signed-off-by: Jordan Justen <[email protected]>
> Reviewed-by: Chad Versace <[email protected]>
> ---
>  tests/util/gen_dispatch.py                | 21 ++++++++++++++++++-
>  tests/util/piglit-util-gl-enum-gen.c.mako | 35 
> +++++++++++++++++++++++++++++++
>  tests/util/piglit-util-gl.h               |  9 ++++++++
>  3 files changed, 64 insertions(+), 1 deletion(-)
...
> diff --git a/tests/util/piglit-util-gl-enum-gen.c.mako 
> b/tests/util/piglit-util-gl-enum-gen.c.mako
> index e22a75d..729abef 100644
> --- a/tests/util/piglit-util-gl-enum-gen.c.mako
> +++ b/tests/util/piglit-util-gl-enum-gen.c.mako
> @@ -50,4 +50,39 @@ piglit_get_prim_name(GLenum prim)
>  >-------default: return "(unrecognized enum)";
>  >-------}
>  }
> +
> +struct gl_name_to_enum {
> +>-------const char *name;
> +>-------GLenum _enum;
> +};
> +
> +static int
> +compare_enum_name(const void *a, const void *b)
> +{
> +>-------return strcmp(((struct gl_name_to_enum*)a)->name,
> +>-------              ((struct gl_name_to_enum*)b)->name);
> +}
> +
> +GLenum
> +piglit_get_gl_enum_from_name(const char *name)
> +{
> +>-------static struct gl_name_to_enum names[] = {
Depending on how friendly the compiler is one might want to make this
"static const" and move the table outside of the function.

> +% for enum in sorted_enums_by_name:
> +>------->-------{ "${enum.name}", ${enum.c_num_literal} },
> +% endfor
> +>-------};
> +>-------struct gl_name_to_enum key = { name, 0 };
> +>-------struct gl_name_to_enum *result;
> +
> +>-------result = (struct gl_name_to_enum*)
> +>------->-------bsearch(&key,
> +>------->-------        names, ARRAY_SIZE(names), sizeof names[0],
> +>------->-------        compare_enum_name);
> +
> +>-------if (result == NULL)
> +>------->-------abort();
Is it me or does this look a bit excessive - none of the other util_gl
functions go that far. How about just printing a catchy error message
:-P

Cheers,
Emil
_______________________________________________
Piglit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to