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 @@

View file

@ -0,0 +1,53 @@
/* File : example.h */
#include <string.h>
#ifndef SWIG
struct A {
};
#endif
class Exc {
public:
Exc(int c, const char *m) {
code = c;
strncpy(msg,m,256);
}
int code;
char msg[256];
};
#if defined(_MSC_VER)
#pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
#endif
class Test {
public:
int simple() throw(int) {
throw(37);
return 1;
}
int message() throw(const char *) {
throw("I died.");
return 1;
}
int hosed() throw(Exc) {
throw(Exc(42,"Hosed"));
return 1;
}
int unknown() throw(A*) {
static A a;
throw &a;
return 1;
}
int multi(int x) throw(int, const char *, Exc) {
if (x == 1) throw(37);
if (x == 2) throw("Bleah!");
if (x == 3) throw(Exc(42,"No-go-diggy-die"));
return 1;
}
};
#if defined(_MSC_VER)
#pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
#endif

View file

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

View file

@ -0,0 +1,54 @@
//file: runme.js
// Throw a lot of exceptions
t = new example.Test();
try{
t.unknown();
throw -1;
} catch(error)
{
if(error == -1) {
print("t.unknown() didn't throw");
}
}
try{
t.simple();
throw -1;
}
catch(error){
if(error == -1) {
print("t.simple() did not throw");
}
}
try{
t.message();
throw -1;
} catch(error){
if(error == -1) {
print("t.message() did not throw");
}
}
try{
t.hosed();
throw -1;
}
catch(error){
if(error == -1) {
print("t.hosed() did not throw");
}
}
for (var i=1; i<4; i++) {
try{
t.multi(i);
throw -1;
}
catch(error){
if(error == -1) {
print("t.mulit(" + i + ") did not throw");
}
}
}