diff --git a/Examples/javascript/class/runme.js b/Examples/javascript/class/runme.js index 0ecaf3f82..5bb62ecd4 100755 --- a/Examples/javascript/class/runme.js +++ b/Examples/javascript/class/runme.js @@ -1,4 +1,3 @@ -// file: runme.js var example = require("./build/Release/example"); // ----- Object creation ----- diff --git a/Examples/javascript/constant/Makefile b/Examples/javascript/constant/Makefile index dbf2f6660..99a9e9e86 100755 --- a/Examples/javascript/constant/Makefile +++ b/Examples/javascript/constant/Makefile @@ -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 diff --git a/Examples/javascript/constant/binding.gyp b/Examples/javascript/constant/binding.gyp new file mode 100644 index 000000000..69af46b22 --- /dev/null +++ b/Examples/javascript/constant/binding.gyp @@ -0,0 +1,8 @@ +{ + "targets": [ + { + "target_name": "example", + "sources": [ "example_wrap.cxx" ] + } + ] +} diff --git a/Examples/javascript/constant/runme.js b/Examples/javascript/constant/runme.js index cd4783a27..b11c08c98 100755 --- a/Examples/javascript/constant/runme.js +++ b/Examples/javascript/constant/runme.js @@ -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"); diff --git a/Examples/javascript/enum/Makefile b/Examples/javascript/enum/Makefile index 180e99cae..99a9e9e86 100755 --- a/Examples/javascript/enum/Makefile +++ b/Examples/javascript/enum/Makefile @@ -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 diff --git a/Examples/javascript/enum/binding.gyp b/Examples/javascript/enum/binding.gyp new file mode 100644 index 000000000..54eebfaa0 --- /dev/null +++ b/Examples/javascript/enum/binding.gyp @@ -0,0 +1,8 @@ +{ + "targets": [ + { + "target_name": "example", + "sources": [ "example.cxx", "example_wrap.cxx" ] + } + ] +} diff --git a/Examples/javascript/enum/example.cpp b/Examples/javascript/enum/example.cxx similarity index 100% rename from Examples/javascript/enum/example.cpp rename to Examples/javascript/enum/example.cxx diff --git a/Examples/javascript/enum/runme.js b/Examples/javascript/enum/runme.js index 3f6283639..9d3accd1d 100755 --- a/Examples/javascript/enum/runme.js +++ b/Examples/javascript/enum/runme.js @@ -1,26 +1,26 @@ -// file: runme.py +var example = require("./build/Release/example"); // ----- Object creation ----- // Print out the value of some enums -print("*** color ***"); -print(" RED =" + example.RED); -print(" BLUE =" + example.BLUE); -print(" GREEN =" + example.GREEN); +console.log("*** color ***"); +console.log(" RED =" + example.RED); +console.log(" BLUE =" + example.BLUE); +console.log(" GREEN =" + example.GREEN); -print("\n*** Foo::speed ***"); -print(" Foo_IMPULSE =" + example.Foo.IMPULSE); -print(" Foo_WARP =" + example.Foo.WARP); -print(" Foo_LUDICROUS =" + example.Foo.LUDICROUS); +console.log("\n*** Foo::speed ***"); +console.log(" Foo_IMPULSE =" + example.Foo.IMPULSE); +console.log(" Foo_WARP =" + example.Foo.WARP); +console.log(" Foo_LUDICROUS =" + example.Foo.LUDICROUS); -print("\nTesting use of enums with functions\n"); +console.log("\nTesting use of enums with functions\n"); example.enum_test(example.RED, example.Foo.IMPULSE); example.enum_test(example.BLUE, example.Foo.WARP); example.enum_test(example.GREEN, example.Foo.LUDICROUS); example.enum_test(1234,5678); -print("\nTesting use of enum with class method"); +console.log("\nTesting use of enum with class method"); f = new example.Foo(); f.enum_test(example.Foo.IMPULSE); @@ -28,7 +28,7 @@ f.enum_test(example.Foo.WARP); f.enum_test(example.Foo.LUDICROUS); // enum value BLUE of enum color is accessed as property of cconst -print("example.BLUE= " + example.BLUE); +console.log("example.BLUE= " + example.BLUE); // enum value LUDICROUS of enum Foo::speed is accessed as as property of cconst -print("example.speed.LUDICROUS= " + example.Foo.LUDICROUS); +console.log("example.speed.LUDICROUS= " + example.Foo.LUDICROUS); diff --git a/Examples/javascript/exception/Makefile b/Examples/javascript/exception/Makefile index 180e99cae..99a9e9e86 100755 --- a/Examples/javascript/exception/Makefile +++ b/Examples/javascript/exception/Makefile @@ -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 diff --git a/Examples/javascript/exception/binding.gyp b/Examples/javascript/exception/binding.gyp new file mode 100644 index 000000000..54eebfaa0 --- /dev/null +++ b/Examples/javascript/exception/binding.gyp @@ -0,0 +1,8 @@ +{ + "targets": [ + { + "target_name": "example", + "sources": [ "example.cxx", "example_wrap.cxx" ] + } + ] +} diff --git a/Examples/javascript/exception/example.cpp b/Examples/javascript/exception/example.cxx similarity index 100% rename from Examples/javascript/exception/example.cpp rename to Examples/javascript/exception/example.cxx diff --git a/Examples/javascript/exception/runme.js b/Examples/javascript/exception/runme.js index 936b37883..f7041f028 100644 --- a/Examples/javascript/exception/runme.js +++ b/Examples/javascript/exception/runme.js @@ -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()."); } } } diff --git a/Examples/javascript/functor/Makefile b/Examples/javascript/functor/Makefile index 180e99cae..99a9e9e86 100755 --- a/Examples/javascript/functor/Makefile +++ b/Examples/javascript/functor/Makefile @@ -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 diff --git a/Examples/javascript/functor/binding.gyp b/Examples/javascript/functor/binding.gyp new file mode 100644 index 000000000..54eebfaa0 --- /dev/null +++ b/Examples/javascript/functor/binding.gyp @@ -0,0 +1,8 @@ +{ + "targets": [ + { + "target_name": "example", + "sources": [ "example.cxx", "example_wrap.cxx" ] + } + ] +} diff --git a/Examples/javascript/functor/example.cpp b/Examples/javascript/functor/example.cxx similarity index 100% rename from Examples/javascript/functor/example.cpp rename to Examples/javascript/functor/example.cxx diff --git a/Examples/javascript/functor/runme.js b/Examples/javascript/functor/runme.js index 48d332c83..f7be78286 100644 --- a/Examples/javascript/functor/runme.js +++ b/Examples/javascript/functor/runme.js @@ -1,5 +1,4 @@ -// Operator overloading example - +var example = require("./build/Release/example"); a = new example.intSum(0); b = new example.doubleSum(100.0); @@ -11,6 +10,6 @@ for (i=1;i<=100;i++) a.call(i); // Note: function call b.call(Math.sqrt(i)); // Note: function call -print(a.result()); -print(b.result()); +console.log(a.result()); +console.log(b.result()); diff --git a/Examples/javascript/namespace/Makefile b/Examples/javascript/namespace/Makefile index 180e99cae..99a9e9e86 100755 --- a/Examples/javascript/namespace/Makefile +++ b/Examples/javascript/namespace/Makefile @@ -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 diff --git a/Examples/javascript/namespace/binding.gyp b/Examples/javascript/namespace/binding.gyp new file mode 100644 index 000000000..54eebfaa0 --- /dev/null +++ b/Examples/javascript/namespace/binding.gyp @@ -0,0 +1,8 @@ +{ + "targets": [ + { + "target_name": "example", + "sources": [ "example.cxx", "example_wrap.cxx" ] + } + ] +} diff --git a/Examples/javascript/namespace/example.cpp b/Examples/javascript/namespace/example.cxx similarity index 100% rename from Examples/javascript/namespace/example.cpp rename to Examples/javascript/namespace/example.cxx diff --git a/Examples/javascript/namespace/runme.js b/Examples/javascript/namespace/runme.js index dc49b078e..9a9d6744d 100644 --- a/Examples/javascript/namespace/runme.js +++ b/Examples/javascript/namespace/runme.js @@ -1,11 +1,10 @@ - print("Global variable Foo=" + example.nspace.Foo); - example.nspace.Foo = 5; - print("Variable Foo changed to " + example.nspace.Foo); - print("GCD of number 6,18 is " + example.nspace.gcd(6,18)); +var example = require("./build/Release/example"); -print("Creating some objects:"); +console.log("Global variable Foo=" + example.nspace.Foo); +example.nspace.Foo = 5; +console.log("Variable Foo changed to " + example.nspace.Foo); +console.log("GCD of number 6,18 is " + example.nspace.gcd(6,18)); + +console.log("Creating some objects:"); c = new example.nspace.Circle(10); -print("area = " + c.area()); - - - +console.log("area = " + c.area()); diff --git a/Examples/javascript/operator/Makefile b/Examples/javascript/operator/Makefile index 180e99cae..99a9e9e86 100755 --- a/Examples/javascript/operator/Makefile +++ b/Examples/javascript/operator/Makefile @@ -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 diff --git a/Examples/javascript/operator/binding.gyp b/Examples/javascript/operator/binding.gyp new file mode 100644 index 000000000..69af46b22 --- /dev/null +++ b/Examples/javascript/operator/binding.gyp @@ -0,0 +1,8 @@ +{ + "targets": [ + { + "target_name": "example", + "sources": [ "example_wrap.cxx" ] + } + ] +} diff --git a/Examples/javascript/operator/example.cpp b/Examples/javascript/operator/example.cpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/Examples/javascript/operator/runme.js b/Examples/javascript/operator/runme.js index 92b8e3b74..9dba4b7f9 100644 --- a/Examples/javascript/operator/runme.js +++ b/Examples/javascript/operator/runme.js @@ -1,23 +1,23 @@ -// Operator overloading example +var example = require("./build/Release/example"); a = new example.Complex(2,3); b = new example.Complex(-5,10); -print ("a =" + a); -print ("b =" + b); +console.log ("a =" + a); +console.log ("b =" + b); c = a.plus(b); -print("c =" + c); -print("a*b =" + a.times(b)); -print("a-c =" + a.minus(c)); +console.log("c =" + c); +console.log("a*b =" + a.times(b)); +console.log("a-c =" + a.minus(c)); e = example.Complex.copy(a.minus(c)); -print("e =" + e); +console.log("e =" + e); // Big expression f = a.plus(b).times(c.plus(b.times(e))).plus(a.uminus()); -print("f =" + f); +console.log("f =" + f); diff --git a/Examples/javascript/overload/Makefile b/Examples/javascript/overload/Makefile index 180e99cae..99a9e9e86 100755 --- a/Examples/javascript/overload/Makefile +++ b/Examples/javascript/overload/Makefile @@ -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 diff --git a/Examples/javascript/overload/binding.gyp b/Examples/javascript/overload/binding.gyp new file mode 100644 index 000000000..69af46b22 --- /dev/null +++ b/Examples/javascript/overload/binding.gyp @@ -0,0 +1,8 @@ +{ + "targets": [ + { + "target_name": "example", + "sources": [ "example_wrap.cxx" ] + } + ] +} diff --git a/Examples/javascript/overload/example.cpp b/Examples/javascript/overload/example.cpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/Examples/javascript/overload/runme.js b/Examples/javascript/overload/runme.js index 6b822f107..5ff5d01be 100644 --- a/Examples/javascript/overload/runme.js +++ b/Examples/javascript/overload/runme.js @@ -1,3 +1,5 @@ +var example = require("./build/Release/example"); + example.f(); example.f(1); example.f(1, 2); diff --git a/Examples/javascript/pointer/Makefile b/Examples/javascript/pointer/Makefile index 180e99cae..99a9e9e86 100755 --- a/Examples/javascript/pointer/Makefile +++ b/Examples/javascript/pointer/Makefile @@ -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 diff --git a/Examples/javascript/pointer/binding.gyp b/Examples/javascript/pointer/binding.gyp new file mode 100644 index 000000000..54eebfaa0 --- /dev/null +++ b/Examples/javascript/pointer/binding.gyp @@ -0,0 +1,8 @@ +{ + "targets": [ + { + "target_name": "example", + "sources": [ "example.cxx", "example_wrap.cxx" ] + } + ] +} diff --git a/Examples/javascript/pointer/example.cpp b/Examples/javascript/pointer/example.cxx similarity index 100% rename from Examples/javascript/pointer/example.cpp rename to Examples/javascript/pointer/example.cxx diff --git a/Examples/javascript/pointer/runme.js b/Examples/javascript/pointer/runme.js index 48f92f11f..00778dfbc 100755 --- a/Examples/javascript/pointer/runme.js +++ b/Examples/javascript/pointer/runme.js @@ -1,7 +1,7 @@ -// file: runme.js +var example = require("./build/Release/example"); // First create some objects using the pointer library. -print("Testing the pointer library\n"); +console.log("Testing the pointer library\n"); a = example.new_intp(); b = example.new_intp(); c = example.new_intp(); @@ -9,9 +9,9 @@ c = example.new_intp(); example.intp_assign(a,37); example.intp_assign(b,42); -print(" a = " + example.intp_value(a) + "\n"); -print(" b = " + example.intp_value(b) + "\n"); -print(" c = " + example.intp_value(c) + "\n"); +console.log(" a = " + example.intp_value(a) + "\n"); +console.log(" b = " + example.intp_value(b) + "\n"); +console.log(" c = " + example.intp_value(c) + "\n"); //// Call the add() function with some pointers example.add(a, b, c); @@ -19,7 +19,7 @@ example.add(a, b, c); // //// Now get the result r = example.intp_value(c); -print(" 37 + 42 = " + r + "\n"); +console.log(" 37 + 42 = " + r + "\n"); // Clean up the pointers example.delete_intp(a); @@ -30,9 +30,6 @@ example.delete_intp(c); //// This should be much easier. Now how it is no longer //// necessary to manufacture pointers. //"OUTPUT" Mapping is not supported - -//print("Trying the typemap library"); +//console.log("Trying the typemap library"); //r = example.subtract(37,42); -//print("37 - 42 =" + r); - - +//console.log("37 - 42 =" + r); diff --git a/Examples/javascript/reference/Makefile b/Examples/javascript/reference/Makefile index 180e99cae..99a9e9e86 100755 --- a/Examples/javascript/reference/Makefile +++ b/Examples/javascript/reference/Makefile @@ -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 diff --git a/Examples/javascript/reference/binding.gyp b/Examples/javascript/reference/binding.gyp new file mode 100644 index 000000000..54eebfaa0 --- /dev/null +++ b/Examples/javascript/reference/binding.gyp @@ -0,0 +1,8 @@ +{ + "targets": [ + { + "target_name": "example", + "sources": [ "example.cxx", "example_wrap.cxx" ] + } + ] +} diff --git a/Examples/javascript/reference/example.cpp b/Examples/javascript/reference/example.cxx similarity index 100% rename from Examples/javascript/reference/example.cpp rename to Examples/javascript/reference/example.cxx diff --git a/Examples/javascript/reference/runme.js b/Examples/javascript/reference/runme.js index 5cf00061e..ee5737076 100755 --- a/Examples/javascript/reference/runme.js +++ b/Examples/javascript/reference/runme.js @@ -1,23 +1,23 @@ // This file illustrates the manipulation of C++ references in Javascript. -// TODO: deleteion of vector objects created here +var example = require("./build/Release/example"); // ----- Object creation ----- -print("Creating some objects:\n"); +console.log("Creating some objects:\n"); a = new example.Vector(3,4,5); b = new example.Vector(10,11,12); -print(" created" + a.print()); -print(" created" + b.print()); +console.log(" created" + a.print()); +console.log(" created" + b.print()); // ----- Call an overloaded operator ----- // This calls the wrapper we placed around operator+(const Vector &a, const Vector &) // It returns a new allocated object. -print("Adding a+b\n"); +console.log("Adding a+b\n"); c = example.addv(a, b); -print("a+b = " + c.print()); +console.log("a+b = " + c.print()); // TODO: Note: Unless we free the result, a memory leak will occur @@ -26,9 +26,9 @@ print("a+b = " + c.print()); // ----- Create a vector array ----- // Note: Using the high-level interface here -print("Creating an array of vectors\n"); +console.log("Creating an array of vectors\n"); va = new example.VectorArray(10); -print("va = " + va + "\n"); +console.log("va = " + va + "\n"); // ----- Set some values in the array ----- @@ -46,20 +46,20 @@ va.set(2,example.addv(a,b)); // Get some values from the array -print("Getting some array values\n"); +console.log("Getting some array values\n"); for (i = 0; i < 5; i++) { temp = va.get(i); - print(i,temp.print()); + console.log(i,temp.print()); } // Watch under resource meter to check on this -print("Making sure we don't leak memory.\n"); +console.log("Making sure we don't leak memory.\n"); for (i = 0; i < 1000000; i++) { c = va.get(i % 10); } //---------TODO--------- //----- Clean up ----- -//print("Cleaning up\n"); +//console.log("Cleaning up\n"); //example.delete_VectorArray(va); //example.delete_Vector(a); diff --git a/Examples/javascript/simple/Makefile b/Examples/javascript/simple/Makefile index fb4669329..99a9e9e86 100755 --- a/Examples/javascript/simple/Makefile +++ b/Examples/javascript/simple/Makefile @@ -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 diff --git a/Examples/javascript/simple/binding.gyp b/Examples/javascript/simple/binding.gyp new file mode 100644 index 000000000..54eebfaa0 --- /dev/null +++ b/Examples/javascript/simple/binding.gyp @@ -0,0 +1,8 @@ +{ + "targets": [ + { + "target_name": "example", + "sources": [ "example.cxx", "example_wrap.cxx" ] + } + ] +} diff --git a/Examples/javascript/simple/example.c b/Examples/javascript/simple/example.cxx similarity index 100% rename from Examples/javascript/simple/example.c rename to Examples/javascript/simple/example.cxx diff --git a/Examples/javascript/simple/runme.js b/Examples/javascript/simple/runme.js index 96c11a5a2..d970dcb7c 100755 --- a/Examples/javascript/simple/runme.js +++ b/Examples/javascript/simple/runme.js @@ -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); diff --git a/Examples/javascript/template/Makefile b/Examples/javascript/template/Makefile index 180e99cae..99a9e9e86 100755 --- a/Examples/javascript/template/Makefile +++ b/Examples/javascript/template/Makefile @@ -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 diff --git a/Examples/javascript/template/binding.gyp b/Examples/javascript/template/binding.gyp new file mode 100644 index 000000000..69af46b22 --- /dev/null +++ b/Examples/javascript/template/binding.gyp @@ -0,0 +1,8 @@ +{ + "targets": [ + { + "target_name": "example", + "sources": [ "example_wrap.cxx" ] + } + ] +} diff --git a/Examples/javascript/template/example.cpp b/Examples/javascript/template/example.cpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/Examples/javascript/template/runme.js b/Examples/javascript/template/runme.js index b2a5264ab..551475c72 100644 --- a/Examples/javascript/template/runme.js +++ b/Examples/javascript/template/runme.js @@ -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; - - diff --git a/Examples/javascript/variables/Makefile b/Examples/javascript/variables/Makefile index fb4669329..99a9e9e86 100755 --- a/Examples/javascript/variables/Makefile +++ b/Examples/javascript/variables/Makefile @@ -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 diff --git a/Examples/javascript/variables/binding.gyp b/Examples/javascript/variables/binding.gyp new file mode 100644 index 000000000..54eebfaa0 --- /dev/null +++ b/Examples/javascript/variables/binding.gyp @@ -0,0 +1,8 @@ +{ + "targets": [ + { + "target_name": "example", + "sources": [ "example.cxx", "example_wrap.cxx" ] + } + ] +} diff --git a/Examples/javascript/variables/example.c b/Examples/javascript/variables/example.cxx similarity index 100% rename from Examples/javascript/variables/example.c rename to Examples/javascript/variables/example.cxx diff --git a/Examples/javascript/variables/runme.js b/Examples/javascript/variables/runme.js index 7c4e151de..22d208480 100755 --- a/Examples/javascript/variables/runme.js +++ b/Examples/javascript/variables/runme.js @@ -1,4 +1,4 @@ -// file: runme.js +var example = require("./build/Release/example"); // Try to set the values of some global variables example.ivar = 42; @@ -17,52 +17,52 @@ example.iptrvar= example.new_int(37); example.ptptr = example.new_Point(37,42); example.name = "Bill"; -// Now print out the values of the variables -print("Variables (values printed from Python)" + "\n"); -print("ivar = " + example.ivar + "\n"); -print("svar = " + example.svar + "\n"); -print("lvar = " + example.lvar + "\n"); -print("uivar = " + example.uivar + "\n"); -print("usvar = " + example.usvar + "\n"); -print("ulvar = " + example.ulvar + "\n"); -print("scvar = " + example.scvar + "\n"); -print("ucvar = " + example.ucvar + "\n"); -print("fvar = " + example.fvar + "\n"); -print("dvar = " + example.dvar + "\n"); -print("cvar = " + example.cvar + "\n"); -print("strvar = " + example.strvar+ "\n"); -print("cstrvar = " + example.cstrvar+ "\n"); -print("iptrvar = " + example.iptrvar+ "\n"); -print("name = " + example.name + "\n"); -print("ptptr = " + example.ptptr + ": " + example.Point_print(example.ptptr) + "\n"); -print("pt = " + example.pt + ": " + example.Point_print(example.pt) + "\n"); +// Now console.log out the values of the variables +console.log("Variables (values console.loged from Python)" + "\n"); +console.log("ivar = " + example.ivar + "\n"); +console.log("svar = " + example.svar + "\n"); +console.log("lvar = " + example.lvar + "\n"); +console.log("uivar = " + example.uivar + "\n"); +console.log("usvar = " + example.usvar + "\n"); +console.log("ulvar = " + example.ulvar + "\n"); +console.log("scvar = " + example.scvar + "\n"); +console.log("ucvar = " + example.ucvar + "\n"); +console.log("fvar = " + example.fvar + "\n"); +console.log("dvar = " + example.dvar + "\n"); +console.log("cvar = " + example.cvar + "\n"); +console.log("strvar = " + example.strvar+ "\n"); +console.log("cstrvar = " + example.cstrvar+ "\n"); +console.log("iptrvar = " + example.iptrvar+ "\n"); +console.log("name = " + example.name + "\n"); +console.log("ptptr = " + example.ptptr + ": " + example.Point_print(example.ptptr) + "\n"); +console.log("pt = " + example.pt + ": " + example.Point_print(example.pt) + "\n"); -print("\nVariables (values printed from C)"); +console.log("\nVariables (values console.loged from C)"); example.print_vars(); -print("\nNow I'm going to try and modify some read only variables"); +console.log("\nNow I'm going to try and modify some read only variables"); -print("Tring to set 'path'"); +console.log("Tring to set 'path'"); try{ example.path = "Whoa!"; - print("Hey, what's going on?!?! This shouldn't work"); + console.log("Hey, what's going on?!?! This shouldn't work"); } catch(e){ - print("Good."); + console.log("Good."); } -print("Trying to set 'status'"); +console.log("Trying to set 'status'"); try{ example.status = 0; - print("Hey, what's going on?!?! This shouldn't work"); + console.log("Hey, what's going on?!?! This shouldn't work"); } catch(e){ - print("Good."); + console.log("Good."); } -print("\nI'm going to try and update a structure variable.\n"); +console.log("\nI'm going to try and update a structure variable.\n"); example.pt = example.ptptr; -print("The new value is: "); +console.log("The new value is: "); example.pt_print(); -print("You should see the value: " + example.Point_print(example.ptptr)); +console.log("You should see the value: " + example.Point_print(example.ptptr));