Skip to content
This repository has been archived by the owner on Dec 1, 2024. It is now read-only.

Commit

Permalink
use MakeCallback() instead of Call(), closes #62
Browse files Browse the repository at this point in the history
  • Loading branch information
rvagg committed Nov 12, 2013
1 parent ca9064a commit 0fee1d9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/batch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ NAN_METHOD(Batch::Write) {
BatchWriteWorker* worker = new BatchWriteWorker(batch, callback);
NanAsyncQueueWorker(worker);
} else {
LD_RUN_CALLBACK(v8::Local<v8::Function>::Cast(args[0]), NULL, 0);
LD_RUN_CALLBACK(v8::Local<v8::Function>::Cast(args[0]), 0, NULL);
}

NanReturnUndefined();
Expand Down
13 changes: 7 additions & 6 deletions src/database.cc
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,12 @@ NAN_METHOD(Database::Close) {
v8::Local<v8::Value> argv[] = {
v8::FunctionTemplate::New()->GetFunction() // empty callback
};
v8::TryCatch try_catch;
end->Call(NanObjectWrapHandle(iterator), 1, argv);
if (try_catch.HasCaught()) {
node::FatalException(try_catch);
}
node::MakeCallback(
NanObjectWrapHandle(iterator)
, end
, 1
, argv
);
}
}
} else {
Expand Down Expand Up @@ -440,7 +441,7 @@ NAN_METHOD(Database::Batch) {
));
} else {
ClearReferences(references);
LD_RUN_CALLBACK(callback, NULL, 0);
LD_RUN_CALLBACK(callback, 0, NULL);
}

NanReturnUndefined();
Expand Down
11 changes: 4 additions & 7 deletions src/leveldown.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,14 @@ static inline void DisposeStringOrBufferFromSlice(
v8::String::New(msg)) \
) \
}; \
LD_RUN_CALLBACK(callback, argv, 1) \
LD_RUN_CALLBACK(callback, 1, argv) \
NanReturnUndefined(); \
} \
return NanThrowError(msg);

#define LD_RUN_CALLBACK(callback, argv, length) \
v8::TryCatch try_catch; \
callback->Call(v8::Context::GetCurrent()->Global(), length, argv); \
if (try_catch.HasCaught()) { \
node::FatalException(try_catch); \
}
#define LD_RUN_CALLBACK(callback, argc, argv) \
node::MakeCallback( \
v8::Context::GetCurrent()->Global(), callback, argc, argv);

/* LD_METHOD_SETUP_COMMON setup the following objects:
* - Database* database
Expand Down

0 comments on commit 0fee1d9

Please sign in to comment.