From 2b4c1cccf30d41f2d0b4a6fe6d190919c47e8046 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Tue, 29 Mar 2016 10:40:18 -0700 Subject: glapi: fix singleton comparisons to use 'is' in python Python has two equality comparitors, 'is' and '=='. The difference is that 'is' determines whether instance A *is* instance B, while '==' determines if instance A *has the same value as* instance B. Comparisons with singletons (the notable ones being None, True, and False) should always by done with 'is', basically everything else should always be done with '=='. Signed-off-by: Dylan Baker --- src/mapi/glapi/gen/glX_XML.py | 2 +- src/mapi/glapi/gen/glX_proto_send.py | 8 ++++---- src/mapi/glapi/gen/glX_proto_size.py | 6 +++--- src/mapi/glapi/gen/glX_server_table.py | 2 +- src/mapi/glapi/gen/gl_XML.py | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/mapi/glapi/gen/glX_XML.py b/src/mapi/glapi/gen/glX_XML.py index 9090b76c65..580a2411c9 100644 --- a/src/mapi/glapi/gen/glX_XML.py +++ b/src/mapi/glapi/gen/glX_XML.py @@ -391,7 +391,7 @@ class glx_function(gl_XML.gl_function): name of the equivalent vector (e.g., glVertex3fv for glVertex3f) function.""" - if self.vectorequiv == None: + if self.vectorequiv is None: return self.name else: return self.vectorequiv diff --git a/src/mapi/glapi/gen/glX_proto_send.py b/src/mapi/glapi/gen/glX_proto_send.py index 8a656c5046..9dcffa67ac 100644 --- a/src/mapi/glapi/gen/glX_proto_send.py +++ b/src/mapi/glapi/gen/glX_proto_send.py @@ -111,14 +111,14 @@ class glx_pixel_function_stub(glX_XML.glx_function): self.images.append(p) p.height = "height" - if p.img_yoff == None: + if p.img_yoff is None: p.img_yoff = "yoffset" if p.depth: - if p.extent == None: + if p.extent is None: p.extent = "extent" - if p.img_woff == None: + if p.img_woff is None: p.img_woff = "woffset" pad_name = func.pad_after(p) @@ -845,7 +845,7 @@ class PrintGlxProtoStubs(glX_proto_common.glx_print_proto): # of them, special case them with generic functions. On # x86, this saves about 26KB in the libGL.so binary. - if f.variable_length_parameter() == None and len(f.parameters) == 1: + if f.variable_length_parameter() is None and len(f.parameters) == 1: p = f.parameters[0] if p.is_pointer(): cmdlen = f.command_fixed_length() diff --git a/src/mapi/glapi/gen/glX_proto_size.py b/src/mapi/glapi/gen/glX_proto_size.py index d49929421d..c157c00388 100644 --- a/src/mapi/glapi/gen/glX_proto_size.py +++ b/src/mapi/glapi/gen/glX_proto_size.py @@ -91,10 +91,10 @@ class glx_enum_function(object): self.count[count].append(e.value) def signature(self): - if self.sig == None: + if self.sig is None: self.sig = "" for i in self.count: - if i == None: + if i is None: raise RuntimeError("i is None. WTF?") self.count[i].sort() @@ -237,7 +237,7 @@ class glx_server_enum_function(glx_enum_function): self.function = func def signature(self): - if self.sig == None: + if self.sig is None: sig = glx_enum_function.signature(self) p = self.function.variable_length_parameter() diff --git a/src/mapi/glapi/gen/glX_server_table.py b/src/mapi/glapi/gen/glX_server_table.py index 9d5542649d..880ab8752c 100644 --- a/src/mapi/glapi/gen/glX_server_table.py +++ b/src/mapi/glapi/gen/glX_server_table.py @@ -355,7 +355,7 @@ class PrintGlxDispatchTables(glX_proto_common.glx_print_proto): def printBody(self, api): for f in api.functionIterateAll(): - if not f.ignore and f.vectorequiv == None: + if not f.ignore and f.vectorequiv is None: if f.glx_rop != 0: self.rop_functions.append(f.glx_rop, f) if f.glx_sop != 0: diff --git a/src/mapi/glapi/gen/gl_XML.py b/src/mapi/glapi/gen/gl_XML.py index b1f8eccd34..f857ad6271 100644 --- a/src/mapi/glapi/gen/gl_XML.py +++ b/src/mapi/glapi/gen/gl_XML.py @@ -914,7 +914,7 @@ class gl_api(object): for func in self.functionIterateAll(): [cat_name, cat_number] = self.category_dict[func.name] - if (cat == None) or (cat == cat_name): + if cat is None or cat == cat_name: [func_cat_type, key] = classify_category(cat_name, cat_number) if not lists[func_cat_type].has_key(key): -- cgit v1.2.3