Skip to content

Commit 87167fa

Browse files
committed
src: use args.This() instead of Holder
The latter is deprecated in V8. Refs: http://crbug.com/333672197 PR-URL: #53474 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
1 parent 1c1bd7c commit 87167fa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+320
-346
lines changed

doc/api/addons.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@ void MyObject::New(const FunctionCallbackInfo<Value>& args) {
923923
void MyObject::PlusOne(const FunctionCallbackInfo<Value>& args) {
924924
Isolate* isolate = args.GetIsolate();
925925

926-
MyObject* obj = ObjectWrap::Unwrap<MyObject>(args.Holder());
926+
MyObject* obj = ObjectWrap::Unwrap<MyObject>(args.This());
927927
obj->value_ += 1;
928928

929929
args.GetReturnValue().Set(Number::New(isolate, obj->value_));
@@ -1138,7 +1138,7 @@ void MyObject::NewInstance(const FunctionCallbackInfo<Value>& args) {
11381138
void MyObject::PlusOne(const FunctionCallbackInfo<Value>& args) {
11391139
Isolate* isolate = args.GetIsolate();
11401140

1141-
MyObject* obj = ObjectWrap::Unwrap<MyObject>(args.Holder());
1141+
MyObject* obj = ObjectWrap::Unwrap<MyObject>(args.This());
11421142
obj->value_ += 1;
11431143

11441144
args.GetReturnValue().Set(Number::New(isolate, obj->value_));

src/README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,6 @@ Node.js source code.)
418418

419419
`args[n]` is a `Local<Value>` that represents the n-th argument passed to the
420420
function. `args.This()` is the `this` value inside this function call.
421-
`args.Holder()` is equivalent to `args.This()` in all use cases inside of
422-
Node.js.
423421

424422
`args.GetReturnValue()` is a placeholder for the return value of the function,
425423
and provides a `.Set()` method that can be called with a boolean, integer,
@@ -829,7 +827,7 @@ The JavaScript object can be accessed as a `v8::Local<v8::Object>` by using
829827
`self->object()`, given a `BaseObject` named `self`.
830828

831829
Accessing a `BaseObject` from a `v8::Local<v8::Object>` (frequently that is
832-
`args.This()` or `args.Holder()` in a [binding function][]) can be done using
830+
`args.This()` in a [binding function][]) can be done using
833831
the `Unwrap<T>(obj)` function, where `T` is a subclass of `BaseObject`.
834832
A helper for this is the `ASSIGN_OR_RETURN_UNWRAP` macro that returns from the
835833
current function if unwrapping fails (typically that means that the `BaseObject`
@@ -838,7 +836,7 @@ has been deleted earlier).
838836
```cpp
839837
void Http2Session::Request(const FunctionCallbackInfo<Value>& args) {
840838
Http2Session* session;
841-
ASSIGN_OR_RETURN_UNWRAP(&session, args.Holder());
839+
ASSIGN_OR_RETURN_UNWRAP(&session, args.This());
842840
Environment* env = session->env();
843841
Local<Context> context = env->context();
844842
Isolate* isolate = env->isolate();

src/async_wrap.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ static void RegisterDestroyHook(const FunctionCallbackInfo<Value>& args) {
254254
void AsyncWrap::GetAsyncId(const FunctionCallbackInfo<Value>& args) {
255255
AsyncWrap* wrap;
256256
args.GetReturnValue().Set(kInvalidAsyncId);
257-
ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder());
257+
ASSIGN_OR_RETURN_UNWRAP(&wrap, args.This());
258258
args.GetReturnValue().Set(wrap->get_async_id());
259259
}
260260

@@ -296,7 +296,7 @@ void AsyncWrap::AsyncReset(const FunctionCallbackInfo<Value>& args) {
296296
CHECK(args[0]->IsObject());
297297

298298
AsyncWrap* wrap;
299-
ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder());
299+
ASSIGN_OR_RETURN_UNWRAP(&wrap, args.This());
300300

301301
Local<Object> resource = args[0].As<Object>();
302302
double execution_async_id =
@@ -308,7 +308,7 @@ void AsyncWrap::AsyncReset(const FunctionCallbackInfo<Value>& args) {
308308
void AsyncWrap::GetProviderType(const FunctionCallbackInfo<Value>& args) {
309309
AsyncWrap* wrap;
310310
args.GetReturnValue().Set(AsyncWrap::PROVIDER_NONE);
311-
ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder());
311+
ASSIGN_OR_RETURN_UNWRAP(&wrap, args.This());
312312
args.GetReturnValue().Set(wrap->provider_type());
313313
}
314314

src/cares_wrap.cc

+5-5
Original file line numberDiff line numberDiff line change
@@ -1404,7 +1404,7 @@ template <class Wrap>
14041404
static void Query(const FunctionCallbackInfo<Value>& args) {
14051405
Environment* env = Environment::GetCurrent(args);
14061406
ChannelWrap* channel;
1407-
ASSIGN_OR_RETURN_UNWRAP(&channel, args.Holder());
1407+
ASSIGN_OR_RETURN_UNWRAP(&channel, args.This());
14081408

14091409
CHECK_EQ(false, args.IsConstructCall());
14101410
CHECK(args[0]->IsObject());
@@ -1664,7 +1664,7 @@ void GetNameInfo(const FunctionCallbackInfo<Value>& args) {
16641664
void GetServers(const FunctionCallbackInfo<Value>& args) {
16651665
Environment* env = Environment::GetCurrent(args);
16661666
ChannelWrap* channel;
1667-
ASSIGN_OR_RETURN_UNWRAP(&channel, args.Holder());
1667+
ASSIGN_OR_RETURN_UNWRAP(&channel, args.This());
16681668

16691669
Local<Array> server_array = Array::New(env->isolate());
16701670

@@ -1702,7 +1702,7 @@ void GetServers(const FunctionCallbackInfo<Value>& args) {
17021702
void SetServers(const FunctionCallbackInfo<Value>& args) {
17031703
Environment* env = Environment::GetCurrent(args);
17041704
ChannelWrap* channel;
1705-
ASSIGN_OR_RETURN_UNWRAP(&channel, args.Holder());
1705+
ASSIGN_OR_RETURN_UNWRAP(&channel, args.This());
17061706

17071707
if (channel->active_query_count()) {
17081708
return args.GetReturnValue().Set(DNS_ESETSRVPENDING);
@@ -1783,7 +1783,7 @@ void SetServers(const FunctionCallbackInfo<Value>& args) {
17831783
void SetLocalAddress(const FunctionCallbackInfo<Value>& args) {
17841784
Environment* env = Environment::GetCurrent(args);
17851785
ChannelWrap* channel;
1786-
ASSIGN_OR_RETURN_UNWRAP(&channel, args.Holder());
1786+
ASSIGN_OR_RETURN_UNWRAP(&channel, args.This());
17871787

17881788
CHECK_EQ(args.Length(), 2);
17891789
CHECK(args[0]->IsString());
@@ -1846,7 +1846,7 @@ void SetLocalAddress(const FunctionCallbackInfo<Value>& args) {
18461846

18471847
void Cancel(const FunctionCallbackInfo<Value>& args) {
18481848
ChannelWrap* channel;
1849-
ASSIGN_OR_RETURN_UNWRAP(&channel, args.Holder());
1849+
ASSIGN_OR_RETURN_UNWRAP(&channel, args.This());
18501850

18511851
TRACE_EVENT_INSTANT0(TRACING_CATEGORY_NODE2(dns, native),
18521852
"cancel", TRACE_EVENT_SCOPE_THREAD);

src/crypto/crypto_cipher.cc

+7-7
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ void CipherBase::Init(const char* cipher_type,
448448

449449
void CipherBase::Init(const FunctionCallbackInfo<Value>& args) {
450450
CipherBase* cipher;
451-
ASSIGN_OR_RETURN_UNWRAP(&cipher, args.Holder());
451+
ASSIGN_OR_RETURN_UNWRAP(&cipher, args.This());
452452
Environment* env = Environment::GetCurrent(args);
453453

454454
CHECK_GE(args.Length(), 3);
@@ -520,7 +520,7 @@ void CipherBase::InitIv(const char* cipher_type,
520520

521521
void CipherBase::InitIv(const FunctionCallbackInfo<Value>& args) {
522522
CipherBase* cipher;
523-
ASSIGN_OR_RETURN_UNWRAP(&cipher, args.Holder());
523+
ASSIGN_OR_RETURN_UNWRAP(&cipher, args.This());
524524
Environment* env = cipher->env();
525525

526526
CHECK_GE(args.Length(), 4);
@@ -655,7 +655,7 @@ bool CipherBase::IsAuthenticatedMode() const {
655655
void CipherBase::GetAuthTag(const FunctionCallbackInfo<Value>& args) {
656656
Environment* env = Environment::GetCurrent(args);
657657
CipherBase* cipher;
658-
ASSIGN_OR_RETURN_UNWRAP(&cipher, args.Holder());
658+
ASSIGN_OR_RETURN_UNWRAP(&cipher, args.This());
659659

660660
// Only callable after Final and if encrypting.
661661
if (cipher->ctx_ ||
@@ -671,7 +671,7 @@ void CipherBase::GetAuthTag(const FunctionCallbackInfo<Value>& args) {
671671

672672
void CipherBase::SetAuthTag(const FunctionCallbackInfo<Value>& args) {
673673
CipherBase* cipher;
674-
ASSIGN_OR_RETURN_UNWRAP(&cipher, args.Holder());
674+
ASSIGN_OR_RETURN_UNWRAP(&cipher, args.This());
675675
Environment* env = Environment::GetCurrent(args);
676676

677677
if (!cipher->ctx_ ||
@@ -784,7 +784,7 @@ bool CipherBase::SetAAD(
784784

785785
void CipherBase::SetAAD(const FunctionCallbackInfo<Value>& args) {
786786
CipherBase* cipher;
787-
ASSIGN_OR_RETURN_UNWRAP(&cipher, args.Holder());
787+
ASSIGN_OR_RETURN_UNWRAP(&cipher, args.This());
788788
Environment* env = Environment::GetCurrent(args);
789789

790790
CHECK_EQ(args.Length(), 2);
@@ -897,7 +897,7 @@ bool CipherBase::SetAutoPadding(bool auto_padding) {
897897

898898
void CipherBase::SetAutoPadding(const FunctionCallbackInfo<Value>& args) {
899899
CipherBase* cipher;
900-
ASSIGN_OR_RETURN_UNWRAP(&cipher, args.Holder());
900+
ASSIGN_OR_RETURN_UNWRAP(&cipher, args.This());
901901

902902
bool b = cipher->SetAutoPadding(args.Length() < 1 || args[0]->IsTrue());
903903
args.GetReturnValue().Set(b); // Possibly report invalid state failure
@@ -972,7 +972,7 @@ void CipherBase::Final(const FunctionCallbackInfo<Value>& args) {
972972
Environment* env = Environment::GetCurrent(args);
973973

974974
CipherBase* cipher;
975-
ASSIGN_OR_RETURN_UNWRAP(&cipher, args.Holder());
975+
ASSIGN_OR_RETURN_UNWRAP(&cipher, args.This());
976976
if (cipher->ctx_ == nullptr)
977977
return THROW_ERR_CRYPTO_INVALID_STATE(env);
978978

0 commit comments

Comments
 (0)