diff options
Diffstat (limited to 'xorg-server/hw/xwin/glx')
-rw-r--r-- | xorg-server/hw/xwin/glx/gen_gl_wrappers.py | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/xorg-server/hw/xwin/glx/gen_gl_wrappers.py b/xorg-server/hw/xwin/glx/gen_gl_wrappers.py index 69ab1efa9..b9e8dda75 100644 --- a/xorg-server/hw/xwin/glx/gen_gl_wrappers.py +++ b/xorg-server/hw/xwin/glx/gen_gl_wrappers.py @@ -123,6 +123,36 @@ 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 +209,15 @@ 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) + 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)) + plist=ParseCmdParams(cmd) 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 +238,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 +264,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 +290,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) 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)) + plist=ParseCmdParams(cmd) + 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 +313,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 +327,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") @@ -372,24 +382,14 @@ class ShimOutputGenerator(OutputGenerator): 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) 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)) + plist=ParseCmdParams(cmd) + 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 +401,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 +417,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") |