From 345dda1a3df50c01bc69ca1dcf840aed95b39994 Mon Sep 17 00:00:00 2001 From: Mark Lobodzinski Date: Mon, 3 Apr 2017 16:58:04 -0600 Subject: [PATCH] scripts: Add object type enum generation to helper Extended the helper_file_generator to produce an object type enum header file. Change-Id: I8013091b34028522d8f50ef3941d7021b262613c --- scripts/helper_file_generator.py | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/scripts/helper_file_generator.py b/scripts/helper_file_generator.py index 0d35b83..bb323da 100644 --- a/scripts/helper_file_generator.py +++ b/scripts/helper_file_generator.py @@ -83,6 +83,7 @@ class HelperFileOutputGenerator(OutputGenerator): self.structNames = [] # List of Vulkan struct typenames self.structTypes = dict() # Map of Vulkan struct typename to required VkStructureType self.structMembers = [] # List of StructMemberData records for all Vulkan structs + self.object_types = [] # List of all handle types # Named tuples to store struct and command data self.StructType = namedtuple('StructType', ['name', 'value']) self.CommandParam = namedtuple('CommandParam', ['type', 'name', 'ispointer', 'isstaticarray', 'isconst', 'iscount', 'len', 'extstructs', 'cdecl']) @@ -159,7 +160,9 @@ class HelperFileOutputGenerator(OutputGenerator): # If the type is a struct type, traverse the imbedded tags generating a structure. # Otherwise, emit the tag text. category = typeElem.get('category') - if (category == 'struct' or category == 'union'): + if category == 'handle': + self.object_types.append(name) + elif (category == 'struct' or category == 'union'): self.structNames.append(name) self.genStruct(typeinfo, name) # @@ -511,6 +514,31 @@ class HelperFileOutputGenerator(OutputGenerator): safe_struct_header += '#endif // %s\n' % item.ifdef_protect return safe_struct_header # + # Combine object types helper header file preamble with body text and return + def GenerateObjectTypesHelperHeader(self): + object_types_helper_header = '\n' + object_types_helper_header += '#pragma once\n' + object_types_helper_header += '\n' + object_types_helper_header += self.GenerateObjectTypesHeader() + return object_types_helper_header + # + # Object types header: create object enum type header file + def GenerateObjectTypesHeader(self): + object_types_header = '' + object_types_header += 'typedef enum VulkanObjectType {\n' + object_types_header += ' kVulkanObjectTypeUnknown = 0,\n' + enum_num = 1 + + for item in self.object_types: + fixup_name = item[2:] + object_types_header += ' kVulkanObjectType%s' % fixup_name + object_types_header += ' = %d,\n' % enum_num + enum_num += 1 + object_types_header += ' kVulkanObjectTypeMax = %d,\n' % enum_num + object_types_header += '} VulkanObjectType;\n' + + return object_types_header + # # Determine if a structure needs a safe_struct helper function # That is, it has an sType or one of its members is a pointer def NeedSafeStruct(self, structure): @@ -699,6 +727,8 @@ class HelperFileOutputGenerator(OutputGenerator): return self.GenerateSafeStructHelperHeader() elif self.helper_file_type == 'safe_struct_source': return self.GenerateSafeStructHelperSource() + elif self.helper_file_type == 'object_types_header': + return self.GenerateObjectTypesHelperHeader() else: return 'Bad Helper File Generator Option %s' % self.helper_file_type -- 2.7.4