Abstract directors and typemap fixes.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@5024 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
94c6b3ba6e
commit
c1b57370b6
10 changed files with 97 additions and 17 deletions
|
|
@ -101,6 +101,7 @@ CPP_TEST_CASES += \
|
|||
default_constructor \
|
||||
default_ns \
|
||||
default_ref \
|
||||
director_abstract \
|
||||
director_basic \
|
||||
director_exception \
|
||||
director_finalizer \
|
||||
|
|
|
|||
26
SWIG/Examples/test-suite/director_abstract.i
Normal file
26
SWIG/Examples/test-suite/director_abstract.i
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
%module(directors="1") director_abstract
|
||||
%{
|
||||
#include <string>
|
||||
|
||||
class Foo {
|
||||
public:
|
||||
virtual ~Foo() {}
|
||||
virtual std::string ping() = 0;
|
||||
virtual std::string pong() { return "Foo::pong();" + ping(); }
|
||||
};
|
||||
|
||||
%}
|
||||
|
||||
%include "typemaps.i"
|
||||
%include "exception.i"
|
||||
%include "std_string.i"
|
||||
|
||||
%feature("director") Foo;
|
||||
|
||||
class Foo {
|
||||
public:
|
||||
virtual ~Foo() {}
|
||||
virtual std::string ping() = 0;
|
||||
virtual std::string pong() { return "Foo::pong();" + ping(); }
|
||||
};
|
||||
|
||||
16
SWIG/Examples/test-suite/python/director_abstract_runme.py
Normal file
16
SWIG/Examples/test-suite/python/director_abstract_runme.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import director_abstract
|
||||
|
||||
class MyFoo(director_abstract.Foo):
|
||||
def ping(self):
|
||||
return "MyFoo::ping()"
|
||||
|
||||
|
||||
a = MyFoo()
|
||||
|
||||
if a.ping() != "MyFoo::ping()":
|
||||
raise RuntimeError, a.ping()
|
||||
|
||||
if a.pong() != "Foo::pong();MyFoo::ping()":
|
||||
raise RuntimeError, a.pong()
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue