On 03/31/2016 06:04 PM, Dylan Baker wrote:
This is the first part of a much larger project I'm working on to
overhaul the generators. The end goal is to use mako templates rather
than a massive series of print statements, be python 2.7 (the current)
and python 3.3+ (I might be talked into support 3.2 if someone has a
really good case) compatible, and to use the Khronos XML instead of
mesa's hand rolled XML.

Obviously that's a rather large project, and this is ~40 patches to get
started. In general this is style cleanups, removal of deprecated
functionality, usage of python features rather than hand rolling things,
and some cleanups/optimizations in the gl_XML and glX_XML modules, which
are used as modules by most of the generators.

The first set of patches (the ones that are prefaced with just glapi:)
make a single kind of change across all of the python files. I made this
choice since this series was originally more than 100 patches, and
that's just crazy for basic cleanups.

I have verified that this only produces whitespace changes between
master and the tip of this series, and further that piglit shows no
changes between the two.

This is available on freedesktop.org:
git://people.freedesktop.org/~dbaker/mesa wip/glapi-cleanup

I do not have mesa push access.

I'm all in favor of cleaning up and simplifying this generator code (though I don't yet have experience with mako).

The original python code is probably nearly 15 years old now and even some of that was based some older .h template code that I originally wrote.

Here's something that could be simplified:

The glapi/glapitemp.h file is basically a remnant of the pre-python code. It's included by glapi_nop.c and glapi_dispatch.c to generate no-op functions and the actual GL entrypoints (when not using X86 assembly).

We should get rid of glapitemp.h and just generate glapi_nop.c and glapi_dispatch.c directly with Python.

There's some weird usage of glapitemp.h in src/mesa/drivers/x11/glxapi.c and src/mesa/drivers/osmesa/osmesa.c that seems like terrible hacks and can hopefully be fixed in some other way.

Also, Chia-I Wu added a layer of complexity to glapi that I've never been able to understand. I don't know if you plan on untangling that code.

The series mostly looks OK to me but I have a few comments coming.

-Brian




Dylan Baker (41):
   glapi: clean imports in python files
   glapi: encode python files in utf-8 rather than ascii
   glapi: Update copyright in python files to cover more than IBM
   glapi: remove unnecessary semi-colons in python
   glapi: use python's textwrap.dedent to make code readable
   glapi: normalize python newlines
   glapi: remove useless returns from python code
   glapi: Fix whitespace in python files.
   glapi: fix singleton comparisons to use 'is' in python
   glapi: Don't use string module in python modules
   glapi: remove superflous parens in python
   glapi: have only one statement per line in python files.
   glapi: replace deprecated has_key method in python
   glapi: use xrange instead of range in python
   glapi: remove useless 0 start parameter for (x)range
   glapi: Use booleans in python code.
   glapi: replace RuntimeError with asserts or Exception
   glapi: gl_XML.py: use python's iter() function rather than calling
     __iter__
   glapi: gl_XML.py: remove gl_api.enumIterateByName
   glapi: gl_XML.py: make gl_api.categoryIterate a generator
   glapi: gl_XML.py: simplify gl_api.functionIterateByOffset
   glapi: gl_XML.py: convert gl_api.functionIterateByOffset to a
     generator
   glapi: gl_XML.py: use collections to simplify
     functionsIterateByCategory
   glapi: gl_XML.py: rework gl_api.functionIterateByOffset
   glapi: gl_XML.py: simplify is_attr_true
   glapi: gl_XML.py: avoid unnecessary method call
   glapi: gl_XML.py: store compiled re as a module variable
   glapi: gl_XML.py: add missing method prototype.
   glapi: gl_XML.py: refactor out extra else statement
   glapi: gl_XML.py: return a tuple from gl_parameter.get_dimensions
   glapi: glX_proto_common.py: return variable from
     glx_print_proto.size_call
   glapi: glX_proto_common.py: remove commented out code.
   glapi: glX_proto_common.py: use python's _ for unused values
   glapi: glX_proto_send.py: don't unpack useless values.
   glapi: glX_proto_send.py: Don't shadow builtins.
   glapi: glX_proto_send.py: remove useless pass keyword
   glapi: glX_proto_send.py: simplify XCB string conversion
   glapi: glX_proto_size.py: Remove dead code.
   glapi: glX_server_table.py: use math.log instead of hand coded log2
     function
   glapi: gl_x86_asm.py: simplify method with sum and generator
   glapi: gl_x86-64_asm.py: use _ for unused variable

  src/mapi/glapi/gen/apiexec.py          |    5 +-
  src/mapi/glapi/gen/glX_XML.py          |  141 +-
  src/mapi/glapi/gen/glX_proto_common.py |   23 +-
  src/mapi/glapi/gen/glX_proto_recv.py   |  100 +-
  src/mapi/glapi/gen/glX_proto_send.py   |  653 ++++-----
  src/mapi/glapi/gen/glX_proto_size.py   |  272 ++--
  src/mapi/glapi/gen/glX_server_table.py |   78 +-
  src/mapi/glapi/gen/gl_SPARC_asm.py     |   21 +-
  src/mapi/glapi/gen/gl_XML.py           |  517 +++----
  src/mapi/glapi/gen/gl_apitemp.py       |  192 ++-
  src/mapi/glapi/gen/gl_enums.py         |  190 ++-
  src/mapi/glapi/gen/gl_genexec.py       |   12 +-
  src/mapi/glapi/gen/gl_gentable.py      |   38 +-
  src/mapi/glapi/gen/gl_procs.py         |   70 +-
  src/mapi/glapi/gen/gl_table.py         |   47 +-
  src/mapi/glapi/gen/gl_x86-64_asm.py    |   41 +-
  src/mapi/glapi/gen/gl_x86_asm.py       |   36 +-
  src/mapi/glapi/gen/license.py          |    6 +-
  src/mapi/glapi/gen/remap_helper.py     |   16 +-
  src/mapi/glapi/gen/static_data.py      | 2471 ++++++++++++++++----------------
  src/mapi/glapi/gen/typeexpr.py         |  120 +-
  21 files changed, 2322 insertions(+), 2727 deletions(-)


_______________________________________________
mesa-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to