diff options
-rw-r--r-- | src/mapi/glapi/gen/apiexec.py | 2 | ||||
-rw-r--r-- | src/mapi/glapi/gen/glX_proto_send.py | 478 | ||||
-rw-r--r-- | src/mapi/glapi/gen/glX_proto_size.py | 18 | ||||
-rw-r--r-- | src/mapi/glapi/gen/gl_SPARC_asm.py | 7 | ||||
-rw-r--r-- | src/mapi/glapi/gen/gl_XML.py | 49 | ||||
-rw-r--r-- | src/mapi/glapi/gen/gl_apitemp.py | 146 | ||||
-rw-r--r-- | src/mapi/glapi/gen/gl_enums.py | 160 | ||||
-rw-r--r-- | src/mapi/glapi/gen/gl_gentable.py | 9 | ||||
-rw-r--r-- | src/mapi/glapi/gen/gl_procs.py | 54 | ||||
-rw-r--r-- | src/mapi/glapi/gen/gl_table.py | 31 | ||||
-rw-r--r-- | src/mapi/glapi/gen/gl_x86_asm.py | 7 |
11 files changed, 502 insertions, 459 deletions
diff --git a/src/mapi/glapi/gen/apiexec.py b/src/mapi/glapi/gen/apiexec.py index 670dc4a6ad..66e857954f 100644 --- a/src/mapi/glapi/gen/apiexec.py +++ b/src/mapi/glapi/gen/apiexec.py @@ -20,6 +20,7 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. + class exec_info(): """Information relating GL APIs to a function. @@ -66,6 +67,7 @@ class exec_info(): self.es1 = es1 self.es2 = es2 + functions = { # OpenGL 3.1 / GL_ARB_texture_buffer_object. Mesa only exposes this # extension with core profile. diff --git a/src/mapi/glapi/gen/glX_proto_send.py b/src/mapi/glapi/gen/glX_proto_send.py index aeb64b59bb..91421667ff 100644 --- a/src/mapi/glapi/gen/glX_proto_send.py +++ b/src/mapi/glapi/gen/glX_proto_send.py @@ -31,6 +31,7 @@ import argparse import copy import string +import textwrap import gl_XML import glX_XML @@ -199,119 +200,120 @@ class PrintGlxProtoStubs(glX_proto_common.glx_print_proto): print ' temp.s[0] = (size); temp.s[1] = (op); \\' print ' *((int *)(dest)) = temp.i; } while(0)' print '' - print """NOINLINE CARD32 -__glXReadReply( Display *dpy, size_t size, void * dest, GLboolean reply_is_always_array ) -{ - xGLXSingleReply reply; - - (void) _XReply(dpy, (xReply *) & reply, 0, False); - if (size != 0) { - if ((reply.length > 0) || reply_is_always_array) { - const GLint bytes = (reply_is_always_array) - ? (4 * reply.length) : (reply.size * size); - const GLint extra = 4 - (bytes & 3); - - _XRead(dpy, dest, bytes); - if ( extra < 4 ) { - _XEatData(dpy, extra); + print textwrap.dedent("""\ + NOINLINE CARD32 + __glXReadReply( Display *dpy, size_t size, void * dest, GLboolean reply_is_always_array ) + { + xGLXSingleReply reply; + + (void) _XReply(dpy, (xReply *) & reply, 0, False); + if (size != 0) { + if ((reply.length > 0) || reply_is_always_array) { + const GLint bytes = (reply_is_always_array) + ? (4 * reply.length) : (reply.size * size); + const GLint extra = 4 - (bytes & 3); + + _XRead(dpy, dest, bytes); + if ( extra < 4 ) { + _XEatData(dpy, extra); + } + } + else { + (void) memcpy( dest, &(reply.pad3), size); + } + } + + return reply.retval; } - } - else { - (void) memcpy( dest, &(reply.pad3), size); - } - } - - return reply.retval; -} - -NOINLINE void -__glXReadPixelReply( Display *dpy, struct glx_context * gc, unsigned max_dim, - GLint width, GLint height, GLint depth, GLenum format, GLenum type, - void * dest, GLboolean dimensions_in_reply ) -{ - xGLXSingleReply reply; - GLint size; - - (void) _XReply(dpy, (xReply *) & reply, 0, False); - - if ( dimensions_in_reply ) { - width = reply.pad3; - height = reply.pad4; - depth = reply.pad5; - - if ((height == 0) || (max_dim < 2)) { height = 1; } - if ((depth == 0) || (max_dim < 3)) { depth = 1; } - } - - size = reply.length * 4; - if (size != 0) { - void * buf = malloc( size ); - - if ( buf == NULL ) { - _XEatData(dpy, size); - __glXSetError(gc, GL_OUT_OF_MEMORY); - } - else { - const GLint extra = 4 - (size & 3); - - _XRead(dpy, buf, size); - if ( extra < 4 ) { - _XEatData(dpy, extra); + + NOINLINE void + __glXReadPixelReply( Display *dpy, struct glx_context * gc, unsigned max_dim, + GLint width, GLint height, GLint depth, GLenum format, GLenum type, + void * dest, GLboolean dimensions_in_reply ) + { + xGLXSingleReply reply; + GLint size; + + (void) _XReply(dpy, (xReply *) & reply, 0, False); + + if ( dimensions_in_reply ) { + width = reply.pad3; + height = reply.pad4; + depth = reply.pad5; + + if ((height == 0) || (max_dim < 2)) { height = 1; } + if ((depth == 0) || (max_dim < 3)) { depth = 1; } + } + + size = reply.length * 4; + if (size != 0) { + void * buf = malloc( size ); + + if ( buf == NULL ) { + _XEatData(dpy, size); + __glXSetError(gc, GL_OUT_OF_MEMORY); + } + else { + const GLint extra = 4 - (size & 3); + + _XRead(dpy, buf, size); + if ( extra < 4 ) { + _XEatData(dpy, extra); + } + + __glEmptyImage(gc, 3, width, height, depth, format, type, + buf, dest); + free(buf); + } + } + } + + #define X_GLXSingle 0 + + NOINLINE FASTCALL GLubyte * + __glXSetupSingleRequest( struct glx_context * gc, GLint sop, GLint cmdlen ) + { + xGLXSingleReq * req; + Display * const dpy = gc->currentDpy; + + (void) __glXFlushRenderBuffer(gc, gc->pc); + LockDisplay(dpy); + GetReqExtra(GLXSingle, cmdlen, req); + req->reqType = gc->majorOpcode; + req->contextTag = gc->currentContextTag; + req->glxCode = sop; + return (GLubyte *)(req) + sz_xGLXSingleReq; + } + + NOINLINE FASTCALL GLubyte * + __glXSetupVendorRequest( struct glx_context * gc, GLint code, GLint vop, GLint cmdlen ) + { + xGLXVendorPrivateReq * req; + Display * const dpy = gc->currentDpy; + + (void) __glXFlushRenderBuffer(gc, gc->pc); + LockDisplay(dpy); + GetReqExtra(GLXVendorPrivate, cmdlen, req); + req->reqType = gc->majorOpcode; + req->glxCode = code; + req->vendorCode = vop; + req->contextTag = gc->currentContextTag; + return (GLubyte *)(req) + sz_xGLXVendorPrivateReq; } - __glEmptyImage(gc, 3, width, height, depth, format, type, - buf, dest); - free(buf); - } - } -} - -#define X_GLXSingle 0 - -NOINLINE FASTCALL GLubyte * -__glXSetupSingleRequest( struct glx_context * gc, GLint sop, GLint cmdlen ) -{ - xGLXSingleReq * req; - Display * const dpy = gc->currentDpy; - - (void) __glXFlushRenderBuffer(gc, gc->pc); - LockDisplay(dpy); - GetReqExtra(GLXSingle, cmdlen, req); - req->reqType = gc->majorOpcode; - req->contextTag = gc->currentContextTag; - req->glxCode = sop; - return (GLubyte *)(req) + sz_xGLXSingleReq; -} - -NOINLINE FASTCALL GLubyte * -__glXSetupVendorRequest( struct glx_context * gc, GLint code, GLint vop, GLint cmdlen ) -{ - xGLXVendorPrivateReq * req; - Display * const dpy = gc->currentDpy; - - (void) __glXFlushRenderBuffer(gc, gc->pc); - LockDisplay(dpy); - GetReqExtra(GLXVendorPrivate, cmdlen, req); - req->reqType = gc->majorOpcode; - req->glxCode = code; - req->vendorCode = vop; - req->contextTag = gc->currentContextTag; - return (GLubyte *)(req) + sz_xGLXVendorPrivateReq; -} - -const GLuint __glXDefaultPixelStore[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 1 }; - -#define zero (__glXDefaultPixelStore+0) -#define one (__glXDefaultPixelStore+8) -#define default_pixel_store_1D (__glXDefaultPixelStore+4) -#define default_pixel_store_1D_size 20 -#define default_pixel_store_2D (__glXDefaultPixelStore+4) -#define default_pixel_store_2D_size 20 -#define default_pixel_store_3D (__glXDefaultPixelStore+0) -#define default_pixel_store_3D_size 36 -#define default_pixel_store_4D (__glXDefaultPixelStore+0) -#define default_pixel_store_4D_size 36 -""" + const GLuint __glXDefaultPixelStore[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 1 }; + + #define zero (__glXDefaultPixelStore+0) + #define one (__glXDefaultPixelStore+8) + #define default_pixel_store_1D (__glXDefaultPixelStore+4) + #define default_pixel_store_1D_size 20 + #define default_pixel_store_2D (__glXDefaultPixelStore+4) + #define default_pixel_store_2D_size 20 + #define default_pixel_store_3D (__glXDefaultPixelStore+0) + #define default_pixel_store_3D_size 36 + #define default_pixel_store_4D (__glXDefaultPixelStore+0) + #define default_pixel_store_4D_size 36 + """) for size in self.generic_sizes: self.print_generic_function(size) @@ -366,45 +368,47 @@ const GLuint __glXDefaultPixelStore[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 1 }; if func.has_different_protocol(n): procs[n] = func.static_glx_name(n) - print """ -#ifdef GLX_SHARED_GLAPI + print textwrap.dedent("""\ + #ifdef GLX_SHARED_GLAPI -static const struct proc_pair -{ - const char *name; - _glapi_proc proc; -} proc_pairs[%d] = {""" % len(procs) + static const struct proc_pair + { + const char *name; + _glapi_proc proc; + } proc_pairs[%d] = { + """ % len(procs)) names = procs.keys() names.sort() for i in xrange(len(names)): comma = ',' if i < len(names) - 1 else '' print ' { "%s", (_glapi_proc) gl%s }%s' % (names[i], procs[names[i]], comma) - print """}; - -static int -__indirect_get_proc_compare(const void *key, const void *memb) -{ - const struct proc_pair *pair = (const struct proc_pair *) memb; - return strcmp((const char *) key, pair->name); -} - -_glapi_proc -__indirect_get_proc_address(const char *name) -{ - const struct proc_pair *pair; - - /* skip "gl" */ - name += 2; - - pair = (const struct proc_pair *) bsearch((const void *) name, - (const void *) proc_pairs, ARRAY_SIZE(proc_pairs), sizeof(proc_pairs[0]), - __indirect_get_proc_compare); - - return (pair) ? pair->proc : NULL; -} - -#endif /* GLX_SHARED_GLAPI */ -""" + print textwrap.dedent("""\ + }; + + static int + __indirect_get_proc_compare(const void *key, const void *memb) + { + const struct proc_pair *pair = (const struct proc_pair *) memb; + return strcmp((const char *) key, pair->name); + } + + _glapi_proc + __indirect_get_proc_address(const char *name) + { + const struct proc_pair *pair; + + /* skip "gl" */ + name += 2; + + pair = (const struct proc_pair *) bsearch((const void *) name, + (const void *) proc_pairs, ARRAY_SIZE(proc_pairs), sizeof(proc_pairs[0]), + __indirect_get_proc_compare); + + return (pair) ? pair->proc : NULL; + } + + #endif /* GLX_SHARED_GLAPI */ + """) return @@ -462,18 +466,19 @@ __indirect_get_proc_address(const char *name) def print_generic_function(self, n): size = (n + 3) & ~3 - print """static FASTCALL NOINLINE void -generic_%u_byte( GLint rop, const void * ptr ) -{ - struct glx_context * const gc = __glXGetCurrentContext(); - const GLuint cmdlen = %u; - - emit_header(gc->pc, rop, cmdlen); - (void) memcpy((void *)(gc->pc + 4), ptr, %u); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); } -} -""" % (n, size + 4, size) + print textwrap.dedent("""\ + static FASTCALL NOINLINE void + generic_%u_byte( GLint rop, const void * ptr ) + { + struct glx_context * const gc = __glXGetCurrentContext(); + const GLuint cmdlen = %u; + + emit_header(gc->pc, rop, cmdlen); + (void) memcpy((void *)(gc->pc + 4), ptr, %u); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); } + } + """ % (n, size + 4, size)) return @@ -936,67 +941,71 @@ class PrintGlxProtoInit_c(gl_XML.gl_print_base): self.name = "glX_proto_send.py (from Mesa)" self.license = license.bsd_license_template % ( \ -"""Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. -(C) Copyright IBM Corporation 2004""", "PRECISION INSIGHT, IBM") + textwrap.dedent("""\ + Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. + (C) Copyright IBM Corporation 2004"""), + "PRECISION INSIGHT, IBM") return def printRealHeader(self): - print """/** - * \\file indirect_init.c - * Initialize indirect rendering dispatch table. - * - * \\author Kevin E. Martin <kevin@precisioninsight.com> - * \\author Brian Paul <brian@precisioninsight.com> - * \\author Ian Romanick <idr@us.ibm.com> - */ - -#include "indirect_init.h" -#include "indirect.h" -#include "glapi.h" -#include <assert.h> - -#ifndef GLX_USE_APPLEGL - -/** - * No-op function used to initialize functions that have no GLX protocol - * support. - */ -static int NoOp(void) -{ - return 0; -} - -/** - * Create and initialize a new GL dispatch table. The table is initialized - * with GLX indirect rendering protocol functions. - */ -struct _glapi_table * __glXNewIndirectAPI( void ) -{ - _glapi_proc *table; - unsigned entries; - unsigned i; - int o; - - entries = _glapi_get_dispatch_table_size(); - table = malloc(entries * sizeof(_glapi_proc)); - if (table == NULL) - return NULL; - - /* first, set all entries to point to no-op functions */ - for (i = 0; i < entries; i++) { - table[i] = (_glapi_proc) NoOp; - } - - /* now, initialize the entries we understand */""" + print textwrap.dedent("""\ + /** + * \\file indirect_init.c + * Initialize indirect rendering dispatch table. + * + * \\author Kevin E. Martin <kevin@precisioninsight.com> + * \\author Brian Paul <brian@precisioninsight.com> + * \\author Ian Romanick <idr@us.ibm.com> + */ + + #include "indirect_init.h" + #include "indirect.h" + #include "glapi.h" + #include <assert.h> + + #ifndef GLX_USE_APPLEGL + + /** + * No-op function used to initialize functions that have no GLX protocol + * support. + */ + static int NoOp(void) + { + return 0; + } + + /** + * Create and initialize a new GL dispatch table. The table is initialized + * with GLX indirect rendering protocol functions. + */ + struct _glapi_table * __glXNewIndirectAPI( void ) + { + _glapi_proc *table; + unsigned entries; + unsigned i; + int o; + + entries = _glapi_get_dispatch_table_size(); + table = malloc(entries * sizeof(_glapi_proc)); + if (table == NULL) + return NULL; + + /* first, set all entries to point to no-op functions */ + for (i = 0; i < entries; i++) { + table[i] = (_glapi_proc) NoOp; + } + + /* now, initialize the entries we understand */ + """) def printRealFooter(self): - print """ - return (struct _glapi_table *) table; -} + print textwrap.dedent("""\ + return (struct _glapi_table *) table; + } -#endif -""" + #endif + """) return @@ -1029,8 +1038,10 @@ class PrintGlxProtoInit_h(gl_XML.gl_print_base): self.name = "glX_proto_send.py (from Mesa)" self.license = license.bsd_license_template % ( \ -"""Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. -(C) Copyright IBM Corporation 2004""", "PRECISION INSIGHT, IBM") + textwrap.dedent("""\ + Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. + (C) Copyright IBM Corporation 2004"""), + "PRECISION INSIGHT, IBM") self.header_tag = "_INDIRECT_H_" self.last_category = "" @@ -1038,35 +1049,36 @@ class PrintGlxProtoInit_h(gl_XML.gl_print_base): def printRealHeader(self): - print """/** - * \\file - * Prototypes for indirect rendering functions. - * - * \\author Kevin E. Martin <kevin@precisioninsight.com> - * \\author Ian Romanick <idr@us.ibm.com> - */ -""" + print textwrap.dedent("""\ + /** + * \\file + * Prototypes for indirect rendering functions. + * + * \\author Kevin E. Martin <kevin@precisioninsight.com> + * \\author Ian Romanick <idr@us.ibm.com> + */ + """) self.printFastcall() self.printNoinline() - print """ -#include <X11/Xfuncproto.h> -#include "glxclient.h" + print textwrap.dedent("""\ + #include <X11/Xfuncproto.h> + #include "glxclient.h" -extern _X_HIDDEN NOINLINE CARD32 __glXReadReply( Display *dpy, size_t size, - void * dest, GLboolean reply_is_always_array ); + extern _X_HIDDEN NOINLINE CARD32 __glXReadReply( Display *dpy, size_t size, + void * dest, GLboolean reply_is_always_array ); -extern _X_HIDDEN NOINLINE void __glXReadPixelReply( Display *dpy, - struct glx_context * gc, unsigned max_dim, GLint width, GLint height, - GLint depth, GLenum format, GLenum type, void * dest, - GLboolean dimensions_in_reply ); + extern _X_HIDDEN NOINLINE void __glXReadPixelReply( Display *dpy, + struct glx_context * gc, unsigned max_dim, GLint width, GLint height, + GLint depth, GLenum format, GLenum type, void * dest, + GLboolean dimensions_in_reply ); -extern _X_HIDDEN NOINLINE FASTCALL GLubyte * __glXSetupSingleRequest( - struct glx_context * gc, GLint sop, GLint cmdlen ); + extern _X_HIDDEN NOINLINE FASTCALL GLubyte * __glXSetupSingleRequest( + struct glx_context * gc, GLint sop, GLint cmdlen ); -extern _X_HIDDEN NOINLINE FASTCALL GLubyte * __glXSetupVendorRequest( - struct glx_context * gc, GLint code, GLint vop, GLint cmdlen ); -""" + extern _X_HIDDEN NOINLINE FASTCALL GLubyte * __glXSetupVendorRequest( + struct glx_context * gc, GLint code, GLint vop, GLint cmdlen ); + """) def printBody(self, api): diff --git a/src/mapi/glapi/gen/glX_proto_size.py b/src/mapi/glapi/gen/glX_proto_size.py index cdae55407d..9bf1b20774 100644 --- a/src/mapi/glapi/gen/glX_proto_size.py +++ b/src/mapi/glapi/gen/glX_proto_size.py @@ -28,6 +28,7 @@ import argparse import string +import textwrap import glX_XML import gl_XML @@ -374,14 +375,15 @@ class PrintGlxSizeStubs_c(PrintGlxSizeStubs_common): class PrintGlxSizeStubs_h(PrintGlxSizeStubs_common): def printRealHeader(self): - print """/** - * \\file - * Prototypes for functions used to determine the number of data elements in - * various GLX protocol messages. - * - * \\author Ian Romanick <idr@us.ibm.com> - */ -""" + print textwrap.dedent("""\ + /** + * \\file + * Prototypes for functions used to determine the number of data elements in + * various GLX protocol messages. + * + * \\author Ian Romanick <idr@us.ibm.com> + */ + """) print '#include <X11/Xfuncproto.h>' print '' self.printPure() diff --git a/src/mapi/glapi/gen/gl_SPARC_asm.py b/src/mapi/glapi/gen/gl_SPARC_asm.py index 138616aae1..52aa98b2a4 100644 --- a/src/mapi/glapi/gen/gl_SPARC_asm.py +++ b/src/mapi/glapi/gen/gl_SPARC_asm.py @@ -27,6 +27,7 @@ # Ian Romanick <idr@us.ibm.com> import argparse +import textwrap import glX_XML import gl_XML @@ -37,8 +38,10 @@ class PrintGenericStubs(gl_XML.gl_print_base): gl_XML.gl_print_base.__init__(self) self.name = "gl_SPARC_asm.py (from Mesa)" self.license = license.bsd_license_template % ( \ -"""Copyright (C) 1999-2003 Brian Paul All Rights Reserved. -(C) Copyright IBM Corporation 2004""", "BRIAN PAUL, IBM") + textwrap.dedent("""\ + Copyright (C) 1999-2003 Brian Paul All Rights Reserved. + (C) Copyright IBM Corporation 2004"""), + "BRIAN PAUL, IBM") def printRealHeader(self): diff --git a/src/mapi/glapi/gen/gl_XML.py b/src/mapi/glapi/gen/gl_XML.py index b4487cb440..dbac4780ae 100644 --- a/src/mapi/glapi/gen/gl_XML.py +++ b/src/mapi/glapi/gen/gl_XML.py @@ -32,6 +32,7 @@ from decimal import Decimal import os.path import re import string +import textwrap import xml.etree.ElementTree as ET import static_data @@ -188,11 +189,13 @@ class gl_print_base(object): The name is also added to the file's undef_list. """ self.undef_list.append("PURE") - print """# if defined(__GNUC__) -# define PURE __attribute__((pure)) -# else -# define PURE -# endif""" + print textwrap.dedent("""\ + # if defined(__GNUC__) + # define PURE __attribute__((pure)) + # else + # define PURE + # endif + """) return @@ -208,11 +211,13 @@ class gl_print_base(object): """ self.undef_list.append("FASTCALL") - print """# if defined(__i386__) && defined(__GNUC__) && !defined(__CYGWIN__) && !defined(__MINGW32__) -# define FASTCALL __attribute__((fastcall)) -# else -# define FASTCALL -# endif""" + print textwrap.dedent("""\ + # if defined(__i386__) && defined(__GNUC__) && !defined(__CYGWIN__) && !defined(__MINGW32__) + # define FASTCALL __attribute__((fastcall)) + # else + # define FASTCALL + # endif + """) return @@ -228,11 +233,13 @@ class gl_print_base(object): """ self.undef_list.append(S) - print """# if defined(__GNUC__) && !defined(__CYGWIN__) && !defined(__MINGW32__) -# define %s __attribute__((visibility("%s"))) -# else -# define %s -# endif""" % (S, s, S) + print textwrap.dedent("""\ + # if defined(__GNUC__) && !defined(__CYGWIN__) && !defined(__MINGW32__) + # define %s __attribute__((visibility("%s"))) + # else + # define %s + # endif + """ % (S, s, S)) return @@ -248,11 +255,13 @@ class gl_print_base(object): """ self.undef_list.append("NOINLINE") - print """# if defined(__GNUC__) -# define NOINLINE __attribute__((noinline)) -# else -# define NOINLINE -# endif""" + print textwrap.dedent("""\ + # if defined(__GNUC__) + # define NOINLINE __attribute__((noinline)) + # else + # define NOINLINE + # endif + """) return diff --git a/src/mapi/glapi/gen/gl_apitemp.py b/src/mapi/glapi/gen/gl_apitemp.py index e80b5b3be8..9f90ad72fd 100644 --- a/src/mapi/glapi/gen/gl_apitemp.py +++ b/src/mapi/glapi/gen/gl_apitemp.py @@ -27,6 +27,7 @@ # Ian Romanick <idr@us.ibm.com> import argparse +import textwrap import glX_XML import gl_XML @@ -38,8 +39,10 @@ class PrintGlOffsets(gl_XML.gl_print_base): self.name = "gl_apitemp.py (from Mesa)" self.license = license.bsd_license_template % ( \ -"""Copyright (C) 1999-2001 Brian Paul All Rights Reserved. -(C) Copyright IBM Corporation 2004""", "BRIAN PAUL, IBM") + textwrap.dedent("""\ + Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + (C) Copyright IBM Corporation 2004"""), + "BRIAN PAUL, IBM") self.es = es @@ -120,77 +123,77 @@ class PrintGlOffsets(gl_XML.gl_print_base): def printRealHeader(self): print '' self.printVisibility( "HIDDEN", "hidden" ) - print """ -/* - * This file is a template which generates the OpenGL API entry point - * functions. It should be included by a .c file which first defines - * the following macros: - * KEYWORD1 - usually nothing, but might be __declspec(dllexport) on Win32 - * KEYWORD2 - usually nothing, but might be __stdcall on Win32 - * NAME(n) - builds the final function name (usually add "gl" prefix) - * DISPATCH(func, args, msg) - code to do dispatch of named function. - * msg is a printf-style debug message. - * RETURN_DISPATCH(func, args, msg) - code to do dispatch with a return value - * - * Here is an example which generates the usual OpenGL functions: - * #define KEYWORD1 - * #define KEYWORD2 - * #define NAME(func) gl##func - * #define DISPATCH(func, args, msg) \\ - * struct _glapi_table *dispatch = CurrentDispatch; \\ - * (*dispatch->func) args - * #define RETURN DISPATCH(func, args, msg) \\ - * struct _glapi_table *dispatch = CurrentDispatch; \\ - * return (*dispatch->func) args - * - */ - - -#if defined( NAME ) -#ifndef KEYWORD1 -#define KEYWORD1 -#endif - -#ifndef KEYWORD1_ALT -#define KEYWORD1_ALT HIDDEN -#endif - -#ifndef KEYWORD2 -#define KEYWORD2 -#endif - -#ifndef DISPATCH -#error DISPATCH must be defined -#endif - -#ifndef RETURN_DISPATCH -#error RETURN_DISPATCH must be defined -#endif - -""" + print textwrap.dedent("""\ + /* + * This file is a template which generates the OpenGL API entry point + * functions. It should be included by a .c file which first defines + * the following macros: + * KEYWORD1 - usually nothing, but might be __declspec(dllexport) on Win32 + * KEYWORD2 - usually nothing, but might be __stdcall on Win32 + * NAME(n) - builds the final function name (usually add "gl" prefix) + * DISPATCH(func, args, msg) - code to do dispatch of named function. + * msg is a printf-style debug message. + * RETURN_DISPATCH(func, args, msg) - code to do dispatch with a return value + * + * Here is an example which generates the usual OpenGL functions: + * #define KEYWORD1 + * #define KEYWORD2 + * #define NAME(func) gl##func + * #define DISPATCH(func, args, msg) \\ + * struct _glapi_table *dispatch = CurrentDispatch; \\ + * (*dispatch->func) args + * #define RETURN DISPATCH(func, args, msg) \\ + * struct _glapi_table *dispatch = CurrentDispatch; \\ + * return (*dispatch->func) args + * + */ + + + #if defined( NAME ) + #ifndef KEYWORD1 + #define KEYWORD1 + #endif + + #ifndef KEYWORD1_ALT + #define KEYWORD1_ALT HIDDEN + #endif + + #ifndef KEYWORD2 + #define KEYWORD2 + #endif + + #ifndef DISPATCH + #error DISPATCH must be defined + #endif + + #ifndef RETURN_DISPATCH + #error RETURN_DISPATCH must be defined + #endif + """) return def printInitDispatch(self, api): - print """ -#endif /* defined( NAME ) */ + print textwrap.dedent("""\ + #endif /* defined( NAME ) */ -/* - * This is how a dispatch table can be initialized with all the functions - * we generated above. - */ -#ifdef DISPATCH_TABLE_NAME + /* + * This is how a dispatch table can be initialized with all the functions + * we generated above. + */ + #ifdef DISPATCH_TABLE_NAME -#ifndef TABLE_ENTRY -#error TABLE_ENTRY must be defined -#endif + #ifndef TABLE_ENTRY + #error TABLE_ENTRY must be defined + #endif -#ifdef _GLAPI_SKIP_NORMAL_ENTRY_POINTS -#error _GLAPI_SKIP_NORMAL_ENTRY_POINTS must not be defined -#endif + #ifdef _GLAPI_SKIP_NORMAL_ENTRY_POINTS + #error _GLAPI_SKIP_NORMAL_ENTRY_POINTS must not be defined + #endif -_glapi_proc DISPATCH_TABLE_NAME[] = {""" + _glapi_proc DISPATCH_TABLE_NAME[] = { + """) for f in api.functionIterateByOffset(): print ' TABLE_ENTRY(%s),' % (f.dispatch_name()) @@ -208,13 +211,14 @@ _glapi_proc DISPATCH_TABLE_NAME[] = {""" def printAliasedTable(self, api): - print """ -/* - * This is just used to silence compiler warnings. - * We list the functions which are not otherwise used. - */ -#ifdef UNUSED_TABLE_NAME -_glapi_proc UNUSED_TABLE_NAME[] = {""" + print textwrap.dedent("""\ + /* + * This is just used to silence compiler warnings. + * We list the functions which are not otherwise used. + */ + #ifdef UNUSED_TABLE_NAME + _glapi_proc UNUSED_TABLE_NAME[] = { + """) normal_entries = [] proto_entries = [] diff --git a/src/mapi/glapi/gen/gl_enums.py b/src/mapi/glapi/gen/gl_enums.py index d23e783435..0ef0633c7b 100644 --- a/src/mapi/glapi/gen/gl_enums.py +++ b/src/mapi/glapi/gen/gl_enums.py @@ -29,6 +29,7 @@ import argparse import re +import textwrap import xml.etree.ElementTree as ET import gl_XML @@ -41,7 +42,8 @@ class PrintGlEnums(gl_XML.gl_print_base): self.name = "gl_enums.py (from Mesa)" self.license = license.bsd_license_template % ( \ -"""Copyright (C) 1999-2005 Brian Paul All Rights Reserved.""", "BRIAN PAUL") + "Copyright (C) 1999-2005 Brian Paul All Rights Reserved.", + "BRIAN PAUL") # Mapping from enum value to (name, priority) tuples. self.enum_table = {} # Mapping from enum name to value @@ -62,85 +64,83 @@ class PrintGlEnums(gl_XML.gl_print_base): return def print_code(self): - print """ -typedef int (*cfunc)(const void *, const void *); - -/** - * Compare a key enum value to an element in the \c enum_string_table_offsets array. - * - * \c bsearch always passes the key as the first parameter and the pointer - * to the array element as the second parameter. We can elimiate some - * extra work by taking advantage of that fact. - * - * \param a Pointer to the desired enum name. - * \param b Pointer into the \c enum_string_table_offsets array. - */ -static int compar_nr( const int *a, enum_elt *b ) -{ - return a[0] - b->n; -} - - -static char token_tmp[20]; - -const char *_mesa_enum_to_string( int nr ) -{ - enum_elt *elt; - - elt = bsearch(& nr, enum_string_table_offsets, - ARRAY_SIZE(enum_string_table_offsets), - sizeof(enum_string_table_offsets[0]), - (cfunc) compar_nr); - - if (elt != NULL) { - return &enum_string_table[elt->offset]; - } - else { - /* this is not re-entrant safe, no big deal here */ - _mesa_snprintf(token_tmp, sizeof(token_tmp) - 1, "0x%x", nr); - token_tmp[sizeof(token_tmp) - 1] = '\\0'; - return token_tmp; - } -} - -/** - * Primitive names - */ -static const char *prim_names[PRIM_MAX+3] = { - "GL_POINTS", - "GL_LINES", - "GL_LINE_LOOP", - "GL_LINE_STRIP", - "GL_TRIANGLES", - "GL_TRIANGLE_STRIP", - "GL_TRIANGLE_FAN", - "GL_QUADS", - "GL_QUAD_STRIP", - "GL_POLYGON", - "GL_LINES_ADJACENCY", - "GL_LINE_STRIP_ADJACENCY", - "GL_TRIANGLES_ADJACENCY", - "GL_TRIANGLE_STRIP_ADJACENCY", - "GL_PATCHES", - "outside begin/end", - "unknown state" -}; - - -/* Get the name of an enum given that it is a primitive type. Avoids - * GL_FALSE/GL_POINTS ambiguity and others. - */ -const char * -_mesa_lookup_prim_by_nr(GLuint nr) -{ - if (nr < ARRAY_SIZE(prim_names)) - return prim_names[nr]; - else - return "invalid mode"; -} - - -""" + print textwrap.dedent("""\ + typedef int (*cfunc)(const void *, const void *); + + /** + * Compare a key enum value to an element in the \c enum_string_table_offsets array. + * + * \c bsearch always passes the key as the first parameter and the pointer + * to the array element as the second parameter. We can elimiate some + * extra work by taking advantage of that fact. + * + * \param a Pointer to the desired enum name. + * \param b Pointer into the \c enum_string_table_offsets array. + */ + static int compar_nr( const int *a, enum_elt *b ) + { + return a[0] - b->n; + } + + + static char token_tmp[20]; + + const char *_mesa_enum_to_string( int nr ) + { + enum_elt *elt; + + elt = bsearch(& nr, enum_string_table_offsets, + ARRAY_SIZE(enum_string_table_offsets), + sizeof(enum_string_table_offsets[0]), + (cfunc) compar_nr); + + if (elt != NULL) { + return &enum_string_table[elt->offset]; + } + else { + /* this is not re-entrant safe, no big deal here */ + _mesa_snprintf(token_tmp, sizeof(token_tmp) - 1, "0x%x", nr); + token_tmp[sizeof(token_tmp) - 1] = '\\0'; + return token_tmp; + } + } + + /** + * Primitive names + */ + static const char *prim_names[PRIM_MAX+3] = { + "GL_POINTS", + "GL_LINES", + "GL_LINE_LOOP", + "GL_LINE_STRIP", + "GL_TRIANGLES", + "GL_TRIANGLE_STRIP", + "GL_TRIANGLE_FAN", + "GL_QUADS", + "GL_QUAD_STRIP", + "GL_POLYGON", + "GL_LINES_ADJACENCY", + "GL_LINE_STRIP_ADJACENCY", + "GL_TRIANGLES_ADJACENCY", + "GL_TRIANGLE_STRIP_ADJACENCY", + "GL_PATCHES", + "outside begin/end", + "unknown state" + }; + + + /* Get the name of an enum given that it is a primitive type. Avoids + * GL_FALSE/GL_POINTS ambiguity and others. + */ + const char * + _mesa_lookup_prim_by_nr(GLuint nr) + { + if (nr < ARRAY_SIZE(prim_names)) + return prim_names[nr]; + else + return "invalid mode"; + } + """) return diff --git a/src/mapi/glapi/gen/gl_gentable.py b/src/mapi/glapi/gen/gl_gentable.py index c353e1f6ed..aa174ab3d8 100644 --- a/src/mapi/glapi/gen/gl_gentable.py +++ b/src/mapi/glapi/gen/gl_gentable.py @@ -32,6 +32,7 @@ # Ian Romanick <idr@us.ibm.com> import argparse +import textwrap import glX_XML import gl_XML @@ -157,9 +158,11 @@ class PrintCode(gl_XML.gl_print_base): self.name = "gl_gentable.py (from Mesa)" self.license = license.bsd_license_template % ( \ -"""Copyright (C) 1999-2001 Brian Paul All Rights Reserved. -(C) Copyright IBM Corporation 2004, 2005 -(C) Copyright Apple Inc 2011""", "BRIAN PAUL, IBM") + textwrap.dedent("""\ + Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + (C) Copyright IBM Corporation 2004, 2005 + (C) Copyright Apple Inc 2011"""), + "BRIAN PAUL, IBM") return diff --git a/src/mapi/glapi/gen/gl_procs.py b/src/mapi/glapi/gen/gl_procs.py index 9bd71d5f93..04c54b5419 100644 --- a/src/mapi/glapi/gen/gl_procs.py +++ b/src/mapi/glapi/gen/gl_procs.py @@ -27,6 +27,7 @@ # Ian Romanick <idr@us.ibm.com> import argparse +import textwrap import license import gl_XML @@ -40,34 +41,35 @@ class PrintGlProcs(gl_XML.gl_print_base): self.es = es self.name = "gl_procs.py (from Mesa)" self.license = license.bsd_license_template % ( \ -"""Copyright (C) 1999-2001 Brian Paul All Rights Reserved. -(C) Copyright IBM Corporation 2004, 2006""", "BRIAN PAUL, IBM") + textwrap.dedent("""\ + Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + (C) Copyright IBM Corporation 2004, 2006"""), + "BRIAN PAUL, IBM") def printRealHeader(self): - print """ -/* This file is only included by glapi.c and is used for - * the GetProcAddress() function - */ - -typedef struct { - GLint Name_offset; -#if defined(NEED_FUNCTION_POINTER) || defined(GLX_INDIRECT_RENDERING) - _glapi_proc Address; -#endif - GLuint Offset; -} glprocs_table_t; - -#if !defined(NEED_FUNCTION_POINTER) && !defined(GLX_INDIRECT_RENDERING) -# define NAME_FUNC_OFFSET(n,f1,f2,f3,o) { n , o } -#elif defined(NEED_FUNCTION_POINTER) && !defined(GLX_INDIRECT_RENDERING) -# define NAME_FUNC_OFFSET(n,f1,f2,f3,o) { n , (_glapi_proc) f1 , o } -#elif defined(NEED_FUNCTION_POINTER) && defined(GLX_INDIRECT_RENDERING) -# define NAME_FUNC_OFFSET(n,f1,f2,f3,o) { n , (_glapi_proc) f2 , o } -#elif !defined(NEED_FUNCTION_POINTER) && defined(GLX_INDIRECT_RENDERING) -# define NAME_FUNC_OFFSET(n,f1,f2,f3,o) { n , (_glapi_proc) f3 , o } -#endif - -""" + print textwrap.dedent("""\ + /* This file is only included by glapi.c and is used for + * the GetProcAddress() function + */ + + typedef struct { + GLint Name_offset; + #if defined(NEED_FUNCTION_POINTER) || defined(GLX_INDIRECT_RENDERING) + _glapi_proc Address; + #endif + GLuint Offset; + } glprocs_table_t; + + #if !defined(NEED_FUNCTION_POINTER) && !defined(GLX_INDIRECT_RENDERING) + # define NAME_FUNC_OFFSET(n,f1,f2,f3,o) { n , o } + #elif defined(NEED_FUNCTION_POINTER) && !defined(GLX_INDIRECT_RENDERING) + # define NAME_FUNC_OFFSET(n,f1,f2,f3,o) { n , (_glapi_proc) f1 , o } + #elif defined(NEED_FUNCTION_POINTER) && defined(GLX_INDIRECT_RENDERING) + # define NAME_FUNC_OFFSET(n,f1,f2,f3,o) { n , (_glapi_proc) f2 , o } + #elif !defined(NEED_FUNCTION_POINTER) && defined(GLX_INDIRECT_RENDERING) + # define NAME_FUNC_OFFSET(n,f1,f2,f3,o) { n , (_glapi_proc) f3 , o } + #endif + """) return def printRealFooter(self): diff --git a/src/mapi/glapi/gen/gl_table.py b/src/mapi/glapi/gen/gl_table.py index 6f8fa36cfc..d15dc0b620 100644 --- a/src/mapi/glapi/gen/gl_table.py +++ b/src/mapi/glapi/gen/gl_table.py @@ -28,6 +28,7 @@ # Ian Romanick <idr@us.ibm.com> import argparse +import textwrap import gl_XML import license @@ -40,8 +41,10 @@ class PrintGlTable(gl_XML.gl_print_base): self.header_tag = '_GLAPI_TABLE_H_' self.name = "gl_table.py (from Mesa)" self.license = license.bsd_license_template % ( \ -"""Copyright (C) 1999-2003 Brian Paul All Rights Reserved. -(C) Copyright IBM Corporation 2004""", "BRIAN PAUL, IBM") + textwrap.dedent("""\ + Copyright (C) 1999-2003 Brian Paul All Rights Reserved. + (C) Copyright IBM Corporation 2004"""), + "BRIAN PAUL, IBM") self.ifdef_emitted = False return @@ -87,18 +90,18 @@ class PrintRemapTable(gl_XML.gl_print_base): def printRealHeader(self): - print """ -/** - * \\file main/dispatch.h - * Macros for handling GL dispatch tables. - * - * For each known GL function, there are 3 macros in this file. The first - * macro is named CALL_FuncName and is used to call that GL function using - * the specified dispatch table. The other 2 macros, called GET_FuncName - * can SET_FuncName, are used to get and set the dispatch pointer for the - * named function in the specified dispatch table. - */ -""" + print textwrap.dedent("""\ + /** + * \\file main/dispatch.h + * Macros for handling GL dispatch tables. + * + * For each known GL function, there are 3 macros in this file. The first + * macro is named CALL_FuncName and is used to call that GL function using + * the specified dispatch table. The other 2 macros, called GET_FuncName + * can SET_FuncName, are used to get and set the dispatch pointer for the + * named function in the specified dispatch table. + */ + """) return diff --git a/src/mapi/glapi/gen/gl_x86_asm.py b/src/mapi/glapi/gen/gl_x86_asm.py index 2b9db45416..e55a35819c 100644 --- a/src/mapi/glapi/gen/gl_x86_asm.py +++ b/src/mapi/glapi/gen/gl_x86_asm.py @@ -27,6 +27,7 @@ # Ian Romanick <idr@us.ibm.com> import argparse +import textwrap import glX_XML import gl_XML @@ -39,8 +40,10 @@ class PrintGenericStubs(gl_XML.gl_print_base): self.name = "gl_x86_asm.py (from Mesa)" self.license = license.bsd_license_template % ( \ -"""Copyright (C) 1999-2001 Brian Paul All Rights Reserved. -(C) Copyright IBM Corporation 2004, 2005""", "BRIAN PAUL, IBM") + textwrap.dedent("""\ + Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + (C) Copyright IBM Corporation 2004, 2005"""), + "BRIAN PAUL, IBM") return |