]> git.cworth.org Git - apitrace/blobdiff - specs/stdapi.py
Introduce AttribArray, a code generator for pseudo-type attrib_list.
[apitrace] / specs / stdapi.py
index b86668bd13be9d2a44b34227fbf5d06eee7733f5..795f0cfa2776f7e7f24c7cf0803f85cad2e8f8b8 100644 (file)
@@ -270,6 +270,18 @@ class Array(Type):
         return visitor.visitArray(self, *args, **kwargs)
 
 
+class AttribArray(Type):
+
+    def __init__(self, keyType, valueTypes):
+        Type.__init__(self, (Pointer(Const(Int))).expr)
+        self.type = (Pointer(Const(Int))) # for function prototypes and such
+        self.keyType = keyType
+        self.valueTypes = valueTypes
+
+    def visit(self, visitor, *args, **kwargs):
+        return visitor.visitAttribArray(self, *args, **kwargs)
+
+
 class Blob(Type):
 
     def __init__(self, type, size):
@@ -385,6 +397,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')
@@ -428,6 +446,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():
@@ -560,6 +584,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
 
@@ -764,6 +791,10 @@ 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:
+            self.visit(valueType, *args, **kwargs)
+
     def visitBlob(self, array, *args, **kwargs):
         pass