From: Robert Bradshaw Date: Thu, 1 Nov 2007 09:45:45 +0000 (-0700) Subject: make overridable a type-level property, now overriding functions must agree X-Git-Tag: 0.9.6.14~29^2~101 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=51a31d8804b6a6526e208941f93a7ccbe5f2bbe2;p=cython.git make overridable a type-level property, now overriding functions must agree --- diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index cd1313e2..7f4dc1be 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -1550,7 +1550,7 @@ class SimpleCallNode(ExprNode): result = "%s(%s)" % (self.function.result_code, join(arg_list_code, ",")) if self.wrapper_call or \ - self.function.entry.is_unbound_cmethod and self.function.entry.is_overridable: + self.function.entry.is_unbound_cmethod and self.function.entry.type.is_overridable: result = "(%s = 1, %s)" % (Naming.skip_dispatch_cname, result) return result @@ -1770,7 +1770,6 @@ class AttributeNode(ExprNode): ubcm_entry.is_cfunction = 1 ubcm_entry.func_cname = entry.func_cname ubcm_entry.is_unbound_cmethod = 1 - ubcm_entry.is_overridable = entry.is_overridable self.mutate_into_name_node(env, ubcm_entry, None) return 1 return 0 diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 3a69f00f..83ef12b4 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -761,6 +761,7 @@ class CFuncDefNode(FuncDefNode): # may be different if we're overriding a C method inherited # from the base type of an extension type. self.type = type + type.is_overridable = self.overridable name = name_declarator.name cname = name_declarator.cname self.entry = env.declare_cfunction( @@ -768,7 +769,6 @@ class CFuncDefNode(FuncDefNode): cname = cname, visibility = self.visibility, defining = self.body is not None, api = self.api) - self.entry.is_overridable = self.overridable self.return_type = type.return_type if self.overridable: diff --git a/Cython/Compiler/PyrexTypes.py b/Cython/Compiler/PyrexTypes.py index 3874474e..2f8baf2b 100644 --- a/Cython/Compiler/PyrexTypes.py +++ b/Cython/Compiler/PyrexTypes.py @@ -535,7 +535,7 @@ class CFuncType(CType): def __init__(self, return_type, args, has_varargs = 0, exception_value = None, exception_check = 0, calling_convention = "", - nogil = 0, with_gil = 0): + nogil = 0, with_gil = 0, is_overridable = 0): self.return_type = return_type self.args = args self.has_varargs = has_varargs @@ -544,6 +544,7 @@ class CFuncType(CType): self.calling_convention = calling_convention self.nogil = nogil self.with_gil = with_gil + self.is_overridable = is_overridable def __repr__(self): arg_reprs = map(repr, self.args) @@ -572,6 +573,8 @@ class CFuncType(CType): return 1 if not other_type.is_cfunction: return 0 + if self.is_overridable != other_type.is_overridable: + return 0 nargs = len(self.args) if nargs <> len(other_type.args): return 0 diff --git a/Cython/Compiler/Symtab.py b/Cython/Compiler/Symtab.py index af4e2070..3a580778 100644 --- a/Cython/Compiler/Symtab.py +++ b/Cython/Compiler/Symtab.py @@ -109,6 +109,7 @@ class Entry: defined_in_pxd = 0 api = 0 utility_code = None + is_overridable = 0 def __init__(self, name, cname, type, pos = None, init = None): self.name = name