diff --git a/netlinkwrapper.cc b/netlinkwrapper.cc index 6837f30..d7640f7 100644 --- a/netlinkwrapper.cc +++ b/netlinkwrapper.cc @@ -24,7 +24,7 @@ void NetLinkWrapper::Init(Local exports) // Prepare constructor template Local tpl = FunctionTemplate::New(isolate, New); - tpl->SetClassName(String::NewFromUtf8(isolate, "NetLinkWrapper")); + tpl->SetClassName(String::NewFromUtf8(isolate, "NetLinkWrapper").ToLocalChecked()); tpl->InstanceTemplate()->SetInternalFieldCount(1); // Prototype @@ -35,7 +35,7 @@ void NetLinkWrapper::Init(Local exports) NODE_SET_PROTOTYPE_METHOD(tpl, "disconnect", Disconnect); constructor.Reset(isolate, Nan::GetFunction(tpl).ToLocalChecked()); - exports->Set(String::NewFromUtf8(isolate, "NetLinkWrapper"), Nan::GetFunction(tpl).ToLocalChecked()); + Nan::Set(exports, Nan::New("NetLinkWrapper").ToLocalChecked(), Nan::GetFunction(tpl).ToLocalChecked()); } void NetLinkWrapper::New(const FunctionCallbackInfo& args) @@ -69,13 +69,13 @@ void NetLinkWrapper::Connect(const FunctionCallbackInfo& args) if(args.Length() != 2 && args.Length() != 1) { - isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "'connect' requires the arguments port and optionally host"))); + isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "'connect' requires the arguments port and optionally host").ToLocalChecked())); return; } if(!args[0]->IsNumber()) { - isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "'connect' second arg should be number for port on server"))); + isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "'connect' second arg should be number for port on server").ToLocalChecked())); return; } int port = (int)args[0]->NumberValue(isolate->GetCurrentContext()).FromJust(); @@ -93,7 +93,7 @@ void NetLinkWrapper::Connect(const FunctionCallbackInfo& args) } catch(NL::Exception& e) { - isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, e.what()))); + isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, e.what()).ToLocalChecked())); return; } } @@ -114,7 +114,7 @@ void NetLinkWrapper::Blocking(const FunctionCallbackInfo& args) } catch(NL::Exception& e) { - isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, e.what()))); + isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, e.what()).ToLocalChecked())); return; } args.GetReturnValue().Set(Boolean::New(isolate, blocking)); @@ -123,23 +123,23 @@ void NetLinkWrapper::Blocking(const FunctionCallbackInfo& args) { if(!args[0]->IsBoolean()) { - isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "first optional arg when passed must be boolean to set blocking to"))); + isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "first optional arg when passed must be boolean to set blocking to").ToLocalChecked())); return; } try { - obj->socket->blocking(args[0]->BooleanValue(isolate->GetCurrentContext()).FromJust()); + obj->socket->blocking(args[0]->BooleanValue(args.GetIsolate())); } catch(NL::Exception& e) { - isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, e.what()))); + isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, e.what()).ToLocalChecked())); return; } } else { - isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "too many args sent to blocking"))); + isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "too many args sent to blocking").ToLocalChecked())); return; } } @@ -153,7 +153,7 @@ void NetLinkWrapper::Read(const FunctionCallbackInfo& args) if((args.Length() != 1 && args.Length() != 2) || !args[0]->IsNumber()) { - isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "'read' first argument must be a number representing how many bytes to try to read"))); + isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "'read' first argument must be a number representing how many bytes to try to read").ToLocalChecked())); return; } size_t bufferSize = (int)args[0]->NumberValue(isolate->GetCurrentContext()).FromJust(); @@ -162,11 +162,11 @@ void NetLinkWrapper::Read(const FunctionCallbackInfo& args) if(args.Length() == 2 && args[0]->IsBoolean()) { try { - obj->socket->blocking(args[1]->BooleanValue(isolate->GetCurrentContext()).FromJust()); + obj->socket->blocking(args[1]->BooleanValue(args.GetIsolate())); } catch(NL::Exception& e) { - isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, e.what()))); + isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, e.what()).ToLocalChecked())); return; } } @@ -178,14 +178,14 @@ void NetLinkWrapper::Read(const FunctionCallbackInfo& args) } catch(NL::Exception& e) { - isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, e.what()))); + isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, e.what()).ToLocalChecked())); return; } if(bufferRead > -1 && bufferRead <= (int)bufferSize) // range check { std::string read(buffer, bufferRead); - args.GetReturnValue().Set(v8::String::NewFromUtf8(isolate, read.c_str())); + args.GetReturnValue().Set(v8::String::NewFromUtf8(isolate, read.c_str()).ToLocalChecked()); } //else it did not read any data, so this will return undefined @@ -201,7 +201,7 @@ void NetLinkWrapper::Write(const FunctionCallbackInfo& args) if(args.Length() != 1 || !args[0]->IsString()) { - isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "'send' first argument must be a string to send"))); + isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "'send' first argument must be a string to send").ToLocalChecked())); return; } Nan::Utf8String param1(args[0]); @@ -213,7 +213,7 @@ void NetLinkWrapper::Write(const FunctionCallbackInfo& args) } catch(NL::Exception& e) { - isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, e.what()))); + isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, e.what()).ToLocalChecked())); return; } } @@ -231,7 +231,7 @@ void NetLinkWrapper::Disconnect(const FunctionCallbackInfo& args) } catch(NL::Exception& e) { - isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, e.what()))); + isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, e.what()).ToLocalChecked())); return; } }