summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Bridon <bochecha@daitauha.fr>2018-07-05 15:17:32 +0200
committerDylan Baker <dylan@pnwbakers.com>2018-07-06 10:04:22 -0700
commit0f7b18fa0d353aab0a44082b1aca8d8c00df71a7 (patch)
treee511fe8f70b48ad5203e3a0e52d0dc1b086bfd91
parentb3a42fa0667caeeebabd9e6aeb46a9534810c2f3 (diff)
downloadmesa-0f7b18fa0d353aab0a44082b1aca8d8c00df71a7.tar.gz
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 <bochecha@daitauha.fr> Acked-by: Eric Engestrom <eric.engestrom@intel.com> Acked-by: Dylan Baker <dylan@pnwbakers.com>
-rw-r--r--src/amd/common/sid_tables.py39
-rw-r--r--src/amd/vulkan/vk_format_table.py93
-rw-r--r--src/compiler/nir/nir_builder_opcodes_h.py3
-rw-r--r--src/compiler/nir/nir_constant_expressions.py5
-rw-r--r--src/compiler/nir/nir_opcodes_c.py4
-rw-r--r--src/compiler/nir/nir_opcodes_h.py3
-rw-r--r--src/compiler/nir/nir_opt_algebraic.py12
-rw-r--r--src/gallium/auxiliary/indices/u_indices_gen.py296
-rw-r--r--src/gallium/auxiliary/indices/u_unfilled_gen.py94
-rw-r--r--src/gallium/auxiliary/util/u_format_pack.py168
-rw-r--r--src/gallium/auxiliary/util/u_format_table.py181
-rw-r--r--src/gallium/drivers/freedreno/ir3/ir3_nir_trig.py8
-rw-r--r--src/gallium/drivers/r600/egd_tables.py51
-rw-r--r--src/intel/compiler/brw_nir_trig_workarounds.py8
-rw-r--r--src/mapi/glapi/gen/glX_proto_common.py8
-rw-r--r--src/mapi/glapi/gen/glX_proto_send.py408
-rw-r--r--src/mapi/glapi/gen/glX_proto_size.py232
-rw-r--r--src/mapi/glapi/gen/gl_SPARC_asm.py360
-rw-r--r--src/mapi/glapi/gen/gl_XML.py48
-rw-r--r--src/mapi/glapi/gen/gl_apitemp.py96
-rw-r--r--src/mapi/glapi/gen/gl_enums.py62
-rw-r--r--src/mapi/glapi/gen/gl_genexec.py12
-rw-r--r--src/mapi/glapi/gen/gl_gentable.py14
-rw-r--r--src/mapi/glapi/gen/gl_marshal.py26
-rw-r--r--src/mapi/glapi/gen/gl_marshal_h.py16
-rw-r--r--src/mapi/glapi/gen/gl_procs.py60
-rw-r--r--src/mapi/glapi/gen/gl_table.py126
-rw-r--r--src/mapi/glapi/gen/gl_x86-64_asm.py184
-rw-r--r--src/mapi/glapi/gen/gl_x86_asm.py264
-rw-r--r--src/mapi/glapi/gen/remap_helper.py46
-rw-r--r--src/mapi/glapi/gen/typeexpr.py6
-rw-r--r--src/mapi/mapi_abi.py154
-rw-r--r--src/mesa/main/format_info.py40
-rw-r--r--src/mesa/main/format_pack.py3
-rw-r--r--src/mesa/main/format_unpack.py3
-rw-r--r--src/mesa/main/get_hash_generator.py28
-rw-r--r--src/util/format_srgb.py69
-rw-r--r--src/util/xmlpool/gen_xmlpool.py17
38 files changed, 1652 insertions, 1595 deletions
diff --git a/src/amd/common/sid_tables.py b/src/amd/common/sid_tables.py
index ca90f82535d..421c2a13352 100644
--- a/src/amd/common/sid_tables.py
+++ b/src/amd/common/sid_tables.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
CopyRight = '''
/*
@@ -333,10 +334,10 @@ def write_tables(asics, packets):
strings_offsets = IntTable("int")
fields = FieldTable()
- print '/* This file is autogenerated by sid_tables.py from sid.h. Do not edit directly. */'
- print
- print CopyRight.strip()
- print '''
+ print('/* This file is autogenerated by sid_tables.py from sid.h. Do not edit directly. */')
+ print()
+ print(CopyRight.strip())
+ print('''
#ifndef SID_TABLES_H
#define SID_TABLES_H
@@ -358,17 +359,17 @@ struct si_packet3 {
unsigned name_offset;
unsigned op;
};
-'''
+''')
- print 'static const struct si_packet3 packet3_table[] = {'
+ print('static const struct si_packet3 packet3_table[] = {')
for pkt in packets:
- print '\t{%s, %s},' % (strings.add(pkt[5:]), pkt)
- print '};'
- print
+ print('\t{%s, %s},' % (strings.add(pkt[5:]), pkt))
+ print('};')
+ print()
regs = {}
for asic in asics:
- print 'static const struct si_reg %s_reg_table[] = {' % (asic.name)
+ print('static const struct si_reg %s_reg_table[] = {' % (asic.name))
for reg in asic.registers:
# Only output a register that was changed or added relative to
# the previous generation
@@ -377,27 +378,27 @@ struct si_packet3 {
continue
if len(reg.fields):
- print '\t{%s, %s, %s, %s},' % (strings.add(reg.name), reg.r_name,
- len(reg.fields), fields.add(reg.fields))
+ print('\t{%s, %s, %s, %s},' % (strings.add(reg.name), reg.r_name,
+ len(reg.fields), fields.add(reg.fields)))
else:
- print '\t{%s, %s},' % (strings.add(reg.name), reg.r_name)
+ print('\t{%s, %s},' % (strings.add(reg.name), reg.r_name))
regs[reg.r_name] = reg
- print '};'
- print
+ print('};')
+ print()
fields.emit(sys.stdout, strings, strings_offsets)
- print
+ print()
strings.emit(sys.stdout, "sid_strings")
- print
+ print()
strings_offsets.emit(sys.stdout, "sid_strings_offsets")
- print
- print '#endif'
+ print()
+ print('#endif')
def main():
diff --git a/src/amd/vulkan/vk_format_table.py b/src/amd/vulkan/vk_format_table.py
index cd1af6226a4..604aac8fa75 100644
--- a/src/amd/vulkan/vk_format_table.py
+++ b/src/amd/vulkan/vk_format_table.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
CopyRight = '''
/**************************************************************************
@@ -79,24 +80,24 @@ def print_channels(format, func):
if format.nr_channels() <= 1:
func(format.le_channels, format.le_swizzles)
else:
- print '#ifdef PIPE_ARCH_BIG_ENDIAN'
+ print('#ifdef PIPE_ARCH_BIG_ENDIAN')
func(format.be_channels, format.be_swizzles)
- print '#else'
+ print('#else')
func(format.le_channels, format.le_swizzles)
- print '#endif'
+ print('#endif')
def write_format_table(formats):
- print '/* This file is autogenerated by vk_format_table.py from vk_format_layout.csv. Do not edit directly. */'
- print
+ print('/* This file is autogenerated by vk_format_table.py from vk_format_layout.csv. Do not edit directly. */')
+ print()
# This will print the copyright message on the top of this file
- print CopyRight.strip()
- print
- print '#include "stdbool.h"'
- print '#include "vk_format.h"'
- print
+ print(CopyRight.strip())
+ print()
+ print('#include "stdbool.h"')
+ print('#include "vk_format.h"')
+ print()
def do_channel_array(channels, swizzles):
- print " {"
+ print(" {")
for i in range(4):
channel = channels[i]
if i < 3:
@@ -104,13 +105,13 @@ def write_format_table(formats):
else:
sep = ""
if channel.size:
- print " {%s, %s, %s, %s, %u, %u}%s\t/* %s = %s */" % (type_map[channel.type], bool_map(channel.norm), bool_map(channel.pure), bool_map(channel.scaled), channel.size, channel.shift, sep, "xyzw"[i], channel.name)
+ print(" {%s, %s, %s, %s, %u, %u}%s\t/* %s = %s */" % (type_map[channel.type], bool_map(channel.norm), bool_map(channel.pure), bool_map(channel.scaled), channel.size, channel.shift, sep, "xyzw"[i], channel.name))
else:
- print " {0, 0, 0, 0, 0}%s" % (sep,)
- print " },"
+ print(" {0, 0, 0, 0, 0}%s" % (sep,))
+ print(" },")
def do_swizzle_array(channels, swizzles):
- print " {"
+ print(" {")
for i in range(4):
swizzle = swizzles[i]
if i < 3:
@@ -121,43 +122,43 @@ def write_format_table(formats):
comment = colorspace_channels_map[format.colorspace][i]
except (KeyError, IndexError):
comment = 'ignored'
- print " %s%s\t/* %s */" % (swizzle_map[swizzle], sep, comment)
- print " },"
+ print(" %s%s\t/* %s */" % (swizzle_map[swizzle], sep, comment))
+ print(" },")
for format in formats:
- print 'static const struct vk_format_description'
- print 'vk_format_%s_description = {' % (format.short_name(),)
- print " %s," % (format.name,)
- print " \"%s\"," % (format.name,)
- print " \"%s\"," % (format.short_name(),)
- print " {%u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_size())
- print " %s," % (layout_map(format.layout),)
- print " %u,\t/* nr_channels */" % (format.nr_channels(),)
- print " %s,\t/* is_array */" % (bool_map(format.is_array()),)
- print " %s,\t/* is_bitmask */" % (bool_map(format.is_bitmask()),)
- print " %s,\t/* is_mixed */" % (bool_map(format.is_mixed()),)
+ print('static const struct vk_format_description')
+ print('vk_format_%s_description = {' % (format.short_name(),))
+ print(" %s," % (format.name,))
+ print(" \"%s\"," % (format.name,))
+ print(" \"%s\"," % (format.short_name(),))
+ print(" {%u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_size()))
+ print(" %s," % (layout_map(format.layout),))
+ print(" %u,\t/* nr_channels */" % (format.nr_channels(),))
+ print(" %s,\t/* is_array */" % (bool_map(format.is_array()),))
+ print(" %s,\t/* is_bitmask */" % (bool_map(format.is_bitmask()),))
+ print(" %s,\t/* is_mixed */" % (bool_map(format.is_mixed()),))
print_channels(format, do_channel_array)
print_channels(format, do_swizzle_array)
- print " %s," % (colorspace_map(format.colorspace),)
- print "};"
- print
+ print(" %s," % (colorspace_map(format.colorspace),))
+ print("};")
+ print()
- print "const struct vk_format_description *"
- print "vk_format_description(VkFormat format)"
- print "{"
- print " if (format > VK_FORMAT_END_RANGE) {"
- print " return NULL;"
- print " }"
- print
- print " switch (format) {"
+ print("const struct vk_format_description *")
+ print("vk_format_description(VkFormat format)")
+ print("{")
+ print(" if (format > VK_FORMAT_END_RANGE) {")
+ print(" return NULL;")
+ print(" }")
+ print()
+ print(" switch (format) {")
for format in formats:
- print " case %s:" % format.name
- print " return &vk_format_%s_description;" % (format.short_name(),)
- print " default:"
- print " return NULL;"
- print " }"
- print "}"
- print
+ print(" case %s:" % format.name)
+ print(" return &vk_format_%s_description;" % (format.short_name(),))
+ print(" default:")
+ print(" return NULL;")
+ print(" }")
+ print("}")
+ print()
def main():
diff --git a/src/compiler/nir/nir_builder_opcodes_h.py b/src/compiler/nir/nir_builder_opcodes_h.py
index 4a41e6079ed..72cf5b4549d 100644
--- a/src/compiler/nir/nir_builder_opcodes_h.py
+++ b/src/compiler/nir/nir_builder_opcodes_h.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
template = """\
/* Copyright (C) 2015 Broadcom
@@ -68,4 +69,4 @@ from nir_opcodes import opcodes
from nir_intrinsics import INTR_OPCODES
from mako.template import Template
-print Template(template).render(opcodes=opcodes, INTR_OPCODES=INTR_OPCODES)
+print(Template(template).render(opcodes=opcodes, INTR_OPCODES=INTR_OPCODES))
diff --git a/src/compiler/nir/nir_constant_expressions.py b/src/compiler/nir/nir_constant_expressions.py
index db5bde2b82d..35dffe70ce7 100644
--- a/src/compiler/nir/nir_constant_expressions.py
+++ b/src/compiler/nir/nir_constant_expressions.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
import re
@@ -431,8 +432,8 @@ nir_eval_const_opcode(nir_op op, unsigned num_components,
from nir_opcodes import opcodes
from mako.template import Template
-print Template(template).render(opcodes=opcodes, type_sizes=type_sizes,
+print(Template(template).render(opcodes=opcodes, type_sizes=type_sizes,
type_has_size=type_has_size,
type_add_size=type_add_size,
op_bit_sizes=op_bit_sizes,
- get_const_field=get_const_field)
+ get_const_field=get_const_field))
diff --git a/src/compiler/nir/nir_opcodes_c.py b/src/compiler/nir/nir_opcodes_c.py
index 8afccca9504..108e144b5f4 100644
--- a/src/compiler/nir/nir_opcodes_c.py
+++ b/src/compiler/nir/nir_opcodes_c.py
@@ -23,6 +23,8 @@
# Authors:
# Connor Abbott (cwabbott0@gmail.com)
+from __future__ import print_function
+
from nir_opcodes import opcodes
from mako.template import Template
@@ -135,4 +137,4 @@ const nir_op_info nir_op_infos[nir_num_opcodes] = {
};
""")
-print template.render(opcodes=opcodes)
+print(template.render(opcodes=opcodes))
diff --git a/src/compiler/nir/nir_opcodes_h.py b/src/compiler/nir/nir_opcodes_h.py
index c9538e4e957..8ad17c84d49 100644
--- a/src/compiler/nir/nir_opcodes_h.py
+++ b/src/compiler/nir/nir_opcodes_h.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
template = """\
/* Copyright (C) 2014 Connor Abbott
@@ -43,4 +44,4 @@ typedef enum {
from nir_opcodes import opcodes
from mako.template import Template
-print Template(template).render(opcodes=opcodes)
+print(Template(template).render(opcodes=opcodes))
diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
index 2f1cba398f0..5e07d662b07 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -23,6 +23,8 @@
# Authors:
# Jason Ekstrand (jason@jlekstrand.net)
+from __future__ import print_function
+
from collections import OrderedDict
import nir_algebraic
import itertools
@@ -791,8 +793,8 @@ late_optimizations = [
(('b2f@32', a), ('iand', a, 1.0), 'options->lower_b2f'),
]
-print nir_algebraic.AlgebraicPass("nir_opt_algebraic", optimizations).render()
-print nir_algebraic.AlgebraicPass("nir_opt_algebraic_before_ffma",
- before_ffma_optimizations).render()
-print nir_algebraic.AlgebraicPass("nir_opt_algebraic_late",
- late_optimizations).render()
+print(nir_algebraic.AlgebraicPass("nir_opt_algebraic", optimizations).render())
+print(nir_algebraic.AlgebraicPass("nir_opt_algebraic_before_ffma",
+ before_ffma_optimizations).render())
+print(nir_algebraic.AlgebraicPass("nir_opt_algebraic_late",
+ late_optimizations).render())
diff --git a/src/gallium/auxiliary/indices/u_indices_gen.py b/src/gallium/auxiliary/indices/u_indices_gen.py
index 376348d5f8e..2d9297854c5 100644
--- a/src/gallium/auxiliary/indices/u_indices_gen.py
+++ b/src/gallium/auxiliary/indices/u_indices_gen.py
@@ -1,3 +1,5 @@
+from __future__ import print_function
+
copyright = '''
/*
* Copyright 2009 VMware, Inc.
@@ -69,9 +71,9 @@ pv_idx = dict(first='PV_FIRST', last='PV_LAST')
pr_idx = dict(prdisable='PR_DISABLE', prenable='PR_ENABLE')
def prolog():
- print '''/* File automatically generated by u_indices_gen.py */'''
- print copyright
- print r'''
+ print('''/* File automatically generated by u_indices_gen.py */''')
+ print(copyright)
+ print(r'''
/**
* @file
@@ -107,7 +109,7 @@ static u_translate_func translate[IN_COUNT][OUT_COUNT][PV_COUNT][PV_COUNT][PR_CO
static u_generate_func generate[OUT_COUNT][PV_COUNT][PV_COUNT][PRIM_COUNT];
-'''
+''')
def vert( intype, outtype, v0 ):
if intype == GENERATE:
@@ -116,30 +118,30 @@ def vert( intype, outtype, v0 ):
return '(' + outtype + ')in[' + v0 + ']'
def point( intype, outtype, ptr, v0 ):
- print ' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';'
+ print(' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';')
def line( intype, outtype, ptr, v0, v1 ):
- print ' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';'
- print ' (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';'
+ print(' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';')
+ print(' (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';')
def tri( intype, outtype, ptr, v0, v1, v2 ):
- print ' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';'
- print ' (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';'
- print ' (' + ptr + ')[2] = ' + vert( intype, outtype, v2 ) + ';'
+ print(' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';')
+ print(' (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';')
+ print(' (' + ptr + ')[2] = ' + vert( intype, outtype, v2 ) + ';')
def lineadj( intype, outtype, ptr, v0, v1, v2, v3 ):
- print ' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';'
- print ' (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';'
- print ' (' + ptr + ')[2] = ' + vert( intype, outtype, v2 ) + ';'
- print ' (' + ptr + ')[3] = ' + vert( intype, outtype, v3 ) + ';'
+ print(' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';')
+ print(' (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';')
+ print(' (' + ptr + ')[2] = ' + vert( intype, outtype, v2 ) + ';')
+ print(' (' + ptr + ')[3] = ' + vert( intype, outtype, v3 ) + ';')
def triadj( intype, outtype, ptr, v0, v1, v2, v3, v4, v5 ):
- print ' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';'
- print ' (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';'
- print ' (' + ptr + ')[2] = ' + vert( intype, outtype, v2 ) + ';'
- print ' (' + ptr + ')[3] = ' + vert( intype, outtype, v3 ) + ';'
- print ' (' + ptr + ')[4] = ' + vert( intype, outtype, v4 ) + ';'
- print ' (' + ptr + ')[5] = ' + vert( intype, outtype, v5 ) + ';'
+ print(' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';')
+ print(' (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';')
+ print(' (' + ptr + ')[2] = ' + vert( intype, outtype, v2 ) + ';')
+ print(' (' + ptr + ')[3] = ' + vert( intype, outtype, v3 ) + ';')
+ print(' (' + ptr + ')[4] = ' + vert( intype, outtype, v4 ) + ';')
+ print(' (' + ptr + ')[5] = ' + vert( intype, outtype, v5 ) + ';')
def do_point( intype, outtype, ptr, v0 ):
point( intype, outtype, ptr, v0 )
@@ -186,231 +188,231 @@ def name(intype, outtype, inpv, outpv, pr, prim):
return 'translate_' + prim + '_' + intype + '2' + outtype + '_' + inpv + '2' + outpv + '_' + pr
def preamble(intype, outtype, inpv, outpv, pr, prim):
- print 'static void ' + name( intype, outtype, inpv, outpv, pr, prim ) + '('
+ print('static void ' + name( intype, outtype, inpv, outpv, pr, prim ) + '(')
if intype != GENERATE:
- print ' const void * _in,'
- print ' unsigned start,'
+ print(' const void * _in,')
+ print(' unsigned start,')
if intype != GENERATE:
- print ' unsigned in_nr,'
- print ' unsigned out_nr,'
+ print(' unsigned in_nr,')
+ print(' unsigned out_nr,')
if intype != GENERATE:
- print ' unsigned restart_index,'
- print ' void *_out )'
- print '{'
+ print(' unsigned restart_index,')
+ print(' void *_out )')
+ print('{')
if intype != GENERATE:
- print ' const ' + intype + '*in = (const ' + intype + '*)_in;'
- print ' ' + outtype + ' *out = (' + outtype + '*)_out;'
- print ' unsigned i, j;'
- print ' (void)j;'
+ print(' const ' + intype + '*in = (const ' + intype + '*)_in;')
+ print(' ' + outtype + ' *out = (' + outtype + '*)_out;')
+ print(' unsigned i, j;')
+ print(' (void)j;')
def postamble():
- print '}'
+ print('}')
def points(intype, outtype, inpv, outpv, pr):
preamble(intype, outtype, inpv, outpv, pr, prim='points')
- print ' for (i = start; i < (out_nr+start); i++) { '
+ print(' for (i = start; i < (out_nr+start); i++) { ')
do_point( intype, outtype, 'out+i', 'i' );
- print ' }'
+ print(' }')
postamble()
def lines(intype, outtype, inpv, outpv, pr):
preamble(intype, outtype, inpv, outpv, pr, prim='lines')
- print ' for (i = start; i < (out_nr+start); i+=2) { '
+ print(' for (i = start; i < (out_nr+start); i+=2) { ')
do_line( intype, outtype, 'out+i', 'i', 'i+1', inpv, outpv );
- print ' }'
+ print(' }')
postamble()
def linestrip(intype, outtype, inpv, outpv, pr):
preamble(intype, outtype, inpv, outpv, pr, prim='linestrip')
- print ' for (i = start, j = 0; j < out_nr; j+=2, i++) { '
+ print(' for (i = start, j = 0; j < out_nr; j+=2, i++) { ')
do_line( intype, outtype, 'out+j', 'i', 'i+1', inpv, outpv );
- print ' }'
+ print(' }')
postamble()
def lineloop(intype, outtype, inpv, outpv, pr):
preamble(intype, outtype, inpv, outpv, pr, prim='lineloop')
- print ' for (i = start, j = 0; j < out_nr - 2; j+=2, i++) { '
+ print(' for (i = start, j = 0; j < out_nr - 2; j+=2, i++) { ')
do_line( intype, outtype, 'out+j', 'i', 'i+1', inpv, outpv );
- print ' }'
+ print(' }')
do_line( intype, outtype, 'out+j', 'i', 'start', inpv, outpv );
postamble()
def tris(intype, outtype, inpv, outpv, pr):
preamble(intype, outtype, inpv, outpv, pr, prim='tris')
- print ' for (i = start; i < (out_nr+start); i+=3) { '
+ print(' for (i = start; i < (out_nr+start); i+=3) { ')
do_tri( intype, outtype, 'out+i', 'i', 'i+1', 'i+2', inpv, outpv );
- print ' }'
+ print(' }')
postamble()
def tristrip(intype, outtype, inpv, outpv, pr):
preamble(intype, outtype, inpv, outpv, pr, prim='tristrip')
- print ' for (i = start, j = 0; j < out_nr; j+=3, i++) { '
+ print(' for (i = start, j = 0; j < out_nr; j+=3, i++) { ')
if inpv == FIRST:
do_tri( intype, outtype, 'out+j', 'i', 'i+1+(i&1)', 'i+2-(i&1)', inpv, outpv );
else:
do_tri( intype, outtype, 'out+j', 'i+(i&1)', 'i+1-(i&1)', 'i+2', inpv, outpv );
- print ' }'
+ print(' }')
postamble()
def trifan(intype, outtype, inpv, outpv, pr):
preamble(intype, outtype, inpv, outpv, pr, prim='trifan')
- print ' for (i = start, j = 0; j < out_nr; j+=3, i++) { '
+ print(' for (i = start, j = 0; j < out_nr; j+=3, i++) { ')
do_tri( intype, outtype, 'out+j', 'start', 'i+1', 'i+2', inpv, outpv );
- print ' }'
+ print(' }')
postamble()
def polygon(intype, outtype, inpv, outpv, pr):
preamble(intype, outtype, inpv, outpv, pr, prim='polygon')
- print ' for (i = start, j = 0; j < out_nr; j+=3, i++) { '
+ print(' for (i = start, j = 0; j < out_nr; j+=3, i++) { ')
if pr == PRENABLE:
- print 'restart:'
- print ' if (i + 3 > in_nr) {'
- print ' (out+j+0)[0] = restart_index;'
- print ' (out+j+0)[1] = restart_index;'
- print ' (out+j+0)[2] = restart_index;'
- print ' continue;'
- print ' }'
- print ' if (in[i + 0] == restart_index) {'
- print ' i += 1;'
- print ' start = i;'
- print ' goto restart;'
- print ' }'
- print ' if (in[i + 1] == restart_index) {'
- print ' i += 2;'
- print ' start = i;'
- print ' goto restart;'
- print ' }'
- print ' if (in[i + 2] == restart_index) {'
- print ' i += 3;'
- print ' start = i;'
- print ' goto restart;'
- print ' }'
+ print('restart:')
+ print(' if (i + 3 > in_nr) {')
+ print(' (out+j+0)[0] = restart_index;')
+ print(' (out+j+0)[1] = restart_index;')
+ print(' (out+j+0)[2] = restart_index;')
+ print(' continue;')
+ print(' }')
+ print(' if (in[i + 0] == restart_index) {')
+ print(' i += 1;')
+ print(' start = i;')
+ print(' goto restart;')
+ print(' }')
+ print(' if (in[i + 1] == restart_index) {')
+ print(' i += 2;')
+ print(' start = i;')
+ print(' goto restart;')
+ print(' }')
+ print(' if (in[i + 2] == restart_index) {')
+ print(' i += 3;')
+ print(' start = i;')
+ print(' goto restart;')
+ print(' }')
if inpv == FIRST:
do_tri( intype, outtype, 'out+j', 'start', 'i+1', 'i+2', inpv, outpv );
else:
do_tri( intype, outtype, 'out+j', 'i+1', 'i+2', 'start', inpv, outpv );
- print ' }'
+ print(' }')
postamble()
def quads(intype, outtype, inpv, outpv, pr):
preamble(intype, outtype, inpv, outpv, pr, prim='quads')
- print ' for (i = start, j = 0; j < out_nr; j+=6, i+=4) { '
+ print(' for (i = start, j = 0; j < out_nr; j+=6, i+=4) { ')
if pr == PRENABLE:
- print 'restart:'
- print ' if (i + 4 > in_nr) {'
- print ' (out+j+0)[0] = restart_index;'
- print ' (out+j+0)[1] = restart_index;'
- print ' (out+j+0)[2] = restart_index;'
- print ' (out+j+3)[0] = restart_index;'
- print ' (out+j+3)[1] = restart_index;'
- print ' (out+j+3)[2] = restart_index;'
- print ' continue;'
- print ' }'
- print ' if (in[i + 0] == restart_index) {'
- print ' i += 1;'
- print ' goto restart;'
- print ' }'
- print ' if (in[i + 1] == restart_index) {'
- print ' i += 2;'
- print ' goto restart;'
- print ' }'
- print ' if (in[i + 2] == restart_index) {'
- print ' i += 3;'
- print ' goto restart;'
- print ' }'
- print ' if (in[i + 3] == restart_index) {'
- print ' i += 4;'
- print ' goto restart;'
- print ' }'
+ print('restart:')
+ print(' if (i + 4 > in_nr) {')
+ print(' (out+j+0)[0] = restart_index;')
+ print(' (out+j+0)[1] = restart_index;')
+ print(' (out+j+0)[2] = restart_index;')
+ print(' (out+j+3)[0] = restart_index;')
+ print(' (out+j+3)[1] = restart_index;')
+ print(' (out+j+3)[2] = restart_index;')
+ print(' continue;')
+ print(' }')
+ print(' if (in[i + 0] == restart_index) {')
+ print(' i += 1;')
+ print(' goto restart;')
+ print(' }')
+ print(' if (in[i + 1] == restart_index) {')
+ print(' i += 2;')
+ print(' goto restart;')
+ print(' }')
+ print(' if (in[i + 2] == restart_index) {')
+ print(' i += 3;')
+ print(' goto restart;')
+ print(' }')
+ print(' if (in[i + 3] == restart_index) {')
+ print(' i += 4;')
+ print(' goto restart;')
+ print(' }')
do_quad( intype, outtype, 'out+j', 'i+0', 'i+1', 'i+2', 'i+3', inpv, outpv );
- print ' }'
+ print(' }')
postamble()
def quadstrip(intype, outtype, inpv, outpv, pr):
preamble(intype, outtype, inpv, outpv, pr, prim='quadstrip')
- print ' for (i = start, j = 0; j < out_nr; j+=6, i+=2) { '
+ print(' for (i = start, j = 0; j < out_nr; j+=6, i+=2) { ')
if pr == PRENABLE:
- print 'restart:'
- print ' if (i + 4 > in_nr) {'
- print ' (out+j+0)[0] = restart_index;'
- print ' (out+j+0)[1] = restart_index;'
- print ' (out+j+0)[2] = restart_index;'
- print ' (out+j+3)[0] = restart_index;'
- print ' (out+j+3)[1] = restart_index;'
- print ' (out+j+3)[2] = restart_index;'
- print ' continue;'
- print ' }'
- print ' if (in[i + 0] == restart_index) {'
- print ' i += 1;'
- print ' goto restart;'
- print ' }'
- print ' if (in[i + 1] == restart_index) {'
- print ' i += 2;'
- print ' goto restart;'
- print ' }'
- print ' if (in[i + 2] == restart_index) {'
- print ' i += 3;'
- print ' goto restart;'
- print ' }'
- print ' if (in[i + 3] == restart_index) {'
- print ' i += 4;'
- print ' goto restart;'
- print ' }'
+ print('restart:')
+ print(' if (i + 4 > in_nr) {')
+ print(' (out+j+0)[0] = restart_index;')
+ print(' (out+j+0)[1] = restart_index;')
+ print(' (out+j+0)[2] = restart_index;')
+ print(' (out+j+3)[0] = restart_index;')
+ print(' (out+j+3)[1] = restart_index;')
+ print(' (out+j+3)[2] = restart_index;')
+ print(' continue;')
+ print(' }')
+ print(' if (in[i + 0] == restart_index) {')
+ print(' i += 1;')
+ print(' goto restart;')
+ print(' }')
+ print(' if (in[i + 1] == restart_index) {')
+ print(' i += 2;')
+ print(' goto restart;')
+ print(' }')
+ print(' if (in[i + 2] == restart_index) {')
+ print(' i += 3;')
+ print(' goto restart;')
+ print(' }')
+ print(' if (in[i + 3] == restart_index) {')
+ print(' i += 4;')
+ print(' goto restart;')
+ print(' }')
if inpv == LAST:
do_quad( intype, outtype, 'out+j', 'i+2', 'i+0', 'i+1', 'i+3', inpv, outpv );
else:
do_quad( intype, outtype, 'out+j', 'i+0', 'i+1', 'i+3', 'i+2', inpv, outpv );
- print ' }'
+ print(' }')
postamble()
def linesadj(intype, outtype, inpv, outpv, pr):
preamble(intype, outtype, inpv, outpv, pr, prim='linesadj')
- print ' for (i = start; i < (out_nr+start); i+=4) { '
+ print(' for (i = start; i < (out_nr+start); i+=4) { ')
do_lineadj( intype, outtype, 'out+i', 'i+0', 'i+1', 'i+2', 'i+3', inpv, outpv )
- print ' }'
+ print(' }')
postamble()
def linestripadj(intype, outtype, inpv, outpv, pr):
preamble(intype, outtype, inpv, outpv, pr, prim='linestripadj')
- print ' for (i = start, j = 0; j < out_nr; j+=4, i++) {'
+ print(' for (i = start, j = 0; j < out_nr; j+=4, i++) {')
do_lineadj( intype, outtype, 'out+j', 'i+0', 'i+1', 'i+2', 'i+3', inpv, outpv )
- print ' }'
+ print(' }')
postamble()
def trisadj(intype, outtype, inpv, outpv, pr):
preamble(intype, outtype, inpv, outpv, pr, prim='trisadj')
- print ' for (i = start; i < (out_nr+start); i+=6) { '
+ print(' for (i = start; i < (out_nr+start); i+=6) { ')
do_triadj( intype, outtype, 'out+i', 'i+0', 'i+1', 'i+2', 'i+3',
'i+4', 'i+5', inpv, outpv )
- print ' }'
+ print(' }')
postamble()
def tristripadj(intype, outtype, inpv, outpv, pr):
preamble(intype, outtype, inpv, outpv, pr, prim='tristripadj')
- print ' for (i = start, j = 0; j < out_nr; i+=2, j+=6) { '
- print ' if (i % 4 == 0) {'
- print ' /* even triangle */'
+ print(' for (i = start, j = 0; j < out_nr; i+=2, j+=6) { ')
+ print(' if (i % 4 == 0) {')
+ print(' /* even triangle */')
do_triadj( intype, outtype, 'out+j',
'i+0', 'i+1', 'i+2', 'i+3', 'i+4', 'i+5', inpv, outpv )
- print ' } else {'
- print ' /* odd triangle */'
+ print(' } else {')
+ print(' /* odd triangle */')
do_triadj( intype, outtype, 'out+j',
'i+2', 'i-2', 'i+0', 'i+3', 'i+4', 'i+6', inpv, outpv )
- print ' }'
- print ' }'
+ print(' }')
+ print(' }')
postamble()
@@ -466,19 +468,19 @@ def emit_all_inits():
init(intype, outtype, inpv, outpv, pr, prim)
def emit_init():
- print 'void u_index_init( void )'
- print '{'
- print ' static int firsttime = 1;'
- print ' if (!firsttime) return;'
- print ' firsttime = 0;'
+ print('void u_index_init( void )')
+ print('{')
+ print(' static int firsttime = 1;')
+ print(' if (!firsttime) return;')
+ print(' firsttime = 0;')
emit_all_inits()
- print '}'
+ print('}')
def epilog():
- print '#include "indices/u_indices.c"'
+ print('#include "indices/u_indices.c"')
def main():
diff --git a/src/gallium/auxiliary/indices/u_unfilled_gen.py b/src/gallium/auxiliary/indices/u_unfilled_gen.py
index 4780d98383a..4c7d7c61e91 100644
--- a/src/gallium/auxiliary/indices/u_unfilled_gen.py
+++ b/src/gallium/auxiliary/indices/u_unfilled_gen.py
@@ -1,3 +1,5 @@
+from __future__ import print_function
+
copyright = '''
/*
* Copyright 2009 VMware, Inc.
@@ -53,9 +55,9 @@ outtype_idx = dict(ushort='OUT_USHORT', uint='OUT_UINT')
def prolog():
- print '''/* File automatically generated by u_unfilled_gen.py */'''
- print copyright
- print r'''
+ print('''/* File automatically generated by u_unfilled_gen.py */''')
+ print(copyright)
+ print(r'''
/**
* @file
@@ -93,7 +95,7 @@ static unsigned in_size_idx( unsigned index_size )
static u_generate_func generate_line[OUT_COUNT][PRIM_COUNT];
static u_translate_func translate_line[IN_COUNT][OUT_COUNT][PRIM_COUNT];
-'''
+''')
def vert( intype, outtype, v0 ):
if intype == GENERATE:
@@ -102,8 +104,8 @@ def vert( intype, outtype, v0 ):
return '(' + outtype + ')in[' + v0 + ']'
def line( intype, outtype, ptr, v0, v1 ):
- print ' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';'
- print ' (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';'
+ print(' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';')
+ print(' (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';')
# XXX: have the opportunity here to avoid over-drawing shared lines in
# tristrips, fans, etc, by integrating this into the calling functions
@@ -127,89 +129,89 @@ def name(intype, outtype, prim):
return 'translate_' + prim + '_' + intype + '2' + outtype
def preamble(intype, outtype, prim):
- print 'static void ' + name( intype, outtype, prim ) + '('
+ print('static void ' + name( intype, outtype, prim ) + '(')
if intype != GENERATE:
- print ' const void * _in,'
- print ' unsigned start,'
+ print(' const void * _in,')
+ print(' unsigned start,')
if intype != GENERATE:
- print ' unsigned in_nr,'
- print ' unsigned out_nr,'
+ print(' unsigned in_nr,')
+ print(' unsigned out_nr,')
if intype != GENERATE:
- print ' unsigned restart_index,'
- print ' void *_out )'
- print '{'
+ print(' unsigned restart_index,')
+ print(' void *_out )')
+ print('{')
if intype != GENERATE:
- print ' const ' + intype + '*in = (const ' + intype + '*)_in;'
- print ' ' + outtype + ' *out = (' + outtype + '*)_out;'
- print ' unsigned i, j;'
- print ' (void)j;'
+ print(' const ' + intype + '*in = (const ' + intype + '*)_in;')
+ print(' ' + outtype + ' *out = (' + outtype + '*)_out;')
+ print(' unsigned i, j;')
+ print(' (void)j;')
def postamble():
- print '}'
+ print('}')
def tris(intype, outtype):
preamble(intype, outtype, prim='tris')
- print ' for (i = start, j = 0; j < out_nr; j+=6, i+=3) { '
+ print(' for (i = start, j = 0; j < out_nr; j+=6, i+=3) { ')
do_tri( intype, outtype, 'out+j', 'i', 'i+1', 'i+2' );
- print ' }'
+ print(' }')
postamble()
def tristrip(intype, outtype):
preamble(intype, outtype, prim='tristrip')
- print ' for (i = start, j = 0; j < out_nr; j+=6, i++) { '
+ print(' for (i = start, j = 0; j < out_nr; j+=6, i++) { ')
do_tri( intype, outtype, 'out+j', 'i', 'i+1/*+(i&1)*/', 'i+2/*-(i&1)*/' );
- print ' }'
+ print(' }')
postamble()
def trifan(intype, outtype):
preamble(intype, outtype, prim='trifan')
- print ' for (i = start, j = 0; j < out_nr; j+=6, i++) { '
+ print(' for (i = start, j = 0; j < out_nr; j+=6, i++) { ')
do_tri( intype, outtype, 'out+j', '0', 'i+1', 'i+2' );
- print ' }'
+ print(' }')
postamble()
def polygon(intype, outtype):
preamble(intype, outtype, prim='polygon')
- print ' for (i = start, j = 0; j < out_nr; j+=2, i++) { '
+ print(' for (i = start, j = 0; j < out_nr; j+=2, i++) { ')
line( intype, outtype, 'out+j', 'i', '(i+1)%(out_nr/2)' )
- print ' }'
+ print(' }')
postamble()
def quads(intype, outtype):
preamble(intype, outtype, prim='quads')
- print ' for (i = start, j = 0; j < out_nr; j+=8, i+=4) { '
+ print(' for (i = start, j = 0; j < out_nr; j+=8, i+=4) { ')
do_quad( intype, outtype, 'out+j', 'i+0', 'i+1', 'i+2', 'i+3' );
- print ' }'
+ print(' }')
postamble()
def quadstrip(intype, outtype):
preamble(intype, outtype, prim='quadstrip')
- print ' for (i = start, j = 0; j < out_nr; j+=8, i+=2) { '
+ print(' for (i = start, j = 0; j < out_nr; j+=8, i+=2) { ')
do_quad( intype, outtype, 'out+j', 'i+2', 'i+0', 'i+1', 'i+3' );
- print ' }'
+ print(' }')
postamble()
def trisadj(intype, outtype):
preamble(intype, outtype, prim='trisadj')
- print ' for (i = start, j = 0; j < out_nr; j+=6, i+=6) { '
+ print(' for (i = start, j = 0; j < out_nr; j+=6, i+=6) { ')
do_tri( intype, outtype, 'out+j', 'i', 'i+2', 'i+4' );
- print ' }'
+ print(' }')
postamble()
def tristripadj(intype, outtype):
preamble(intype, outtype, prim='tristripadj')
- print ' for (i = start, j = 0; j < out_nr; j+=6, i+=2) { '
+ print(' for (i = start, j = 0; j < out_nr; j+=6, i+=2) { ')
do_tri( intype, outtype, 'out+j', 'i', 'i+2', 'i+4' );
- print ' }'
+ print(' }')
postamble()
@@ -227,16 +229,16 @@ def emit_funcs():
def init(intype, outtype, prim):
if intype == GENERATE:
- print ('generate_line[' +
+ print(('generate_line[' +
outtype_idx[outtype] +
'][' + longprim[prim] +
- '] = ' + name( intype, outtype, prim ) + ';')
+ '] = ' + name( intype, outtype, prim ) + ';'))
else:
- print ('translate_line[' +
+ print(('translate_line[' +
intype_idx[intype] +
'][' + outtype_idx[outtype] +
'][' + longprim[prim] +
- '] = ' + name( intype, outtype, prim ) + ';')
+ '] = ' + name( intype, outtype, prim ) + ';'))
def emit_all_inits():
@@ -246,19 +248,19 @@ def emit_all_inits():
init(intype, outtype, prim)
def emit_init():
- print 'void u_unfilled_init( void )'
- print '{'
- print ' static int firsttime = 1;'
- print ' if (!firsttime) return;'
- print ' firsttime = 0;'
+ print('void u_unfilled_init( void )')
+ print('{')
+ print(' static int firsttime = 1;')
+ print(' if (!firsttime) return;')
+ print(' firsttime = 0;')
emit_all_inits()
- print '}'
+ print('}')
def epilog():
- print '#include "indices/u_unfilled_indices.c"'
+ print('#include "indices/u_unfilled_indices.c"')
def main():
diff --git a/src/gallium/auxiliary/util/u_format_pack.py b/src/gallium/auxiliary/util/u_format_pack.py
index c9b8cd7abc0..7a952a48b30 100644
--- a/src/gallium/auxiliary/util/u_format_pack.py
+++ b/src/gallium/auxiliary/util/u_format_pack.py
@@ -36,6 +36,8 @@
'''
+from __future__ import print_function
+
from u_format_parse import *
@@ -53,11 +55,11 @@ def print_channels(format, func):
if format.nr_channels() <= 1:
func(format.le_channels, format.le_swizzles)
else:
- print '#ifdef PIPE_ARCH_BIG_ENDIAN'
+ print('#ifdef PIPE_ARCH_BIG_ENDIAN')
func(format.be_channels, format.be_swizzles)
- print '#else'
+ print('#else')
func(format.le_channels, format.le_swizzles)
- print '#endif'
+ print('#endif')
def generate_format_type(format):
'''Generate a structure that describes the format.'''
@@ -68,18 +70,18 @@ def generate_format_type(format):
for channel in channels:
if channel.type == VOID:
if channel.size:
- print ' unsigned %s:%u;' % (channel.name, channel.size)
+ print(' unsigned %s:%u;' % (channel.name, channel.size))
elif channel.type == UNSIGNED:
- print ' unsigned %s:%u;' % (channel.name, channel.size)
+ print(' unsigned %s:%u;' % (channel.name, channel.size))
elif channel.type in (SIGNED, FIXED):
- print ' int %s:%u;' % (channel.name, channel.size)
+ print(' int %s:%u;' % (channel.name, channel.size))
elif channel.type == FLOAT:
if channel.size == 64:
- print ' double %s;' % (channel.name)
+ print(' double %s;' % (channel.name))
elif channel.size == 32:
- print ' float %s;' % (channel.name)
+ print(' float %s;' % (channel.name))
else:
- print ' unsigned %s:%u;' % (channel.name, channel.size)
+ print(' unsigned %s:%u;' % (channel.name, channel.size))
else:
assert 0
@@ -88,41 +90,41 @@ def generate_format_type(format):
assert channel.size % 8 == 0 and is_pot(channel.size)
if channel.type == VOID:
if channel.size:
- print ' uint%u_t %s;' % (channel.size, channel.name)
+ print(' uint%u_t %s;' % (channel.size, channel.name))
elif channel.type == UNSIGNED:
- print ' uint%u_t %s;' % (channel.size, channel.name)
+ print(' uint%u_t %s;' % (channel.size, channel.name))
elif channel.type in (SIGNED, FIXED):
- print ' int%u_t %s;' % (channel.size, channel.name)
+ print(' int%u_t %s;' % (channel.size, channel.name))
elif channel.type == FLOAT:
if channel.size == 64:
- print ' double %s;' % (channel.name)
+ print(' double %s;' % (channel.name))
elif channel.size == 32:
- print ' float %s;' % (channel.name)
+ print(' float %s;' % (channel.name))
elif channel.size == 16:
- print ' uint16_t %s;' % (channel.name)
+ print(' uint16_t %s;' % (channel.name))
else:
assert 0
else:
assert 0
- print 'union util_format_%s {' % format.short_name()
+ print('union util_format_%s {' % format.short_name())
if format.block_size() in (8, 16, 32, 64):
- print ' uint%u_t value;' % (format.block_size(),)
+ print(' uint%u_t value;' % (format.block_size(),))
use_bitfields = False
for channel in format.le_channels:
if channel.size % 8 or not is_pot(channel.size):
use_bitfields = True
- print ' struct {'
+ print(' struct {')
if use_bitfields:
print_channels(format, generate_bitfields)
else:
print_channels(format, generate_full_fields)
- print ' } chan;'
- print '};'
- print
+ print(' } chan;')
+ print('};')
+ print()
def is_format_supported(format):
@@ -444,15 +446,15 @@ def generate_unpack_kernel(format, dst_channel, dst_native_type):
def unpack_from_bitmask(channels, swizzles):
depth = format.block_size()
- print ' uint%u_t value = *(const uint%u_t *)src;' % (depth, depth)
+ print(' uint%u_t value = *(const uint%u_t *)src;' % (depth, depth))
# Declare the intermediate variables
for i in range(format.nr_channels()):
src_channel = channels[i]
if src_channel.type == UNSIGNED:
- print ' uint%u_t %s;' % (depth, src_channel.name)
+ print(' uint%u_t %s;' % (depth, src_channel.name))
elif src_channel.type == SIGNED:
- print ' int%u_t %s;' % (depth, src_channel.name)
+ print(' int%u_t %s;' % (depth, src_channel.name))
# Compute the intermediate unshifted values
for i in range(format.nr_channels()):
@@ -479,7 +481,7 @@ def generate_unpack_kernel(format, dst_channel, dst_native_type):
value = None
if value is not None:
- print ' %s = %s;' % (src_channel.name, value)
+ print(' %s = %s;' % (src_channel.name, value))
# Convert, swizzle, and store final values
for i in range(4):
@@ -503,11 +505,11 @@ def generate_unpack_kernel(format, dst_channel, dst_native_type):
value = '0'
else:
assert False
- print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i])
+ print(' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i]))
def unpack_from_union(channels, swizzles):
- print ' union util_format_%s pixel;' % format.short_name()
- print ' memcpy(&pixel, src, sizeof pixel);'
+ print(' union util_format_%s pixel;' % format.short_name())
+ print(' memcpy(&pixel, src, sizeof pixel);')
for i in range(4):
swizzle = swizzles[i]
@@ -530,7 +532,7 @@ def generate_unpack_kernel(format, dst_channel, dst_native_type):
value = '0'
else:
assert False
- print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i])
+ print(' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i]))
if format.is_bitmask():
print_channels(format, unpack_from_bitmask)
@@ -551,7 +553,7 @@ def generate_pack_kernel(format, src_channel, src_native_type):
inv_swizzle = inv_swizzles(swizzles)
depth = format.block_size()
- print ' uint%u_t value = 0;' % depth
+ print(' uint%u_t value = 0;' % depth)
for i in range(4):
dst_channel = channels[i]
@@ -577,14 +579,14 @@ def generate_pack_kernel(format, src_channel, src_native_type):
else:
value = None
if value is not None:
- print ' value |= %s;' % (value)
+ print(' value |= %s;' % (value))
- print ' *(uint%u_t *)dst = value;' % depth
+ print(' *(uint%u_t *)dst = value;' % depth)
def pack_into_union(channels, swizzles):
inv_swizzle = inv_swizzles(swizzles)
- print ' union util_format_%s pixel;' % format.short_name()
+ print(' union util_format_%s pixel;' % format.short_name())
for i in range(4):
dst_channel = channels[i]
@@ -600,9 +602,9 @@ def generate_pack_kernel(format, src_channel, src_native_type):
dst_channel, dst_native_type,
value,
dst_colorspace = dst_colorspace)
- print ' pixel.chan.%s = %s;' % (dst_channel.name, value)
+ print(' pixel.chan.%s = %s;' % (dst_channel.name, value))
- print ' memcpy(dst, &pixel, sizeof pixel);'
+ print(' memcpy(dst, &pixel, sizeof pixel);')
if format.is_bitmask():
print_channels(format, pack_into_bitmask)
@@ -615,28 +617,28 @@ def generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix):
name = format.short_name()
- print 'static inline void'
- print 'util_format_%s_unpack_%s(%s *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)' % (name, dst_suffix, dst_native_type)
- print '{'
+ print('static inline void')
+ print('util_format_%s_unpack_%s(%s *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)' % (name, dst_suffix, dst_native_type))
+ print('{')
if is_format_supported(format):
- print ' unsigned x, y;'
- print ' for(y = 0; y < height; y += %u) {' % (format.block_height,)
- print ' %s *dst = dst_row;' % (dst_native_type)
- print ' const uint8_t *src = src_row;'
- print ' for(x = 0; x < width; x += %u) {' % (format.block_width,)
+ print(' unsigned x, y;')
+ print(' for(y = 0; y < height; y += %u) {' % (format.block_height,))
+ print(' %s *dst = dst_row;' % (dst_native_type))
+ print(' const uint8_t *src = src_row;')
+ print(' for(x = 0; x < width; x += %u) {' % (format.block_width,))
generate_unpack_kernel(format, dst_channel, dst_native_type)
- print ' src += %u;' % (format.block_size() / 8,)
- print ' dst += 4;'
- print ' }'
- print ' src_row += src_stride;'
- print ' dst_row += dst_stride/sizeof(*dst_row);'
- print ' }'
-
- print '}'
- print
+ print(' src += %u;' % (format.block_size() / 8,))
+ print(' dst += 4;')
+ print(' }')
+ print(' src_row += src_stride;')
+ print(' dst_row += dst_stride/sizeof(*dst_row);')
+ print(' }')
+
+ print('}')
+ print()
def generate_format_pack(format, src_channel, src_native_type, src_suffix):
@@ -644,28 +646,28 @@ def generate_format_pack(format, src_channel, src_native_type, src_suffix):
name = format.short_name()
- print 'static inline void'
- print 'util_format_%s_pack_%s(uint8_t *dst_row, unsigned dst_stride, const %s *src_row, unsigned src_stride, unsigned width, unsigned height)' % (name, src_suffix, src_native_type)
- print '{'
+ print('static inline void')
+ print('util_format_%s_pack_%s(uint8_t *dst_row, unsigned dst_stride, const %s *src_row, unsigned src_stride, unsigned width, unsigned height)' % (name, src_suffix, src_native_type))
+ print('{')
if is_format_supported(format):
- print ' unsigned x, y;'
- print ' for(y = 0; y < height; y += %u) {' % (format.block_height,)
- print ' const %s *src = src_row;' % (src_native_type)
- print ' uint8_t *dst = dst_row;'
- print ' for(x = 0; x < width; x += %u) {' % (format.block_width,)
+ print(' unsigned x, y;')
+ print(' for(y = 0; y < height; y += %u) {' % (format.block_height,))
+ print(' const %s *src = src_row;' % (src_native_type))
+ print(' uint8_t *dst = dst_row;')
+ print(' for(x = 0; x < width; x += %u) {' % (format.block_width,))
generate_pack_kernel(format, src_channel, src_native_type)
- print ' src += 4;'
- print ' dst += %u;' % (format.block_size() / 8,)
- print ' }'
- print ' dst_row += dst_stride;'
- print ' src_row += src_stride/sizeof(*src_row);'
- print ' }'
+ print(' src += 4;')
+ print(' dst += %u;' % (format.block_size() / 8,))
+ print(' }')
+ print(' dst_row += dst_stride;')
+ print(' src_row += src_stride/sizeof(*src_row);')
+ print(' }')
- print '}'
- print
+ print('}')
+ print()
def generate_format_fetch(format, dst_channel, dst_native_type, dst_suffix):
@@ -673,15 +675,15 @@ def generate_format_fetch(format, dst_channel, dst_native_type, dst_suffix):
name = format.short_name()
- print 'static inline void'
- print 'util_format_%s_fetch_%s(%s *dst, const uint8_t *src, UNUSED unsigned i, UNUSED unsigned j)' % (name, dst_suffix, dst_native_type)
- print '{'
+ print('static inline void')
+ print('util_format_%s_fetch_%s(%s *dst, const uint8_t *src, UNUSED unsigned i, UNUSED unsigned j)' % (name, dst_suffix, dst_native_type))
+ print('{')
if is_format_supported(format):
generate_unpack_kernel(format, dst_channel, dst_native_type)
- print '}'
- print
+ print('}')
+ print()
def is_format_hand_written(format):
@@ -689,16 +691,16 @@ def is_format_hand_written(format):
def generate(formats):
- print
- print '#include "pipe/p_compiler.h"'
- print '#include "u_math.h"'
- print '#include "u_half.h"'
- print '#include "u_format.h"'
- print '#include "u_format_other.h"'
- print '#include "util/format_srgb.h"'
- print '#include "u_format_yuv.h"'
- print '#include "u_format_zs.h"'
- print
+ print()
+ print('#include "pipe/p_compiler.h"')
+ print('#include "u_math.h"')
+ print('#include "u_half.h"')
+ print('#include "u_format.h"')
+ print('#include "u_format_other.h"')
+ print('#include "util/format_srgb.h"')
+ print('#include "u_format_yuv.h"')
+ print('#include "u_format_zs.h"')
+ print()
for format in formats:
if not is_format_hand_written(format):
diff --git a/src/gallium/auxiliary/util/u_format_table.py b/src/gallium/auxiliary/util/u_format_table.py
index a9df9849947..1a966c52bc7 100644
--- a/src/gallium/auxiliary/util/u_format_table.py
+++ b/src/gallium/auxiliary/util/u_format_table.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
CopyRight = '''
/**************************************************************************
@@ -79,23 +80,23 @@ swizzle_map = {
def write_format_table(formats):
- print '/* This file is autogenerated by u_format_table.py from u_format.csv. Do not edit directly. */'
- print
+ print('/* This file is autogenerated by u_format_table.py from u_format.csv. Do not edit directly. */')
+ print()
# This will print the copyright message on the top of this file
- print CopyRight.strip()
- print
- print '#include "u_format.h"'
- print '#include "u_format_bptc.h"'
- print '#include "u_format_s3tc.h"'
- print '#include "u_format_rgtc.h"'
- print '#include "u_format_latc.h"'
- print '#include "u_format_etc.h"'
- print
+ print(CopyRight.strip())
+ print()
+ print('#include "u_format.h"')
+ print('#include "u_format_bptc.h"')
+ print('#include "u_format_s3tc.h"')
+ print('#include "u_format_rgtc.h"')
+ print('#include "u_format_latc.h"')
+ print('#include "u_format_etc.h"')
+ print()
u_format_pack.generate(formats)
def do_channel_array(channels, swizzles):
- print " {"
+ print(" {")
for i in range(4):
channel = channels[i]
if i < 3:
@@ -103,13 +104,13 @@ def write_format_table(formats):
else:
sep = ""
if channel.size:
- print " {%s, %s, %s, %u, %u}%s\t/* %s = %s */" % (type_map[channel.type], bool_map(channel.norm), bool_map(channel.pure), channel.size, channel.shift, sep, "xyzw"[i], channel.name)
+ print(" {%s, %s, %s, %u, %u}%s\t/* %s = %s */" % (type_map[channel.type], bool_map(channel.norm), bool_map(channel.pure), channel.size, channel.shift, sep, "xyzw"[i], channel.name))
else:
- print " {0, 0, 0, 0, 0}%s" % (sep,)
- print " },"
+ print(" {0, 0, 0, 0, 0}%s" % (sep,))
+ print(" },")
def do_swizzle_array(channels, swizzles):
- print " {"
+ print(" {")
for i in range(4):
swizzle = swizzles[i]
if i < 3:
@@ -120,102 +121,102 @@ def write_format_table(formats):
comment = colorspace_channels_map[format.colorspace][i]
except (KeyError, IndexError):
comment = 'ignored'
- print " %s%s\t/* %s */" % (swizzle_map[swizzle], sep, comment)
- print " },"
+ print(" %s%s\t/* %s */" % (swizzle_map[swizzle], sep, comment))
+ print(" },")
for format in formats:
- print 'const struct util_format_description'
- print 'util_format_%s_description = {' % (format.short_name(),)
- print " %s," % (format.name,)
- print " \"%s\"," % (format.name,)
- print " \"%s\"," % (format.short_name(),)
- print " {%u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_size())
- print " %s," % (layout_map(format.layout),)
- print " %u,\t/* nr_channels */" % (format.nr_channels(),)
- print " %s,\t/* is_array */" % (bool_map(format.is_array()),)
- print " %s,\t/* is_bitmask */" % (bool_map(format.is_bitmask()),)
- print " %s,\t/* is_mixed */" % (bool_map(format.is_mixed()),)
+ print('const struct util_format_description')
+ print('util_format_%s_description = {' % (format.short_name(),))
+ print(" %s," % (format.name,))
+ print(" \"%s\"," % (format.name,))
+ print(" \"%s\"," % (format.short_name(),))
+ print(" {%u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_size()))
+ print(" %s," % (layout_map(format.layout),))
+ print(" %u,\t/* nr_channels */" % (format.nr_channels(),))
+ print(" %s,\t/* is_array */" % (bool_map(format.is_array()),))
+ print(" %s,\t/* is_bitmask */" % (bool_map(format.is_bitmask()),))
+ print(" %s,\t/* is_mixed */" % (bool_map(format.is_mixed()),))
u_format_pack.print_channels(format, do_channel_array)
u_format_pack.print_channels(format, do_swizzle_array)
- print " %s," % (colorspace_map(format.colorspace),)
+ print(" %s," % (colorspace_map(format.colorspace),))
access = True
if format.layout == 'astc':
access = False
if format.layout == 'etc' and format.short_name() != 'etc1_rgb8':
access = False
if format.colorspace != ZS and not format.is_pure_color() and access:
- print " &util_format_%s_unpack_rgba_8unorm," % format.short_name()
- print " &util_format_%s_pack_rgba_8unorm," % format.short_name()
+ print(" &util_format_%s_unpack_rgba_8unorm," % format.short_name())
+ print(" &util_format_%s_pack_rgba_8unorm," % format.short_name())
if format.layout == 's3tc' or format.layout == 'rgtc':
- print " &util_format_%s_fetch_rgba_8unorm," % format.short_name()
+ print(" &util_format_%s_fetch_rgba_8unorm," % format.short_name())
else:
- print " NULL, /* fetch_rgba_8unorm */"
- print " &util_format_%s_unpack_rgba_float," % format.short_name()
- print " &util_format_%s_pack_rgba_float," % format.short_name()
- print " &util_format_%s_fetch_rgba_float," % format.short_name()
+ print(" NULL, /* fetch_rgba_8unorm */")
+ print(" &util_format_%s_unpack_rgba_float," % format.short_name())
+ print(" &util_format_%s_pack_rgba_float," % format.short_name())
+ print(" &util_format_%s_fetch_rgba_float," % format.short_name())
else:
- print " NULL, /* unpack_rgba_8unorm */"
- print " NULL, /* pack_rgba_8unorm */"
- print " NULL, /* fetch_rgba_8unorm */"
- print " NULL, /* unpack_rgba_float */"
- print " NULL, /* pack_rgba_float */"
- print " NULL, /* fetch_rgba_float */"
+ print(" NULL, /* unpack_rgba_8unorm */")
+ print(" NULL, /* pack_rgba_8unorm */")
+ print(" NULL, /* fetch_rgba_8unorm */")
+ print(" NULL, /* unpack_rgba_float */")
+ print(" NULL, /* pack_rgba_float */")
+ print(" NULL, /* fetch_rgba_float */")
if format.has_depth():
- print " &util_format_%s_unpack_z_32unorm," % format.short_name()
- print " &util_format_%s_pack_z_32unorm," % format.short_name()
- print " &util_format_%s_unpack_z_float," % format.short_name()
- print " &util_format_%s_pack_z_float," % format.short_name()
+ print(" &util_format_%s_unpack_z_32unorm," % format.short_name())
+ print(" &util_format_%s_pack_z_32unorm," % format.short_name())
+ print(" &util_format_%s_unpack_z_float," % format.short_name())
+ print(" &util_format_%s_pack_z_float," % format.short_name())
else:
- print " NULL, /* unpack_z_32unorm */"
- print " NULL, /* pack_z_32unorm */"
- print " NULL, /* unpack_z_float */"
- print " NULL, /* pack_z_float */"
+ print(" NULL, /* unpack_z_32unorm */")
+ print(" NULL, /* pack_z_32unorm */")
+ print(" NULL, /* unpack_z_float */")
+ print(" NULL, /* pack_z_float */")
if format.has_stencil():
- print " &util_format_%s_unpack_s_8uint," % format.short_name()
- print " &util_format_%s_pack_s_8uint," % format.short_name()
+ print(" &util_format_%s_unpack_s_8uint," % format.short_name())
+ print(" &util_format_%s_pack_s_8uint," % format.short_name())
else:
- print " NULL, /* unpack_s_8uint */"
- print " NULL, /* pack_s_8uint */"
+ print(" NULL, /* unpack_s_8uint */")
+ print(" NULL, /* pack_s_8uint */")
if format.is_pure_unsigned():
- print " &util_format_%s_unpack_unsigned, /* unpack_rgba_uint */" % format.short_name()
- print " &util_format_%s_pack_unsigned, /* pack_rgba_uint */" % format.short_name()
- print " &util_format_%s_unpack_signed, /* unpack_rgba_sint */" % format.short_name()
- print " &util_format_%s_pack_signed, /* pack_rgba_sint */" % format.short_name()
- print " &util_format_%s_fetch_unsigned, /* fetch_rgba_uint */" % format.short_name()
- print " NULL /* fetch_rgba_sint */"
+ print(" &util_format_%s_unpack_unsigned, /* unpack_rgba_uint */" % format.short_name())
+ print(" &util_format_%s_pack_unsigned, /* pack_rgba_uint */" % format.short_name())
+ print(" &util_format_%s_unpack_signed, /* unpack_rgba_sint */" % format.short_name())
+ print(" &util_format_%s_pack_signed, /* pack_rgba_sint */" % format.short_name())
+ print(" &util_format_%s_fetch_unsigned, /* fetch_rgba_uint */" % format.short_name())
+ print(" NULL /* fetch_rgba_sint */")
elif format.is_pure_signed():
- print " &util_format_%s_unpack_unsigned, /* unpack_rgba_uint */" % format.short_name()
- print " &util_format_%s_pack_unsigned, /* pack_rgba_uint */" % format.short_name()
- print " &util_format_%s_unpack_signed, /* unpack_rgba_sint */" % format.short_name()
- print " &util_format_%s_pack_signed, /* pack_rgba_sint */" % format.short_name()
- print " NULL, /* fetch_rgba_uint */"
- print " &util_format_%s_fetch_signed /* fetch_rgba_sint */" % format.short_name()
+ print(" &util_format_%s_unpack_unsigned, /* unpack_rgba_uint */" % format.short_name())
+ print(" &util_format_%s_pack_unsigned, /* pack_rgba_uint */" % format.short_name())
+ print(" &util_format_%s_unpack_signed, /* unpack_rgba_sint */" % format.short_name())
+ print(" &util_format_%s_pack_signed, /* pack_rgba_sint */" % format.short_name())
+ print(" NULL, /* fetch_rgba_uint */")
+ print(" &util_format_%s_fetch_signed /* fetch_rgba_sint */" % format.short_name())
else:
- print " NULL, /* unpack_rgba_uint */"
- print " NULL, /* pack_rgba_uint */"
- print " NULL, /* unpack_rgba_sint */"
- print " NULL, /* pack_rgba_sint */"
- print " NULL, /* fetch_rgba_uint */"
- print " NULL /* fetch_rgba_sint */"
- print "};"
- print
+ print(" NULL, /* unpack_rgba_uint */")
+ print(" NULL, /* pack_rgba_uint */")
+ print(" NULL, /* unpack_rgba_sint */")
+ print(" NULL, /* pack_rgba_sint */")
+ print(" NULL, /* fetch_rgba_uint */")
+ print(" NULL /* fetch_rgba_sint */")
+ print("};")
+ print()
- print "const struct util_format_description *"
- print "util_format_description(enum pipe_format format)"
- print "{"
- print " if (format >= PIPE_FORMAT_COUNT) {"
- print " return NULL;"
- print " }"
- print
- print " switch (format) {"
+ print("const struct util_format_description *")
+ print("util_format_description(enum pipe_format format)")
+ print("{")
+ print(" if (format >= PIPE_FORMAT_COUNT) {")
+ print(" return NULL;")
+ print(" }")
+ print()
+ print(" switch (format) {")
for format in formats:
- print " case %s:" % format.name
- print " return &util_format_%s_description;" % (format.short_name(),)
- print " default:"
- print " return NULL;"
- print " }"
- print "}"
- print
+ print(" case %s:" % format.name)
+ print(" return &util_format_%s_description;" % (format.short_name(),))
+ print(" default:")
+ print(" return NULL;")
+ print(" }")
+ print("}")
+ print()
def main():
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_nir_trig.py b/src/gallium/drivers/freedreno/ir3/ir3_nir_trig.py
index a0ab9d01903..3968aea543c 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_nir_trig.py
+++ b/src/gallium/drivers/freedreno/ir3/ir3_nir_trig.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 argparse
import sys
@@ -40,9 +42,9 @@ def main():
def run():
import nir_algebraic # pylint: disable=import-error
- print '#include "ir3_nir.h"'
- print nir_algebraic.AlgebraicPass("ir3_nir_apply_trig_workarounds",
- trig_workarounds).render()
+ print('#include "ir3_nir.h"')
+ print(nir_algebraic.AlgebraicPass("ir3_nir_apply_trig_workarounds",
+ trig_workarounds).render())
if __name__ == '__main__':
diff --git a/src/gallium/drivers/r600/egd_tables.py b/src/gallium/drivers/r600/egd_tables.py
index d7b78c7fb16..7489649ec72 100644
--- a/src/gallium/drivers/r600/egd_tables.py
+++ b/src/gallium/drivers/r600/egd_tables.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
CopyRight = '''
/*
@@ -217,10 +218,10 @@ def write_tables(regs, packets):
strings = StringTable()
strings_offsets = IntTable("int")
- print '/* This file is autogenerated by egd_tables.py from evergreend.h. Do not edit directly. */'
- print
- print CopyRight.strip()
- print '''
+ print('/* This file is autogenerated by egd_tables.py from evergreend.h. Do not edit directly. */')
+ print()
+ print(CopyRight.strip())
+ print('''
#ifndef EG_TABLES_H
#define EG_TABLES_H
@@ -242,20 +243,20 @@ struct eg_packet3 {
unsigned name_offset;
unsigned op;
};
-'''
+''')
- print 'static const struct eg_packet3 packet3_table[] = {'
+ print('static const struct eg_packet3 packet3_table[] = {')
for pkt in packets:
- print '\t{%s, %s},' % (strings.add(pkt[5:]), pkt)
- print '};'
- print
+ print('\t{%s, %s},' % (strings.add(pkt[5:]), pkt))
+ print('};')
+ print()
- print 'static const struct eg_field egd_fields_table[] = {'
+ print('static const struct eg_field egd_fields_table[] = {')
fields_idx = 0
for reg in regs:
if len(reg.fields) and reg.own_fields:
- print '\t/* %s */' % (fields_idx)
+ print('\t/* %s */' % (fields_idx))
reg.fields_idx = fields_idx
@@ -266,34 +267,34 @@ struct eg_packet3 {
while value[1] >= len(values_offsets):
values_offsets.append(-1)
values_offsets[value[1]] = strings.add(strip_prefix(value[0]))
- print '\t{%s, %s(~0u), %s, %s},' % (
+ print('\t{%s, %s(~0u), %s, %s},' % (
strings.add(field.name), field.s_name,
- len(values_offsets), strings_offsets.add(values_offsets))
+ len(values_offsets), strings_offsets.add(values_offsets)))
else:
- print '\t{%s, %s(~0u)},' % (strings.add(field.name), field.s_name)
+ print('\t{%s, %s(~0u)},' % (strings.add(field.name), field.s_name))
fields_idx += 1
- print '};'
- print
+ print('};')
+ print()
- print 'static const struct eg_reg egd_reg_table[] = {'
+ print('static const struct eg_reg egd_reg_table[] = {')
for reg in regs:
if len(reg.fields):
- print '\t{%s, %s, %s, %s},' % (strings.add(reg.name), reg.r_name,
- len(reg.fields), reg.fields_idx if reg.own_fields else reg.fields_owner.fields_idx)
+ print('\t{%s, %s, %s, %s},' % (strings.add(reg.name), reg.r_name,
+ len(reg.fields), reg.fields_idx if reg.own_fields else reg.fields_owner.fields_idx))
else:
- print '\t{%s, %s},' % (strings.add(reg.name), reg.r_name)
- print '};'
- print
+ print('\t{%s, %s},' % (strings.add(reg.name), reg.r_name))
+ print('};')
+ print()
strings.emit(sys.stdout, "egd_strings")
- print
+ print()
strings_offsets.emit(sys.stdout, "egd_strings_offsets")
- print
- print '#endif'
+ print()
+ print('#endif')
def main():
diff --git a/src/intel/compiler/brw_nir_trig_workarounds.py b/src/intel/compiler/brw_nir_trig_workarounds.py
index 3d08b9a41ea..d60e094c625 100644
--- a/src/intel/compiler/brw_nir_trig_workarounds.py
+++ b/src/intel/compiler/brw_nir_trig_workarounds.py
@@ -31,6 +31,8 @@
# amplitude slightly. Apparently this also minimizes the error function,
# reducing the maximum error from 0.00006 to about 0.00003.
+from __future__ import print_function
+
import argparse
import sys
@@ -51,9 +53,9 @@ def main():
def run():
import nir_algebraic # pylint: disable=import-error
- print '#include "brw_nir.h"'
- print nir_algebraic.AlgebraicPass("brw_nir_apply_trig_workarounds",
- TRIG_WORKAROUNDS).render()
+ print('#include "brw_nir.h"')
+ print(nir_algebraic.AlgebraicPass("brw_nir_apply_trig_workarounds",
+ TRIG_WORKAROUNDS).render())
if __name__ == '__main__':
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 <idr@us.ibm.com>
+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 <idr@us.ibm.com>
# Jeremy Kolb <jkolb@brandeis.edu>
+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 <kevin@precisioninsight.com>
* \\author Ian Romanick <idr@us.ibm.com>
*/
-"""
+""")
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 <idr@us.ibm.com>
+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 <idr@us.ibm.com>
*/
-"""
- 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 <idr@us.ibm.com>
+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 <idr@us.ibm.com>
+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 <idr@us.ibm.com>
+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 <zack@kde.org>
+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 <idr@us.ibm.com>
+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 <idr@us.ibm.com>
+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 <idr@us.ibm.com>
+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 <idr@us.ibm.com>
+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 <idr@us.ibm.com>
+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 <idr@us.ibm.com>
+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()))
diff --git a/src/mapi/mapi_abi.py b/src/mapi/mapi_abi.py
index 82a2511ec39..0a49c06ff2c 100644
--- a/src/mapi/mapi_abi.py
+++ b/src/mapi/mapi_abi.py
@@ -24,6 +24,8 @@
# Authors:
# Chia-I Wu <olv@lunarg.com>
+from __future__ import print_function
+
import sys
# make it possible to import glapi
import os
@@ -541,79 +543,79 @@ class ABIPrinter(object):
return "\n".join(asm)
def output_for_lib(self):
- print self.c_notice()
+ print(self.c_notice())
if self.c_header:
- print
- print self.c_header
+ print()
+ print(self.c_header)
- print
- print '#ifdef MAPI_TMP_DEFINES'
- print self.c_public_includes()
- print
- print self.c_public_declarations(self.prefix_lib)
- print '#undef MAPI_TMP_DEFINES'
- print '#endif /* MAPI_TMP_DEFINES */'
+ print()
+ print('#ifdef MAPI_TMP_DEFINES')
+ print(self.c_public_includes())
+ print()
+ print(self.c_public_declarations(self.prefix_lib))
+ print('#undef MAPI_TMP_DEFINES')
+ print('#endif /* MAPI_TMP_DEFINES */')
if self.lib_need_table_size:
- print
- print '#ifdef MAPI_TMP_TABLE'
- print self.c_mapi_table()
- print '#undef MAPI_TMP_TABLE'
- print '#endif /* MAPI_TMP_TABLE */'
+ print()
+ print('#ifdef MAPI_TMP_TABLE')
+ print(self.c_mapi_table())
+ print('#undef MAPI_TMP_TABLE')
+ print('#endif /* MAPI_TMP_TABLE */')
if self.lib_need_noop_array:
- print
- print '#ifdef MAPI_TMP_NOOP_ARRAY'
- print '#ifdef DEBUG'
- print
- print self.c_noop_functions(self.prefix_noop, self.prefix_warn)
- print
- print 'const mapi_func table_%s_array[] = {' % (self.prefix_noop)
- print self.c_noop_initializer(self.prefix_noop, False)
- print '};'
- print
- print '#else /* DEBUG */'
- print
- print 'const mapi_func table_%s_array[] = {' % (self.prefix_noop)
- print self.c_noop_initializer(self.prefix_noop, True)
- print '};'
- print
- print '#endif /* DEBUG */'
- print '#undef MAPI_TMP_NOOP_ARRAY'
- print '#endif /* MAPI_TMP_NOOP_ARRAY */'
+ print()
+ print('#ifdef MAPI_TMP_NOOP_ARRAY')
+ print('#ifdef DEBUG')
+ print()
+ print(self.c_noop_functions(self.prefix_noop, self.prefix_warn))
+ print()
+ print('const mapi_func table_%s_array[] = {' % (self.prefix_noop))
+ print(self.c_noop_initializer(self.prefix_noop, False))
+ print('};')
+ print()
+ print('#else /* DEBUG */')
+ print()
+ print('const mapi_func table_%s_array[] = {' % (self.prefix_noop))
+ print(self.c_noop_initializer(self.prefix_noop, True))
+ print('};')
+ print()
+ print('#endif /* DEBUG */')
+ print('#undef MAPI_TMP_NOOP_ARRAY')
+ print('#endif /* MAPI_TMP_NOOP_ARRAY */')
if self.lib_need_stubs:
pool, pool_offsets = self.c_stub_string_pool()
- print
- print '#ifdef MAPI_TMP_PUBLIC_STUBS'
- print 'static const char public_string_pool[] ='
- print pool
- print
- print 'static const struct mapi_stub public_stubs[] = {'
- print self.c_stub_initializer(self.prefix_lib, pool_offsets)
- print '};'
- print '#undef MAPI_TMP_PUBLIC_STUBS'
- print '#endif /* MAPI_TMP_PUBLIC_STUBS */'
+ print()
+ print('#ifdef MAPI_TMP_PUBLIC_STUBS')
+ print('static const char public_string_pool[] =')
+ print(pool)
+ print()
+ print('static const struct mapi_stub public_stubs[] = {')
+ print(self.c_stub_initializer(self.prefix_lib, pool_offsets))
+ print('};')
+ print('#undef MAPI_TMP_PUBLIC_STUBS')
+ print('#endif /* MAPI_TMP_PUBLIC_STUBS */')
if self.lib_need_all_entries:
- print
- print '#ifdef MAPI_TMP_PUBLIC_ENTRIES'
- print self.c_public_dispatches(self.prefix_lib, False)
- print
- print 'static const mapi_func public_entries[] = {'
- print self.c_public_initializer(self.prefix_lib)
- print '};'
- print '#undef MAPI_TMP_PUBLIC_ENTRIES'
- print '#endif /* MAPI_TMP_PUBLIC_ENTRIES */'
-
- print
- print '#ifdef MAPI_TMP_STUB_ASM_GCC'
- print '__asm__('
- print self.c_asm_gcc(self.prefix_lib, False)
- print ');'
- print '#undef MAPI_TMP_STUB_ASM_GCC'
- print '#endif /* MAPI_TMP_STUB_ASM_GCC */'
+ print()
+ print('#ifdef MAPI_TMP_PUBLIC_ENTRIES')
+ print(self.c_public_dispatches(self.prefix_lib, False))
+ print()
+ print('static const mapi_func public_entries[] = {')
+ print(self.c_public_initializer(self.prefix_lib))
+ print('};')
+ print('#undef MAPI_TMP_PUBLIC_ENTRIES')
+ print('#endif /* MAPI_TMP_PUBLIC_ENTRIES */')
+
+ print()
+ print('#ifdef MAPI_TMP_STUB_ASM_GCC')
+ print('__asm__(')
+ print(self.c_asm_gcc(self.prefix_lib, False))
+ print(');')
+ print('#undef MAPI_TMP_STUB_ASM_GCC')
+ print('#endif /* MAPI_TMP_STUB_ASM_GCC */')
if self.lib_need_non_hidden_entries:
all_hidden = True
@@ -622,21 +624,21 @@ class ABIPrinter(object):
all_hidden = False
break
if not all_hidden:
- print
- print '#ifdef MAPI_TMP_PUBLIC_ENTRIES_NO_HIDDEN'
- print self.c_public_dispatches(self.prefix_lib, True)
- print
- print '/* does not need public_entries */'
- print '#undef MAPI_TMP_PUBLIC_ENTRIES_NO_HIDDEN'
- print '#endif /* MAPI_TMP_PUBLIC_ENTRIES_NO_HIDDEN */'
-
- print
- print '#ifdef MAPI_TMP_STUB_ASM_GCC_NO_HIDDEN'
- print '__asm__('
- print self.c_asm_gcc(self.prefix_lib, True)
- print ');'
- print '#undef MAPI_TMP_STUB_ASM_GCC_NO_HIDDEN'
- print '#endif /* MAPI_TMP_STUB_ASM_GCC_NO_HIDDEN */'
+ print()
+ print('#ifdef MAPI_TMP_PUBLIC_ENTRIES_NO_HIDDEN')
+ print(self.c_public_dispatches(self.prefix_lib, True))
+ print()
+ print('/* does not need public_entries */')
+ print('#undef MAPI_TMP_PUBLIC_ENTRIES_NO_HIDDEN')
+ print('#endif /* MAPI_TMP_PUBLIC_ENTRIES_NO_HIDDEN */')
+
+ print()
+ print('#ifdef MAPI_TMP_STUB_ASM_GCC_NO_HIDDEN')
+ print('__asm__(')
+ print(self.c_asm_gcc(self.prefix_lib, True))
+ print(');')
+ print('#undef MAPI_TMP_STUB_ASM_GCC_NO_HIDDEN')
+ print('#endif /* MAPI_TMP_STUB_ASM_GCC_NO_HIDDEN */')
class GLAPIPrinter(ABIPrinter):
"""OpenGL API Printer"""
diff --git a/src/mesa/main/format_info.py b/src/mesa/main/format_info.py
index b0308efc12e..bbecaa24510 100644
--- a/src/mesa/main/format_info.py
+++ b/src/mesa/main/format_info.py
@@ -21,6 +21,8 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+from __future__ import print_function
+
import format_parser as parser
import sys
@@ -135,7 +137,7 @@ def get_channel_bits(fmat, chan_name):
formats = parser.parse(sys.argv[1])
-print '''
+print('''
/*
* Mesa 3-D graphics library
*
@@ -167,35 +169,35 @@ print '''
static const struct gl_format_info format_info[MESA_FORMAT_COUNT] =
{
-'''
+''')
def format_channel_bits(fmat, tuple_list):
return ['.%s = %s' % (field, str(get_channel_bits(fmat, name))) for (field, name) in tuple_list]
for fmat in formats:
- print ' {'
- print ' .Name = {0},'.format(fmat.name)
- print ' .StrName = "{0}",'.format(fmat.name)
- print ' .Layout = {0},'.format('MESA_FORMAT_LAYOUT_' + fmat.layout.upper())
- print ' .BaseFormat = {0},'.format(get_gl_base_format(fmat))
- print ' .DataType = {0},'.format(get_gl_data_type(fmat))
+ print(' {')
+ print(' .Name = {0},'.format(fmat.name))
+ print(' .StrName = "{0}",'.format(fmat.name))
+ print(' .Layout = {0},'.format('MESA_FORMAT_LAYOUT_' + fmat.layout.upper()))
+ print(' .BaseFormat = {0},'.format(get_gl_base_format(fmat)))
+ print(' .DataType = {0},'.format(get_gl_data_type(fmat)))
bits = [('RedBits', 'r'), ('GreenBits', 'g'), ('BlueBits', 'b'), ('AlphaBits', 'a')]
- print ' {0},'.format(', '.join(format_channel_bits(fmat, bits)))
+ print(' {0},'.format(', '.join(format_channel_bits(fmat, bits))))
bits = [('LuminanceBits', 'l'), ('IntensityBits', 'i'), ('DepthBits', 'z'), ('StencilBits', 's')]
- print ' {0},'.format(', '.join(format_channel_bits(fmat, bits)))
+ print(' {0},'.format(', '.join(format_channel_bits(fmat, bits))))
- print ' .IsSRGBFormat = {0:d},'.format(fmat.colorspace == 'srgb')
+ print(' .IsSRGBFormat = {0:d},'.format(fmat.colorspace == 'srgb'))
- print ' .BlockWidth = {0}, .BlockHeight = {1}, .BlockDepth = {2},'.format(fmat.block_width, fmat.block_height, fmat.block_depth)
- print ' .BytesPerBlock = {0},'.format(int(fmat.block_size() / 8))
+ print(' .BlockWidth = {0}, .BlockHeight = {1}, .BlockDepth = {2},'.format(fmat.block_width, fmat.block_height, fmat.block_depth))
+ print(' .BytesPerBlock = {0},'.format(int(fmat.block_size() / 8)))
- print ' .Swizzle = {{ {0} }},'.format(', '.join(map(str, fmat.swizzle)))
+ print(' .Swizzle = {{ {0} }},'.format(', '.join(map(str, fmat.swizzle))))
if fmat.is_array():
chan = fmat.array_element()
norm = chan.norm or chan.type == parser.FLOAT
- print ' .ArrayFormat = MESA_ARRAY_FORMAT({0}),'.format(', '.join([
+ print(' .ArrayFormat = MESA_ARRAY_FORMAT({0}),'.format(', '.join([
str(chan.size / 8),
str(int(chan.sign)),
str(int(chan.type == parser.FLOAT)),
@@ -205,9 +207,9 @@ for fmat in formats:
str(fmat.swizzle[1]),
str(fmat.swizzle[2]),
str(fmat.swizzle[3]),
- ]))
+ ])))
else:
- print ' .ArrayFormat = 0,'
- print ' },'
+ print(' .ArrayFormat = 0,')
+ print(' },')
-print '};'
+print('};')
diff --git a/src/mesa/main/format_pack.py b/src/mesa/main/format_pack.py
index 77ab16694ed..d3c8d24acd6 100644
--- a/src/mesa/main/format_pack.py
+++ b/src/mesa/main/format_pack.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
from mako.template import Template
from sys import argv
@@ -1001,4 +1002,4 @@ _mesa_pack_colormask(mesa_format format, const GLubyte colorMask[4], void *dst)
template = Template(string);
-print template.render(argv = argv[0:])
+print(template.render(argv = argv[0:]))
diff --git a/src/mesa/main/format_unpack.py b/src/mesa/main/format_unpack.py
index 87f64cc151a..286c08e6219 100644
--- a/src/mesa/main/format_unpack.py
+++ b/src/mesa/main/format_unpack.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
from mako.template import Template
from sys import argv
@@ -891,4 +892,4 @@ _mesa_unpack_depth_stencil_row(mesa_format format, GLuint n,
template = Template(string);
-print template.render(argv = argv[0:])
+print(template.render(argv = argv[0:]))
diff --git a/src/mesa/main/get_hash_generator.py b/src/mesa/main/get_hash_generator.py
index ddd498fee47..86c6771066a 100644
--- a/src/mesa/main/get_hash_generator.py
+++ b/src/mesa/main/get_hash_generator.py
@@ -28,6 +28,8 @@
# Generate a C header file containing hash tables of glGet parameter
# names for each GL API. The generated file is to be included by glGet.c
+from __future__ import print_function
+
import os, sys, imp, getopt
from collections import defaultdict
import get_hash_params
@@ -46,16 +48,16 @@ hash_table_size = 1024
gl_apis=set(["GL", "GL_CORE", "GLES", "GLES2", "GLES3", "GLES31", "GLES32"])
def print_header():
- print "typedef const unsigned short table_t[%d];\n" % (hash_table_size)
- print "static const int prime_factor = %d, prime_step = %d;\n" % \
- (prime_factor, prime_step)
+ print("typedef const unsigned short table_t[%d];\n" % (hash_table_size))
+ print("static const int prime_factor = %d, prime_step = %d;\n" % \
+ (prime_factor, prime_step))
def print_params(params):
- print "static const struct value_desc values[] = {"
+ print("static const struct value_desc values[] = {")
for p in params:
- print " { %s, %s }," % (p[0], p[1])
+ print(" { %s, %s }," % (p[0], p[1]))
- print "};\n"
+ print("};\n")
def api_name(api):
return "API_OPEN%s" % api
@@ -78,7 +80,7 @@ def table_name(api):
return "table_" + api_name(api)
def print_table(api, table):
- print "static table_t %s = {" % (table_name(api))
+ print("static table_t %s = {" % (table_name(api)))
# convert sparse (index, value) table into a dense table
dense_table = [0] * hash_table_size
@@ -89,9 +91,9 @@ def print_table(api, table):
for i in range(0, hash_table_size, row_size):
row = dense_table[i : i + row_size]
idx_val = ["%4d" % v for v in row]
- print " " * 4 + ", ".join(idx_val) + ","
+ print(" " * 4 + ", ".join(idx_val) + ",")
- print "};\n"
+ print("};\n")
def print_tables(tables):
for table in tables:
@@ -104,12 +106,12 @@ def print_tables(tables):
i = api_index(api)
dense_tables[i] = "&%s" % (tname)
- print "static table_t *table_set[] = {"
+ print("static table_t *table_set[] = {")
for expr in dense_tables:
- print " %s," % expr
- print "};\n"
+ print(" %s," % expr)
+ print("};\n")
- print "#define table(api) (*table_set[api])"
+ print("#define table(api) (*table_set[api])")
# Merge tables with matching parameter lists (i.e. GL and GL_CORE)
def merge_tables(tables):
diff --git a/src/util/format_srgb.py b/src/util/format_srgb.py
index 44b35a061d6..0b3b5611fc9 100644
--- a/src/util/format_srgb.py
+++ b/src/util/format_srgb.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
CopyRight = '''
/**************************************************************************
@@ -57,33 +58,27 @@ def linear_to_srgb(x):
def generate_srgb_tables():
- print 'const float'
- print 'util_format_srgb_8unorm_to_linear_float_table[256] = {'
+ print('const float')
+ print('util_format_srgb_8unorm_to_linear_float_table[256] = {')
for j in range(0, 256, 4):
- print ' ',
- for i in range(j, j + 4):
- print '%.7e,' % (srgb_to_linear(i / 255.0),),
- print
- print '};'
- print
- print 'const uint8_t'
- print 'util_format_srgb_to_linear_8unorm_table[256] = {'
+ print(' ', end=' ')
+ print(' '.join(['%.7e,' % srgb_to_linear(i / 255.0) for i in range(j, j + 4)]))
+ print('};')
+ print()
+ print('const uint8_t')
+ print('util_format_srgb_to_linear_8unorm_table[256] = {')
for j in range(0, 256, 16):
- print ' ',
- for i in range(j, j + 16):
- print '%3u,' % (int(srgb_to_linear(i / 255.0) * 255.0 + 0.5),),
- print
- print '};'
- print
- print 'const uint8_t'
- print 'util_format_linear_to_srgb_8unorm_table[256] = {'
+ print(' ', end=' ')
+ print(' '.join(['%3u,' % int(srgb_to_linear(i / 255.0) * 255.0 + 0.5) for i in range(j, j + 16)]))
+ print('};')
+ print()
+ print('const uint8_t')
+ print('util_format_linear_to_srgb_8unorm_table[256] = {')
for j in range(0, 256, 16):
- print ' ',
- for i in range(j, j + 16):
- print '%3u,' % (int(linear_to_srgb(i / 255.0) * 255.0 + 0.5),),
- print
- print '};'
- print
+ print(' ', end=' ')
+ print(' '.join(['%3u,' % int(linear_to_srgb(i / 255.0) * 255.0 + 0.5) for i in range(j, j + 16)]))
+ print('};')
+ print()
# calculate the table interpolation values used in float linear to unorm8 srgb
numexp = 13
@@ -128,25 +123,23 @@ def generate_srgb_tables():
valtable.append((int_a << 16) + int_b)
- print 'const unsigned'
- print 'util_format_linear_to_srgb_helper_table[104] = {'
+ print('const unsigned')
+ print('util_format_linear_to_srgb_helper_table[104] = {')
for j in range(0, nbuckets, 4):
- print ' ',
- for i in range(j, j + 4):
- print '0x%08x,' % (valtable[i],),
- print
- print '};'
- print
+ print(' ', end=' ')
+ print(' '.join(['0x%08x,' % valtable[i] for i in range(j, j + 4)]))
+ print('};')
+ print()
def main():
- print '/* This file is autogenerated by u_format_srgb.py. Do not edit directly. */'
- print
+ print('/* This file is autogenerated by u_format_srgb.py. Do not edit directly. */')
+ print()
# This will print the copyright message on the top of this file
- print CopyRight.strip()
- print
- print '#include "format_srgb.h"'
- print
+ print(CopyRight.strip())
+ print()
+ print('#include "format_srgb.h"')
+ print()
generate_srgb_tables()
diff --git a/src/util/xmlpool/gen_xmlpool.py b/src/util/xmlpool/gen_xmlpool.py
index eb68a65174b..8336e0f9523 100644
--- a/src/util/xmlpool/gen_xmlpool.py
+++ b/src/util/xmlpool/gen_xmlpool.py
@@ -7,6 +7,8 @@
# `{localedir}/{language}/LC_MESSAGES/options.mo`.
#
+from __future__ import print_function
+
import sys
import gettext
import re
@@ -130,16 +132,16 @@ def expandMatches (matches, translations, end=None):
# non-ascii unicode chars in the original English descriptions.
text = escapeCString (trans.ugettext (unicode (expandCString (
matches[0].expand (r'\5')), "utf-8"))).encode("utf-8")
- print matches[0].expand (r'\1' + lang + r'\3"' + text + r'"\7') + suffix
+ print(matches[0].expand (r'\1' + lang + r'\3"' + text + r'"\7') + suffix)
# Expand any subsequent enum lines
for match in matches[1:]:
text = escapeCString (trans.ugettext (unicode (expandCString (
match.expand (r'\3')), "utf-8"))).encode("utf-8")
- print match.expand (r'\1"' + text + r'"\5')
+ print(match.expand (r'\1"' + text + r'"\5'))
# Expand description end
if end:
- print end,
+ print(end, end='')
# Compile a list of translation classes to all supported languages.
# The first translation is always a NullTranslations.
@@ -160,10 +162,9 @@ reENUM = re.compile (r'(\s*DRI_CONF_ENUM\s*\([^,]+,\s*)(gettext\s*\(\s*")(
reDESC_END = re.compile (r'\s*DRI_CONF_DESC_END')
# Print a header
-print \
-"/***********************************************************************\n" \
+print("/***********************************************************************\n" \
" *** THIS FILE IS GENERATED AUTOMATICALLY. DON'T EDIT! ***\n" \
-" ***********************************************************************/"
+" ***********************************************************************/")
# Process the options template and generate options.h with all
# translations.
@@ -185,7 +186,7 @@ for line in template:
continue
if reLibintl_h.search (line):
# Ignore (comment out) #include <libintl.h>
- print "/* %s * commented out by gen_xmlpool.py */" % line
+ print("/* %s * commented out by gen_xmlpool.py */" % line)
continue
matchDESC = reDESC .match (line)
matchDESC_BEGIN = reDESC_BEGIN.match (line)
@@ -196,7 +197,7 @@ for line in template:
assert len(descMatches) == 0
descMatches = [matchDESC_BEGIN]
else:
- print line,
+ print(line, end='')
if len(descMatches) > 0:
sys.stderr.write ("Warning: unterminated description at end of file.\n")