Commit 14f8ffd2 authored by gsamain's avatar gsamain Committed by Xavier Thompson

Clean cppclass <init> management

parent 22cb8452
...@@ -4027,7 +4027,10 @@ class CppClassType(CType): ...@@ -4027,7 +4027,10 @@ class CppClassType(CType):
break break
func_type = CFuncType(self, [], exception_check='+', nogil=nogil) func_type = CFuncType(self, [], exception_check='+', nogil=nogil)
return self.scope.declare_cfunction(u'<init>', func_type, pos) entry = self.scope.declare_cfunction(u'<init>', func_type, pos)
# This flag is set in order to be able to override this default __init__ by a user-defined one
entry.is_inherited = 1
return entry
def check_nullary_constructor(self, pos, msg="stack allocated"): def check_nullary_constructor(self, pos, msg="stack allocated"):
constructor = self.scope.lookup(u'<init>') constructor = self.scope.lookup(u'<init>')
......
...@@ -485,11 +485,7 @@ class Scope(object): ...@@ -485,11 +485,7 @@ class Scope(object):
if type.is_cfunction and old_entry.type.is_cfunction and self.is_cpp_class_scope: if type.is_cfunction and old_entry.type.is_cfunction and self.is_cpp_class_scope:
for index, alt_entry in enumerate(old_entry.all_alternatives()): for index, alt_entry in enumerate(old_entry.all_alternatives()):
if type.compatible_signature_with(alt_entry.type): if type.compatible_signature_with(alt_entry.type):
if name == '<init>' and not type.args: if alt_entry.is_inherited:
# Cython pre-declares the no-args constructor - allow later user definitions.
old_index = index
cpp_override_allowed = True
elif alt_entry.is_inherited:
old_index = index old_index = index
cpp_override_allowed = True cpp_override_allowed = True
break break
......
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