- normal_entries = []
- proto_entries = []
- for f in api.functionIterateByOffset():
- normal_ents, proto_ents = self.classifyEntryPoints(f)
-
- # exclude f.name
- if f.name in normal_ents:
- normal_ents.remove(f.name)
- elif f.name in proto_ents:
- proto_ents.remove(f.name)
-
- normal_ents = [f.static_name(ent) for ent in normal_ents]
- proto_ents = [f.static_name(ent) for ent in proto_ents]
-
- normal_entries.extend(normal_ents)
- proto_entries.extend(proto_ents)
-
- print '#ifndef _GLAPI_SKIP_NORMAL_ENTRY_POINTS'
- for ent in normal_entries:
- print ' TABLE_ENTRY(%s),' % (ent)
- print '#endif /* _GLAPI_SKIP_NORMAL_ENTRY_POINTS */'
- print '#ifndef _GLAPI_SKIP_PROTO_ENTRY_POINTS'
- for ent in proto_entries:
- print ' TABLE_ENTRY(%s),' % (ent)
- print '#endif /* _GLAPI_SKIP_PROTO_ENTRY_POINTS */'
-
- print '};'
- print '#endif /*UNUSED_TABLE_NAME*/'
- print ''
- return
-
-
- def classifyEntryPoints(self, func):
- normal_names = []
- normal_stubs = []
- proto_names = []
- proto_stubs = []
- # classify the entry points
- for name in func.entry_points:
- if func.has_different_protocol(name):
- if func.is_static_entry_point(name):
- proto_names.append(name)
- else:
- proto_stubs.append(name)
- else:
- if func.is_static_entry_point(name):
- normal_names.append(name)
- else:
- normal_stubs.append(name)
- # there can be at most one stub for a function
- if normal_stubs:
- normal_names.append(normal_stubs[0])
- elif proto_stubs:
- proto_names.append(proto_stubs[0])
-
- return (normal_names, proto_names)
-
- def printBody(self, api):
- normal_entry_points = []
- proto_entry_points = []
- for func in api.functionIterateByOffset():
- normal_ents, proto_ents = self.classifyEntryPoints(func)
- normal_entry_points.append((func, normal_ents))
- proto_entry_points.append((func, proto_ents))
-
- print '#ifndef _GLAPI_SKIP_NORMAL_ENTRY_POINTS'
- print ''
- for func, ents in normal_entry_points:
- for ent in ents:
- self.printFunction(func, ent)
- print ''
- print '#endif /* _GLAPI_SKIP_NORMAL_ENTRY_POINTS */'
- print ''
- print '/* these entry points might require different protocols */'
- print '#ifndef _GLAPI_SKIP_PROTO_ENTRY_POINTS'
- print ''
- for func, ents in proto_entry_points:
- for ent in ents:
- self.printFunction(func, ent)
- print ''
- print '#endif /* _GLAPI_SKIP_PROTO_ENTRY_POINTS */'
- print ''
-
- self.printInitDispatch(api)
- self.printAliasedTable(api)
- return
-
-
-def show_usage():
- print "Usage: %s [-f input_file_name] [-c]" % sys.argv[0]
- print "-c Enable compatibility with OpenGL ES."
- sys.exit(1)
+ normal_entries = []
+ proto_entries = []
+ for f in api.functionIterateByOffset():
+ normal_ents, proto_ents = self.classifyEntryPoints(f)
+
+ # exclude f.name
+ if f.name in normal_ents:
+ normal_ents.remove(f.name)
+ elif f.name in proto_ents:
+ proto_ents.remove(f.name)
+
+ normal_ents = [f.static_name(ent) for ent in normal_ents]
+ proto_ents = [f.static_name(ent) for ent in proto_ents]
+
+ normal_entries.extend(normal_ents)
+ proto_entries.extend(proto_ents)
+
+ print '#ifndef _GLAPI_SKIP_NORMAL_ENTRY_POINTS'
+ for ent in normal_entries:
+ print ' TABLE_ENTRY(%s),' % (ent)
+ print '#endif /* _GLAPI_SKIP_NORMAL_ENTRY_POINTS */'
+ print '#ifndef _GLAPI_SKIP_PROTO_ENTRY_POINTS'
+ for ent in proto_entries:
+ print ' TABLE_ENTRY(%s),' % (ent)
+ print '#endif /* _GLAPI_SKIP_PROTO_ENTRY_POINTS */'
+
+ print '};'
+ print '#endif /*UNUSED_TABLE_NAME*/'
+ print ''
+ return
+
+
+ def classifyEntryPoints(self, func):
+ normal_names = []
+ normal_stubs = []
+ proto_names = []
+ proto_stubs = []
+ # classify the entry points
+ for name in func.entry_points:
+ if func.has_different_protocol(name):
+ if func.is_static_entry_point(name):
+ proto_names.append(name)
+ else:
+ proto_stubs.append(name)
+ else:
+ if func.is_static_entry_point(name):
+ normal_names.append(name)
+ else:
+ normal_stubs.append(name)
+ # there can be at most one stub for a function
+ if normal_stubs:
+ normal_names.append(normal_stubs[0])
+ elif proto_stubs:
+ proto_names.append(proto_stubs[0])
+
+ return (normal_names, proto_names)
+
+ def printBody(self, api):
+ normal_entry_points = []
+ proto_entry_points = []
+ for func in api.functionIterateByOffset():
+ normal_ents, proto_ents = self.classifyEntryPoints(func)
+ normal_entry_points.append((func, normal_ents))
+ proto_entry_points.append((func, proto_ents))
+
+ print '#ifndef _GLAPI_SKIP_NORMAL_ENTRY_POINTS'
+ print ''
+ for func, ents in normal_entry_points:
+ for ent in ents:
+ self.printFunction(func, ent)
+ print ''
+ print '#endif /* _GLAPI_SKIP_NORMAL_ENTRY_POINTS */'
+ print ''
+ print '/* these entry points might require different protocols */'
+ print '#ifndef _GLAPI_SKIP_PROTO_ENTRY_POINTS'
+ print ''
+ for func, ents in proto_entry_points:
+ for ent in ents:
+ self.printFunction(func, ent)
+ print ''
+ print '#endif /* _GLAPI_SKIP_PROTO_ENTRY_POINTS */'
+ print ''
+
+ self.printInitDispatch(api)
+ self.printAliasedTable(api)
+ return
+
+
+def _parser():
+ """Parser arguments and return a namespace."""
+ parser = argparse.ArgumentParser()
+ parser.add_argument('-f',
+ metavar='<input file name>',
+ dest='filename',
+ default="gl_API.xml",
+ help="An XML file describing the API.")
+ parser.add_argument('-c',
+ action='store_true',
+ dest='es',
+ help="Enable OpenGL ES compatibility")
+ return parser.parse_args()
+
+
+def main():
+ """Main function."""
+ args = _parser()
+
+ api = gl_XML.parse_GL_API(args.filename, glX_XML.glx_item_factory())
+
+ printer = PrintGlOffsets(args.es)
+ printer.Print(api)
+