Skip to content

Commit 3b28b18

Browse files
authored
Migrate from deprecated Get/SetPrototypeV2() and HolderV2() (#252)
... to Get/SetPrototype() and Holder() respectively. No functional changes.
1 parent f061cba commit 3b28b18

13 files changed

Lines changed: 29 additions & 31 deletions

‎src/api/environment.cc‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,7 @@ MaybeLocal<Object> InitializePrivateSymbols(Local<Context> context,
958958

959959
Local<Object> private_symbols_object;
960960
if (!private_symbols->NewInstance(context).ToLocal(&private_symbols_object) ||
961-
private_symbols_object->SetPrototypeV2(context, Null(isolate))
961+
private_symbols_object->SetPrototype(context, Null(isolate))
962962
.IsNothing()) {
963963
return MaybeLocal<Object>();
964964
}
@@ -984,7 +984,7 @@ MaybeLocal<Object> InitializePerIsolateSymbols(Local<Context> context,
984984
Local<Object> per_isolate_symbols_object;
985985
if (!per_isolate_symbols->NewInstance(context).ToLocal(
986986
&per_isolate_symbols_object) ||
987-
per_isolate_symbols_object->SetPrototypeV2(context, Null(isolate))
987+
per_isolate_symbols_object->SetPrototype(context, Null(isolate))
988988
.IsNothing()) {
989989
return MaybeLocal<Object>();
990990
}

‎src/internal_only_v8.cc‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ class PrototypeChainHas : public v8::QueryObjectPredicate {
3333
if (creation_context != context_) {
3434
return false;
3535
}
36-
for (Local<Value> proto = object->GetPrototypeV2(); proto->IsObject();
37-
proto = proto.As<Object>()->GetPrototypeV2()) {
36+
for (Local<Value> proto = object->GetPrototype(); proto->IsObject();
37+
proto = proto.As<Object>()->GetPrototype()) {
3838
if (search_ == proto) return true;
3939
}
4040
return false;

‎src/js_native_api_v8.cc‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,7 +1585,7 @@ napi_status NAPI_CDECL node_api_set_prototype(napi_env env,
15851585

15861586
v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value);
15871587

1588-
v8::Maybe<bool> set_maybe = obj->SetPrototypeV2(context, val);
1588+
v8::Maybe<bool> set_maybe = obj->SetPrototype(context, val);
15891589

15901590
RETURN_STATUS_IF_FALSE_WITH_PREAMBLE(
15911591
env, set_maybe.FromMaybe(false), napi_generic_failure);
@@ -1604,7 +1604,7 @@ napi_status NAPI_CDECL napi_get_prototype(napi_env env,
16041604
CHECK_TO_OBJECT(env, context, obj, object);
16051605

16061606
// This doesn't invokes Proxy's [[GetPrototypeOf]] handler.
1607-
v8::Local<v8::Value> val = obj->GetPrototypeV2();
1607+
v8::Local<v8::Value> val = obj->GetPrototype();
16081608
*result = v8impl::JsValueFromV8LocalValue(val);
16091609
return GET_RETURN_STATUS(env);
16101610
}

‎src/module_wrap.cc‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,7 @@ void ModuleWrap::HasAsyncGraph(Local<Name> property,
10351035
Isolate* isolate = args.GetIsolate();
10361036
Environment* env = Environment::GetCurrent(isolate);
10371037
ModuleWrap* obj;
1038-
ASSIGN_OR_RETURN_UNWRAP(&obj, args.HolderV2());
1038+
ASSIGN_OR_RETURN_UNWRAP(&obj, args.Holder());
10391039

10401040
Local<Module> module = obj->module_.Get(isolate);
10411041
if (module->GetStatus() < Module::kInstantiated) {
@@ -1251,7 +1251,7 @@ void ModuleWrap::SetImportMetaResolveInitializer(
12511251
static void ImportMetaResolveLazyGetter(
12521252
Local<v8::Name> name, const PropertyCallbackInfo<Value>& info) {
12531253
Isolate* isolate = info.GetIsolate();
1254-
Local<Value> receiver_val = info.HolderV2();
1254+
Local<Value> receiver_val = info.Holder();
12551255
if (!receiver_val->IsObject()) {
12561256
THROW_ERR_INVALID_INVOCATION(isolate);
12571257
return;
@@ -1292,7 +1292,7 @@ static void PathHelpersLazyGetter(Local<v8::Name> name,
12921292
// When this getter is invoked in a vm context, the `Realm::GetCurrent(info)`
12931293
// returns a nullptr and retrieve the creation context via `this` object and
12941294
// get the creation Realm.
1295-
Local<Value> receiver_val = info.HolderV2();
1295+
Local<Value> receiver_val = info.Holder();
12961296
if (!receiver_val->IsObject()) {
12971297
THROW_ERR_INVALID_INVOCATION(isolate);
12981298
return;

‎src/node_buffer.cc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ MaybeLocal<Uint8Array> New(Environment* env,
287287
size_t length) {
288288
CHECK(!env->buffer_prototype_object().IsEmpty());
289289
Local<Uint8Array> ui = Uint8Array::New(ab, byte_offset, length);
290-
if (ui->SetPrototypeV2(env->context(), env->buffer_prototype_object())
290+
if (ui->SetPrototype(env->context(), env->buffer_prototype_object())
291291
.IsNothing()) {
292292
return MaybeLocal<Uint8Array>();
293293
}

‎src/node_constants.cc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1284,7 +1284,7 @@ void CreatePerContextProperties(Local<Object> target,
12841284
Isolate* isolate = Isolate::GetCurrent();
12851285
Environment* env = Environment::GetCurrent(context);
12861286

1287-
CHECK(target->SetPrototypeV2(env->context(), Null(isolate)).FromJust());
1287+
CHECK(target->SetPrototype(env->context(), Null(isolate)).FromJust());
12881288

12891289
Local<Object> os_constants =
12901290
Object::New(isolate, Null(isolate), nullptr, nullptr, 0);

‎src/node_contextify.cc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ ContextifyContext* ContextifyContext::Get(const PropertyCallbackInfo<T>& args) {
454454
// args.GetIsolate()->GetCurrentContext() and take the pointer at
455455
// ContextEmbedderIndex::kContextifyContext, as V8 is supposed to
456456
// push the creation context before invoking these callbacks.
457-
return Get(args.HolderV2());
457+
return Get(args.Holder());
458458
}
459459

460460
ContextifyContext* ContextifyContext::Get(Local<Object> object) {

‎src/node_ffi.cc‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ void DynamicLibrary::GetFunctions(const FunctionCallbackInfo<Value>& args) {
489489
}
490490

491491
Local<Object> functions = Object::New(isolate);
492-
if (!functions->SetPrototypeV2(context, Null(isolate)).FromMaybe(false)) {
492+
if (!functions->SetPrototype(context, Null(isolate)).FromMaybe(false)) {
493493
return;
494494
}
495495

@@ -645,7 +645,7 @@ void DynamicLibrary::GetSymbols(const FunctionCallbackInfo<Value>& args) {
645645
}
646646

647647
Local<Object> symbols = Object::New(isolate);
648-
if (!symbols->SetPrototypeV2(context, Null(isolate)).FromMaybe(false)) {
648+
if (!symbols->SetPrototype(context, Null(isolate)).FromMaybe(false)) {
649649
return;
650650
}
651651
for (const auto& entry : lib->symbols_) {

‎src/node_options.cc‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,8 +1830,7 @@ void GetCLIOptionsInfo(const FunctionCallbackInfo<Value>& args) {
18301830

18311831
Local<Map> options = Map::New(isolate);
18321832
if (options
1833-
->SetPrototypeV2(context,
1834-
env->primordials_safe_map_prototype_object())
1833+
->SetPrototype(context, env->primordials_safe_map_prototype_object())
18351834
.IsNothing()) {
18361835
return;
18371836
}
@@ -1871,8 +1870,7 @@ void GetCLIOptionsInfo(const FunctionCallbackInfo<Value>& args) {
18711870
if (!ToV8Value(context, _ppop_instance.aliases_).ToLocal(&aliases)) return;
18721871

18731872
if (aliases.As<Object>()
1874-
->SetPrototypeV2(context,
1875-
env->primordials_safe_map_prototype_object())
1873+
->SetPrototype(context, env->primordials_safe_map_prototype_object())
18761874
.IsNothing()) {
18771875
return;
18781876
}

‎src/node_sqlite.cc‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ Intercepted DatabaseSyncLimits::LimitsGetter(
748748
}
749749

750750
DatabaseSyncLimits* limits;
751-
ASSIGN_OR_RETURN_UNWRAP(&limits, info.HolderV2(), Intercepted::kNo);
751+
ASSIGN_OR_RETURN_UNWRAP(&limits, info.Holder(), Intercepted::kNo);
752752

753753
Environment* env = limits->env();
754754
Isolate* isolate = env->isolate();
@@ -780,7 +780,7 @@ Intercepted DatabaseSyncLimits::LimitsSetter(
780780
}
781781

782782
DatabaseSyncLimits* limits;
783-
ASSIGN_OR_RETURN_UNWRAP(&limits, info.HolderV2(), Intercepted::kNo);
783+
ASSIGN_OR_RETURN_UNWRAP(&limits, info.Holder(), Intercepted::kNo);
784784

785785
Environment* env = limits->env();
786786
Isolate* isolate = env->isolate();
@@ -2945,9 +2945,9 @@ BaseObjectPtr<StatementSyncIterator> StatementExecutionHelper::Iterate(
29452945
}
29462946

29472947
if (iter->object()
2948-
->GetPrototypeV2()
2948+
->GetPrototype()
29492949
.As<Object>()
2950-
->SetPrototypeV2(context, js_iterator_prototype)
2950+
->SetPrototype(context, js_iterator_prototype)
29512951
.IsNothing()) {
29522952
return BaseObjectPtr<StatementSyncIterator>();
29532953
}

0 commit comments

Comments
 (0)