summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
0cdc7b5)
Unify getwrite and getread to keep the write and read sides in sync
Some more special cases for array sizes
Wrap glXGetProcAddress to catch dynamically acquired functions
Transmit null terminator with strings
s = parts[5][1:-1]
if s.isdigit():
p[3] = int(s)
s = parts[5][1:-1]
if s.isdigit():
p[3] = int(s)
+ elif s=="" or (len(parts)>=7 and parts[6]=="retained"):
p[3] = "~"
else:
p[3] = s
p[3] = "~"
else:
p[3] = s
"GLchar *":"%s",
"GLcharARB *":"%s",
"GLvoid*":"%p",
"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"}
"GLhandleARB":"%i",
"GLhalfNV":"%#x",
"GLuint64EXT":"%lld"}
else:
return (fmtmap[ptype], param[0])
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:
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])
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])
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])
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 **")
- return (iomap[ptype], "")
+ return (iomap[ptype], None, None)
# Write out function enums
# Write out function enums
# Write out wrapper functions for transmitting side
# 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])))
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]:
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)
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]:
if f[1]!="void":
out.write("\tpos += read_%s(&ret, data+pos);\n"%iomap[f[1]])
for p in f[2]:
+ (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])
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])
static inline void write_string(const unsigned char *s)
{
static inline void write_string(const unsigned char *s)
{
- write_data(s, strlen(s));
+ write_data(s, strlen(s)+1);
}
static inline void begin_packet(int func)
}
static inline void begin_packet(int func)
+void (*glXGetProcAddress(const GLubyte *procname))(void)
+{
+ void *handle = dlopen(NULL, RTLD_LAZY);
+ return dlsym(handle, (const char *)procname);
+}
+
+void (*glXGetProcAddressARB(const GLubyte *))(void) __attribute__((alias("glXGetProcAddress")));
+