Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit 04e9cc7fc2f83b68901764c1c6752bb088dc9cf2 @lupomontero committed Mar 12, 2011
Showing with 58 additions and 0 deletions.
  1. +5 −0 .gitignore
  2. +19 −0 cpphello.cpp
  3. +6 −0 test/cpphello.js
  4. +28 −0 wscript
@@ -0,0 +1,5 @@
+*.swp
+.DS_Store
+.lock*
+*.node
+build/
@@ -0,0 +1,19 @@
+#include <v8.h>
+#include <node.h>
+
+using namespace node;
+using namespace v8;
+
+static Handle<Value> foo(const Arguments& args)
+{
+ return String::New("Hello World");
+}
+
+extern "C" {
+ static void init(Handle<Object> target)
+ {
+ NODE_SET_METHOD(target, "foo", foo);
+ }
+
+ NODE_MODULE(cpphello, init);
+}
@@ -0,0 +1,6 @@
+var
+ util = require('util'),
+ cpphello = require('../cpphello');
+
+console.log(cpphello.foo());
+console.log(util.inspect(cpphello, true, null));
28 wscript
@@ -0,0 +1,28 @@
+import Options
+from os import unlink, symlink, popen
+from os.path import exists
+
+srcdir = "."
+blddir = "build"
+VERSION = "0.0.1"
+
+def set_options(opt):
+ opt.tool_options("compiler_cxx")
+
+def configure(conf):
+ conf.check_tool("compiler_cxx")
+ conf.check_tool("node_addon")
+
+def build(bld):
+ obj = bld.new_task_gen("cxx", "shlib", "node_addon")
+ obj.target = "cpphello"
+ obj.source = "cpphello.cpp"
+ obj.cxxflags = ["-D_FILE_OFFSET_BITS=64", "-D_LARGEFILE_SOURCE"]
+
+def shutdown():
+ if Options.commands['clean']:
+ if exists('cpphello.node'): unlink('cpphello.node')
+ else:
+ if exists('build/default/cpphello.node') and not exists('cpphello.node'):
+ symlink('build/default/cpphello.node', 'cpphello.node')
+

0 comments on commit 04e9cc7

Please sign in to comment.