class Function(Thing):
def __init__(self, name):
Thing.__init__(self, name, Thing.FUNCTION)
+ self.return_type = "void"
+ self.params = []
self.typedef = None
self.vectorequiv = None
root = doc.documentElement
commands = get_nested_elements(root, "commands/command")
for cmd in commands:
- name = get_text_contents(get_nested_elements(cmd, "proto/name")[0])
+ proto = cmd.getElementsByTagName("proto")[0]
+ name = get_text_contents(proto.getElementsByTagName("name")[0])
func = things.get(name)
if not func:
func = Function(name)
if vec:
func.vectorequiv = vec[0].getAttribute("name")
+ ptype = proto.getElementsByTagName("ptype")
+ if ptype:
+ func.return_type = get_text_contents(ptype[0])
+ else:
+ for c in proto.childNodes:
+ if c.nodeType==xml.dom.Node.TEXT_NODE and c.data.strip():
+ func.return_type = c.data.strip()
+ break
+
+ params = cmd.getElementsByTagName("param")
+ for p in params:
+ func.params.append(get_text_contents(p))
+
enums = get_nested_elements(root, "enums/enum")
for en in enums:
name = en.getAttribute("name")
if funcs or enums:
out.write("\n#ifndef GL_%s\n"%ext)
for f in funcs:
- out.write("typedef int (*%s)(...);\n"%f.typedef)
+ out.write("typedef %s (*%s)(%s);\n"%(f.return_type, f.typedef, ", ".join(f.params)))
if funcs and enums:
out.write("\n")
for e in enums: