From: Robert Bradshaw Date: Wed, 6 Oct 2010 09:52:01 +0000 (-0700) Subject: Get rid of unused __get__/__set__ warnings for cimported classes. X-Git-Tag: 0.14.alpha0~297 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=17111fa709ca24ac5aa639b3c85e86ac6b5d9c1a;p=cython.git Get rid of unused __get__/__set__ warnings for cimported classes. --- diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 5864b472..2288185c 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -899,13 +899,11 @@ class CVarDefNode(StatNode): # declarators [CDeclaratorNode] # in_pxd boolean # api boolean - # properties [entry] # decorators [cython.locals(...)] or None # directive_locals { string : NameNode } locals defined by cython.locals(...) child_attrs = ["base_type", "declarators"] - properties = () decorators = None directive_locals = {} @@ -921,7 +919,6 @@ class CVarDefNode(StatNode): # a property; made in AnalyseDeclarationsTransform). if (dest_scope.is_c_class_scope and self.visibility in ('public', 'readonly')): - self.properties = [] need_property = True else: need_property = False @@ -955,8 +952,7 @@ class CVarDefNode(StatNode): "Only 'extern' C variable declaration allowed in .pxd file") entry = dest_scope.declare_var(name, type, declarator.pos, cname = cname, visibility = visibility, is_cdef = 1) - if need_property: - self.properties.append(entry) + entry.needs_property = need_property class CStructOrUnionDefNode(StatNode): diff --git a/Cython/Compiler/ParseTreeTransforms.py b/Cython/Compiler/ParseTreeTransforms.py index fccba177..17bfb3f6 100644 --- a/Cython/Compiler/ParseTreeTransforms.py +++ b/Cython/Compiler/ParseTreeTransforms.py @@ -1018,6 +1018,20 @@ property NAME: self.visitchildren(node) self.env_stack.pop() return node + + def visit_CClassDefNode(self, node): + node = self.visit_ClassDefNode(node) + if node.scope and node.scope.implemented: + stats = [] + for entry in node.scope.var_entries: + if entry.needs_property: + property = self.create_Property(entry) + property.analyse_declarations(node.scope) + self.visit(property) + stats.append(property) + if stats: + node.body.stats += stats + return node def visit_FuncDefNode(self, node): self.seen_vars_stack.append(set()) @@ -1093,20 +1107,9 @@ property NAME: return node def visit_CVarDefNode(self, node): - # to ensure all CNameDeclaratorNodes are visited. self.visitchildren(node) - - if node.properties: - stats = [] - for entry in node.properties: - property = self.create_Property(entry) - property.analyse_declarations(node.dest_scope) - self.visit(property) - stats.append(property) - return StatListNode(pos=node.pos, stats=stats) - else: - return None + return None def create_Property(self, entry): if entry.visibility == 'public':