Commit d72a42fd authored by gsamain's avatar gsamain

Rewrite return type when inheriting some c++ inplace operators

parent ace19b9b
......@@ -2587,6 +2587,7 @@ class CppClassScope(Scope):
# to work with this type.
for base_entry in \
base_scope.inherited_var_entries + base_scope.var_entries:
base_entry_type = base_entry.type
#constructor/destructor is not inherited
if base_entry.name == "<del>"\
or base_entry.name == "<init>" and not self.parent_type.is_cyp_class\
......@@ -2600,6 +2601,14 @@ class CppClassScope(Scope):
return_type=self.parent_type)
wrapper_entry.is_inherited = 1
#print base_entry.name, self.entries
elif base_entry.name.startswith("operator")\
and base_entry.name[8:] in ('+=', '-=', '*=', '/=', '%=', '<<=', '>>=', '&=', '|=', '^=')\
and self.parent_type.is_cyp_class:
# Rewrite return type for inplace operators.
# This is needed for a correct type inference.
base_entry_type = PyrexTypes.CFuncType(self.parent_type, base_entry_type.args, nogil=1,
has_varargs=base_entry_type.has_varargs,
optional_arg_count=base_entry_type.optional_arg_count)
elif base_entry.name == "__new__" and self.parent_type.is_cyp_class:
# Rewrite first argument for __new__
alloc_type = PyrexTypes.CPtrType(PyrexTypes.CFuncType(
......@@ -2629,7 +2638,7 @@ class CppClassScope(Scope):
if base_entry.name in self.entries:
base_entry.name # FIXME: is there anything to do in this case?
entry = self.declare(base_entry.name, base_entry.cname,
base_entry.type, None, 'extern')
base_entry_type, None, 'extern')
entry.is_variable = 1
entry.is_inherited = 1
entry.is_cfunction = base_entry.is_cfunction
......
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