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

Fix serialport source code for API changes #923

Merged
merged 2 commits into from
Nov 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions vendor/node-usb-native/src/combined.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
#include <nan.h>

extern "C" {
void init_serialport(v8::Handle<v8::Object> target);
void init_serialport( v8::Local<v8::Object> target);
#ifndef DISABLE_USB_DETECTOR
void init_detector(v8::Handle<v8::Object> target);
void init_detector( v8::Local<v8::Object> target);
#endif
void initAll(v8::Handle<v8::Object> target) {
void initAll( v8::Local<v8::Object> target) {
init_serialport(target);
#ifndef DISABLE_USB_DETECTOR
init_detector(target);
Expand Down
2 changes: 1 addition & 1 deletion vendor/node-usb-native/src/detection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ void StopMonitoring(const Nan::FunctionCallbackInfo<v8::Value>& args) {
}

extern "C" {
void init_detector (v8::Handle<v8::Object> target) {
void init_detector ( v8::Local<v8::Object> target) {
Nan::SetMethod(target, "find", Find);
Nan::SetMethod(target, "registerAdded", RegisterAdded);
Nan::SetMethod(target, "registerRemoved", RegisterRemoved);
Expand Down
22 changes: 11 additions & 11 deletions vendor/node-usb-native/src/serialport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ v8::Local<v8::Value> getValueFromObject(v8::Local<v8::Object> options, std::stri

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

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

int fd;
#if NODE_MAJOR_VERSION >= 10
fd = argv[1]->ToInt32(v8::Isolate::GetCurrent())->Int32Value();
fd = argv[1]->ToInt32(Nan::GetCurrentContext()).ToLocalChecked()->Value();
#else
fd = argv[1]->ToInt32()->Int32Value();
#endif
Expand All @@ -205,7 +205,7 @@ NAN_METHOD(Update) {
}
int fd;
#if NODE_MAJOR_VERSION >= 10
fd = info[0]->ToInt32(v8::Isolate::GetCurrent())->Int32Value();
fd = info[0]->ToInt32(Nan::GetCurrentContext()).ToLocalChecked()->Value();
#else
fd = info[0]->ToInt32()->Int32Value();
#endif
Expand Down Expand Up @@ -233,7 +233,7 @@ NAN_METHOD(Update) {

baton->fd = fd;
#if NODE_MAJOR_VERSION >= 10
baton->baudRate = Nan::Get(options, Nan::New<v8::String>("baudRate").ToLocalChecked()).ToLocalChecked()->ToInt32(v8::Isolate::GetCurrent())->Int32Value();
baton->baudRate = Nan::Get(options, Nan::New<v8::String>("baudRate").ToLocalChecked()).ToLocalChecked()->ToInt32(Nan::GetCurrentContext()).ToLocalChecked()->Value();
#else
baton->baudRate = Nan::Get(options, Nan::New<v8::String>("baudRate").ToLocalChecked()).ToLocalChecked()->ToInt32()->Int32Value();
#endif
Expand Down Expand Up @@ -273,7 +273,7 @@ NAN_METHOD(Write) {
}
int fd;
#if NODE_MAJOR_VERSION >= 10
fd = info[0]->ToInt32(v8::Isolate::GetCurrent())->Int32Value();
fd = info[0]->ToInt32(Nan::GetCurrentContext()).ToLocalChecked()->Value();
#else
fd = info[0]->ToInt32()->Int32Value();
#endif
Expand Down Expand Up @@ -394,7 +394,7 @@ NAN_METHOD(Close) {
CloseBaton* baton = new CloseBaton();
memset(baton, 0, sizeof(CloseBaton));
#if NODE_MAJOR_VERSION >= 10
baton->fd = info[0]->ToInt32(v8::Isolate::GetCurrent())->Int32Value();
baton->fd = info[0]->ToInt32(Nan::GetCurrentContext()).ToLocalChecked()->Value();
#else
baton->fd = info[0]->ToInt32()->Int32Value();
#endif
Expand Down Expand Up @@ -511,7 +511,7 @@ NAN_METHOD(Flush) {
}
int fd;
#if NODE_MAJOR_VERSION >= 10
fd = info[0]->ToInt32(v8::Isolate::GetCurrent())->Int32Value();
fd = info[0]->ToInt32(Nan::GetCurrentContext()).ToLocalChecked()->Value();
#else
fd = info[0]->ToInt32()->Int32Value();
#endif
Expand Down Expand Up @@ -564,7 +564,7 @@ NAN_METHOD(Set) {
}
int fd;
#if NODE_MAJOR_VERSION >= 10
fd = info[0]->ToInt32(v8::Isolate::GetCurrent())->Int32Value();
fd = info[0]->ToInt32(Nan::GetCurrentContext()).ToLocalChecked()->Value();
#else
fd = info[0]->ToInt32()->Int32Value();
#endif
Expand Down Expand Up @@ -626,7 +626,7 @@ NAN_METHOD(Drain) {
}
int fd;
#if NODE_MAJOR_VERSION >= 10
fd = info[0]->ToInt32(v8::Isolate::GetCurrent())->Int32Value();
fd = info[0]->ToInt32(Nan::GetCurrentContext()).ToLocalChecked()->Value();
#else
fd = info[0]->ToInt32()->Int32Value();
#endif
Expand Down Expand Up @@ -697,7 +697,7 @@ SerialPortStopBits NAN_INLINE(ToStopBitEnum(double stopBits)) {
}

extern "C" {
void init_serialport(v8::Handle<v8::Object> target) {
void init_serialport( v8::Local<v8::Object> target) {
Nan::HandleScope scope;
Nan::SetMethod(target, "set", Set);
Nan::SetMethod(target, "open", Open);
Expand Down
4 changes: 2 additions & 2 deletions vendor/node-usb-native/src/serialport_poller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void SerialportPoller::callCallback(int status) {



void SerialportPoller::Init(Handle<Object> target) {
void SerialportPoller::Init(Local<Object> target) {
Nan::HandleScope scope;

// Prepare constructor template
Expand Down Expand Up @@ -84,7 +84,7 @@ NAN_METHOD(SerialportPoller::New) {

SerialportPoller* obj = new SerialportPoller();
#if NODE_MAJOR_VERSION >= 10
obj->fd_ = info[0]->ToInt32(v8::Isolate::GetCurrent())->Int32Value();
obj->fd_ = info[0]->ToInt32(Nan::GetCurrentContext()).ToLocalChecked()->Value();
#else
obj->fd_ = info[0]->ToInt32()->Int32Value();
#endif
Expand Down
2 changes: 1 addition & 1 deletion vendor/node-usb-native/src/serialport_poller.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class SerialportPoller : public Nan::ObjectWrap {
public:
static void Init(v8::Handle<v8::Object> target);
static void Init( v8::Local<v8::Object> target);

void callCallback(int status);

Expand Down
4 changes: 2 additions & 2 deletions vendor/node-usb-native/src/serialport_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ OpenBatonPlatformOptions* ParsePlatformOptions(const v8::Local<v8::Object>& opti

UnixPlatformOptions* result = new UnixPlatformOptions();
#if NODE_MAJOR_VERSION >= 10
result->vmin = Nan::Get(options, Nan::New<v8::String>("vmin").ToLocalChecked()).ToLocalChecked()->ToInt32(v8::Isolate::GetCurrent())->Int32Value();
result->vtime = Nan::Get(options, Nan::New<v8::String>("vtime").ToLocalChecked()).ToLocalChecked()->ToInt32(v8::Isolate::GetCurrent())->Int32Value();
result->vmin = Nan::Get(options, Nan::New<v8::String>("vmin").ToLocalChecked()).ToLocalChecked()->ToInt32(Nan::GetCurrentContext()).ToLocalChecked()->Value();
result->vtime = Nan::Get(options, Nan::New<v8::String>("vtime").ToLocalChecked()).ToLocalChecked()->ToInt32(Nan::GetCurrentContext()).ToLocalChecked()->Value();
#else
result->vmin = Nan::Get(options, Nan::New<v8::String>("vmin").ToLocalChecked()).ToLocalChecked()->ToInt32()->Int32Value();
result->vtime = Nan::Get(options, Nan::New<v8::String>("vtime").ToLocalChecked()).ToLocalChecked()->ToInt32()->Int32Value();
Expand Down