Commit bdeae71b authored by Liam Middlebrook's avatar Liam Middlebrook Committed by Alexandre Julliard

winevulkan: Generate typedefs for aliased structs.

parent e737aafa
...@@ -1571,6 +1571,7 @@ class VkStruct(Sequence): ...@@ -1571,6 +1571,7 @@ class VkStruct(Sequence):
self.union = union self.union = union
self.type_info = None # To be set later. self.type_info = None # To be set later.
self.struct_extensions = [] self.struct_extensions = []
self.aliased_by = []
def __getitem__(self, i): def __getitem__(self, i):
return self.members[i] return self.members[i]
...@@ -1581,7 +1582,10 @@ class VkStruct(Sequence): ...@@ -1581,7 +1582,10 @@ class VkStruct(Sequence):
@staticmethod @staticmethod
def from_alias(struct, alias): def from_alias(struct, alias):
name = struct.attrib.get("name") name = struct.attrib.get("name")
return VkStruct(name, alias.members, alias.returnedonly, alias.structextends, alias=alias) aliasee = VkStruct(name, alias.members, alias.returnedonly, alias.structextends, alias=alias)
alias.add_aliased_by(aliasee)
return aliasee
@staticmethod @staticmethod
def from_xml(struct): def from_xml(struct):
...@@ -1666,6 +1670,10 @@ class VkStruct(Sequence): ...@@ -1666,6 +1670,10 @@ class VkStruct(Sequence):
postfix (str, optional): text to append to end of struct name, useful for struct renaming. postfix (str, optional): text to append to end of struct name, useful for struct renaming.
""" """
# Only define alias structs when doing conversions
if self.is_alias() and not conv:
return ""
if self.union: if self.union:
text = "typedef union {0}".format(self.name) text = "typedef union {0}".format(self.name)
else: else:
...@@ -1687,12 +1695,21 @@ class VkStruct(Sequence): ...@@ -1687,12 +1695,21 @@ class VkStruct(Sequence):
if postfix is not None: if postfix is not None:
text += "}} {0}{1};\n\n".format(self.name, postfix) text += "}} {0}{1};\n\n".format(self.name, postfix)
else: else:
text += "}} {0};\n\n".format(self.name) text += "}} {0};\n".format(self.name)
for aliasee in self.aliased_by:
text += "typedef {0} {1};\n".format(self.name, aliasee.name)
text += "\n"
return text return text
def is_alias(self): def is_alias(self):
return bool(self.alias) return bool(self.alias)
def add_aliased_by(self, aliasee):
self.aliased_by.append(aliasee)
def needs_alignment(self): def needs_alignment(self):
""" Check if structure needs alignment for 64-bit data. """ Check if structure needs alignment for 64-bit data.
Various structures need alignment on 64-bit variables due Various structures need alignment on 64-bit variables due
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment