Added the ability to get the size of a parameter as a string. Changed the
authorIan Romanick <idr@us.ibm.com>
Wed, 1 Dec 2004 00:29:48 +0000 (00:29 +0000)
committerIan Romanick <idr@us.ibm.com>
Wed, 1 Dec 2004 00:29:48 +0000 (00:29 +0000)
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.

src/mesa/glapi/gl_XML.py

index 55bbddafa5b8f592e53dda22e6fbbdff9ceb8d6b..79da5abab9b61d08394c209217e12e5864a817e4 100644 (file)
@@ -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