Commit 0860c918 authored by Robert Bradshaw's avatar Robert Bradshaw

Inherit C++ nested types.

parent ae11b63c
......@@ -2299,6 +2299,11 @@ class CppClassScope(Scope):
modifiers=base_entry.func_modifiers,
utility_code=base_entry.utility_code)
entry.is_inherited = 1
for base_entry in base_scope.type_entries:
entry = self.declare_type(base_entry.name, base_entry.type,
base_entry.pos, base_entry.cname,
base_entry.visibility)
entry.is_inherited = 1
def specialize(self, values, type_entry):
scope = CppClassScope(self.name, self.outer_scope)
......
......@@ -22,6 +22,10 @@ cdef extern from "cpp_nested_classes_support.h":
enum MyEnum:
value
cdef cppclass SpecializedTypedClass(TypedClass[double]):
pass
def test_nested_classes():
"""
>>> test_nested_classes()
......@@ -80,3 +84,42 @@ def test_nested_struct(x):
assert s.int_value == x
s.typed_value = x
return s.typed_value
def test_typed_nested_sub_typedef(x):
"""
>>> test_typed_nested_sub_typedef(4)
4.0
"""
cdef SpecializedTypedClass.MyType dx = x
return dx
def test_nested_sub_enum(SpecializedTypedClass.MyEnum x):
"""
>>> test_nested_sub_enum(4)
False
"""
return x == 0
def test_nested_sub_union(x):
"""
>>> test_nested_sub_union(2)
2.0
"""
cdef SpecializedTypedClass.MyUnion u
u.int_value = x
assert u.int_value == x
u.typed_value = x
return u.typed_value
def test_nested_sub_struct(x):
"""
>>> test_nested_sub_struct(2)
2.0
"""
cdef SpecializedTypedClass.MyStruct s
s.int_value = x
assert s.int_value == x
s.typed_value = x
return s.typed_value
......@@ -33,3 +33,5 @@ public:
};
typedef T MyType;
};
class SpecializedTypedClass : public TypedClass<double> {};
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