Commit af8c3c1d authored by Xavier Thompson's avatar Xavier Thompson

Improve declaration analysis of cypclass methods

parent e9dadd66
......@@ -2470,6 +2470,7 @@ class CFuncDefNode(FuncDefNode):
# is_const_method whether this is a const method
# is_static_method whether this is a static method
# is_c_class_method whether this is a cclass method
# is_cyp_class_method whether this is a cypclass method
child_attrs = ["base_type", "declarator", "body", "py_func_stat", "decorators"]
outer_attrs = ["decorators"]
......@@ -2508,6 +2509,7 @@ class CFuncDefNode(FuncDefNode):
"Cannot handle %s decorators yet" % type(func).__name__)
self.is_c_class_method = env.is_c_class_scope
self.is_cyp_class_method = env.is_cpp_class_scope and env.parent_type.is_cyp_class
if self.directive_locals is None:
self.directive_locals = {}
self.directive_locals.update(env.directives.get('locals', {}))
......@@ -2549,8 +2551,7 @@ class CFuncDefNode(FuncDefNode):
# It is reinserted here, as __new__ MUST be static in a cypclass,
# so there is no self arg (the first arg is actually the allocator).
if env.is_cpp_class_scope and env.parent_type.is_cyp_class\
and name in ("__new__", "__alloc__") and not self.is_static_method:
if self.is_cyp_class_method and name in ("__new__", "__alloc__") and not self.is_static_method:
self.is_static_method = 1
if declarator.skipped_self:
_name, _type, _pos, _arg = declarator.skipped_self
......@@ -2630,8 +2631,7 @@ class CFuncDefNode(FuncDefNode):
# An error will be produced in the cdef function
self.overridable = False
if env.is_cpp_class_scope and env.parent_type.is_cyp_class\
and not declarator.skipped_self and not self.is_static_method:
if self.is_cyp_class_method and not declarator.skipped_self and not self.is_static_method:
# It means we have a cypclass method without the self argument
# => shout
error(self.pos, "Cypclass methods must have a self argument")
......@@ -2650,6 +2650,7 @@ class CFuncDefNode(FuncDefNode):
self_locking_state.is_rlocked = self.is_const_method
self_locking_state.is_wlocked = not self.is_const_method
def declare_cpdef_wrapper(self, env):
if self.overridable:
if self.is_static_method:
......
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