%shared_ptr support improvements for classes in an inheritance chain
Fix %shared_ptr support for private and protected inheritance. - Remove unnecessary Warning 520: Derived class 'Derived' of 'Base' is not similarly marked as a smart pointer - Do not generate code that attempts to cast up the inheritance chain in the type system runtime in such cases as it doesn't compile and can't be used. Remove unnecessary warning 520 for %shared_ptr when the base class is ignored.
This commit is contained in:
parent
803ba97a83
commit
fc2205e64d
3 changed files with 87 additions and 29 deletions
|
|
@ -166,3 +166,51 @@ public:
|
|||
int HiddenPrivateDestructor::DeleteCount = 0;
|
||||
%}
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// Non-public inheritance and shared_ptr
|
||||
/////////////////////////////////////////////////
|
||||
|
||||
#if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED)
|
||||
%shared_ptr(Base)
|
||||
// No %shared_ptr(DerivedPrivate1) to check Warning 520 does not appear
|
||||
// No %shared_ptr(DerivedProtected1) to check Warning 520 does not appear
|
||||
%shared_ptr(DerivedPrivate2)
|
||||
%shared_ptr(DerivedProtected2)
|
||||
|
||||
%ignore Base2;
|
||||
%shared_ptr(DerivedPublic)
|
||||
#endif
|
||||
|
||||
%inline %{
|
||||
class Base {
|
||||
public:
|
||||
virtual int b() = 0;
|
||||
};
|
||||
|
||||
class DerivedProtected1 : protected Base {
|
||||
public:
|
||||
virtual int b() { return 20; }
|
||||
};
|
||||
class DerivedPrivate1 : private Base {
|
||||
public:
|
||||
virtual int b() { return 20; }
|
||||
};
|
||||
|
||||
class DerivedProtected2 : protected Base {
|
||||
public:
|
||||
virtual int b() { return 20; }
|
||||
};
|
||||
class DerivedPrivate2 : private Base {
|
||||
public:
|
||||
virtual int b() { return 20; }
|
||||
};
|
||||
|
||||
class Base2 {
|
||||
public:
|
||||
virtual int b2() = 0;
|
||||
};
|
||||
class DerivedPublic : public Base2 {
|
||||
public:
|
||||
virtual int b2() { return 20; }
|
||||
};
|
||||
%}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue