mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 10:30:15 +02:00
Unpin node-addon-api, cast CallbackInfo access to size_t
See https://github.com/nodejs/node-addon-api/pull/1253
This commit is contained in:
parent
a9bd0e79f8
commit
bdc50e1d6e
@ -131,7 +131,7 @@
|
||||
"dependencies": {
|
||||
"color": "^4.2.3",
|
||||
"detect-libc": "^2.0.1",
|
||||
"node-addon-api": "5.0.0",
|
||||
"node-addon-api": "^5.1.0",
|
||||
"prebuild-install": "^7.1.1",
|
||||
"semver": "^7.3.8",
|
||||
"simple-get": "^4.0.1",
|
||||
|
@ -79,7 +79,9 @@ namespace sharp {
|
||||
Napi::Buffer<char> NewOrCopyBuffer(Napi::Env env, char* data, size_t len) {
|
||||
try {
|
||||
return Napi::Buffer<char>::New(env, data, len, FreeCallback);
|
||||
} catch (Napi::Error const &err) {}
|
||||
} catch (Napi::Error const &err) {
|
||||
static_cast<void>(err);
|
||||
}
|
||||
Napi::Buffer<char> buf = Napi::Buffer<char>::Copy(env, data, len);
|
||||
FreeCallback(nullptr, data);
|
||||
return buf;
|
||||
|
@ -276,7 +276,7 @@ class MetadataWorker : public Napi::AsyncWorker {
|
||||
Napi::Value metadata(const Napi::CallbackInfo& info) {
|
||||
// V8 objects are converted to non-V8 types held in the baton struct
|
||||
MetadataBaton *baton = new MetadataBaton;
|
||||
Napi::Object options = info[0].As<Napi::Object>();
|
||||
Napi::Object options = info[size_t(0)].As<Napi::Object>();
|
||||
|
||||
// Input
|
||||
baton->input = sharp::CreateInputDescriptor(options.Get("input").As<Napi::Object>());
|
||||
@ -285,7 +285,7 @@ Napi::Value metadata(const Napi::CallbackInfo& info) {
|
||||
Napi::Function debuglog = options.Get("debuglog").As<Napi::Function>();
|
||||
|
||||
// Join queue for worker thread
|
||||
Napi::Function callback = info[1].As<Napi::Function>();
|
||||
Napi::Function callback = info[size_t(1)].As<Napi::Function>();
|
||||
MetadataWorker *worker = new MetadataWorker(callback, baton, debuglog);
|
||||
worker->Receiver().Set("options", options);
|
||||
worker->Queue();
|
||||
|
@ -1387,7 +1387,7 @@ class PipelineWorker : public Napi::AsyncWorker {
|
||||
Napi::Value pipeline(const Napi::CallbackInfo& info) {
|
||||
// V8 objects are converted to non-V8 types held in the baton struct
|
||||
PipelineBaton *baton = new PipelineBaton;
|
||||
Napi::Object options = info[0].As<Napi::Object>();
|
||||
Napi::Object options = info[size_t(0)].As<Napi::Object>();
|
||||
|
||||
// Input
|
||||
baton->input = sharp::CreateInputDescriptor(options.Get("input").As<Napi::Object>());
|
||||
@ -1661,7 +1661,7 @@ Napi::Value pipeline(const Napi::CallbackInfo& info) {
|
||||
Napi::Function queueListener = options.Get("queueListener").As<Napi::Function>();
|
||||
|
||||
// Join queue for worker thread
|
||||
Napi::Function callback = info[1].As<Napi::Function>();
|
||||
Napi::Function callback = info[size_t(1)].As<Napi::Function>();
|
||||
PipelineWorker *worker = new PipelineWorker(callback, baton, debuglog, queueListener);
|
||||
worker->Receiver().Set("options", options);
|
||||
worker->Queue();
|
||||
|
@ -172,7 +172,7 @@ class StatsWorker : public Napi::AsyncWorker {
|
||||
Napi::Value stats(const Napi::CallbackInfo& info) {
|
||||
// V8 objects are converted to non-V8 types held in the baton struct
|
||||
StatsBaton *baton = new StatsBaton;
|
||||
Napi::Object options = info[0].As<Napi::Object>();
|
||||
Napi::Object options = info[size_t(0)].As<Napi::Object>();
|
||||
|
||||
// Input
|
||||
baton->input = sharp::CreateInputDescriptor(options.Get("input").As<Napi::Object>());
|
||||
@ -182,7 +182,7 @@ Napi::Value stats(const Napi::CallbackInfo& info) {
|
||||
Napi::Function debuglog = options.Get("debuglog").As<Napi::Function>();
|
||||
|
||||
// Join queue for worker thread
|
||||
Napi::Function callback = info[1].As<Napi::Function>();
|
||||
Napi::Function callback = info[size_t(1)].As<Napi::Function>();
|
||||
StatsWorker *worker = new StatsWorker(callback, baton, debuglog);
|
||||
worker->Receiver().Set("options", options);
|
||||
worker->Queue();
|
||||
|
@ -30,16 +30,16 @@ Napi::Value cache(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
|
||||
// Set memory limit
|
||||
if (info[0].IsNumber()) {
|
||||
vips_cache_set_max_mem(info[0].As<Napi::Number>().Int32Value() * 1048576);
|
||||
if (info[size_t(0)].IsNumber()) {
|
||||
vips_cache_set_max_mem(info[size_t(0)].As<Napi::Number>().Int32Value() * 1048576);
|
||||
}
|
||||
// Set file limit
|
||||
if (info[1].IsNumber()) {
|
||||
vips_cache_set_max_files(info[1].As<Napi::Number>().Int32Value());
|
||||
if (info[size_t(1)].IsNumber()) {
|
||||
vips_cache_set_max_files(info[size_t(1)].As<Napi::Number>().Int32Value());
|
||||
}
|
||||
// Set items limit
|
||||
if (info[2].IsNumber()) {
|
||||
vips_cache_set_max(info[2].As<Napi::Number>().Int32Value());
|
||||
if (info[size_t(2)].IsNumber()) {
|
||||
vips_cache_set_max(info[size_t(2)].As<Napi::Number>().Int32Value());
|
||||
}
|
||||
|
||||
// Get memory stats
|
||||
@ -69,8 +69,8 @@ Napi::Value cache(const Napi::CallbackInfo& info) {
|
||||
*/
|
||||
Napi::Value concurrency(const Napi::CallbackInfo& info) {
|
||||
// Set concurrency
|
||||
if (info[0].IsNumber()) {
|
||||
vips_concurrency_set(info[0].As<Napi::Number>().Int32Value());
|
||||
if (info[size_t(0)].IsNumber()) {
|
||||
vips_concurrency_set(info[size_t(0)].As<Napi::Number>().Int32Value());
|
||||
}
|
||||
// Get concurrency
|
||||
return Napi::Number::New(info.Env(), vips_concurrency_get());
|
||||
@ -91,8 +91,8 @@ Napi::Value counters(const Napi::CallbackInfo& info) {
|
||||
*/
|
||||
Napi::Value simd(const Napi::CallbackInfo& info) {
|
||||
// Set state
|
||||
if (info[0].IsBoolean()) {
|
||||
vips_vector_set_enabled(info[0].As<Napi::Boolean>().Value());
|
||||
if (info[size_t(0)].IsBoolean()) {
|
||||
vips_vector_set_enabled(info[size_t(0)].As<Napi::Boolean>().Value());
|
||||
}
|
||||
// Get state
|
||||
return Napi::Boolean::New(info.Env(), vips_vector_isenabled());
|
||||
@ -185,10 +185,10 @@ Napi::Value _maxColourDistance(const Napi::CallbackInfo& info) {
|
||||
|
||||
// Open input files
|
||||
VImage image1;
|
||||
sharp::ImageType imageType1 = sharp::DetermineImageType(info[0].As<Napi::String>().Utf8Value().data());
|
||||
sharp::ImageType imageType1 = sharp::DetermineImageType(info[size_t(0)].As<Napi::String>().Utf8Value().data());
|
||||
if (imageType1 != sharp::ImageType::UNKNOWN) {
|
||||
try {
|
||||
image1 = VImage::new_from_file(info[0].As<Napi::String>().Utf8Value().c_str());
|
||||
image1 = VImage::new_from_file(info[size_t(0)].As<Napi::String>().Utf8Value().c_str());
|
||||
} catch (...) {
|
||||
throw Napi::Error::New(env, "Input file 1 has corrupt header");
|
||||
}
|
||||
@ -196,10 +196,10 @@ Napi::Value _maxColourDistance(const Napi::CallbackInfo& info) {
|
||||
throw Napi::Error::New(env, "Input file 1 is of an unsupported image format");
|
||||
}
|
||||
VImage image2;
|
||||
sharp::ImageType imageType2 = sharp::DetermineImageType(info[1].As<Napi::String>().Utf8Value().data());
|
||||
sharp::ImageType imageType2 = sharp::DetermineImageType(info[size_t(1)].As<Napi::String>().Utf8Value().data());
|
||||
if (imageType2 != sharp::ImageType::UNKNOWN) {
|
||||
try {
|
||||
image2 = VImage::new_from_file(info[1].As<Napi::String>().Utf8Value().c_str());
|
||||
image2 = VImage::new_from_file(info[size_t(1)].As<Napi::String>().Utf8Value().c_str());
|
||||
} catch (...) {
|
||||
throw Napi::Error::New(env, "Input file 2 has corrupt header");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user