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

Commit

Permalink
Merge pull request #146 from atom/upgrade-nan-usage
Browse files Browse the repository at this point in the history
upgrade to latest nan and address deprecations
  • Loading branch information
shiftkey authored Feb 6, 2019
2 parents 7e4f8b8 + fb2b465 commit 22301ce
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 18 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"prebuild": "^8.1.2"
},
"dependencies": {
"nan": "2.8.0",
"nan": "2.12.1",
"@shiftkey/prebuild-install": "5.2.4"
}
}
10 changes: 5 additions & 5 deletions src/async.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void GetPasswordWorker::HandleOKCallback() {
val
};

callback->Call(2, argv);
callback->Call(2, argv, async_resource);
}


Expand Down Expand Up @@ -105,7 +105,7 @@ void DeletePasswordWorker::HandleOKCallback() {
val
};

callback->Call(2, argv);
callback->Call(2, argv, async_resource);
}


Expand Down Expand Up @@ -144,7 +144,7 @@ void FindPasswordWorker::HandleOKCallback() {
val
};

callback->Call(2, argv);
callback->Call(2, argv, async_resource);
}


Expand Down Expand Up @@ -201,12 +201,12 @@ void FindCredentialsWorker::HandleOKCallback() {
Nan::Null(),
val
};
callback->Call(2, argv);
callback->Call(2, argv, async_resource);
} else {
v8::Local<v8::Value> argv[] = {
Nan::Null(),
Nan::New<v8::Array>(0)
};
callback->Call(2, argv);
callback->Call(2, argv, async_resource);
}
}
41 changes: 32 additions & 9 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,63 @@
namespace {

NAN_METHOD(SetPassword) {
Nan::Utf8String serviceNan(info[0]);
std::string service(*serviceNan, serviceNan.length());
Nan::Utf8String usernameNan(info[1]);
std::string username(*usernameNan, usernameNan.length());
Nan::Utf8String passwordNan(info[2]);
std::string password(*passwordNan, passwordNan.length());

SetPasswordWorker* worker = new SetPasswordWorker(
*v8::String::Utf8Value(info[0]),
*v8::String::Utf8Value(info[1]),
*v8::String::Utf8Value(info[2]),
service,
username,
password,
new Nan::Callback(info[3].As<v8::Function>()));
Nan::AsyncQueueWorker(worker);
}

NAN_METHOD(GetPassword) {
Nan::Utf8String serviceNan(info[0]);
std::string service(*serviceNan, serviceNan.length());
Nan::Utf8String usernameNan(info[1]);
std::string username(*usernameNan, usernameNan.length());

GetPasswordWorker* worker = new GetPasswordWorker(
*v8::String::Utf8Value(info[0]),
*v8::String::Utf8Value(info[1]),
service,
username,
new Nan::Callback(info[2].As<v8::Function>()));
Nan::AsyncQueueWorker(worker);
}

NAN_METHOD(DeletePassword) {
Nan::Utf8String serviceNan(info[0]);
std::string service(*serviceNan, serviceNan.length());
Nan::Utf8String usernameNan(info[1]);
std::string username(*usernameNan, usernameNan.length());

DeletePasswordWorker* worker = new DeletePasswordWorker(
*v8::String::Utf8Value(info[0]),
*v8::String::Utf8Value(info[1]),
service,
username,
new Nan::Callback(info[2].As<v8::Function>()));
Nan::AsyncQueueWorker(worker);
}

NAN_METHOD(FindPassword) {
Nan::Utf8String serviceNan(info[0]);
std::string service(*serviceNan, serviceNan.length());

FindPasswordWorker* worker = new FindPasswordWorker(
*v8::String::Utf8Value(info[0]),
service,
new Nan::Callback(info[1].As<v8::Function>()));
Nan::AsyncQueueWorker(worker);
}

NAN_METHOD(FindCredentials) {
Nan::Utf8String serviceNan(info[0]);
std::string service(*serviceNan, serviceNan.length());

FindCredentialsWorker* worker = new FindCredentialsWorker(
*v8::String::Utf8Value(info[0]),
service,
new Nan::Callback(info[1].As<v8::Function>()));
Nan::AsyncQueueWorker(worker);
}
Expand Down

0 comments on commit 22301ce

Please sign in to comment.