summaryrefslogtreecommitdiffstats
path: root/src/mapi
diff options
context:
space:
mode:
authorMathieu Bridon <[email protected]>2018-07-05 15:17:39 +0200
committerDylan Baker <[email protected]>2018-07-24 11:07:04 -0700
commit022d2a381d32d24aabe2c54704a5a5e2440a75e9 (patch)
tree587757745b212fef0f3c5ac9985b754963cb791e /src/mapi
parent01da2feb0edd36abb161d96ccd6020c4b358da91 (diff)
python: Better use iterators
In Python 2, iterators had a .next() method. In Python 3, instead they have a .__next__() method, which is automatically called by the next() builtin. In addition, it is better to use the iter() builtin to create an iterator, rather than calling its __iter__() method. These were also introduced in Python 2.6, so using it makes the script compatible with Python 2 and 3. Signed-off-by: Mathieu Bridon <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Reviewed-by: Dylan Baker <[email protected]>
Diffstat (limited to 'src/mapi')
-rw-r--r--src/mapi/glapi/gen/glX_XML.py17
-rw-r--r--src/mapi/glapi/gen/gl_XML.py12
2 files changed, 15 insertions, 14 deletions
diff --git a/src/mapi/glapi/gen/glX_XML.py b/src/mapi/glapi/gen/glX_XML.py
index e10c8b0a097..ff0011bf9ce 100644
--- a/src/mapi/glapi/gen/glX_XML.py
+++ b/src/mapi/glapi/gen/glX_XML.py
@@ -296,7 +296,7 @@ class glx_function(gl_XML.gl_function):
parameters.extend( temp[1] )
if include_variable_parameters:
parameters.extend( temp[2] )
- return parameters.__iter__()
+ return iter(parameters)
def parameterIterateCounters(self):
@@ -304,7 +304,7 @@ class glx_function(gl_XML.gl_function):
for name in self.counter_list:
temp.append( self.parameters_by_name[ name ] )
- return temp.__iter__()
+ return iter(temp)
def parameterIterateOutputs(self):
@@ -547,13 +547,14 @@ class glx_function_iterator(object):
return self
- def next(self):
- f = self.iterator.next()
+ def __next__(self):
+ while True:
+ f = next(self.iterator)
- if f.client_supported_for_indirect():
- return f
- else:
- return self.next()
+ if f.client_supported_for_indirect():
+ return f
+
+ next = __next__
class glx_api(gl_XML.gl_api):
diff --git a/src/mapi/glapi/gen/gl_XML.py b/src/mapi/glapi/gen/gl_XML.py
index 7bd5a1f4e43..b4aa6be985e 100644
--- a/src/mapi/glapi/gen/gl_XML.py
+++ b/src/mapi/glapi/gen/gl_XML.py
@@ -782,9 +782,9 @@ class gl_function( gl_item ):
def parameterIterator(self, name = None):
if name is not None:
- return self.entry_point_parameters[name].__iter__();
+ return iter(self.entry_point_parameters[name]);
else:
- return self.parameters.__iter__();
+ return iter(self.parameters);
def get_parameter_string(self, entrypoint = None):
@@ -996,7 +996,7 @@ class gl_api(object):
for name in names:
functions.append(lists[func_cat_type][key][name])
- return functions.__iter__()
+ return iter(functions)
def functionIterateByOffset(self):
@@ -1017,7 +1017,7 @@ class gl_api(object):
if temp[i]:
list.append(temp[i])
- return list.__iter__();
+ return iter(list);
def functionIterateAll(self):
@@ -1031,7 +1031,7 @@ class gl_api(object):
for enum in keys:
list.append( self.enums_by_name[ enum ] )
- return list.__iter__()
+ return iter(list)
def categoryIterate(self):
@@ -1049,7 +1049,7 @@ class gl_api(object):
for key in keys:
list.append(self.categories[cat_type][key])
- return list.__iter__()
+ return iter(list)
def get_category_for_name( self, name ):