X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=specs%2Fstdapi.py;fp=specs%2Fstdapi.py;h=2057124c9edf9bd4610a0f423fd7e7f359fee71b;hb=5b6fb75c9e2f1ad31bc3c3fb354003efe0352050;hp=c74d3111bca9aae9659d99be97c6fa2db7285bb6;hpb=a03c5b266027838f99244510f8efa3bfc3e1a3c9;p=apitrace diff --git a/specs/stdapi.py b/specs/stdapi.py index c74d311..2057124 100644 --- a/specs/stdapi.py +++ b/specs/stdapi.py @@ -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):