From e1265cefa1e67d0bcb5f78a479ce6ee8668677de Mon Sep 17 00:00:00 2001 From: Andreas Haas Date: Fri, 13 Feb 2026 11:05:17 +0100 Subject: [PATCH] Add type tags to uses of v8::External The variants without type tags are going to be removed. Bug: 436799229 --- test/addons/async-resource/binding.cc | 46 +++++++++++++++------------ 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/test/addons/async-resource/binding.cc b/test/addons/async-resource/binding.cc index 6fd9b37cbeda40..1808b56905c5d7 100644 --- a/test/addons/async-resource/binding.cc +++ b/test/addons/async-resource/binding.cc @@ -1,8 +1,9 @@ -#include "node.h" - #include + #include +#include "node.h" + namespace { using node::AsyncResource; @@ -23,9 +24,7 @@ class CustomAsyncResource : public AsyncResource { public: CustomAsyncResource(Isolate* isolate, Local resource) : AsyncResource(isolate, resource, "CustomAsyncResource") {} - ~CustomAsyncResource() { - custom_async_resource_destructor_calls++; - } + ~CustomAsyncResource() { custom_async_resource_destructor_calls++; } }; void CreateAsyncResource(const FunctionCallbackInfo& args) { @@ -39,26 +38,27 @@ void CreateAsyncResource(const FunctionCallbackInfo& args) { r = new AsyncResource(isolate, args[0].As(), "foobär"); } - args.GetReturnValue().Set( - External::New(isolate, static_cast(r))); + args.GetReturnValue().Set(External::New(isolate, static_cast(r), + v8::kExternalPointerTypeTagDefault)); } void DestroyAsyncResource(const FunctionCallbackInfo& args) { assert(args[0]->IsExternal()); - auto r = static_cast(args[0].As()->Value()); + auto r = static_cast( + args[0].As()->Value(v8::kExternalPointerTypeTagDefault)); delete r; } void CallViaFunction(const FunctionCallbackInfo& args) { Isolate* isolate = args.GetIsolate(); assert(args[0]->IsExternal()); - auto r = static_cast(args[0].As()->Value()); + auto r = static_cast( + args[0].As()->Value(v8::kExternalPointerTypeTagDefault)); - Local name = - String::NewFromUtf8(isolate, "methöd").ToLocalChecked(); - Local fn = - r->get_resource()->Get(isolate->GetCurrentContext(), name) - .ToLocalChecked(); + Local name = String::NewFromUtf8(isolate, "methöd").ToLocalChecked(); + Local fn = r->get_resource() + ->Get(isolate->GetCurrentContext(), name) + .ToLocalChecked(); assert(fn->IsFunction()); Local arg = Integer::New(isolate, 42); @@ -69,10 +69,10 @@ void CallViaFunction(const FunctionCallbackInfo& args) { void CallViaString(const FunctionCallbackInfo& args) { Isolate* isolate = args.GetIsolate(); assert(args[0]->IsExternal()); - auto r = static_cast(args[0].As()->Value()); + auto r = static_cast( + args[0].As()->Value(v8::kExternalPointerTypeTagDefault)); - Local name = - String::NewFromUtf8(isolate, "methöd").ToLocalChecked(); + Local name = String::NewFromUtf8(isolate, "methöd").ToLocalChecked(); Local arg = Integer::New(isolate, 42); MaybeLocal ret = r->MakeCallback(name, 1, &arg); @@ -82,7 +82,8 @@ void CallViaString(const FunctionCallbackInfo& args) { void CallViaUtf8Name(const FunctionCallbackInfo& args) { Isolate* isolate = args.GetIsolate(); assert(args[0]->IsExternal()); - auto r = static_cast(args[0].As()->Value()); + auto r = static_cast( + args[0].As()->Value(v8::kExternalPointerTypeTagDefault)); Local arg = Integer::New(isolate, 42); MaybeLocal ret = r->MakeCallback("methöd", 1, &arg); @@ -91,19 +92,22 @@ void CallViaUtf8Name(const FunctionCallbackInfo& args) { void GetAsyncId(const FunctionCallbackInfo& args) { assert(args[0]->IsExternal()); - auto r = static_cast(args[0].As()->Value()); + auto r = static_cast( + args[0].As()->Value(v8::kExternalPointerTypeTagDefault)); args.GetReturnValue().Set(r->get_async_id()); } void GetTriggerAsyncId(const FunctionCallbackInfo& args) { assert(args[0]->IsExternal()); - auto r = static_cast(args[0].As()->Value()); + auto r = static_cast( + args[0].As()->Value(v8::kExternalPointerTypeTagDefault)); args.GetReturnValue().Set(r->get_trigger_async_id()); } void GetResource(const FunctionCallbackInfo& args) { assert(args[0]->IsExternal()); - auto r = static_cast(args[0].As()->Value()); + auto r = static_cast( + args[0].As()->Value(v8::kExternalPointerTypeTagDefault)); args.GetReturnValue().Set(r->get_resource()); }