summaryrefslogtreecommitdiffstats
path: root/src/mapi/glapi/gen/glX_XML.py
diff options
context:
space:
mode:
authorJosé Fonseca <[email protected]>2014-03-24 15:41:08 +0000
committerJosé Fonseca <[email protected]>2014-03-26 13:51:32 +0000
commit2de70fe23f320ce4f559e37057fe07b7af99cf5a (patch)
tree16806aa819e81b03cb4be45144f99d6e29ae1cd8 /src/mapi/glapi/gen/glX_XML.py
parentb761dfa0c3de4bc69a5b8bdf6cb9f6993ad7173d (diff)
mapi/glapi: Use ElementTree instead of libxml2.
It is quite hard to meet the dependency of the libxml2 python bindings outside Linux, and in particularly on MacOSX; whereas ElementTree is part of Python's standard library. ElementTree is more limited than libxml2: no DTD verification, defaults from DTD, or XInclude support, but none of these limitations is serious enough to justify using libxml2. In fact, it was easier to refactor the code to use ElementTree than to try to get libxml2 python bindings. In the process, gl_item_factory class was refactored so that there is one method for each kind of object to be created, as it simplifies things substantially. I confirmed that precisely the same output is generated for GL/GLX/GLES. v2: Remove m4/ax_python_module.m4 as suggested by Matt Turner. Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/mapi/glapi/gen/glX_XML.py')
-rw-r--r--src/mapi/glapi/gen/glX_XML.py55
1 files changed, 24 insertions, 31 deletions
diff --git a/src/mapi/glapi/gen/glX_XML.py b/src/mapi/glapi/gen/glX_XML.py
index 03a35b740eb..12ff291fc1b 100644
--- a/src/mapi/glapi/gen/glX_XML.py
+++ b/src/mapi/glapi/gen/glX_XML.py
@@ -33,29 +33,27 @@ import sys, getopt, string
class glx_item_factory(gl_XML.gl_item_factory):
"""Factory to create GLX protocol oriented objects derived from gl_item."""
- def create_item(self, name, element, context):
- if name == "function":
- return glx_function(element, context)
- elif name == "enum":
- return glx_enum(element, context)
- elif name == "api":
- return glx_api(self)
- else:
- return gl_XML.gl_item_factory.create_item(self, name, element, context)
+ def create_function(self, element, context):
+ return glx_function(element, context)
+
+ def create_enum(self, element, context, category):
+ return glx_enum(element, context, category)
+
+ def create_api(self):
+ return glx_api(self)
class glx_enum(gl_XML.gl_enum):
- def __init__(self, element, context):
- gl_XML.gl_enum.__init__(self, element, context)
+ def __init__(self, element, context, category):
+ gl_XML.gl_enum.__init__(self, element, context, category)
self.functions = {}
- child = element.children
- while child:
- if child.type == "element" and child.name == "size":
- n = child.nsProp( "name", None )
- c = child.nsProp( "count", None )
- m = child.nsProp( "mode", None )
+ for child in element.getchildren():
+ if child.tag == "size":
+ n = child.get( "name" )
+ c = child.get( "count" )
+ m = child.get( "mode", "set" )
if not c:
c = self.default_count
@@ -70,8 +68,6 @@ class glx_enum(gl_XML.gl_enum):
if not self.functions.has_key(n):
self.functions[ n ] = [c, mode]
- child = child.next
-
return
@@ -120,10 +116,10 @@ class glx_function(gl_XML.gl_function):
# appears after the function that it aliases.
if not self.vectorequiv:
- self.vectorequiv = element.nsProp("vectorequiv", None)
+ self.vectorequiv = element.get("vectorequiv")
- name = element.nsProp("name", None)
+ name = element.get("name")
if name == self.name:
for param in self.parameters:
self.parameters_by_name[ param.name ] = param
@@ -135,12 +131,11 @@ class glx_function(gl_XML.gl_function):
self.counter_list.append(param.counter)
- child = element.children
- while child:
- if child.type == "element" and child.name == "glx":
- rop = child.nsProp( 'rop', None )
- sop = child.nsProp( 'sop', None )
- vop = child.nsProp( 'vendorpriv', None )
+ for child in element.getchildren():
+ if child.tag == "glx":
+ rop = child.get( 'rop' )
+ sop = child.get( 'sop' )
+ vop = child.get( 'vendorpriv' )
if rop:
self.glx_rop = int(rop)
@@ -152,12 +147,12 @@ class glx_function(gl_XML.gl_function):
self.glx_vendorpriv = int(vop)
self.glx_vendorpriv_names.append(name)
- self.img_reset = child.nsProp( 'img_reset', None )
+ self.img_reset = child.get( 'img_reset' )
# The 'handcode' attribute can be one of 'true',
# 'false', 'client', or 'server'.
- handcode = child.nsProp( 'handcode', None )
+ handcode = child.get( 'handcode', 'false' )
if handcode == "false":
self.server_handcode = 0
self.client_handcode = 0
@@ -179,8 +174,6 @@ class glx_function(gl_XML.gl_function):
self.reply_always_array = gl_XML.is_attr_true( child, 'always_array' )
self.dimensions_in_reply = gl_XML.is_attr_true( child, 'dimensions_in_reply' )
- child = child.next
-
# Do some validation of the GLX protocol information. As
# new tests are discovered, they should be added here.