Convert javascript examples to nodejs.
This commit is contained in:
parent
dbf2b1fe94
commit
5da54ca435
48 changed files with 312 additions and 223 deletions
|
|
@ -1,21 +1,21 @@
|
|||
TOP = ../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
CXXSRCS = example.cpp
|
||||
CXXSRCS = example.cxx
|
||||
JS_SCRIPT = runme.js
|
||||
TARGET = example
|
||||
INTERFACE = example.i
|
||||
|
||||
all::
|
||||
wrapper::
|
||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' javascript_cpp
|
||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' javascript_wrapper_cpp
|
||||
|
||||
build:: wrapper
|
||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' javascript_build
|
||||
|
||||
clean::
|
||||
$(MAKE) -f $(TOP)/Makefile javascript_clean
|
||||
|
||||
javascript_exe::
|
||||
$(MAKE) -f $(TOP)/Makefile JSCXXSRCS='$(JSCXXSRCS)' TARGET='$(TARGET)' \
|
||||
TOP='$(TOP)' javascript_exe
|
||||
|
||||
check:: all
|
||||
check:: build
|
||||
$(MAKE) -f $(TOP)/Makefile JSCXXSRCS='$(JSCXXSRCS)' TARGET='$(TARGET)' \
|
||||
TOP='$(TOP)' JS_SCRIPT='$(JS_SCRIPT)' javascript_run
|
||||
|
|
|
|||
8
Examples/javascript/exception/binding.gyp
Normal file
8
Examples/javascript/exception/binding.gyp
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"targets": [
|
||||
{
|
||||
"target_name": "example",
|
||||
"sources": [ "example.cxx", "example_wrap.cxx" ]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
//file: runme.js
|
||||
// Throw a lot of exceptions
|
||||
var example = require("./build/Release/example");
|
||||
|
||||
print("Trying to catch some exceptions.");
|
||||
console.log("Trying to catch some exceptions.");
|
||||
t = new example.Test();
|
||||
try{
|
||||
t.unknown();
|
||||
|
|
@ -9,9 +8,9 @@ try{
|
|||
} catch(error)
|
||||
{
|
||||
if(error == -1) {
|
||||
print("t.unknown() didn't throw");
|
||||
console.log("t.unknown() didn't throw");
|
||||
} else {
|
||||
print("successfully catched throw in Test::unknown().");
|
||||
console.log("successfully catched throw in Test::unknown().");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -21,9 +20,9 @@ try{
|
|||
}
|
||||
catch(error){
|
||||
if(error == -1) {
|
||||
print("t.simple() did not throw");
|
||||
console.log("t.simple() did not throw");
|
||||
} else {
|
||||
print("successfully catched throw in Test::simple().");
|
||||
console.log("successfully catched throw in Test::simple().");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -32,9 +31,9 @@ try{
|
|||
throw -1;
|
||||
} catch(error){
|
||||
if(error == -1) {
|
||||
print("t.message() did not throw");
|
||||
console.log("t.message() did not throw");
|
||||
} else {
|
||||
print("successfully catched throw in Test::message().");
|
||||
console.log("successfully catched throw in Test::message().");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -44,9 +43,9 @@ try{
|
|||
}
|
||||
catch(error){
|
||||
if(error == -1) {
|
||||
print("t.hosed() did not throw");
|
||||
console.log("t.hosed() did not throw");
|
||||
} else {
|
||||
print("successfully catched throw in Test::hosed().");
|
||||
console.log("successfully catched throw in Test::hosed().");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -57,9 +56,9 @@ for (var i=1; i<4; i++) {
|
|||
}
|
||||
catch(error){
|
||||
if(error == -1) {
|
||||
print("t.multi(" + i + ") did not throw");
|
||||
console.log("t.multi(" + i + ") did not throw");
|
||||
} else {
|
||||
print("successfully catched throw in Test::multi().");
|
||||
console.log("successfully catched throw in Test::multi().");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue