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

Commit 556e489

Browse files
authored
Fix serialport source code for API changes (#923)
* Fix serialport source code for API changes * fix serialport api
1 parent 2d4d72b commit 556e489

File tree

6 files changed

+20
-20
lines changed

6 files changed

+20
-20
lines changed

vendor/node-usb-native/src/combined.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
#include <nan.h>
1010

1111
extern "C" {
12-
void init_serialport(v8::Handle<v8::Object> target);
12+
void init_serialport( v8::Local<v8::Object> target);
1313
#ifndef DISABLE_USB_DETECTOR
14-
void init_detector(v8::Handle<v8::Object> target);
14+
void init_detector( v8::Local<v8::Object> target);
1515
#endif
16-
void initAll(v8::Handle<v8::Object> target) {
16+
void initAll( v8::Local<v8::Object> target) {
1717
init_serialport(target);
1818
#ifndef DISABLE_USB_DETECTOR
1919
init_detector(target);

vendor/node-usb-native/src/detection.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ void StopMonitoring(const Nan::FunctionCallbackInfo<v8::Value>& args) {
210210
}
211211

212212
extern "C" {
213-
void init_detector (v8::Handle<v8::Object> target) {
213+
void init_detector ( v8::Local<v8::Object> target) {
214214
Nan::SetMethod(target, "find", Find);
215215
Nan::SetMethod(target, "registerAdded", RegisterAdded);
216216
Nan::SetMethod(target, "registerRemoved", RegisterRemoved);

vendor/node-usb-native/src/serialport.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ v8::Local<v8::Value> getValueFromObject(v8::Local<v8::Object> options, std::stri
8888

8989
int getIntFromObject(v8::Local<v8::Object> options, std::string key) {
9090
#if NODE_MAJOR_VERSION >= 10
91-
return getValueFromObject(options, key)->ToInt32(v8::Isolate::GetCurrent())->Int32Value();
91+
return Nan::To<v8::Int32>(getValueFromObject(options, key)).ToLocalChecked()->Value();
9292
#else
9393
return getValueFromObject(options, key)->ToInt32()->Int32Value();
9494
#endif
@@ -104,7 +104,7 @@ v8::Local<v8::String> getStringFromObj(v8::Local<v8::Object> options, std::strin
104104

105105
double getDoubleFromObject(v8::Local<v8::Object> options, std::string key) {
106106
#if NODE_MAJOR_VERSION >= 10
107-
return getValueFromObject(options, key)->ToNumber(v8::Isolate::GetCurrent())->NumberValue();
107+
return Nan::To<double>(getValueFromObject(options, key)).FromMaybe(0);
108108
#else
109109
return getValueFromObject(options, key)->ToNumber()->NumberValue();
110110
#endif
@@ -181,7 +181,7 @@ void EIO_AfterOpen(uv_work_t* req) {
181181

182182
int fd;
183183
#if NODE_MAJOR_VERSION >= 10
184-
fd = argv[1]->ToInt32(v8::Isolate::GetCurrent())->Int32Value();
184+
fd = argv[1]->ToInt32(Nan::GetCurrentContext()).ToLocalChecked()->Value();
185185
#else
186186
fd = argv[1]->ToInt32()->Int32Value();
187187
#endif
@@ -205,7 +205,7 @@ NAN_METHOD(Update) {
205205
}
206206
int fd;
207207
#if NODE_MAJOR_VERSION >= 10
208-
fd = info[0]->ToInt32(v8::Isolate::GetCurrent())->Int32Value();
208+
fd = info[0]->ToInt32(Nan::GetCurrentContext()).ToLocalChecked()->Value();
209209
#else
210210
fd = info[0]->ToInt32()->Int32Value();
211211
#endif
@@ -233,7 +233,7 @@ NAN_METHOD(Update) {
233233

234234
baton->fd = fd;
235235
#if NODE_MAJOR_VERSION >= 10
236-
baton->baudRate = Nan::Get(options, Nan::New<v8::String>("baudRate").ToLocalChecked()).ToLocalChecked()->ToInt32(v8::Isolate::GetCurrent())->Int32Value();
236+
baton->baudRate = Nan::Get(options, Nan::New<v8::String>("baudRate").ToLocalChecked()).ToLocalChecked()->ToInt32(Nan::GetCurrentContext()).ToLocalChecked()->Value();
237237
#else
238238
baton->baudRate = Nan::Get(options, Nan::New<v8::String>("baudRate").ToLocalChecked()).ToLocalChecked()->ToInt32()->Int32Value();
239239
#endif
@@ -273,7 +273,7 @@ NAN_METHOD(Write) {
273273
}
274274
int fd;
275275
#if NODE_MAJOR_VERSION >= 10
276-
fd = info[0]->ToInt32(v8::Isolate::GetCurrent())->Int32Value();
276+
fd = info[0]->ToInt32(Nan::GetCurrentContext()).ToLocalChecked()->Value();
277277
#else
278278
fd = info[0]->ToInt32()->Int32Value();
279279
#endif
@@ -394,7 +394,7 @@ NAN_METHOD(Close) {
394394
CloseBaton* baton = new CloseBaton();
395395
memset(baton, 0, sizeof(CloseBaton));
396396
#if NODE_MAJOR_VERSION >= 10
397-
baton->fd = info[0]->ToInt32(v8::Isolate::GetCurrent())->Int32Value();
397+
baton->fd = info[0]->ToInt32(Nan::GetCurrentContext()).ToLocalChecked()->Value();
398398
#else
399399
baton->fd = info[0]->ToInt32()->Int32Value();
400400
#endif
@@ -511,7 +511,7 @@ NAN_METHOD(Flush) {
511511
}
512512
int fd;
513513
#if NODE_MAJOR_VERSION >= 10
514-
fd = info[0]->ToInt32(v8::Isolate::GetCurrent())->Int32Value();
514+
fd = info[0]->ToInt32(Nan::GetCurrentContext()).ToLocalChecked()->Value();
515515
#else
516516
fd = info[0]->ToInt32()->Int32Value();
517517
#endif
@@ -564,7 +564,7 @@ NAN_METHOD(Set) {
564564
}
565565
int fd;
566566
#if NODE_MAJOR_VERSION >= 10
567-
fd = info[0]->ToInt32(v8::Isolate::GetCurrent())->Int32Value();
567+
fd = info[0]->ToInt32(Nan::GetCurrentContext()).ToLocalChecked()->Value();
568568
#else
569569
fd = info[0]->ToInt32()->Int32Value();
570570
#endif
@@ -626,7 +626,7 @@ NAN_METHOD(Drain) {
626626
}
627627
int fd;
628628
#if NODE_MAJOR_VERSION >= 10
629-
fd = info[0]->ToInt32(v8::Isolate::GetCurrent())->Int32Value();
629+
fd = info[0]->ToInt32(Nan::GetCurrentContext()).ToLocalChecked()->Value();
630630
#else
631631
fd = info[0]->ToInt32()->Int32Value();
632632
#endif
@@ -697,7 +697,7 @@ SerialPortStopBits NAN_INLINE(ToStopBitEnum(double stopBits)) {
697697
}
698698

699699
extern "C" {
700-
void init_serialport(v8::Handle<v8::Object> target) {
700+
void init_serialport( v8::Local<v8::Object> target) {
701701
Nan::HandleScope scope;
702702
Nan::SetMethod(target, "set", Set);
703703
Nan::SetMethod(target, "open", Open);

vendor/node-usb-native/src/serialport_poller.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void SerialportPoller::callCallback(int status) {
4949

5050

5151

52-
void SerialportPoller::Init(Handle<Object> target) {
52+
void SerialportPoller::Init(Local<Object> target) {
5353
Nan::HandleScope scope;
5454

5555
// Prepare constructor template
@@ -84,7 +84,7 @@ NAN_METHOD(SerialportPoller::New) {
8484

8585
SerialportPoller* obj = new SerialportPoller();
8686
#if NODE_MAJOR_VERSION >= 10
87-
obj->fd_ = info[0]->ToInt32(v8::Isolate::GetCurrent())->Int32Value();
87+
obj->fd_ = info[0]->ToInt32(Nan::GetCurrentContext()).ToLocalChecked()->Value();
8888
#else
8989
obj->fd_ = info[0]->ToInt32()->Int32Value();
9090
#endif

vendor/node-usb-native/src/serialport_poller.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
class SerialportPoller : public Nan::ObjectWrap {
1212
public:
13-
static void Init(v8::Handle<v8::Object> target);
13+
static void Init( v8::Local<v8::Object> target);
1414

1515
void callCallback(int status);
1616

vendor/node-usb-native/src/serialport_unix.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ OpenBatonPlatformOptions* ParsePlatformOptions(const v8::Local<v8::Object>& opti
4242

4343
UnixPlatformOptions* result = new UnixPlatformOptions();
4444
#if NODE_MAJOR_VERSION >= 10
45-
result->vmin = Nan::Get(options, Nan::New<v8::String>("vmin").ToLocalChecked()).ToLocalChecked()->ToInt32(v8::Isolate::GetCurrent())->Int32Value();
46-
result->vtime = Nan::Get(options, Nan::New<v8::String>("vtime").ToLocalChecked()).ToLocalChecked()->ToInt32(v8::Isolate::GetCurrent())->Int32Value();
45+
result->vmin = Nan::Get(options, Nan::New<v8::String>("vmin").ToLocalChecked()).ToLocalChecked()->ToInt32(Nan::GetCurrentContext()).ToLocalChecked()->Value();
46+
result->vtime = Nan::Get(options, Nan::New<v8::String>("vtime").ToLocalChecked()).ToLocalChecked()->ToInt32(Nan::GetCurrentContext()).ToLocalChecked()->Value();
4747
#else
4848
result->vmin = Nan::Get(options, Nan::New<v8::String>("vmin").ToLocalChecked()).ToLocalChecked()->ToInt32()->Int32Value();
4949
result->vtime = Nan::Get(options, Nan::New<v8::String>("vtime").ToLocalChecked()).ToLocalChecked()->ToInt32()->Int32Value();

0 commit comments

Comments
 (0)