Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for Node v12/v13 - for v8 changes #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
16 changes: 8 additions & 8 deletions src/UdpPort.cc
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ void UdpPort::doProcess (std::shared_ptr<iProcessData> processData, std::string
NAN_METHOD(UdpPort::AddMembership) {
if (info.Length() != 2)
return Nan::ThrowError("UdpPort AddMembership expects 2 arguments");
String::Utf8Value mAddrStr(Nan::To<String>(info[0]).ToLocalChecked());
String::Utf8Value uAddrStr(Nan::To<String>(info[1]).ToLocalChecked());
String::Utf8Value mAddrStr(v8::Isolate::GetCurrent(), Nan::To<String>(info[0]).ToLocalChecked());
String::Utf8Value uAddrStr(v8::Isolate::GetCurrent(), Nan::To<String>(info[1]).ToLocalChecked());

UdpPort *obj = Nan::ObjectWrap::Unwrap<UdpPort>(info.Holder());
try {
Expand All @@ -144,8 +144,8 @@ NAN_METHOD(UdpPort::AddMembership) {
NAN_METHOD(UdpPort::DropMembership) {
if (info.Length() != 2)
return Nan::ThrowError("UdpPort DropMembership expects 2 arguments");
String::Utf8Value mAddrStr(Nan::To<String>(info[0]).ToLocalChecked());
String::Utf8Value uAddrStr(Nan::To<String>(info[1]).ToLocalChecked());
String::Utf8Value mAddrStr(v8::Isolate::GetCurrent(), Nan::To<String>(info[0]).ToLocalChecked());
String::Utf8Value uAddrStr(v8::Isolate::GetCurrent(), Nan::To<String>(info[1]).ToLocalChecked());

UdpPort *obj = Nan::ObjectWrap::Unwrap<UdpPort>(info.Holder());
try {
Expand Down Expand Up @@ -219,7 +219,7 @@ NAN_METHOD(UdpPort::Bind) {
return Nan::ThrowError("UdpPort Bind requires a valid callback as the third parameter");

uint32_t port = Nan::To<uint32_t>(info[0]).FromJust();
String::Utf8Value addrStr(Nan::To<String>(info[1]).ToLocalChecked());
String::Utf8Value addrStr(v8::Isolate::GetCurrent(), Nan::To<String>(info[1]).ToLocalChecked());
Local<Function> callback = Local<Function>::Cast(info[2]);

UdpPort *obj = Nan::ObjectWrap::Unwrap<UdpPort>(info.Holder());
Expand All @@ -244,18 +244,18 @@ NAN_METHOD(UdpPort::Send) {
uint32_t offset = Nan::To<uint32_t>(info[1]).FromJust();
uint32_t length = Nan::To<uint32_t>(info[2]).FromJust();
uint32_t port = Nan::To<uint32_t>(info[3]).FromJust();
String::Utf8Value addrStr(Nan::To<String>(info[4]).ToLocalChecked());
String::Utf8Value addrStr(v8::Isolate::GetCurrent(), Nan::To<String>(info[4]).ToLocalChecked());
Nan::Callback *callback = new Nan::Callback(Local<Function>::Cast(info[5]));

if (1 == bufArray->Length()) {
uint32_t buffLen = (uint32_t)node::Buffer::Length(bufArray->Get(0));
uint32_t buffLen = (uint32_t)node::Buffer::Length(bufArray->Get(v8::Isolate::GetCurrent()->GetCurrentContext(), 0).ToLocalChecked());
if (offset + length > buffLen)
return Nan::ThrowError("UdpPort Send - out of range offset/length");
}

tBufVec bufVec;
for (uint32_t i = 0; i < bufArray->Length(); ++i) {
Local<Object> bufferObj = Local<Object>::Cast(bufArray->Get(i));
Local<Object> bufferObj = Local<Object>::Cast(bufArray->Get(v8::Isolate::GetCurrent()->GetCurrentContext(), i).ToLocalChecked());
uint8_t *sendBuf = (uint8_t *)node::Buffer::Data(bufferObj);
uint32_t bufLen = (uint32_t)node::Buffer::Length(bufferObj);
if (1 == bufArray->Length()) {
Expand Down
2 changes: 1 addition & 1 deletion src/UdpPort.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class UdpPort : public Nan::ObjectWrap, public iProcess {
if (!Nan::Has(options, typeStr).FromJust())
return Nan::ThrowError("UdpPort constructor requires type string in first parameter");

v8::String::Utf8Value ipTypeUtf8(Nan::To<v8::String>(Nan::Get(options, typeStr).ToLocalChecked()).ToLocalChecked());
v8::String::Utf8Value ipTypeUtf8(v8::Isolate::GetCurrent(), Nan::To<v8::String>(Nan::Get(options, typeStr).ToLocalChecked()).ToLocalChecked());
std::string ipType = *ipTypeUtf8;
bool reuseAddr = false;
v8::Local<v8::String> reuseStr = Nan::New<v8::String>("reuseAddr").ToLocalChecked();
Expand Down