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,17 @@
TOP = ../..
SWIGEXE = $(TOP)/../swig
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
SRCS = example.c
TARGET = example
INTERFACE = example.i
check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run
build:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_clean

View File

@@ -0,0 +1,16 @@
/* File : example.c */
void add(int *x, int *y, int *result) {
*result = *x + *y;
}
void sub(int *x, int *y, int *result) {
*result = *x - *y;
}
int divide(int n, int d, int *r) {
int q;
q = n/d;
*r = n - q*d;
return q;
}

View File

@@ -0,0 +1,30 @@
/* File : example.i */
%module example
%{
extern void add(int *, int *, int *);
extern void sub(int *, int *, int *);
extern int divide(int, int, int *);
%}
/* This example illustrates a couple of different techniques
for manipulating C pointers */
/* First we'll use the pointer library */
extern void add(int *x, int *y, int *result);
%include cpointer.i
%pointer_functions(int, intp);
/* Next we'll use some typemaps */
%include typemaps.i
extern void sub(int *INPUT, int *INPUT, int *OUTPUT);
/* Next we'll use typemaps and the %apply directive */
%apply int *OUTPUT { int *r };
extern int divide(int n, int d, int *r);

View File

@@ -0,0 +1,47 @@
lines(0);
ilib_verbose(0);
ierr = exec('loader.sce', 'errcatch');
if ierr <> 0 then
disp(lasterror());
exit(ierr);
end
// First create some objects using the pointer library.
printf("Testing the pointer library\n")
a = new_intp();
b = new_intp();
c = new_intp(); // Memory for result
intp_assign(a, 37);
intp_assign(b, 42);
printf(" a = %d\n", intp_value(a));
printf(" b = %d\n", intp_value(b));
printf(" c = %d\n", intp_value(c));
// Call the add() function with some pointers
add(a, b, c);
// Now get the result
r = intp_value(c);
printf(" 37 + 42 = %d\n", r);
// Clean up the pointers
delete_intp(a);
delete_intp(b);
delete_intp(c);
// Now try the typemap library
// This should be much easier. Now how it is no longer
// necessary to manufacture pointers.
printf("Trying the typemap library\n");
r = sub(37, 42);
printf(" 37 - 42 = %d\n", r);
// Now try the version with multiple return values
printf("Testing multiple return values\n");
[q, r] = divide(42, 37);
printf(" 42/37 = %d remainder %d\n", q, r);
exit