add director+thread case

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7147 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2005-04-08 06:48:27 +00:00
commit 30bd3c6834
2 changed files with 51 additions and 0 deletions

View file

@ -0,0 +1,40 @@
%module(directors="1") director_thread
%{
#include <pthread.h>
#include <iostream>
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<Foo*>(t);
while (1) {
sleep(1);
std::cout << "invoked" << std::endl;
f->do_foo();
}
}
}

View file

@ -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()