summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mesa/glapi/gl_XML.py76
-rw-r--r--src/mesa/glapi/gl_apitemp.py14
-rw-r--r--src/mesa/glapi/gl_procs.py30
3 files changed, 67 insertions, 53 deletions
diff --git a/src/mesa/glapi/gl_XML.py b/src/mesa/glapi/gl_XML.py
index 61c9b355cf..16499df094 100644
--- a/src/mesa/glapi/gl_XML.py
+++ b/src/mesa/glapi/gl_XML.py
@@ -425,6 +425,58 @@ class glItemFactory:
return None
+class glFunctionIterator:
+ """Class to iterate over a list of glFunctions
+
+ Objects of this classare returned by
+ FilterGLAPISpecBase::functionIterator. This default version
+ iterates over the functions in order of dispatch table offset. All
+ of the "true" functions are iterated first, followed by the alias
+ functions."""
+
+ def __init__(self, context):
+ self.context = context
+ self.keys = context.functions.keys()
+ self.keys.sort()
+
+ self.prevk = -1
+ self.direction = 1
+
+ for self.index in range(0, len(self.keys)):
+ if self.keys[ self.index ] >= 0: break
+
+ if self.index == len(self.keys):
+ self.direction = -1
+ self.index -= 1
+
+ self.split = self.index - 1
+ return
+
+
+ def __iter__(self):
+ return self
+
+
+ def next(self):
+ if self.index < 0:
+ raise StopIteration
+
+ k = self.keys[ self.index ]
+
+ #if self.context.functions[k].fn_alias == None:
+ # if k != self.prevk + 1:
+ # print 'Missing offset %d' % (prevk)
+ # self.prevk = int(k)
+
+ self.index += self.direction
+
+ if self.index == len(self.keys):
+ self.index = self.split
+ self.direction = -1
+
+ return self.context.functions[k]
+
+
class FilterGLAPISpecBase(saxutils.XMLFilterBase):
name = "a"
license = "The license for this file is unspecified."
@@ -457,25 +509,13 @@ class FilterGLAPISpecBase(saxutils.XMLFilterBase):
return self.functions[index]
- def printFunctions(self):
- keys = self.functions.keys()
- keys.sort()
- prevk = -1
- for k in keys:
- if k < 0: continue
-
- if self.functions[k].fn_alias == None:
- if k != prevk + 1:
- #print 'Missing offset %d' % (prevk)
- pass
- prevk = int(k)
- self.printFunction(self.functions[k])
-
- keys.reverse()
- for k in keys:
- if self.functions[k].fn_alias != None:
- self.printFunction(self.functions[k])
+ def functionIterator(self):
+ return glFunctionIterator(self)
+
+ def printFunctions(self):
+ for f in self.functionIterator():
+ self.printFunction(f)
return
diff --git a/src/mesa/glapi/gl_apitemp.py b/src/mesa/glapi/gl_apitemp.py
index 533cc65bec..d89440acbf 100644
--- a/src/mesa/glapi/gl_apitemp.py
+++ b/src/mesa/glapi/gl_apitemp.py
@@ -149,12 +149,10 @@ class PrintGlOffsets(gl_XML.FilterGLAPISpecBase):
#endif
static _glapi_proc DISPATCH_TABLE_NAME[] = {"""
- keys = self.functions.keys()
- keys.sort()
- for k in keys:
- if k < 0: continue
+ for f in self.functionIterator():
+ if f.fn_offset < 0: continue
- print ' TABLE_ENTRY(%s),' % (self.functions[k].name)
+ print ' TABLE_ENTRY(%s),' % (f.name)
print ' /* A whole bunch of no-op functions. These might be called'
print ' * when someone tries to call a dynamically-registered'
@@ -177,11 +175,7 @@ static _glapi_proc DISPATCH_TABLE_NAME[] = {"""
#ifdef UNUSED_TABLE_NAME
static _glapi_proc UNUSED_TABLE_NAME[] = {"""
- keys = self.functions.keys()
- keys.sort()
- keys.reverse();
- for k in keys:
- f = self.functions[k]
+ for f in self.functionIterator():
if f.fn_offset < 0:
print ' TABLE_ENTRY(%s),' % (f.name)
diff --git a/src/mesa/glapi/gl_procs.py b/src/mesa/glapi/gl_procs.py
index f9ce8e2da1..a9fdd1812c 100644
--- a/src/mesa/glapi/gl_procs.py
+++ b/src/mesa/glapi/gl_procs.py
@@ -91,16 +91,8 @@ class PrintGlProcs(gl_XML.FilterGLAPISpecBase):
else:
print 'static const char gl_string_table[] = {'
- keys = self.functions.keys()
- keys.sort()
- for k in keys:
- if k < 0: continue
- self.printFunctionString(self.functions[k])
-
- keys.reverse()
- for k in keys:
- if k >= -1: continue
- self.printFunctionString(self.functions[k])
+ for f in self.functionIterator():
+ self.printFunctionString(f)
if self.long_strings:
print ' ;'
@@ -110,27 +102,15 @@ class PrintGlProcs(gl_XML.FilterGLAPISpecBase):
print ''
print 'static const glprocs_table_t static_functions[] = {'
- keys = self.functions.keys()
- keys.sort()
base_offset = 0
- for k in keys:
- if k < 0: continue
- self.printFunctionOffset(self.functions[k], base_offset)
-
- # The length of the function's name, plus 2 for "gl",
- # plus 1 for the NUL.
-
- base_offset += len(self.functions[k].name) + 3
- keys.reverse()
- for k in keys:
- if k >= -1: continue
- self.printFunctionOffset(self.functions[k], base_offset)
+ for f in self.functionIterator():
+ self.printFunctionOffset(f, base_offset)
# The length of the function's name, plus 2 for "gl",
# plus 1 for the NUL.
- base_offset += len(self.functions[k].name) + 3
+ base_offset += len(f.name) + 3
print ' NAME_FUNC_OFFSET( -1, NULL, 0 )'
print '};'