Move funcptr.i from being an R only test to a test for all languages. Modify the test to test function pointers with no arguments, which is a problem for R.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10250 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
14d23e5a59
commit
9029bae5e0
3 changed files with 10 additions and 17 deletions
40
Examples/test-suite/funcptr.i
Normal file
40
Examples/test-suite/funcptr.i
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
%module funcptr
|
||||
|
||||
/*
|
||||
Complicated one that should defeat just reading , to find
|
||||
the number of arguments expected in the function pointer.
|
||||
extern void do(int (*op)(int (*i)(double, double), int j));
|
||||
*/
|
||||
|
||||
%inline %{
|
||||
typedef double (*DistFun)(double* data, int r, int c, int i, int j, void *xdata);
|
||||
|
||||
void distance(double *data, int *dim, DistFun fun, double *output) {
|
||||
}
|
||||
|
||||
typedef int (*Operator)(int i,int j);
|
||||
|
||||
int do_op(int a, int b, int (*op)(int,int)) {
|
||||
return (*op)(a,b);
|
||||
}
|
||||
|
||||
int add(int a, int b) {
|
||||
return a+b;
|
||||
}
|
||||
|
||||
int sub(int a, int b) {
|
||||
return a-b;
|
||||
}
|
||||
|
||||
int mul(int a, int b) {
|
||||
return a*b;
|
||||
}
|
||||
|
||||
int *nowt() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int (*funcvar)(int,int) = add;
|
||||
int * (*funcvar2)() = nowt;
|
||||
int * (*funcvar3)(void) = nowt;
|
||||
%}
|
||||
Loading…
Add table
Add a link
Reference in a new issue