From 697c575af40c625fda9220ca8dc575a792b93621 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Fri, 30 Oct 2026 11:27:01 +0100 Subject: [PATCH] src,test: use non-deprecated `v8::FunctionCallbackInfo::DataV2` API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Joyee Cheung Signed-Off-By: Michaƫl Zasso Signed-off-by: Chengzhong Wu PR-URL: https://github.com/nodejs/node/pull/67070 Reviewed-By: Yagiz Nizipli Reviewed-By: Richard Lau Reviewed-By: Joyee Cheung --- doc/api/addons.md | 4 ++-- src/js_native_api_v8.cc | 4 +++- src/module_wrap.cc | 4 ++-- src/node_ffi.cc | 4 ++-- src/node_locks.cc | 8 ++++---- src/node_util.cc | 2 +- src/node_wasm_web_api.cc | 2 +- test/addons/worker-addon-exit/binding.cc | 3 ++- test/cctest/test_environment.cc | 8 ++++---- 9 files changed, 21 insertions(+), 18 deletions(-) diff --git a/doc/api/addons.md b/doc/api/addons.md index 80d23a4cf48..315bcda1642 100644 --- a/doc/api/addons.md +++ b/doc/api/addons.md @@ -214,7 +214,7 @@ class AddonData { static void Method(const v8::FunctionCallbackInfo& info) { // Retrieve the per-addon-instance data. AddonData* data = - reinterpret_cast(info.Data().As()->Value()); + reinterpret_cast(info.DataV2().As()->Value()); data->call_count++; info.GetReturnValue().Set((double)data->call_count); } @@ -982,7 +982,7 @@ void MyObject::New(const FunctionCallbackInfo& args) { const int argc = 1; Local argv[argc] = { args[0] }; Local cons = - args.Data().As()->GetInternalField(0) + args.DataV2().As().As()->GetInternalField(0) .As().As(); Local result = cons->NewInstance(context, argc, argv).ToLocalChecked(); diff --git a/src/js_native_api_v8.cc b/src/js_native_api_v8.cc index ba1ab6f1851..863b0f9e3ae 100644 --- a/src/js_native_api_v8.cc +++ b/src/js_native_api_v8.cc @@ -491,7 +491,9 @@ class FunctionCallbackWrapper { explicit FunctionCallbackWrapper( const v8::FunctionCallbackInfo& cbinfo) : cbinfo_(cbinfo), - bundle_(CallbackBundle::FromCallbackData(cbinfo.Data())) {} + bundle_( + CallbackBundle::FromCallbackData(cbinfo.DataV2().As())) { + } void InvokeCallback() { napi_callback_info cbinfo_wrapper = diff --git a/src/module_wrap.cc b/src/module_wrap.cc index 444d3133753..be3e6f668c0 100644 --- a/src/module_wrap.cc +++ b/src/module_wrap.cc @@ -1259,7 +1259,7 @@ static void ImportMetaResolveLazyGetter( // This should be createImportMetaResolve(). The loader argument is already // bound at initialization time. - Local args[] = {info.Data()}; + Local args[] = {info.DataV2().As()}; Local ret; if (!initializer ->Call(context, Undefined(realm->isolate()), arraysize(args), args) @@ -1290,7 +1290,7 @@ static void PathHelpersLazyGetter(Local name, } Environment* env = Environment::GetCurrent(context); - node::Utf8Value url(isolate, info.Data()); + node::Utf8Value url(isolate, info.DataV2().As()); auto file_url = ada::parse(url.ToStringView()); CHECK(file_url); auto file_path = url::FileURLToPath(env, *file_url); diff --git a/src/node_ffi.cc b/src/node_ffi.cc index b8127587d4e..9b0703b84e9 100644 --- a/src/node_ffi.cc +++ b/src/node_ffi.cc @@ -664,7 +664,7 @@ void DynamicLibrary::Close(const FunctionCallbackInfo& args) { void DynamicLibrary::InvokeFunction(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); - FFIFunctionInfo* info = Unwrap(args.Data()); + FFIFunctionInfo* info = Unwrap(args.DataV2().As()); CHECK_NOT_NULL(info); FFIFunction* fn = info->fn.get(); @@ -736,7 +736,7 @@ void DynamicLibrary::InvokeFunction(const FunctionCallbackInfo& args) { void DynamicLibrary::InvokeFunctionSB(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); - FFIFunctionInfo* info = Unwrap(args.Data()); + FFIFunctionInfo* info = Unwrap(args.DataV2().As()); CHECK_NOT_NULL(info); FFIFunction* fn = info->fn.get(); diff --git a/src/node_locks.cc b/src/node_locks.cc index 4fca3a7df94..c58efbf5561 100644 --- a/src/node_locks.cc +++ b/src/node_locks.cc @@ -130,7 +130,7 @@ static void OnLockCallbackFulfilled(const FunctionCallbackInfo& info) { Environment* env = Environment::GetCurrent(info); BaseObjectPtr lock_holder{ - BaseObject::FromJSObject(info.Data())}; + BaseObject::FromJSObject(info.DataV2().As())}; std::shared_ptr lock = lock_holder->lock(); // Release the lock and continue processing the queue. @@ -144,7 +144,7 @@ static void OnLockCallbackRejected(const FunctionCallbackInfo& info) { Environment* env = Environment::GetCurrent(info); BaseObjectPtr lock_holder{ - BaseObject::FromJSObject(info.Data())}; + BaseObject::FromJSObject(info.DataV2().As())}; std::shared_ptr lock = lock_holder->lock(); LockManager::GetCurrent()->ReleaseLockAndProcessQueue( @@ -154,13 +154,13 @@ static void OnLockCallbackRejected(const FunctionCallbackInfo& info) { // Called when the promise returned from the user's callback resolves static void OnIfAvailableFulfill(const FunctionCallbackInfo& info) { HandleScope handle_scope(info.GetIsolate()); - USE(info.Data().As()->Resolve( + USE(info.DataV2().As().As()->Resolve( info.GetIsolate()->GetCurrentContext(), info[0])); } // Called when the promise returned from the user's callback rejects static void OnIfAvailableReject(const FunctionCallbackInfo& info) { - USE(info.Data().As()->Reject( + USE(info.DataV2().As().As()->Reject( info.GetIsolate()->GetCurrentContext(), info[0])); } diff --git a/src/node_util.cc b/src/node_util.cc index e19ba77e264..a8f4188b4db 100644 --- a/src/node_util.cc +++ b/src/node_util.cc @@ -374,7 +374,7 @@ static void DefineLazyPropertiesGetter( } Realm* realm = Realm::GetCurrent(context); - Local arg = info.Data(); + Local arg = info.DataV2().As(); Local require_result; if (!realm->builtin_module_require() ->Call(context, Null(isolate), 1, &arg) diff --git a/src/node_wasm_web_api.cc b/src/node_wasm_web_api.cc index a49cab7fb62..d977793eb13 100644 --- a/src/node_wasm_web_api.cc +++ b/src/node_wasm_web_api.cc @@ -157,7 +157,7 @@ void StartStreamingCompilation(const FunctionCallbackInfo& info) { // Create the wrapper object. std::shared_ptr streaming = - WasmStreaming::Unpack(info.GetIsolate(), info.Data()); + WasmStreaming::Unpack(info.GetIsolate(), info.DataV2()); Environment* env = Environment::GetCurrent(info); Local obj; if (!WasmStreamingObject::Create(env, streaming).ToLocal(&obj)) { diff --git a/test/addons/worker-addon-exit/binding.cc b/test/addons/worker-addon-exit/binding.cc index 312534fa4c7..33ab053c234 100644 --- a/test/addons/worker-addon-exit/binding.cc +++ b/test/addons/worker-addon-exit/binding.cc @@ -72,7 +72,8 @@ void MyObject::New(const FunctionCallbackInfo& args) { // Invoked as plain function `MyObject(...)`, turn into construct call. const int argc = 1; Local argv[argc] = {args[0]}; - Local cons = args.Data() + Local cons = args.DataV2() + .As() .As() ->GetInternalField(0) .As() diff --git a/test/cctest/test_environment.cc b/test/cctest/test_environment.cc index 1f6d3012e25..cec49dac916 100644 --- a/test/cctest/test_environment.cc +++ b/test/cctest/test_environment.cc @@ -694,8 +694,8 @@ TEST_F(EnvironmentTest, RunAndClearNativeImmediatesSkipsEmptyScope) { v8::Function::New( context, [](const v8::FunctionCallbackInfo& info) { - IntVec* callback_calls = - static_cast(info.Data().As()->Value( + IntVec* callback_calls = static_cast( + info.DataV2().As().As()->Value( v8::kExternalPointerTypeTagDefault)); callback_calls->push_back(info[0].As()->Value()); }, @@ -1081,8 +1081,8 @@ TEST_F(EnvironmentTest, NestedMicrotaskQueue) { v8::Function::New( context, [](const v8::FunctionCallbackInfo& info) { - IntVec* callback_calls = - static_cast(info.Data().As()->Value( + IntVec* callback_calls = static_cast( + info.DataV2().As().As()->Value( v8::kExternalPointerTypeTagDefault)); callback_calls->push_back(info[0].As()->Value()); },