glthread: sync in glFlush for multiple contexts
[mesa.git] / src / mapi / glapi / gen / glX_XML.py
index 975321a76ab6f63ad2ff138aa09066d1db6f0a6c..3b54a967fdcb255ed7e4e37ff367b340bec43ce1 100644 (file)
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 
 # (C) Copyright IBM Corporation 2004, 2005
 # All Rights Reserved.
@@ -33,29 +32,27 @@ import sys, getopt, string
 class glx_item_factory(gl_XML.gl_item_factory):
     """Factory to create GLX protocol oriented objects derived from gl_item."""
 
-    def create_item(self, name, element, context):
-        if name == "function":
-            return glx_function(element, context)
-        elif name == "enum":
-            return glx_enum(element, context)
-        elif name == "api":
-            return glx_api(self)
-        else:
-            return gl_XML.gl_item_factory.create_item(self, name, element, context)
+    def create_function(self, element, context):
+        return glx_function(element, context)
+
+    def create_enum(self, element, context, category):
+        return glx_enum(element, context, category)
+
+    def create_api(self):
+        return glx_api(self)
 
 
 class glx_enum(gl_XML.gl_enum):
-    def __init__(self, element, context):
-        gl_XML.gl_enum.__init__(self, element, context)
+    def __init__(self, element, context, category):
+        gl_XML.gl_enum.__init__(self, element, context, category)
 
         self.functions = {}
 
-        child = element.children
-        while child:
-            if child.type == "element" and child.name == "size":
-                n = child.nsProp( "name", None )
-                c = child.nsProp( "count", None )
-                m = child.nsProp( "mode", None )
+        for child in element:
+            if child.tag == "size":
+                n = child.get( "name" )
+                c = child.get( "count" )
+                m = child.get( "mode", "set" )
 
                 if not c:
                     c = self.default_count
@@ -67,11 +64,9 @@ class glx_enum(gl_XML.gl_enum):
                 else:
                     mode = 1
 
-                if not self.functions.has_key(n):
+                if n not in self.functions:
                     self.functions[ n ] = [c, mode]
 
-            child = child.next
-
         return
 
 
@@ -120,10 +115,10 @@ class glx_function(gl_XML.gl_function):
         # appears after the function that it aliases.
 
         if not self.vectorequiv:
-            self.vectorequiv = element.nsProp("vectorequiv", None)
+            self.vectorequiv = element.get("vectorequiv")
 
 
-        name = element.nsProp("name", None)
+        name = element.get("name")
         if name == self.name:
             for param in self.parameters:
                 self.parameters_by_name[ param.name ] = param
@@ -135,12 +130,11 @@ class glx_function(gl_XML.gl_function):
                     self.counter_list.append(param.counter)
 
 
-        child = element.children
-        while child:
-            if child.type == "element" and child.name == "glx":
-                rop = child.nsProp( 'rop', None )
-                sop = child.nsProp( 'sop', None )
-                vop = child.nsProp( 'vendorpriv', None )
+        for child in element:
+            if child.tag == "glx":
+                rop = child.get( 'rop' )
+                sop = child.get( 'sop' )
+                vop = child.get( 'vendorpriv' )
 
                 if rop:
                     self.glx_rop = int(rop)
@@ -152,12 +146,12 @@ class glx_function(gl_XML.gl_function):
                     self.glx_vendorpriv = int(vop)
                     self.glx_vendorpriv_names.append(name)
 
-                self.img_reset = child.nsProp( 'img_reset', None )
+                self.img_reset = child.get( 'img_reset' )
 
                 # The 'handcode' attribute can be one of 'true',
                 # 'false', 'client', or 'server'.
 
-                handcode = child.nsProp( 'handcode', None )
+                handcode = child.get( 'handcode', 'false' )
                 if handcode == "false":
                     self.server_handcode = 0
                     self.client_handcode = 0
@@ -179,8 +173,6 @@ class glx_function(gl_XML.gl_function):
                 self.reply_always_array   = gl_XML.is_attr_true( child, 'always_array' )
                 self.dimensions_in_reply  = gl_XML.is_attr_true( child, 'dimensions_in_reply' )
 
-            child = child.next
-
 
         # Do some validation of the GLX protocol information.  As
         # new tests are discovered, they should be added here.
@@ -304,7 +296,7 @@ class glx_function(gl_XML.gl_function):
         parameters.extend( temp[1] )
         if include_variable_parameters:
             parameters.extend( temp[2] )
-        return parameters.__iter__()
+        return iter(parameters)
 
 
     def parameterIterateCounters(self):
@@ -312,7 +304,7 @@ class glx_function(gl_XML.gl_function):
         for name in self.counter_list:
             temp.append( self.parameters_by_name[ name ] )
 
-        return temp.__iter__()
+        return iter(temp)
 
 
     def parameterIterateOutputs(self):
@@ -364,7 +356,7 @@ class glx_function(gl_XML.gl_function):
                 # FIXME adds some extra diffs to the generated
                 # FIXME code.
 
-                size_string = size_string + " + __GLX_PAD(%s)" % (p.size_string(1))
+                size_string = size_string + " + safe_pad(%s)" % (p.size_string(1))
 
         return size_string
 
@@ -478,7 +470,7 @@ class glx_function(gl_XML.gl_function):
     def needs_reply(self):
         try:
             x = self._needs_reply
-        except Exception, e:
+        except Exception:
             x = 0
             if self.return_type != 'void':
                 x = 1
@@ -543,7 +535,7 @@ class glx_function(gl_XML.gl_function):
         return not self.ignore and (self.offset != -1) and (self.glx_rop or self.glx_sop or self.glx_vendorpriv or self.vectorequiv or self.client_handcode)
 
 
-class glx_function_iterator:
+class glx_function_iterator(object):
     """Class to iterate over a list of glXFunctions"""
 
     def __init__(self, context):
@@ -555,13 +547,14 @@ class glx_function_iterator:
         return self
 
 
-    def next(self):
-        f = self.iterator.next()
+    def __next__(self):
+        while True:
+            f = next(self.iterator)
 
-        if f.client_supported_for_indirect():
-            return f
-        else:
-            return self.next()
+            if f.client_supported_for_indirect():
+                return f
+
+    next = __next__
 
 
 class glx_api(gl_XML.gl_api):