[Piglit] [PATCH 10/14] glapi: Parse the GLES3 core header for piglit-dispatch.

Paul Berry stereotype441 at gmail.com
Wed Jun 12 14:06:33 PDT 2013


On 5 June 2013 16:14, Eric Anholt <eric at anholt.net> wrote:

> This gets us piglit-dispatch support for all the core functions of
> GLES2/3.
> ---
>  cmake/piglit_glapi.cmake |  1 +
>  glapi/parse_glspec.py    | 41 ++++++++++++++++++++++++++++++++++++++++-
>  2 files changed, 41 insertions(+), 1 deletion(-)
>
> diff --git a/cmake/piglit_glapi.cmake b/cmake/piglit_glapi.cmake
> index 368c1ca..899c7ee 100644
> --- a/cmake/piglit_glapi.cmake
> +++ b/cmake/piglit_glapi.cmake
> @@ -34,6 +34,7 @@ set(piglit_glapi_inputs
>         ${piglit_glapi_src_dir}/gl.spec
>         ${piglit_glapi_src_dir}/enum.spec
>         ${piglit_glapi_src_dir}/enumext.spec
> +       ${piglit_glapi_src_dir}/GLES3/gl3.h
>         )
>
>  add_custom_command(
> diff --git a/glapi/parse_glspec.py b/glapi/parse_glspec.py
> index ef6143c..163de70 100644
> --- a/glapi/parse_glspec.py
> +++ b/glapi/parse_glspec.py
> @@ -447,6 +447,43 @@ class Api(object):
>              for alias in attributes['alias']:
>                  self.synonyms.add_alias(name, alias)
>
> +    def read_gles_header(self, f):
> +        category = 'GL_ES_VERSION_2_0'
> +        for line in f:
> +            # The GLES gl3.h has typedefs, tokens, and prototypes,
> +            # each listed after a comment indicating whether they're
> +            # part of 2.0 core or 3.0 core.
> +            if re.match(r'/\* OpenGL ES 2.0 \*/', line):
> +                category = 'GL_ES_VERSION_2_0'
> +            elif re.match(r'/\* OpenGL ES 3.0 \*/', line):
> +                category = 'GL_ES_VERSION_3_0'
> +
> +            m = re.match(r'GL_APICALL', line)
> +            if m:
> +                # We do the regexp in two parts to make sure that we
> +                # actually do catch all the GL_APICALLs.
> +                m =
> re.match(r'^GL_APICALL\s*(.*)\s*GL_APIENTRY\s*gl(\w*)\s\((.*)\).*$', line)
> +                return_type, name, args = m.groups()
> +
> +                return_type = return_type.strip()
> +                args = args.split(', ')
> +
> +                if args[0] == 'void':
> +                    args.remove('void')
>

How about:

if args == ['void']:
    args = []

Just so that it doesn't look like this is supposed to handle foo(void, int
x) or any other such nonsense.


> +                param_names = [None] * len(args)
> +                param_types = [None] * len(args)
> +                i = 0
> +                for arg in args:
> +                    splitloc = max(arg.rfind(' '), arg.rfind('*'))
> +                    param_type = arg[:splitloc + 1]
> +                    param_name = arg[splitloc + 1:]
> +
> +                    param_types[i] = param_type
> +                    param_names[i] = param_name
> +                    i += 1
>

Slightly terser (and more conventional Python, IMHO) would be:

param_names = []
param_types = []
for arg in args:
    splitloc = max(arg.rfind(' '), arg.find('*'))
    param_types.append(arg[:splitloc + 1])
    param_names.append(arg[splitloc + 1:])


I'm nit-picking, though.  With or without these two changes, the patch is:

Reviewed-by: Paul Berry <stereotype441 at gmail.com>


> +
> +                self.add_function(name, return_type, param_names,
> param_types, category)
> +
>      # Convert each line in the enumext.spec file into a key/value pair
>      # in self.enums, mapping an enum name to a dict.  For example, the
>      # following enumext.spec input:
> @@ -495,5 +532,7 @@ if __name__ == '__main__':
>          api.read_enumext_spec(f)
>      with open(sys.argv[4]) as f:
>          api.read_enumext_spec(f)
> -    with open(sys.argv[5], 'w') as f:
> +    with open(sys.argv[5]) as f:
> +        api.read_gles_header(f)
> +    with open(sys.argv[6], 'w') as f:
>          f.write(api.to_json())
> --
> 1.8.3.rc0
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20130612/955ff10d/attachment.html>


More information about the Piglit mailing list