Fixes to Octave examples
- rename example modules from "example" to "swigexample", to avoid a warning from shadowing the Octave built-in function "example" - remove deprecated "static" Makefile targets: there is no longer an option to build static Octave modules in the Examples Makefile - emacs whitespace cleanup run on all files
This commit is contained in:
parent
7964ebe34f
commit
c28d0c6c80
63 changed files with 211 additions and 345 deletions
|
|
@ -1,7 +1,7 @@
|
|||
TOP = ../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
SRCS = example.c
|
||||
TARGET = example
|
||||
TARGET = swigexample
|
||||
INTERFACE = example.i
|
||||
|
||||
check: build
|
||||
|
|
@ -11,9 +11,5 @@ build:
|
|||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
|
||||
|
||||
static:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile octave_clean
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* File : example.i */
|
||||
%module example
|
||||
%module swigexample
|
||||
|
||||
%{
|
||||
extern void add(int *, int *, int *);
|
||||
|
|
@ -24,7 +24,3 @@ extern void sub(int *INPUT, int *INPUT, int *OUTPUT);
|
|||
|
||||
%apply int *OUTPUT { int *r };
|
||||
extern int divide(int n, int d, int *r);
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,42 +1,39 @@
|
|||
# file: runme.m
|
||||
|
||||
example;
|
||||
swigexample;
|
||||
|
||||
# First create some objects using the pointer library.
|
||||
printf("Testing the pointer library\n");
|
||||
a = example.new_intp();
|
||||
b = example.new_intp();
|
||||
c = example.new_intp();
|
||||
example.intp_assign(a,37);
|
||||
example.intp_assign(b,42);
|
||||
a = swigexample.new_intp();
|
||||
b = swigexample.new_intp();
|
||||
c = swigexample.new_intp();
|
||||
swigexample.intp_assign(a,37);
|
||||
swigexample.intp_assign(b,42);
|
||||
|
||||
a,b,c
|
||||
|
||||
# Call the add() function with some pointers
|
||||
example.add(a,b,c);
|
||||
swigexample.add(a,b,c);
|
||||
|
||||
# Now get the result
|
||||
r = example.intp_value(c);
|
||||
r = swigexample.intp_value(c);
|
||||
printf(" 37 + 42 = %i\n",r);
|
||||
|
||||
# Clean up the pointers
|
||||
example.delete_intp(a);
|
||||
example.delete_intp(b);
|
||||
example.delete_intp(c);
|
||||
swigexample.delete_intp(a);
|
||||
swigexample.delete_intp(b);
|
||||
swigexample.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 = example.sub(37,42);
|
||||
r = swigexample.sub(37,42);
|
||||
printf(" 37 - 42 = %i\n",r);
|
||||
|
||||
# Now try the version with multiple return values
|
||||
|
||||
printf("Testing multiple return values\n");
|
||||
[q,r] = example.divide(42,37);
|
||||
[q,r] = swigexample.divide(42,37);
|
||||
printf(" 42/37 = %d remainder %d\n",q,r);
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue