X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=extgen.py;fp=extgen.py;h=109802862b91d65f5d43479275ae2f303c3a9f3c;hb=5318aa4fd553be4ce0bc428e73592b787842cdea;hp=0000000000000000000000000000000000000000;hpb=4c89817d6e060323ec1ddd275f3265cea688c650;p=libs%2Fgl.git diff --git a/extgen.py b/extgen.py new file mode 100755 index 00000000..10980286 --- /dev/null +++ b/extgen.py @@ -0,0 +1,67 @@ +#!/usr/bin/python +# $Id$ + +import sys + +ext=sys.argv[1] + +funcs=[] +cur_func=None +for line in file("gl.spec"): + if line[0]=='#' or line.find(':')>=0: + continue + elif line[0]=='\t' and cur_func: + parts=line.split() + if parts[0]=="category" and parts[1]==ext: + funcs.append(cur_func) + else: + paren=line.find('(') + if paren>0: + cur_func=line[:paren] + +out=file(ext.lower()+".h", "w") +out.write("#ifndef MSP_GL_%s_\n"%ext.upper()) +out.write("#define MSP_GL_%s_\n"%ext.upper()) + +out.write(""" +#include + +namespace Msp { +namespace GL { + +""") + +for f in funcs: + out.write("extern PFNGL%sPROC gl%s;\n"%(f.upper(), f)) + +out.write("\nvoid init_%s();\n"%ext.lower()) + +out.write(""" +} // namespace GL +} // namespace Msp + +#endif +""") + +out=file(ext.lower()+".cpp", "w") +out.write("#include \"extension.h\"\n") +out.write("#include \"%s.h\"\n"%ext.lower()) + +out.write(""" +namespace Msp { +namespace GL { + +""") + +for f in funcs: + out.write("PFNGL%sPROC gl%s=0;\n"%(f.upper(), f)) + +out.write("\nvoid init_%s()\n{\n"%ext.lower()) +for f in funcs: + out.write("\tgl%s=reinterpret_cast(get_proc_address(\"gl%s\"));\n"%(f, f.upper(), f)) +out.write("}\n") + +out.write(""" +} // namespace GL +} // namespace Msp +""")