Skip to content

Commit 64817c7

Browse files
committed
Revert fortran branch changes to old funcptr test
1 parent 6afa7bf commit 64817c7

File tree

1 file changed

+4
-32
lines changed

1 file changed

+4
-32
lines changed

Examples/test-suite/funcptr.i

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,13 @@
33
/*
44
Complicated one that should defeat just reading , to find
55
the number of arguments expected in the function pointer.
6-
extern void do(int (*op)(int (*i)(double, double), int j));
6+
extern void do(int (*op)(int (*i)(double, double), int j));
77
*/
8-
%{
9-
#include <stdlib.h>
10-
%}
118

129
%inline %{
1310
typedef double (*DistFun)(double* data, int r, int c, int i, int j, void *xdata);
1411

1512
void distance(double *data, int *dim, DistFun fun, double *output) {
16-
double val;
17-
val = fun(data, dim[0], dim[1], dim[2], dim[3], output);
18-
}
19-
20-
typedef double (*const CDistFun)(double* data, int r, int c, int i, int j, void *xdata);
21-
void const_distance(double *data, int *dim, CDistFun fun, double *output) {
22-
double val = fun(data, dim[0], dim[1], dim[2], dim[3], output);
2313
}
2414

2515
typedef int (*Operator)(int i,int j);
@@ -40,18 +30,18 @@ int multiply(int a, int b) {
4030
return a*b;
4131
}
4232

43-
int *nowt() {
33+
int *nowt() {
4434
return 0;
4535
}
4636

47-
int *nowt2(void) {
37+
int *nowt2(void) {
4838
return 0;
4939
}
5040

5141
struct MyStruct { int i; };
5242
typedef struct MyStruct * MyStructPtr;
5343

54-
MyStructPtr mystructptr() {
44+
MyStructPtr mystructptr() {
5545
return 0;
5646
}
5747

@@ -67,22 +57,4 @@ void (*pfunc0)();
6757
int (*pfuncA)();
6858
void (*pfunc1)(int);
6959
void (*pfunc2)(int, double);
70-
71-
#ifdef SWIGFORTRAN
72-
// Temporary example of setting function handles. This will be improved.
73-
%apply void* { SWIGTYPE (**)(ANY) } ;
74-
75-
%typemap(fin) SWIGTYPE (**)(ANY) = FORTRAN_INTRINSIC_TYPE&;
76-
%typemap(ftype, in="type(C_FUNPTR), target, intent(inout)") SWIGTYPE (**)(ANY)
77-
"type(C_FUNPTR), pointer"
78-
#endif
79-
80-
void set_handle(int choice, Operator* op) {
81-
switch (choice) {
82-
case 0: *op = add; break;
83-
case 1: *op = subtract; break;
84-
case 2: *op = multiply; break;
85-
default: *op = NULL;
86-
}
87-
}
8860
%}

0 commit comments

Comments
 (0)