diff --git a/src/common.cc b/src/common.cc index 7a43b466..36799619 100644 --- a/src/common.cc +++ b/src/common.cc @@ -31,13 +31,13 @@ using vips::VImage; namespace sharp { // Convenience methods to access the attributes of a v8::Object - bool HasAttr(v8::Handle obj, std::string attr) { + bool HasAttr(v8::Local obj, std::string attr) { return Nan::Has(obj, Nan::New(attr).ToLocalChecked()).FromJust(); } - std::string AttrAsStr(v8::Handle obj, std::string attr) { + std::string AttrAsStr(v8::Local obj, std::string attr) { return *Nan::Utf8String(Nan::Get(obj, Nan::New(attr).ToLocalChecked()).ToLocalChecked()); } - std::vector AttrAsRgba(v8::Handle obj, std::string attr) { + std::vector AttrAsRgba(v8::Local obj, std::string attr) { v8::Local background = AttrAs(obj, attr); std::vector rgba(4); for (unsigned int i = 0; i < 4; i++) { @@ -48,7 +48,7 @@ namespace sharp { // Create an InputDescriptor instance from a v8::Object describing an input image InputDescriptor* CreateInputDescriptor( - v8::Handle input, std::vector> &buffersToPersist + v8::Local input, std::vector> &buffersToPersist ) { Nan::HandleScope(); InputDescriptor *descriptor = new InputDescriptor; diff --git a/src/common.h b/src/common.h index 40705af2..cf55b689 100644 --- a/src/common.h +++ b/src/common.h @@ -77,22 +77,22 @@ namespace sharp { }; // Convenience methods to access the attributes of a v8::Object - bool HasAttr(v8::Handle obj, std::string attr); - std::string AttrAsStr(v8::Handle obj, std::string attr); - std::vector AttrAsRgba(v8::Handle obj, std::string attr); - template v8::Local AttrAs(v8::Handle obj, std::string attr) { + bool HasAttr(v8::Local obj, std::string attr); + std::string AttrAsStr(v8::Local obj, std::string attr); + std::vector AttrAsRgba(v8::Local obj, std::string attr); + template v8::Local AttrAs(v8::Local obj, std::string attr) { return Nan::Get(obj, Nan::New(attr).ToLocalChecked()).ToLocalChecked().As(); } - template T AttrTo(v8::Handle obj, std::string attr) { + template T AttrTo(v8::Local obj, std::string attr) { return Nan::To(Nan::Get(obj, Nan::New(attr).ToLocalChecked()).ToLocalChecked()).FromJust(); } - template T AttrTo(v8::Handle obj, int attr) { + template T AttrTo(v8::Local obj, int attr) { return Nan::To(Nan::Get(obj, attr).ToLocalChecked()).FromJust(); } // Create an InputDescriptor instance from a v8::Object describing an input image InputDescriptor* CreateInputDescriptor( - v8::Handle input, std::vector> &buffersToPersist); + v8::Local input, std::vector> &buffersToPersist); enum class ImageType { JPEG,