summaryrefslogtreecommitdiff
path: root/test/addons/hello-world
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2011-12-20 22:03:32 -0800
committerRyan Dahl <ry@tinyclouds.org>2011-12-20 22:03:35 -0800
commit18b92201be7e654ac9997b947d38aaf46adee06d (patch)
tree85bbbbb6e17f6b91615533a05987ae238703b973 /test/addons/hello-world
parent7edfb029844cf10cc1d815dadc7384fdb285f4e9 (diff)
downloadandroid-node-v8-18b92201be7e654ac9997b947d38aaf46adee06d.tar.gz
android-node-v8-18b92201be7e654ac9997b947d38aaf46adee06d.tar.bz2
android-node-v8-18b92201be7e654ac9997b947d38aaf46adee06d.zip
Support addons with gyp
Initial pass.
Diffstat (limited to 'test/addons/hello-world')
-rw-r--r--test/addons/hello-world/binding.cc17
-rw-r--r--test/addons/hello-world/binding.gyp8
-rw-r--r--test/addons/hello-world/test.js4
3 files changed, 29 insertions, 0 deletions
diff --git a/test/addons/hello-world/binding.cc b/test/addons/hello-world/binding.cc
new file mode 100644
index 0000000000..82e8c5583d
--- /dev/null
+++ b/test/addons/hello-world/binding.cc
@@ -0,0 +1,17 @@
+#include <node.h>
+#include <v8.h>
+
+using namespace v8;
+
+extern "C" {
+ void init(Handle<Object> target);
+}
+
+Handle<Value> Method(const Arguments& args) {
+ HandleScope scope;
+ return scope.Close(String::New("world"));
+}
+
+void init(Handle<Object> target) {
+ NODE_SET_METHOD(target, "hello", Method);
+}
diff --git a/test/addons/hello-world/binding.gyp b/test/addons/hello-world/binding.gyp
new file mode 100644
index 0000000000..3bfb84493f
--- /dev/null
+++ b/test/addons/hello-world/binding.gyp
@@ -0,0 +1,8 @@
+{
+ 'targets': [
+ {
+ 'target_name': 'binding',
+ 'sources': [ 'binding.cc' ]
+ }
+ ]
+}
diff --git a/test/addons/hello-world/test.js b/test/addons/hello-world/test.js
new file mode 100644
index 0000000000..27550a3864
--- /dev/null
+++ b/test/addons/hello-world/test.js
@@ -0,0 +1,4 @@
+var assert = require('assert');
+var binding = require('./out/Release/binding');
+assert.equal('world', binding.hello());
+console.log('binding.hello() =', binding.hello());