Initial commit of Octave module.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10290 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Xavier Delacour 2008-03-01 23:35:44 +00:00
commit 393391965c
275 changed files with 14004 additions and 5 deletions

View file

@ -0,0 +1,21 @@
TOP = ../..
SWIG = $(TOP)/../preinst-swig
CXXSRCS = example.cxx
TARGET = example
INTERFACE = example.i
LIBS = -lm
SWIGOPT =
all::
$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
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::
$(MAKE) -f $(TOP)/Makefile octave_clean
rm -f $(TARGET).py
check: all

View 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");
}
}

View file

@ -0,0 +1,13 @@
/* 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);

View file

@ -0,0 +1,11 @@
/* File : example.i */
%module example
%{
#include "example.h"
%}
/* Let's just grab the original header file here */
%include "example.h"

View file

@ -0,0 +1,32 @@
# file: runme.m
example
# ----- Object creation -----
# Print out the value of some enums
printf("*** color ***\n");
printf(" RED = %i\n", example.RED);
printf(" BLUE = %i\n", example.BLUE);
printf(" GREEN = %i\n", example.GREEN);
printf("\n*** Foo::speed ***\n");
printf(" Foo_IMPULSE = %i\n", example.Foo_IMPULSE);
printf(" Foo_WARP = %i\n", example.Foo_WARP);
printf(" Foo_LUDICROUS = %i\n", example.Foo_LUDICROUS);
printf("\nTesting use of enums with functions\n");
example.enum_test(example.RED, example.Foo_IMPULSE);
example.enum_test(example.BLUE, example.Foo_WARP);
example.enum_test(example.GREEN, example.Foo_LUDICROUS);
example.enum_test(1234,5678)
printf("\nTesting use of enum with class method\n");
f = example.Foo();
f.enum_test(example.Foo_IMPULSE);
f.enum_test(example.Foo_WARP);
f.enum_test(example.Foo_LUDICROUS);