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
|
||||
SRCS = example.c
|
||||
CXXSRCS = example.cxx
|
||||
JS_SCRIPT = runme.js
|
||||
TARGET = example
|
||||
INTERFACE = example.i
|
||||
|
||||
all::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' javascript
|
||||
wrapper::
|
||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
||||
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/simple/binding.gyp
Normal file
8
Examples/javascript/simple/binding.gyp
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"targets": [
|
||||
{
|
||||
"target_name": "example",
|
||||
"sources": [ "example.cxx", "example_wrap.cxx" ]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -1,22 +1,22 @@
|
|||
/* file: runme.js */
|
||||
var example = require("./build/Release/example");
|
||||
|
||||
/* Call our gcd() function */
|
||||
|
||||
x = 42;
|
||||
y = 105;
|
||||
g = example.gcd(x,y);
|
||||
print("GCD of x and y is=" + g);
|
||||
console.log("GCD of x and y is=" + g);
|
||||
|
||||
/* Manipulate the Foo global variable */
|
||||
|
||||
/* Output its current value */
|
||||
print("Global variable Foo=" + example.Foo);
|
||||
console.log("Global variable Foo=" + example.Foo);
|
||||
|
||||
/* Change its value */
|
||||
example.Foo = 3.1415926;
|
||||
|
||||
/* See if the change took effect */
|
||||
print("Variable Foo changed to=" + example.Foo);
|
||||
console.log("Variable Foo changed to=" + example.Foo);
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue