]> git.cworth.org Git - apitrace/blobdiff - specs/stdapi.py
Minimal D3D11 support.
[apitrace] / specs / stdapi.py
index c74d3111bca9aae9659d99be97c6fa2db7285bb6..2057124c9edf9bd4610a0f423fd7e7f359fee71b 100644 (file)
@@ -41,7 +41,10 @@ class Type:
         # on this type, so it should preferrably be something representative of
         # the type.
         if tag is None:
-            tag = ''.join([c for c in expr if c.isalnum() or c in '_'])
+            if expr is not None:
+                tag = ''.join([c for c in expr if c.isalnum() or c in '_'])
+            else:
+                tag = 'anonynoums'
         else:
             for c in tag:
                 assert c.isalnum() or c in '_'
@@ -257,12 +260,35 @@ class Struct(Type):
         Struct.__id += 1
 
         self.name = name
-        self.members = members
+        self.members = []
+
+        # Eliminate anonymous unions
+        for type, name in members:
+            if name is not None:
+                self.members.append((type, name))
+            else:
+                assert isinstance(type, Union)
+                assert type.name is None
+                self.members.extend(type.members)
 
     def visit(self, visitor, *args, **kwargs):
         return visitor.visitStruct(self, *args, **kwargs)
 
 
+class Union(Type):
+
+    __id = 0
+
+    def __init__(self, name, members):
+        Type.__init__(self, name)
+
+        self.id = Union.__id
+        Union.__id += 1
+
+        self.name = name
+        self.members = members
+
+
 class Alias(Type):
 
     def __init__(self, expr, type):
@@ -388,8 +414,8 @@ class Interface(Type):
 
 class Method(Function):
 
-    def __init__(self, type, name, args, const=False, sideeffects=True):
-        Function.__init__(self, type, name, args, call = '__stdcall', sideeffects=sideeffects)
+    def __init__(self, type, name, args, call = '__stdcall', const=False, sideeffects=True):
+        Function.__init__(self, type, name, args, call = call, sideeffects=sideeffects)
         for index in range(len(self.args)):
             self.args[index].index = index + 1
         self.const = const
@@ -400,6 +426,10 @@ class Method(Function):
             s += ' const'
         return s
 
+def StdMethod(*args, **kwargs):
+    kwargs.setdefault('call', '__stdcall')
+    return Method(*args, **kwargs)
+
 
 class String(Type):