winevulkan: Parse enum value aliases.
Signed-off-by: Józef Kucia <jkucia@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
94a4dadd9a
commit
b5a79ca5d0
|
@ -322,22 +322,26 @@ class VkEnum(object):
|
||||||
for v in enum.findall("enum"):
|
for v in enum.findall("enum"):
|
||||||
# Value is either a value or a bitpos, only one can exist.
|
# Value is either a value or a bitpos, only one can exist.
|
||||||
value = v.attrib.get("value")
|
value = v.attrib.get("value")
|
||||||
if value is None:
|
alias_name = v.attrib.get("alias")
|
||||||
# bitmask
|
if alias_name:
|
||||||
value = 1 << int(v.attrib.get("bitpos"))
|
alias = next(x for x in values if x.name == alias_name)
|
||||||
values.append(VkEnumValue(v.attrib.get("name"), value, hex=True))
|
values.append(VkEnumValue(v.attrib.get("name"), alias.value, alias.hex))
|
||||||
else:
|
elif value:
|
||||||
# Some values are in hex form. We want to preserve the hex representation
|
# Some values are in hex form. We want to preserve the hex representation
|
||||||
# at least when we convert back to a string. Internally we want to use int.
|
# at least when we convert back to a string. Internally we want to use int.
|
||||||
if "0x" in value:
|
if "0x" in value:
|
||||||
values.append(VkEnumValue(v.attrib.get("name"), int(value, 0), hex=True))
|
values.append(VkEnumValue(v.attrib.get("name"), int(value, 0), hex=True))
|
||||||
else:
|
else:
|
||||||
values.append(VkEnumValue(v.attrib.get("name"), int(value, 0)))
|
values.append(VkEnumValue(v.attrib.get("name"), int(value, 0)))
|
||||||
|
else:
|
||||||
|
# bitmask
|
||||||
|
value = 1 << int(v.attrib.get("bitpos"))
|
||||||
|
values.append(VkEnumValue(v.attrib.get("name"), value, hex=True))
|
||||||
|
|
||||||
# vulkan.h contains a *_MAX_ENUM value set to 32-bit at the time of writing,
|
# vulkan.h contains a *_MAX_ENUM value set to 32-bit at the time of writing,
|
||||||
# which is to prepare for extensions as they can add values and hence affect
|
# which is to prepare for extensions as they can add values and hence affect
|
||||||
# the size definition.
|
# the size definition.
|
||||||
max_name = re.sub(r'([0-9a-z_])([A-Z0-9])',r'\1_\2',name).upper() + "_MAX_ENUM"
|
max_name = re.sub(r'([0-9a-z_])([A-Z0-9])',r'\1_\2', name).upper() + "_MAX_ENUM"
|
||||||
values.append(VkEnumValue(max_name, 0x7fffffff, hex=True))
|
values.append(VkEnumValue(max_name, 0x7fffffff, hex=True))
|
||||||
|
|
||||||
return VkEnum(name, values)
|
return VkEnum(name, values)
|
||||||
|
|
Loading…
Reference in New Issue