Commit 51a31d88 authored by Robert Bradshaw's avatar Robert Bradshaw

make overridable a type-level property, now overriding functions must agree

parent 7f291b65
...@@ -1550,7 +1550,7 @@ class SimpleCallNode(ExprNode): ...@@ -1550,7 +1550,7 @@ class SimpleCallNode(ExprNode):
result = "%s(%s)" % (self.function.result_code, result = "%s(%s)" % (self.function.result_code,
join(arg_list_code, ",")) join(arg_list_code, ","))
if self.wrapper_call or \ 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) result = "(%s = 1, %s)" % (Naming.skip_dispatch_cname, result)
return result return result
...@@ -1770,7 +1770,6 @@ class AttributeNode(ExprNode): ...@@ -1770,7 +1770,6 @@ class AttributeNode(ExprNode):
ubcm_entry.is_cfunction = 1 ubcm_entry.is_cfunction = 1
ubcm_entry.func_cname = entry.func_cname ubcm_entry.func_cname = entry.func_cname
ubcm_entry.is_unbound_cmethod = 1 ubcm_entry.is_unbound_cmethod = 1
ubcm_entry.is_overridable = entry.is_overridable
self.mutate_into_name_node(env, ubcm_entry, None) self.mutate_into_name_node(env, ubcm_entry, None)
return 1 return 1
return 0 return 0
......
...@@ -761,6 +761,7 @@ class CFuncDefNode(FuncDefNode): ...@@ -761,6 +761,7 @@ class CFuncDefNode(FuncDefNode):
# may be different if we're overriding a C method inherited # may be different if we're overriding a C method inherited
# from the base type of an extension type. # from the base type of an extension type.
self.type = type self.type = type
type.is_overridable = self.overridable
name = name_declarator.name name = name_declarator.name
cname = name_declarator.cname cname = name_declarator.cname
self.entry = env.declare_cfunction( self.entry = env.declare_cfunction(
...@@ -768,7 +769,6 @@ class CFuncDefNode(FuncDefNode): ...@@ -768,7 +769,6 @@ class CFuncDefNode(FuncDefNode):
cname = cname, visibility = self.visibility, cname = cname, visibility = self.visibility,
defining = self.body is not None, defining = self.body is not None,
api = self.api) api = self.api)
self.entry.is_overridable = self.overridable
self.return_type = type.return_type self.return_type = type.return_type
if self.overridable: if self.overridable:
......
...@@ -535,7 +535,7 @@ class CFuncType(CType): ...@@ -535,7 +535,7 @@ class CFuncType(CType):
def __init__(self, return_type, args, has_varargs = 0, def __init__(self, return_type, args, has_varargs = 0,
exception_value = None, exception_check = 0, calling_convention = "", 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.return_type = return_type
self.args = args self.args = args
self.has_varargs = has_varargs self.has_varargs = has_varargs
...@@ -544,6 +544,7 @@ class CFuncType(CType): ...@@ -544,6 +544,7 @@ class CFuncType(CType):
self.calling_convention = calling_convention self.calling_convention = calling_convention
self.nogil = nogil self.nogil = nogil
self.with_gil = with_gil self.with_gil = with_gil
self.is_overridable = is_overridable
def __repr__(self): def __repr__(self):
arg_reprs = map(repr, self.args) arg_reprs = map(repr, self.args)
...@@ -572,6 +573,8 @@ class CFuncType(CType): ...@@ -572,6 +573,8 @@ class CFuncType(CType):
return 1 return 1
if not other_type.is_cfunction: if not other_type.is_cfunction:
return 0 return 0
if self.is_overridable != other_type.is_overridable:
return 0
nargs = len(self.args) nargs = len(self.args)
if nargs <> len(other_type.args): if nargs <> len(other_type.args):
return 0 return 0
......
...@@ -109,6 +109,7 @@ class Entry: ...@@ -109,6 +109,7 @@ class Entry:
defined_in_pxd = 0 defined_in_pxd = 0
api = 0 api = 0
utility_code = None utility_code = None
is_overridable = 0
def __init__(self, name, cname, type, pos = None, init = None): def __init__(self, name, cname, type, pos = None, init = None):
self.name = name self.name = name
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment