diff options
author | MichaĆ Janiszewski <janisozaur+signed@gmail.com> | 2018-10-30 23:22:03 +0100 |
---|---|---|
committer | Lenny Komow <lenny@lunarg.com> | 2018-11-01 13:26:26 -0600 |
commit | af584f26fd35689b7678c2110a2b313ab4e969e0 (patch) | |
tree | 00f8410c220042cae831354b34c16ad1a4d979b8 | |
parent | 786bfe7ce231046649479019ca4b654be370287f (diff) | |
download | Vulkan-Loader-af584f26fd35689b7678c2110a2b313ab4e969e0.tar.gz Vulkan-Loader-af584f26fd35689b7678c2110a2b313ab4e969e0.tar.bz2 Vulkan-Loader-af584f26fd35689b7678c2110a2b313ab4e969e0.zip |
scripts: Compare to `None` using `is` operator
This is a trivial change that replaces `==` operator with `is` operator, following PEP 8 guideline:
> Comparisons to singletons like None should always be done with is or is not, never the equality operators.
https://legacy.python.org/dev/peps/pep-0008/#programming-recommendations
Change-Id: I4f9f6c921e4158365d4e41965bfcd43b7a3c07e0
-rw-r--r-- | scripts/dispatch_table_helper_generator.py | 2 | ||||
-rw-r--r-- | scripts/helper_file_generator.py | 14 | ||||
-rw-r--r-- | scripts/loader_extension_generator.py | 14 | ||||
-rw-r--r-- | scripts/loader_genvk.py | 2 |
4 files changed, 16 insertions, 16 deletions
diff --git a/scripts/dispatch_table_helper_generator.py b/scripts/dispatch_table_helper_generator.py index 1e2412c0..2ef96631 100644 --- a/scripts/dispatch_table_helper_generator.py +++ b/scripts/dispatch_table_helper_generator.py @@ -160,7 +160,7 @@ class DispatchTableHelperOutputGenerator(OutputGenerator): # Determine if this API should be ignored or added to the instance or device dispatch table def AddCommandToDispatchList(self, name, handle_type, protect, cmdinfo): handle = self.registry.tree.find("types/type/[name='" + handle_type + "'][@category='handle']") - if handle == None: + if handle is None: return if handle_type != 'VkInstance' and handle_type != 'VkPhysicalDevice' and name != 'vkGetInstanceProcAddr': self.device_dispatch_list.append((name, self.featureExtraProtect)) diff --git a/scripts/helper_file_generator.py b/scripts/helper_file_generator.py index f35ba405..9d7ecdb3 100644 --- a/scripts/helper_file_generator.py +++ b/scripts/helper_file_generator.py @@ -192,7 +192,7 @@ class HelperFileOutputGenerator(OutputGenerator): if self.helper_file_type == 'enum_string_header': value_set = set() for elem in groupElem.findall('enum'): - if elem.get('supported') != 'disabled' and elem.get('alias') == None: + if elem.get('supported') != 'disabled' and elem.get('alias') is None: value_set.add(elem.get('name')) self.enum_output += self.GenerateEnumStringConversion(groupName, value_set) elif self.helper_file_type == 'object_types_header': @@ -437,7 +437,7 @@ class HelperFileOutputGenerator(OutputGenerator): for item in self.structMembers: if self.NeedSafeStruct(item) == True: safe_struct_header += '\n' - if item.ifdef_protect != None: + if item.ifdef_protect is not None: safe_struct_header += '#ifdef %s\n' % item.ifdef_protect safe_struct_header += 'struct safe_%s {\n' % (item.name) for member in item.members: @@ -463,7 +463,7 @@ class HelperFileOutputGenerator(OutputGenerator): safe_struct_header += ' %s *ptr() { return reinterpret_cast<%s *>(this); }\n' % (item.name, item.name) safe_struct_header += ' %s const *ptr() const { return reinterpret_cast<%s const *>(this); }\n' % (item.name, item.name) safe_struct_header += '};\n' - if item.ifdef_protect != None: + if item.ifdef_protect is not None: safe_struct_header += '#endif // %s\n' % item.ifdef_protect return safe_struct_header # @@ -803,7 +803,7 @@ class HelperFileOutputGenerator(OutputGenerator): continue if item.name in wsi_structs: continue - if item.ifdef_protect != None: + if item.ifdef_protect is not None: safe_struct_body.append("#ifdef %s\n" % item.ifdef_protect) ss_name = "safe_%s" % item.name init_list = '' # list of members in struct constructor initializer @@ -1111,7 +1111,7 @@ class HelperFileOutputGenerator(OutputGenerator): init_copy = copy_construct_init.replace('src.', 'src->') init_construct = copy_construct_txt.replace('src.', 'src->') safe_struct_body.append("\nvoid %s::initialize(const %s* src)\n{\n%s%s}" % (ss_name, ss_name, init_copy, init_construct)) - if item.ifdef_protect != None: + if item.ifdef_protect is not None: safe_struct_body.append("#endif // %s\n" % item.ifdef_protect) return "\n".join(safe_struct_body) # @@ -1203,7 +1203,7 @@ class HelperFileOutputGenerator(OutputGenerator): if not info: continue - if item.ifdef_protect != None: + if item.ifdef_protect is not None: code.append('#ifdef %s' % item.ifdef_protect) code.append('// Map type {} to id {}'.format(typename, info.value)) @@ -1211,7 +1211,7 @@ class HelperFileOutputGenerator(OutputGenerator): id_decl=id_decl, id_member=id_member)) code.append(idmap_format.format(template=idmap, typename=typename, id_value=info.value, typedef=type_member)) - if item.ifdef_protect != None: + if item.ifdef_protect is not None: code.append('#endif // %s' % item.ifdef_protect) # Generate utilities for all types diff --git a/scripts/loader_extension_generator.py b/scripts/loader_extension_generator.py index 827c4598..199dee10 100644 --- a/scripts/loader_extension_generator.py +++ b/scripts/loader_extension_generator.py @@ -304,7 +304,7 @@ class LoaderExtensionOutputGenerator(OutputGenerator): handle = self.registry.tree.find("types/type/[name='" + handle_type + "'][@category='handle']") return_type = cmdinfo.elem.find('proto/type') - if (return_type != None and return_type.text == 'void'): + if (return_type is not None and return_type.text == 'void'): return_type = None cmd_params = [] @@ -326,7 +326,7 @@ class LoaderExtensionOutputGenerator(OutputGenerator): cmd_params.append(self.CommandParam(type=param_type, name=param_name, cdecl=param_cdecl)) - if handle != None and handle_type != 'VkInstance' and handle_type != 'VkPhysicalDevice': + if handle is not None and handle_type != 'VkInstance' and handle_type != 'VkPhysicalDevice': # The Core Vulkan code will be wrapped in a feature called VK_VERSION_#_# # For example: VK_VERSION_1_0 wraps the core 1.0 Vulkan functionality if 'VK_VERSION_' in extension_name: @@ -697,13 +697,13 @@ class LoaderExtensionOutputGenerator(OutputGenerator): if cur_cmd.name in PRE_INSTANCE_FUNCTIONS: mod_string = mod_string.replace(cur_cmd.name[2:] + '(\n', cur_cmd.name[2:] + '(\n const Vk' + cur_cmd.name[2:] + 'Chain* chain,\n') - if (cur_cmd.protect != None): + if (cur_cmd.protect is not None): terminators += '#ifdef %s\n' % cur_cmd.protect terminators += mod_string terminators += '\n' - if (cur_cmd.protect != None): + if (cur_cmd.protect is not None): terminators += '#endif // %s\n' % cur_cmd.protect terminators += '\n' @@ -960,7 +960,7 @@ class LoaderExtensionOutputGenerator(OutputGenerator): physdev_type_to_replace = 'VkPhysicalDevice' physdev_name_replacement = 'phys_dev_term->phys_dev' - if (ext_cmd.return_type != None): + if (ext_cmd.return_type is not None): return_prefix += 'return ' has_return_type = True @@ -1041,7 +1041,7 @@ class LoaderExtensionOutputGenerator(OutputGenerator): count += 1 funcs += ');\n' if ext_cmd.ext_name in NULL_CHECK_EXT_NAMES: - if ext_cmd.return_type != None: + if ext_cmd.return_type is not None: funcs += ' } else {\n' funcs += ' return VK_SUCCESS;\n' funcs += ' }\n' @@ -1273,7 +1273,7 @@ class LoaderExtensionOutputGenerator(OutputGenerator): count += 1 funcs += ');\n' if ext_cmd.ext_name in NULL_CHECK_EXT_NAMES: - if ext_cmd.return_type != None: + if ext_cmd.return_type is not None: funcs += ' } else {\n' funcs += ' return VK_SUCCESS;\n' funcs += ' }\n' diff --git a/scripts/loader_genvk.py b/scripts/loader_genvk.py index ab0ce8a2..3ef6f8fc 100644 --- a/scripts/loader_genvk.py +++ b/scripts/loader_genvk.py @@ -32,7 +32,7 @@ def endTimer(timeit, msg): # Turn a list of strings into a regexp string matching exactly those strings def makeREstring(list, default = None): - if len(list) > 0 or default == None: + if len(list) > 0 or default is None: return '^(' + '|'.join(list) + ')$' else: return default |