summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <baker.dylan.c@gmail.com>2016-03-30 16:34:36 -0700
committerDylan Baker <baker.dylan.c@gmail.com>2016-03-31 15:52:22 -0700
commit028f88f35b48586057195b8def3c3b2f410c0044 (patch)
tree51c1ae995483c4376ea14ab9a9d201497789068f
parent010fa5efcb8b9b9b9a50e6ac7eabf015fd3739d2 (diff)
glapi: Use booleans in python code.
All versions of python that are even worth considering for support (2.6+) have booleans (actually, so do a lot of versions not worth supporting), so don't use 1 and 0 for emulating them, which also helps to clarify the code, since returning an actual value of 1 or 0 happens). Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
-rw-r--r--src/mapi/glapi/gen/glX_XML.py8
-rw-r--r--src/mapi/glapi/gen/glX_proto_recv.py6
-rw-r--r--src/mapi/glapi/gen/glX_proto_send.py4
-rw-r--r--src/mapi/glapi/gen/glX_proto_size.py4
-rw-r--r--src/mapi/glapi/gen/glX_server_table.py4
-rw-r--r--src/mapi/glapi/gen/gl_XML.py25
-rw-r--r--src/mapi/glapi/gen/gl_x86-64_asm.py2
7 files changed, 23 insertions, 30 deletions
diff --git a/src/mapi/glapi/gen/glX_XML.py b/src/mapi/glapi/gen/glX_XML.py
index acc4f21475..9586323ad9 100644
--- a/src/mapi/glapi/gen/glX_XML.py
+++ b/src/mapi/glapi/gen/glX_XML.py
@@ -195,17 +195,17 @@ class glx_function(gl_XML.gl_function):
"""
if self.glx_rop == 0:
- return 0
+ return False
if self.server_handcode or self.images:
- return 1
+ return True
for param in self.parameters:
if not param.is_output:
if param.counter or len(param.count_parameter_list):
- return 1
+ return True
- return 0
+ return False
def variable_length_parameter(self):
for param in self.parameters:
diff --git a/src/mapi/glapi/gen/glX_proto_recv.py b/src/mapi/glapi/gen/glX_proto_recv.py
index d0a6371bde..33776f7853 100644
--- a/src/mapi/glapi/gen/glX_proto_recv.py
+++ b/src/mapi/glapi/gen/glX_proto_recv.py
@@ -290,7 +290,7 @@ class PrintGlxDispatchFunctions(glX_proto_common.glx_print_proto):
print '#endif'
print ''
- need_blank = 0
+ need_blank = False
if self.do_swap:
for param in f.parameterIterateGlxSend():
if param.count_parameter_list:
@@ -330,13 +330,13 @@ class PrintGlxDispatchFunctions(glX_proto_common.glx_print_proto):
compsize = self.size_call(f, 1)
print ' %s = (%s) %s( (%s *) (pc + %s), %s );' % (param.name, param.type_string(), swap_func, self.real_types[type_size], o, compsize)
- need_blank = 1
+ need_blank = True
else:
for param in f.parameterIterateGlxSend():
if param.count_parameter_list:
print '%s %s = (%s) (pc + %s);' % (indent, param.name, param.type_string(), param.offset)
- need_blank = 1
+ need_blank = True
if need_blank:
print ''
diff --git a/src/mapi/glapi/gen/glX_proto_send.py b/src/mapi/glapi/gen/glX_proto_send.py
index 731f259459..3de11d4838 100644
--- a/src/mapi/glapi/gen/glX_proto_send.py
+++ b/src/mapi/glapi/gen/glX_proto_send.py
@@ -616,9 +616,9 @@ class PrintGlxProtoStubs(glX_proto_common.glx_print_proto):
skip_condition = "%s" % (condition_list.pop(0))
print ' if (__builtin_expect(%s, 1)) {' % (skip_condition)
- return 1
+ return True
else:
- return 0
+ return False
def printSingleFunction(self, f, name):
self.common_func_print_just_start(f, name)
diff --git a/src/mapi/glapi/gen/glX_proto_size.py b/src/mapi/glapi/gen/glX_proto_size.py
index 46ac61ef87..e1e1a742a5 100644
--- a/src/mapi/glapi/gen/glX_proto_size.py
+++ b/src/mapi/glapi/gen/glX_proto_size.py
@@ -175,9 +175,9 @@ class glx_enum_function(object):
print ' const unsigned idx = (e & 0x%02xU);' % (mask)
print ''
print ' return (e == a[idx]) ? (GLint) b[idx] : 0;'
- return 1
+ return True
else:
- return 0
+ return False
def PrintUsingSwitch(self, name):
"""Emit the body of the __gl*_size function using a switch-statement."""
diff --git a/src/mapi/glapi/gen/glX_server_table.py b/src/mapi/glapi/gen/glX_server_table.py
index e67ff702ee..4549fbd219 100644
--- a/src/mapi/glapi/gen/glX_server_table.py
+++ b/src/mapi/glapi/gen/glX_server_table.py
@@ -153,10 +153,10 @@ class function_table:
def is_empty_leaf(self, base_opcode, M):
for op in xrange(base_opcode, base_opcode + (1 << M)):
if op in self.functions:
- return 0
+ return False
break
- return 1
+ return True
def dump_tree(self, node, base_opcode, remaining_bits, base_entry, depth):
M = node[0]
diff --git a/src/mapi/glapi/gen/gl_XML.py b/src/mapi/glapi/gen/gl_XML.py
index f1606a6cfa..7e08c3bfd8 100644
--- a/src/mapi/glapi/gen/gl_XML.py
+++ b/src/mapi/glapi/gen/gl_XML.py
@@ -455,7 +455,7 @@ class gl_parameter(object):
self.is_padding = is_attr_true(element, 'padding')
def compatible(self, other):
- return 1
+ return True
def is_array(self):
return self.is_pointer()
@@ -464,10 +464,7 @@ class gl_parameter(object):
return self.type_expr.is_pointer()
def is_image(self):
- if self.width:
- return 1
- else:
- return 0
+ return bool(self.width)
def is_variable_length(self):
return len(self.count_parameter_list) or self.counter
@@ -475,13 +472,9 @@ class gl_parameter(object):
def is_64_bit(self):
count = self.type_expr.get_element_count()
if count:
- if (self.size() / count) == 8:
- return 1
+ return (self.size() / count) == 8
else:
- if self.size() == 8:
- return 1
-
- return 0
+ return self.size() == 8
def string(self):
return self.type_expr.original_string + " " + self.name
@@ -532,7 +525,7 @@ class gl_parameter(object):
return c
- def size_string(self, use_parens=1):
+ def size_string(self, use_parens=True):
s = self.size()
if self.counter or self.count_parameter_list:
list = ["compsize"]
@@ -571,7 +564,7 @@ class gl_function(gl_item):
self.return_type = "void"
self.parameters = []
self.offset = -1
- self.initialized = 0
+ self.initialized = False
self.images = []
self.exec_flavor = 'mesa'
self.desktop = True
@@ -663,9 +656,9 @@ class gl_function(gl_item):
raise RuntimeError("Function true name redefined. Was %s, now %s." % (self.name, true_name))
# There are two possible cases. The first time an entry-point
- # with data is seen, self.initialized will be 0. On that
+ # with data is seen, self.initialized will be False. On that
# pass, we just fill in the data. The next time an
- # entry-point with data is seen, self.initialized will be 1.
+ # entry-point with data is seen, self.initialized will be True.
# On that pass we have to make that the new values match the
# valuse from the previous entry-point.
@@ -700,7 +693,7 @@ class gl_function(gl_item):
self.images.append(param)
if element.getchildren():
- self.initialized = 1
+ self.initialized = True
self.entry_point_parameters[name] = parameters
else:
self.entry_point_parameters[name] = []
diff --git a/src/mapi/glapi/gen/gl_x86-64_asm.py b/src/mapi/glapi/gen/gl_x86-64_asm.py
index acbeb2fe8e..bfd12709f2 100644
--- a/src/mapi/glapi/gen/gl_x86-64_asm.py
+++ b/src/mapi/glapi/gen/gl_x86-64_asm.py
@@ -37,7 +37,7 @@ import license
def should_use_push(registers):
for [reg, offset] in registers:
if reg[1:4] == "xmm":
- return 0
+ return False
N = len(registers)
return (N & 1) != 0