Convert javascript examples to nodejs.

This commit is contained in:
Oliver Buchtala 2013-09-03 06:26:54 +02:00
commit 5da54ca435
48 changed files with 312 additions and 223 deletions

View file

@ -1,21 +1,21 @@
TOP = ../..
SWIG = $(TOP)/../preinst-swig
CXXSRCS =
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
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

View file

@ -0,0 +1,8 @@
{
"targets": [
{
"target_name": "example",
"sources": [ "example_wrap.cxx" ]
}
]
}

View file

@ -1,14 +1,14 @@
// file: runme.js
var example = require("./build/Release/example");
print("ICONST = " + example.ICONST + " (should be 42)\n");
print("FCONST = " + example.FCONST + " (should be 2.1828)\n");
print("CCONST = " + example.CCONST + " (should be 'x')\n");
print("CCONST2 = " + example.CCONST2 + " (this should be on a new line)\n");
print("SCONST = " + example.SCONST + " (should be 'Hello World')\n");
print("SCONST2 = " + example.SCONST2 + " (should be '\"Hello World\"')\n");
print("EXPR = " + example.EXPR + " (should be 48.5484)\n");
print("iconst = " + example.iconst + " (should be 37)\n");
print("fconst = " + example.fconst + " (should be 3.14)\n");
console.log("ICONST = " + example.ICONST + " (should be 42)\n");
console.log("FCONST = " + example.FCONST + " (should be 2.1828)\n");
console.log("CCONST = " + example.CCONST + " (should be 'x')\n");
console.log("CCONST2 = " + example.CCONST2 + " (this should be on a new line)\n");
console.log("SCONST = " + example.SCONST + " (should be 'Hello World')\n");
console.log("SCONST2 = " + example.SCONST2 + " (should be '\"Hello World\"')\n");
console.log("EXPR = " + example.EXPR + " (should be 48.5484)\n");
console.log("iconst = " + example.iconst + " (should be 37)\n");
console.log("fconst = " + example.fconst + " (should be 3.14)\n");
print("EXTERN = " + example.EXTERN + " (should be undefined)\n");
print("FOO = " + example.FOO + " (should be undefined)\n");
console.log("EXTERN = " + example.EXTERN + " (should be undefined)\n");
console.log("FOO = " + example.FOO + " (should be undefined)\n");