mirror of https://github.com/lukechilds/node.git
Browse Source
mainly to allow native addons to export single functions on rather than being restricted to operating on an existing object. Init functions now receive exports as the first argument, like before, but also the module object as the second argument, if they support it. Related to #4634 cc: @rvaggv0.9.9-release
isaacs
12 years ago
6 changed files with 52 additions and 13 deletions
@ -0,0 +1,15 @@ |
|||
#include <node.h> |
|||
#include <v8.h> |
|||
|
|||
using namespace v8; |
|||
|
|||
Handle<Value> Method(const Arguments& args) { |
|||
HandleScope scope; |
|||
return scope.Close(String::New("world")); |
|||
} |
|||
|
|||
void init(Handle<Object> exports, Handle<Object> module) { |
|||
NODE_SET_METHOD(module, "exports", Method); |
|||
} |
|||
|
|||
NODE_MODULE(binding, init); |
@ -0,0 +1,8 @@ |
|||
{ |
|||
'targets': [ |
|||
{ |
|||
'target_name': 'binding', |
|||
'sources': [ 'binding.cc' ] |
|||
} |
|||
] |
|||
} |
@ -0,0 +1,4 @@ |
|||
var assert = require('assert'); |
|||
var binding = require('./build/Release/binding'); |
|||
assert.equal('world', binding()); |
|||
console.log('binding.hello() =', binding()); |
Loading…
Reference in new issue