update swig on windows
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
SRCS = example.c
|
||||
|
||||
include $(SRCDIR)../example.mk
|
||||
19
winx64/bin/swigwin-4.0.0/Examples/octave/funcptr2/example.c
Normal file
19
winx64/bin/swigwin-4.0.0/Examples/octave/funcptr2/example.c
Normal file
@@ -0,0 +1,19 @@
|
||||
/* File : example.c */
|
||||
|
||||
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 (*funcvar)(int,int) = add;
|
||||
@@ -0,0 +1,8 @@
|
||||
/* file: example.h */
|
||||
|
||||
extern int do_op(int,int, int (*op)(int,int));
|
||||
extern int add(int,int);
|
||||
extern int sub(int,int);
|
||||
extern int mul(int,int);
|
||||
|
||||
extern int (*funcvar)(int,int);
|
||||
20
winx64/bin/swigwin-4.0.0/Examples/octave/funcptr2/example.i
Normal file
20
winx64/bin/swigwin-4.0.0/Examples/octave/funcptr2/example.i
Normal file
@@ -0,0 +1,20 @@
|
||||
/* File : example.i */
|
||||
%module swigexample
|
||||
|
||||
%feature("autodoc", 1);
|
||||
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
||||
/* Wrap a function taking a pointer to a function */
|
||||
extern int do_op(int a, int b, int (*op)(int, int));
|
||||
|
||||
/* Now install a bunch of "ops" as constants */
|
||||
%callback("%(upper)s");
|
||||
int add(int, int);
|
||||
int sub(int, int);
|
||||
int mul(int, int);
|
||||
%nocallback;
|
||||
|
||||
extern int (*funcvar)(int,int);
|
||||
27
winx64/bin/swigwin-4.0.0/Examples/octave/funcptr2/runme.m
Normal file
27
winx64/bin/swigwin-4.0.0/Examples/octave/funcptr2/runme.m
Normal file
@@ -0,0 +1,27 @@
|
||||
# do not dump Octave core
|
||||
if exist("crash_dumps_octave_core", "builtin")
|
||||
crash_dumps_octave_core(0);
|
||||
endif
|
||||
|
||||
swigexample
|
||||
|
||||
a = 37
|
||||
b = 42
|
||||
|
||||
# Now call our C function with a bunch of callbacks
|
||||
|
||||
printf("Trying some C callback functions\n");
|
||||
printf(" a = %i\n", a);
|
||||
printf(" b = %i\n", b);
|
||||
printf(" ADD(a,b) = %i\n", swigexample.do_op(a,b,swigexample.ADD));
|
||||
printf(" SUB(a,b) = %i\n", swigexample.do_op(a,b,swigexample.SUB));
|
||||
printf(" MUL(a,b) = %i\n", swigexample.do_op(a,b,swigexample.MUL));
|
||||
|
||||
printf("Here is what the C callback function objects look like in Octave\n");
|
||||
swigexample.ADD
|
||||
swigexample.SUB
|
||||
swigexample.MUL
|
||||
|
||||
printf("Call the functions directly...\n");
|
||||
printf(" add(a,b) = %i\n", swigexample.add(a,b));
|
||||
printf(" sub(a,b) = %i\n", swigexample.sub(a,b));
|
||||
Reference in New Issue
Block a user