def main(): parser = argparse.ArgumentParser() parser.add_argument("target", choices=("header", "source"), help="Whether to build the source or header file.") parser.add_argument("func_list_file", help="The function list .py file.") parser.add_argument("xml_files", nargs="+", help="The XML files with the EGL function lists.") args = parser.parse_args() # The function list is a Python module, but it's specified on the command # line. eglFunctionList = imp.load_source("eglFunctionList", args.func_list_file) xmlFunctions = genCommon.getFunctions(args.xml_files) xmlByName = dict((f.name, f) for f in xmlFunctions) functions = [] for (name, eglFunc) in eglFunctionList.EGL_FUNCTIONS: func = xmlByName[name] eglFunc = fixupEglFunc(func, eglFunc) functions.append((func, eglFunc)) # Sort the function list by name. functions = sorted(functions, key=lambda f: f[0].name) if args.target == "header": text = generateHeader(functions) elif args.target == "source": text = generateSource(functions) sys.stdout.write(text)
def main(): parser = argparse.ArgumentParser() parser.add_argument("target", choices=("header", "source"), help="Whether to build the source or header file.") parser.add_argument("xml_files", nargs="+", help="The XML files with the EGL function lists.") args = parser.parse_args() xmlFunctions = genCommon.getFunctions(args.xml_files) xmlByName = dict((f.name, f) for f in xmlFunctions) functions = [] for (name, eglFunc) in eglFunctionList.EGL_FUNCTIONS: func = xmlByName[name] eglFunc = fixupEglFunc(func, eglFunc) functions.append((func, eglFunc)) # Sort the function list by name. functions = sorted(functions, key=lambda f: f[0].name) if args.target == "header": text = generateHeader(functions) elif args.target == "source": text = generateSource(functions) sys.stdout.write(text)
def _main(): print(r""" /* DO NOT EDIT - This file generated automatically by gl_table.py script */ #if !defined( _GLAPI_TABLE_H_ ) # define _GLAPI_TABLE_H_ #ifndef GLAPIENTRYP # ifndef GLAPIENTRY # define GLAPIENTRY # endif # define GLAPIENTRYP GLAPIENTRY * #endif typedef void (APIENTRY *GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); struct _glapi_table {""".lstrip("\n")) for func in genCommon.getFunctions(sys.argv[1:]): print( " {f.rt} (GLAPIENTRYP {f.basename})({f.decArgs}); /* {f.slot} */" .format(f=func)) print("};\n") print("#endif /* !defined( _GLAPI_TABLE_H_ ) */")
def main(): if (len(sys.argv) < 4): print("Usage: %r source|header <function_list> <xml_file> [xml_file...]" % (sys.argv[0],)) sys.exit(2) target = sys.argv[1] funcListFile = sys.argv[2] xmlFiles = sys.argv[3:] # The function list is a Python module, but it's specified on the command # line. eglFunctionList = imp.load_source("eglFunctionList", funcListFile) xmlFunctions = genCommon.getFunctions(xmlFiles) xmlByName = dict((f.name, f) for f in xmlFunctions) functions = [] for (name, eglFunc) in eglFunctionList.EGL_FUNCTIONS: func = xmlByName[name] eglFunc = fixupEglFunc(func, eglFunc) functions.append((func, eglFunc)) # Sort the function list by name. functions = sorted(functions, key=lambda f: f[0].name) if (target == "header"): text = generateHeader(functions) elif (target == "source"): text = generateSource(functions) else: raise ValueError("Invalid target: %r" % (target,)) sys.stdout.write(text)
def _main(): print(r""" /* DO NOT EDIT - This file generated automatically by gl_table.py script */ #if !defined( _GLAPI_TABLE_H_ ) # define _GLAPI_TABLE_H_ #ifndef GLAPIENTRYP # ifndef GLAPIENTRY # define GLAPIENTRY # endif # define GLAPIENTRYP GLAPIENTRY * #endif typedef void (APIENTRY *GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); struct _glapi_table {""".lstrip("\n")) for func in genCommon.getFunctions(sys.argv[1:]): print(" {f.rt} (GLAPIENTRYP {f.basename})({f.decArgs}); /* {f.slot} */".format(f=func)) print("};\n") print("#endif /* !defined( _GLAPI_TABLE_H_ ) */")
def _main(): functions = genCommon.getFunctions(sys.argv[1:]) functions = [f for f in functions if(f.name not in _SKIP_GLX_FUNCTIONS)] sys.stdout.write(generateLibGLXStubs(functions))
def _main(): print(r""" /* DO NOT EDIT - This file generated automatically by gl_inittable.py script */ /* GLXEXT is the define used in the xserver when the GLX extension is being * built. Hijack this to determine whether this file is being built for the * server or the client. */ #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif #if (defined(GLXEXT) && defined(HAVE_BACKTRACE)) \ || (!defined(GLXEXT) && defined(DEBUG) && !defined(_WIN32_WCE) && !defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__OpenBSD__)) #define USE_BACKTRACE #endif #ifdef USE_BACKTRACE #include <execinfo.h> #endif #include <dlfcn.h> #include <stdlib.h> #include <stdio.h> #include "glheader.h" #include "glapi.h" #include "glapitable.h" #ifdef GLXEXT #include "os.h" #endif static void __glapi_inittable_NoOp(void) { const char *fstr = "Unknown"; /* Silence potential GCC warning for some #ifdef paths. */ (void) fstr; #if defined(USE_BACKTRACE) #if !defined(GLXEXT) if (getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG")) #endif { void *frames[2]; if(backtrace(frames, 2) == 2) { Dl_info info; dladdr(frames[1], &info); if(info.dli_sname) fstr = info.dli_sname; } #if !defined(GLXEXT) fprintf(stderr, "Call to unimplemented API: %s\n", fstr); #endif } #endif #if defined(GLXEXT) LogMessage(X_ERROR, "GLX: Call to unimplemented API: %s\n", fstr); #endif } static void __glapi_inittable_set_remaining_noop(struct _glapi_table *disp, size_t entries) { void **dispatch = (void **) disp; int i; /* ISO C is annoying sometimes */ union {_glapi_proc p; void *v;} p; p.p = __glapi_inittable_NoOp; for(i=0; i < entries; i++) if(dispatch[i] == NULL) dispatch[i] = p.v; } """.lstrip("\n")) # We split populating the table into a bunch of smaller functions instead # of one huge one. If we put everything in one function, the it takes # forever to compile. functionCount = 0 entriesPerFunction = 100 for (index, func) in enumerate(genCommon.getFunctions(sys.argv[1:])): if (index % entriesPerFunction == 0): if (index > 0): print("}\n") print(r""" static void _glapi_init_table_from_callback_%d(struct _glapi_table *table, size_t entries, void *(*get_proc_addr)(const char *name, void *param), void *param) { """.lstrip("\n") % (functionCount, )) functionCount += 1 print(r""" if(!table->{f.basename}) {{ void ** procp = (void **) &table->{f.basename}; *procp = (*get_proc_addr)("{f.name}", param); }} """.format(f=func)) print(r""" } void _glapi_init_table_from_callback(struct _glapi_table *table, size_t entries, void *(*get_proc_addr)(const char *name, void *param), void *param) { """.lstrip("\n")) for i in xrange(functionCount): print( " _glapi_init_table_from_callback_%d(table, entries, get_proc_addr, param);" % (i, )) print("") print(" __glapi_inittable_set_remaining_noop(table, entries);") print("}\n")
def _main(): print(r""" /* DO NOT EDIT - This file generated automatically by gl_inittable.py script */ /* GLXEXT is the define used in the xserver when the GLX extension is being * built. Hijack this to determine whether this file is being built for the * server or the client. */ #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif #if (defined(GLXEXT) && defined(HAVE_BACKTRACE)) \ || (!defined(GLXEXT) && defined(DEBUG) && !defined(_WIN32_WCE) && !defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__OpenBSD__)) #define USE_BACKTRACE #endif #ifdef USE_BACKTRACE #include <execinfo.h> #endif #include <dlfcn.h> #include <stdlib.h> #include <stdio.h> #include "main/glheader.h" #include "glapi.h" #include "glapitable.h" #ifdef GLXEXT #include "os.h" #endif static void __glapi_inittable_NoOp(void) { const char *fstr = "Unknown"; /* Silence potential GCC warning for some #ifdef paths. */ (void) fstr; #if defined(USE_BACKTRACE) #if !defined(GLXEXT) if (getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG")) #endif { void *frames[2]; if(backtrace(frames, 2) == 2) { Dl_info info; dladdr(frames[1], &info); if(info.dli_sname) fstr = info.dli_sname; } #if !defined(GLXEXT) fprintf(stderr, "Call to unimplemented API: %s\n", fstr); #endif } #endif #if defined(GLXEXT) LogMessage(X_ERROR, "GLX: Call to unimplemented API: %s\n", fstr); #endif } static void __glapi_inittable_set_remaining_noop(struct _glapi_table *disp, size_t entries) { void **dispatch = (void **) disp; int i; /* ISO C is annoying sometimes */ union {_glapi_proc p; void *v;} p; p.p = __glapi_inittable_NoOp; for(i=0; i < entries; i++) if(dispatch[i] == NULL) dispatch[i] = p.v; } """.lstrip("\n")) # We split populating the table into a bunch of smaller functions instead # of one huge one. If we put everything in one function, the it takes # forever to compile. functionCount = 0 entriesPerFunction = 100 for (index, func) in enumerate(genCommon.getFunctions(sys.argv[1:])): if (index % entriesPerFunction == 0): if (index > 0): print("}\n") print(r""" static void _glapi_init_table_from_callback_%d(struct _glapi_table *table, size_t entries, void *(*get_proc_addr)(const char *name, void *param), void *param) { """.lstrip("\n") % (functionCount,)) functionCount += 1 print(r""" if(!table->{f.basename}) {{ void ** procp = (void **) &table->{f.basename}; *procp = (*get_proc_addr)("{f.name}", param); }} """.format(f=func)) print(r""" } void _glapi_init_table_from_callback(struct _glapi_table *table, size_t entries, void *(*get_proc_addr)(const char *name, void *param), void *param) { """.lstrip("\n")) for i in xrange(functionCount): print(" _glapi_init_table_from_callback_%d(table, entries, get_proc_addr, param);" % (i,)) print("") print(" __glapi_inittable_set_remaining_noop(table, entries);") print("}\n")