-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathmodule.cpp
More file actions
29 lines (22 loc) · 1023 Bytes
/
module.cpp
File metadata and controls
29 lines (22 loc) · 1023 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
#include <nan.h>
#include "standalone/hello.hpp"
#include "standalone_async/hello_async.hpp"
#include "object_sync/hello.hpp"
// #include "your_code.hpp"
// "target" is a magic var that nodejs passes into modules scope
// When you write things to target, they become available to call from js
// What exactly IS target?
static void init(v8::Local<v8::Object> target) {
// expose hello method
Nan::SetMethod(target, "hello", standalone::hello);
// expose hello_async method
Nan::SetMethod(target, "hello_async", standalone_async::hello_async);
// expose HelloObject class
object_sync::HelloObject::init(target);
// Notice there are multiple "hello" functions as part of this module:
// 1) standalone::hello
// 2) HelloObject.hello()...not really sure why this function doesnt have to be expliclty exposed
// add more methods/classes below that youd like to use in node.js-world
// then create a .cpp and .hpp file in /src for each new method
}
NODE_MODULE(module, init)