mirror of
https://github.com/lovell/sharp.git
synced 2025-07-10 11:00:14 +02:00
Remove use of deprecated V8 API, swap v8::Handle for v8::Local #1668
This commit is contained in:
parent
159e8dace2
commit
aa9b328778
@ -31,13 +31,13 @@ using vips::VImage;
|
|||||||
namespace sharp {
|
namespace sharp {
|
||||||
|
|
||||||
// Convenience methods to access the attributes of a v8::Object
|
// Convenience methods to access the attributes of a v8::Object
|
||||||
bool HasAttr(v8::Handle<v8::Object> obj, std::string attr) {
|
bool HasAttr(v8::Local<v8::Object> obj, std::string attr) {
|
||||||
return Nan::Has(obj, Nan::New(attr).ToLocalChecked()).FromJust();
|
return Nan::Has(obj, Nan::New(attr).ToLocalChecked()).FromJust();
|
||||||
}
|
}
|
||||||
std::string AttrAsStr(v8::Handle<v8::Object> obj, std::string attr) {
|
std::string AttrAsStr(v8::Local<v8::Object> obj, std::string attr) {
|
||||||
return *Nan::Utf8String(Nan::Get(obj, Nan::New(attr).ToLocalChecked()).ToLocalChecked());
|
return *Nan::Utf8String(Nan::Get(obj, Nan::New(attr).ToLocalChecked()).ToLocalChecked());
|
||||||
}
|
}
|
||||||
std::vector<double> AttrAsRgba(v8::Handle<v8::Object> obj, std::string attr) {
|
std::vector<double> AttrAsRgba(v8::Local<v8::Object> obj, std::string attr) {
|
||||||
v8::Local<v8::Object> background = AttrAs<v8::Object>(obj, attr);
|
v8::Local<v8::Object> background = AttrAs<v8::Object>(obj, attr);
|
||||||
std::vector<double> rgba(4);
|
std::vector<double> rgba(4);
|
||||||
for (unsigned int i = 0; i < 4; i++) {
|
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
|
// Create an InputDescriptor instance from a v8::Object describing an input image
|
||||||
InputDescriptor* CreateInputDescriptor(
|
InputDescriptor* CreateInputDescriptor(
|
||||||
v8::Handle<v8::Object> input, std::vector<v8::Local<v8::Object>> &buffersToPersist
|
v8::Local<v8::Object> input, std::vector<v8::Local<v8::Object>> &buffersToPersist
|
||||||
) {
|
) {
|
||||||
Nan::HandleScope();
|
Nan::HandleScope();
|
||||||
InputDescriptor *descriptor = new InputDescriptor;
|
InputDescriptor *descriptor = new InputDescriptor;
|
||||||
|
14
src/common.h
14
src/common.h
@ -77,22 +77,22 @@ namespace sharp {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Convenience methods to access the attributes of a v8::Object
|
// Convenience methods to access the attributes of a v8::Object
|
||||||
bool HasAttr(v8::Handle<v8::Object> obj, std::string attr);
|
bool HasAttr(v8::Local<v8::Object> obj, std::string attr);
|
||||||
std::string AttrAsStr(v8::Handle<v8::Object> obj, std::string attr);
|
std::string AttrAsStr(v8::Local<v8::Object> obj, std::string attr);
|
||||||
std::vector<double> AttrAsRgba(v8::Handle<v8::Object> obj, std::string attr);
|
std::vector<double> AttrAsRgba(v8::Local<v8::Object> obj, std::string attr);
|
||||||
template<typename T> v8::Local<T> AttrAs(v8::Handle<v8::Object> obj, std::string attr) {
|
template<typename T> v8::Local<T> AttrAs(v8::Local<v8::Object> obj, std::string attr) {
|
||||||
return Nan::Get(obj, Nan::New(attr).ToLocalChecked()).ToLocalChecked().As<T>();
|
return Nan::Get(obj, Nan::New(attr).ToLocalChecked()).ToLocalChecked().As<T>();
|
||||||
}
|
}
|
||||||
template<typename T> T AttrTo(v8::Handle<v8::Object> obj, std::string attr) {
|
template<typename T> T AttrTo(v8::Local<v8::Object> obj, std::string attr) {
|
||||||
return Nan::To<T>(Nan::Get(obj, Nan::New(attr).ToLocalChecked()).ToLocalChecked()).FromJust();
|
return Nan::To<T>(Nan::Get(obj, Nan::New(attr).ToLocalChecked()).ToLocalChecked()).FromJust();
|
||||||
}
|
}
|
||||||
template<typename T> T AttrTo(v8::Handle<v8::Object> obj, int attr) {
|
template<typename T> T AttrTo(v8::Local<v8::Object> obj, int attr) {
|
||||||
return Nan::To<T>(Nan::Get(obj, attr).ToLocalChecked()).FromJust();
|
return Nan::To<T>(Nan::Get(obj, attr).ToLocalChecked()).FromJust();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create an InputDescriptor instance from a v8::Object describing an input image
|
// Create an InputDescriptor instance from a v8::Object describing an input image
|
||||||
InputDescriptor* CreateInputDescriptor(
|
InputDescriptor* CreateInputDescriptor(
|
||||||
v8::Handle<v8::Object> input, std::vector<v8::Local<v8::Object>> &buffersToPersist);
|
v8::Local<v8::Object> input, std::vector<v8::Local<v8::Object>> &buffersToPersist);
|
||||||
|
|
||||||
enum class ImageType {
|
enum class ImageType {
|
||||||
JPEG,
|
JPEG,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user