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/template/binding.gyp
Normal file
8
Examples/javascript/template/binding.gyp
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"targets": [
|
||||
{
|
||||
"target_name": "example",
|
||||
"sources": [ "example_wrap.cxx" ]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
// file: runme.js
|
||||
var example = require("./build/Release/example");
|
||||
|
||||
//Call some templated functions
|
||||
print(example.maxint(3,7));
|
||||
print(example.maxdouble(3.14,2.18));
|
||||
console.log(example.maxint(3,7));
|
||||
console.log(example.maxdouble(3.14,2.18));
|
||||
|
||||
// Create some class
|
||||
|
||||
|
|
@ -19,14 +19,12 @@ sum = 0;
|
|||
for(i=0;i<=100;i++)
|
||||
sum = sum + iv.getitem(i);
|
||||
|
||||
print(sum);
|
||||
console.log(sum);
|
||||
|
||||
sum = 0.0;
|
||||
for(i=0;i<=1000;i++)
|
||||
sum = sum + dv.getitem(i);
|
||||
print(sum);
|
||||
console.log(sum);
|
||||
|
||||
delete iv;
|
||||
delete dv;
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue