def main(): """Main function.""" args = _parser() printer = PrintGenericStubs() api = gl_XML.parse_GL_API(args.filename, glX_XML.glx_item_factory()) printer.Print(api)
def abi_parse_xml(xml): """Parse a GLAPI XML file for ABI entries.""" import os GLAPI = "./%s/../glapi/gen" % (os.path.dirname(sys.argv[0])) sys.path.append(GLAPI) import gl_XML, glX_XML api = gl_XML.parse_GL_API(xml, glX_XML.glx_item_factory()) entry_dict = {} for func in api.functionIterateByOffset(): # make sure func.name appear first entry_points = func.entry_points[:] entry_points.remove(func.name) entry_points.insert(0, func.name) for name in entry_points: attrs = { "slot": func.offset, "hidden": not func.is_static_entry_point(name), "alias": None if name == func.name else func.name, "handcode": bool(func.has_different_protocol(name)), } # post-process attrs if attrs["alias"]: try: alias = entry_dict[attrs["alias"]] except KeyError: raise Exception("failed to alias %s" % attrs["alias"]) if alias.alias: raise Exception("recursive alias %s" % ent.name) attrs["alias"] = alias if attrs["handcode"]: attrs["handcode"] = func.static_glx_name(name) else: attrs["handcode"] = None if entry_dict.has_key(name): raise Exception("%s is duplicated" % (name)) cols = [] cols.append(func.return_type) cols.append(name) params = func.get_parameter_string(name) cols.extend([p.strip() for p in params.split(",")]) ent = ABIEntry(cols, attrs) entry_dict[ent.name] = ent entries = entry_dict.values() entries.sort() return entries
def abi_parse_xml(xml): """Parse a GLAPI XML file for ABI entries.""" import os GLAPI = "./%s/../glapi/gen" % (os.path.dirname(sys.argv[0])) sys.path.append(GLAPI) import gl_XML, glX_XML api = gl_XML.parse_GL_API(xml, glX_XML.glx_item_factory()) entry_dict = {} for func in api.functionIterateByOffset(): # make sure func.name appear first entry_points = func.entry_points[:] entry_points.remove(func.name) entry_points.insert(0, func.name) for name in entry_points: attrs = { 'slot': func.offset, 'hidden': not func.is_static_entry_point(name), 'alias': None if name == func.name else func.name, 'handcode': bool(func.has_different_protocol(name)), } # post-process attrs if attrs['alias']: try: alias = entry_dict[attrs['alias']] except KeyError: raise Exception('failed to alias %s' % attrs['alias']) if alias.alias: raise Exception('recursive alias %s' % ent.name) attrs['alias'] = alias if attrs['handcode']: attrs['handcode'] = func.static_glx_name(name) else: attrs['handcode'] = None if entry_dict.has_key(name): raise Exception('%s is duplicated' % (name)) cols = [] cols.append(func.return_type) cols.append(name) params = func.get_parameter_string(name) cols.extend([p.strip() for p in params.split(',')]) ent = ABIEntry(cols, attrs) entry_dict[ent.name] = ent entries = entry_dict.values() entries.sort() return entries
def abi_parse_xml(xml): """Parse a GLAPI XML file for ABI entries.""" import gl_XML, glX_XML api = gl_XML.parse_GL_API(xml, glX_XML.glx_item_factory()) entry_dict = {} for func in api.functionIterateByOffset(): # make sure func.name appear first entry_points = func.entry_points[:] entry_points.remove(func.name) entry_points.insert(0, func.name) for name in entry_points: attrs = { 'slot': func.offset, 'hidden': not func.is_static_entry_point(name), 'alias': None if name == func.name else func.name, 'handcode': bool(func.has_different_protocol(name)), } # post-process attrs if attrs['alias']: try: alias = entry_dict[attrs['alias']] except KeyError: raise Exception('failed to alias %s' % attrs['alias']) if alias.alias: raise Exception('recursive alias %s' % ent.name) attrs['alias'] = alias if attrs['handcode']: attrs['handcode'] = func.static_glx_name(name) else: attrs['handcode'] = None if entry_dict.has_key(name): raise Exception('%s is duplicated' % (name)) cols = [] cols.append(func.return_type) cols.append(name) params = func.get_parameter_string(name) cols.extend([p.strip() for p in params.split(',')]) ent = ABIEntry(cols, attrs) entry_dict[ent.name] = ent entries = entry_dict.values() entries.sort() return entries
def main(): """Main function.""" args = _parser() if args.mode == "proto": printer = PrintGlxProtoStubs() elif args.mode == "init_c": printer = PrintGlxProtoInit_c() elif args.mode == "init_h": printer = PrintGlxProtoInit_h() printer.debug = args.debug api = gl_XML.parse_GL_API(args.filename, glX_XML.glx_item_factory()) printer.Print(api)
def main(): """Main function.""" args = _parser() if args.mode == "proto": printer = PrintGlxProtoStubs() elif args.mode == "init_c": printer = PrintGlxProtoInit_c() elif args.mode == "init_h": printer = PrintGlxProtoInit_h() printer.debug = args.debug api = gl_XML.parse_GL_API(args.filename, glX_XML.glx_item_factory()) printer.Print( api )
def main(): """Main function.""" args = _parser() if args.mode == "size_c": printer = PrintGlxSizeStubs_c(args.which_functions) elif args.mode == "size_h": printer = PrintGlxSizeStubs_h(args.which_functions) if args.header_tag is not None: printer.header_tag = args.header_tag elif args.mode == "reqsize_c": printer = PrintGlxReqSize_c() elif args.mode == "reqsize_h": printer = PrintGlxReqSize_h() api = gl_XML.parse_GL_API(args.filename, glX_XML.glx_item_factory()) printer.Print(api)
def show_usage(): print "Usage: %s [-f input_file_name] [-m output_mode]" % sys.argv[0] sys.exit(1) if __name__ == '__main__': file_name = "gl_API.xml" mode = "generic" try: (args, trail) = getopt.getopt(sys.argv[1:], "m:f:") except Exception, e: show_usage() for (arg, val) in args: if arg == '-m': mode = val elif arg == "-f": file_name = val if mode == "generic": printer = PrintGenericStubs() else: print "ERROR: Invalid mode \"%s\" specified." % mode show_usage() api = gl_XML.parse_GL_API(file_name, glX_XML.glx_item_factory()) printer.Print(api)
if not f.ignore and f.vectorequiv == None: if f.glx_rop != 0: self.rop_functions.append(f.glx_rop, f) if f.glx_sop != 0: self.sop_functions.append(f.glx_sop, f) if f.glx_vendorpriv != 0: self.vop_functions.append(f.glx_vendorpriv, f) self.sop_functions.Print() self.rop_functions.Print() self.vop_functions.Print() return def _parser(): """Parse arguments and return namespace.""" parser = argparse.ArgumentParser() parser.add_argument('-f', dest='filename', default='gl_API.xml', help='An XML file describing an API.') return parser.parse_args() if __name__ == '__main__': args = _parser() printer = PrintGlxDispatchTables() api = gl_XML.parse_GL_API(args.filename, glX_XML.glx_item_factory()) printer.Print(api)
def main(): """Main function.""" args = _parser() api = gl_XML.parse_GL_API(args.file_name, glX_XML.glx_item_factory()) PrintGlProcs(args.es).Print(api)
op, file1, file2 = args if op not in ops: show_usage(ops) skips = [] for opt, val in options: if opt == "-k": skips = val.split(",") for elt in skips: try: elts.remove(elt) except ValueError: show_usage(ops) api1 = gl_XML.parse_GL_API(file1, glX_XML.glx_item_factory()) api2 = gl_XML.parse_GL_API(file2, glX_XML.glx_item_factory()) set = ApiSet(api1, elts) func = getattr(set, op) result = func(api2) if not is_api_empty(result): cat_name = "%s_of_%s_and_%s" \ % (op, os.path.basename(file1), os.path.basename(file2)) print '<?xml version="1.0"?>' print '<!DOCTYPE OpenGLAPI SYSTEM "%s/gl_API.dtd">' % GLAPI print print '<OpenGLAPI>' 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) if __name__ == "__main__": file_name = "gl_API.xml" try: (args, trail) = getopt.getopt(sys.argv[1:], "f:c") except Exception, e: show_usage() es = False for (arg, val) in args: if arg == "-f": file_name = val elif arg == "-c": es = True api = gl_XML.parse_GL_API(file_name, glX_XML.glx_item_factory()) printer = PrintGlOffsets(es) printer.Print(api)