diff --git a/Examples/javascript/class/Makefile b/Examples/javascript/class/Makefile index 507289ed1..99a9e9e86 100755 --- a/Examples/javascript/class/Makefile +++ b/Examples/javascript/class/Makefile @@ -5,17 +5,17 @@ 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/class/binding.gyp b/Examples/javascript/class/binding.gyp new file mode 100644 index 000000000..54eebfaa0 --- /dev/null +++ b/Examples/javascript/class/binding.gyp @@ -0,0 +1,8 @@ +{ + "targets": [ + { + "target_name": "example", + "sources": [ "example.cxx", "example_wrap.cxx" ] + } + ] +} diff --git a/Examples/javascript/class/runme.js b/Examples/javascript/class/runme.js index 50261d868..0ecaf3f82 100755 --- a/Examples/javascript/class/runme.js +++ b/Examples/javascript/class/runme.js @@ -1,15 +1,16 @@ // file: runme.js +var example = require("./build/Release/example"); // ----- Object creation ----- -print("Creating some objects:"); +console.log("Creating some objects:"); c = new example.Circle(10); -print("Created circle " + c); +console.log("Created circle " + c); s = new example.Square(10); -print("Created square " + s); +console.log("Created square " + s); // ----- Access a static member ----- -print("\nA total of " + example.Shape.nshapes + " shapes were created"); // access static member as properties of the class object +console.log("\nA total of " + example.Shape.nshapes + " shapes were created"); // access static member as properties of the class object // ----- Member data access ----- // Set the location of the object. @@ -21,26 +22,26 @@ c.y = 30; s.x = -10; s.y = 5; -print("\nHere is their new position:"); -print("Circle = (" + c.x + "," + c.y + ")"); -print("Square = (" + s.x + "," + s.y + ")"); +console.log("\nHere is their new position:"); +console.log("Circle = (" + c.x + "," + c.y + ")"); +console.log("Square = (" + s.x + "," + s.y + ")"); // ----- Call some methods ----- -print("\nHere are some properties of the shapes:"); -print("Circle:"); -print("area = " + c.area() + ""); -print("perimeter = " + c.perimeter() + ""); -print("\n"); -print("Square:"); -print("area = " + s.area() + ""); -print("perimeter = " + s.perimeter() + ""); +console.log("\nHere are some properties of the shapes:"); +console.log("Circle:"); +console.log("area = " + c.area() + ""); +console.log("perimeter = " + c.perimeter() + ""); +console.log("\n"); +console.log("Square:"); +console.log("area = " + s.area() + ""); +console.log("perimeter = " + s.perimeter() + ""); // ----- Delete everything ----- -print("\nGuess I'll clean up now"); +console.log("\nGuess I'll clean up now"); // Note: this invokes the virtual destructor delete c; -delete s; +delete s; -print (example.Shape.nshapes + " shapes remain"); +console.log(example.Shape.nshapes + " shapes remain"); -print("Goodbye"); +console.log("Goodbye");