From: Ian Romanick Date: Wed, 1 Dec 2004 00:29:48 +0000 (+0000) Subject: Added the ability to get the size of a parameter as a string. Changed the X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4f0a75e7241ca1545b67ccabe007b94c8cf9b429;p=mesa.git Added the ability to get the size of a parameter as a string. Changed the meaning of "variable length array" to include variables that are "counted" instead of just ones that use an enum to map to a count. Added glParameter to the glItemFactory. --- diff --git a/src/mesa/glapi/gl_XML.py b/src/mesa/glapi/gl_XML.py index 55bbddafa5b..79da5abab9b 100644 --- a/src/mesa/glapi/gl_XML.py +++ b/src/mesa/glapi/gl_XML.py @@ -193,7 +193,7 @@ class glParameter( glItem ): to glCallLists, are not variable length arrays in this sense.""" - return self.p_count_parameters != None + return (self.p_count_parameters != None) or (self.counter != None) def is_array(self): @@ -211,7 +211,7 @@ class glParameter( glItem ): glDeleteTextures), or a general variable length vector.""" if self.is_array(): - if self.is_variable_length_array(): + if self.p_count_parameters != None: return "compsize" elif self.counter != None: return self.counter @@ -222,13 +222,32 @@ class glParameter( glItem ): def size(self): - if self.is_variable_length_array(): + if self.p_count_parameters != None or self.counter != None or self.is_output: return 0 elif self.p_count == 0: return self.p_type.size else: return self.p_type.size * self.p_count + def size_string(self): + s = self.size() + if s == 0: + a_prod = "compsize" + b_prod = self.p_type.size + + if self.p_count_parameters == None and self.counter != None: + a_prod = self.counter + elif self.p_count_parameters != None and self.counter == None: + pass + elif self.p_count_parameters != None and self.counter != None: + b_prod = self.counter + else: + raise RuntimeError("Parameter '%s' to function '%s' has size 0." % (self.name, self.context.name)) + + return "(%s * %s)" % (a_prod, b_prod) + else: + return str(s) + class glParameterIterator: """Class to iterate over a list of glParameters. @@ -283,7 +302,7 @@ class glFunction( glItem ): def startElement(self, name, attrs): if name == "param": try: - glParameter(self, name, attrs) + self.context.factory.create(self, name, attrs) except RuntimeError: print "Error with parameter '%s' in function '%s'." \ % (attrs.get('name','(unknown)'), self.name) @@ -326,6 +345,8 @@ class glItemFactory: return glType(context, name, attrs) elif name == "enum": return glEnum(context, name, attrs) + elif name == "param": + return glParameter(context, name, attrs) else: return None