diff options
author | Mathieu Bridon <[email protected]> | 2018-07-05 15:17:32 +0200 |
---|---|---|
committer | Dylan Baker <[email protected]> | 2018-07-06 10:04:22 -0700 |
commit | 0f7b18fa0d353aab0a44082b1aca8d8c00df71a7 (patch) | |
tree | e511fe8f70b48ad5203e3a0e52d0dc1b086bfd91 /src/mapi/glapi | |
parent | b3a42fa0667caeeebabd9e6aeb46a9534810c2f3 (diff) |
python: Use the print function
In Python 2, `print` was a statement, but it became a function in
Python 3.
Using print functions everywhere makes the script compatible with Python
versions >= 2.6, including Python 3.
Signed-off-by: Mathieu Bridon <[email protected]>
Acked-by: Eric Engestrom <[email protected]>
Acked-by: Dylan Baker <[email protected]>
Diffstat (limited to 'src/mapi/glapi')
-rw-r--r-- | src/mapi/glapi/gen/glX_proto_common.py | 8 | ||||
-rw-r--r-- | src/mapi/glapi/gen/glX_proto_send.py | 408 | ||||
-rw-r--r-- | src/mapi/glapi/gen/glX_proto_size.py | 232 | ||||
-rw-r--r-- | src/mapi/glapi/gen/gl_SPARC_asm.py | 360 | ||||
-rw-r--r-- | src/mapi/glapi/gen/gl_XML.py | 48 | ||||
-rw-r--r-- | src/mapi/glapi/gen/gl_apitemp.py | 96 | ||||
-rw-r--r-- | src/mapi/glapi/gen/gl_enums.py | 62 | ||||
-rw-r--r-- | src/mapi/glapi/gen/gl_genexec.py | 12 | ||||
-rw-r--r-- | src/mapi/glapi/gen/gl_gentable.py | 14 | ||||
-rw-r--r-- | src/mapi/glapi/gen/gl_marshal.py | 26 | ||||
-rw-r--r-- | src/mapi/glapi/gen/gl_marshal_h.py | 16 | ||||
-rw-r--r-- | src/mapi/glapi/gen/gl_procs.py | 60 | ||||
-rw-r--r-- | src/mapi/glapi/gen/gl_table.py | 126 | ||||
-rw-r--r-- | src/mapi/glapi/gen/gl_x86-64_asm.py | 184 | ||||
-rw-r--r-- | src/mapi/glapi/gen/gl_x86_asm.py | 264 | ||||
-rw-r--r-- | src/mapi/glapi/gen/remap_helper.py | 46 | ||||
-rw-r--r-- | src/mapi/glapi/gen/typeexpr.py | 6 |
17 files changed, 1001 insertions, 967 deletions
diff --git a/src/mapi/glapi/gen/glX_proto_common.py b/src/mapi/glapi/gen/glX_proto_common.py index bd1192cb47b..adc20dc9f02 100644 --- a/src/mapi/glapi/gen/glX_proto_common.py +++ b/src/mapi/glapi/gen/glX_proto_common.py @@ -24,6 +24,8 @@ # Authors: # Ian Romanick <[email protected]> +from __future__ import print_function + import gl_XML, glX_XML import string @@ -80,12 +82,12 @@ class glx_print_proto(gl_XML.gl_print_base): compsize = self.size_call(f) if compsize: - print ' const GLuint compsize = %s;' % (compsize) + print(' const GLuint compsize = %s;' % (compsize)) if bias: - print ' const GLuint cmdlen = %s - %u;' % (f.command_length(), bias) + print(' const GLuint cmdlen = %s - %u;' % (f.command_length(), bias)) else: - print ' const GLuint cmdlen = %s;' % (f.command_length()) + print(' const GLuint cmdlen = %s;' % (f.command_length())) #print '' return compsize diff --git a/src/mapi/glapi/gen/glX_proto_send.py b/src/mapi/glapi/gen/glX_proto_send.py index d458214fb74..f199e9a0a16 100644 --- a/src/mapi/glapi/gen/glX_proto_send.py +++ b/src/mapi/glapi/gen/glX_proto_send.py @@ -26,6 +26,8 @@ # Ian Romanick <[email protected]> # Jeremy Kolb <[email protected]> +from __future__ import print_function + import argparse import gl_XML, glX_XML, glX_proto_common, license @@ -163,58 +165,58 @@ class PrintGlxProtoStubs(glX_proto_common.glx_print_proto): return def printRealHeader(self): - print '' - print '#include <GL/gl.h>' - print '#include "indirect.h"' - print '#include "glxclient.h"' - print '#include "indirect_size.h"' - print '#include "glapi.h"' - print '#include <GL/glxproto.h>' - print '#include <X11/Xlib-xcb.h>' - print '#include <xcb/xcb.h>' - print '#include <xcb/glx.h>' - print '#include <limits.h>' - - print '' + print('') + print('#include <GL/gl.h>') + print('#include "indirect.h"') + print('#include "glxclient.h"') + print('#include "indirect_size.h"') + print('#include "glapi.h"') + print('#include <GL/glxproto.h>') + print('#include <X11/Xlib-xcb.h>') + print('#include <xcb/xcb.h>') + print('#include <xcb/glx.h>') + print('#include <limits.h>') + + print('') self.printFastcall() self.printNoinline() - print '' - - print 'static _X_INLINE int safe_add(int a, int b)' - print '{' - print ' if (a < 0 || b < 0) return -1;' - print ' if (INT_MAX - a < b) return -1;' - print ' return a + b;' - print '}' - print 'static _X_INLINE int safe_mul(int a, int b)' - print '{' - print ' if (a < 0 || b < 0) return -1;' - print ' if (a == 0 || b == 0) return 0;' - print ' if (a > INT_MAX / b) return -1;' - print ' return a * b;' - print '}' - print 'static _X_INLINE int safe_pad(int a)' - print '{' - print ' int ret;' - print ' if (a < 0) return -1;' - print ' if ((ret = safe_add(a, 3)) < 0) return -1;' - print ' return ret & (GLuint)~3;' - print '}' - print '' - - print '#ifndef __GNUC__' - print '# define __builtin_expect(x, y) x' - print '#endif' - print '' - print '/* If the size and opcode values are known at compile-time, this will, on' - print ' * x86 at least, emit them with a single instruction.' - print ' */' - print '#define emit_header(dest, op, size) \\' - print ' do { union { short s[2]; int i; } temp; \\' - print ' temp.s[0] = (size); temp.s[1] = (op); \\' - print ' *((int *)(dest)) = temp.i; } while(0)' - print '' - print """NOINLINE CARD32 + print('') + + print('static _X_INLINE int safe_add(int a, int b)') + print('{') + print(' if (a < 0 || b < 0) return -1;') + print(' if (INT_MAX - a < b) return -1;') + print(' return a + b;') + print('}') + print('static _X_INLINE int safe_mul(int a, int b)') + print('{') + print(' if (a < 0 || b < 0) return -1;') + print(' if (a == 0 || b == 0) return 0;') + print(' if (a > INT_MAX / b) return -1;') + print(' return a * b;') + print('}') + print('static _X_INLINE int safe_pad(int a)') + print('{') + print(' int ret;') + print(' if (a < 0) return -1;') + print(' if ((ret = safe_add(a, 3)) < 0) return -1;') + print(' return ret & (GLuint)~3;') + print('}') + print('') + + print('#ifndef __GNUC__') + print('# define __builtin_expect(x, y) x') + print('#endif') + print('') + print('/* If the size and opcode values are known at compile-time, this will, on') + print(' * x86 at least, emit them with a single instruction.') + print(' */') + print('#define emit_header(dest, op, size) \\') + print(' do { union { short s[2]; int i; } temp; \\') + 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; @@ -326,7 +328,7 @@ const GLuint __glXDefaultPixelStore[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 1 }; #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) @@ -381,20 +383,20 @@ 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 """ + print(""" #ifdef GLX_INDIRECT_RENDERING static const struct proc_pair { const char *name; _glapi_proc proc; -} proc_pairs[%d] = {""" % len(procs) +} 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 """}; + 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) @@ -419,16 +421,16 @@ __indirect_get_proc_address(const char *name) } #endif /* GLX_INDIRECT_RENDERING */ -""" +""") return def printFunction(self, func, name): footer = '}\n' if func.glx_rop == ~0: - print 'static %s' % (func.return_type) - print '%s( unsigned opcode, unsigned dim, %s )' % (func.name, func.get_parameter_string()) - print '{' + print('static %s' % (func.return_type)) + print('%s( unsigned opcode, unsigned dim, %s )' % (func.name, func.get_parameter_string())) + print('{') else: if func.has_different_protocol(name): if func.return_type == "void": @@ -437,27 +439,27 @@ __indirect_get_proc_address(const char *name) ret_string = "return " func_name = func.static_glx_name(name) - print '#define %s %d' % (func.opcode_vendor_name(name), func.glx_vendorpriv) - print '%s gl%s(%s)' % (func.return_type, func_name, func.get_parameter_string()) - print '{' - print ' struct glx_context * const gc = __glXGetCurrentContext();' - print '' - print '#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)' - print ' if (gc->isDirect) {' - print ' const _glapi_proc *const disp_table = (_glapi_proc *)GET_DISPATCH();' - print ' PFNGL%sPROC p =' % (name.upper()) - print ' (PFNGL%sPROC) disp_table[%d];' % (name.upper(), func.offset) - print ' %sp(%s);' % (ret_string, func.get_called_parameter_string()) - print ' } else' - print '#endif' - print ' {' + print('#define %s %d' % (func.opcode_vendor_name(name), func.glx_vendorpriv)) + print('%s gl%s(%s)' % (func.return_type, func_name, func.get_parameter_string())) + print('{') + print(' struct glx_context * const gc = __glXGetCurrentContext();') + print('') + print('#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)') + print(' if (gc->isDirect) {') + print(' const _glapi_proc *const disp_table = (_glapi_proc *)GET_DISPATCH();') + print(' PFNGL%sPROC p =' % (name.upper())) + print(' (PFNGL%sPROC) disp_table[%d];' % (name.upper(), func.offset)) + print(' %sp(%s);' % (ret_string, func.get_called_parameter_string())) + print(' } else') + print('#endif') + print(' {') footer = '}\n}\n' else: - print '#define %s %d' % (func.opcode_name(), func.opcode_value()) + print('#define %s %d' % (func.opcode_name(), func.opcode_value())) - print '%s __indirect_gl%s(%s)' % (func.return_type, name, func.get_parameter_string()) - print '{' + print('%s __indirect_gl%s(%s)' % (func.return_type, name, func.get_parameter_string())) + print('{') if func.glx_rop != 0 or func.vectorequiv != None: @@ -469,15 +471,15 @@ __indirect_get_proc_address(const char *name) self.printSingleFunction(func, name) pass else: - print "/* Missing GLX protocol for %s. */" % (name) + print("/* Missing GLX protocol for %s. */" % (name)) - print footer + print(footer) return def print_generic_function(self, n): size = (n + 3) & ~3 - print """static FASTCALL NOINLINE void + print("""static FASTCALL NOINLINE void generic_%u_byte( GLint rop, const void * ptr ) { struct glx_context * const gc = __glXGetCurrentContext(); @@ -488,7 +490,7 @@ generic_%u_byte( GLint rop, const void * ptr ) gc->pc += cmdlen; if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); } } -""" % (n, size + 4, size) +""" % (n, size + 4, size)) return @@ -499,14 +501,14 @@ generic_%u_byte( GLint rop, const void * ptr ) src_ptr = "&" + p.name if p.is_padding: - print '(void) memset((void *)(%s + %u), 0, %s);' \ - % (pc, p.offset + adjust, p.size_string() ) + print('(void) memset((void *)(%s + %u), 0, %s);' \ + % (pc, p.offset + adjust, p.size_string() )) elif not extra_offset: - print '(void) memcpy((void *)(%s + %u), (void *)(%s), %s);' \ - % (pc, p.offset + adjust, src_ptr, p.size_string() ) + print('(void) memcpy((void *)(%s + %u), (void *)(%s), %s);' \ + % (pc, p.offset + adjust, src_ptr, p.size_string() )) else: - print '(void) memcpy((void *)(%s + %u + %s), (void *)(%s), %s);' \ - % (pc, p.offset + adjust, extra_offset, src_ptr, p.size_string() ) + print('(void) memcpy((void *)(%s + %u + %s), (void *)(%s), %s);' \ + % (pc, p.offset + adjust, extra_offset, src_ptr, p.size_string() )) def common_emit_args(self, f, pc, adjust, skip_vla): extra_offset = None @@ -542,7 +544,7 @@ generic_%u_byte( GLint rop, const void * ptr ) self.common_emit_one_arg(param, pc, adjust, None) if f.pad_after(param): - print '(void) memcpy((void *)(%s + %u), zero, 4);' % (pc, (param.offset + param.size()) + adjust) + print('(void) memcpy((void *)(%s + %u), zero, 4);' % (pc, (param.offset + param.size()) + adjust)) else: [dim, width, height, depth, extent] = param.get_dimensions() @@ -552,14 +554,14 @@ generic_%u_byte( GLint rop, const void * ptr ) dim_str = str(dim) if param.is_padding: - print '(void) memset((void *)(%s + %u), 0, %s);' \ - % (pc, (param.offset - 4) + adjust, param.size_string() ) + print('(void) memset((void *)(%s + %u), 0, %s);' \ + % (pc, (param.offset - 4) + adjust, param.size_string() )) if param.img_null_flag: if large: - print '(void) memcpy((void *)(%s + %u), zero, 4);' % (pc, (param.offset - 4) + adjust) + print('(void) memcpy((void *)(%s + %u), zero, 4);' % (pc, (param.offset - 4) + adjust)) else: - print '(void) memcpy((void *)(%s + %u), (void *)((%s == NULL) ? one : zero), 4);' % (pc, (param.offset - 4) + adjust, param.name) + print('(void) memcpy((void *)(%s + %u), (void *)((%s == NULL) ? one : zero), 4);' % (pc, (param.offset - 4) + adjust, param.name)) pixHeaderPtr = "%s + %u" % (pc, adjust) @@ -571,13 +573,13 @@ generic_%u_byte( GLint rop, const void * ptr ) else: condition = 'compsize > 0' - print 'if (%s) {' % (condition) - print ' gc->fillImage(gc, %s, %s, %s, %s, %s, %s, %s, %s, %s);' % (dim_str, width, height, depth, param.img_format, param.img_type, param.name, pcPtr, pixHeaderPtr) - print '} else {' - print ' (void) memcpy( %s, default_pixel_store_%uD, default_pixel_store_%uD_size );' % (pixHeaderPtr, dim, dim) - print '}' + print('if (%s) {' % (condition)) + print(' gc->fillImage(gc, %s, %s, %s, %s, %s, %s, %s, %s, %s);' % (dim_str, width, height, depth, param.img_format, param.img_type, param.name, pcPtr, pixHeaderPtr)) + print('} else {') + print(' (void) memcpy( %s, default_pixel_store_%uD, default_pixel_store_%uD_size );' % (pixHeaderPtr, dim, dim)) + print('}') else: - print '__glXSendLargeImage(gc, compsize, %s, %s, %s, %s, %s, %s, %s, %s, %s);' % (dim_str, width, height, depth, param.img_format, param.img_type, param.name, pcPtr, pixHeaderPtr) + print('__glXSendLargeImage(gc, compsize, %s, %s, %s, %s, %s, %s, %s, %s, %s);' % (dim_str, width, height, depth, param.img_format, param.img_type, param.name, pcPtr, pixHeaderPtr)) return @@ -586,16 +588,16 @@ generic_%u_byte( GLint rop, const void * ptr ) if not op_name: op_name = f.opcode_real_name() - print 'const GLint op = %s;' % (op_name) - print 'const GLuint cmdlenLarge = cmdlen + 4;' - print 'GLubyte * const pc = __glXFlushRenderBuffer(gc, gc->pc);' - print '(void) memcpy((void *)(pc + 0), (void *)(&cmdlenLarge), 4);' - print '(void) memcpy((void *)(pc + 4), (void *)(&op), 4);' + print('const GLint op = %s;' % (op_name)) + print('const GLuint cmdlenLarge = cmdlen + 4;') + print('GLubyte * const pc = __glXFlushRenderBuffer(gc, gc->pc);') + print('(void) memcpy((void *)(pc + 0), (void *)(&cmdlenLarge), 4);') + print('(void) memcpy((void *)(pc + 4), (void *)(&op), 4);') return def common_func_print_just_start(self, f, name): - print ' struct glx_context * const gc = __glXGetCurrentContext();' + print(' struct glx_context * const gc = __glXGetCurrentContext();') # The only reason that single and vendor private commands need # a variable called 'dpy' is because they use the SyncHandle @@ -613,10 +615,10 @@ generic_%u_byte( GLint rop, const void * ptr ) if not f.glx_rop: for p in f.parameterIterateOutputs(): if p.is_image() and (p.img_format != "GL_COLOR_INDEX" or p.img_type != "GL_BITMAP"): - print ' const __GLXattribute * const state = gc->client_state_private;' + print(' const __GLXattribute * const state = gc->client_state_private;') break - print ' Display * const dpy = gc->currentDpy;' + print(' Display * const dpy = gc->currentDpy;') skip_condition = "dpy != NULL" elif f.can_be_large: skip_condition = "gc->currentDpy != NULL" @@ -625,35 +627,35 @@ generic_%u_byte( GLint rop, const void * ptr ) if f.return_type != 'void': - print ' %s retval = (%s) 0;' % (f.return_type, f.return_type) + print(' %s retval = (%s) 0;' % (f.return_type, f.return_type)) if name != None and name not in f.glx_vendorpriv_names: - print '#ifndef USE_XCB' + print('#ifndef USE_XCB') self.emit_packet_size_calculation(f, 0) if name != None and name not in f.glx_vendorpriv_names: - print '#endif' + print('#endif') if f.command_variable_length() != "": - print " if (0%s < 0) {" % f.command_variable_length() - print " __glXSetError(gc, GL_INVALID_VALUE);" + print(" if (0%s < 0) {" % f.command_variable_length()) + print(" __glXSetError(gc, GL_INVALID_VALUE);") if f.return_type != 'void': - print " return 0;" + print(" return 0;") else: - print " return;" - print " }" + print(" return;") + print(" }") condition_list = [] for p in f.parameterIterateCounters(): condition_list.append( "%s >= 0" % (p.name) ) # 'counter' parameters cannot be negative - print " if (%s < 0) {" % p.name - print " __glXSetError(gc, GL_INVALID_VALUE);" + print(" if (%s < 0) {" % p.name) + print(" __glXSetError(gc, GL_INVALID_VALUE);") if f.return_type != 'void': - print " return 0;" + print(" return 0;") else: - print " return;" - print " }" + print(" return;") + print(" }") if skip_condition: condition_list.append( skip_condition ) @@ -664,7 +666,7 @@ generic_%u_byte( GLint rop, const void * ptr ) else: skip_condition = "%s" % (condition_list.pop(0)) - print ' if (__builtin_expect(%s, 1)) {' % (skip_condition) + print(' if (__builtin_expect(%s, 1)) {' % (skip_condition)) return 1 else: return 0 @@ -674,16 +676,16 @@ generic_%u_byte( GLint rop, const void * ptr ) self.common_func_print_just_start(f, name) if self.debug: - print ' printf( "Enter %%s...\\n", "gl%s" );' % (f.name) + print(' printf( "Enter %%s...\\n", "gl%s" );' % (f.name)) if name not in f.glx_vendorpriv_names: # XCB specific: - print '#ifdef USE_XCB' + print('#ifdef USE_XCB') if self.debug: - print ' printf("\\tUsing XCB.\\n");' - print ' xcb_connection_t *c = XGetXCBConnection(dpy);' - print ' (void) __glXFlushRenderBuffer(gc, gc->pc);' + print(' printf("\\tUsing XCB.\\n");') + print(' xcb_connection_t *c = XGetXCBConnection(dpy);') + print(' (void) __glXFlushRenderBuffer(gc, gc->pc);') xcb_name = 'xcb_glx%s' % convertStringForXCB(name) iparams=[] @@ -710,7 +712,7 @@ generic_%u_byte( GLint rop, const void * ptr ) xcb_request = '%s(%s)' % (xcb_name, ", ".join(["c", "gc->currentContextTag"] + iparams + extra_iparams)) if f.needs_reply(): - print ' %s_reply_t *reply = %s_reply(c, %s, NULL);' % (xcb_name, xcb_name, xcb_request) + print(' %s_reply_t *reply = %s_reply(c, %s, NULL);' % (xcb_name, xcb_name, xcb_request)) if output: if output.is_image(): [dim, w, h, d, junk] = output.get_dimensions() @@ -721,30 +723,30 @@ generic_%u_byte( GLint rop, const void * ptr ) if dim < 2: h = "1" else: - print ' if (%s == 0) { %s = 1; }' % (h, h) + print(' if (%s == 0) { %s = 1; }' % (h, h)) if dim < 3: d = "1" else: - print ' if (%s == 0) { %s = 1; }' % (d, d) + print(' if (%s == 0) { %s = 1; }' % (d, d)) - print ' __glEmptyImage(gc, 3, %s, %s, %s, %s, %s, %s_data(reply), %s);' % (w, h, d, output.img_format, output.img_type, xcb_name, output.name) + print(' __glEmptyImage(gc, 3, %s, %s, %s, %s, %s, %s_data(reply), %s);' % (w, h, d, output.img_format, output.img_type, xcb_name, output.name)) else: if f.reply_always_array: - print ' (void)memcpy(%s, %s_data(reply), %s_data_length(reply) * sizeof(%s));' % (output.name, xcb_name, xcb_name, output.get_base_type_string()) + print(' (void)memcpy(%s, %s_data(reply), %s_data_length(reply) * sizeof(%s));' % (output.name, xcb_name, xcb_name, output.get_base_type_string())) else: - print ' /* the XXX_data_length() xcb function name is misleading, it returns the number */' - print ' /* of elements, not the length of the data part. A single element is embedded. */' - print ' if (%s_data_length(reply) == 1)' % (xcb_name) - print ' (void)memcpy(%s, &reply->datum, sizeof(reply->datum));' % (output.name) - print ' else' - print ' (void)memcpy(%s, %s_data(reply), %s_data_length(reply) * sizeof(%s));' % (output.name, xcb_name, xcb_name, output.get_base_type_string()) + print(' /* the XXX_data_length() xcb function name is misleading, it returns the number */') + print(' /* of elements, not the length of the data part. A single element is embedded. */') + print(' if (%s_data_length(reply) == 1)' % (xcb_name)) + print(' (void)memcpy(%s, &reply->datum, sizeof(reply->datum));' % (output.name)) + print(' else') + print(' (void)memcpy(%s, %s_data(reply), %s_data_length(reply) * sizeof(%s));' % (output.name, xcb_name, xcb_name, output.get_base_type_string())) if f.return_type != 'void': - print ' retval = reply->ret_val;' - print ' free(reply);' + print(' retval = reply->ret_val;') + print(' free(reply);') else: - print ' ' + xcb_request + ';' - print '#else' + print(' ' + xcb_request + ';') + print('#else') # End of XCB specific. @@ -754,9 +756,9 @@ generic_%u_byte( GLint rop, const void * ptr ) pc_decl = "(void)" if name in f.glx_vendorpriv_names: - print ' %s __glXSetupVendorRequest(gc, %s, %s, cmdlen);' % (pc_decl, f.opcode_real_name(), f.opcode_vendor_name(name)) + print(' %s __glXSetupVendorRequest(gc, %s, %s, cmdlen);' % (pc_decl, f.opcode_real_name(), f.opcode_vendor_name(name))) else: - print ' %s __glXSetupSingleRequest(gc, %s, cmdlen);' % (pc_decl, f.opcode_name()) + print(' %s __glXSetupSingleRequest(gc, %s, cmdlen);' % (pc_decl, f.opcode_name())) self.common_emit_args(f, "pc", 0, 0) @@ -765,12 +767,12 @@ generic_%u_byte( GLint rop, const void * ptr ) for img in images: if img.is_output: o = f.command_fixed_length() - 4 - print ' *(int32_t *)(pc + %u) = 0;' % (o) + print(' *(int32_t *)(pc + %u) = 0;' % (o)) if img.img_format != "GL_COLOR_INDEX" or img.img_type != "GL_BITMAP": - print ' * (int8_t *)(pc + %u) = state->storePack.swapEndian;' % (o) + print(' * (int8_t *)(pc + %u) = state->storePack.swapEndian;' % (o)) if f.img_reset: - print ' * (int8_t *)(pc + %u) = %s;' % (o + 1, f.img_reset) + print(' * (int8_t *)(pc + %u) = %s;' % (o + 1, f.img_reset)) return_name = '' @@ -787,9 +789,9 @@ generic_%u_byte( GLint rop, const void * ptr ) if p.is_image(): [dim, w, h, d, junk] = p.get_dimensions() if f.dimensions_in_reply: - print " __glXReadPixelReply(dpy, gc, %u, 0, 0, 0, %s, %s, %s, GL_TRUE);" % (dim, p.img_format, p.img_type, p.name) + print(" __glXReadPixelReply(dpy, gc, %u, 0, 0, 0, %s, %s, %s, GL_TRUE);" % (dim, p.img_format, p.img_type, p.name)) else: - print " __glXReadPixelReply(dpy, gc, %u, %s, %s, %s, %s, %s, %s, GL_FALSE);" % (dim, w, h, d, p.img_format, p.img_type, p.name) + print(" __glXReadPixelReply(dpy, gc, %u, %s, %s, %s, %s, %s, %s, GL_FALSE);" % (dim, w, h, d, p.img_format, p.img_type, p.name)) got_reply = 1 else: @@ -809,7 +811,7 @@ generic_%u_byte( GLint rop, const void * ptr ) # non-arrays) gives us this. s = p.size() / p.get_element_count() - print " %s __glXReadReply(dpy, %s, %s, %s);" % (return_str, s, p.name, aa) + print(" %s __glXReadReply(dpy, %s, %s, %s);" % (return_str, s, p.name, aa)) got_reply = 1 @@ -817,25 +819,25 @@ generic_%u_byte( GLint rop, const void * ptr ) # read a NULL reply to get the return value. if not got_reply: - print " %s __glXReadReply(dpy, 0, NULL, GL_FALSE);" % (return_str) + print(" %s __glXReadReply(dpy, 0, NULL, GL_FALSE);" % (return_str)) elif self.debug: # Only emit the extra glFinish call for functions # that don't already require a reply from the server. - print ' __indirect_glFinish();' + print(' __indirect_glFinish();') if self.debug: - print ' printf( "Exit %%s.\\n", "gl%s" );' % (name) + print(' printf( "Exit %%s.\\n", "gl%s" );' % (name)) - print ' UnlockDisplay(dpy); SyncHandle();' + print(' UnlockDisplay(dpy); SyncHandle();') if name not in f.glx_vendorpriv_names: - print '#endif /* USE_XCB */' + print('#endif /* USE_XCB */') - print ' }' - print ' return%s;' % (return_name) + print(' }') + print(' return%s;' % (return_name)) return @@ -859,7 +861,7 @@ generic_%u_byte( GLint rop, const void * ptr ) if f.pad_after(param): p_string += ", 1" - print ' %s(%s, %u%s );' % (self.pixel_stubs[f.name] , f.opcode_name(), dim, p_string) + print(' %s(%s, %u%s );' % (self.pixel_stubs[f.name] , f.opcode_name(), dim, p_string)) return @@ -870,32 +872,32 @@ generic_%u_byte( GLint rop, const void * ptr ) if f.can_be_large: - print 'if (cmdlen <= gc->maxSmallRenderCommandSize) {' - print ' if ( (gc->pc + cmdlen) > gc->bufEnd ) {' - print ' (void) __glXFlushRenderBuffer(gc, gc->pc);' - print ' }' + print('if (cmdlen <= gc->maxSmallRenderCommandSize) {') + print(' if ( (gc->pc + cmdlen) > gc->bufEnd ) {') + print(' (void) __glXFlushRenderBuffer(gc, gc->pc);') + print(' }') if f.glx_rop == ~0: opcode = "opcode" else: opcode = f.opcode_real_name() - print 'emit_header(gc->pc, %s, cmdlen);' % (opcode) + print('emit_header(gc->pc, %s, cmdlen);' % (opcode)) self.pixel_emit_args( f, "gc->pc", 0 ) - print 'gc->pc += cmdlen;' - print 'if (gc->pc > gc->limit) { (void) __glXFlushRenderBuffer(gc, gc->pc); }' + print('gc->pc += cmdlen;') + print('if (gc->pc > gc->limit) { (void) __glXFlushRenderBuffer(gc, gc->pc); }') if f.can_be_large: - print '}' - print 'else {' + print('}') + print('else {') self.large_emit_begin(f, opcode) self.pixel_emit_args(f, "pc", 1) - print '}' + print('}') - if trailer: print trailer + if trailer: print(trailer) return @@ -912,7 +914,7 @@ generic_%u_byte( GLint rop, const void * ptr ) if p.is_pointer(): cmdlen = f.command_fixed_length() if cmdlen in self.generic_sizes: - print ' generic_%u_byte( %s, %s );' % (cmdlen, f.opcode_real_name(), p.name) + print(' generic_%u_byte( %s, %s );' % (cmdlen, f.opcode_real_name(), p.name)) return if self.common_func_print_just_start(f, None): @@ -921,36 +923,36 @@ generic_%u_byte( GLint rop, const void * ptr ) trailer = None if self.debug: - print 'printf( "Enter %%s...\\n", "gl%s" );' % (f.name) + print('printf( "Enter %%s...\\n", "gl%s" );' % (f.name)) if f.can_be_large: - print 'if (cmdlen <= gc->maxSmallRenderCommandSize) {' - print ' if ( (gc->pc + cmdlen) > gc->bufEnd ) {' - print ' (void) __glXFlushRenderBuffer(gc, gc->pc);' - print ' }' + print('if (cmdlen <= gc->maxSmallRenderCommandSize) {') + print(' if ( (gc->pc + cmdlen) > gc->bufEnd ) {') + print(' (void) __glXFlushRenderBuffer(gc, gc->pc);') + print(' }') - print 'emit_header(gc->pc, %s, cmdlen);' % (f.opcode_real_name()) + print('emit_header(gc->pc, %s, cmdlen);' % (f.opcode_real_name())) self.common_emit_args(f, "gc->pc", 4, 0) - print 'gc->pc += cmdlen;' - print 'if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }' + print('gc->pc += cmdlen;') + print('if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }') if f.can_be_large: - print '}' - print 'else {' + print('}') + print('else {') self.large_emit_begin(f) self.common_emit_args(f, "pc", 8, 1) p = f.variable_length_parameter() - print ' __glXSendLargeCommand(gc, pc, %u, %s, %s);' % (p.offset + 8, p.name, p.size_string()) - print '}' + print(' __glXSendLargeCommand(gc, pc, %u, %s, %s);' % (p.offset + 8, p.name, p.size_string())) + print('}') if self.debug: - print '__indirect_glFinish();' - print 'printf( "Exit %%s.\\n", "gl%s" );' % (f.name) + print('__indirect_glFinish();') + print('printf( "Exit %%s.\\n", "gl%s" );' % (f.name)) - if trailer: print trailer + if trailer: print(trailer) return @@ -966,7 +968,7 @@ class PrintGlxProtoInit_c(gl_XML.gl_print_base): def printRealHeader(self): - print """/** + print("""/** * \\file indirect_init.c * Initialize indirect rendering dispatch table. * @@ -1012,15 +1014,15 @@ struct _glapi_table * __glXNewIndirectAPI( void ) table[i] = (_glapi_proc) NoOp; } - /* now, initialize the entries we understand */""" + /* now, initialize the entries we understand */""") def printRealFooter(self): - print """ + print(""" return (struct _glapi_table *) table; } #endif -""" +""") return @@ -1034,15 +1036,15 @@ struct _glapi_table * __glXNewIndirectAPI( void ) for func in api.functionIterateByCategory(name): if func.client_supported_for_indirect(): if preamble: - print preamble + print(preamble) preamble = None if func.is_abi(): - print ' table[{offset}] = (_glapi_proc) __indirect_gl{name};'.format(name = func.name, offset = func.offset) + print(' table[{offset}] = (_glapi_proc) __indirect_gl{name};'.format(name = func.name, offset = func.offset)) else: - print ' o = _glapi_get_proc_offset("gl{0}");'.format(func.name) - print ' assert(o > 0);' - print ' table[o] = (_glapi_proc) __indirect_gl{0};'.format(func.name) + print(' o = _glapi_get_proc_offset("gl{0}");'.format(func.name)) + print(' assert(o > 0);') + print(' table[o] = (_glapi_proc) __indirect_gl{0};'.format(func.name)) return @@ -1062,18 +1064,18 @@ class PrintGlxProtoInit_h(gl_XML.gl_print_base): def printRealHeader(self): - print """/** + print("""/** * \\file * Prototypes for indirect rendering functions. * * \\author Kevin E. Martin <[email protected]> * \\author Ian Romanick <[email protected]> */ -""" +""") self.printFastcall() self.printNoinline() - print """ + print(""" #include <X11/Xfuncproto.h> #include "glxclient.h" @@ -1090,32 +1092,32 @@ extern _X_HIDDEN NOINLINE FASTCALL GLubyte * __glXSetupSingleRequest( extern _X_HIDDEN NOINLINE FASTCALL GLubyte * __glXSetupVendorRequest( struct glx_context * gc, GLint code, GLint vop, GLint cmdlen ); -""" +""") def printBody(self, api): for func in api.functionIterateGlx(): params = func.get_parameter_string() - print 'extern _X_HIDDEN %s __indirect_gl%s(%s);' % (func.return_type, func.name, params) + print('extern _X_HIDDEN %s __indirect_gl%s(%s);' % (func.return_type, func.name, params)) for n in func.entry_points: if func.has_different_protocol(n): asdf = func.static_glx_name(n) if asdf not in func.static_entry_points: - print 'extern _X_HIDDEN %s gl%s(%s);' % (func.return_type, asdf, params) + print('extern _X_HIDDEN %s gl%s(%s);' % (func.return_type, asdf, params)) # give it a easy-to-remember name if func.client_handcode: - print '#define gl_dispatch_stub_%s gl%s' % (n, asdf) + print('#define gl_dispatch_stub_%s gl%s' % (n, asdf)) else: - print 'GLAPI %s GLAPIENTRY gl%s(%s);' % (func.return_type, asdf, params) + print('GLAPI %s GLAPIENTRY gl%s(%s);' % (func.return_type, asdf, params)) break - print '' - print '#ifdef GLX_INDIRECT_RENDERING' - print 'extern _X_HIDDEN void (*__indirect_get_proc_address(const char *name))(void);' - print '#endif' + print('') + print('#ifdef GLX_INDIRECT_RENDERING') + print('extern _X_HIDDEN void (*__indirect_get_proc_address(const char *name))(void);') + print('#endif') def _parser(): diff --git a/src/mapi/glapi/gen/glX_proto_size.py b/src/mapi/glapi/gen/glX_proto_size.py index 8dbb0af86d7..2b7cefd2357 100644 --- a/src/mapi/glapi/gen/glX_proto_size.py +++ b/src/mapi/glapi/gen/glX_proto_size.py @@ -24,6 +24,8 @@ # Authors: # Ian Romanick <[email protected]> +from __future__ import print_function + import argparse import sys, string @@ -167,19 +169,19 @@ class glx_enum_function(object): masked_count[i] = c - print ' static const GLushort a[%u] = {' % (mask + 1) + print(' static const GLushort a[%u] = {' % (mask + 1)) for e in masked_enums: - print ' %s, ' % (masked_enums[e]) - print ' };' + print(' %s, ' % (masked_enums[e])) + print(' };') - print ' static const GLubyte b[%u] = {' % (mask + 1) + print(' static const GLubyte b[%u] = {' % (mask + 1)) for c in masked_count: - print ' %u, ' % (masked_count[c]) - print ' };' + print(' %u, ' % (masked_count[c])) + print(' };') - print ' const unsigned idx = (e & 0x%02xU);' % (mask) - print '' - print ' return (e == a[idx]) ? (GLint) b[idx] : 0;' + print(' const unsigned idx = (e & 0x%02xU);' % (mask)) + print('') + print(' return (e == a[idx]) ? (GLint) b[idx] : 0;') return 1; else: return 0; @@ -189,7 +191,7 @@ class glx_enum_function(object): """Emit the body of the __gl*_size function using a switch-statement.""" - print ' switch( e ) {' + print(' switch( e ) {') for c in sorted(self.count): for e in self.count[c]: @@ -211,30 +213,30 @@ class glx_enum_function(object): for k in keys: j = list[k] if first: - print ' case GL_%s:' % (j) + print(' case GL_%s:' % (j)) first = 0 else: - print '/* case GL_%s:*/' % (j) + print('/* case GL_%s:*/' % (j)) if c == -1: - print ' return __gl%s_variable_size( e );' % (name) + print(' return __gl%s_variable_size( e );' % (name)) else: - print ' return %u;' % (c) + print(' return %u;' % (c)) - print ' default: return 0;' - print ' }' + print(' default: return 0;') + print(' }') def Print(self, name): - print '_X_INTERNAL PURE FASTCALL GLint' - print '__gl%s_size( GLenum e )' % (name) - print '{' + print('_X_INTERNAL PURE FASTCALL GLint') + print('__gl%s_size( GLenum e )' % (name)) + print('{') if not self.PrintUsingTable(): self.PrintUsingSwitch(name) - print '}' - print '' + print('}') + print('') class glx_server_enum_function(glx_enum_function): @@ -282,18 +284,18 @@ class glx_server_enum_function(glx_enum_function): fixup.append( p.name ) - print ' GLsizei compsize;' - print '' + print(' GLsizei compsize;') + print('') printer.common_emit_fixups(fixup) - print '' - print ' compsize = __gl%s_size(%s);' % (f.name, string.join(f.count_parameter_list, ",")) + print('') + print(' compsize = __gl%s_size(%s);' % (f.name, string.join(f.count_parameter_list, ","))) p = f.variable_length_parameter() - print ' return safe_pad(%s);' % (p.size_string()) + print(' return safe_pad(%s);' % (p.size_string())) - print '}' - print '' + print('}') + print('') class PrintGlxSizeStubs_common(gl_XML.gl_print_base): @@ -313,34 +315,34 @@ class PrintGlxSizeStubs_common(gl_XML.gl_print_base): class PrintGlxSizeStubs_c(PrintGlxSizeStubs_common): def printRealHeader(self): - print '' - print '#include <X11/Xfuncproto.h>' - print '#include <GL/gl.h>' + print('') + print('#include <X11/Xfuncproto.h>') + print('#include <GL/gl.h>') if self.emit_get: - print '#include "indirect_size_get.h"' - print '#include "glxserver.h"' - print '#include "indirect_util.h"' + print('#include "indirect_size_get.h"') + print('#include "glxserver.h"') + print('#include "indirect_util.h"') - print '#include "indirect_size.h"' + print('#include "indirect_size.h"') - print '' + print('') self.printPure() - print '' + print('') self.printFastcall() - print '' - print '' - print '#ifdef HAVE_FUNC_ATTRIBUTE_ALIAS' - print '# define ALIAS2(from,to) \\' - print ' _X_INTERNAL PURE FASTCALL GLint __gl ## from ## _size( GLenum e ) \\' - print ' __attribute__ ((alias( # to )));' - print '# define ALIAS(from,to) ALIAS2( from, __gl ## to ## _size )' - print '#else' - print '# define ALIAS(from,to) \\' - print ' _X_INTERNAL PURE FASTCALL GLint __gl ## from ## _size( GLenum e ) \\' - print ' { return __gl ## to ## _size( e ); }' - print '#endif' - print '' - print '' + print('') + print('') + print('#ifdef HAVE_FUNC_ATTRIBUTE_ALIAS') + print('# define ALIAS2(from,to) \\') + print(' _X_INTERNAL PURE FASTCALL GLint __gl ## from ## _size( GLenum e ) \\') + print(' __attribute__ ((alias( # to )));') + print('# define ALIAS(from,to) ALIAS2( from, __gl ## to ## _size )') + print('#else') + print('# define ALIAS(from,to) \\') + print(' _X_INTERNAL PURE FASTCALL GLint __gl ## from ## _size( GLenum e ) \\') + print(' { return __gl ## to ## _size( e ); }') + print('#endif') + print('') + print('') def printBody(self, api): @@ -362,26 +364,26 @@ class PrintGlxSizeStubs_c(PrintGlxSizeStubs_common): for [alias_name, real_name] in aliases: - print 'ALIAS( %s, %s )' % (alias_name, real_name) + print('ALIAS( %s, %s )' % (alias_name, real_name)) class PrintGlxSizeStubs_h(PrintGlxSizeStubs_common): def printRealHeader(self): - print """/** + print("""/** * \\file * Prototypes for functions used to determine the number of data elements in * various GLX protocol messages. * * \\author Ian Romanick <[email protected]> */ -""" - print '#include <X11/Xfuncproto.h>' - print '' +""") + print('#include <X11/Xfuncproto.h>') + print('') self.printPure(); - print '' + print('') self.printFastcall(); - print '' + print('') def printBody(self, api): @@ -391,7 +393,7 @@ class PrintGlxSizeStubs_h(PrintGlxSizeStubs_common): continue if (ef.is_set() and self.emit_set) or (not ef.is_set() and self.emit_get): - print 'extern _X_INTERNAL PURE FASTCALL GLint __gl%s_size(GLenum);' % (func.name) + print('extern _X_INTERNAL PURE FASTCALL GLint __gl%s_size(GLenum);' % (func.name)) class PrintGlxReqSize_common(gl_XML.gl_print_base): @@ -415,16 +417,16 @@ class PrintGlxReqSize_h(PrintGlxReqSize_common): def printRealHeader(self): - print '#include <X11/Xfuncproto.h>' - print '' + print('#include <X11/Xfuncproto.h>') + print('') self.printPure() - print '' + print('') def printBody(self, api): for func in api.functionIterateGlx(): if not func.ignore and func.has_variable_size_request(): - print 'extern PURE _X_HIDDEN int __glX%sReqSize(const GLbyte *pc, Bool swap, int reqlen);' % (func.name) + print('extern PURE _X_HIDDEN int __glX%sReqSize(const GLbyte *pc, Bool swap, int reqlen);' % (func.name)) class PrintGlxReqSize_c(PrintGlxReqSize_common): @@ -441,25 +443,25 @@ class PrintGlxReqSize_c(PrintGlxReqSize_common): def printRealHeader(self): - print '' - print '#include <GL/gl.h>' - print '#include "glxserver.h"' - print '#include "glxbyteorder.h"' - print '#include "indirect_size.h"' - print '#include "indirect_reqsize.h"' - print '' - print '#ifdef HAVE_FUNC_ATTRIBUTE_ALIAS' - print '# define ALIAS2(from,to) \\' - print ' GLint __glX ## from ## ReqSize( const GLbyte * pc, Bool swap, int reqlen ) \\' - print ' __attribute__ ((alias( # to )));' - print '# define ALIAS(from,to) ALIAS2( from, __glX ## to ## ReqSize )' - print '#else' - print '# define ALIAS(from,to) \\' - print ' GLint __glX ## from ## ReqSize( const GLbyte * pc, Bool swap, int reqlen ) \\' - print ' { return __glX ## to ## ReqSize( pc, swap, reqlen ); }' - print '#endif' - print '' - print '' + print('') + print('#include <GL/gl.h>') + print('#include "glxserver.h"') + print('#include "glxbyteorder.h"') + print('#include "indirect_size.h"') + print('#include "indirect_reqsize.h"') + print('') + print('#ifdef HAVE_FUNC_ATTRIBUTE_ALIAS') + print('# define ALIAS2(from,to) \\') + print(' GLint __glX ## from ## ReqSize( const GLbyte * pc, Bool swap, int reqlen ) \\') + print(' __attribute__ ((alias( # to )));') + print('# define ALIAS(from,to) ALIAS2( from, __glX ## to ## ReqSize )') + print('#else') + print('# define ALIAS(from,to) \\') + print(' GLint __glX ## from ## ReqSize( const GLbyte * pc, Bool swap, int reqlen ) \\') + print(' { return __glX ## to ## ReqSize( pc, swap, reqlen ); }') + print('#endif') + print('') + print('') def printBody(self, api): @@ -511,7 +513,7 @@ class PrintGlxReqSize_c(PrintGlxReqSize_common): for [alias_name, real_name] in aliases: - print 'ALIAS( %s, %s )' % (alias_name, real_name) + print('ALIAS( %s, %s )' % (alias_name, real_name)) return @@ -520,10 +522,10 @@ class PrintGlxReqSize_c(PrintGlxReqSize_common): """Utility function to emit conditional byte-swaps.""" if fixup: - print ' if (swap) {' + print(' if (swap) {') for name in fixup: - print ' %s = bswap_32(%s);' % (name, name) - print ' }' + print(' %s = bswap_32(%s);' % (name, name)) + print(' }') return @@ -532,14 +534,14 @@ class PrintGlxReqSize_c(PrintGlxReqSize_common): offset = p.offset dst = p.string() src = '(%s *)' % (p.type_string()) - print '%-18s = *%11s(%s + %u);' % (dst, src, pc, offset + adjust); + print('%-18s = *%11s(%s + %u);' % (dst, src, pc, offset + adjust)); return def common_func_print_just_header(self, f): - print 'int' - print '__glX%sReqSize( const GLbyte * pc, Bool swap, int reqlen )' % (f.name) - print '{' + print('int') + print('__glX%sReqSize( const GLbyte * pc, Bool swap, int reqlen )' % (f.name)) + print('{') def printPixelFunction(self, f): @@ -548,20 +550,20 @@ class PrintGlxReqSize_c(PrintGlxReqSize_common): f.offset_of( f.parameters[0].name ) [dim, w, h, d, junk] = f.get_images()[0].get_dimensions() - print ' GLint row_length = * (GLint *)(pc + 4);' + print(' GLint row_length = * (GLint *)(pc + 4);') if dim < 3: fixup = ['row_length', 'skip_rows', 'alignment'] - print ' GLint image_height = 0;' - print ' GLint skip_images = 0;' - print ' GLint skip_rows = * (GLint *)(pc + 8);' - print ' GLint alignment = * (GLint *)(pc + 16);' + print(' GLint image_height = 0;') + print(' GLint skip_images = 0;') + print(' GLint skip_rows = * (GLint *)(pc + 8);') + print(' GLint alignment = * (GLint *)(pc + 16);') else: fixup = ['row_length', 'image_height', 'skip_rows', 'skip_images', 'alignment'] - print ' GLint image_height = * (GLint *)(pc + 8);' - print ' GLint skip_rows = * (GLint *)(pc + 16);' - print ' GLint skip_images = * (GLint *)(pc + 20);' - print ' GLint alignment = * (GLint *)(pc + 32);' + print(' GLint image_height = * (GLint *)(pc + 8);') + print(' GLint skip_rows = * (GLint *)(pc + 16);') + print(' GLint skip_images = * (GLint *)(pc + 20);') + print(' GLint alignment = * (GLint *)(pc + 32);') img = f.images[0] for p in f.parameterIterateGlxSend(): @@ -569,21 +571,21 @@ class PrintGlxReqSize_c(PrintGlxReqSize_common): self.common_emit_one_arg(p, "pc", 0) fixup.append( p.name ) - print '' + print('') self.common_emit_fixups(fixup) if img.img_null_flag: - print '' - print ' if (*(CARD32 *) (pc + %s))' % (img.offset - 4) - print ' return 0;' - - print '' - print ' return __glXImageSize(%s, %s, %s, %s, %s, %s,' % (img.img_format, img.img_type, img.img_target, w, h, d ) - print ' image_height, row_length, skip_images,' - print ' skip_rows, alignment);' - print '}' - print '' + print('') + print(' if (*(CARD32 *) (pc + %s))' % (img.offset - 4)) + print(' return 0;') + + print('') + print(' return __glXImageSize(%s, %s, %s, %s, %s, %s,' % (img.img_format, img.img_type, img.img_target, w, h, d )) + print(' image_height, row_length, skip_images,') + print(' skip_rows, alignment);') + print('}') + print('') return @@ -632,13 +634,13 @@ class PrintGlxReqSize_c(PrintGlxReqSize_common): self.common_emit_one_arg(p, "pc", 0) - print '' + print('') self.common_emit_fixups(fixup) - print '' + print('') - print ' return safe_pad(%s);' % (size) - print '}' - print '' + print(' return safe_pad(%s);' % (size)) + print('}') + print('') return alias diff --git a/src/mapi/glapi/gen/gl_SPARC_asm.py b/src/mapi/glapi/gen/gl_SPARC_asm.py index 7b5714effde..0152958a8b9 100644 --- a/src/mapi/glapi/gen/gl_SPARC_asm.py +++ b/src/mapi/glapi/gen/gl_SPARC_asm.py @@ -24,6 +24,8 @@ # Authors: # Ian Romanick <[email protected]> +from __future__ import print_function + import argparse import license @@ -39,192 +41,192 @@ class PrintGenericStubs(gl_XML.gl_print_base): def printRealHeader(self): - print '#ifdef __arch64__' - print '#define GL_OFF(N)\t((N) * 8)' - print '#define GL_LL\t\tldx' - print '#define GL_TIE_LD(SYM)\t%tie_ldx(SYM)' - print '#define GL_STACK_SIZE\t128' - print '#else' - print '#define GL_OFF(N)\t((N) * 4)' - print '#define GL_LL\t\tld' - print '#define GL_TIE_LD(SYM)\t%tie_ld(SYM)' - print '#define GL_STACK_SIZE\t64' - print '#endif' - print '' - print '#define GLOBL_FN(x) .globl x ; .type x, @function' - print '#define HIDDEN(x) .hidden x' - print '' - print '\t.register %g2, #scratch' - print '\t.register %g3, #scratch' - print '' - print '\t.text' - print '' - print '\tGLOBL_FN(__glapi_sparc_icache_flush)' - print '\tHIDDEN(__glapi_sparc_icache_flush)' - print '\t.type\t__glapi_sparc_icache_flush, @function' - print '__glapi_sparc_icache_flush: /* %o0 = insn_addr */' - print '\tflush\t%o0' - print '\tretl' - print '\t nop' - print '' - print '\t.align\t32' - print '' - print '\t.type\t__glapi_sparc_get_pc, @function' - print '__glapi_sparc_get_pc:' - print '\tretl' - print '\t add\t%o7, %g2, %g2' - print '\t.size\t__glapi_sparc_get_pc, .-__glapi_sparc_get_pc' - print '' - print '#ifdef GLX_USE_TLS' - print '' - print '\tGLOBL_FN(__glapi_sparc_get_dispatch)' - print '\tHIDDEN(__glapi_sparc_get_dispatch)' - print '__glapi_sparc_get_dispatch:' - print '\tmov\t%o7, %g1' - print '\tsethi\t%hi(_GLOBAL_OFFSET_TABLE_-4), %g2' - print '\tcall\t__glapi_sparc_get_pc' - print '\tadd\t%g2, %lo(_GLOBAL_OFFSET_TABLE_+4), %g2' - print '\tmov\t%g1, %o7' - print '\tsethi\t%tie_hi22(_glapi_tls_Dispatch), %g1' - print '\tadd\t%g1, %tie_lo10(_glapi_tls_Dispatch), %g1' - print '\tGL_LL\t[%g2 + %g1], %g2, GL_TIE_LD(_glapi_tls_Dispatch)' - print '\tretl' - print '\t mov\t%g2, %o0' - print '' - print '\t.data' - print '\t.align\t32' - print '' - print '\t/* --> sethi %hi(_glapi_tls_Dispatch), %g1 */' - print '\t/* --> or %g1, %lo(_glapi_tls_Dispatch), %g1 */' - print '\tGLOBL_FN(__glapi_sparc_tls_stub)' - print '\tHIDDEN(__glapi_sparc_tls_stub)' - print '__glapi_sparc_tls_stub: /* Call offset in %g3 */' - print '\tmov\t%o7, %g1' - print '\tsethi\t%hi(_GLOBAL_OFFSET_TABLE_-4), %g2' - print '\tcall\t__glapi_sparc_get_pc' - print '\tadd\t%g2, %lo(_GLOBAL_OFFSET_TABLE_+4), %g2' - print '\tmov\t%g1, %o7' - print '\tsrl\t%g3, 10, %g3' - print '\tsethi\t%tie_hi22(_glapi_tls_Dispatch), %g1' - print '\tadd\t%g1, %tie_lo10(_glapi_tls_Dispatch), %g1' - print '\tGL_LL\t[%g2 + %g1], %g2, GL_TIE_LD(_glapi_tls_Dispatch)' - print '\tGL_LL\t[%g7+%g2], %g1' - print '\tGL_LL\t[%g1 + %g3], %g1' - print '\tjmp\t%g1' - print '\t nop' - print '\t.size\t__glapi_sparc_tls_stub, .-__glapi_sparc_tls_stub' - print '' - print '#define GL_STUB(fn, off)\t\t\t\t\\' - print '\tGLOBL_FN(fn);\t\t\t\t\t\\' - print 'fn:\tba\t__glapi_sparc_tls_stub;\t\t\t\\' - print '\t sethi\tGL_OFF(off), %g3;\t\t\t\\' - print '\t.size\tfn,.-fn;' - print '' - print '#elif defined(HAVE_PTHREAD)' - print '' - print '\t/* 64-bit 0x00 --> sethi %hh(_glapi_Dispatch), %g1 */' - print '\t/* 64-bit 0x04 --> sethi %lm(_glapi_Dispatch), %g2 */' - print '\t/* 64-bit 0x08 --> or %g1, %hm(_glapi_Dispatch), %g1 */' - print '\t/* 64-bit 0x0c --> sllx %g1, 32, %g1 */' - print '\t/* 64-bit 0x10 --> add %g1, %g2, %g1 */' - print '\t/* 64-bit 0x14 --> ldx [%g1 + %lo(_glapi_Dispatch)], %g1 */' - print '' - print '\t/* 32-bit 0x00 --> sethi %hi(_glapi_Dispatch), %g1 */' - print '\t/* 32-bit 0x04 --> ld [%g1 + %lo(_glapi_Dispatch)], %g1 */' - print '' - print '\t.data' - print '\t.align\t32' - print '' - print '\tGLOBL_FN(__glapi_sparc_pthread_stub)' - print '\tHIDDEN(__glapi_sparc_pthread_stub)' - print '__glapi_sparc_pthread_stub: /* Call offset in %g3 */' - print '\tmov\t%o7, %g1' - print '\tsethi\t%hi(_GLOBAL_OFFSET_TABLE_-4), %g2' - print '\tcall\t__glapi_sparc_get_pc' - print '\t add\t%g2, %lo(_GLOBAL_OFFSET_TABLE_+4), %g2' - print '\tmov\t%g1, %o7' - print '\tsethi\t%hi(_glapi_Dispatch), %g1' - print '\tor\t%g1, %lo(_glapi_Dispatch), %g1' - print '\tsrl\t%g3, 10, %g3' - print '\tGL_LL\t[%g2+%g1], %g2' - print '\tGL_LL\t[%g2], %g1' - print '\tcmp\t%g1, 0' - print '\tbe\t2f' - print '\t nop' - print '1:\tGL_LL\t[%g1 + %g3], %g1' - print '\tjmp\t%g1' - print '\t nop' - print '2:\tsave\t%sp, GL_STACK_SIZE, %sp' - print '\tmov\t%g3, %l0' - print '\tcall\t_glapi_get_dispatch' - print '\t nop' - print '\tmov\t%o0, %g1' - print '\tmov\t%l0, %g3' - print '\tba\t1b' - print '\t restore %g0, %g0, %g0' - print '\t.size\t__glapi_sparc_pthread_stub, .-__glapi_sparc_pthread_stub' - print '' - print '#define GL_STUB(fn, off)\t\t\t\\' - print '\tGLOBL_FN(fn);\t\t\t\t\\' - print 'fn:\tba\t__glapi_sparc_pthread_stub;\t\\' - print '\t sethi\tGL_OFF(off), %g3;\t\t\\' - print '\t.size\tfn,.-fn;' - print '' - print '#else /* Non-threaded version. */' - print '' - print '\t.type __glapi_sparc_nothread_stub, @function' - print '__glapi_sparc_nothread_stub: /* Call offset in %g3 */' - print '\tmov\t%o7, %g1' - print '\tsethi\t%hi(_GLOBAL_OFFSET_TABLE_-4), %g2' - print '\tcall\t__glapi_sparc_get_pc' - print '\t add\t%g2, %lo(_GLOBAL_OFFSET_TABLE_+4), %g2' - print '\tmov\t%g1, %o7' - print '\tsrl\t%g3, 10, %g3' - print '\tsethi\t%hi(_glapi_Dispatch), %g1' - print '\tor\t%g1, %lo(_glapi_Dispatch), %g1' - print '\tGL_LL\t[%g2+%g1], %g2' - print '\tGL_LL\t[%g2], %g1' - print '\tGL_LL\t[%g1 + %g3], %g1' - print '\tjmp\t%g1' - print '\t nop' - print '\t.size\t__glapi_sparc_nothread_stub, .-__glapi_sparc_nothread_stub' - print '' - print '#define GL_STUB(fn, off)\t\t\t\\' - print '\tGLOBL_FN(fn);\t\t\t\t\\' - print 'fn:\tba\t__glapi_sparc_nothread_stub;\t\\' - print '\t sethi\tGL_OFF(off), %g3;\t\t\\' - print '\t.size\tfn,.-fn;' - print '' - print '#endif' - print '' - print '#define GL_STUB_ALIAS(fn, alias) \\' - print ' .globl fn; \\' - print ' .set fn, alias' - print '' - print '\t.text' - print '\t.align\t32' - print '' - print '\t.globl\tgl_dispatch_functions_start' - print '\tHIDDEN(gl_dispatch_functions_start)' - print 'gl_dispatch_functions_start:' - print '' + print('#ifdef __arch64__') + print('#define GL_OFF(N)\t((N) * 8)') + print('#define GL_LL\t\tldx') + print('#define GL_TIE_LD(SYM)\t%tie_ldx(SYM)') + print('#define GL_STACK_SIZE\t128') + print('#else') + print('#define GL_OFF(N)\t((N) * 4)') + print('#define GL_LL\t\tld') + print('#define GL_TIE_LD(SYM)\t%tie_ld(SYM)') + print('#define GL_STACK_SIZE\t64') + print('#endif') + print('') + print('#define GLOBL_FN(x) .globl x ; .type x, @function') + print('#define HIDDEN(x) .hidden x') + print('') + print('\t.register %g2, #scratch') + print('\t.register %g3, #scratch') + print('') + print('\t.text') + print('') + print('\tGLOBL_FN(__glapi_sparc_icache_flush)') + print('\tHIDDEN(__glapi_sparc_icache_flush)') + print('\t.type\t__glapi_sparc_icache_flush, @function') + print('__glapi_sparc_icache_flush: /* %o0 = insn_addr */') + print('\tflush\t%o0') + print('\tretl') + print('\t nop') + print('') + print('\t.align\t32') + print('') + print('\t.type\t__glapi_sparc_get_pc, @function') + print('__glapi_sparc_get_pc:') + print('\tretl') + print('\t add\t%o7, %g2, %g2') + print('\t.size\t__glapi_sparc_get_pc, .-__glapi_sparc_get_pc') + print('') + print('#ifdef GLX_USE_TLS') + print('') + print('\tGLOBL_FN(__glapi_sparc_get_dispatch)') + print('\tHIDDEN(__glapi_sparc_get_dispatch)') + print('__glapi_sparc_get_dispatch:') + print('\tmov\t%o7, %g1') + print('\tsethi\t%hi(_GLOBAL_OFFSET_TABLE_-4), %g2') + print('\tcall\t__glapi_sparc_get_pc') + print('\tadd\t%g2, %lo(_GLOBAL_OFFSET_TABLE_+4), %g2') + print('\tmov\t%g1, %o7') + print('\tsethi\t%tie_hi22(_glapi_tls_Dispatch), %g1') + print('\tadd\t%g1, %tie_lo10(_glapi_tls_Dispatch), %g1') + print('\tGL_LL\t[%g2 + %g1], %g2, GL_TIE_LD(_glapi_tls_Dispatch)') + print('\tretl') + print('\t mov\t%g2, %o0') + print('') + print('\t.data') + print('\t.align\t32') + print('') + print('\t/* --> sethi %hi(_glapi_tls_Dispatch), %g1 */') + print('\t/* --> or %g1, %lo(_glapi_tls_Dispatch), %g1 */') + print('\tGLOBL_FN(__glapi_sparc_tls_stub)') + print('\tHIDDEN(__glapi_sparc_tls_stub)') + print('__glapi_sparc_tls_stub: /* Call offset in %g3 */') + print('\tmov\t%o7, %g1') + print('\tsethi\t%hi(_GLOBAL_OFFSET_TABLE_-4), %g2') + print('\tcall\t__glapi_sparc_get_pc') + print('\tadd\t%g2, %lo(_GLOBAL_OFFSET_TABLE_+4), %g2') + print('\tmov\t%g1, %o7') + print('\tsrl\t%g3, 10, %g3') + print('\tsethi\t%tie_hi22(_glapi_tls_Dispatch), %g1') + print('\tadd\t%g1, %tie_lo10(_glapi_tls_Dispatch), %g1') + print('\tGL_LL\t[%g2 + %g1], %g2, GL_TIE_LD(_glapi_tls_Dispatch)') + print('\tGL_LL\t[%g7+%g2], %g1') + print('\tGL_LL\t[%g1 + %g3], %g1') + print('\tjmp\t%g1') + print('\t nop') + print('\t.size\t__glapi_sparc_tls_stub, .-__glapi_sparc_tls_stub') + print('') + print('#define GL_STUB(fn, off)\t\t\t\t\\') + print('\tGLOBL_FN(fn);\t\t\t\t\t\\') + print('fn:\tba\t__glapi_sparc_tls_stub;\t\t\t\\') + print('\t sethi\tGL_OFF(off), %g3;\t\t\t\\') + print('\t.size\tfn,.-fn;') + print('') + print('#elif defined(HAVE_PTHREAD)') + print('') + print('\t/* 64-bit 0x00 --> sethi %hh(_glapi_Dispatch), %g1 */') + print('\t/* 64-bit 0x04 --> sethi %lm(_glapi_Dispatch), %g2 */') + print('\t/* 64-bit 0x08 --> or %g1, %hm(_glapi_Dispatch), %g1 */') + print('\t/* 64-bit 0x0c --> sllx %g1, 32, %g1 */') + print('\t/* 64-bit 0x10 --> add %g1, %g2, %g1 */') + print('\t/* 64-bit 0x14 --> ldx [%g1 + %lo(_glapi_Dispatch)], %g1 */') + print('') + print('\t/* 32-bit 0x00 --> sethi %hi(_glapi_Dispatch), %g1 */') + print('\t/* 32-bit 0x04 --> ld [%g1 + %lo(_glapi_Dispatch)], %g1 */') + print('') + print('\t.data') + print('\t.align\t32') + print('') + print('\tGLOBL_FN(__glapi_sparc_pthread_stub)') + print('\tHIDDEN(__glapi_sparc_pthread_stub)') + print('__glapi_sparc_pthread_stub: /* Call offset in %g3 */') + print('\tmov\t%o7, %g1') + print('\tsethi\t%hi(_GLOBAL_OFFSET_TABLE_-4), %g2') + print('\tcall\t__glapi_sparc_get_pc') + print('\t add\t%g2, %lo(_GLOBAL_OFFSET_TABLE_+4), %g2') + print('\tmov\t%g1, %o7') + print('\tsethi\t%hi(_glapi_Dispatch), %g1') + print('\tor\t%g1, %lo(_glapi_Dispatch), %g1') + print('\tsrl\t%g3, 10, %g3') + print('\tGL_LL\t[%g2+%g1], %g2') + print('\tGL_LL\t[%g2], %g1') + print('\tcmp\t%g1, 0') + print('\tbe\t2f') + print('\t nop') + print('1:\tGL_LL\t[%g1 + %g3], %g1') + print('\tjmp\t%g1') + print('\t nop') + print('2:\tsave\t%sp, GL_STACK_SIZE, %sp') + print('\tmov\t%g3, %l0') + print('\tcall\t_glapi_get_dispatch') + print('\t nop') + print('\tmov\t%o0, %g1') + print('\tmov\t%l0, %g3') + print('\tba\t1b') + print('\t restore %g0, %g0, %g0') + print('\t.size\t__glapi_sparc_pthread_stub, .-__glapi_sparc_pthread_stub') + print('') + print('#define GL_STUB(fn, off)\t\t\t\\') + print('\tGLOBL_FN(fn);\t\t\t\t\\') + print('fn:\tba\t__glapi_sparc_pthread_stub;\t\\') + print('\t sethi\tGL_OFF(off), %g3;\t\t\\') + print('\t.size\tfn,.-fn;') + print('') + print('#else /* Non-threaded version. */') + print('') + print('\t.type __glapi_sparc_nothread_stub, @function') + print('__glapi_sparc_nothread_stub: /* Call offset in %g3 */') + print('\tmov\t%o7, %g1') + print('\tsethi\t%hi(_GLOBAL_OFFSET_TABLE_-4), %g2') + print('\tcall\t__glapi_sparc_get_pc') + print('\t add\t%g2, %lo(_GLOBAL_OFFSET_TABLE_+4), %g2') + print('\tmov\t%g1, %o7') + print('\tsrl\t%g3, 10, %g3') + print('\tsethi\t%hi(_glapi_Dispatch), %g1') + print('\tor\t%g1, %lo(_glapi_Dispatch), %g1') + print('\tGL_LL\t[%g2+%g1], %g2') + print('\tGL_LL\t[%g2], %g1') + print('\tGL_LL\t[%g1 + %g3], %g1') + print('\tjmp\t%g1') + print('\t nop') + print('\t.size\t__glapi_sparc_nothread_stub, .-__glapi_sparc_nothread_stub') + print('') + print('#define GL_STUB(fn, off)\t\t\t\\') + print('\tGLOBL_FN(fn);\t\t\t\t\\') + print('fn:\tba\t__glapi_sparc_nothread_stub;\t\\') + print('\t sethi\tGL_OFF(off), %g3;\t\t\\') + print('\t.size\tfn,.-fn;') + print('') + print('#endif') + print('') + print('#define GL_STUB_ALIAS(fn, alias) \\') + print(' .globl fn; \\') + print(' .set fn, alias') + print('') + print('\t.text') + print('\t.align\t32') + print('') + print('\t.globl\tgl_dispatch_functions_start') + print('\tHIDDEN(gl_dispatch_functions_start)') + print('gl_dispatch_functions_start:') + print('') return def printRealFooter(self): - print '' - print '\t.globl\tgl_dispatch_functions_end' - print '\tHIDDEN(gl_dispatch_functions_end)' - print 'gl_dispatch_functions_end:' + print('') + print('\t.globl\tgl_dispatch_functions_end') + print('\tHIDDEN(gl_dispatch_functions_end)') + print('gl_dispatch_functions_end:') return def printBody(self, api): for f in api.functionIterateByOffset(): name = f.dispatch_name() - print '\tGL_STUB(gl%s, %d)' % (name, f.offset) + print('\tGL_STUB(gl%s, %d)' % (name, f.offset)) if not f.is_static_entry_point(f.name): - print '\tHIDDEN(gl%s)' % (name) + print('\tHIDDEN(gl%s)' % (name)) for f in api.functionIterateByOffset(): name = f.dispatch_name() @@ -235,11 +237,11 @@ class PrintGenericStubs(gl_XML.gl_print_base): text = '\tGL_STUB_ALIAS(gl%s, gl%s)' % (n, f.name) if f.has_different_protocol(n): - print '#ifndef GLX_INDIRECT_RENDERING' - print text - print '#endif' + print('#ifndef GLX_INDIRECT_RENDERING') + print(text) + print('#endif') else: - print text + print(text) return diff --git a/src/mapi/glapi/gen/gl_XML.py b/src/mapi/glapi/gen/gl_XML.py index 1bab5fee51f..3a191abe0d6 100644 --- a/src/mapi/glapi/gen/gl_XML.py +++ b/src/mapi/glapi/gen/gl_XML.py @@ -24,6 +24,8 @@ # Authors: # Ian Romanick <[email protected]> +from __future__ import print_function + from collections import OrderedDict from decimal import Decimal import xml.etree.ElementTree as ET @@ -126,17 +128,17 @@ class gl_print_base(object): def printHeader(self): """Print the header associated with all files and call the printRealHeader method.""" - print '/* DO NOT EDIT - This file generated automatically by %s script */' \ - % (self.name) - print '' - print '/*' - print (' * ' + self.license.replace('\n', '\n * ')).replace(' \n', '\n') - print ' */' - print '' + print('/* DO NOT EDIT - This file generated automatically by %s script */' \ + % (self.name)) + print('') + print('/*') + print((' * ' + self.license.replace('\n', '\n * ')).replace(' \n', '\n')) + print(' */') + print('') if self.header_tag: - print '#if !defined( %s )' % (self.header_tag) - print '# define %s' % (self.header_tag) - print '' + print('#if !defined( %s )' % (self.header_tag)) + print('# define %s' % (self.header_tag)) + print('') self.printRealHeader(); return @@ -147,13 +149,13 @@ class gl_print_base(object): self.printRealFooter() if self.undef_list: - print '' + print('') for u in self.undef_list: - print "# undef %s" % (u) + print("# undef %s" % (u)) if self.header_tag: - print '' - print '#endif /* !defined( %s ) */' % (self.header_tag) + print('') + print('#endif /* !defined( %s ) */' % (self.header_tag)) def printRealHeader(self): @@ -183,11 +185,11 @@ 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__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) + print("""# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) # define PURE __attribute__((pure)) # else # define PURE -# endif""" +# endif""") return @@ -203,11 +205,11 @@ class gl_print_base(object): """ self.undef_list.append("FASTCALL") - print """# if defined(__i386__) && defined(__GNUC__) && !defined(__CYGWIN__) && !defined(__MINGW32__) + print("""# if defined(__i386__) && defined(__GNUC__) && !defined(__CYGWIN__) && !defined(__MINGW32__) # define FASTCALL __attribute__((fastcall)) # else # define FASTCALL -# endif""" +# endif""") return @@ -223,11 +225,11 @@ class gl_print_base(object): """ self.undef_list.append(S) - print """# if defined(__GNUC__) && !defined(__CYGWIN__) && !defined(__MINGW32__) + print("""# if defined(__GNUC__) && !defined(__CYGWIN__) && !defined(__MINGW32__) # define %s __attribute__((visibility("%s"))) # else # define %s -# endif""" % (S, s, S) +# endif""" % (S, s, S)) return @@ -243,11 +245,11 @@ class gl_print_base(object): """ self.undef_list.append("NOINLINE") - print """# if defined(__GNUC__) + print("""# if defined(__GNUC__) # define NOINLINE __attribute__((noinline)) # else # define NOINLINE -# endif""" +# endif""") return @@ -1069,5 +1071,5 @@ class gl_api(object): if type_name in self.types_by_name: return self.types_by_name[ type_name ].type_expr else: - print "Unable to find base type matching \"%s\"." % (type_name) + print("Unable to find base type matching \"%s\"." % (type_name)) return None diff --git a/src/mapi/glapi/gen/gl_apitemp.py b/src/mapi/glapi/gen/gl_apitemp.py index a8e5d814555..d0583f48ef1 100644 --- a/src/mapi/glapi/gen/gl_apitemp.py +++ b/src/mapi/glapi/gen/gl_apitemp.py @@ -24,6 +24,8 @@ # Authors: # Ian Romanick <[email protected]> +from __future__ import print_function + import argparse import gl_XML, glX_XML @@ -97,27 +99,27 @@ class PrintGlOffsets(gl_XML.gl_print_base): if (cat.startswith("es") or cat.startswith("GL_OES")): need_proto = True if need_proto: - print '%s %s KEYWORD2 NAME(%s)(%s);' % (keyword, f.return_type, n, f.get_parameter_string(name)) - print '' + print('%s %s KEYWORD2 NAME(%s)(%s);' % (keyword, f.return_type, n, f.get_parameter_string(name))) + print('') - print '%s %s KEYWORD2 NAME(%s)(%s)' % (keyword, f.return_type, n, f.get_parameter_string(name)) - print '{' + print('%s %s KEYWORD2 NAME(%s)(%s)' % (keyword, f.return_type, n, f.get_parameter_string(name))) + print('{') if silence: - print ' %s' % (silence) + print(' %s' % (silence)) if p_string == "": - print ' %s(%s, (), (F, "gl%s();\\n"));' \ - % (dispatch, f.name, name) + print(' %s(%s, (), (F, "gl%s();\\n"));' \ + % (dispatch, f.name, name)) else: - print ' %s(%s, (%s), (F, "gl%s(%s);\\n", %s));' \ - % (dispatch, f.name, p_string, name, t_string, o_string) - print '}' - print '' + print(' %s(%s, (%s), (F, "gl%s(%s);\\n", %s));' \ + % (dispatch, f.name, p_string, name, t_string, o_string)) + print('}') + print('') return def printRealHeader(self): - print '' + print('') self.printVisibility( "HIDDEN", "hidden" ) - print """ + 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 @@ -164,13 +166,13 @@ class PrintGlOffsets(gl_XML.gl_print_base): #error RETURN_DISPATCH must be defined #endif -""" +""") return def printInitDispatch(self, api): - print """ + print(""" #endif /* defined( NAME ) */ /* @@ -187,31 +189,31 @@ class PrintGlOffsets(gl_XML.gl_print_base): #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()) + print(' TABLE_ENTRY(%s),' % (f.dispatch_name())) - print ' /* A whole bunch of no-op functions. These might be called' - print ' * when someone tries to call a dynamically-registered' - print ' * extension function without a current rendering context.' - print ' */' + print(' /* A whole bunch of no-op functions. These might be called') + print(' * when someone tries to call a dynamically-registered') + print(' * extension function without a current rendering context.') + print(' */') for i in range(1, 100): - print ' TABLE_ENTRY(Unused),' + print(' TABLE_ENTRY(Unused),') - print '};' - print '#endif /* DISPATCH_TABLE_NAME */' - print '' + print('};') + print('#endif /* DISPATCH_TABLE_NAME */') + print('') return def printAliasedTable(self, api): - print """ + 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[] = {""" +_glapi_proc UNUSED_TABLE_NAME[] = {""") normal_entries = [] proto_entries = [] @@ -230,18 +232,18 @@ _glapi_proc UNUSED_TABLE_NAME[] = {""" normal_entries.extend(normal_ents) proto_entries.extend(proto_ents) - print '#ifndef _GLAPI_SKIP_NORMAL_ENTRY_POINTS' + 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' + 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(' TABLE_ENTRY(%s),' % (ent)) + print('#endif /* _GLAPI_SKIP_PROTO_ENTRY_POINTS */') - print '};' - print '#endif /*UNUSED_TABLE_NAME*/' - print '' + print('};') + print('#endif /*UNUSED_TABLE_NAME*/') + print('') return @@ -278,23 +280,23 @@ _glapi_proc UNUSED_TABLE_NAME[] = {""" normal_entry_points.append((func, normal_ents)) proto_entry_points.append((func, proto_ents)) - print '#ifndef _GLAPI_SKIP_NORMAL_ENTRY_POINTS' - print '' + 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 '' + 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 '' + print('') + print('#endif /* _GLAPI_SKIP_PROTO_ENTRY_POINTS */') + print('') self.printInitDispatch(api) self.printAliasedTable(api) diff --git a/src/mapi/glapi/gen/gl_enums.py b/src/mapi/glapi/gen/gl_enums.py index 768a54a3a6a..00f8134bae2 100644 --- a/src/mapi/glapi/gen/gl_enums.py +++ b/src/mapi/glapi/gen/gl_enums.py @@ -25,6 +25,8 @@ # Authors: # Zack Rusin <[email protected]> +from __future__ import print_function + import argparse import license @@ -48,20 +50,20 @@ class PrintGlEnums(gl_XML.gl_print_base): def printRealHeader(self): - print '#include "main/glheader.h"' - print '#include "main/enums.h"' - print '#include "main/imports.h"' - print '#include "main/mtypes.h"' - print '' - print 'typedef struct PACKED {' - print ' uint32_t offset;' - print ' int n;' - print '} enum_elt;' - print '' + print('#include "main/glheader.h"') + print('#include "main/enums.h"') + print('#include "main/imports.h"') + print('#include "main/mtypes.h"') + print('') + print('typedef struct PACKED {') + print(' uint32_t offset;') + print(' int n;') + print('} enum_elt;') + print('') return def print_code(self): - print """ + print(""" typedef int (*cfunc)(const void *, const void *); /** @@ -144,7 +146,7 @@ _mesa_lookup_prim_by_nr(GLuint nr) } -""" +""") return @@ -154,37 +156,37 @@ _mesa_lookup_prim_by_nr(GLuint nr) sorted_enum_values = sorted(self.enum_table.keys()) string_offsets = {} i = 0; - print '#if defined(__GNUC__)' - print '# define LONGSTRING __extension__' - print '#else' - print '# define LONGSTRING' - print '#endif' - print '' - print 'LONGSTRING static const char enum_string_table[] = {' + print('#if defined(__GNUC__)') + print('# define LONGSTRING __extension__') + print('#else') + print('# define LONGSTRING') + print('#endif') + print('') + print('LONGSTRING static const char enum_string_table[] = {') # We express the very long concatenation of enum strings as an array # of characters rather than as a string literal to work-around MSVC's # 65535 character limit. for enum in sorted_enum_values: (name, pri) = self.enum_table[enum] - print " ", + print(" ", end=' ') for ch in name: - print "'%c'," % ch, - print "'\\0'," + print("'%c'," % ch, end=' ') + print("'\\0',") string_offsets[ enum ] = i i += len(name) + 1 - print '};' - print '' + print('};') + print('') - print 'static const enum_elt enum_string_table_offsets[%u] =' % (len(self.enum_table)) - print '{' + print('static const enum_elt enum_string_table_offsets[%u] =' % (len(self.enum_table))) + print('{') for enum in sorted_enum_values: (name, pri) = self.enum_table[enum] - print ' { %5u, 0x%08X }, /* %s */' % (string_offsets[enum], enum, name) - print '};' - print '' + print(' { %5u, 0x%08X }, /* %s */' % (string_offsets[enum], enum, name)) + print('};') + print('') self.print_code() return @@ -240,7 +242,7 @@ _mesa_lookup_prim_by_nr(GLuint nr) # confuse us. GL_ACTIVE_PROGRAM_EXT is OK to lose because # we choose GL_ACTIVE PROGRAM instead. if name in self.string_to_int and name != "GL_ACTIVE_PROGRAM_EXT": - print "#error Renumbering {0} from {1} to {2}".format(name, self.string_to_int[name], value) + print("#error Renumbering {0} from {1} to {2}".format(name, self.string_to_int[name], value)) self.string_to_int[name] = value diff --git a/src/mapi/glapi/gen/gl_genexec.py b/src/mapi/glapi/gen/gl_genexec.py index be8013b62b2..fc5b10a4b35 100644 --- a/src/mapi/glapi/gen/gl_genexec.py +++ b/src/mapi/glapi/gen/gl_genexec.py @@ -24,6 +24,8 @@ # _mesa_initialize_exec_table(). It is responsible for populating all # entries in the "exec" dispatch table that aren't dynamic. +from __future__ import print_function + import argparse import collections import license @@ -170,10 +172,10 @@ class PrintCode(gl_XML.gl_print_base): 'Intel Corporation') def printRealHeader(self): - print header + print(header) def printRealFooter(self): - print footer + print(footer) def printBody(self, api): # Collect SET_* calls by the condition under which they should @@ -249,10 +251,10 @@ class PrintCode(gl_XML.gl_print_base): # Print out an if statement for each unique condition, with # the SET_* calls nested inside it. for condition in sorted(settings_by_condition.keys()): - print ' if ({0}) {{'.format(condition) + print(' if ({0}) {{'.format(condition)) for setting in sorted(settings_by_condition[condition]): - print ' {0}'.format(setting) - print ' }' + print(' {0}'.format(setting)) + print(' }') def _parser(): diff --git a/src/mapi/glapi/gen/gl_gentable.py b/src/mapi/glapi/gen/gl_gentable.py index 50153bbabd5..73fa6c6daac 100644 --- a/src/mapi/glapi/gen/gl_gentable.py +++ b/src/mapi/glapi/gen/gl_gentable.py @@ -29,6 +29,8 @@ # Based on code ogiginally by: # Ian Romanick <[email protected]> +from __future__ import print_function + import argparse import license @@ -187,12 +189,12 @@ class PrintCode(gl_XML.gl_print_base): def printRealHeader(self): - print header + print(header) return def printRealFooter(self): - print footer + print(footer) return @@ -218,11 +220,11 @@ class PrintCode(gl_XML.gl_print_base): if funcnames[i] is None: raise Exception("Function table has no function at offset %d" % (i)) - print "#define GLAPI_TABLE_COUNT %d" % func_count - print "static const char * const _glapi_table_func_names[GLAPI_TABLE_COUNT] = {" + print("#define GLAPI_TABLE_COUNT %d" % func_count) + print("static const char * const _glapi_table_func_names[GLAPI_TABLE_COUNT] = {") for i in xrange(0, func_count): - print " /* %5d */ \"%s\"," % (i, funcnames[i]) - print "};" + print(" /* %5d */ \"%s\"," % (i, funcnames[i])) + print("};") return diff --git a/src/mapi/glapi/gen/gl_marshal.py b/src/mapi/glapi/gen/gl_marshal.py index 6a2c0d7b314..e9dd2c4f786 100644 --- a/src/mapi/glapi/gen/gl_marshal.py +++ b/src/mapi/glapi/gen/gl_marshal.py @@ -20,6 +20,8 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. +from __future__ import print_function + import contextlib import getopt import gl_XML @@ -42,9 +44,9 @@ current_indent = 0 def out(str): if str: - print ' '*current_indent + str + print(' '*current_indent + str) else: - print '' + print('') @contextlib.contextmanager @@ -64,15 +66,15 @@ class PrintCode(gl_XML.gl_print_base): 'Copyright (C) 2012 Intel Corporation', 'INTEL CORPORATION') def printRealHeader(self): - print header - print 'static inline int safe_mul(int a, int b)' - print '{' - print ' if (a < 0 || b < 0) return -1;' - print ' if (a == 0 || b == 0) return 0;' - print ' if (a > INT_MAX / b) return -1;' - print ' return a * b;' - print '}' - print + print(header) + print('static inline int safe_mul(int a, int b)') + print('{') + print(' if (a < 0 || b < 0) return -1;') + print(' if (a == 0 || b == 0) return 0;') + print(' if (a > INT_MAX / b) return -1;') + print(' return a * b;') + print('}') + print() def printRealFooter(self): pass @@ -342,7 +344,7 @@ class PrintCode(gl_XML.gl_print_base): def show_usage(): - print 'Usage: %s [-f input_file_name]' % sys.argv[0] + print('Usage: %s [-f input_file_name]' % sys.argv[0]) sys.exit(1) diff --git a/src/mapi/glapi/gen/gl_marshal_h.py b/src/mapi/glapi/gen/gl_marshal_h.py index 998ca5930d4..6490595a00f 100644 --- a/src/mapi/glapi/gen/gl_marshal_h.py +++ b/src/mapi/glapi/gen/gl_marshal_h.py @@ -20,6 +20,8 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. +from __future__ import print_function + import getopt import gl_XML import license @@ -46,24 +48,24 @@ class PrintCode(gl_XML.gl_print_base): 'Copyright (C) 2012 Intel Corporation', 'INTEL CORPORATION') def printRealHeader(self): - print header + print(header) def printRealFooter(self): - print footer + print(footer) def printBody(self, api): - print 'enum marshal_dispatch_cmd_id' - print '{' + print('enum marshal_dispatch_cmd_id') + print('{') for func in api.functionIterateAll(): flavor = func.marshal_flavor() if flavor in ('skip', 'sync'): continue - print ' DISPATCH_CMD_{0},'.format(func.name) - print '};' + print(' DISPATCH_CMD_{0},'.format(func.name)) + print('};') def show_usage(): - print 'Usage: %s [-f input_file_name]' % sys.argv[0] + print('Usage: %s [-f input_file_name]' % sys.argv[0]) sys.exit(1) diff --git a/src/mapi/glapi/gen/gl_procs.py b/src/mapi/glapi/gen/gl_procs.py index d9ea1ab0749..a7bc909ce28 100644 --- a/src/mapi/glapi/gen/gl_procs.py +++ b/src/mapi/glapi/gen/gl_procs.py @@ -24,6 +24,8 @@ # Authors: # Ian Romanick <[email protected]> +from __future__ import print_function + import argparse import license @@ -42,7 +44,7 @@ class PrintGlProcs(gl_XML.gl_print_base): (C) Copyright IBM Corporation 2004, 2006""", "BRIAN PAUL, IBM") def printRealHeader(self): - print """ + print(""" /* This file is only included by glapi.c and is used for * the GetProcAddress() function */ @@ -65,20 +67,20 @@ typedef struct { # define NAME_FUNC_OFFSET(n,f1,f2,f3,o) { n , (_glapi_proc) f3 , o } #endif -""" +""") return def printRealFooter(self): - print '' - print '#undef NAME_FUNC_OFFSET' + print('') + print('#undef NAME_FUNC_OFFSET') return def printFunctionString(self, name): - print ' "gl%s\\0"' % (name) + print(' "gl%s\\0"' % (name)) def printBody(self, api): - print '' - print 'static const char gl_string_table[] =' + print('') + print('static const char gl_string_table[] =') base_offset = 0 table = [] @@ -108,23 +110,23 @@ typedef struct { base_offset += len(n) + 3 - print ' ;' - print '' - print '' - print "#ifdef USE_MGL_NAMESPACE" + print(' ;') + print('') + print('') + print("#ifdef USE_MGL_NAMESPACE") for func in api.functionIterateByOffset(): for n in func.entry_points: if (not func.is_static_entry_point(func.name)) or (func.has_different_protocol(n) and not func.is_static_entry_point(n)): - print '#define gl_dispatch_stub_%u mgl_dispatch_stub_%u' % (func.offset, func.offset) + print('#define gl_dispatch_stub_%u mgl_dispatch_stub_%u' % (func.offset, func.offset)) break - print "#endif /* USE_MGL_NAMESPACE */" - print '' - print '' - print '#if defined(NEED_FUNCTION_POINTER) || defined(GLX_INDIRECT_RENDERING)' + print("#endif /* USE_MGL_NAMESPACE */") + print('') + print('') + print('#if defined(NEED_FUNCTION_POINTER) || defined(GLX_INDIRECT_RENDERING)') for func in api.functionIterateByOffset(): for n in func.entry_points: if (not func.is_static_entry_point(func.name)) or (func.has_different_protocol(n) and not func.is_static_entry_point(n)): - print '%s GLAPIENTRY gl_dispatch_stub_%u(%s);' % (func.return_type, func.offset, func.get_parameter_string()) + print('%s GLAPIENTRY gl_dispatch_stub_%u(%s);' % (func.return_type, func.offset, func.get_parameter_string())) break if self.es: @@ -139,26 +141,26 @@ typedef struct { % (func.return_type, "gl" + n, func.get_parameter_string(n)) categories[cat].append(proto) if categories: - print '' - print '/* OpenGL ES specific prototypes */' - print '' + print('') + print('/* OpenGL ES specific prototypes */') + print('') keys = categories.keys() keys.sort() for key in keys: - print '/* category %s */' % key - print "\n".join(categories[key]) - print '' + print('/* category %s */' % key) + print("\n".join(categories[key])) + print('') - print '#endif /* defined(NEED_FUNCTION_POINTER) || defined(GLX_INDIRECT_RENDERING) */' + print('#endif /* defined(NEED_FUNCTION_POINTER) || defined(GLX_INDIRECT_RENDERING) */') - print '' - print 'static const glprocs_table_t static_functions[] = {' + print('') + print('static const glprocs_table_t static_functions[] = {') for info in table: - print ' NAME_FUNC_OFFSET(%5u, %s, %s, %s, %d),' % info + print(' NAME_FUNC_OFFSET(%5u, %s, %s, %s, %d),' % info) - print ' NAME_FUNC_OFFSET(-1, NULL, NULL, NULL, 0)' - print '};' + print(' NAME_FUNC_OFFSET(-1, NULL, NULL, NULL, 0)') + print('};') return diff --git a/src/mapi/glapi/gen/gl_table.py b/src/mapi/glapi/gen/gl_table.py index 579efa80e17..4b89ef8a856 100644 --- a/src/mapi/glapi/gen/gl_table.py +++ b/src/mapi/glapi/gen/gl_table.py @@ -25,6 +25,8 @@ # Authors: # Ian Romanick <[email protected]> +from __future__ import print_function + import argparse import gl_XML @@ -45,33 +47,33 @@ class PrintGlTable(gl_XML.gl_print_base): def printBody(self, api): for f in api.functionIterateByOffset(): arg_string = f.get_parameter_string() - print ' %s (GLAPIENTRYP %s)(%s); /* %d */' % ( - f.return_type, f.name, arg_string, f.offset) + print(' %s (GLAPIENTRYP %s)(%s); /* %d */' % ( + f.return_type, f.name, arg_string, f.offset)) def printRealHeader(self): - print '#ifndef GLAPIENTRYP' - print '# ifndef GLAPIENTRY' - print '# define GLAPIENTRY' - print '# endif' - print '' - print '# define GLAPIENTRYP GLAPIENTRY *' - print '#endif' - print '' - print '' - print '#ifdef __cplusplus' - print 'extern "C" {' - print '#endif' - print '' - print 'struct _glapi_table' - print '{' + print('#ifndef GLAPIENTRYP') + print('# ifndef GLAPIENTRY') + print('# define GLAPIENTRY') + print('# endif') + print('') + print('# define GLAPIENTRYP GLAPIENTRY *') + print('#endif') + print('') + print('') + print('#ifdef __cplusplus') + print('extern "C" {') + print('#endif') + print('') + print('struct _glapi_table') + print('{') return def printRealFooter(self): - print '};' - print '' - print '#ifdef __cplusplus' - print '}' - print '#endif' + print('};') + print('') + print('#ifdef __cplusplus') + print('}') + print('#endif') return @@ -87,7 +89,7 @@ class PrintRemapTable(gl_XML.gl_print_base): def printRealHeader(self): - print """ + print(""" /** * \\file main/dispatch.h * Macros for handling GL dispatch tables. @@ -98,27 +100,27 @@ class PrintRemapTable(gl_XML.gl_print_base): * can SET_FuncName, are used to get and set the dispatch pointer for the * named function in the specified dispatch table. */ -""" +""") return def printBody(self, api): - print '#define CALL_by_offset(disp, cast, offset, parameters) \\' - print ' (*(cast (GET_by_offset(disp, offset)))) parameters' - print '#define GET_by_offset(disp, offset) \\' - print ' (offset >= 0) ? (((_glapi_proc *)(disp))[offset]) : NULL' - print '#define SET_by_offset(disp, offset, fn) \\' - print ' do { \\' - print ' if ( (offset) < 0 ) { \\' - print ' /* fprintf( stderr, "[%s:%u] SET_by_offset(%p, %d, %s)!\\n", */ \\' - print ' /* __func__, __LINE__, disp, offset, # fn); */ \\' - print ' /* abort(); */ \\' - print ' } \\' - print ' else { \\' - print ' ( (_glapi_proc *) (disp) )[offset] = (_glapi_proc) fn; \\' - print ' } \\' - print ' } while(0)' - print '' + print('#define CALL_by_offset(disp, cast, offset, parameters) \\') + print(' (*(cast (GET_by_offset(disp, offset)))) parameters') + print('#define GET_by_offset(disp, offset) \\') + print(' (offset >= 0) ? (((_glapi_proc *)(disp))[offset]) : NULL') + print('#define SET_by_offset(disp, offset, fn) \\') + print(' do { \\') + print(' if ( (offset) < 0 ) { \\') + print(' /* fprintf( stderr, "[%s:%u] SET_by_offset(%p, %d, %s)!\\n", */ \\') + print(' /* __func__, __LINE__, disp, offset, # fn); */ \\') + print(' /* abort(); */ \\') + print(' } \\') + print(' else { \\') + print(' ( (_glapi_proc *) (disp) )[offset] = (_glapi_proc) fn; \\') + print(' } \\') + print(' } while(0)') + print('') functions = [] abi_functions = [] @@ -130,43 +132,43 @@ class PrintRemapTable(gl_XML.gl_print_base): else: abi_functions.append([f, -1]) - print '/* total number of offsets below */' - print '#define _gloffset_COUNT %d' % (len(abi_functions + functions)) - print '' + print('/* total number of offsets below */') + print('#define _gloffset_COUNT %d' % (len(abi_functions + functions))) + print('') for f, index in abi_functions: - print '#define _gloffset_%s %d' % (f.name, f.offset) + print('#define _gloffset_%s %d' % (f.name, f.offset)) remap_table = "driDispatchRemapTable" - print '#define %s_size %u' % (remap_table, count) - print 'extern int %s[ %s_size ];' % (remap_table, remap_table) - print '' + print('#define %s_size %u' % (remap_table, count)) + print('extern int %s[ %s_size ];' % (remap_table, remap_table)) + print('') for f, index in functions: - print '#define %s_remap_index %u' % (f.name, index) + print('#define %s_remap_index %u' % (f.name, index)) - print '' + print('') for f, index in functions: - print '#define _gloffset_%s %s[%s_remap_index]' % (f.name, remap_table, f.name) + print('#define _gloffset_%s %s[%s_remap_index]' % (f.name, remap_table, f.name)) - print '' + print('') for f, index in abi_functions + functions: arg_string = gl_XML.create_parameter_string(f.parameters, 0) - print 'typedef %s (GLAPIENTRYP _glptr_%s)(%s);' % (f.return_type, f.name, arg_string) - print '#define CALL_%s(disp, parameters) \\' % (f.name) - print ' (* GET_%s(disp)) parameters' % (f.name) - print 'static inline _glptr_%s GET_%s(struct _glapi_table *disp) {' % (f.name, f.name) - print ' return (_glptr_%s) (GET_by_offset(disp, _gloffset_%s));' % (f.name, f.name) - print '}' - print - print 'static inline void SET_%s(struct _glapi_table *disp, %s (GLAPIENTRYP fn)(%s)) {' % (f.name, f.return_type, arg_string) - print ' SET_by_offset(disp, _gloffset_%s, fn);' % (f.name) - print '}' - print + print('typedef %s (GLAPIENTRYP _glptr_%s)(%s);' % (f.return_type, f.name, arg_string)) + print('#define CALL_%s(disp, parameters) \\' % (f.name)) + print(' (* GET_%s(disp)) parameters' % (f.name)) + print('static inline _glptr_%s GET_%s(struct _glapi_table *disp) {' % (f.name, f.name)) + print(' return (_glptr_%s) (GET_by_offset(disp, _gloffset_%s));' % (f.name, f.name)) + print('}') + print() + print('static inline void SET_%s(struct _glapi_table *disp, %s (GLAPIENTRYP fn)(%s)) {' % (f.name, f.return_type, arg_string)) + print(' SET_by_offset(disp, _gloffset_%s, fn);' % (f.name)) + print('}') + print() return diff --git a/src/mapi/glapi/gen/gl_x86-64_asm.py b/src/mapi/glapi/gen/gl_x86-64_asm.py index cde80ecdc05..36d3ecdde92 100644 --- a/src/mapi/glapi/gen/gl_x86-64_asm.py +++ b/src/mapi/glapi/gen/gl_x86-64_asm.py @@ -24,6 +24,8 @@ # Authors: # Ian Romanick <[email protected]> +from __future__ import print_function + import argparse import copy @@ -54,7 +56,7 @@ def save_all_regs(registers): adjust_stack = 0 if not should_use_push(registers): adjust_stack = local_size(registers) - print '\tsubq\t$%u, %%rsp' % (adjust_stack) + print('\tsubq\t$%u, %%rsp' % (adjust_stack)) for [reg, stack_offset] in registers: save_reg( reg, stack_offset, adjust_stack ) @@ -72,18 +74,18 @@ def restore_all_regs(registers): restore_reg(reg, stack_offset, adjust_stack) if adjust_stack: - print '\taddq\t$%u, %%rsp' % (adjust_stack) + print('\taddq\t$%u, %%rsp' % (adjust_stack)) return def save_reg(reg, offset, use_move): if use_move: if offset == 0: - print '\tmovq\t%s, (%%rsp)' % (reg) + print('\tmovq\t%s, (%%rsp)' % (reg)) else: - print '\tmovq\t%s, %u(%%rsp)' % (reg, offset) + print('\tmovq\t%s, %u(%%rsp)' % (reg, offset)) else: - print '\tpushq\t%s' % (reg) + print('\tpushq\t%s' % (reg)) return @@ -91,11 +93,11 @@ def save_reg(reg, offset, use_move): def restore_reg(reg, offset, use_move): if use_move: if offset == 0: - print '\tmovq\t(%%rsp), %s' % (reg) + print('\tmovq\t(%%rsp), %s' % (reg)) else: - print '\tmovq\t%u(%%rsp), %s' % (offset, reg) + print('\tmovq\t%u(%%rsp), %s' % (offset, reg)) else: - print '\tpopq\t%s' % (reg) + print('\tpopq\t%s' % (reg)) return @@ -119,62 +121,62 @@ class PrintGenericStubs(gl_XML.gl_print_base): def printRealHeader(self): - print "/* If we build with gcc's -fvisibility=hidden flag, we'll need to change" - print " * the symbol visibility mode to 'default'." - print ' */' - print '' - print '#include "x86/assyntax.h"' - print '' - print '#ifdef __GNUC__' - print '# pragma GCC visibility push(default)' - print '# define HIDDEN(x) .hidden x' - print '#else' - print '# define HIDDEN(x)' - print '#endif' - print '' - print '# if defined(USE_MGL_NAMESPACE)' - print '# define GL_PREFIX(n) GLNAME(CONCAT(mgl,n))' - print '# define _glapi_Dispatch _mglapi_Dispatch' - print '# else' - print '# define GL_PREFIX(n) GLNAME(CONCAT(gl,n))' - print '# endif' - print '' - print '\t.text' - print '' - print '#ifdef GLX_USE_TLS' - print '' - print '_x86_64_get_dispatch:' - print '\tmovq\t_glapi_tls_Dispatch@GOTTPOFF(%rip), %rax' - print '\tmovq\t%fs:(%rax), %rax' - print '\tret' - print '\t.size\t_x86_64_get_dispatch, .-_x86_64_get_dispatch' - print '' - print '#elif defined(HAVE_PTHREAD)' - print '' - print '\t.extern\t_glapi_Dispatch' - print '\t.extern\t_gl_DispatchTSD' - print '\t.extern\tpthread_getspecific' - print '' - print '\t.p2align\t4,,15' - print '_x86_64_get_dispatch:' - print '\tmovq\t_gl_DispatchTSD@GOTPCREL(%rip), %rax' - print '\tmovl\t(%rax), %edi' - print '\tjmp\tpthread_getspecific@PLT' - print '' - print '#else' - print '' - print '\t.extern\t_glapi_get_dispatch' - print '' - print '#endif' - print '' + print("/* If we build with gcc's -fvisibility=hidden flag, we'll need to change") + print(" * the symbol visibility mode to 'default'.") + print(' */') + print('') + print('#include "x86/assyntax.h"') + print('') + print('#ifdef __GNUC__') + print('# pragma GCC visibility push(default)') + print('# define HIDDEN(x) .hidden x') + print('#else') + print('# define HIDDEN(x)') + print('#endif') + print('') + print('# if defined(USE_MGL_NAMESPACE)') + print('# define GL_PREFIX(n) GLNAME(CONCAT(mgl,n))') + print('# define _glapi_Dispatch _mglapi_Dispatch') + print('# else') + print('# define GL_PREFIX(n) GLNAME(CONCAT(gl,n))') + print('# endif') + print('') + print('\t.text') + print('') + print('#ifdef GLX_USE_TLS') + print('') + print('_x86_64_get_dispatch:') + print('\tmovq\t_glapi_tls_Dispatch@GOTTPOFF(%rip), %rax') + print('\tmovq\t%fs:(%rax), %rax') + print('\tret') + print('\t.size\t_x86_64_get_dispatch, .-_x86_64_get_dispatch') + print('') + print('#elif defined(HAVE_PTHREAD)') + print('') + print('\t.extern\t_glapi_Dispatch') + print('\t.extern\t_gl_DispatchTSD') + print('\t.extern\tpthread_getspecific') + print('') + print('\t.p2align\t4,,15') + print('_x86_64_get_dispatch:') + print('\tmovq\t_gl_DispatchTSD@GOTPCREL(%rip), %rax') + print('\tmovl\t(%rax), %edi') + print('\tjmp\tpthread_getspecific@PLT') + print('') + print('#else') + print('') + print('\t.extern\t_glapi_get_dispatch') + print('') + print('#endif') + print('') return def printRealFooter(self): - print '' - print '#if defined (__ELF__) && defined (__linux__)' - print ' .section .note.GNU-stack,"",%progbits' - print '#endif' + print('') + print('#if defined (__ELF__) && defined (__linux__)') + print(' .section .note.GNU-stack,"",%progbits') + print('#endif') return @@ -219,47 +221,47 @@ class PrintGenericStubs(gl_XML.gl_print_base): name = f.dispatch_name() - print '\t.p2align\t4,,15' - print '\t.globl\tGL_PREFIX(%s)' % (name) - print '\t.type\tGL_PREFIX(%s), @function' % (name) + print('\t.p2align\t4,,15') + print('\t.globl\tGL_PREFIX(%s)' % (name)) + print('\t.type\tGL_PREFIX(%s), @function' % (name)) if not f.is_static_entry_point(f.name): - print '\tHIDDEN(GL_PREFIX(%s))' % (name) - print 'GL_PREFIX(%s):' % (name) - print '#if defined(GLX_USE_TLS)' - print '\tcall\t_x86_64_get_dispatch@PLT' - print '\tmovq\t%u(%%rax), %%r11' % (f.offset * 8) - print '\tjmp\t*%r11' - print '#elif defined(HAVE_PTHREAD)' + print('\tHIDDEN(GL_PREFIX(%s))' % (name)) + print('GL_PREFIX(%s):' % (name)) + print('#if defined(GLX_USE_TLS)') + print('\tcall\t_x86_64_get_dispatch@PLT') + print('\tmovq\t%u(%%rax), %%r11' % (f.offset * 8)) + print('\tjmp\t*%r11') + print('#elif defined(HAVE_PTHREAD)') save_all_regs(registers) - print '\tcall\t_x86_64_get_dispatch@PLT' + print('\tcall\t_x86_64_get_dispatch@PLT') restore_all_regs(registers) if f.offset == 0: - print '\tmovq\t(%rax), %r11' + print('\tmovq\t(%rax), %r11') else: - print '\tmovq\t%u(%%rax), %%r11' % (f.offset * 8) + print('\tmovq\t%u(%%rax), %%r11' % (f.offset * 8)) - print '\tjmp\t*%r11' + print('\tjmp\t*%r11') - print '#else' - print '\tmovq\t_glapi_Dispatch(%rip), %rax' - print '\ttestq\t%rax, %rax' - print '\tje\t1f' - print '\tmovq\t%u(%%rax), %%r11' % (f.offset * 8) - print '\tjmp\t*%r11' - print '1:' + print('#else') + print('\tmovq\t_glapi_Dispatch(%rip), %rax') + print('\ttestq\t%rax, %rax') + print('\tje\t1f') + print('\tmovq\t%u(%%rax), %%r11' % (f.offset * 8)) + print('\tjmp\t*%r11') + print('1:') save_all_regs(registers) - print '\tcall\t_glapi_get_dispatch' + print('\tcall\t_glapi_get_dispatch') restore_all_regs(registers) - print '\tmovq\t%u(%%rax), %%r11' % (f.offset * 8) - print '\tjmp\t*%r11' - print '#endif /* defined(GLX_USE_TLS) */' + print('\tmovq\t%u(%%rax), %%r11' % (f.offset * 8)) + print('\tjmp\t*%r11') + print('#endif /* defined(GLX_USE_TLS) */') - print '\t.size\tGL_PREFIX(%s), .-GL_PREFIX(%s)' % (name, name) - print '' + print('\t.size\tGL_PREFIX(%s), .-GL_PREFIX(%s)' % (name, name)) + print('') return @@ -276,11 +278,11 @@ class PrintGenericStubs(gl_XML.gl_print_base): text = '\t.globl GL_PREFIX(%s) ; .set GL_PREFIX(%s), GL_PREFIX(%s)' % (n, n, dispatch) if f.has_different_protocol(n): - print '#ifndef GLX_INDIRECT_RENDERING' - print text - print '#endif' + print('#ifndef GLX_INDIRECT_RENDERING') + print(text) + print('#endif') else: - print text + print(text) return diff --git a/src/mapi/glapi/gen/gl_x86_asm.py b/src/mapi/glapi/gen/gl_x86_asm.py index 24c15a70809..ada849f35e9 100644 --- a/src/mapi/glapi/gen/gl_x86_asm.py +++ b/src/mapi/glapi/gen/gl_x86_asm.py @@ -24,6 +24,8 @@ # Authors: # Ian Romanick <[email protected]> +from __future__ import print_function + import argparse import license @@ -53,135 +55,135 @@ class PrintGenericStubs(gl_XML.gl_print_base): def printRealHeader(self): - print '#include "x86/assyntax.h"' - print '' - print '#if defined(STDCALL_API)' - print '# if defined(USE_MGL_NAMESPACE)' - print '# define GL_PREFIX(n,n2) GLNAME(CONCAT(mgl,n2))' - print '# else' - print '# define GL_PREFIX(n,n2) GLNAME(CONCAT(gl,n2))' - print '# endif' - print '#else' - print '# if defined(USE_MGL_NAMESPACE)' - print '# define GL_PREFIX(n,n2) GLNAME(CONCAT(mgl,n))' - print '# define _glapi_Dispatch _mglapi_Dispatch' - print '# else' - print '# define GL_PREFIX(n,n2) GLNAME(CONCAT(gl,n))' - print '# endif' - print '#endif' - print '' - print '#define GL_OFFSET(x) CODEPTR(REGOFF(4 * x, EAX))' - print '' - print '#if defined(GNU_ASSEMBLER) && !defined(__MINGW32__) && !defined(__APPLE__)' - print '#define GLOBL_FN(x) GLOBL x ; .type x, @function' - print '#else' - print '#define GLOBL_FN(x) GLOBL x' - print '#endif' - print '' - print '' - print '#ifdef GLX_USE_TLS' - print '' - print '#ifdef GLX_X86_READONLY_TEXT' - print '# define CTX_INSNS MOV_L(GS:(EAX), EAX)' - print '#else' - print '# define CTX_INSNS NOP /* Pad for init_glapi_relocs() */' - print '#endif' - print '' - print '# define GL_STUB(fn,off,fn_alt)\t\t\t\\' - print 'ALIGNTEXT16;\t\t\t\t\t\t\\' - print 'GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\' - print 'GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\' - print '\tCALL(_x86_get_dispatch) ;\t\t\t\\' - print '\tCTX_INSNS ; \\' - print '\tJMP(GL_OFFSET(off))' - print '' - print '#elif defined(HAVE_PTHREAD)' - print '# define GL_STUB(fn,off,fn_alt)\t\t\t\\' - print 'ALIGNTEXT16;\t\t\t\t\t\t\\' - print 'GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\' - print 'GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\' - print '\tMOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ;\t\\' - print '\tTEST_L(EAX, EAX) ;\t\t\t\t\\' - print '\tJE(1f) ;\t\t\t\t\t\\' - print '\tJMP(GL_OFFSET(off)) ;\t\t\t\t\\' - print '1:\tCALL(_x86_get_dispatch) ;\t\t\t\\' - print '\tJMP(GL_OFFSET(off))' - print '#else' - print '# define GL_STUB(fn,off,fn_alt)\t\t\t\\' - print 'ALIGNTEXT16;\t\t\t\t\t\t\\' - print 'GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\' - print 'GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\' - print '\tMOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ;\t\\' - print '\tTEST_L(EAX, EAX) ;\t\t\t\t\\' - print '\tJE(1f) ;\t\t\t\t\t\\' - print '\tJMP(GL_OFFSET(off)) ;\t\t\t\t\\' - print '1:\tCALL(_glapi_get_dispatch) ;\t\t\t\\' - print '\tJMP(GL_OFFSET(off))' - print '#endif' - print '' - print '#ifdef HAVE_FUNC_ATTRIBUTE_ALIAS' - print '# define GL_STUB_ALIAS(fn,off,fn_alt,alias,alias_alt)\t\\' - print '\t.globl\tGL_PREFIX(fn, fn_alt) ;\t\t\t\\' - print '\t.set\tGL_PREFIX(fn, fn_alt), GL_PREFIX(alias, alias_alt)' - print '#else' - print '# define GL_STUB_ALIAS(fn,off,fn_alt,alias,alias_alt)\t\\' - print ' GL_STUB(fn, off, fn_alt)' - print '#endif' - print '' - print 'SEG_TEXT' - print '' - print '#ifdef GLX_USE_TLS' - print '' - print '\tGLOBL\tGLNAME(_x86_get_dispatch)' - print '\tHIDDEN(GLNAME(_x86_get_dispatch))' - print 'ALIGNTEXT16' - print 'GLNAME(_x86_get_dispatch):' - print '\tcall 1f' - print '1:\tpopl %eax' - print '\taddl $_GLOBAL_OFFSET_TABLE_+[.-1b], %eax' - print '\tmovl _glapi_tls_Dispatch@GOTNTPOFF(%eax), %eax' - print '\tret' - print '' - print '#elif defined(HAVE_PTHREAD)' - print 'EXTERN GLNAME(_glapi_Dispatch)' - print 'EXTERN GLNAME(_gl_DispatchTSD)' - print 'EXTERN GLNAME(pthread_getspecific)' - print '' - print 'ALIGNTEXT16' - print 'GLNAME(_x86_get_dispatch):' - print '\tSUB_L(CONST(24), ESP)' - print '\tPUSH_L(GLNAME(_gl_DispatchTSD))' - print '\tCALL(GLNAME(pthread_getspecific))' - print '\tADD_L(CONST(28), ESP)' - print '\tRET' - print '#else' - print 'EXTERN GLNAME(_glapi_get_dispatch)' - print '#endif' - print '' - - print '#if defined( GLX_USE_TLS ) && !defined( GLX_X86_READONLY_TEXT )' - print '\t\t.section\twtext, "awx", @progbits' - print '#endif /* defined( GLX_USE_TLS ) */' - - print '' - print '\t\tALIGNTEXT16' - print '\t\tGLOBL GLNAME(gl_dispatch_functions_start)' - print '\t\tHIDDEN(GLNAME(gl_dispatch_functions_start))' - print 'GLNAME(gl_dispatch_functions_start):' - print '' + print('#include "x86/assyntax.h"') + print('') + print('#if defined(STDCALL_API)') + print('# if defined(USE_MGL_NAMESPACE)') + print('# define GL_PREFIX(n,n2) GLNAME(CONCAT(mgl,n2))') + print('# else') + print('# define GL_PREFIX(n,n2) GLNAME(CONCAT(gl,n2))') + print('# endif') + print('#else') + print('# if defined(USE_MGL_NAMESPACE)') + print('# define GL_PREFIX(n,n2) GLNAME(CONCAT(mgl,n))') + print('# define _glapi_Dispatch _mglapi_Dispatch') + print('# else') + print('# define GL_PREFIX(n,n2) GLNAME(CONCAT(gl,n))') + print('# endif') + print('#endif') + print('') + print('#define GL_OFFSET(x) CODEPTR(REGOFF(4 * x, EAX))') + print('') + print('#if defined(GNU_ASSEMBLER) && !defined(__MINGW32__) && !defined(__APPLE__)') + print('#define GLOBL_FN(x) GLOBL x ; .type x, @function') + print('#else') + print('#define GLOBL_FN(x) GLOBL x') + print('#endif') + print('') + print('') + print('#ifdef GLX_USE_TLS') + print('') + print('#ifdef GLX_X86_READONLY_TEXT') + print('# define CTX_INSNS MOV_L(GS:(EAX), EAX)') + print('#else') + print('# define CTX_INSNS NOP /* Pad for init_glapi_relocs() */') + print('#endif') + print('') + print('# define GL_STUB(fn,off,fn_alt)\t\t\t\\') + print('ALIGNTEXT16;\t\t\t\t\t\t\\') + print('GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\') + print('GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\') + print('\tCALL(_x86_get_dispatch) ;\t\t\t\\') + print('\tCTX_INSNS ; \\') + print('\tJMP(GL_OFFSET(off))') + print('') + print('#elif defined(HAVE_PTHREAD)') + print('# define GL_STUB(fn,off,fn_alt)\t\t\t\\') + print('ALIGNTEXT16;\t\t\t\t\t\t\\') + print('GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\') + print('GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\') + print('\tMOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ;\t\\') + print('\tTEST_L(EAX, EAX) ;\t\t\t\t\\') + print('\tJE(1f) ;\t\t\t\t\t\\') + print('\tJMP(GL_OFFSET(off)) ;\t\t\t\t\\') + print('1:\tCALL(_x86_get_dispatch) ;\t\t\t\\') + print('\tJMP(GL_OFFSET(off))') + print('#else') + print('# define GL_STUB(fn,off,fn_alt)\t\t\t\\') + print('ALIGNTEXT16;\t\t\t\t\t\t\\') + print('GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\') + print('GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\') + print('\tMOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ;\t\\') + print('\tTEST_L(EAX, EAX) ;\t\t\t\t\\') + print('\tJE(1f) ;\t\t\t\t\t\\') + print('\tJMP(GL_OFFSET(off)) ;\t\t\t\t\\') + print('1:\tCALL(_glapi_get_dispatch) ;\t\t\t\\') + print('\tJMP(GL_OFFSET(off))') + print('#endif') + print('') + print('#ifdef HAVE_FUNC_ATTRIBUTE_ALIAS') + print('# define GL_STUB_ALIAS(fn,off,fn_alt,alias,alias_alt)\t\\') + print('\t.globl\tGL_PREFIX(fn, fn_alt) ;\t\t\t\\') + print('\t.set\tGL_PREFIX(fn, fn_alt), GL_PREFIX(alias, alias_alt)') + print('#else') + print('# define GL_STUB_ALIAS(fn,off,fn_alt,alias,alias_alt)\t\\') + print(' GL_STUB(fn, off, fn_alt)') + print('#endif') + print('') + print('SEG_TEXT') + print('') + print('#ifdef GLX_USE_TLS') + print('') + print('\tGLOBL\tGLNAME(_x86_get_dispatch)') + print('\tHIDDEN(GLNAME(_x86_get_dispatch))') + print('ALIGNTEXT16') + print('GLNAME(_x86_get_dispatch):') + print('\tcall 1f') + print('1:\tpopl %eax') + print('\taddl $_GLOBAL_OFFSET_TABLE_+[.-1b], %eax') + print('\tmovl _glapi_tls_Dispatch@GOTNTPOFF(%eax), %eax') + print('\tret') + print('') + print('#elif defined(HAVE_PTHREAD)') + print('EXTERN GLNAME(_glapi_Dispatch)') + print('EXTERN GLNAME(_gl_DispatchTSD)') + print('EXTERN GLNAME(pthread_getspecific)') + print('') + print('ALIGNTEXT16') + print('GLNAME(_x86_get_dispatch):') + print('\tSUB_L(CONST(24), ESP)') + print('\tPUSH_L(GLNAME(_gl_DispatchTSD))') + print('\tCALL(GLNAME(pthread_getspecific))') + print('\tADD_L(CONST(28), ESP)') + print('\tRET') + print('#else') + print('EXTERN GLNAME(_glapi_get_dispatch)') + print('#endif') + print('') + + print('#if defined( GLX_USE_TLS ) && !defined( GLX_X86_READONLY_TEXT )') + print('\t\t.section\twtext, "awx", @progbits') + print('#endif /* defined( GLX_USE_TLS ) */') + + print('') + print('\t\tALIGNTEXT16') + print('\t\tGLOBL GLNAME(gl_dispatch_functions_start)') + print('\t\tHIDDEN(GLNAME(gl_dispatch_functions_start))') + print('GLNAME(gl_dispatch_functions_start):') + print('') return def printRealFooter(self): - print '' - print '\t\tGLOBL\tGLNAME(gl_dispatch_functions_end)' - print '\t\tHIDDEN(GLNAME(gl_dispatch_functions_end))' - print '\t\tALIGNTEXT16' - print 'GLNAME(gl_dispatch_functions_end):' - print '' - print '#if defined (__ELF__) && defined (__linux__)' - print ' .section .note.GNU-stack,"",%progbits' - print '#endif' + print('') + print('\t\tGLOBL\tGLNAME(gl_dispatch_functions_end)') + print('\t\tHIDDEN(GLNAME(gl_dispatch_functions_end))') + print('\t\tALIGNTEXT16') + print('GLNAME(gl_dispatch_functions_end):') + print('') + print('#if defined (__ELF__) && defined (__linux__)') + print(' .section .note.GNU-stack,"",%progbits') + print('#endif') return @@ -191,10 +193,10 @@ class PrintGenericStubs(gl_XML.gl_print_base): stack = self.get_stack_size(f) alt = "%s@%u" % (name, stack) - print '\tGL_STUB(%s, %d, %s)' % (name, f.offset, alt) + print('\tGL_STUB(%s, %d, %s)' % (name, f.offset, alt)) if not f.is_static_entry_point(f.name): - print '\tHIDDEN(GL_PREFIX(%s, %s))' % (name, alt) + print('\tHIDDEN(GL_PREFIX(%s, %s))' % (name, alt)) for f in api.functionIterateByOffset(): @@ -209,11 +211,11 @@ class PrintGenericStubs(gl_XML.gl_print_base): text = '\tGL_STUB_ALIAS(%s, %d, %s, %s, %s)' % (n, f.offset, alt2, name, alt) if f.has_different_protocol(n): - print '#ifndef GLX_INDIRECT_RENDERING' - print text - print '#endif' + print('#ifndef GLX_INDIRECT_RENDERING') + print(text) + print('#endif') else: - print text + print(text) return diff --git a/src/mapi/glapi/gen/remap_helper.py b/src/mapi/glapi/gen/remap_helper.py index de759d6c04b..0740b189f67 100644 --- a/src/mapi/glapi/gen/remap_helper.py +++ b/src/mapi/glapi/gen/remap_helper.py @@ -23,6 +23,8 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. +from __future__ import print_function + import argparse import license @@ -66,23 +68,23 @@ class PrintGlRemap(gl_XML.gl_print_base): def printRealHeader(self): - print '#include "main/dispatch.h"' - print '#include "main/remap.h"' - print '' + print('#include "main/dispatch.h"') + print('#include "main/remap.h"') + print('') return def printBody(self, api): pool_indices = {} - print '/* this is internal to remap.c */' - print '#ifndef need_MESA_remap_table' - print '#error Only remap.c should include this file!' - print '#endif /* need_MESA_remap_table */' - print '' + print('/* this is internal to remap.c */') + print('#ifndef need_MESA_remap_table') + print('#error Only remap.c should include this file!') + print('#endif /* need_MESA_remap_table */') + print('') - print '' - print 'static const char _mesa_function_pool[] =' + print('') + print('static const char _mesa_function_pool[] =') # output string pool index = 0; @@ -100,26 +102,26 @@ class PrintGlRemap(gl_XML.gl_print_base): else: comments = "dynamic" - print ' /* _mesa_function_pool[%d]: %s (%s) */' \ - % (index, f.name, comments) + print(' /* _mesa_function_pool[%d]: %s (%s) */' \ + % (index, f.name, comments)) for line in spec: - print ' "%s\\0"' % line + print(' "%s\\0"' % line) index += len(line) + 1 - print ' ;' - print '' + print(' ;') + print('') - print '/* these functions need to be remapped */' - print 'static const struct gl_function_pool_remap MESA_remap_table_functions[] = {' + print('/* these functions need to be remapped */') + print('static const struct gl_function_pool_remap MESA_remap_table_functions[] = {') # output all functions that need to be remapped # iterate by offsets so that they are sorted by remap indices for f in api.functionIterateByOffset(): if not f.assign_offset: continue - print ' { %5d, %s_remap_index },' \ - % (pool_indices[f], f.name) - print ' { -1, -1 }' - print '};' - print '' + print(' { %5d, %s_remap_index },' \ + % (pool_indices[f], f.name)) + print(' { -1, -1 }') + print('};') + print('') return diff --git a/src/mapi/glapi/gen/typeexpr.py b/src/mapi/glapi/gen/typeexpr.py index 6da85c289c1..5ff9798dadc 100644 --- a/src/mapi/glapi/gen/typeexpr.py +++ b/src/mapi/glapi/gen/typeexpr.py @@ -24,6 +24,8 @@ # Authors: # Ian Romanick <[email protected]> +from __future__ import print_function + import string, copy class type_node(object): @@ -286,6 +288,6 @@ if __name__ == '__main__': create_initial_types() for t in types_to_try: - print 'Trying "%s"...' % (t) + print('Trying "%s"...' % (t)) te = type_expression( t ) - print 'Got "%s" (%u, %u).' % (te.string(), te.get_stack_size(), te.get_element_size()) + print('Got "%s" (%u, %u).' % (te.string(), te.get_stack_size(), te.get_element_size())) |