From 4e7ed79423b98bed92950db9478dde720b5e4d26 Mon Sep 17 00:00:00 2001 From: xibxor Date: Mon, 15 Jul 2019 11:22:55 -0700 Subject: [PATCH 1/2] update calls to use contexts and convert Maybes into Checked values, for compatibility with node 12.6.0 and v8 >= 7.5.288.22 --- src/zlib_sync.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/zlib_sync.cc b/src/zlib_sync.cc index 999c967..2324eb3 100644 --- a/src/zlib_sync.cc +++ b/src/zlib_sync.cc @@ -65,15 +65,15 @@ class ZlibSyncInflate : public ObjectWrap { static NAN_METHOD(Push) { ZlibSyncInflate* self = ObjectWrap::Unwrap(info.This()); - + auto context = info.GetIsolate()->GetCurrentContext(); Local buffer = Local::Cast(info[0]); int flush = Z_NO_FLUSH; if(info[1]->IsBoolean()) { - if(info[1]->BooleanValue()) { + if(info[1]->BooleanValue(context).ToChecked()) { flush = Z_FINISH; } } else if(info[1]->IsNumber()) { - flush = info[1]->Int32Value(); + flush = info[1]->Int32Value(context).ToChecked(); } z_stream* stream = &self->stream; @@ -153,7 +153,7 @@ class ZlibSyncInflate : public ObjectWrap { if(!info.IsConstructCall()) { return Nan::ThrowTypeError("Use the new operator to construct a ZlibSyncInflate."); } - + auto context = info.GetIsolate()->GetCurrentContext(); unsigned int chunkSize = 16 * 1024; bool toString = false; int windowBits = 15; @@ -162,12 +162,12 @@ class ZlibSyncInflate : public ObjectWrap { Local val = Nan::Get(options, Nan::New("chunkSize").ToLocalChecked()).ToLocalChecked(); if(val->IsNumber()) { - chunkSize = val->Int32Value(); + chunkSize = val->Int32Value(context).ToChecked(); } val = Nan::Get(options, Nan::New("to").ToLocalChecked()).ToLocalChecked(); if(val->IsString()) { - std::string to = *String::Utf8Value(val->ToString()); + std::string to = *Nan::Utf8String(val->ToString(context).ToLocalChecked()); if(to == "string") { toString = true; } @@ -175,7 +175,7 @@ class ZlibSyncInflate : public ObjectWrap { val = Nan::Get(options, Nan::New("windowBits").ToLocalChecked()).ToLocalChecked(); if(val->IsNumber()) { - windowBits = val->Int32Value(); + windowBits = val->Int32Value(context).ToChecked(); } } @@ -187,7 +187,7 @@ class ZlibSyncInflate : public ObjectWrap { static NAN_MODULE_INIT(Init) { Nan::HandleScope scope; - + auto context = Nan::GetCurrentContext(); Local tpl = Nan::New(New); tpl->SetClassName(Nan::New("ZlibSyncInflate").ToLocalChecked()); tpl->InstanceTemplate()->SetInternalFieldCount(1); @@ -201,7 +201,7 @@ class ZlibSyncInflate : public ObjectWrap { Nan::SetAccessor(itpl, Nan::New("result").ToLocalChecked(), GetResult); Nan::SetAccessor(itpl, Nan::New("windowBits").ToLocalChecked(), GetWindowBits); - target->Set(Nan::New("Inflate").ToLocalChecked(), tpl->GetFunction()); + target->Set(Nan::New("Inflate").ToLocalChecked(), tpl->GetFunction(context).ToLocalChecked()); } }; From a3f3e7080f7198753c18dc53aeb903060ea9c917 Mon Sep 17 00:00:00 2001 From: abalabahaha Date: Thu, 1 Aug 2019 23:18:25 -0700 Subject: [PATCH 2/2] Use Nan for getting local Contexts --- src/zlib_sync.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/zlib_sync.cc b/src/zlib_sync.cc index 2324eb3..c8af1b8 100644 --- a/src/zlib_sync.cc +++ b/src/zlib_sync.cc @@ -65,7 +65,7 @@ class ZlibSyncInflate : public ObjectWrap { static NAN_METHOD(Push) { ZlibSyncInflate* self = ObjectWrap::Unwrap(info.This()); - auto context = info.GetIsolate()->GetCurrentContext(); + Local context = Nan::GetCurrentContext(); Local buffer = Local::Cast(info[0]); int flush = Z_NO_FLUSH; if(info[1]->IsBoolean()) { @@ -153,7 +153,7 @@ class ZlibSyncInflate : public ObjectWrap { if(!info.IsConstructCall()) { return Nan::ThrowTypeError("Use the new operator to construct a ZlibSyncInflate."); } - auto context = info.GetIsolate()->GetCurrentContext(); + Local context = Nan::GetCurrentContext(); unsigned int chunkSize = 16 * 1024; bool toString = false; int windowBits = 15; @@ -187,7 +187,7 @@ class ZlibSyncInflate : public ObjectWrap { static NAN_MODULE_INIT(Init) { Nan::HandleScope scope; - auto context = Nan::GetCurrentContext(); + Local context = Nan::GetCurrentContext(); Local tpl = Nan::New(New); tpl->SetClassName(Nan::New("ZlibSyncInflate").ToLocalChecked()); tpl->InstanceTemplate()->SetInternalFieldCount(1);