]> git.cworth.org Git - apitrace/blobdiff - specs/stdapi.py
d3d8: Update specs to match d3d9.
[apitrace] / specs / stdapi.py
index cde94cb6fa522a583f0deb31edce660901d6c9cb..1097347f38ce3a97a26b9312c7de183c469e8c0f 100644 (file)
@@ -129,6 +129,8 @@ UInt32 = Literal("uint32_t", "UInt")
 Int64 = Literal("int64_t", "SInt")
 UInt64 = Literal("uint64_t", "UInt")
 
+IntPtr = Literal("intptr_t", "SInt")
+UIntPtr = Literal("uintptr_t", "UInt")
 
 class Const(Type):
 
@@ -458,7 +460,8 @@ class Interface(Type):
 
 class Method(Function):
 
-    def __init__(self, type, name, args, call = '__stdcall', const=False, sideeffects=True):
+    def __init__(self, type, name, args, call = '', const=False, sideeffects=True):
+        assert call == '__stdcall'
         Function.__init__(self, type, name, args, call = call, sideeffects=sideeffects)
         for index in range(len(self.args)):
             self.args[index].index = index + 1
@@ -834,11 +837,8 @@ class Collector(Traverser):
 
 
 
-class API:
-    '''API abstraction.
-
-    Essentially, a collection of types, functions, and interfaces.
-    '''
+class Module:
+    '''A collection of functions.'''
 
     def __init__(self, name = None):
         self.name = name
@@ -846,50 +846,73 @@ class API:
         self.functions = []
         self.interfaces = []
 
+    def addFunctions(self, functions):
+        self.functions.extend(functions)
+
+    def addInterfaces(self, interfaces):
+        self.interfaces.extend(interfaces)
+
+    def mergeModule(self, module):
+        self.headers.extend(module.headers)
+        self.functions.extend(module.functions)
+        self.interfaces.extend(module.interfaces)
+
+    def getFunctionByName(self, name):
+        for function in self.functions:
+            if function.name == name:
+                return function
+        return None
+
+
+class API:
+    '''API abstraction.
+
+    Essentially, a collection of types, functions, and interfaces.
+    '''
+
+    def __init__(self, modules = None):
+        self.modules = []
+        if modules is not None:
+            self.modules.extend(modules)
+
     def getAllTypes(self):
         collector = Collector()
-        for function in self.functions:
-            for arg in function.args:
-                collector.visit(arg.type)
-            collector.visit(function.type)
-        for interface in self.interfaces:
-            collector.visit(interface)
-            for method in interface.iterMethods():
-                for arg in method.args:
+        for module in self.modules:
+            for function in module.functions:
+                for arg in function.args:
                     collector.visit(arg.type)
-                collector.visit(method.type)
+                collector.visit(function.type)
+            for interface in module.interfaces:
+                collector.visit(interface)
+                for method in interface.iterMethods():
+                    for arg in method.args:
+                        collector.visit(arg.type)
+                    collector.visit(method.type)
         return collector.types
 
+    def getAllFunctions(self):
+        functions = []
+        for module in self.modules:
+            functions.extend(module.functions)
+        return functions
+
     def getAllInterfaces(self):
         types = self.getAllTypes()
         interfaces = [type for type in types if isinstance(type, Interface)]
-        for interface in self.interfaces:
-            if interface not in interfaces:
-                interfaces.append(interface)
+        for module in self.modules:
+            for interface in module.interfaces:
+                if interface not in interfaces:
+                    interfaces.append(interface)
         return interfaces
 
-    def addFunction(self, function):
-        self.functions.append(function)
-
-    def addFunctions(self, functions):
-        for function in functions:
-            self.addFunction(function)
-
-    def addInterface(self, interface):
-        self.interfaces.append(interface)
-
-    def addInterfaces(self, interfaces):
-        self.interfaces.extend(interfaces)
-
-    def addApi(self, api):
-        self.headers.extend(api.headers)
-        self.addFunctions(api.functions)
-        self.addInterfaces(api.interfaces)
+    def addModule(self, module):
+        self.modules.append(module)
 
     def getFunctionByName(self, name):
-        for function in self.functions:
-            if function.name == name:
-                return function
+        for module in self.modules:
+            for function in module.functions:
+                if function.name == name:
+                    return function
         return None