s = parts[5][1:-1]
if s.isdigit():
p[3] = int(s)
- elif s=="":
+ elif s=="" or (len(parts)>=7 and parts[6]=="retained"):
p[3] = "~"
else:
p[3] = s
"GLchar *":"%s",
"GLcharARB *":"%s",
"GLvoid*":"%p",
- "GLsizeiptr":"%p",
- "GLsizeiptrARB":"%p",
- "GLintptr":"%p",
- "GLintptrARB":"%p",
+ "GLsizeiptr":"%d",
+ "GLsizeiptrARB":"%d",
+ "GLintptr":"%d",
+ "GLintptrARB":"%d",
"GLhandleARB":"%i",
"GLhalfNV":"%#x",
"GLuint64EXT":"%lld"}
else:
return (fmtmap[ptype], param[0])
-def getwrite(func, param):
+def getrwinfo(func, param):
ptype = basetype(param[1], param[3]!=0)
if param[3]:
if type(param[3])==int:
size = compsize(func, param[3][9:-1], ptype)
if not size:
print "Compsize '%s' for function '%s' failed"%(param[3][9:-1], func[0])
- return ("pointer", None)
- elif param[3]=="~" and (param[2]=="charARB" or param[2]=="Char"):
- return ("string", None)
+ return ("pointer", None, "void **")
+ elif param[3]=="~":
+ if param[2]=="charARB" or param[2]=="Char":
+ return ("string", None, "const unsigned char **")
+ else:
+ return ("pointer", None, "void **")
else:
s = getparam(func, param[3].split('*')[0])
- if s and (s[2]=="SizeI" or s[2].endswith("Int32")) and s[3]==0:
+ if s and (s[2]=="SizeI" or s[2].endswith("Int32") or s[2].startswith("BufferSize")) and s[3]==0:
size = "%s*sizeof(%s)"%(param[3], ptype)
if func[0].startswith("Uniform") and func[0][8]!='u' and func[0][7].isdigit():
size += "*%s"%func[0][7]
else:
print "Could not determine size for array parameter '%s[%s]' of function '%s'"%(param[0], param[3], func[0])
- return ("pointer", None)
- return ("data", size)
- else:
- return (iomap[ptype], None)
-
-def getread(func, param):
- ptype = basetype(param[1], param[3]!=0)
- if param[3]:
- return ("data", "(const void **)")
+ return ("pointer", None, "void **")
+ return ("data", size, "const void **")
else:
- return (iomap[ptype], "")
+ return (iomap[ptype], None, None)
# Write out function enums
# Write out wrapper functions for transmitting side
-out = open(os.path.join(outdir, "glwrap.funcs"), "w");
+out = open(os.path.join(outdir, "glwrap.funcs"), "w")
for f in funcs:
out.write("%s GLAPIENTRY gl%s(%s)\n{\n"%(f[1], f[0], ", ".join("%s %s"%(p[1], p[0]) for p in f[2])))
if f[1]!="void":
out.write("\twrite_%s(ret);\n"%iomap[f[1]])
for p in f[2]:
- (t, s) = getwrite(f, p)
+ (t, s, c) = getrwinfo(f, p)
out.write("\twrite_%s(%s"%(t, p[0]))
if s:
out.write(", %s"%s)
if f[1]!="void":
out.write("\tpos += read_%s(&ret, data+pos);\n"%iomap[f[1]])
for p in f[2]:
- (t, c) = getread(f, p)
+ (t, s, c) = getrwinfo(f, p)
+ if c:
+ c="(%s)"%c
+ else:
+ c=""
out.write("\tpos += read_%s(%s&arg_%s, data+pos);\n"%(t, c, p[0]))
out.write("\tif(dec->%s)\n"%f[0])
out.write("\t\tdec->%s(dec->user_data"%f[0])