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

Commit 80d8810

Browse files
authored
fix serialport build err under unix (#730)
1 parent f425ac6 commit 80d8810

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ NAN_METHOD(SerialportPoller::New) {
8383
}
8484

8585
SerialportPoller* obj = new SerialportPoller();
86-
obj->fd_ = info[0]->ToInt32()->Int32Value();
86+
#if NODE_MAJOR_VERSION >= 10
87+
obj->fd_ = info[0]->ToInt32(v8::Isolate::GetCurrent())->Int32Value();
88+
#else
89+
obj->fd_ = info[0]->ToInt32()->Int32Value();
90+
#endif
8791
obj->callback_ = new Nan::Callback(info[1].As<v8::Function>());
8892
// obj->callCallback();
8993

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

+7-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,13 @@ OpenBatonPlatformOptions* ParsePlatformOptions(const v8::Local<v8::Object>& opti
4141
Nan::HandleScope scope;
4242

4343
UnixPlatformOptions* result = new UnixPlatformOptions();
44-
result->vmin = Nan::Get(options, Nan::New<v8::String>("vmin").ToLocalChecked()).ToLocalChecked()->ToInt32()->Int32Value();
45-
result->vtime = Nan::Get(options, Nan::New<v8::String>("vtime").ToLocalChecked()).ToLocalChecked()->ToInt32()->Int32Value();
44+
#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();
47+
#else
48+
result->vmin = Nan::Get(options, Nan::New<v8::String>("vmin").ToLocalChecked()).ToLocalChecked()->ToInt32()->Int32Value();
49+
result->vtime = Nan::Get(options, Nan::New<v8::String>("vtime").ToLocalChecked()).ToLocalChecked()->ToInt32()->Int32Value();
50+
#endif
4651

4752
return result;
4853
}

0 commit comments

Comments
 (0)