summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon TURNEY <jon.turney@dronecode.org.uk>2014-07-30 17:15:47 +0100
committerJon TURNEY <jon.turney@dronecode.org.uk>2014-12-12 18:07:29 +0000
commit6e0054f587fad7b3671de942435ddf9437304382 (patch)
treeb9e193fd763c690b1fe354bdf1826eb2357ba5a7
parent68122584cc05b02cf2ed9101fb3834c42916cb97 (diff)
Improve code generator to deal with latest Khronos OpenGL registry XMLcygwin-patches-for-1.16
Refactor of parsing the <proto> XML element Include all text from the param element, in the order it appears in the xml document, as part of the formal parameter definition This is needed to correctly handle the XML description added in svn r27498 of glPathGlyphIndexRangeNV()'s baseAndCount parameter of type GLuint[2] Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
-rwxr-xr-xhw/xwin/glx/gen_gl_wrappers.py101
1 files changed, 52 insertions, 49 deletions
diff --git a/hw/xwin/glx/gen_gl_wrappers.py b/hw/xwin/glx/gen_gl_wrappers.py
index 69ab1efa9..5f4526b9d 100755
--- a/hw/xwin/glx/gen_gl_wrappers.py
+++ b/hw/xwin/glx/gen_gl_wrappers.py
@@ -123,6 +123,38 @@ else:
errWarn = sys.stderr
diag = open(diagFilename, 'w')
+def ParseCmdRettype(cmd):
+ proto = noneStr(cmd.elem.find('proto'))
+ rettype = noneStr(proto.text)
+ if rettype.lower() != "void ":
+ plist = ([t for t in proto.itertext()])
+ rettype = ''.join(plist[:-1])
+ rettype = rettype.strip()
+ return rettype
+
+def ParseCmdParams(cmd):
+ params = cmd.elem.findall('param')
+ plist = []
+ for param in params:
+ # construct the formal parameter definition from ptype and name
+ # elements, also using any text found around these in the
+ # param element, in the order it appears in the document
+ paramtype = ''
+ # also extract the formal parameter name from the name element
+ paramname = ''
+ for t in param.iter():
+ if t.tag == 'ptype' or t.tag == 'param':
+ paramtype = paramtype + noneStr(t.text)
+ if t.tag == 'name':
+ paramname = t.text + '_'
+ paramtype = paramtype + ' ' + paramname
+ if t.tail is not None:
+ paramtype = paramtype + t.tail.strip()
+
+ plist.append((paramtype, paramname))
+
+ return plist
+
class PreResolveOutputGenerator(OutputGenerator):
def __init__(self,
errFile = sys.stderr,
@@ -179,25 +211,16 @@ class WrapperOutputGenerator(OutputGenerator):
if prefix == 'wgl' and not name in used_wgl_ext_fns:
return
- proto=noneStr(cmd.elem.find('proto'))
- rettype=noneStr(proto.text)
- if rettype.lower()!="void ":
- plist = ([t for t in proto.itertext()])
- rettype = ''.join(plist[:-1])
- rettype=rettype.strip()
+ rettype = ParseCmdRettype(cmd)
+ plist = ParseCmdParams(cmd)
+
if staticwrappers: self.outFile.write("static ")
self.outFile.write("%s %sWrapper("%(rettype, name))
- params = cmd.elem.findall('param')
- plist=[]
- for param in params:
- paramlist = ([t for t in param.itertext()])
- paramtype = ''.join(paramlist[:-1])
- paramname = paramlist[-1]
- plist.append((paramtype, paramname))
+
Comma=""
if len(plist):
for ptype, pname in plist:
- self.outFile.write("%s%s%s_"%(Comma, ptype, pname))
+ self.outFile.write("%s%s"%(Comma, ptype))
Comma=", "
else:
self.outFile.write("void")
@@ -218,7 +241,7 @@ class WrapperOutputGenerator(OutputGenerator):
Comma=""
for ptype, pname in plist:
- self.outFile.write("%s%s_"%(Comma, pname))
+ self.outFile.write("%s%s"%(Comma, pname))
Comma=", "
# for GL 1.2+ functions, generate stdcall wrappers which use wglGetProcAddress()
@@ -244,7 +267,7 @@ class WrapperOutputGenerator(OutputGenerator):
Comma=""
for ptype, pname in plist:
- self.outFile.write("%s%s_"%(Comma, pname))
+ self.outFile.write("%s%s"%(Comma, pname))
Comma=", "
self.outFile.write(" );\n}\n\n")
@@ -270,24 +293,14 @@ class ThunkOutputGenerator(OutputGenerator):
def genCmd(self, cmd, name):
OutputGenerator.genCmd(self, cmd, name)
- proto=noneStr(cmd.elem.find('proto'))
- rettype=noneStr(proto.text)
- if rettype.lower()!="void ":
- plist = ([t for t in proto.itertext()])
- rettype = ''.join(plist[:-1])
- rettype=rettype.strip()
+ rettype = ParseCmdRettype(cmd)
+ plist = ParseCmdParams(cmd)
+
self.outFile.write("%s %sWrapper("%(rettype, name))
- params = cmd.elem.findall('param')
- plist=[]
- for param in params:
- paramlist = ([t for t in param.itertext()])
- paramtype = ''.join(paramlist[:-1])
- paramname = paramlist[-1]
- plist.append((paramtype, paramname))
Comma=""
if len(plist):
for ptype, pname in plist:
- self.outFile.write("%s%s%s_"%(Comma, ptype, pname))
+ self.outFile.write("%s%s"%(Comma, ptype))
Comma=", "
else:
self.outFile.write("void")
@@ -303,7 +316,7 @@ class ThunkOutputGenerator(OutputGenerator):
Comma=""
for ptype, pname in plist:
- self.outFile.write("%s%s_"%(Comma, pname))
+ self.outFile.write("%s%s"%(Comma, pname))
Comma=", "
# for GL 1.2+ functions, generate wrappers which use wglGetProcAddress()
@@ -317,7 +330,7 @@ class ThunkOutputGenerator(OutputGenerator):
Comma=""
for ptype, pname in plist:
- self.outFile.write("%s%s_"%(Comma, pname))
+ self.outFile.write("%s%s"%(Comma, pname))
Comma=", "
self.outFile.write(" );\n}\n\n")
@@ -368,28 +381,18 @@ class ShimOutputGenerator(OutputGenerator):
def genCmd(self, cmd, name):
OutputGenerator.genCmd(self, cmd, name)
+ # for GL functions which are in the ABI, generate a shim which calls the function via GetProcAddress
if not self.OldVersion:
return
- # for GL functions which are in the ABI, generate a shim which calls the function via GetProcAddress
- proto=noneStr(cmd.elem.find('proto'))
- rettype=noneStr(proto.text)
- if rettype.lower()!="void ":
- plist = ([t for t in proto.itertext()])
- rettype = ''.join(plist[:-1])
- rettype=rettype.strip()
+ rettype = ParseCmdRettype(cmd)
+ plist = ParseCmdParams(cmd)
+
self.outFile.write("%s %s("%(rettype, name))
- params = cmd.elem.findall('param')
- plist=[]
- for param in params:
- paramlist = ([t for t in param.itertext()])
- paramtype = ''.join(paramlist[:-1])
- paramname = paramlist[-1]
- plist.append((paramtype, paramname))
Comma=""
if len(plist):
for ptype, pname in plist:
- self.outFile.write("%s%s%s_"%(Comma, ptype, pname))
+ self.outFile.write("%s%s"%(Comma, ptype))
Comma=", "
else:
self.outFile.write("void")
@@ -401,7 +404,7 @@ class ShimOutputGenerator(OutputGenerator):
if len(plist):
Comma=""
for ptype, pname in plist:
- self.outFile.write("%s %s %s_"%(Comma, ptype, pname))
+ self.outFile.write("%s %s"%(Comma, ptype))
Comma=", "
else:
self.outFile.write("void")
@@ -417,7 +420,7 @@ class ShimOutputGenerator(OutputGenerator):
Comma=""
for ptype, pname in plist:
- self.outFile.write("%s%s_"%(Comma, pname))
+ self.outFile.write("%s%s"%(Comma, pname))
Comma=", "
self.outFile.write(" );\n}\n\n")