update swig on windows

This commit is contained in:
Bassem Girgis
2019-08-04 21:38:19 -05:00
parent 8414b7136b
commit 76ad52be58
5943 changed files with 91790 additions and 71892 deletions

View File

@@ -0,0 +1,3 @@
SRCS = example.c
include $(SRCDIR)../example.mk

View 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;

View File

@@ -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);

View 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);

View 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));