Improve cpp11_function_objects test for python

This commit is contained in:
Yann Diorcet 2014-10-11 20:20:10 +02:00
commit aeacff3b14
2 changed files with 23 additions and 6 deletions

View file

@ -3,25 +3,31 @@
Function objects are objects which overload the operator() function.
The std::function does not provide any seamless support in the target languages yet.
*/
%module cpp11_function_objects
%module(directors="1") cpp11_function_objects
%rename(__call__) Test::operator();
%feature("director") Test;
%inline %{
struct Test {
class Test {
public:
int value;
void operator()(int x, int y) {
virtual void operator()(int x, int y) {
value=x+y;
}
Test() : value(0) {}
} test;
~Test() {}
};
Test test;
#include <functional>
std::function<void ( int, int )> pF = test;
int testit1(Test new_test, int a, int b) {
pF = new_test;
int testit1(Test &new_test, int a, int b) {
pF = std::ref(new_test);
pF(a, b);
return new_test.value;
}