Skip to content

Commit

Permalink
make compatible with V8 7.1
Browse files Browse the repository at this point in the history
* Remove use of two argument Concat
  • Loading branch information
refack committed Dec 17, 2018
1 parent a8c34ea commit 91e55e2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 19 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"url": "git://github.com/mapbox/node-sqlite3.git"
},
"dependencies": {
"nan": "~2.10.0",
"nan": "~2.11.1",
"node-pre-gyp": "^0.11.0",
"request": "^2.87.0"
},
Expand Down
15 changes: 9 additions & 6 deletions src/database.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void Database::Process() {
Nan::HandleScope scope;

if (!open && locked && !queue.empty()) {
EXCEPTION(Nan::New("Database handle is closed").ToLocalChecked(), SQLITE_MISUSE, exception);
EXCEPTION("Database handle is closed", SQLITE_MISUSE, exception);
Local<Value> argv[] = { exception };
bool called = false;

Expand Down Expand Up @@ -85,7 +85,7 @@ void Database::Schedule(Work_Callback callback, Baton* baton, bool exclusive) {
Nan::HandleScope scope;

if (!open && locked) {
EXCEPTION(Nan::New("Database is closed").ToLocalChecked(), SQLITE_MISUSE, exception);
EXCEPTION("Database is closed", SQLITE_MISUSE, exception);
Local<Function> cb = Nan::New(baton->callback);
if (!cb.IsEmpty() && cb->IsFunction()) {
Local<Value> argv[] = { exception };
Expand Down Expand Up @@ -176,7 +176,7 @@ void Database::Work_AfterOpen(uv_work_t* req) {

Local<Value> argv[1];
if (baton->status != SQLITE_OK) {
EXCEPTION(Nan::New(baton->message.c_str()).ToLocalChecked(), baton->status, exception);
EXCEPTION(baton->message, baton->status, exception);
argv[0] = exception;
}
else {
Expand Down Expand Up @@ -256,7 +256,7 @@ void Database::Work_AfterClose(uv_work_t* req) {

Local<Value> argv[1];
if (baton->status != SQLITE_OK) {
EXCEPTION(Nan::New(baton->message.c_str()).ToLocalChecked(), baton->status, exception);
EXCEPTION(baton->message, baton->status, exception);
argv[0] = exception;
}
else {
Expand Down Expand Up @@ -346,6 +346,9 @@ NAN_METHOD(Database::Configure) {
}
else {
return Nan::ThrowError(Exception::Error(String::Concat(
#if V8_MAJOR_VERSION > 6
info.GetIsolate(),
#endif
Nan::To<String>(info[0]).ToLocalChecked(),
Nan::New(" is not a valid configuration option").ToLocalChecked()
)));
Expand Down Expand Up @@ -554,7 +557,7 @@ void Database::Work_AfterExec(uv_work_t* req) {
Local<Function> cb = Nan::New(baton->callback);

if (baton->status != SQLITE_OK) {
EXCEPTION(Nan::New(baton->message.c_str()).ToLocalChecked(), baton->status, exception);
EXCEPTION(baton->message, baton->status, exception);

if (!cb.IsEmpty() && cb->IsFunction()) {
Local<Value> argv[] = { exception };
Expand Down Expand Up @@ -656,7 +659,7 @@ void Database::Work_AfterLoadExtension(uv_work_t* req) {
Local<Function> cb = Nan::New(baton->callback);

if (baton->status != SQLITE_OK) {
EXCEPTION(Nan::New(baton->message.c_str()).ToLocalChecked(), baton->status, exception);
EXCEPTION(baton->message, baton->status, exception);

if (!cb.IsEmpty() && cb->IsFunction()) {
Local<Value> argv[] = { exception };
Expand Down
14 changes: 4 additions & 10 deletions src/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,15 @@ const char* sqlite_authorizer_string(int type);
Nan::New(property).ToLocalChecked()).ToLocalChecked()).FromJust();

#define EXCEPTION(msg, errno, name) \
Local<Value> name = Exception::Error( \
String::Concat( \
String::Concat( \
Nan::New(sqlite_code_string(errno)).ToLocalChecked(), \
Nan::New(": ").ToLocalChecked() \
), \
(msg) \
) \
); \
Local<Value> name = Exception::Error(Nan::New( \
std::string(sqlite_code_string(errno)) + \
std::string(": ") + std::string(msg) \
).ToLocalChecked()); \
Local<Object> name ##_obj = name.As<Object>(); \
Nan::Set(name ##_obj, Nan::New("errno").ToLocalChecked(), Nan::New(errno));\
Nan::Set(name ##_obj, Nan::New("code").ToLocalChecked(), \
Nan::New(sqlite_code_string(errno)).ToLocalChecked());


#define EMIT_EVENT(obj, argc, argv) \
TRY_CATCH_CALL((obj), \
Nan::Get(obj, \
Expand Down
4 changes: 2 additions & 2 deletions src/statement.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ template <class T> void Statement::Error(T* baton) {
Statement* stmt = baton->stmt;
// Fail hard on logic errors.
assert(stmt->status != 0);
EXCEPTION(Nan::New(stmt->message.c_str()).ToLocalChecked(), stmt->status, exception);
EXCEPTION(stmt->message, stmt->status, exception);

Local<Function> cb = Nan::New(baton->callback);

Expand Down Expand Up @@ -857,7 +857,7 @@ void Statement::CleanQueue() {
if (prepared && !queue.empty()) {
// This statement has already been prepared and is now finalized.
// Fire error for all remaining items in the queue.
EXCEPTION(Nan::New<String>("Statement is already finalized").ToLocalChecked(), SQLITE_MISUSE, exception);
EXCEPTION("Statement is already finalized", SQLITE_MISUSE, exception);
Local<Value> argv[] = { exception };
bool called = false;

Expand Down

0 comments on commit 91e55e2

Please sign in to comment.