-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathbinding.cpp
More file actions
38 lines (29 loc) · 772 Bytes
/
binding.cpp
File metadata and controls
38 lines (29 loc) · 772 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// v8
#include <v8.h>
// node.js
#include <node.h>
#include <node_version.h>
#if (NODE_MODULE_VERSION > 0x000B)
static void get_hello(const v8::FunctionCallbackInfo<v8::Value>& args)
{
v8::HandleScope scope(v8::Isolate::GetCurrent());
args.GetReturnValue().Set(v8::String::New("hello"));
}
#else
static v8::Handle<v8::Value> get_hello(const v8::Arguments& args)
{
v8::HandleScope scope;
return scope.Close(v8::String::New("hello"));
}
#endif
extern "C" {
static void start(v8::Handle<v8::Object> target) {
#if (NODE_MODULE_VERSION > 0x000B)
v8::HandleScope scope(v8::Isolate::GetCurrent());
#else
v8::HandleScope scope;
#endif
NODE_SET_METHOD(target, "hello", get_hello);
}
}
NODE_MODULE(node_addon_example, start)