Skip to content

Commit dbf3594

Browse files
authored
Merge pull request #66 from ddopson/backport
Support for node v0.10.
2 parents dc10fd4 + f198ebc commit dbf3594

File tree

4 files changed

+24
-16
lines changed

4 files changed

+24
-16
lines changed

Diff for: binding.gyp

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
],
2121
"cflags": [ "-O0", "-funwind-tables" ],
2222
"xcode_settings": {
23+
"MACOSX_DEPLOYMENT_TARGET": "10.9",
2324
"OTHER_CFLAGS": [ "-O0", "-funwind-tables" ],
2425
"CLANG_CXX_LIBRARY": "libc++"
2526
},

Diff for: package-lock.json

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
},
1717
"dependencies": {
1818
"bindings": "^1.2.1",
19-
"nan": "^2.13.2"
19+
"nan": "^2.14.0"
2020
},
2121
"main": "index.js",
2222
"types": "index.d.ts",

Diff for: src/segfault-handler.cpp

+18-11
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ struct callback_helper {
5959

6060
struct callback_args {
6161

62-
v8::Persistent<Function, v8::CopyablePersistentTraits<Function> >* callback;
62+
Nan::Persistent<Function, Nan::CopyablePersistentTraits<Function> >* callback;
6363
char **stack;
6464
size_t stack_size;
6565
int signo;
6666
long addr;
6767
pthread_mutex_t mutex;
6868
pthread_cond_t cond;
6969

70-
callback_args(v8::Persistent<Function, v8::CopyablePersistentTraits<Function> >* callback, void * const* stack, size_t stack_size, int signo, long addr) :
70+
callback_args(Nan::Persistent<Function, Nan::CopyablePersistentTraits<Function> >* callback, void * const* stack, size_t stack_size, int signo, long addr) :
7171
callback(callback), stack(backtrace_symbols(stack, stack_size)), stack_size(stack_size), signo(signo), addr(addr) {
7272
pthread_mutex_init(&mutex, NULL);
7373
pthread_cond_init(&cond, NULL);
@@ -81,12 +81,11 @@ struct callback_helper {
8181
};
8282

8383
uv_async_t* handle;
84-
v8::Persistent<Function, v8::CopyablePersistentTraits<Function> > callback;
84+
Nan::Persistent<Function, Nan::CopyablePersistentTraits<Function> > callback;
8585

8686
callback_helper(Local<Function> func) {
87-
Isolate* isolate = Isolate::GetCurrent();
8887
// set the function reference
89-
callback.Reset(isolate, func);
88+
callback.Reset(func);
9089

9190
// create the callback handle
9291
handle = (uv_async_t*) malloc(sizeof (uv_async_t));
@@ -113,7 +112,11 @@ struct callback_helper {
113112
// directly execute the callback if we're on the main thread,
114113
// otherwise have uv send it and await the mutex
115114
if (Isolate::GetCurrent()) {
115+
#if defined(UV_VERSION_MAJOR) && UV_VERSION_MAJOR > 0
116116
make_callback(handle);
117+
#else
118+
make_callback(handle, 0);
119+
#endif
117120
} else {
118121
// lock the callback mutex
119122
pthread_mutex_lock(&args->mutex);
@@ -137,26 +140,30 @@ struct callback_helper {
137140
free(handle);
138141
}
139142

143+
#if defined(UV_VERSION_MAJOR) && UV_VERSION_MAJOR > 0
140144
static void make_callback(uv_async_t* handle) {
141-
Isolate* isolate = Isolate::GetCurrent();
142-
v8::HandleScope scope(isolate);
145+
#else
146+
static void make_callback(uv_async_t* handle, int status) {
147+
#endif
148+
149+
Nan::HandleScope scope;
143150

144151
struct callback_args* args = (struct callback_args*) handle->data;
145152

146153
// lock the mutex
147154
pthread_mutex_lock(&args->mutex);
148155

149156
// build the stack arguments
150-
Local<Array> argStack = Array::New(isolate, args->stack_size);
157+
Local<Array> argStack = Nan::New<Array>(args->stack_size);
151158
for (size_t i = 0; i < args->stack_size; i++) {
152-
Nan::Set(argStack, i, String::NewFromUtf8(isolate, args->stack[i], v8::NewStringType::kInternalized).ToLocalChecked());
159+
Nan::Set(argStack, i, Nan::New<String>(args->stack[i]).ToLocalChecked());
153160
}
154161

155162
// collect all callback arguments
156-
Local<Value> argv[3] = {Number::New(isolate, args->signo), Number::New(isolate, args->addr), argStack};
163+
Local<Value> argv[3] = {Nan::New<Number>(args->signo), Nan::New<Number>(args->addr), argStack};
157164

158165
// execute the callback function on the main threaod
159-
Nan::Call(Local<Function>::New(isolate, *args->callback), isolate->GetCurrentContext()->Global(), 3, argv);
166+
Nan::Call(Nan::New<Function>(*args->callback), Nan::GetCurrentContext()->Global(), 3, argv);
160167

161168
// broadcast that we're done with the callback
162169
pthread_cond_broadcast(&args->cond);

0 commit comments

Comments
 (0)