-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello.cc
More file actions
31 lines (26 loc) · 807 Bytes
/
hello.cc
File metadata and controls
31 lines (26 loc) · 807 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
#include <node.h>
#include <v8.h>
using namespace v8;
Handle<Value> Method(const Arguments& args) {
HandleScope scope;
return scope.Close(String::New("world"));
}
Handle<Value> Method2(const Arguments& args) {
HandleScope scope;
char str[10];
Local<String> x = String::New("x");
Local<Number> num = Number::New(args[0]->ToObject()->Get(x)->NumberValue());
return scope.Close(num);
if (args[0]->ToObject()->Get(x)->IsNumber()){
return scope.Close(String::New("is"));
} else {
return scope.Close(String::New("is not"));
}
}
void init(Handle<Object> exports) {
exports->Set(String::NewSymbol("hello"),
FunctionTemplate::New(Method)->GetFunction());
exports->Set(String::NewSymbol("foo"),
FunctionTemplate::New(Method2)->GetFunction());
}
NODE_MODULE(hello, init)