Remove glEnum::startElement, but refactor out some of the common code from
authorIan Romanick <idr@us.ibm.com>
Mon, 24 Jan 2005 21:29:13 +0000 (21:29 +0000)
committerIan Romanick <idr@us.ibm.com>
Mon, 24 Jan 2005 21:29:13 +0000 (21:29 +0000)
there and glXEnum::startElement to glEnum::process_attributes.

src/mesa/glapi/glX_XML.py
src/mesa/glapi/gl_XML.py

index 8efc90ca56a1cf9f1876d25c34dbd5215ecb7b4b..4c9da6e304da5ae3d992abe3d2d7b1a51c158b22 100644 (file)
@@ -244,17 +244,12 @@ class glXEnum(gl_XML.glEnum):
 
        def startElement(self, name, attrs):
                if name == "size":
-                       n = attrs.get('name', None)
+                       [n, c] = self.process_attributes(attrs)
+
                        if not self.context.glx_enum_functions.has_key( n ):
                                f = glXEnumFunction( n )
                                self.context.glx_enum_functions[ f.name ] = f
 
-                       temp = attrs.get('count', None)
-                       try:
-                               c = int(temp)
-                       except Exception,e:
-                               raise RuntimeError('Invalid count value "%s" for enum "%s" in function "%s" when an integer was expected.' % (temp, self.name, n))
-
                        self.context.glx_enum_functions[ n ].append( c, self.value, self.name )
                else:
                        gl_XML.glEnum.startElement(self, context, name, attrs)
index 538756ea0c2d2d8f1b333feda26bd3e1e9fb16cd..bc7d27befe3d6dd45365d7515d2403d0e1c27931 100644 (file)
@@ -86,18 +86,21 @@ class glEnum( glItem ):
 
        def __init__(self, context, name, attrs):
                self.value = int(attrs.get('value', "0x0000"), 0)
-               self.functions = {}
 
                enum_name = "GL_" + attrs.get('name', None)
                glItem.__init__(self, name, enum_name, context)
 
-       def startElement(self, name, attrs):
-               if name == "size":
-                       name = attrs.get('name', None)
-                       count = int(attrs.get('count', "0"), 0)
-                       self.functions[name] = count
 
-               return
+       def process_attributes(self, attrs):
+               name = attrs.get('name', None)
+
+               temp = attrs.get('count', None)
+               try:
+                       c = int(temp)
+               except Exception,e:
+                       raise RuntimeError('Invalid count value "%s" for enum "%s" in function "%s" when an integer was expected.' % (temp, self.name, n))
+
+               return [name, c]
 
 
 class glType( glItem ):