update swig on windows
This commit is contained in:
3
winx64/bin/swigwin-4.0.0/Examples/octave/enum/Makefile
Normal file
3
winx64/bin/swigwin-4.0.0/Examples/octave/enum/Makefile
Normal file
@@ -0,0 +1,3 @@
|
||||
CXXSRCS = example.cxx
|
||||
|
||||
include $(SRCDIR)../example.mk
|
||||
37
winx64/bin/swigwin-4.0.0/Examples/octave/enum/example.cxx
Normal file
37
winx64/bin/swigwin-4.0.0/Examples/octave/enum/example.cxx
Normal file
@@ -0,0 +1,37 @@
|
||||
/* File : example.c */
|
||||
|
||||
#include "example.h"
|
||||
#include <stdio.h>
|
||||
|
||||
void Foo::enum_test(speed s) {
|
||||
if (s == IMPULSE) {
|
||||
printf("IMPULSE speed\n");
|
||||
} else if (s == WARP) {
|
||||
printf("WARP speed\n");
|
||||
} else if (s == LUDICROUS) {
|
||||
printf("LUDICROUS speed\n");
|
||||
} else {
|
||||
printf("Unknown speed\n");
|
||||
}
|
||||
}
|
||||
|
||||
void enum_test(color c, Foo::speed s) {
|
||||
if (c == RED) {
|
||||
printf("color = RED, ");
|
||||
} else if (c == BLUE) {
|
||||
printf("color = BLUE, ");
|
||||
} else if (c == GREEN) {
|
||||
printf("color = GREEN, ");
|
||||
} else {
|
||||
printf("color = Unknown color!, ");
|
||||
}
|
||||
if (s == Foo::IMPULSE) {
|
||||
printf("speed = IMPULSE speed\n");
|
||||
} else if (s == Foo::WARP) {
|
||||
printf("speed = WARP speed\n");
|
||||
} else if (s == Foo::LUDICROUS) {
|
||||
printf("speed = LUDICROUS speed\n");
|
||||
} else {
|
||||
printf("speed = Unknown speed!\n");
|
||||
}
|
||||
}
|
||||
12
winx64/bin/swigwin-4.0.0/Examples/octave/enum/example.h
Normal file
12
winx64/bin/swigwin-4.0.0/Examples/octave/enum/example.h
Normal file
@@ -0,0 +1,12 @@
|
||||
/* File : example.h */
|
||||
|
||||
enum color { RED, BLUE, GREEN };
|
||||
|
||||
class Foo {
|
||||
public:
|
||||
Foo() { }
|
||||
enum speed { IMPULSE, WARP, LUDICROUS };
|
||||
void enum_test(speed s);
|
||||
};
|
||||
|
||||
void enum_test(color c, Foo::speed s);
|
||||
12
winx64/bin/swigwin-4.0.0/Examples/octave/enum/example.i
Normal file
12
winx64/bin/swigwin-4.0.0/Examples/octave/enum/example.i
Normal file
@@ -0,0 +1,12 @@
|
||||
/* File : example.i */
|
||||
%module swigexample
|
||||
|
||||
%feature("autodoc", 1);
|
||||
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
||||
/* Let's just grab the original header file here */
|
||||
|
||||
%include "example.h"
|
||||
33
winx64/bin/swigwin-4.0.0/Examples/octave/enum/runme.m
Normal file
33
winx64/bin/swigwin-4.0.0/Examples/octave/enum/runme.m
Normal file
@@ -0,0 +1,33 @@
|
||||
# do not dump Octave core
|
||||
if exist("crash_dumps_octave_core", "builtin")
|
||||
crash_dumps_octave_core(0);
|
||||
endif
|
||||
|
||||
swigexample
|
||||
|
||||
# ----- Object creation -----
|
||||
|
||||
# Print out the value of some enums
|
||||
printf("*** color ***\n");
|
||||
printf(" RED = %i\n", swigexample.RED);
|
||||
printf(" BLUE = %i\n", swigexample.BLUE);
|
||||
printf(" GREEN = %i\n", swigexample.GREEN);
|
||||
|
||||
printf("\n*** Foo::speed ***\n");
|
||||
printf(" Foo_IMPULSE = %i\n", swigexample.Foo_IMPULSE);
|
||||
printf(" Foo_WARP = %i\n", swigexample.Foo_WARP);
|
||||
printf(" Foo_LUDICROUS = %i\n", swigexample.Foo_LUDICROUS);
|
||||
|
||||
printf("\nTesting use of enums with functions\n");
|
||||
|
||||
swigexample.enum_test(swigexample.RED, swigexample.Foo_IMPULSE);
|
||||
swigexample.enum_test(swigexample.BLUE, swigexample.Foo_WARP);
|
||||
swigexample.enum_test(swigexample.GREEN, swigexample.Foo_LUDICROUS);
|
||||
swigexample.enum_test(1234,5678)
|
||||
|
||||
printf("\nTesting use of enum with class method\n");
|
||||
f = swigexample.Foo();
|
||||
|
||||
f.enum_test(swigexample.Foo_IMPULSE);
|
||||
f.enum_test(swigexample.Foo_WARP);
|
||||
f.enum_test(swigexample.Foo_LUDICROUS);
|
||||
Reference in New Issue
Block a user