Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 20 lines (17 sloc) 0.919 kb
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
Something went wrong with that request. Please try again.