-
Notifications
You must be signed in to change notification settings - Fork 699
Expand file tree
/
Copy pathutils.h
More file actions
19 lines (17 loc) · 919 Bytes
/
utils.h
File metadata and controls
19 lines (17 loc) · 919 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#ifndef UTILS_H
#define UTILS_H
// Credit: @samcday
// http://sambro.is-super-awesome.com/2011/03/03/creating-a-proper-buffer-in-a-node-c-addon/
#define MAKE_FAST_BUFFER(NG_SLOW_BUFFER, NG_FAST_BUFFER) \
Local<Function> NG_JS_BUFFER = Local<Function>::Cast( \
Context::GetCurrent()->Global()->Get( \
String::New("Buffer"))); \
\
Handle<Value> NG_JS_ARGS[3] = { \
NG_SLOW_BUFFER->handle_, \
Integer::New(Buffer::Length(NG_SLOW_BUFFER)), \
Integer::New(0) \
}; \
\
NG_FAST_BUFFER = NG_JS_BUFFER->NewInstance(3, NG_JS_ARGS);
#endif