[Piglit] [PATCH 10/15] piglit-dispatch: Code generation script

Eric Anholt eric at anholt.net
Mon Mar 5 23:16:45 PST 2012


On Fri,  2 Mar 2012 15:40:28 -0800, Paul Berry <stereotype441 at gmail.com> wrote:
> This is the first in a series of patches that replaces GLEW with a new
> mechanism called "piglit-dispatch".  This patch adds the script that
> will be used by piglit-dispatch to build its generated code.
> 
> The input to the code generation script is a set of XML files
> describing the GL API, in the same form as used by Mesa.  For the time
> being, these files can be found at
> git://github.com/stereotype441/glapi.git.

From talking today, it sounds like investigating glspec as a source for
this instead of the XML is very promising.  But I'll review it anyway.

I have to say: This was really nice code to read.  I'm usually not a fan
of python (I tend to find python code impenetrable), but I feel like I
understand what this code is doing, and I understand python in general
better as a result.

> +# Generate a top-of-file comment cautioning that the file is
> +# auto-generated and should not be manually edited.
> +def generated_boilerplate():
> +    return """\
> +/**
> + * This file was automatically generated by the script {0!r}.
> + *
> + * DO NOT EDIT!
> + *
> + * To regenerate, run "make piglit_dispatch_gen" from the toplevel directory.
> + */
> +""".format(os.path.basename(sys.argv[0]))

Even though the files are generated, and they're describing an API in a
way that may or may not be copyrightable, it's probably a good idea to
put a license on it so people know they can at least use it in the usual
permissive way.

> +    # Generate a list of Function objects representing all functions
> +    # in the API.  The resulting list is sorted by function name.
> +    def compute_unique_functions(self):
> +	functions = []
> +	names_used = set()
> +	for f in self.__functions:
> +	    if f.name in names_used:
> +		continue
> +	    functions.append(f)
> +	functions.sort(key = lambda f: f.name)
> +	return functions

I was surprised to see this function -- I would have assumed that the
parsed Api contained uniquely-named Functions in the first place.  Is it
to do with parsing GL/GLES variants of XML or something?  Are those
all exact matches in terms of signature?


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20120305/b4a04606/attachment.pgp>


More information about the Piglit mailing list