From: Ian Romanick Date: Thu, 3 Mar 2005 21:21:59 +0000 (+0000) Subject: Check for some common function parameter description errors in the X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ce77d372647f025854d497c263e45882d6f6b0a6;p=mesa.git Check for some common function parameter description errors in the endElement handler for . This catches the errors as early as possible and makes debugging other code easier. --- 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 element. + + At the end of a 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