Conflicts:
	.project
	COPYRIGHT
	Doc/Manual/style.css
	Examples/Makefile.in
	Examples/test-suite/common.mk
	Lib/typemaps/strings.swg
	Makefile.in
	Source/DOH/fio.c
	Source/Makefile.am
	Source/Modules/emit.cxx
	Source/Modules/javascript.cxx
	configure.in

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/oliverb-javascript-v8@13764 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Oliver Buchtala 2012-09-08 00:56:48 +00:00
commit 050219d998
136 changed files with 7987 additions and 141 deletions

View file

@ -0,0 +1,24 @@
TOP = ../..
SWIG = $(TOP)/../preinst-swig
SRCS = example.cpp
JSCXXSRCS = $(TOP)/../Tools/javascript/javascript.cxx
JAVASCRIPT_EXE = $(TOP)/../Tools/javascript/javascript
JAVASCRIPT_MODULE = example
JS_SCRIPT = runme.js
TARGET = example
INTERFACE = example.i
SWIGOPT = -I$(TOP)/../Lib/javascript -I$(TOP)/../Lib/javascript/jsc
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' javascript_cpp
clean::
$(MAKE) -f $(TOP)/Makefile javascript_clean
check:: all
$(MAKE) -f $(TOP)/Makefile JSCXXSRCS='$(JSCXXSRCS)' TARGET='$(TARGET)' \
JAVASCRIPT_EXE='$(JAVASCRIPT_EXE)' javascript_exe
$(MAKE) -f $(TOP)/Makefile JSCXXSRCS='$(JSCXXSRCS)' TARGET='$(TARGET)' \
JAVASCRIPT_EXE='$(JAVASCRIPT_EXE)' JAVASCRIPT_MODULE='$(JAVASCRIPT_MODULE)' JS_SCRIPT='$(JS_SCRIPT)' javascript_run

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=10, WARP=20, LUDICROUS=30 };
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,34 @@
// file: runme.py
// ----- Object creation -----
// Print out the value of some enums
print("*** color ***");
print(" RED =" + example.RED);
print(" BLUE =" + example.BLUE);
print(" GREEN =" + example.GREEN);
print("\n*** Foo::speed ***");
print(" Foo_IMPULSE =" + example.Foo.IMPULSE);
print(" Foo_WARP =" + example.Foo.WARP);
print(" Foo_LUDICROUS =" + example.Foo.LUDICROUS);
print("\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);
print("\nTesting use of enum with class method");
f = new example.Foo();
f.enum_test(example.Foo.IMPULSE);
f.enum_test(example.Foo.WARP);
f.enum_test(example.Foo.LUDICROUS);
// enum value BLUE of enum color is accessed as property of cconst
print("example.BLUE= " + example.BLUE);
// enum value LUDICROUS of enum Foo::speed is accessed as as property of cconst
print("example.speed.LUDICROUS= " + example.Foo.LUDICROUS);