X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=scripts%2Fextgen.py;h=7083e13a1e6dcfc8ad00a3179bcd13cbe7f12bdb;hb=3297703b932007051decb2f1353b93a1a2d4157c;hp=fbb66815ae1de93102485065bace98bde781b05f;hpb=67538c60b8baa6816b8ae2d343ae62d881e6c58d;p=libs%2Fgl.git diff --git a/scripts/extgen.py b/scripts/extgen.py index fbb66815..7083e13a 100755 --- a/scripts/extgen.py +++ b/scripts/extgen.py @@ -31,6 +31,7 @@ if sys.argv[i].startswith("gl"): i += 1 target_ext = sys.argv[i] +backport_ext = None out_base = None if target_ext.endswith(".glext"): fn = target_ext @@ -46,6 +47,8 @@ if target_ext.endswith(".glext"): core_version = parts[2] elif parts[0]=="secondary": secondary.append(parts[1]) + elif parts[0]=="backport": + backport_ext = parts[1] if i+11: + print "Warning: multiple backport extension candidates: %s"%(" ".join(e.name for e in backport_ext_candidates)) + + for e in backport_ext_candidates: + if e.base_name==target_ext.base_name: + backport_ext = e + + if not backport_ext and len(backport_ext_candidates)==1: + print "Warning: potential backport extension has mismatched name: %s"%backport_ext_candidates[0].name for f in funcs: f.typedef = "FPtr_%s"%f.name @@ -341,6 +366,33 @@ else: else: source_ext = None +if funcs or enums: + any_supported = False + all_supported = True + for t in itertools.chain(funcs, enums): + if target_api in t.supported_apis: + any_supported = True + else: + all_supported = False + + if not any_supported: + print "Warning: %s is not supported by the target API"%target_ext.name + elif not all_supported: + print "Warning: %s is only partially supported by the target API"%target_ext.name + unsupported = "" + label = "Warning: Unsupported tokens: " + for t in itertools.chain(funcs, enums): + if target_api not in t.supported_apis: + if unsupported and len(label)+len(unsupported)+2+len(t.name)>78: + print label+unsupported + label = " "*len(label) + unsupported = "" + if unsupported: + unsupported += ", " + unsupported += t.name + if unsupported: + print label+unsupported + ### Output ### out = file(out_base+".h", "w") @@ -359,7 +411,7 @@ namespace GL { if funcs or enums: if funcs: for f in funcs: - out.write("typedef %s (*%s)(%s);\n"%(f.return_type, f.typedef, ", ".join(f.params))) + out.write("typedef %s (APIENTRY *%s)(%s);\n"%(f.return_type, f.typedef, ", ".join(f.params))) out.write("\n") if enums: @@ -403,10 +455,16 @@ out.write("#include \"%s.h\"\n"%target_ext.name.lower()) if funcs: out.write(""" #ifdef __APPLE__ -#define GET_PROC_ADDRESS(x) ::x +#define GET_PROC_ADDRESS(x) &::x #else #define GET_PROC_ADDRESS(x) get_proc_address(#x) #endif + +#ifdef WIN32 +#define GET_PROC_ADDRESS_1_1(x) &::x +#else +#define GET_PROC_ADDRESS_1_1(x) GET_PROC_ADDRESS(x) +#endif """) out.write(""" namespace Msp { @@ -424,8 +482,11 @@ if core_version: out.write(" || is_supported(\"GL_%s\")"%backport_ext.name) out.write(")\n\t{\n") for f in funcs: - if f.version or target_api in f.supported_apis: - out.write("\t\t%s = reinterpret_cast<%s>(GET_PROC_ADDRESS(%s));\n"%(f.name, f.typedef, f.name)) + if target_api in f.supported_apis: + gpa_suffix = "" + if f.version<=[1, 1]: + gpa_suffix = "_1_1" + out.write("\t\t%s = reinterpret_cast<%s>(GET_PROC_ADDRESS%s(%s));\n"%(f.name, f.typedef, gpa_suffix, f.name)) out.write("\t\treturn Extension::CORE;\n") out.write("\t}\n") if source_ext and source_ext!=backport_ext: @@ -434,7 +495,7 @@ if source_ext and source_ext!=backport_ext: s = f if f.sources: s = f.sources[0] - if s.version or target_api in s.supported_apis: + if target_api in s.supported_apis: out.write("\t\t%s = reinterpret_cast<%s>(GET_PROC_ADDRESS(%s));\n"%(f.name, f.typedef, s.name)) out.write("\t\treturn Extension::EXTENSION;\n") out.write("\t}\n")