aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mapi/glapi
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2014-03-28 17:43:20 +0100
committermarha <marha@users.sourceforge.net>2014-03-28 17:43:20 +0100
commitf0f09f4aa3cdd0267f58b362a7c9fc5ae0921afd (patch)
treeafbeb028495328a2817aedbac7aae484a2c71a83 /mesalib/src/mapi/glapi
parentbf0cbcc1d00962ef2221cb4ceae87cc5ae737454 (diff)
parentcbfb19790917d271b8ca6156554b16acc802719f (diff)
downloadvcxsrv-f0f09f4aa3cdd0267f58b362a7c9fc5ae0921afd.tar.gz
vcxsrv-f0f09f4aa3cdd0267f58b362a7c9fc5ae0921afd.tar.bz2
vcxsrv-f0f09f4aa3cdd0267f58b362a7c9fc5ae0921afd.zip
Merge remote-tracking branch 'origin/released'
Conflicts: X11/xtrans/Xtrans.c
Diffstat (limited to 'mesalib/src/mapi/glapi')
-rw-r--r--mesalib/src/mapi/glapi/gen/glX_XML.py55
-rw-r--r--mesalib/src/mapi/glapi/gen/glX_doc.py280
-rw-r--r--mesalib/src/mapi/glapi/gen/glX_proto_common.py13
-rw-r--r--mesalib/src/mapi/glapi/gen/gl_XML.py217
4 files changed, 134 insertions, 431 deletions
diff --git a/mesalib/src/mapi/glapi/gen/glX_XML.py b/mesalib/src/mapi/glapi/gen/glX_XML.py
index 03a35b740..12ff291fc 100644
--- a/mesalib/src/mapi/glapi/gen/glX_XML.py
+++ b/mesalib/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.
diff --git a/mesalib/src/mapi/glapi/gen/glX_doc.py b/mesalib/src/mapi/glapi/gen/glX_doc.py
deleted file mode 100644
index 35d068894..000000000
--- a/mesalib/src/mapi/glapi/gen/glX_doc.py
+++ /dev/null
@@ -1,280 +0,0 @@
-#!/usr/bin/env python
-
-# (C) Copyright IBM Corporation 2004, 2005
-# All Rights Reserved.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# on the rights to use, copy, modify, merge, publish, distribute, sub
-# license, and/or sell copies of the Software, and to permit persons to whom
-# the Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice (including the next
-# paragraph) shall be included in all copies or substantial portions of the
-# Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
-# IBM AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-# IN THE SOFTWARE.
-#
-# Authors:
-# Ian Romanick <idr@us.ibm.com>
-
-import gl_XML, glX_XML, glX_proto_common, license
-import sys, getopt
-
-
-class glx_doc_item_factory(glX_proto_common.glx_proto_item_factory):
- """Factory to create GLX protocol documentation oriented objects derived from glItem."""
-
- def create_item(self, name, element, context):
- if name == "parameter":
- return glx_doc_parameter(element, context)
- else:
- return glX_proto_common.glx_proto_item_factory.create_item(self, name, element, context)
-
-
-class glx_doc_parameter(gl_XML.gl_parameter):
- def packet_type(self, type_dict):
- """Get the type string for the packet header
-
- GLX protocol documentation uses type names like CARD32,
- FLOAT64, LISTofCARD8, and ENUM. This function converts the
- type of the parameter to one of these names."""
-
- list_of = ""
- if self.is_array():
- list_of = "LISTof"
-
- t_name = self.get_base_type_string()
- if not type_dict.has_key( t_name ):
- type_name = "CARD8"
- else:
- type_name = type_dict[ t_name ]
-
- return "%s%s" % (list_of, type_name)
-
-
- def packet_size(self):
- p = None
- s = self.size()
- if s == 0:
- a_prod = "n"
- b_prod = self.p_type.size
-
- if not self.count_parameter_list and self.counter:
- a_prod = self.counter
- elif self.count_parameter_list and not self.counter or self.is_output:
- pass
- elif self.count_parameter_list and self.counter:
- b_prod = self.counter
- else:
- raise RuntimeError("Parameter '%s' to function '%s' has size 0." % (self.name, self.context.name))
-
- ss = "%s*%s" % (a_prod, b_prod)
-
- return [ss, p]
- else:
- if s % 4 != 0:
- p = "p"
-
- return [str(s), p]
-
-class PrintGlxProtoText(gl_XML.gl_print_base):
- def __init__(self):
- gl_XML.gl_print_base.__init__(self)
- self.license = ""
-
-
- def printHeader(self):
- return
-
-
- def body_size(self, f):
- # At some point, refactor this function and
- # glXFunction::command_payload_length.
-
- size = 0;
- size_str = ""
- pad_str = ""
- plus = ""
- for p in f.parameterIterateGlxSend():
- [s, pad] = p.packet_size()
- try:
- size += int(s)
- except Exception,e:
- size_str += "%s%s" % (plus, s)
- plus = "+"
-
- if pad != None:
- pad_str = pad
-
- return [size, size_str, pad_str]
-
-
- def print_render_header(self, f):
- [size, size_str, pad_str] = self.body_size(f)
- size += 4;
-
- if size_str == "":
- s = "%u" % ((size + 3) & ~3)
- elif pad_str != "":
- s = "%u+%s+%s" % (size, size_str, pad_str)
- else:
- s = "%u+%s" % (size, size_str)
-
- print ' 2 %-15s rendering command length' % (s)
- print ' 2 %-4u rendering command opcode' % (f.glx_rop)
- return
-
-
- def print_single_header(self, f):
- [size, size_str, pad_str] = self.body_size(f)
- size = ((size + 3) / 4) + 2;
-
- if f.glx_vendorpriv != 0:
- size += 1
-
- print ' 1 CARD8 opcode (X assigned)'
- print ' 1 %-4u GLX opcode (%s)' % (f.opcode_real_value(), f.opcode_real_name())
-
- if size_str == "":
- s = "%u" % (size)
- elif pad_str != "":
- s = "%u+((%s+%s)/4)" % (size, size_str, pad_str)
- else:
- s = "%u+((%s)/4)" % (size, size_str)
-
- print ' 2 %-15s request length' % (s)
-
- if f.glx_vendorpriv != 0:
- print ' 4 %-4u vendor specific opcode' % (f.opcode_value())
-
- print ' 4 GLX_CONTEXT_TAG context tag'
-
- return
-
-
- def print_reply(self, f):
- print ' =>'
- print ' 1 1 reply'
- print ' 1 unused'
- print ' 2 CARD16 sequence number'
-
- if f.output == None:
- print ' 4 0 reply length'
- elif f.reply_always_array:
- print ' 4 m reply length'
- else:
- print ' 4 m reply length, m = (n == 1 ? 0 : n)'
-
-
- output = None
- for x in f.parameterIterateOutputs():
- output = x
- break
-
-
- unused = 24
- if f.return_type != 'void':
- print ' 4 %-15s return value' % (f.return_type)
- unused -= 4
- elif output != None:
- print ' 4 unused'
- unused -= 4
-
- if output != None:
- print ' 4 CARD32 n'
- unused -= 4
-
- if output != None:
- if not f.reply_always_array:
- print ''
- print ' if (n = 1) this follows:'
- print ''
- print ' 4 CARD32 %s' % (output.name)
- print ' %-2u unused' % (unused - 4)
- print ''
- print ' otherwise this follows:'
- print ''
-
- print ' %-2u unused' % (unused)
-
- [s, pad] = output.packet_size()
- print ' %-8s %-15s %s' % (s, output.packet_type( self.type_map ), output.name)
- if pad != None:
- try:
- bytes = int(s)
- bytes = 4 - (bytes & 3)
- print ' %-8u %-15s unused' % (bytes, "")
- except Exception,e:
- print ' %-8s %-15s unused, %s=pad(%s)' % (pad, "", pad, s)
- else:
- print ' %-2u unused' % (unused)
-
-
- def print_body(self, f):
- for p in f.parameterIterateGlxSend():
- [s, pad] = p.packet_size()
- print ' %-8s %-15s %s' % (s, p.packet_type( self.type_map ), p.name)
- if pad != None:
- try:
- bytes = int(s)
- bytes = 4 - (bytes & 3)
- print ' %-8u %-15s unused' % (bytes, "")
- except Exception,e:
- print ' %-8s %-15s unused, %s=pad(%s)' % (pad, "", pad, s)
-
- def printBody(self, api):
- self.type_map = {}
- for t in api.typeIterate():
- self.type_map[ "GL" + t.name ] = t.glx_name
-
-
- # At some point this should be expanded to support pixel
- # functions, but I'm not going to lose any sleep over it now.
-
- for f in api.functionIterateByOffset():
- if f.client_handcode or f.server_handcode or f.vectorequiv or len(f.get_images()):
- continue
-
-
- if f.glx_rop:
- print ' %s' % (f.name)
- self.print_render_header(f)
- elif f.glx_sop or f.glx_vendorpriv:
- print ' %s' % (f.name)
- self.print_single_header(f)
- else:
- continue
-
- self.print_body(f)
-
- if f.needs_reply():
- self.print_reply(f)
-
- print ''
- return
-
-
-if __name__ == '__main__':
- file_name = "gl_API.xml"
-
- try:
- (args, trail) = getopt.getopt(sys.argv[1:], "f:")
- except Exception,e:
- show_usage()
-
- for (arg,val) in args:
- if arg == "-f":
- file_name = val
-
- api = gl_XML.parse_GL_API( file_name, glx_doc_item_factory() )
-
- printer = PrintGlxProtoText()
- printer.Print( api )
diff --git a/mesalib/src/mapi/glapi/gen/glX_proto_common.py b/mesalib/src/mapi/glapi/gen/glX_proto_common.py
index 86d9189a9..ae2c2d581 100644
--- a/mesalib/src/mapi/glapi/gen/glX_proto_common.py
+++ b/mesalib/src/mapi/glapi/gen/glX_proto_common.py
@@ -32,18 +32,15 @@ import string
class glx_proto_item_factory(glX_XML.glx_item_factory):
"""Factory to create GLX protocol oriented objects derived from gl_item."""
- def create_item(self, name, element, context):
- if name == "type":
- return glx_proto_type(element, context)
- else:
- return glX_XML.glx_item_factory.create_item(self, name, element, context)
+ def create_type(self, element, context, category):
+ return glx_proto_type(element, context, category)
class glx_proto_type(gl_XML.gl_type):
- def __init__(self, element, context):
- gl_XML.gl_type.__init__(self, element, context)
+ def __init__(self, element, context, category):
+ gl_XML.gl_type.__init__(self, element, context, category)
- self.glx_name = element.nsProp( "glx_name", None )
+ self.glx_name = element.get( "glx_name" )
return
diff --git a/mesalib/src/mapi/glapi/gen/gl_XML.py b/mesalib/src/mapi/glapi/gen/gl_XML.py
index 3bbc79439..1a2bc2b91 100644
--- a/mesalib/src/mapi/glapi/gen/gl_XML.py
+++ b/mesalib/src/mapi/glapi/gen/gl_XML.py
@@ -26,20 +26,19 @@
# Ian Romanick <idr@us.ibm.com>
from decimal import Decimal
-import libxml2
+import xml.etree.ElementTree as ET
import re, sys, string
+import os.path
import typeexpr
def parse_GL_API( file_name, factory = None ):
- doc = libxml2.readFile( file_name, None, libxml2.XML_PARSE_XINCLUDE + libxml2.XML_PARSE_NOBLANKS + libxml2.XML_PARSE_DTDVALID + libxml2.XML_PARSE_DTDATTR + libxml2.XML_PARSE_DTDLOAD + libxml2.XML_PARSE_NOENT )
- ret = doc.xincludeProcess()
if not factory:
factory = gl_item_factory()
- api = factory.create_item( "api", None, None )
- api.process_element( doc )
+ api = factory.create_api()
+ api.parse_file( file_name )
# After the XML has been processed, we need to go back and assign
# dispatch offsets to the functions that request that their offsets
@@ -51,12 +50,10 @@ def parse_GL_API( file_name, factory = None ):
func.offset = api.next_offset;
api.next_offset += 1
- doc.freeDoc()
-
return api
-def is_attr_true( element, name ):
+def is_attr_true( element, name, default = "false" ):
"""Read a name value from an element's attributes.
The value read from the attribute list must be either 'true' or
@@ -64,7 +61,7 @@ def is_attr_true( element, name ):
value is 'true', non-zero will be returned. An exception will be
raised for any other value."""
- value = element.nsProp( name, None )
+ value = element.get( name, default )
if value == "true":
return 1
elif value == "false":
@@ -254,8 +251,8 @@ class gl_print_base(object):
def real_function_name(element):
- name = element.nsProp( "name", None )
- alias = element.nsProp( "alias", None )
+ name = element.get( "name" )
+ alias = element.get( "alias" )
if alias:
return alias
@@ -324,21 +321,22 @@ def create_parameter_string(parameters, include_names):
class gl_item(object):
- def __init__(self, element, context):
+ def __init__(self, element, context, category):
self.context = context
- self.name = element.nsProp( "name", None )
- self.category = real_category_name( element.parent.nsProp( "name", None ) )
+ self.name = element.get( "name" )
+ self.category = real_category_name( category )
+
return
class gl_type( gl_item ):
- def __init__(self, element, context):
- gl_item.__init__(self, element, context)
- self.size = int( element.nsProp( "size", None ), 0 )
+ def __init__(self, element, context, category):
+ gl_item.__init__(self, element, context, category)
+ self.size = int( element.get( "size" ), 0 )
te = typeexpr.type_expression( None )
tn = typeexpr.type_node()
- tn.size = int( element.nsProp( "size", None ), 0 )
+ tn.size = int( element.get( "size" ), 0 )
tn.integer = not is_attr_true( element, "float" )
tn.unsigned = is_attr_true( element, "unsigned" )
tn.pointer = is_attr_true( element, "pointer" )
@@ -354,11 +352,11 @@ class gl_type( gl_item ):
class gl_enum( gl_item ):
- def __init__(self, element, context):
- gl_item.__init__(self, element, context)
- self.value = int( element.nsProp( "value", None ), 0 )
+ def __init__(self, element, context, category):
+ gl_item.__init__(self, element, context, category)
+ self.value = int( element.get( "value" ), 0 )
- temp = element.nsProp( "count", None )
+ temp = element.get( "count" )
if not temp or temp == "?":
self.default_count = -1
else:
@@ -404,12 +402,12 @@ class gl_enum( gl_item ):
class gl_parameter(object):
def __init__(self, element, context):
- self.name = element.nsProp( "name", None )
+ self.name = element.get( "name" )
- ts = element.nsProp( "type", None )
+ ts = element.get( "type" )
self.type_expr = typeexpr.type_expression( ts, context )
- temp = element.nsProp( "variable_param", None )
+ temp = element.get( "variable_param" )
if temp:
self.count_parameter_list = temp.split( ' ' )
else:
@@ -420,7 +418,7 @@ class gl_parameter(object):
# statement will throw an exception, and the except block will
# take over.
- c = element.nsProp( "count", None )
+ c = element.get( "count" )
try:
count = int(c)
self.count = count
@@ -430,7 +428,7 @@ class gl_parameter(object):
self.count = 0
self.counter = c
- self.count_scale = int(element.nsProp( "count_scale", None ))
+ self.count_scale = int(element.get( "count_scale", "1" ))
elements = (count * self.count_scale)
if elements == 1:
@@ -450,19 +448,19 @@ class gl_parameter(object):
# Pixel data has special parameters.
- self.width = element.nsProp('img_width', None)
- self.height = element.nsProp('img_height', None)
- self.depth = element.nsProp('img_depth', None)
- self.extent = element.nsProp('img_extent', None)
+ self.width = element.get('img_width')
+ self.height = element.get('img_height')
+ self.depth = element.get('img_depth')
+ self.extent = element.get('img_extent')
- self.img_xoff = element.nsProp('img_xoff', None)
- self.img_yoff = element.nsProp('img_yoff', None)
- self.img_zoff = element.nsProp('img_zoff', None)
- self.img_woff = element.nsProp('img_woff', None)
+ self.img_xoff = element.get('img_xoff')
+ self.img_yoff = element.get('img_yoff')
+ self.img_zoff = element.get('img_zoff')
+ self.img_woff = element.get('img_woff')
- self.img_format = element.nsProp('img_format', None)
- self.img_type = element.nsProp('img_type', None)
- self.img_target = element.nsProp('img_target', None)
+ self.img_format = element.get('img_format')
+ self.img_type = element.get('img_type')
+ self.img_target = element.get('img_target')
self.img_pad_dimensions = is_attr_true( element, 'img_pad_dimensions' )
self.img_null_flag = is_attr_true( element, 'img_null_flag' )
@@ -648,17 +646,17 @@ class gl_function( gl_item ):
def process_element(self, element):
- name = element.nsProp( "name", None )
- alias = element.nsProp( "alias", None )
+ name = element.get( "name" )
+ alias = element.get( "alias" )
- if is_attr_true(element, "static_dispatch"):
+ if is_attr_true(element, "static_dispatch", "true"):
self.static_entry_points.append(name)
self.entry_points.append( name )
self.entry_point_api_map[name] = {}
for api in ('es1', 'es2'):
- version_str = element.nsProp(api, None)
+ version_str = element.get(api, 'none')
assert version_str is not None
if version_str != 'none':
version_decimal = Decimal(version_str)
@@ -667,15 +665,15 @@ class gl_function( gl_item ):
version_decimal < self.api_map[api]:
self.api_map[api] = version_decimal
- exec_flavor = element.nsProp('exec', None)
+ exec_flavor = element.get('exec')
if exec_flavor:
self.exec_flavor = exec_flavor
- deprecated = element.nsProp('deprecated', None)
+ deprecated = element.get('deprecated', 'none')
if deprecated != 'none':
self.deprecated = Decimal(deprecated)
- if not is_attr_true(element, 'desktop'):
+ if not is_attr_true(element, 'desktop', 'true'):
self.desktop = False
if alias:
@@ -686,7 +684,7 @@ class gl_function( gl_item ):
# Only try to set the offset when a non-alias entry-point
# is being processed.
- offset = element.nsProp( "offset", None )
+ offset = element.get( "offset" )
if offset:
try:
o = int( offset )
@@ -712,16 +710,12 @@ class gl_function( gl_item ):
parameters = []
return_type = "void"
- child = element.children
- while child:
- if child.type == "element":
- if child.name == "return":
- return_type = child.nsProp( "type", None )
- elif child.name == "param":
- param = self.context.factory.create_item( "parameter", child, self.context)
- parameters.append( param )
-
- child = child.next
+ for child in element.getchildren():
+ if child.tag == "return":
+ return_type = child.get( "type", "void" )
+ elif child.tag == "param":
+ param = self.context.factory.create_parameter(child, self.context)
+ parameters.append( param )
if self.initialized:
@@ -746,7 +740,7 @@ class gl_function( gl_item ):
if param.is_image():
self.images.append( param )
- if element.children:
+ if element.getchildren():
self.initialized = 1
self.entry_point_parameters[name] = parameters
else:
@@ -848,19 +842,20 @@ class gl_function( gl_item ):
class gl_item_factory(object):
"""Factory to create objects derived from gl_item."""
- def create_item(self, item_name, element, context):
- if item_name == "function":
- return gl_function(element, context)
- if item_name == "type":
- return gl_type(element, context)
- elif item_name == "enum":
- return gl_enum(element, context)
- elif item_name == "parameter":
- return gl_parameter(element, context)
- elif item_name == "api":
- return gl_api(self)
- else:
- return None
+ def create_function(self, element, context):
+ return gl_function(element, context)
+
+ def create_type(self, element, context, category):
+ return gl_type(element, context, category)
+
+ def create_enum(self, element, context, category):
+ return gl_enum(element, context, category)
+
+ def create_parameter(self, element, context):
+ return gl_parameter(element, context)
+
+ def create_api(self):
+ return gl_api(self)
class gl_api(object):
@@ -903,66 +898,64 @@ class gl_api(object):
self.functions_by_name = functions_by_name
- def process_element(self, doc):
- element = doc.children
- while element.type != "element" or element.name != "OpenGLAPI":
- element = element.next
- if element:
- self.process_OpenGLAPI(element)
- return
+ def parse_file(self, file_name):
+ doc = ET.parse( file_name )
+ self.process_element(file_name, doc)
- def process_OpenGLAPI(self, element):
- child = element.children
- while child:
- if child.type == "element":
- if child.name == "category":
- self.process_category( child )
- elif child.name == "OpenGLAPI":
- self.process_OpenGLAPI( child )
+ def process_element(self, file_name, doc):
+ element = doc.getroot()
+ if element.tag == "OpenGLAPI":
+ self.process_OpenGLAPI(file_name, element)
+ return
+
- child = child.next
+ def process_OpenGLAPI(self, file_name, element):
+ for child in element.getchildren():
+ if child.tag == "category":
+ self.process_category( child )
+ elif child.tag == "OpenGLAPI":
+ self.process_OpenGLAPI( file_name, child )
+ elif child.tag == '{http://www.w3.org/2001/XInclude}include':
+ href = child.get('href')
+ href = os.path.join(os.path.dirname(file_name), href)
+ self.parse_file(href)
return
def process_category(self, cat):
- cat_name = cat.nsProp( "name", None )
- cat_number = cat.nsProp( "number", None )
+ cat_name = cat.get( "name" )
+ cat_number = cat.get( "number" )
[cat_type, key] = classify_category(cat_name, cat_number)
self.categories[cat_type][key] = [cat_name, cat_number]
- child = cat.children
- while child:
- if child.type == "element":
- if child.name == "function":
- func_name = real_function_name( child )
-
- temp_name = child.nsProp( "name", None )
- self.category_dict[ temp_name ] = [cat_name, cat_number]
-
- if self.functions_by_name.has_key( func_name ):
- func = self.functions_by_name[ func_name ]
- func.process_element( child )
- else:
- func = self.factory.create_item( "function", child, self )
- self.functions_by_name[ func_name ] = func
+ for child in cat.getchildren():
+ if child.tag == "function":
+ func_name = real_function_name( child )
- if func.offset >= self.next_offset:
- self.next_offset = func.offset + 1
+ temp_name = child.get( "name" )
+ self.category_dict[ temp_name ] = [cat_name, cat_number]
+ if self.functions_by_name.has_key( func_name ):
+ func = self.functions_by_name[ func_name ]
+ func.process_element( child )
+ else:
+ func = self.factory.create_function( child, self )
+ self.functions_by_name[ func_name ] = func
- elif child.name == "enum":
- enum = self.factory.create_item( "enum", child, self )
- self.enums_by_name[ enum.name ] = enum
- elif child.name == "type":
- t = self.factory.create_item( "type", child, self )
- self.types_by_name[ "GL" + t.name ] = t
+ if func.offset >= self.next_offset:
+ self.next_offset = func.offset + 1
- child = child.next
+ elif child.tag == "enum":
+ enum = self.factory.create_enum( child, self, cat_name )
+ self.enums_by_name[ enum.name ] = enum
+ elif child.tag == "type":
+ t = self.factory.create_type( child, self, cat_name )
+ self.types_by_name[ "GL" + t.name ] = t
return