3
3
/*
4
4
Complicated one that should defeat just reading , to find
5
5
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));
7
7
*/
8
- %{
9
- #include < stdlib.h>
10
- %}
11
8
12
9
%inline %{
13
10
typedef double (*DistFun)(double * data, int r, int c, int i, int j, void *xdata);
14
11
15
12
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);
23
13
}
24
14
25
15
typedef int (*Operator)(int i,int j);
@@ -40,18 +30,18 @@ int multiply(int a, int b) {
40
30
return a*b;
41
31
}
42
32
43
- int *nowt () {
33
+ int *nowt () {
44
34
return 0 ;
45
35
}
46
36
47
- int *nowt2 (void ) {
37
+ int *nowt2 (void ) {
48
38
return 0 ;
49
39
}
50
40
51
41
struct MyStruct { int i; };
52
42
typedef struct MyStruct * MyStructPtr;
53
43
54
- MyStructPtr mystructptr () {
44
+ MyStructPtr mystructptr () {
55
45
return 0 ;
56
46
}
57
47
@@ -67,22 +57,4 @@ void (*pfunc0)();
67
57
int (*pfuncA)();
68
58
void (*pfunc1)(int );
69
59
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
- }
88
60
%}
0 commit comments