test more global function pointer variables

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10268 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2008-02-27 13:07:26 +00:00
commit 69e6f39cfd
2 changed files with 20 additions and 3 deletions

View file

@ -6,6 +6,8 @@
extern void do(int (*op)(int (*i)(double, double), int j));
*/
%typemap(in) int (int intres) { /* in typemap int */ intres = 0; }
%typemap(in) double (double doubleres) { /* in typemap double */ doubleres = 0; }
%inline %{
typedef double (*DistFun)(double* data, int r, int c, int i, int j, void *xdata);
@ -22,19 +24,34 @@ int add(int a, int b) {
return a+b;
}
int sub(int a, int b) {
int subtract(int a, int b) {
return a-b;
}
int mul(int a, int b) {
int multiply(int a, int b) {
return a*b;
}
int *nowt() {
return 0;
}
struct MyStruct {};
typedef struct MyStruct * MyStructPtr;
MyStructPtr mystructptr() {
return 0;
}
typedef int * Integer;
int (*funcvar)(int,int) = add;
int * (*funcvar2)() = nowt;
int * (*funcvar3)(void) = nowt;
Integer (*funcvar4)() = nowt;
MyStructPtr (*funcvar5)() = mystructptr;
void (*pfunc0)();
int (*pfuncA)();
void (*pfunc1)(int);
void (*pfunc2)(int, double);
%}

View file

@ -3,5 +3,5 @@ dyn.load(paste("funcptr", .Platform$dynlib.ext, sep=""))
source("funcptr.R")
cacheMetaData(1)
unittest(do_op(1, 3, add), 4)
unittest(do_op(2, 3, mul), 6)
unittest(do_op(2, 3, multiply), 6)
unittest(do_op(2, 3, funcvar()), 5)