summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorMathieu Bridon <[email protected]>2018-07-05 15:17:32 +0200
committerDylan Baker <[email protected]>2018-07-06 10:04:22 -0700
commit0f7b18fa0d353aab0a44082b1aca8d8c00df71a7 (patch)
treee511fe8f70b48ad5203e3a0e52d0dc1b086bfd91 /src/mesa
parentb3a42fa0667caeeebabd9e6aeb46a9534810c2f3 (diff)
python: Use the print function
In Python 2, `print` was a statement, but it became a function in Python 3. Using print functions everywhere makes the script compatible with Python versions >= 2.6, including Python 3. Signed-off-by: Mathieu Bridon <[email protected]> Acked-by: Eric Engestrom <[email protected]> Acked-by: Dylan Baker <[email protected]>
Diffstat (limited to 'src/mesa')
-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
4 files changed, 40 insertions, 34 deletions
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):