Commit 1c7b2328 authored by Xavier Thompson's avatar Xavier Thompson

Generate code to correctly resolve cypclass methods according to MRO

parent a4a225bd
......@@ -7421,6 +7421,8 @@ class AttributeNode(ExprNode):
if obj.type.is_builtin_type and self.entry and self.entry.is_variable:
# accessing a field of a builtin type, need to cast better than result_as() does
obj_code = obj.type.cast_code(obj.result(), to_object_struct = True)
if obj.type.is_cyp_class and self.entry and self.entry.from_type:
self.member = "%s::%s" % (self.entry.from_type.empty_declaration_code(), self.member)
return "%s%s%s" % (obj_code, self.op, self.member)
def generate_result_code(self, code):
......
......@@ -142,6 +142,11 @@ class Entry(object):
#
# is_default boolean This entry is a compiler-generated default and
# is not user-defined (e.g default contructor)
#
# from_type CypClassType or CppClassType or CStructOrUnionType or None
# The type in which this entry was first declared
# when it is later inherited by a cypclass
#
# mro_index integer The index of the type where this entry was originally
# declared in the mro of the cypclass where it is now
......@@ -232,6 +237,7 @@ class Entry(object):
self.inner_entries = []
self.defining_entry = self
self.mro_index = 0
self.from_type = None
def __repr__(self):
return "%s(<%x>, name=%s, type=%s)" % (type(self).__name__, id(self), self.name, self.type)
......@@ -509,12 +515,14 @@ class Scope(object):
if alt_entry.is_default:
previous_alternative_indices.append(index)
ccp_override_allowed = True
continue
# Any inherited method is visible
# until overloaded by a method with the same signature
if alt_entry.is_inherited:
previous_alternative_indices.append(index)
cpp_override_allowed = True
continue
if cpp_override_allowed:
# C++ function/method overrides with different signatures are ok.
......@@ -541,6 +549,7 @@ class Scope(object):
entry = Entry(name, cname, type, pos = pos)
if from_type and self.is_cyp_class_scope:
entry.mro_index = self.parent_type.mro().index(from_type)
entry.from_type = from_type
entry.in_cinclude = self.in_cinclude
entry.create_wrapper = create_wrapper
......
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