=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: winevulkan: Parse enum value aliases.

Alexandre Julliard julliard at winehq.org
Fri Oct 5 16:40:40 CDT 2018


Module: wine
Branch: master
Commit: b5a79ca5d05d6fcfa87fa0b5924d49aed7f18c6e
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=b5a79ca5d05d6fcfa87fa0b5924d49aed7f18c6e

Author: Józef Kucia <jkucia at codeweavers.com>
Date:   Fri Oct  5 16:55:19 2018 +0200

winevulkan: Parse enum value aliases.

Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/winevulkan/make_vulkan | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/dlls/winevulkan/make_vulkan b/dlls/winevulkan/make_vulkan
index ce14c78..cb55a30 100755
--- a/dlls/winevulkan/make_vulkan
+++ b/dlls/winevulkan/make_vulkan
@@ -322,22 +322,26 @@ class VkEnum(object):
         for v in enum.findall("enum"):
             # Value is either a value or a bitpos, only one can exist.
             value = v.attrib.get("value")
-            if value is None:
-                # bitmask
-                value = 1 << int(v.attrib.get("bitpos"))
-                values.append(VkEnumValue(v.attrib.get("name"), value, hex=True))
-            else:
+            alias_name = v.attrib.get("alias")
+            if alias_name:
+                alias = next(x for x in values if x.name == alias_name)
+                values.append(VkEnumValue(v.attrib.get("name"), alias.value, alias.hex))
+            elif value:
                 # 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.
                 if "0x" in value:
                     values.append(VkEnumValue(v.attrib.get("name"), int(value, 0), hex=True))
                 else:
                     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,
         # which is to prepare for extensions as they can add values and hence affect
         # 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))
 
         return VkEnum(name, values)




More information about the wine-cvs mailing list