Commit f49fc8fe authored by Xavier Thompson's avatar Xavier Thompson

Make cypclass always inherit virtually from all bases

parent baa6c7f1
......@@ -1005,8 +1005,12 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.put("struct %s" % type.cname)
if type.base_classes:
base_class_list = [base_class.empty_declaration_code() for base_class in type.base_classes]
if type.is_cyp_class and (type.base_classes[-1] is cy_object_type or type.base_classes[-1].name == "ActhonActivableClass"):
base_class_list[-1] = "virtual " + base_class_list[-1]
# if type.is_cyp_class and (type.base_classes[-1] is cy_object_type or type.base_classes[-1].name == "ActhonActivableClass"):
# base_class_list[-1] = "virtual " + base_class_list[-1]
if type.is_cyp_class:
base_class_decl = ",virtual public ".join(base_class_list)
code.put(" : virtual public %s" % base_class_decl)
else:
base_class_decl = ", public ".join(base_class_list)
code.put(" : public %s" % base_class_decl)
code.putln(" {")
......
......@@ -32,13 +32,36 @@ cdef cypclass Diamond(InplaceAddition, InplaceSubstraction):
InplaceAddition.__init__(self, a)
InplaceSubstraction.__init__(self, b)
def test_non_virtual_inheritance():
# def test_non_virtual_inheritance():
# """
# >>> test_non_virtual_inheritance()
# 1
# 2
# 3
# 0
# """
# cdef Diamond diamond = Diamond(1, 2)
#
# diamond.print_IA_base()
# diamond.print_IS_base()
#
# cdef InplaceAddition iadd_obj = InplaceAddition(2)
# cdef InplaceSubstraction isub_obj = InplaceSubstraction(2)
#
# diamond += iadd_obj
# diamond -= isub_obj
#
# diamond.print_IA_base()
# diamond.print_IS_base()
def test_virtual_inheritance():
"""
>>> test_non_virtual_inheritance()
1
>>> test_virtual_inheritance()
2
2
2
2
3
0
"""
cdef Diamond diamond = Diamond(1, 2)
......
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