diff --git a/nan_callbacks_12_inl.h b/nan_callbacks_12_inl.h index 806d64c0..1f8bbedd 100644 --- a/nan_callbacks_12_inl.h +++ b/nan_callbacks_12_inl.h @@ -111,7 +111,19 @@ class FunctionCallbackInfo { } #endif inline v8::Local Data() const { return data_; } - inline v8::Local Holder() const { return info_.Holder(); } + NAN_DEPRECATED inline v8::Local Holder() const { +#if defined(V8_MAJOR_VERSION) && \ + (V8_MAJOR_VERSION > 12 || \ + (V8_MAJOR_VERSION == 12 && \ + (defined(V8_MINOR_VERSION) && \ + (V8_MINOR_VERSION > 5 || \ + (V8_MINOR_VERSION == 5 && defined(V8_BUILD_NUMBER) && \ + V8_BUILD_NUMBER >= 214))))) + return info_.This(); +#else + return info_.Holder(); +#endif + } inline bool IsConstructCall() const { return info_.IsConstructCall(); } inline int Length() const { return info_.Length(); } inline v8::Local operator[](int i) const { return info_[i]; } diff --git a/nan_callbacks_pre_12_inl.h b/nan_callbacks_pre_12_inl.h index 409f6125..ca3d2f48 100644 --- a/nan_callbacks_pre_12_inl.h +++ b/nan_callbacks_pre_12_inl.h @@ -140,7 +140,9 @@ class FunctionCallbackInfo { return args_.Callee(); } inline v8::Local Data() const { return data_; } - inline v8::Local Holder() const { return args_.Holder(); } + NAN_DEPRECATED inline v8::Local Holder() const { + return args_.Holder(); + } inline bool IsConstructCall() const { return args_.IsConstructCall(); } inline int Length() const { return args_.Length(); } inline v8::Local operator[](int i) const { return args_[i]; } diff --git a/test/cpp/accessors.cpp b/test/cpp/accessors.cpp index 5848a409..a68b82ca 100644 --- a/test/cpp/accessors.cpp +++ b/test/cpp/accessors.cpp @@ -90,7 +90,7 @@ NAN_METHOD(SetterGetter::New) { NAN_GETTER(SetterGetter::GetProp1) { SetterGetter* settergetter = - ObjectWrap::Unwrap(info.Holder()); + ObjectWrap::Unwrap(info.This()); assert(strlen(settergetter->log) < sizeof (settergetter->log)); strncat( settergetter->log @@ -112,7 +112,7 @@ NAN_GETTER(SetterGetter::GetProp1) { NAN_GETTER(SetterGetter::GetProp2) { SetterGetter* settergetter = - ObjectWrap::Unwrap(info.Holder()); + ObjectWrap::Unwrap(info.This()); assert(strlen(settergetter->log) < sizeof (settergetter->log)); strncat( settergetter->log @@ -134,7 +134,7 @@ NAN_GETTER(SetterGetter::GetProp2) { NAN_SETTER(SetterGetter::SetProp2) { SetterGetter* settergetter = - ObjectWrap::Unwrap(info.Holder()); + ObjectWrap::Unwrap(info.This()); strncpy( settergetter->prop2 , *Utf8String(value) @@ -159,7 +159,7 @@ NAN_SETTER(SetterGetter::SetProp2) { NAN_METHOD(SetterGetter::Log) { SetterGetter* settergetter = - ObjectWrap::Unwrap(info.Holder()); + ObjectWrap::Unwrap(info.This()); info.GetReturnValue().Set(Nan::New(settergetter->log).ToLocalChecked()); } diff --git a/test/cpp/accessors2.cpp b/test/cpp/accessors2.cpp index f5a2b312..59125d33 100644 --- a/test/cpp/accessors2.cpp +++ b/test/cpp/accessors2.cpp @@ -88,7 +88,7 @@ NAN_METHOD(SetterGetter::New) { NAN_GETTER(SetterGetter::GetProp1) { SetterGetter* settergetter = - ObjectWrap::Unwrap(info.Holder()); + ObjectWrap::Unwrap(info.This()); assert(strlen(settergetter->log) < sizeof (settergetter->log)); strncat( settergetter->log @@ -110,7 +110,7 @@ NAN_GETTER(SetterGetter::GetProp1) { NAN_GETTER(SetterGetter::GetProp2) { SetterGetter* settergetter = - ObjectWrap::Unwrap(info.Holder()); + ObjectWrap::Unwrap(info.This()); assert(strlen(settergetter->log) < sizeof (settergetter->log)); strncat( settergetter->log @@ -132,7 +132,7 @@ NAN_GETTER(SetterGetter::GetProp2) { NAN_SETTER(SetterGetter::SetProp2) { SetterGetter* settergetter = - ObjectWrap::Unwrap(info.Holder()); + ObjectWrap::Unwrap(info.This()); strncpy( settergetter->prop2 , *Nan::Utf8String(value) @@ -157,7 +157,7 @@ NAN_SETTER(SetterGetter::SetProp2) { NAN_METHOD(SetterGetter::Log) { SetterGetter* settergetter = - ObjectWrap::Unwrap(info.Holder()); + ObjectWrap::Unwrap(info.This()); info.GetReturnValue().Set(Nan::New(settergetter->log).ToLocalChecked()); } diff --git a/test/cpp/methodswithdata.cpp b/test/cpp/methodswithdata.cpp index 7dd6cbc3..daa91046 100644 --- a/test/cpp/methodswithdata.cpp +++ b/test/cpp/methodswithdata.cpp @@ -74,7 +74,7 @@ NAN_GETTER(SetterGetter::GetProp1) { std::string datavalue = *Nan::Utf8String(info.Data()); assert(datavalue == "prop1-data"); SetterGetter* settergetter = - ObjectWrap::Unwrap(info.Holder()); + ObjectWrap::Unwrap(info.This()); assert(strlen(settergetter->log) < sizeof (settergetter->log)); strncat( settergetter->log @@ -99,7 +99,7 @@ NAN_GETTER(SetterGetter::GetProp2) { assert(datavalue == "prop2-data"); SetterGetter* settergetter = - ObjectWrap::Unwrap(info.Holder()); + ObjectWrap::Unwrap(info.This()); assert(strlen(settergetter->log) < sizeof (settergetter->log)); strncat( settergetter->log @@ -124,7 +124,7 @@ NAN_SETTER(SetterGetter::SetProp2) { assert(datavalue == "prop2-data"); SetterGetter* settergetter = - ObjectWrap::Unwrap(info.Holder()); + ObjectWrap::Unwrap(info.This()); strncpy( settergetter->prop2 , *Utf8String(value) @@ -149,7 +149,7 @@ NAN_SETTER(SetterGetter::SetProp2) { NAN_METHOD(SetterGetter::Log) { SetterGetter* settergetter = - ObjectWrap::Unwrap(info.Holder()); + ObjectWrap::Unwrap(info.This()); info.GetReturnValue().Set(Nan::New(settergetter->log).ToLocalChecked()); } diff --git a/test/cpp/objectwraphandle.cpp b/test/cpp/objectwraphandle.cpp index ac4f79aa..64dd9e7a 100644 --- a/test/cpp/objectwraphandle.cpp +++ b/test/cpp/objectwraphandle.cpp @@ -47,17 +47,17 @@ class MyObject : public ObjectWrap { } static NAN_METHOD(GetHandle) { - MyObject* obj = ObjectWrap::Unwrap(info.Holder()); + MyObject* obj = ObjectWrap::Unwrap(info.This()); info.GetReturnValue().Set(obj->handle()); } static NAN_METHOD(GetHandleConst) { - MyObject const *obj = ObjectWrap::Unwrap(info.Holder()); + MyObject const *obj = ObjectWrap::Unwrap(info.This()); info.GetReturnValue().Set(obj->handle()); } static NAN_METHOD(GetValue) { - MyObject* obj = ObjectWrap::Unwrap(info.Holder()); + MyObject* obj = ObjectWrap::Unwrap(info.This()); info.GetReturnValue().Set(obj->value_); } diff --git a/test/cpp/wrappedobjectfactory.cpp b/test/cpp/wrappedobjectfactory.cpp index 9930a5f1..ec3955e4 100644 --- a/test/cpp/wrappedobjectfactory.cpp +++ b/test/cpp/wrappedobjectfactory.cpp @@ -49,7 +49,7 @@ class InnerObject : public ObjectWrap { } static NAN_METHOD(GetValue) { - InnerObject* obj = ObjectWrap::Unwrap(info.Holder()); + InnerObject* obj = ObjectWrap::Unwrap(info.This()); info.GetReturnValue().Set(obj->value_); } @@ -102,7 +102,7 @@ class MyObject : public ObjectWrap { } static NAN_METHOD(GetValue) { - MyObject* obj = ObjectWrap::Unwrap(info.Holder()); + MyObject* obj = ObjectWrap::Unwrap(info.This()); info.GetReturnValue().Set(obj->value_); } diff --git a/test/js/accessors-test.js b/test/js/accessors-test.js index e6ad4573..36c264c1 100644 --- a/test/js/accessors-test.js +++ b/test/js/accessors-test.js @@ -11,7 +11,7 @@ const test = require('tap').test , bindings = require('bindings')({ module_root: testRoot, bindings: 'accessors' }); test('accessors', function (t) { - t.plan(7) + t.plan(9) var settergetter = bindings.create() t.equal(settergetter.prop1, 'this is property 1') t.ok(settergetter.prop2 === '') @@ -28,5 +28,8 @@ test('accessors', function (t) { t.equal(derived.prop1, 'this is property 1') derived.prop2 = 'setting a new value' t.equal(derived.prop2, 'setting a new value') - t.equal(settergetter.prop2, 'setting a new value') + t.equal(settergetter.prop2, 'setting a value') + settergetter.prop2 = 'setting another value' + t.equal(settergetter.prop2, 'setting another value') + t.equal(derived.prop2, 'setting a new value') }) diff --git a/test/js/methodswithdata-test.js b/test/js/methodswithdata-test.js index c6d2b22f..b23a0a08 100644 --- a/test/js/methodswithdata-test.js +++ b/test/js/methodswithdata-test.js @@ -11,28 +11,30 @@ const test = require('tap').test , bindings = require('bindings')({ module_root: testRoot, bindings: 'methodswithdata' }) test('SetMethod with data', function (t) { - t.plan(1); - t.ok(bindings.testWithData()); + t.plan(1); + t.ok(bindings.testWithData()); }); test('accessors with data', function (t) { - t.plan(7) - var settergetter = bindings.create() - t.equal(settergetter.prop1, 'this is property 1') - t.ok(settergetter.prop2 === '') - settergetter.prop2 = 'setting a value' - t.equal(settergetter.prop2, 'setting a value') - t.equal(settergetter.log(), - 'New()\n' + - 'Prop1:GETTER(this is property 1)\n' + - 'Prop2:GETTER()\n' + - 'Prop2:SETTER(setting a value)\n' + - 'Prop2:GETTER(setting a value)\n' - ) - var derived = Object.create(settergetter) - t.equal(derived.prop1, 'this is property 1') - derived.prop2 = 'setting a new value' - t.equal(derived.prop2, 'setting a new value') - t.equal(settergetter.prop2, 'setting a new value') - }) - \ No newline at end of file + t.plan(9) + var settergetter = bindings.create() + t.equal(settergetter.prop1, 'this is property 1') + t.ok(settergetter.prop2 === '') + settergetter.prop2 = 'setting a value' + t.equal(settergetter.prop2, 'setting a value') + t.equal(settergetter.log(), + 'New()\n' + + 'Prop1:GETTER(this is property 1)\n' + + 'Prop2:GETTER()\n' + + 'Prop2:SETTER(setting a value)\n' + + 'Prop2:GETTER(setting a value)\n' + ) + var derived = Object.create(settergetter) + t.equal(derived.prop1, 'this is property 1') + derived.prop2 = 'setting a new value' + t.equal(derived.prop2, 'setting a new value') + t.equal(settergetter.prop2, 'setting a value') + settergetter.prop2 = 'setting another value' + t.equal(settergetter.prop2, 'setting another value') + t.equal(derived.prop2, 'setting a new value') +})