diff --git a/Examples/test-suite/python/director_thread.i b/Examples/test-suite/python/director_thread.i new file mode 100644 index 000000000..ec2bca923 --- /dev/null +++ b/Examples/test-suite/python/director_thread.i @@ -0,0 +1,40 @@ +%module(directors="1") director_thread + +%{ +#include +#include + +class Foo; +extern "C" void* working(void* t); +%} + + +%feature("director") Foo; + +%inline { + class Foo { + public: + virtual ~Foo() {} + + void run() { + pthread_t *t = new pthread_t; + pthread_create(t,NULL,working,this); + sleep(5); + } + + virtual void do_foo() { + std::cout << "foo" << std::endl; + } + }; +} + +%inline { + extern "C" void* working(void* t) { + Foo* f = static_cast(t); + while (1) { + sleep(1); + std::cout << "invoked" << std::endl; + f->do_foo(); + } + } +} diff --git a/Examples/test-suite/python/director_thread_runme.py b/Examples/test-suite/python/director_thread_runme.py new file mode 100644 index 000000000..bec902103 --- /dev/null +++ b/Examples/test-suite/python/director_thread_runme.py @@ -0,0 +1,11 @@ +from director_thread import Foo + +class Derived(Foo) : + def __init__(self): + Foo.__init__(self) + print "too" + def do_foo(self): + print "at drived class" + +d = Derived() +d.run()