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: https://github.com/nodejs/node/pull/67070
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Richard Lau <richard.lau@ibm.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
This commit is contained in:
Michaël ZassoandJoyee Cheung authored and Chengzhong Wu committed 2026-11-19 10:34:49 -05:00
1 parent 5cefeb1dc8
commit 697c575af4
9 files changed
+21 -18

No files matched your search

+2 -2
View File
@@ -214,7 +214,7 @@ class AddonData {
static void Method(const v8::FunctionCallbackInfo<v8::Value>& info) {
// Retrieve the per-addon-instance data.
AddonData* data =
reinterpret_cast<AddonData*>(info.Data().As<External>()->Value());
reinterpret_cast<AddonData*>(info.DataV2().As<External>()->Value());
data->call_count++;
info.GetReturnValue().Set((double)data->call_count);
}
@@ -982,7 +982,7 @@ void MyObject::New(const FunctionCallbackInfo<Value>& args) {
const int argc = 1;
Local<Value> argv[argc] = { args[0] };
Local<Function> cons =
args.Data().As<Object>()->GetInternalField(0)
args.DataV2().As<Value>().As<Object>()->GetInternalField(0)
.As<Value>().As<Function>();
Local<Object> result =
cons->NewInstance(context, argc, argv).ToLocalChecked();
+3 -1
View File
@@ -491,7 +491,9 @@ class FunctionCallbackWrapper {
explicit FunctionCallbackWrapper(
const v8::FunctionCallbackInfo<v8::Value>& cbinfo)
: cbinfo_(cbinfo),
bundle_(CallbackBundle::FromCallbackData(cbinfo.Data())) {}
bundle_(
CallbackBundle::FromCallbackData(cbinfo.DataV2().As<v8::Value>())) {
}
void InvokeCallback() {
napi_callback_info cbinfo_wrapper =
+2 -2
View File
@@ -1259,7 +1259,7 @@ static void ImportMetaResolveLazyGetter(
// This should be createImportMetaResolve(). The loader argument is already
// bound at initialization time.
Local<Value> args[] = {info.Data()};
Local<Value> args[] = {info.DataV2().As<Value>()};
Local<Value> ret;
if (!initializer
->Call(context, Undefined(realm->isolate()), arraysize(args), args)
@@ -1290,7 +1290,7 @@ static void PathHelpersLazyGetter(Local<v8::Name> name,
}
Environment* env = Environment::GetCurrent(context);
node::Utf8Value url(isolate, info.Data());
node::Utf8Value url(isolate, info.DataV2().As<Value>());
auto file_url = ada::parse(url.ToStringView());
CHECK(file_url);
auto file_path = url::FileURLToPath(env, *file_url);
+2 -2
View File
@@ -664,7 +664,7 @@ void DynamicLibrary::Close(const FunctionCallbackInfo<Value>& args) {
void DynamicLibrary::InvokeFunction(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
FFIFunctionInfo* info = Unwrap<FFIFunctionInfo>(args.Data());
FFIFunctionInfo* info = Unwrap<FFIFunctionInfo>(args.DataV2().As<Value>());
CHECK_NOT_NULL(info);
FFIFunction* fn = info->fn.get();
@@ -736,7 +736,7 @@ void DynamicLibrary::InvokeFunction(const FunctionCallbackInfo<Value>& args) {
void DynamicLibrary::InvokeFunctionSB(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
FFIFunctionInfo* info = Unwrap<FFIFunctionInfo>(args.Data());
FFIFunctionInfo* info = Unwrap<FFIFunctionInfo>(args.DataV2().As<Value>());
CHECK_NOT_NULL(info);
FFIFunction* fn = info->fn.get();
+4 -4
View File
@@ -130,7 +130,7 @@ static void OnLockCallbackFulfilled(const FunctionCallbackInfo<Value>& info) {
Environment* env = Environment::GetCurrent(info);
BaseObjectPtr<LockHolder> lock_holder{
BaseObject::FromJSObject<LockHolder>(info.Data())};
BaseObject::FromJSObject<LockHolder>(info.DataV2().As<Value>())};
std::shared_ptr<Lock> lock = lock_holder->lock();
// Release the lock and continue processing the queue.
@@ -144,7 +144,7 @@ static void OnLockCallbackRejected(const FunctionCallbackInfo<Value>& info) {
Environment* env = Environment::GetCurrent(info);
BaseObjectPtr<LockHolder> lock_holder{
BaseObject::FromJSObject<LockHolder>(info.Data())};
BaseObject::FromJSObject<LockHolder>(info.DataV2().As<Value>())};
std::shared_ptr<Lock> lock = lock_holder->lock();
LockManager::GetCurrent()->ReleaseLockAndProcessQueue(
@@ -154,13 +154,13 @@ static void OnLockCallbackRejected(const FunctionCallbackInfo<Value>& info) {
// Called when the promise returned from the user's callback resolves
static void OnIfAvailableFulfill(const FunctionCallbackInfo<Value>& info) {
HandleScope handle_scope(info.GetIsolate());
USE(info.Data().As<Promise::Resolver>()->Resolve(
USE(info.DataV2().As<Value>().As<Promise::Resolver>()->Resolve(
info.GetIsolate()->GetCurrentContext(), info[0]));
}
// Called when the promise returned from the user's callback rejects
static void OnIfAvailableReject(const FunctionCallbackInfo<Value>& info) {
USE(info.Data().As<Promise::Resolver>()->Reject(
USE(info.DataV2().As<Value>().As<Promise::Resolver>()->Reject(
info.GetIsolate()->GetCurrentContext(), info[0]));
}
+1 -1
View File
@@ -374,7 +374,7 @@ static void DefineLazyPropertiesGetter(
}
Realm* realm = Realm::GetCurrent(context);
Local<Value> arg = info.Data();
Local<Value> arg = info.DataV2().As<Value>();
Local<Value> require_result;
if (!realm->builtin_module_require()
->Call(context, Null(isolate), 1, &arg)
+1 -1
View File
@@ -157,7 +157,7 @@ void StartStreamingCompilation(const FunctionCallbackInfo<Value>& info) {
// Create the wrapper object.
std::shared_ptr<WasmStreaming> streaming =
WasmStreaming::Unpack(info.GetIsolate(), info.Data());
WasmStreaming::Unpack(info.GetIsolate(), info.DataV2());
Environment* env = Environment::GetCurrent(info);
Local<Object> obj;
if (!WasmStreamingObject::Create(env, streaming).ToLocal(&obj)) {
+2 -1
View File
@@ -72,7 +72,8 @@ void MyObject::New(const FunctionCallbackInfo<Value>& args) {
// Invoked as plain function `MyObject(...)`, turn into construct call.
const int argc = 1;
Local<Value> argv[argc] = {args[0]};
Local<Function> cons = args.Data()
Local<Function> cons = args.DataV2()
.As<Value>()
.As<Object>()
->GetInternalField(0)
.As<Value>()
+4 -4
View File
@@ -694,8 +694,8 @@ TEST_F(EnvironmentTest, RunAndClearNativeImmediatesSkipsEmptyScope) {
v8::Function::New(
context,
[](const v8::FunctionCallbackInfo<v8::Value>& info) {
IntVec* callback_calls =
static_cast<IntVec*>(info.Data().As<v8::External>()->Value(
IntVec* callback_calls = static_cast<IntVec*>(
info.DataV2().As<v8::Value>().As<v8::External>()->Value(
v8::kExternalPointerTypeTagDefault));
callback_calls->push_back(info[0].As<v8::Int32>()->Value());
},
@@ -1081,8 +1081,8 @@ TEST_F(EnvironmentTest, NestedMicrotaskQueue) {
v8::Function::New(
context,
[](const v8::FunctionCallbackInfo<v8::Value>& info) {
IntVec* callback_calls =
static_cast<IntVec*>(info.Data().As<v8::External>()->Value(
IntVec* callback_calls = static_cast<IntVec*>(
info.DataV2().As<v8::Value>().As<v8::External>()->Value(
v8::kExternalPointerTypeTagDefault));
callback_calls->push_back(info[0].As<v8::Int32>()->Value());
},