]> git.cworth.org Git - apitrace/blobdiff - specs/stdapi.py
Allow float-based attrib_lists as found in WGL.
[apitrace] / specs / stdapi.py
index 930bb82b9be8a9eee0088178b9bda22bafb2fa00..5cf1a37def1295c08620014332487f5539298876 100644 (file)
@@ -270,6 +270,28 @@ class Array(Type):
         return visitor.visitArray(self, *args, **kwargs)
 
 
+class AttribArray(Type):
+
+    def __init__(self, keyType, valueTypes, isConst = True, punType = None, terminator = '0'):
+        self.baseType = Int
+        if punType is not None:
+            self.baseType = punType
+        if isConst:
+            Type.__init__(self, (Pointer(Const(self.baseType))).expr)
+        else:
+            Type.__init__(self, (Pointer(self.baseType)).expr)
+        self.keyType = keyType
+        self.valueTypes = valueTypes
+        self.terminator = terminator
+        self.hasKeysWithoutValues = False
+        for key, value in valueTypes:
+            if value is None:
+                self.hasKeysWithoutValues = True
+
+    def visit(self, visitor, *args, **kwargs):
+        return visitor.visitAttribArray(self, *args, **kwargs)
+
+
 class Blob(Type):
 
     def __init__(self, type, size):
@@ -340,13 +362,7 @@ def InOut(type, name):
 
 class Function:
 
-    # 0-3 are reserved to memcpy, malloc, free, and realloc
-    __id = 4
-
     def __init__(self, type, name, args, call = '', fail = None, sideeffects=True, internal=False):
-        self.id = Function.__id
-        Function.__id += 1
-
         self.type = type
         self.name = name
 
@@ -391,6 +407,12 @@ class Function:
     def argNames(self):
         return [arg.name for arg in self.args]
 
+    def getArgByName(self, name):
+        for arg in self.args:
+            if arg.name == name:
+                return arg
+        return None
+
 
 def StdFunction(*args, **kwargs):
     kwargs.setdefault('call', '__stdcall')
@@ -434,6 +456,12 @@ class Interface(Type):
             iface = iface.base
         raise StopIteration
 
+    def hasBase(self, *bases):
+        for iface in self.iterBases():
+            if iface in bases:
+                return True
+        return False
+
     def iterBaseMethods(self):
         if self.base is not None:
             for iface, method in self.base.iterBaseMethods():
@@ -566,6 +594,9 @@ class Visitor:
     def visitArray(self, array, *args, **kwargs):
         raise NotImplementedError
 
+    def visitAttribArray(self, array, *args, **kwargs):
+        raise NotImplementedError
+
     def visitBlob(self, blob, *args, **kwargs):
         raise NotImplementedError
 
@@ -770,6 +801,11 @@ class Traverser(Visitor):
     def visitArray(self, array, *args, **kwargs):
         self.visit(array.type, *args, **kwargs)
 
+    def visitAttribArray(self, attribs, *args, **kwargs):
+        for key, valueType in attribs.valueTypes:
+            if valueType is not None:
+                self.visit(valueType, *args, **kwargs)
+
     def visitBlob(self, array, *args, **kwargs):
         pass