Use Nan wrapper for type conversion
This commit is contained in:
committed by
petrzjunior
parent
5de4cc4fb4
commit
9cc61350a0
@@ -38,8 +38,8 @@
|
||||
"test": "mocha"
|
||||
},
|
||||
"dependencies": {
|
||||
"bindings": "^1.4.0",
|
||||
"nan": "^2.12.1"
|
||||
"bindings": "^1.5.0",
|
||||
"nan": "^2.14.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "^6.0.0",
|
||||
|
||||
@@ -58,10 +58,8 @@ void CardReader::init(Local<Object> target) {
|
||||
Nan::SetPrototypeTemplate(tpl, "SCARD_UNPOWER_CARD", Nan::New(SCARD_UNPOWER_CARD));
|
||||
Nan::SetPrototypeTemplate(tpl, "SCARD_EJECT_CARD", Nan::New(SCARD_EJECT_CARD));
|
||||
|
||||
Local <Context> context = Nan::GetCurrentContext();
|
||||
|
||||
constructor.Reset(tpl->GetFunction(context).ToLocalChecked());
|
||||
target->Set(Nan::New("CardReader").ToLocalChecked(), tpl->GetFunction(context).ToLocalChecked());
|
||||
constructor.Reset(Nan::GetFunction(tpl).ToLocalChecked());
|
||||
target->Set(Nan::New("CardReader").ToLocalChecked(), Nan::GetFunction(tpl).ToLocalChecked());
|
||||
}
|
||||
|
||||
CardReader::CardReader(const std::string &reader_name): m_card_context(0),
|
||||
@@ -136,11 +134,9 @@ NAN_METHOD(CardReader::Connect) {
|
||||
return Nan::ThrowError("Third argument must be a callback function");
|
||||
}
|
||||
|
||||
Local<Context> context = Nan::GetCurrentContext();
|
||||
|
||||
ConnectInput* ci = new ConnectInput();
|
||||
ci->share_mode = info[0]->Uint32Value(context).FromJust();
|
||||
ci->pref_protocol = info[1]->Uint32Value(context).FromJust();
|
||||
ci->share_mode = Nan::To<uint32_t>(info[0]).FromJust();
|
||||
ci->pref_protocol = Nan::To<uint32_t>(info[1]).FromJust();
|
||||
Local<Function> cb = Local<Function>::Cast(info[2]);
|
||||
|
||||
// This creates our work request, including the libuv struct.
|
||||
@@ -174,9 +170,7 @@ NAN_METHOD(CardReader::Disconnect) {
|
||||
return Nan::ThrowError("Second argument must be a callback function");
|
||||
}
|
||||
|
||||
Local<Context> context = Nan::GetCurrentContext();
|
||||
|
||||
DWORD disposition = info[0]->Uint32Value(context).FromJust();
|
||||
DWORD disposition = Nan::To<uint32_t>(info[0]).FromJust();
|
||||
Local<Function> cb = Local<Function>::Cast(info[1]);
|
||||
|
||||
// This creates our work request, including the libuv struct.
|
||||
@@ -222,11 +216,9 @@ NAN_METHOD(CardReader::Transmit) {
|
||||
return Nan::ThrowError("Fourth argument must be a callback function");
|
||||
}
|
||||
|
||||
Local<Context> context = Nan::GetCurrentContext();
|
||||
|
||||
Local<Object> buffer_data = Nan::To<Object>(info[0]).ToLocalChecked();
|
||||
uint32_t out_len = info[1]->Uint32Value(context).FromJust();
|
||||
uint32_t protocol = info[2]->Uint32Value(context).FromJust();
|
||||
uint32_t out_len = Nan::To<uint32_t>(info[1]).FromJust();
|
||||
uint32_t protocol = Nan::To<uint32_t>(info[2]).FromJust();
|
||||
|
||||
Local<Function> cb = Local<Function>::Cast(info[3]);
|
||||
|
||||
@@ -280,10 +272,8 @@ NAN_METHOD(CardReader::Control) {
|
||||
return Nan::ThrowError("Fourth argument must be a callback function");
|
||||
}
|
||||
|
||||
Local<Context> context = Nan::GetCurrentContext();
|
||||
|
||||
Local<Object> in_buf = Nan::To<Object>(info[0]).ToLocalChecked();
|
||||
DWORD control_code = info[1]->Uint32Value(context).FromJust();
|
||||
DWORD control_code = Nan::To<uint32_t>(info[1]).FromJust();
|
||||
Local<Object> out_buf = Nan::To<Object>(info[2]).ToLocalChecked();
|
||||
Local<Function> cb = Local<Function>::Cast(info[3]);
|
||||
|
||||
|
||||
@@ -8,8 +8,6 @@ Nan::Persistent<Function> PCSCLite::constructor;
|
||||
|
||||
void PCSCLite::init(Local<Object> target) {
|
||||
|
||||
Local<Context> context = Nan::GetCurrentContext();
|
||||
|
||||
// Prepare constructor template
|
||||
Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New);
|
||||
tpl->SetClassName(Nan::New("PCSCLite").ToLocalChecked());
|
||||
@@ -19,8 +17,8 @@ void PCSCLite::init(Local<Object> target) {
|
||||
Nan::SetPrototypeTemplate(tpl, "close", Nan::New<FunctionTemplate>(Close));
|
||||
|
||||
|
||||
constructor.Reset(tpl->GetFunction(context).ToLocalChecked());
|
||||
target->Set(Nan::New("PCSCLite").ToLocalChecked(), tpl->GetFunction(context).ToLocalChecked());
|
||||
constructor.Reset(Nan::GetFunction(tpl).ToLocalChecked());
|
||||
target->Set(Nan::New("PCSCLite").ToLocalChecked(), Nan::GetFunction(tpl).ToLocalChecked());
|
||||
}
|
||||
|
||||
PCSCLite::PCSCLite(): m_card_context(0),
|
||||
|
||||
16
yarn.lock
16
yarn.lock
@@ -70,10 +70,10 @@ balanced-match@^1.0.0:
|
||||
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
|
||||
integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c=
|
||||
|
||||
bindings@^1.4.0:
|
||||
version "1.4.0"
|
||||
resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.4.0.tgz#909efa49f2ebe07ecd3cb136778f665052040127"
|
||||
integrity sha512-7znEVX22Djn+nYjxCWKDne0RRloa9XfYa84yk3s+HkE3LpDYZmhArYr9O9huBoHY3/oXispx5LorIX7Sl2CgSQ==
|
||||
bindings@^1.5.0:
|
||||
version "1.5.0"
|
||||
resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.5.0.tgz#10353c9e945334bc0511a6d90b38fbc7c9c504df"
|
||||
integrity sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==
|
||||
dependencies:
|
||||
file-uri-to-path "1.0.0"
|
||||
|
||||
@@ -428,10 +428,10 @@ ms@^2.1.1:
|
||||
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009"
|
||||
integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==
|
||||
|
||||
nan@^2.12.1:
|
||||
version "2.12.1"
|
||||
resolved "https://registry.yarnpkg.com/nan/-/nan-2.12.1.tgz#7b1aa193e9aa86057e3c7bbd0ac448e770925552"
|
||||
integrity sha512-JY7V6lRkStKcKTvHO5NVSQRv+RV+FIL5pvDoLiAtSL9pKlC5x9PKQcZDsq7m4FO4d57mkhC6Z+QhAh3Jdk5JFw==
|
||||
nan@^2.14.0:
|
||||
version "2.14.0"
|
||||
resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.0.tgz#7818f722027b2459a86f0295d434d1fc2336c52c"
|
||||
integrity sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==
|
||||
|
||||
nise@^1.5.2:
|
||||
version "1.5.3"
|
||||
|
||||
Reference in New Issue
Block a user