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 = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIG = $(TOP)/../preinst-swig
|
||||||
CXXSRCS = example.cxx
|
CXXSRCS = example.cxx
|
||||||
TARGET = example
|
TARGET = swigexample
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
LIBS = -lm
|
LIBS = -lm
|
||||||
SWIGOPT =
|
SWIGOPT =
|
||||||
|
|
@ -13,9 +13,5 @@ build:
|
||||||
$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
||||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
|
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
|
||||||
|
|
||||||
static:
|
|
||||||
$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
|
||||||
SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(MAKE) -f $(TOP)/Makefile octave_clean
|
$(MAKE) -f $(TOP)/Makefile octave_clean
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
/* File : example.cxx */
|
/* File : example.cxx */
|
||||||
|
|
||||||
#include "example.h"
|
#include "example.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,4 +20,3 @@ public:
|
||||||
void setCallback(Callback *cb) { delCallback(); _callback = cb; }
|
void setCallback(Callback *cb) { delCallback(); _callback = cb; }
|
||||||
void call() { if (_callback) _callback->run(); }
|
void call() { if (_callback) _callback->run(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/* File : example.i */
|
/* File : example.i */
|
||||||
%module(directors="1") example
|
%module(directors="1") swigexample
|
||||||
%{
|
%{
|
||||||
#include "example.h"
|
#include "example.h"
|
||||||
%}
|
%}
|
||||||
|
|
@ -10,4 +10,3 @@
|
||||||
%feature("director") Callback;
|
%feature("director") Callback;
|
||||||
|
|
||||||
%include "example.h"
|
%include "example.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,13 @@
|
||||||
|
|
||||||
# This file illustrates the cross language polymorphism using directors.
|
# This file illustrates the cross language polymorphism using directors.
|
||||||
|
|
||||||
example
|
swigexample
|
||||||
|
|
||||||
OctCallback=@() subclass(example.Callback(), \
|
OctCallback=@() subclass(swigexample.Callback(),"run",@(self) printf("OctCallback.run()\n"));
|
||||||
'run',@(self) printf("OctCallback.run()\n"));
|
|
||||||
|
|
||||||
# Create an Caller instance
|
# Create an Caller instance
|
||||||
|
|
||||||
caller = example.Caller();
|
caller = swigexample.Caller();
|
||||||
|
|
||||||
# Add a simple C++ callback (caller owns the callback, so
|
# Add a simple C++ callback (caller owns the callback, so
|
||||||
# we disown it first)
|
# we disown it first)
|
||||||
|
|
@ -17,7 +16,7 @@ caller = example.Caller();
|
||||||
printf("Adding and calling a normal C++ callback\n");
|
printf("Adding and calling a normal C++ callback\n");
|
||||||
printf("----------------------------------------\n");
|
printf("----------------------------------------\n");
|
||||||
|
|
||||||
callback = example.Callback().__disown();
|
callback = swigexample.Callback().__disown();
|
||||||
caller.setCallback(callback);
|
caller.setCallback(callback);
|
||||||
caller.call();
|
caller.call();
|
||||||
caller.delCallback();
|
caller.delCallback();
|
||||||
|
|
@ -43,7 +42,7 @@ caller.call();
|
||||||
caller.delCallback();
|
caller.delCallback();
|
||||||
|
|
||||||
# careful-- using callback here may cause problems; octave_swig_type still
|
# careful-- using callback here may cause problems; octave_swig_type still
|
||||||
# exists, but is holding a destroyed object (the C++ example.Callback).
|
# exists, but is holding a destroyed object (the C++ swigexample.Callback).
|
||||||
# to manually drop the octave-side reference, you can use
|
# to manually drop the octave-side reference, you can use
|
||||||
clear callback;
|
clear callback;
|
||||||
|
|
||||||
|
|
@ -60,4 +59,3 @@ a.Callback.run();
|
||||||
# All done.
|
# All done.
|
||||||
|
|
||||||
printf("octave exit\n");
|
printf("octave exit\n");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIG = $(TOP)/../preinst-swig
|
||||||
CXXSRCS = example.cxx
|
CXXSRCS = example.cxx
|
||||||
TARGET = example
|
TARGET = swigexample
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
LIBS = -lm
|
LIBS = -lm
|
||||||
SWIGOPT =
|
SWIGOPT =
|
||||||
|
|
@ -13,9 +13,5 @@ build:
|
||||||
$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
||||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
|
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
|
||||||
|
|
||||||
static:
|
|
||||||
$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
|
||||||
SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(MAKE) -f $(TOP)/Makefile octave_clean
|
$(MAKE) -f $(TOP)/Makefile octave_clean
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,3 @@ public:
|
||||||
virtual double area(void);
|
virtual double area(void);
|
||||||
virtual double perimeter(void);
|
virtual double perimeter(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/* File : example.i */
|
/* File : example.i */
|
||||||
%module example
|
%module swigexample
|
||||||
|
|
||||||
%{
|
%{
|
||||||
#include "example.h"
|
#include "example.h"
|
||||||
|
|
@ -7,4 +7,3 @@
|
||||||
|
|
||||||
/* Let's just grab the original header file here */
|
/* Let's just grab the original header file here */
|
||||||
%include "example.h"
|
%include "example.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,17 +3,17 @@
|
||||||
# This file illustrates the proxy class C++ interface generated
|
# This file illustrates the proxy class C++ interface generated
|
||||||
# by SWIG.
|
# by SWIG.
|
||||||
|
|
||||||
example
|
swigexample
|
||||||
|
|
||||||
# ----- Object creation -----
|
# ----- Object creation -----
|
||||||
|
|
||||||
printf("Creating some objects:\n");
|
printf("Creating some objects:\n");
|
||||||
c = example.Circle(10)
|
c = swigexample.Circle(10)
|
||||||
s = example.Square(10)
|
s = swigexample.Square(10)
|
||||||
|
|
||||||
# ----- Access a static member -----
|
# ----- Access a static member -----
|
||||||
|
|
||||||
printf("\nA total of %i shapes were created\n", example.Shape.nshapes);
|
printf("\nA total of %i shapes were created\n", swigexample.Shape.nshapes);
|
||||||
|
|
||||||
# ----- Member data access -----
|
# ----- Member data access -----
|
||||||
|
|
||||||
|
|
@ -46,7 +46,5 @@ printf("\nGuess I'll clean up now\n");
|
||||||
clear c
|
clear c
|
||||||
clear s
|
clear s
|
||||||
|
|
||||||
printf("%i shapes remain\n", example.Shape.nshapes);
|
printf("%i shapes remain\n", swigexample.Shape.nshapes);
|
||||||
printf("Goodbye\n");
|
printf("Goodbye\n");
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIG = $(TOP)/../preinst-swig
|
||||||
CXXSRCS =
|
CXXSRCS =
|
||||||
TARGET = example
|
TARGET = swigexample
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
LIBS = -lm
|
LIBS = -lm
|
||||||
SWIGOPT =
|
SWIGOPT =
|
||||||
|
|
@ -13,9 +13,5 @@ build:
|
||||||
$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
||||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
|
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
|
||||||
|
|
||||||
static:
|
|
||||||
$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
|
||||||
SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(MAKE) -f $(TOP)/Makefile octave_clean
|
$(MAKE) -f $(TOP)/Makefile octave_clean
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/* File : example.i */
|
/* File : example.i */
|
||||||
%module example
|
%module swigexample
|
||||||
|
|
||||||
/* A few preprocessor macros */
|
/* A few preprocessor macros */
|
||||||
|
|
||||||
|
|
@ -23,5 +23,3 @@
|
||||||
|
|
||||||
%constant int iconst = 37;
|
%constant int iconst = 37;
|
||||||
%constant double fconst = 3.14;
|
%constant double fconst = 3.14;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,25 @@
|
||||||
# file: runme.m
|
# file: runme.m
|
||||||
|
|
||||||
example
|
swigexample
|
||||||
|
|
||||||
printf("ICONST = %i (should be 42)\n", example.ICONST);
|
printf("ICONST = %i (should be 42)\n", swigexample.ICONST);
|
||||||
printf("FCONST = %f (should be 2.1828)\n", example.FCONST);
|
printf("FCONST = %f (should be 2.1828)\n", swigexample.FCONST);
|
||||||
printf("CCONST = %s (should be 'x')\n", example.CCONST);
|
printf("CCONST = %s (should be 'x')\n", swigexample.CCONST);
|
||||||
printf("CCONST2 = %s (this should be on a new line)\n", example.CCONST2);
|
printf("CCONST2 = %s (this should be on a new line)\n", swigexample.CCONST2);
|
||||||
printf("SCONST = %s (should be 'Hello World')\n", example.SCONST);
|
printf("SCONST = %s (should be 'Hello World')\n", swigexample.SCONST);
|
||||||
printf("SCONST2 = %s (should be '\"Hello World\"')\n", example.SCONST2);
|
printf("SCONST2 = %s (should be '\"Hello World\"')\n", swigexample.SCONST2);
|
||||||
printf("EXPR = %f (should be 48.5484)\n", example.EXPR);
|
printf("EXPR = %f (should be 48.5484)\n", swigexample.EXPR);
|
||||||
printf("iconst = %i (should be 37)\n", example.iconst);
|
printf("iconst = %i (should be 37)\n", swigexample.iconst);
|
||||||
printf("fconst = %f (should be 3.14)\n", example.fconst);
|
printf("fconst = %f (should be 3.14)\n", swigexample.fconst);
|
||||||
|
|
||||||
try
|
try
|
||||||
printf("EXTERN = %s (Arg! This shouldn't printf(anything)\n", example.EXTERN);
|
printf("EXTERN = %s (Arg! This shouldn't printf(anything)\n", swigexample.EXTERN);
|
||||||
catch
|
catch
|
||||||
printf("EXTERN isn't defined (good)\n");
|
printf("EXTERN isn't defined (good)\n");
|
||||||
end_try_catch
|
end_try_catch
|
||||||
|
|
||||||
try
|
try
|
||||||
printf("FOO = %i (Arg! This shouldn't printf(anything)\n", example.FOO);
|
printf("FOO = %i (Arg! This shouldn't printf(anything)\n", swigexample.FOO);
|
||||||
catch
|
catch
|
||||||
printf("FOO isn't defined (good)\n");
|
printf("FOO isn't defined (good)\n");
|
||||||
end_try_catch
|
end_try_catch
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIG = $(TOP)/../preinst-swig
|
||||||
SRCS = example.c
|
SRCS = example.c
|
||||||
TARGET = example
|
TARGET = swigexample
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
|
|
||||||
check: build
|
check: build
|
||||||
|
|
@ -11,9 +11,5 @@ build:
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
|
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
|
||||||
|
|
||||||
static:
|
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
|
||||||
TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(MAKE) -f $(TOP)/Makefile octave_clean
|
$(MAKE) -f $(TOP)/Makefile octave_clean
|
||||||
|
|
|
||||||
|
|
@ -19,5 +19,3 @@ int fact(int n) {
|
||||||
if (n <= 0) return 1;
|
if (n <= 0) return 1;
|
||||||
return n*fact(n-1);
|
return n*fact(n-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/* File : example.i */
|
/* File : example.i */
|
||||||
%module example
|
%module swigexample
|
||||||
|
|
||||||
%contract gcd(int x, int y) {
|
%contract gcd(int x, int y) {
|
||||||
require:
|
require:
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,21 @@
|
||||||
# file: runme.m
|
# file: runme.m
|
||||||
|
|
||||||
example
|
swigexample
|
||||||
|
|
||||||
# Call our gcd() function
|
# Call our gcd() function
|
||||||
|
|
||||||
x = 42;
|
x = 42;
|
||||||
y = 105;
|
y = 105;
|
||||||
g = example.gcd(x,y);
|
g = swigexample.gcd(x,y);
|
||||||
printf("The gcd of %d and %d is %d\n",x,y,g);
|
printf("The gcd of %d and %d is %d\n",x,y,g);
|
||||||
|
|
||||||
# Manipulate the Foo global variable
|
# Manipulate the Foo global variable
|
||||||
|
|
||||||
# Output its current value
|
# Output its current value
|
||||||
printf("Foo = %f\n", example.cvar.Foo);
|
printf("Foo = %f\n", swigexample.cvar.Foo);
|
||||||
|
|
||||||
# Change its value
|
# Change its value
|
||||||
example.cvar.Foo = 3.1415926;
|
swigexample.cvar.Foo = 3.1415926;
|
||||||
|
|
||||||
# See if the change took effect
|
# See if the change took effect
|
||||||
printf("Foo = %f\n", example.cvar.Foo);
|
printf("Foo = %f\n", swigexample.cvar.Foo);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIG = $(TOP)/../preinst-swig
|
||||||
CXXSRCS = example.cxx
|
CXXSRCS = example.cxx
|
||||||
TARGET = example
|
TARGET = swigexample
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
LIBS = -lm
|
LIBS = -lm
|
||||||
SWIGOPT =
|
SWIGOPT =
|
||||||
|
|
@ -13,9 +13,5 @@ build:
|
||||||
$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
||||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
|
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
|
||||||
|
|
||||||
static:
|
|
||||||
$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
|
||||||
SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(MAKE) -f $(TOP)/Makefile octave_clean
|
$(MAKE) -f $(TOP)/Makefile octave_clean
|
||||||
|
|
|
||||||
|
|
@ -10,4 +10,3 @@ class Foo {
|
||||||
};
|
};
|
||||||
|
|
||||||
void enum_test(color c, Foo::speed s);
|
void enum_test(color c, Foo::speed s);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/* File : example.i */
|
/* File : example.i */
|
||||||
%module example
|
%module swigexample
|
||||||
|
|
||||||
%{
|
%{
|
||||||
#include "example.h"
|
#include "example.h"
|
||||||
|
|
@ -8,4 +8,3 @@
|
||||||
/* Let's just grab the original header file here */
|
/* Let's just grab the original header file here */
|
||||||
|
|
||||||
%include "example.h"
|
%include "example.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,32 +1,30 @@
|
||||||
# file: runme.m
|
# file: runme.m
|
||||||
|
|
||||||
example
|
swigexample
|
||||||
|
|
||||||
# ----- Object creation -----
|
# ----- Object creation -----
|
||||||
|
|
||||||
# Print out the value of some enums
|
# Print out the value of some enums
|
||||||
printf("*** color ***\n");
|
printf("*** color ***\n");
|
||||||
printf(" RED = %i\n", example.RED);
|
printf(" RED = %i\n", swigexample.RED);
|
||||||
printf(" BLUE = %i\n", example.BLUE);
|
printf(" BLUE = %i\n", swigexample.BLUE);
|
||||||
printf(" GREEN = %i\n", example.GREEN);
|
printf(" GREEN = %i\n", swigexample.GREEN);
|
||||||
|
|
||||||
printf("\n*** Foo::speed ***\n");
|
printf("\n*** Foo::speed ***\n");
|
||||||
printf(" Foo_IMPULSE = %i\n", example.Foo_IMPULSE);
|
printf(" Foo_IMPULSE = %i\n", swigexample.Foo_IMPULSE);
|
||||||
printf(" Foo_WARP = %i\n", example.Foo_WARP);
|
printf(" Foo_WARP = %i\n", swigexample.Foo_WARP);
|
||||||
printf(" Foo_LUDICROUS = %i\n", example.Foo_LUDICROUS);
|
printf(" Foo_LUDICROUS = %i\n", swigexample.Foo_LUDICROUS);
|
||||||
|
|
||||||
printf("\nTesting use of enums with functions\n");
|
printf("\nTesting use of enums with functions\n");
|
||||||
|
|
||||||
example.enum_test(example.RED, example.Foo_IMPULSE);
|
swigexample.enum_test(swigexample.RED, swigexample.Foo_IMPULSE);
|
||||||
example.enum_test(example.BLUE, example.Foo_WARP);
|
swigexample.enum_test(swigexample.BLUE, swigexample.Foo_WARP);
|
||||||
example.enum_test(example.GREEN, example.Foo_LUDICROUS);
|
swigexample.enum_test(swigexample.GREEN, swigexample.Foo_LUDICROUS);
|
||||||
example.enum_test(1234,5678)
|
swigexample.enum_test(1234,5678)
|
||||||
|
|
||||||
printf("\nTesting use of enum with class method\n");
|
printf("\nTesting use of enum with class method\n");
|
||||||
f = example.Foo();
|
f = swigexample.Foo();
|
||||||
|
|
||||||
f.enum_test(example.Foo_IMPULSE);
|
|
||||||
f.enum_test(example.Foo_WARP);
|
|
||||||
f.enum_test(example.Foo_LUDICROUS);
|
|
||||||
|
|
||||||
|
|
||||||
|
f.enum_test(swigexample.Foo_IMPULSE);
|
||||||
|
f.enum_test(swigexample.Foo_WARP);
|
||||||
|
f.enum_test(swigexample.Foo_LUDICROUS);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIG = $(TOP)/../preinst-swig
|
||||||
CXXSRCS = example.cxx
|
CXXSRCS = example.cxx
|
||||||
TARGET = example
|
TARGET = swigexample
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
LIBS = -lm
|
LIBS = -lm
|
||||||
SWIGOPT =
|
SWIGOPT =
|
||||||
|
|
@ -13,9 +13,5 @@ build:
|
||||||
$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
||||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
|
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
|
||||||
|
|
||||||
static:
|
|
||||||
$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
|
||||||
SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(MAKE) -f $(TOP)/Makefile octave_clean
|
$(MAKE) -f $(TOP)/Makefile octave_clean
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
/* File : example.cxx */
|
/* File : example.cxx */
|
||||||
|
|
||||||
#include "example.h"
|
#include "example.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,4 +53,3 @@ public:
|
||||||
std::cout << "~EmployeeList empty." << std::endl;
|
std::cout << "~EmployeeList empty." << std::endl;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/* File : example.i */
|
/* File : example.i */
|
||||||
%module(directors="1") example
|
%module(directors="1") swigexample
|
||||||
%{
|
%{
|
||||||
#include "example.h"
|
#include "example.h"
|
||||||
%}
|
%}
|
||||||
|
|
@ -12,4 +12,3 @@
|
||||||
%feature("director") Manager;
|
%feature("director") Manager;
|
||||||
|
|
||||||
%include "example.h"
|
%include "example.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,12 @@
|
||||||
|
|
||||||
# This file illustrates the cross language polymorphism using directors.
|
# This file illustrates the cross language polymorphism using directors.
|
||||||
|
|
||||||
example
|
swigexample
|
||||||
|
|
||||||
|
|
||||||
# CEO class, which overrides Employee::getPosition().
|
# CEO class, which overrides Employee::getPosition().
|
||||||
|
|
||||||
CEO=@(name) subclass(example.Manager(name),'getPosition',@(self) "CEO");
|
CEO=@(name) subclass(swigexample.Manager(name),'getPosition',@(self) "CEO");
|
||||||
|
|
||||||
# Create an instance of our employee extension class, CEO. The calls to
|
# Create an instance of our employee extension class, CEO. The calls to
|
||||||
# getName() and getPosition() are standard, the call to getTitle() uses
|
# getName() and getPosition() are standard, the call to getTitle() uses
|
||||||
|
|
@ -22,7 +22,7 @@ printf("----------------------\n");
|
||||||
# Create a new EmployeeList instance. This class does not have a C++
|
# Create a new EmployeeList instance. This class does not have a C++
|
||||||
# director wrapper, but can be used freely with other classes that do.
|
# director wrapper, but can be used freely with other classes that do.
|
||||||
|
|
||||||
list = example.EmployeeList();
|
list = swigexample.EmployeeList();
|
||||||
|
|
||||||
# EmployeeList owns its items, so we must surrender ownership of objects
|
# EmployeeList owns its items, so we must surrender ownership of objects
|
||||||
# we add. This involves first calling the __disown__ method to tell the
|
# we add. This involves first calling the __disown__ method to tell the
|
||||||
|
|
@ -71,4 +71,3 @@ printf("----------------------\n");
|
||||||
# All done.
|
# All done.
|
||||||
|
|
||||||
printf("octave exit\n");
|
printf("octave exit\n");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIG = $(TOP)/../preinst-swig
|
||||||
SRCS = example.c
|
SRCS = example.c
|
||||||
TARGET = example
|
TARGET = swigexample
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
|
|
||||||
check: build
|
check: build
|
||||||
|
|
@ -11,9 +11,5 @@ build:
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
|
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
|
||||||
|
|
||||||
static:
|
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
|
||||||
TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(MAKE) -f $(TOP)/Makefile octave_clean
|
$(MAKE) -f $(TOP)/Makefile octave_clean
|
||||||
|
|
|
||||||
|
|
@ -6,4 +6,3 @@ extern int sub(int,int);
|
||||||
extern int mul(int,int);
|
extern int mul(int,int);
|
||||||
|
|
||||||
extern int (*funcvar)(int,int);
|
extern int (*funcvar)(int,int);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/* File : example.i */
|
/* File : example.i */
|
||||||
%module example
|
%module swigexample
|
||||||
%{
|
%{
|
||||||
#include "example.h"
|
#include "example.h"
|
||||||
%}
|
%}
|
||||||
|
|
@ -13,4 +13,3 @@ extern int do_op(int a, int b, int (*op)(int, int));
|
||||||
%constant int (*MUL)(int,int) = mul;
|
%constant int (*MUL)(int,int) = mul;
|
||||||
|
|
||||||
extern int (*funcvar)(int,int);
|
extern int (*funcvar)(int,int);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# file: runme.m
|
# file: runme.m
|
||||||
|
|
||||||
example
|
swigexample
|
||||||
|
|
||||||
a = 37
|
a = 37
|
||||||
b = 42
|
b = 42
|
||||||
|
|
@ -10,12 +10,11 @@ b = 42
|
||||||
printf("Trying some C callback functions\n");
|
printf("Trying some C callback functions\n");
|
||||||
printf(" a = %i\n", a);
|
printf(" a = %i\n", a);
|
||||||
printf(" b = %i\n", b);
|
printf(" b = %i\n", b);
|
||||||
printf(" ADD(a,b) = %i\n", example.do_op(a,b,example.ADD));
|
printf(" ADD(a,b) = %i\n", swigexample.do_op(a,b,swigexample.ADD));
|
||||||
printf(" SUB(a,b) = %i\n", example.do_op(a,b,example.SUB));
|
printf(" SUB(a,b) = %i\n", swigexample.do_op(a,b,swigexample.SUB));
|
||||||
printf(" MUL(a,b) = %i\n", example.do_op(a,b,example.MUL));
|
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");
|
printf("Here is what the C callback function objects look like in Octave\n");
|
||||||
example.ADD
|
swigexample.ADD
|
||||||
example.SUB
|
swigexample.SUB
|
||||||
example.MUL
|
swigexample.MUL
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIG = $(TOP)/../preinst-swig
|
||||||
SRCS = example.c
|
SRCS = example.c
|
||||||
TARGET = example
|
TARGET = swigexample
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
|
|
||||||
check: build
|
check: build
|
||||||
|
|
@ -11,9 +11,5 @@ build:
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
|
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
|
||||||
|
|
||||||
static:
|
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
|
||||||
TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(MAKE) -f $(TOP)/Makefile octave_clean
|
$(MAKE) -f $(TOP)/Makefile octave_clean
|
||||||
|
|
|
||||||
|
|
@ -6,4 +6,3 @@ extern int sub(int,int);
|
||||||
extern int mul(int,int);
|
extern int mul(int,int);
|
||||||
|
|
||||||
extern int (*funcvar)(int,int);
|
extern int (*funcvar)(int,int);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/* File : example.i */
|
/* File : example.i */
|
||||||
%module example
|
%module swigexample
|
||||||
%{
|
%{
|
||||||
#include "example.h"
|
#include "example.h"
|
||||||
%}
|
%}
|
||||||
|
|
@ -15,4 +15,3 @@ int mul(int, int);
|
||||||
%nocallback;
|
%nocallback;
|
||||||
|
|
||||||
extern int (*funcvar)(int,int);
|
extern int (*funcvar)(int,int);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# file: runme.m
|
# file: runme.m
|
||||||
|
|
||||||
example
|
swigexample
|
||||||
|
|
||||||
a = 37
|
a = 37
|
||||||
b = 42
|
b = 42
|
||||||
|
|
@ -10,15 +10,15 @@ b = 42
|
||||||
printf("Trying some C callback functions\n");
|
printf("Trying some C callback functions\n");
|
||||||
printf(" a = %i\n", a);
|
printf(" a = %i\n", a);
|
||||||
printf(" b = %i\n", b);
|
printf(" b = %i\n", b);
|
||||||
printf(" ADD(a,b) = %i\n", example.do_op(a,b,example.ADD));
|
printf(" ADD(a,b) = %i\n", swigexample.do_op(a,b,swigexample.ADD));
|
||||||
printf(" SUB(a,b) = %i\n", example.do_op(a,b,example.SUB));
|
printf(" SUB(a,b) = %i\n", swigexample.do_op(a,b,swigexample.SUB));
|
||||||
printf(" MUL(a,b) = %i\n", example.do_op(a,b,example.MUL));
|
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");
|
printf("Here is what the C callback function objects look like in Octave\n");
|
||||||
example.ADD
|
swigexample.ADD
|
||||||
example.SUB
|
swigexample.SUB
|
||||||
example.MUL
|
swigexample.MUL
|
||||||
|
|
||||||
printf("Call the functions directly...\n");
|
printf("Call the functions directly...\n");
|
||||||
printf(" add(a,b) = %i\n", example.add(a,b));
|
printf(" add(a,b) = %i\n", swigexample.add(a,b));
|
||||||
printf(" sub(a,b) = %i\n", example.sub(a,b));
|
printf(" sub(a,b) = %i\n", swigexample.sub(a,b));
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIG = $(TOP)/../preinst-swig
|
||||||
CXXSRCS =
|
CXXSRCS =
|
||||||
TARGET = example
|
TARGET = swigexample
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
LIBS = -lm
|
LIBS = -lm
|
||||||
SWIGOPT =
|
SWIGOPT =
|
||||||
|
|
@ -13,9 +13,5 @@ build:
|
||||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
||||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
|
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
|
||||||
|
|
||||||
static:
|
|
||||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
|
||||||
TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(MAKE) -f $(TOP)/Makefile octave_clean
|
$(MAKE) -f $(TOP)/Makefile octave_clean
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/* File : example.i */
|
/* File : example.i */
|
||||||
%module example
|
%module swigexample
|
||||||
|
|
||||||
|
|
||||||
%inline %{
|
%inline %{
|
||||||
|
|
@ -23,7 +23,3 @@ public:
|
||||||
// Instantiate a few versions
|
// Instantiate a few versions
|
||||||
%template(intSum) Sum<int>;
|
%template(intSum) Sum<int>;
|
||||||
%template(doubleSum) Sum<double>;
|
%template(doubleSum) Sum<double>;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
# Operator overloading example
|
# Operator overloading example
|
||||||
example
|
swigexample
|
||||||
|
|
||||||
a = example.intSum(0);
|
a = swigexample.intSum(0);
|
||||||
b = example.doubleSum(100.0);
|
b = swigexample.doubleSum(100.0);
|
||||||
|
|
||||||
# Use the objects. They should be callable just like a normal
|
# Use the objects. They should be callable just like a normal
|
||||||
# python function.
|
# python function.
|
||||||
|
|
@ -14,5 +14,3 @@ endfor
|
||||||
|
|
||||||
a.result()
|
a.result()
|
||||||
b.result()
|
b.result()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIG = $(TOP)/../preinst-swig
|
||||||
SRCS = example.c
|
SRCS = example.c
|
||||||
TARGET = example
|
TARGET = swigexample
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
|
|
||||||
check: build
|
check: build
|
||||||
|
|
@ -13,10 +13,6 @@ build:
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||||
TARGET='$(TARGET)2' SWIGOPT='-module $$(TARGET) -globals .' INTERFACE='$(INTERFACE)' octave
|
TARGET='$(TARGET)2' SWIGOPT='-module $$(TARGET) -globals .' INTERFACE='$(INTERFACE)' octave
|
||||||
|
|
||||||
static:
|
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
|
||||||
TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(MAKE) -f $(TOP)/Makefile octave_clean
|
$(MAKE) -f $(TOP)/Makefile octave_clean
|
||||||
rm -f $(TARGET).m
|
rm -f $(TARGET).m
|
||||||
|
|
|
||||||
|
|
@ -2,60 +2,60 @@
|
||||||
|
|
||||||
# load module
|
# load module
|
||||||
clear all;
|
clear all;
|
||||||
example;
|
swigexample;
|
||||||
assert(cvar.ivar == ifunc);
|
assert(cvar.ivar == ifunc);
|
||||||
assert(exist("example","var"));
|
assert(exist("swigexample","var"));
|
||||||
clear all
|
clear all
|
||||||
example;
|
swigexample;
|
||||||
assert(cvar.ivar == ifunc);
|
assert(cvar.ivar == ifunc);
|
||||||
assert(exist("example","var"));
|
assert(exist("swigexample","var"));
|
||||||
clear all
|
clear all
|
||||||
|
|
||||||
# load module in a function globally before base context
|
# load module in a function globally before base context
|
||||||
clear all;
|
clear all;
|
||||||
function testme
|
function testme
|
||||||
example;
|
swigexample;
|
||||||
assert(cvar.ivar == ifunc);
|
assert(cvar.ivar == ifunc);
|
||||||
assert(exist("example","var"));
|
assert(exist("swigexample","var"));
|
||||||
endfunction
|
endfunction
|
||||||
testme
|
testme
|
||||||
testme
|
testme
|
||||||
example;
|
swigexample;
|
||||||
assert(cvar.ivar == ifunc);
|
assert(cvar.ivar == ifunc);
|
||||||
assert(exist("example","var"));
|
assert(exist("swigexample","var"));
|
||||||
clear all
|
clear all
|
||||||
function testme
|
function testme
|
||||||
example;
|
swigexample;
|
||||||
assert(cvar.ivar == ifunc);
|
assert(cvar.ivar == ifunc);
|
||||||
assert(exist("example","var"));
|
assert(exist("swigexample","var"));
|
||||||
endfunction
|
endfunction
|
||||||
testme
|
testme
|
||||||
testme
|
testme
|
||||||
example;
|
swigexample;
|
||||||
assert(cvar.ivar == ifunc);
|
assert(cvar.ivar == ifunc);
|
||||||
assert(exist("example","var"));
|
assert(exist("swigexample","var"));
|
||||||
clear all
|
clear all
|
||||||
|
|
||||||
# load module in a function globally after base context
|
# load module in a function globally after base context
|
||||||
clear all;
|
clear all;
|
||||||
example;
|
swigexample;
|
||||||
assert(cvar.ivar == ifunc);
|
assert(cvar.ivar == ifunc);
|
||||||
assert(exist("example","var"));
|
assert(exist("swigexample","var"));
|
||||||
function testme
|
function testme
|
||||||
example;
|
swigexample;
|
||||||
assert(cvar.ivar == ifunc);
|
assert(cvar.ivar == ifunc);
|
||||||
assert(exist("example","var"));
|
assert(exist("swigexample","var"));
|
||||||
endfunction
|
endfunction
|
||||||
testme
|
testme
|
||||||
testme
|
testme
|
||||||
clear all
|
clear all
|
||||||
example;
|
swigexample;
|
||||||
assert(cvar.ivar == ifunc);
|
assert(cvar.ivar == ifunc);
|
||||||
assert(exist("example","var"));
|
assert(exist("swigexample","var"));
|
||||||
function testme
|
function testme
|
||||||
example;
|
swigexample;
|
||||||
assert(cvar.ivar == ifunc);
|
assert(cvar.ivar == ifunc);
|
||||||
assert(exist("example","var"));
|
assert(exist("swigexample","var"));
|
||||||
endfunction
|
endfunction
|
||||||
testme
|
testme
|
||||||
testme
|
testme
|
||||||
|
|
@ -69,13 +69,13 @@ endif
|
||||||
|
|
||||||
# load module with no cvar
|
# load module with no cvar
|
||||||
clear all;
|
clear all;
|
||||||
example2;
|
swigexample2;
|
||||||
assert(example2.ivar == ifunc);
|
assert(swigexample2.ivar == ifunc);
|
||||||
assert(exist("example2","var"));
|
assert(exist("swigexample2","var"));
|
||||||
assert(!isglobal("cvar"))
|
assert(!isglobal("cvar"))
|
||||||
clear all
|
clear all
|
||||||
example2;
|
swigexample2;
|
||||||
assert(example2.ivar == ifunc);
|
assert(swigexample2.ivar == ifunc);
|
||||||
assert(exist("example2","var"));
|
assert(exist("swigexample2","var"));
|
||||||
assert(!isglobal("cvar"))
|
assert(!isglobal("cvar"))
|
||||||
clear all
|
clear all
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIG = $(TOP)/../preinst-swig
|
||||||
CXXSRCS =
|
CXXSRCS =
|
||||||
TARGET = example
|
TARGET = swigexample
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
LIBS = -lm
|
LIBS = -lm
|
||||||
SWIGOPT =
|
SWIGOPT =
|
||||||
|
|
@ -13,9 +13,5 @@ build:
|
||||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
||||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
|
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
|
||||||
|
|
||||||
static:
|
|
||||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
|
||||||
TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(MAKE) -f $(TOP)/Makefile octave_clean
|
$(MAKE) -f $(TOP)/Makefile octave_clean
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/* File : example.i */
|
/* File : example.i */
|
||||||
%module example
|
%module swigexample
|
||||||
#pragma SWIG nowarn=SWIGWARN_IGNORE_OPERATOR_EQ
|
#pragma SWIG nowarn=SWIGWARN_IGNORE_OPERATOR_EQ
|
||||||
%{
|
%{
|
||||||
#include "example.h"
|
#include "example.h"
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
# Operator overloading example
|
# Operator overloading example
|
||||||
example
|
swigexample
|
||||||
|
|
||||||
a = example.ComplexVal(2,3);
|
a = swigexample.ComplexVal(2,3);
|
||||||
b = example.ComplexVal(-5,10);
|
b = swigexample.ComplexVal(-5,10);
|
||||||
|
|
||||||
printf("a = %s\n",disp(a));
|
printf("a = %s\n",disp(a));
|
||||||
printf("b = %s\n",disp(b));
|
printf("b = %s\n",disp(b));
|
||||||
|
|
@ -12,7 +12,7 @@ printf("c = %s\n",disp(c));
|
||||||
printf("a*b = %s\n",disp(a*b));
|
printf("a*b = %s\n",disp(a*b));
|
||||||
printf("a-c = %s\n",disp(a-c));
|
printf("a-c = %s\n",disp(a-c));
|
||||||
|
|
||||||
e = example.ComplexVal(a-c);
|
e = swigexample.ComplexVal(a-c);
|
||||||
printf("e = %s\n",disp(e));
|
printf("e = %s\n",disp(e));
|
||||||
|
|
||||||
# Big expression
|
# Big expression
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIG = $(TOP)/../preinst-swig
|
||||||
SRCS = example.c
|
SRCS = example.c
|
||||||
TARGET = example
|
TARGET = swigexample
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
|
|
||||||
check: build
|
check: build
|
||||||
|
|
@ -11,9 +11,5 @@ build:
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
|
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
|
||||||
|
|
||||||
static:
|
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
|
||||||
TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(MAKE) -f $(TOP)/Makefile octave_clean
|
$(MAKE) -f $(TOP)/Makefile octave_clean
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/* File : example.i */
|
/* File : example.i */
|
||||||
%module example
|
%module swigexample
|
||||||
|
|
||||||
%{
|
%{
|
||||||
extern void add(int *, int *, int *);
|
extern void add(int *, int *, int *);
|
||||||
|
|
@ -24,7 +24,3 @@ extern void sub(int *INPUT, int *INPUT, int *OUTPUT);
|
||||||
|
|
||||||
%apply int *OUTPUT { int *r };
|
%apply int *OUTPUT { int *r };
|
||||||
extern int divide(int n, int d, int *r);
|
extern int divide(int n, int d, int *r);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,42 +1,39 @@
|
||||||
# file: runme.m
|
# file: runme.m
|
||||||
|
|
||||||
example;
|
swigexample;
|
||||||
|
|
||||||
# First create some objects using the pointer library.
|
# First create some objects using the pointer library.
|
||||||
printf("Testing the pointer library\n");
|
printf("Testing the pointer library\n");
|
||||||
a = example.new_intp();
|
a = swigexample.new_intp();
|
||||||
b = example.new_intp();
|
b = swigexample.new_intp();
|
||||||
c = example.new_intp();
|
c = swigexample.new_intp();
|
||||||
example.intp_assign(a,37);
|
swigexample.intp_assign(a,37);
|
||||||
example.intp_assign(b,42);
|
swigexample.intp_assign(b,42);
|
||||||
|
|
||||||
a,b,c
|
a,b,c
|
||||||
|
|
||||||
# Call the add() function with some pointers
|
# Call the add() function with some pointers
|
||||||
example.add(a,b,c);
|
swigexample.add(a,b,c);
|
||||||
|
|
||||||
# Now get the result
|
# Now get the result
|
||||||
r = example.intp_value(c);
|
r = swigexample.intp_value(c);
|
||||||
printf(" 37 + 42 = %i\n",r);
|
printf(" 37 + 42 = %i\n",r);
|
||||||
|
|
||||||
# Clean up the pointers
|
# Clean up the pointers
|
||||||
example.delete_intp(a);
|
swigexample.delete_intp(a);
|
||||||
example.delete_intp(b);
|
swigexample.delete_intp(b);
|
||||||
example.delete_intp(c);
|
swigexample.delete_intp(c);
|
||||||
|
|
||||||
# Now try the typemap library
|
# Now try the typemap library
|
||||||
# This should be much easier. Now how it is no longer
|
# This should be much easier. Now how it is no longer
|
||||||
# necessary to manufacture pointers.
|
# necessary to manufacture pointers.
|
||||||
|
|
||||||
printf("Trying the typemap library\n");
|
printf("Trying the typemap library\n");
|
||||||
r = example.sub(37,42);
|
r = swigexample.sub(37,42);
|
||||||
printf(" 37 - 42 = %i\n",r);
|
printf(" 37 - 42 = %i\n",r);
|
||||||
|
|
||||||
# Now try the version with multiple return values
|
# Now try the version with multiple return values
|
||||||
|
|
||||||
printf("Testing multiple return values\n");
|
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);
|
printf(" 42/37 = %d remainder %d\n",q,r);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIG = $(TOP)/../preinst-swig
|
||||||
CXXSRCS = example.cxx
|
CXXSRCS = example.cxx
|
||||||
TARGET = example
|
TARGET = swigexample
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
LIBS = -lm
|
LIBS = -lm
|
||||||
SWIGOPT =
|
SWIGOPT =
|
||||||
|
|
@ -13,9 +13,5 @@ build:
|
||||||
$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
||||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
|
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
|
||||||
|
|
||||||
static:
|
|
||||||
$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
|
||||||
SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(MAKE) -f $(TOP)/Makefile octave_clean
|
$(MAKE) -f $(TOP)/Makefile octave_clean
|
||||||
|
|
|
||||||
|
|
@ -43,4 +43,3 @@ Vector &VectorArray::operator[](int index) {
|
||||||
int VectorArray::size() {
|
int VectorArray::size() {
|
||||||
return maxsize;
|
return maxsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,3 @@ public:
|
||||||
Vector &operator[](int);
|
Vector &operator[](int);
|
||||||
int size();
|
int size();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
/* This file has a few "typical" uses of C++ references. */
|
/* This file has a few "typical" uses of C++ references. */
|
||||||
|
|
||||||
%module example
|
%module swigexample
|
||||||
|
|
||||||
%{
|
%{
|
||||||
#include "example.h"
|
#include "example.h"
|
||||||
|
|
@ -42,7 +42,3 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,13 @@
|
||||||
|
|
||||||
# This file illustrates the manipulation of C++ references in Octave
|
# This file illustrates the manipulation of C++ references in Octave
|
||||||
|
|
||||||
example
|
swigexample
|
||||||
|
|
||||||
# ----- Object creation -----
|
# ----- Object creation -----
|
||||||
|
|
||||||
printf("Creating some objects:\n");
|
printf("Creating some objects:\n");
|
||||||
a = example.Vector(3,4,5)
|
a = swigexample.Vector(3,4,5)
|
||||||
b = example.Vector(10,11,12)
|
b = swigexample.Vector(10,11,12)
|
||||||
|
|
||||||
printf(" Created %s\n",a.cprint());
|
printf(" Created %s\n",a.cprint());
|
||||||
printf(" Created %s\n",b.cprint());
|
printf(" Created %s\n",b.cprint());
|
||||||
|
|
@ -22,7 +22,7 @@ printf(" Created %s\n",b.cprint());
|
||||||
# It returns a new allocated object.
|
# It returns a new allocated object.
|
||||||
|
|
||||||
printf("Adding a+b\n");
|
printf("Adding a+b\n");
|
||||||
c = example.addv(a,b);
|
c = swigexample.addv(a,b);
|
||||||
printf(" a+b = %s\n", c.cprint());
|
printf(" a+b = %s\n", c.cprint());
|
||||||
|
|
||||||
clear c
|
clear c
|
||||||
|
|
@ -31,7 +31,7 @@ clear c
|
||||||
|
|
||||||
# Note: Using the high-level interface here
|
# Note: Using the high-level interface here
|
||||||
printf("Creating an array of vectors\n");
|
printf("Creating an array of vectors\n");
|
||||||
va = example.VectorArray(10)
|
va = swigexample.VectorArray(10)
|
||||||
|
|
||||||
# ----- Set some values in the array -----
|
# ----- Set some values in the array -----
|
||||||
|
|
||||||
|
|
@ -39,7 +39,7 @@ va = example.VectorArray(10)
|
||||||
va.set(0,a);
|
va.set(0,a);
|
||||||
va.set(1,b);
|
va.set(1,b);
|
||||||
|
|
||||||
va.set(2,example.addv(a,b))
|
va.set(2,swigexample.addv(a,b))
|
||||||
|
|
||||||
# Get some values from the array
|
# Get some values from the array
|
||||||
|
|
||||||
|
|
@ -60,4 +60,3 @@ printf("Cleaning up\n");
|
||||||
clear va
|
clear va
|
||||||
clear a
|
clear a
|
||||||
clear b
|
clear b
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIG = $(TOP)/../preinst-swig
|
||||||
SRCS = example.c
|
SRCS = example.c
|
||||||
TARGET = example
|
TARGET = swigexample
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
|
|
||||||
check: build
|
check: build
|
||||||
|
|
@ -11,9 +11,5 @@ build:
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
|
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
|
||||||
|
|
||||||
static:
|
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
|
||||||
TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(MAKE) -f $(TOP)/Makefile octave_clean
|
$(MAKE) -f $(TOP)/Makefile octave_clean
|
||||||
|
|
|
||||||
|
|
@ -14,5 +14,3 @@ int gcd(int x, int y) {
|
||||||
}
|
}
|
||||||
return g;
|
return g;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/* File : example.i */
|
/* File : example.i */
|
||||||
%module example
|
%module swigexample
|
||||||
|
|
||||||
%inline %{
|
%inline %{
|
||||||
extern int gcd(int x, int y);
|
extern int gcd(int x, int y);
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,21 @@
|
||||||
# file: runme.m
|
# file: runme.m
|
||||||
|
|
||||||
example
|
swigexample
|
||||||
|
|
||||||
# Call our gcd() function
|
# Call our gcd() function
|
||||||
|
|
||||||
x = 42
|
x = 42
|
||||||
y = 105
|
y = 105
|
||||||
g = example.gcd(x,y)
|
g = swigexample.gcd(x,y)
|
||||||
printf("The gcd of %d and %d is %d\n",x,y,g);
|
printf("The gcd of %d and %d is %d\n",x,y,g);
|
||||||
|
|
||||||
# Manipulate the Foo global variable
|
# Manipulate the Foo global variable
|
||||||
|
|
||||||
# Output its current value
|
# Output its current value
|
||||||
example.cvar.Foo
|
swigexample.cvar.Foo
|
||||||
|
|
||||||
# Change its value
|
# Change its value
|
||||||
example.cvar.Foo = 3.1415926
|
swigexample.cvar.Foo = 3.1415926
|
||||||
|
|
||||||
# See if the change took effect
|
# See if the change took effect
|
||||||
printf("Foo = %f\n", example.cvar.Foo);
|
printf("Foo = %f\n", swigexample.cvar.Foo);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIG = $(TOP)/../preinst-swig
|
||||||
CXXSRCS =
|
CXXSRCS =
|
||||||
TARGET = example
|
TARGET = swigexample
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
LIBS = -lm
|
LIBS = -lm
|
||||||
SWIGOPT =
|
SWIGOPT =
|
||||||
|
|
@ -13,9 +13,5 @@ build:
|
||||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
||||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
|
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
|
||||||
|
|
||||||
static:
|
|
||||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
|
||||||
SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(MAKE) -f $(TOP)/Makefile octave_clean
|
$(MAKE) -f $(TOP)/Makefile octave_clean
|
||||||
|
|
|
||||||
|
|
@ -29,4 +29,3 @@ template<class T> class vector {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/* File : example.i */
|
/* File : example.i */
|
||||||
%module example
|
%module swigexample
|
||||||
|
|
||||||
%{
|
%{
|
||||||
#include "example.h"
|
#include "example.h"
|
||||||
|
|
@ -14,4 +14,3 @@
|
||||||
%template(maxdouble) max<double>;
|
%template(maxdouble) max<double>;
|
||||||
%template(vecint) vector<int>;
|
%template(vecint) vector<int>;
|
||||||
%template(vecdouble) vector<double>;
|
%template(vecdouble) vector<double>;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
# file: runme.m
|
# file: runme.m
|
||||||
|
|
||||||
example
|
swigexample
|
||||||
|
|
||||||
# Call some templated functions
|
# Call some templated functions
|
||||||
example.maxint(3,7)
|
swigexample.maxint(3,7)
|
||||||
example.maxdouble(3.14,2.18)
|
swigexample.maxdouble(3.14,2.18)
|
||||||
|
|
||||||
# Create some class
|
# Create some class
|
||||||
|
|
||||||
iv = example.vecint(100)
|
iv = swigexample.vecint(100)
|
||||||
dv = example.vecdouble(1000)
|
dv = swigexample.vecdouble(1000)
|
||||||
|
|
||||||
for i=0:99,
|
for i=0:99,
|
||||||
iv.setitem(i,2*i);
|
iv.setitem(i,2*i);
|
||||||
|
|
@ -33,5 +33,3 @@ sum
|
||||||
|
|
||||||
clear iv
|
clear iv
|
||||||
clear dv
|
clear dv
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIG = $(TOP)/../preinst-swig
|
||||||
SRCS = example.c
|
SRCS = example.c
|
||||||
TARGET = example
|
TARGET = swigexample
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
|
|
||||||
check: build
|
check: build
|
||||||
|
|
@ -11,9 +11,5 @@ build:
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
|
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
|
||||||
|
|
||||||
static:
|
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
|
||||||
TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(MAKE) -f $(TOP)/Makefile octave_clean
|
$(MAKE) -f $(TOP)/Makefile octave_clean
|
||||||
|
|
|
||||||
|
|
@ -3,4 +3,3 @@
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int x,y;
|
int x,y;
|
||||||
} Point;
|
} Point;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/* File : example.i */
|
/* File : example.i */
|
||||||
%module example
|
%module swigexample
|
||||||
%{
|
%{
|
||||||
#include "example.h"
|
#include "example.h"
|
||||||
%}
|
%}
|
||||||
|
|
@ -50,4 +50,3 @@ extern Point *new_Point(int x, int y);
|
||||||
extern char *Point_print(Point *p);
|
extern char *Point_print(Point *p);
|
||||||
extern void pt_print();
|
extern void pt_print();
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,56 +1,56 @@
|
||||||
# file: runme.m
|
# file: runme.m
|
||||||
|
|
||||||
example
|
swigexample
|
||||||
|
|
||||||
# Try to set the values of some global variables
|
# Try to set the values of some global variables
|
||||||
|
|
||||||
example.cvar.ivar = 42;
|
swigexample.cvar.ivar = 42;
|
||||||
example.cvar.svar = -31000;
|
swigexample.cvar.svar = -31000;
|
||||||
example.cvar.lvar = 65537;
|
swigexample.cvar.lvar = 65537;
|
||||||
example.cvar.uivar = 123456;
|
swigexample.cvar.uivar = 123456;
|
||||||
example.cvar.usvar = 61000;
|
swigexample.cvar.usvar = 61000;
|
||||||
example.cvar.ulvar = 654321;
|
swigexample.cvar.ulvar = 654321;
|
||||||
example.cvar.scvar = -13;
|
swigexample.cvar.scvar = -13;
|
||||||
example.cvar.ucvar = 251;
|
swigexample.cvar.ucvar = 251;
|
||||||
example.cvar.cvar = "S";
|
swigexample.cvar.cvar = "S";
|
||||||
example.cvar.fvar = 3.14159;
|
swigexample.cvar.fvar = 3.14159;
|
||||||
example.cvar.dvar = 2.1828;
|
swigexample.cvar.dvar = 2.1828;
|
||||||
example.cvar.strvar = "Hello World";
|
swigexample.cvar.strvar = "Hello World";
|
||||||
example.cvar.iptrvar= example.new_int(37);
|
swigexample.cvar.iptrvar= swigexample.new_int(37);
|
||||||
example.cvar.ptptr = example.new_Point(37,42);
|
swigexample.cvar.ptptr = swigexample.new_Point(37,42);
|
||||||
example.cvar.name = "Bill";
|
swigexample.cvar.name = "Bill";
|
||||||
|
|
||||||
# Now print out the values of the variables
|
# Now print out the values of the variables
|
||||||
|
|
||||||
printf("Variables (values printed from Octave)\n");
|
printf("Variables (values printed from Octave)\n");
|
||||||
|
|
||||||
printf("ivar = %i\n", example.cvar.ivar);
|
printf("ivar = %i\n", swigexample.cvar.ivar);
|
||||||
printf("svar = %i\n", example.cvar.svar);
|
printf("svar = %i\n", swigexample.cvar.svar);
|
||||||
printf("lvar = %i\n", example.cvar.lvar);
|
printf("lvar = %i\n", swigexample.cvar.lvar);
|
||||||
printf("uivar = %i\n", example.cvar.uivar);
|
printf("uivar = %i\n", swigexample.cvar.uivar);
|
||||||
printf("usvar = %i\n", example.cvar.usvar);
|
printf("usvar = %i\n", swigexample.cvar.usvar);
|
||||||
printf("ulvar = %i\n", example.cvar.ulvar);
|
printf("ulvar = %i\n", swigexample.cvar.ulvar);
|
||||||
printf("scvar = %i\n", example.cvar.scvar);
|
printf("scvar = %i\n", swigexample.cvar.scvar);
|
||||||
printf("ucvar = %i\n", example.cvar.ucvar);
|
printf("ucvar = %i\n", swigexample.cvar.ucvar);
|
||||||
printf("fvar = %i\n", example.cvar.fvar);
|
printf("fvar = %i\n", swigexample.cvar.fvar);
|
||||||
printf("dvar = %i\n", example.cvar.dvar);
|
printf("dvar = %i\n", swigexample.cvar.dvar);
|
||||||
printf("cvar = %s\n", example.cvar.cvar);
|
printf("cvar = %s\n", swigexample.cvar.cvar);
|
||||||
printf("strvar = %s\n", example.cvar.strvar);
|
printf("strvar = %s\n", swigexample.cvar.strvar);
|
||||||
#printf("cstrvar = %s\n", example.cvar.cstrvar);
|
#printf("cstrvar = %s\n", swigexample.cvar.cstrvar);
|
||||||
example.cvar.iptrvar
|
swigexample.cvar.iptrvar
|
||||||
printf("name = %i\n", example.cvar.name);
|
printf("name = %i\n", swigexample.cvar.name);
|
||||||
printf("ptptr = %s\n", example.Point_print(example.cvar.ptptr));
|
printf("ptptr = %s\n", swigexample.Point_print(swigexample.cvar.ptptr));
|
||||||
#printf("pt = %s\n", example.cvar.Point_print(example.cvar.pt));
|
#printf("pt = %s\n", swigexample.cvar.Point_print(swigexample.cvar.pt));
|
||||||
|
|
||||||
printf("\nVariables (values printed from C)\n");
|
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("\nNow I'm going to try and modify some read only variables\n");
|
||||||
|
|
||||||
printf(" Tring to set 'path'\n");
|
printf(" Tring to set 'path'\n");
|
||||||
try
|
try
|
||||||
example.cvar.path = "Whoa!";
|
swigexample.cvar.path = "Whoa!";
|
||||||
printf("Hey, what's going on?!?! This shouldn't work\n");
|
printf("Hey, what's going on?!?! This shouldn't work\n");
|
||||||
catch
|
catch
|
||||||
printf("Good.\n");
|
printf("Good.\n");
|
||||||
|
|
@ -58,7 +58,7 @@ end_try_catch
|
||||||
|
|
||||||
printf(" Trying to set 'status'\n");
|
printf(" Trying to set 'status'\n");
|
||||||
try
|
try
|
||||||
example.cvar.status = 0;
|
swigexample.cvar.status = 0;
|
||||||
printf("Hey, what's going on?!?! This shouldn't work\n");
|
printf("Hey, what's going on?!?! This shouldn't work\n");
|
||||||
catch
|
catch
|
||||||
printf("Good.\n");
|
printf("Good.\n");
|
||||||
|
|
@ -67,9 +67,6 @@ end_try_catch
|
||||||
|
|
||||||
printf("\nI'm going to try and update a structure variable.\n");
|
printf("\nI'm going to try and update a structure variable.\n");
|
||||||
|
|
||||||
example.cvar.pt = example.cvar.ptptr;
|
swigexample.cvar.pt = swigexample.cvar.ptptr;
|
||||||
|
|
||||||
printf("The new value is %s\n", example.Point_print(example.cvar.pt));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
printf("The new value is %s\n", swigexample.Point_print(swigexample.cvar.pt));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue