Skip to content

Commit 697c575

Browse files
targosjoyeecheung
authored andcommitted
src,test: use non-deprecated v8::FunctionCallbackInfo::DataV2 API
Co-Authored-By: Joyee Cheung <joyeec9h3@gmail.com> Signed-Off-By: Michaël Zasso <targos@protonmail.com> Signed-off-by: Chengzhong Wu <cwu631@bloomberg.net> PR-URL: #67070 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Richard Lau <richard.lau@ibm.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
1 parent 5cefeb1 commit 697c575

9 files changed

Lines changed: 21 additions & 18 deletions

File tree

‎doc/api/addons.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ class AddonData {
214214
static void Method(const v8::FunctionCallbackInfo<v8::Value>& info) {
215215
// Retrieve the per-addon-instance data.
216216
AddonData* data =
217-
reinterpret_cast<AddonData*>(info.Data().As<External>()->Value());
217+
reinterpret_cast<AddonData*>(info.DataV2().As<External>()->Value());
218218
data->call_count++;
219219
info.GetReturnValue().Set((double)data->call_count);
220220
}
@@ -982,7 +982,7 @@ void MyObject::New(const FunctionCallbackInfo<Value>& args) {
982982
const int argc = 1;
983983
Local<Value> argv[argc] = { args[0] };
984984
Local<Function> cons =
985-
args.Data().As<Object>()->GetInternalField(0)
985+
args.DataV2().As<Value>().As<Object>()->GetInternalField(0)
986986
.As<Value>().As<Function>();
987987
Local<Object> result =
988988
cons->NewInstance(context, argc, argv).ToLocalChecked();

‎src/js_native_api_v8.cc‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,9 @@ class FunctionCallbackWrapper {
491491
explicit FunctionCallbackWrapper(
492492
const v8::FunctionCallbackInfo<v8::Value>& cbinfo)
493493
: cbinfo_(cbinfo),
494-
bundle_(CallbackBundle::FromCallbackData(cbinfo.Data())) {}
494+
bundle_(
495+
CallbackBundle::FromCallbackData(cbinfo.DataV2().As<v8::Value>())) {
496+
}
495497

496498
void InvokeCallback() {
497499
napi_callback_info cbinfo_wrapper =

‎src/module_wrap.cc‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,7 @@ static void ImportMetaResolveLazyGetter(
12591259

12601260
// This should be createImportMetaResolve(). The loader argument is already
12611261
// bound at initialization time.
1262-
Local<Value> args[] = {info.Data()};
1262+
Local<Value> args[] = {info.DataV2().As<Value>()};
12631263
Local<Value> ret;
12641264
if (!initializer
12651265
->Call(context, Undefined(realm->isolate()), arraysize(args), args)
@@ -1290,7 +1290,7 @@ static void PathHelpersLazyGetter(Local<v8::Name> name,
12901290
}
12911291
Environment* env = Environment::GetCurrent(context);
12921292

1293-
node::Utf8Value url(isolate, info.Data());
1293+
node::Utf8Value url(isolate, info.DataV2().As<Value>());
12941294
auto file_url = ada::parse(url.ToStringView());
12951295
CHECK(file_url);
12961296
auto file_path = url::FileURLToPath(env, *file_url);

‎src/node_ffi.cc‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ void DynamicLibrary::Close(const FunctionCallbackInfo<Value>& args) {
664664

665665
void DynamicLibrary::InvokeFunction(const FunctionCallbackInfo<Value>& args) {
666666
Environment* env = Environment::GetCurrent(args);
667-
FFIFunctionInfo* info = Unwrap<FFIFunctionInfo>(args.Data());
667+
FFIFunctionInfo* info = Unwrap<FFIFunctionInfo>(args.DataV2().As<Value>());
668668
CHECK_NOT_NULL(info);
669669
FFIFunction* fn = info->fn.get();
670670

@@ -736,7 +736,7 @@ void DynamicLibrary::InvokeFunction(const FunctionCallbackInfo<Value>& args) {
736736

737737
void DynamicLibrary::InvokeFunctionSB(const FunctionCallbackInfo<Value>& args) {
738738
Environment* env = Environment::GetCurrent(args);
739-
FFIFunctionInfo* info = Unwrap<FFIFunctionInfo>(args.Data());
739+
FFIFunctionInfo* info = Unwrap<FFIFunctionInfo>(args.DataV2().As<Value>());
740740
CHECK_NOT_NULL(info);
741741
FFIFunction* fn = info->fn.get();
742742

‎src/node_locks.cc‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ static void OnLockCallbackFulfilled(const FunctionCallbackInfo<Value>& info) {
130130
Environment* env = Environment::GetCurrent(info);
131131

132132
BaseObjectPtr<LockHolder> lock_holder{
133-
BaseObject::FromJSObject<LockHolder>(info.Data())};
133+
BaseObject::FromJSObject<LockHolder>(info.DataV2().As<Value>())};
134134
std::shared_ptr<Lock> lock = lock_holder->lock();
135135

136136
// Release the lock and continue processing the queue.
@@ -144,7 +144,7 @@ static void OnLockCallbackRejected(const FunctionCallbackInfo<Value>& info) {
144144
Environment* env = Environment::GetCurrent(info);
145145

146146
BaseObjectPtr<LockHolder> lock_holder{
147-
BaseObject::FromJSObject<LockHolder>(info.Data())};
147+
BaseObject::FromJSObject<LockHolder>(info.DataV2().As<Value>())};
148148
std::shared_ptr<Lock> lock = lock_holder->lock();
149149

150150
LockManager::GetCurrent()->ReleaseLockAndProcessQueue(
@@ -154,13 +154,13 @@ static void OnLockCallbackRejected(const FunctionCallbackInfo<Value>& info) {
154154
// Called when the promise returned from the user's callback resolves
155155
static void OnIfAvailableFulfill(const FunctionCallbackInfo<Value>& info) {
156156
HandleScope handle_scope(info.GetIsolate());
157-
USE(info.Data().As<Promise::Resolver>()->Resolve(
157+
USE(info.DataV2().As<Value>().As<Promise::Resolver>()->Resolve(
158158
info.GetIsolate()->GetCurrentContext(), info[0]));
159159
}
160160

161161
// Called when the promise returned from the user's callback rejects
162162
static void OnIfAvailableReject(const FunctionCallbackInfo<Value>& info) {
163-
USE(info.Data().As<Promise::Resolver>()->Reject(
163+
USE(info.DataV2().As<Value>().As<Promise::Resolver>()->Reject(
164164
info.GetIsolate()->GetCurrentContext(), info[0]));
165165
}
166166

‎src/node_util.cc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ static void DefineLazyPropertiesGetter(
374374
}
375375

376376
Realm* realm = Realm::GetCurrent(context);
377-
Local<Value> arg = info.Data();
377+
Local<Value> arg = info.DataV2().As<Value>();
378378
Local<Value> require_result;
379379
if (!realm->builtin_module_require()
380380
->Call(context, Null(isolate), 1, &arg)

‎src/node_wasm_web_api.cc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ void StartStreamingCompilation(const FunctionCallbackInfo<Value>& info) {
157157

158158
// Create the wrapper object.
159159
std::shared_ptr<WasmStreaming> streaming =
160-
WasmStreaming::Unpack(info.GetIsolate(), info.Data());
160+
WasmStreaming::Unpack(info.GetIsolate(), info.DataV2());
161161
Environment* env = Environment::GetCurrent(info);
162162
Local<Object> obj;
163163
if (!WasmStreamingObject::Create(env, streaming).ToLocal(&obj)) {

‎test/addons/worker-addon-exit/binding.cc‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ void MyObject::New(const FunctionCallbackInfo<Value>& args) {
7272
// Invoked as plain function `MyObject(...)`, turn into construct call.
7373
const int argc = 1;
7474
Local<Value> argv[argc] = {args[0]};
75-
Local<Function> cons = args.Data()
75+
Local<Function> cons = args.DataV2()
76+
.As<Value>()
7677
.As<Object>()
7778
->GetInternalField(0)
7879
.As<Value>()

‎test/cctest/test_environment.cc‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -694,8 +694,8 @@ TEST_F(EnvironmentTest, RunAndClearNativeImmediatesSkipsEmptyScope) {
694694
v8::Function::New(
695695
context,
696696
[](const v8::FunctionCallbackInfo<v8::Value>& info) {
697-
IntVec* callback_calls =
698-
static_cast<IntVec*>(info.Data().As<v8::External>()->Value(
697+
IntVec* callback_calls = static_cast<IntVec*>(
698+
info.DataV2().As<v8::Value>().As<v8::External>()->Value(
699699
v8::kExternalPointerTypeTagDefault));
700700
callback_calls->push_back(info[0].As<v8::Int32>()->Value());
701701
},
@@ -1081,8 +1081,8 @@ TEST_F(EnvironmentTest, NestedMicrotaskQueue) {
10811081
v8::Function::New(
10821082
context,
10831083
[](const v8::FunctionCallbackInfo<v8::Value>& info) {
1084-
IntVec* callback_calls =
1085-
static_cast<IntVec*>(info.Data().As<v8::External>()->Value(
1084+
IntVec* callback_calls = static_cast<IntVec*>(
1085+
info.DataV2().As<v8::Value>().As<v8::External>()->Value(
10861086
v8::kExternalPointerTypeTagDefault));
10871087
callback_calls->push_back(info[0].As<v8::Int32>()->Value());
10881088
},

0 commit comments

Comments
 (0)