summaryrefslogtreecommitdiffstats
path: root/src/mesa/glapi/gl_XML.py
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2005-03-03 21:21:59 +0000
committerIan Romanick <[email protected]>2005-03-03 21:21:59 +0000
commitce77d372647f025854d497c263e45882d6f6b0a6 (patch)
tree9949e03bac7a0e1f460e217ec586cbe9290fed5b /src/mesa/glapi/gl_XML.py
parent6e776f25fd4d275722494824e2d5149a25ed4036 (diff)
Check for some common function parameter description errors in the
endElement handler for <function>. This catches the errors as early as possible and makes debugging other code easier.
Diffstat (limited to 'src/mesa/glapi/gl_XML.py')
-rw-r--r--src/mesa/glapi/gl_XML.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/mesa/glapi/gl_XML.py b/src/mesa/glapi/gl_XML.py
index b2e3cd43252..03aa982ac28 100644
--- a/src/mesa/glapi/gl_XML.py
+++ b/src/mesa/glapi/gl_XML.py
@@ -367,6 +367,9 @@ class glFunction( glItem ):
else:
self.real_name = fn_name
+ self.parameters_by_name = {}
+ self.variable_length_parameters = []
+
glItem.__init__(self, name, fn_name, context)
return
@@ -387,6 +390,32 @@ class glFunction( glItem ):
self.set_return_type(attrs.get('type', None))
+ def endElement(self, name):
+ """Handle the end of a <function> element.
+
+ At the end of a <function> element, there is some semantic
+ checking that can be done. This prevents some possible
+ exceptions from being thrown elsewhere in the code.
+ """
+
+ if name == "function":
+ for p in self.variable_length_parameters:
+ if p.counter:
+ counter = self.parameters_by_name[ p.counter ]
+ if not self.parameters_by_name.has_key( p.counter ):
+ raise RuntimeError("Parameter '%s' of function '%s' has counter '%s', but function has no such parameter." % (p.name, self.name, p.counter))
+ elif not self.parameters_by_name[ p.counter ].is_counter:
+ raise RuntimeError("Parameter '%s' of function '%s' has counter '%s', but '%s' is not marked as a counter." % (p.name, self.name, p.counter, p.counter))
+
+ for n in p.count_parameter_list:
+ if not self.parameters_by_name.has_key( n ):
+ raise RuntimeError("Parameter '%s' of function '%s' has size parameter '%s', but function has no such parameter." % (p.name, self.name, n))
+
+ return 1
+ else:
+ return 0
+
+
def append(self, tag_name, p):
if tag_name != "param":
raise RuntimeError("Trying to append '%s' to parameter list of function '%s'." % (tag_name, self.name))
@@ -398,6 +427,11 @@ class glFunction( glItem ):
if p.count_parameter_list != []:
self.count_parameter_list.extend( p.count_parameter_list )
+ if p.is_variable_length_array():
+ self.variable_length_parameters.append(p)
+
+ self.parameters_by_name[ p.name ] = p
+
def set_return_type(self, t):
self.fn_return_type = t