new test to test smart pointers with virtual methods and hidden methods
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9478 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
98ba2f78c5
commit
352bcb7d64
1 changed files with 36 additions and 0 deletions
36
SWIG/Examples/test-suite/smart_pointer_inherit.i
Normal file
36
SWIG/Examples/test-suite/smart_pointer_inherit.i
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
%module smart_pointer_inherit
|
||||
|
||||
%inline %{
|
||||
|
||||
namespace hi
|
||||
{
|
||||
struct Base
|
||||
{
|
||||
Base(int i) : val(i) {}
|
||||
virtual ~Base() { }
|
||||
virtual int value() = 0;
|
||||
virtual int value2() { return val; }
|
||||
int valuehide() { return val; }
|
||||
int val;
|
||||
};
|
||||
|
||||
struct Derived : Base
|
||||
{
|
||||
Derived(int i) : Base(i) {}
|
||||
virtual int value() { return val; }
|
||||
int valuehide() { return -1; }
|
||||
};
|
||||
|
||||
template <typename T> struct SmartPtr
|
||||
{
|
||||
SmartPtr(T *t) : ptr(t) {}
|
||||
T * operator->() const { return ptr; }
|
||||
private:
|
||||
T *ptr;
|
||||
};
|
||||
}
|
||||
%}
|
||||
|
||||
%template(SmartBase) hi::SmartPtr<hi::Base>;
|
||||
%template(SmartDerived) hi::SmartPtr<hi::Derived>;
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue