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
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
#include <stdlib.h>
|
||||
#include "example.h"
|
||||
|
||||
int ivar = 0;
|
||||
int ivar = 0;
|
||||
short svar = 0;
|
||||
long lvar = 0;
|
||||
unsigned int uivar = 0;
|
||||
|
|
|
|||
|
|
@ -3,4 +3,3 @@
|
|||
typedef struct {
|
||||
int x,y;
|
||||
} Point;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* File : example.i */
|
||||
%module example
|
||||
%module swigexample
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
|
@ -50,4 +50,3 @@ extern Point *new_Point(int x, int y);
|
|||
extern char *Point_print(Point *p);
|
||||
extern void pt_print();
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,56 +1,56 @@
|
|||
# file: runme.m
|
||||
|
||||
example
|
||||
swigexample
|
||||
|
||||
# Try to set the values of some global variables
|
||||
|
||||
example.cvar.ivar = 42;
|
||||
example.cvar.svar = -31000;
|
||||
example.cvar.lvar = 65537;
|
||||
example.cvar.uivar = 123456;
|
||||
example.cvar.usvar = 61000;
|
||||
example.cvar.ulvar = 654321;
|
||||
example.cvar.scvar = -13;
|
||||
example.cvar.ucvar = 251;
|
||||
example.cvar.cvar = "S";
|
||||
example.cvar.fvar = 3.14159;
|
||||
example.cvar.dvar = 2.1828;
|
||||
example.cvar.strvar = "Hello World";
|
||||
example.cvar.iptrvar= example.new_int(37);
|
||||
example.cvar.ptptr = example.new_Point(37,42);
|
||||
example.cvar.name = "Bill";
|
||||
swigexample.cvar.ivar = 42;
|
||||
swigexample.cvar.svar = -31000;
|
||||
swigexample.cvar.lvar = 65537;
|
||||
swigexample.cvar.uivar = 123456;
|
||||
swigexample.cvar.usvar = 61000;
|
||||
swigexample.cvar.ulvar = 654321;
|
||||
swigexample.cvar.scvar = -13;
|
||||
swigexample.cvar.ucvar = 251;
|
||||
swigexample.cvar.cvar = "S";
|
||||
swigexample.cvar.fvar = 3.14159;
|
||||
swigexample.cvar.dvar = 2.1828;
|
||||
swigexample.cvar.strvar = "Hello World";
|
||||
swigexample.cvar.iptrvar= swigexample.new_int(37);
|
||||
swigexample.cvar.ptptr = swigexample.new_Point(37,42);
|
||||
swigexample.cvar.name = "Bill";
|
||||
|
||||
# Now print out the values of the variables
|
||||
|
||||
printf("Variables (values printed from Octave)\n");
|
||||
|
||||
printf("ivar = %i\n", example.cvar.ivar);
|
||||
printf("svar = %i\n", example.cvar.svar);
|
||||
printf("lvar = %i\n", example.cvar.lvar);
|
||||
printf("uivar = %i\n", example.cvar.uivar);
|
||||
printf("usvar = %i\n", example.cvar.usvar);
|
||||
printf("ulvar = %i\n", example.cvar.ulvar);
|
||||
printf("scvar = %i\n", example.cvar.scvar);
|
||||
printf("ucvar = %i\n", example.cvar.ucvar);
|
||||
printf("fvar = %i\n", example.cvar.fvar);
|
||||
printf("dvar = %i\n", example.cvar.dvar);
|
||||
printf("cvar = %s\n", example.cvar.cvar);
|
||||
printf("strvar = %s\n", example.cvar.strvar);
|
||||
#printf("cstrvar = %s\n", example.cvar.cstrvar);
|
||||
example.cvar.iptrvar
|
||||
printf("name = %i\n", example.cvar.name);
|
||||
printf("ptptr = %s\n", example.Point_print(example.cvar.ptptr));
|
||||
#printf("pt = %s\n", example.cvar.Point_print(example.cvar.pt));
|
||||
printf("ivar = %i\n", swigexample.cvar.ivar);
|
||||
printf("svar = %i\n", swigexample.cvar.svar);
|
||||
printf("lvar = %i\n", swigexample.cvar.lvar);
|
||||
printf("uivar = %i\n", swigexample.cvar.uivar);
|
||||
printf("usvar = %i\n", swigexample.cvar.usvar);
|
||||
printf("ulvar = %i\n", swigexample.cvar.ulvar);
|
||||
printf("scvar = %i\n", swigexample.cvar.scvar);
|
||||
printf("ucvar = %i\n", swigexample.cvar.ucvar);
|
||||
printf("fvar = %i\n", swigexample.cvar.fvar);
|
||||
printf("dvar = %i\n", swigexample.cvar.dvar);
|
||||
printf("cvar = %s\n", swigexample.cvar.cvar);
|
||||
printf("strvar = %s\n", swigexample.cvar.strvar);
|
||||
#printf("cstrvar = %s\n", swigexample.cvar.cstrvar);
|
||||
swigexample.cvar.iptrvar
|
||||
printf("name = %i\n", swigexample.cvar.name);
|
||||
printf("ptptr = %s\n", swigexample.Point_print(swigexample.cvar.ptptr));
|
||||
#printf("pt = %s\n", swigexample.cvar.Point_print(swigexample.cvar.pt));
|
||||
|
||||
printf("\nVariables (values printed from C)\n");
|
||||
|
||||
example.print_vars();
|
||||
swigexample.print_vars();
|
||||
|
||||
printf("\nNow I'm going to try and modify some read only variables\n");
|
||||
|
||||
printf(" Tring to set 'path'\n");
|
||||
try
|
||||
example.cvar.path = "Whoa!";
|
||||
swigexample.cvar.path = "Whoa!";
|
||||
printf("Hey, what's going on?!?! This shouldn't work\n");
|
||||
catch
|
||||
printf("Good.\n");
|
||||
|
|
@ -58,7 +58,7 @@ end_try_catch
|
|||
|
||||
printf(" Trying to set 'status'\n");
|
||||
try
|
||||
example.cvar.status = 0;
|
||||
swigexample.cvar.status = 0;
|
||||
printf("Hey, what's going on?!?! This shouldn't work\n");
|
||||
catch
|
||||
printf("Good.\n");
|
||||
|
|
@ -67,9 +67,6 @@ end_try_catch
|
|||
|
||||
printf("\nI'm going to try and update a structure variable.\n");
|
||||
|
||||
example.cvar.pt = example.cvar.ptptr;
|
||||
|
||||
printf("The new value is %s\n", example.Point_print(example.cvar.pt));
|
||||
|
||||
|
||||
swigexample.cvar.pt = swigexample.cvar.ptptr;
|
||||
|
||||
printf("The new value is %s\n", swigexample.Point_print(swigexample.cvar.pt));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue