diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 6e1a463c97b23a545eb03d4a5981fabdd91b135f..0ac3d9a69e046ecd6059eb3a464d00ee970495fa 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -7660,7 +7660,10 @@ class AttributeNode(ExprNode): obj_code = obj.type.cast_code(obj.result(), to_object_struct = True) if obj.type.is_cpp_class and self.entry and self.entry.is_cfunction: # the entry might have been resolved to an overladed alternative in the meantime - self.member = self.entry.cname + if obj.type.is_cyp_class and self.entry.type.is_static_method and self.entry.static_cname is not None: + self.member = self.entry.static_cname + else: + self.member = self.entry.cname return "%s%s%s" % (obj_code, self.op, self.member) def generate_result_code(self, code): diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py index 41237a94863ac685ea5fec80b1985d57db7e55e2..475ba5ea520f796709cc30e7c1b72298123eec3e 100644 --- a/Cython/Compiler/ModuleNode.py +++ b/Cython/Compiler/ModuleNode.py @@ -1041,11 +1041,9 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): continue elif attr.type.is_cyp_class: cname = "%s = NULL" % cname + code.putln("%s;" % attr.type.declaration_code(cname)) if type.is_cyp_class and attr.type.is_cfunction and attr.type.is_static_method and attr.static_cname is not None: - code.putln("%s;" % attr.type.declaration_code(attr.static_cname)) self.generate_cyp_class_static_method_resolution(attr, code) - else: - code.putln("%s;" % attr.type.declaration_code(cname)) is_implementing = 'init_module' in code.globalstate.parts @@ -1191,14 +1189,16 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): arg_decls.append(e.type.op_arg_struct.declaration_code(opt_name)) arg_names.append(opt_name) - header = e.type.function_header_code(e.cname, ", ".join(arg_decls)) + cname = e.cname if not e.type.is_static_method else e.static_cname + + header = e.type.function_header_code(cname, ", ".join(arg_decls)) if not e.name.startswith("operator "): header = e.type.return_type.declaration_code(header) return_code = "" if e.type.return_type.is_void else "return " resolution = e.from_type.empty_declaration_code() - body = "%s%s::%s(%s);" % (return_code, resolution, e.cname, ", ".join(arg_names)) + body = "%s%s::%s(%s);" % (return_code, resolution, cname, ", ".join(arg_names)) code.putln("virtual %s%s {%s}" % (modifiers, header, body)) if inherited_methods: @@ -1219,13 +1219,13 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): arg_decls.append(func_type.op_arg_struct.declaration_code(opt_name)) arg_names.append(opt_name) - header = func_type.function_header_code(static_method.cname, ", ".join(arg_decls)) + header = func_type.function_header_code(static_method.static_cname, ", ".join(arg_decls)) if not static_method.name.startswith("operator "): header = func_type.return_type.declaration_code(header) return_code = "" if func_type.return_type.is_void else "return " - body = "%s%s(%s);" % (return_code, static_method.static_cname, ", ".join(arg_names)) + body = "%s%s(%s);" % (return_code, static_method.cname, ", ".join(arg_names)) code.putln("virtual %s%s {%s}" % (modifiers, header, body)) diff --git a/Cython/Compiler/Symtab.py b/Cython/Compiler/Symtab.py index a6cf943a6fb5e114976783412aebe5e59ce1f54a..2bc186e2ea4223fe1a5e9849020d2a6e49c14c8a 100644 --- a/Cython/Compiler/Symtab.py +++ b/Cython/Compiler/Symtab.py @@ -2848,9 +2848,6 @@ class CppClassScope(Scope): entry.is_cfunction = type.is_cfunction if type.is_cfunction and self.type: if not self.type.get_fused_types(): - if (self.parent_type.is_cyp_class and type.is_static_method and name not in ("<alloc>", "__new__")): - cname = "%s__static__%s" % (Naming.func_prefix, cname) - entry.static_cname = cname entry.func_cname = "%s::%s" % (self.type.empty_declaration_code(), cname) if name != "this" and (defining or name != "<init>" or self.parent_type.is_cyp_class): self.var_entries.append(entry) @@ -3030,6 +3027,9 @@ class CppClassScope(Scope): cname=cname, visibility=visibility) entry.original_name = original_name + if (self.parent_type.is_cyp_class and type.is_static_method and name not in ("<alloc>", "__new__")): + entry.static_cname = "%s__static__%s" % (Naming.func_prefix, cname) + if reify: self.reify_method(entry) #if prev_entry and not defining: