Skip to content

Commit 2de70fe

Browse files
committed
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]>
1 parent b761dfa commit 2de70fe

File tree

8 files changed

+141
-221
lines changed

8 files changed

+141
-221
lines changed

SConstruct

-7
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,6 @@ else:
5959

6060
Help(opts.GenerateHelpText(env))
6161

62-
# fail early for a common error on windows
63-
if env['gles']:
64-
try:
65-
import libxml2
66-
except ImportError:
67-
raise SCons.Errors.UserError, "GLES requires libxml2-python to build"
68-
6962
#######################################################################
7063
# Environment setup
7164

configure.ac

-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ AM_PROG_CC_C_O
5454
AM_PROG_AS
5555
AC_CHECK_PROGS([MAKE], [gmake make])
5656
AC_CHECK_PROGS([PYTHON2], [python2 python])
57-
AX_PYTHON_MODULE([libxml2], [needed])
5857
AC_PROG_SED
5958
AC_PROG_MKDIR_P
6059

docs/README.WIN32

+7-9
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,15 @@ Recipe
3636
Building on windows requires several open-source packages. These are
3737
steps that work as of this writing.
3838

39-
1) install python 2.7
40-
2) install scons (latest)
41-
3) install mingw, flex, and bison
42-
4) install libxml2 from here: http://www.lfd.uci.edu/~gohlke/pythonlibs
43-
get libxml2-python-2.9.1.win-amd64-py2.7.exe
44-
5) install pywin32 from here: http://www.lfd.uci.edu/~gohlke/pythonlibs
39+
- install python 2.7
40+
- install scons (latest)
41+
- install mingw, flex, and bison
42+
- install pywin32 from here: http://www.lfd.uci.edu/~gohlke/pythonlibs
4543
get pywin32-218.4.win-amd64-py2.7.exe
46-
6) install git
47-
7) download mesa from git
44+
- install git
45+
- download mesa from git
4846
see http://www.mesa3d.org/repository.html
49-
8) run scons
47+
- run scons
5048

5149
General
5250
-------

docs/install.html

-4
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ <h2>1.1 General</h2>
4444
</li>
4545
<li>python - Python is needed for building the Gallium components.
4646
Version 2.6.4 or later should work.
47-
<br>
48-
<br>
49-
To build OpenGL ES 1.1 and 2.0 you'll also need
50-
<a href="http://xmlsoft.org/sources/win32/python/libxml2-python-2.7.7.win32-py2.7.exe">libxml2-python</a>.
5147
</li>
5248
</ul>
5349

m4/ax_python_module.m4

-49
This file was deleted.

src/mapi/glapi/gen/glX_XML.py

+24-31
Original file line numberDiff line numberDiff line change
@@ -33,29 +33,27 @@
3333
class glx_item_factory(gl_XML.gl_item_factory):
3434
"""Factory to create GLX protocol oriented objects derived from gl_item."""
3535

36-
def create_item(self, name, element, context):
37-
if name == "function":
38-
return glx_function(element, context)
39-
elif name == "enum":
40-
return glx_enum(element, context)
41-
elif name == "api":
42-
return glx_api(self)
43-
else:
44-
return gl_XML.gl_item_factory.create_item(self, name, element, context)
36+
def create_function(self, element, context):
37+
return glx_function(element, context)
38+
39+
def create_enum(self, element, context, category):
40+
return glx_enum(element, context, category)
41+
42+
def create_api(self):
43+
return glx_api(self)
4544

4645

4746
class glx_enum(gl_XML.gl_enum):
48-
def __init__(self, element, context):
49-
gl_XML.gl_enum.__init__(self, element, context)
47+
def __init__(self, element, context, category):
48+
gl_XML.gl_enum.__init__(self, element, context, category)
5049

5150
self.functions = {}
5251

53-
child = element.children
54-
while child:
55-
if child.type == "element" and child.name == "size":
56-
n = child.nsProp( "name", None )
57-
c = child.nsProp( "count", None )
58-
m = child.nsProp( "mode", None )
52+
for child in element.getchildren():
53+
if child.tag == "size":
54+
n = child.get( "name" )
55+
c = child.get( "count" )
56+
m = child.get( "mode", "set" )
5957

6058
if not c:
6159
c = self.default_count
@@ -70,8 +68,6 @@ def __init__(self, element, context):
7068
if not self.functions.has_key(n):
7169
self.functions[ n ] = [c, mode]
7270

73-
child = child.next
74-
7571
return
7672

7773

@@ -120,10 +116,10 @@ def process_element(self, element):
120116
# appears after the function that it aliases.
121117

122118
if not self.vectorequiv:
123-
self.vectorequiv = element.nsProp("vectorequiv", None)
119+
self.vectorequiv = element.get("vectorequiv")
124120

125121

126-
name = element.nsProp("name", None)
122+
name = element.get("name")
127123
if name == self.name:
128124
for param in self.parameters:
129125
self.parameters_by_name[ param.name ] = param
@@ -135,12 +131,11 @@ def process_element(self, element):
135131
self.counter_list.append(param.counter)
136132

137133

138-
child = element.children
139-
while child:
140-
if child.type == "element" and child.name == "glx":
141-
rop = child.nsProp( 'rop', None )
142-
sop = child.nsProp( 'sop', None )
143-
vop = child.nsProp( 'vendorpriv', None )
134+
for child in element.getchildren():
135+
if child.tag == "glx":
136+
rop = child.get( 'rop' )
137+
sop = child.get( 'sop' )
138+
vop = child.get( 'vendorpriv' )
144139

145140
if rop:
146141
self.glx_rop = int(rop)
@@ -152,12 +147,12 @@ def process_element(self, element):
152147
self.glx_vendorpriv = int(vop)
153148
self.glx_vendorpriv_names.append(name)
154149

155-
self.img_reset = child.nsProp( 'img_reset', None )
150+
self.img_reset = child.get( 'img_reset' )
156151

157152
# The 'handcode' attribute can be one of 'true',
158153
# 'false', 'client', or 'server'.
159154

160-
handcode = child.nsProp( 'handcode', None )
155+
handcode = child.get( 'handcode', 'false' )
161156
if handcode == "false":
162157
self.server_handcode = 0
163158
self.client_handcode = 0
@@ -179,8 +174,6 @@ def process_element(self, element):
179174
self.reply_always_array = gl_XML.is_attr_true( child, 'always_array' )
180175
self.dimensions_in_reply = gl_XML.is_attr_true( child, 'dimensions_in_reply' )
181176

182-
child = child.next
183-
184177

185178
# Do some validation of the GLX protocol information. As
186179
# new tests are discovered, they should be added here.

src/mapi/glapi/gen/glX_proto_common.py

+5-8
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,15 @@
3232
class glx_proto_item_factory(glX_XML.glx_item_factory):
3333
"""Factory to create GLX protocol oriented objects derived from gl_item."""
3434

35-
def create_item(self, name, element, context):
36-
if name == "type":
37-
return glx_proto_type(element, context)
38-
else:
39-
return glX_XML.glx_item_factory.create_item(self, name, element, context)
35+
def create_type(self, element, context, category):
36+
return glx_proto_type(element, context, category)
4037

4138

4239
class glx_proto_type(gl_XML.gl_type):
43-
def __init__(self, element, context):
44-
gl_XML.gl_type.__init__(self, element, context)
40+
def __init__(self, element, context, category):
41+
gl_XML.gl_type.__init__(self, element, context, category)
4542

46-
self.glx_name = element.nsProp( "glx_name", None )
43+
self.glx_name = element.get( "glx_name" )
4744
return
4845

4946

0 commit comments

Comments
 (0)