-
Notifications
You must be signed in to change notification settings - Fork 50
/
functions.h
34 lines (27 loc) · 821 Bytes
/
functions.h
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
#ifndef NATIVE_EXTENSION_GRAB_H
#define NATIVE_EXTENSION_GRAB_H
#include <nan.h>
// Example top-level functions. These functions demonstrate how to return various js types.
// Implementations are in functions.cc
NAN_METHOD(nothing);
NAN_METHOD(aString);
NAN_METHOD(aBoolean);
NAN_METHOD(aNumber);
NAN_METHOD(anObject);
NAN_METHOD(anArray);
NAN_METHOD(callback);
NAN_METHOD(callbackWithParameter);
// Example with node ObjectWrap
// Based on https://nodejs.org/api/addons.html#addons_wrapping_c_objects but using NAN
class MyObject : public Nan::ObjectWrap {
public:
static NAN_MODULE_INIT(Init);
private:
explicit MyObject(double value = 0);
~MyObject();
static NAN_METHOD(New);
static NAN_METHOD(PlusOne);
static Nan::Persistent<v8::Function> constructor;
double value_;
};
#endif