diff --git a/src/node.h b/src/node.h index 12ec36db371..5ac0cf545d2 100644 --- a/src/node.h +++ b/src/node.h @@ -1563,6 +1563,9 @@ void RegisterSignalHandler(int signal, bool reset_handler = false); #endif // _WIN32 +// This is kept as a compatibility layer for addons to wrap cppgc-managed objects +// on Node.js versions without v8::Object::Wrap(). Addons created to work with +// only Node.js versions with v8::Object::Wrap() should use that instead. NODE_DEPRECATED("Use v8::Object::Wrap()", NODE_EXTERN void SetCppgcReference(v8::Isolate* isolate, v8::Local object, diff --git a/test/addons/cppgc-object/binding.cc b/test/addons/cppgc-object/binding.cc index 618b051dd30..7fc16a87b84 100644 --- a/test/addons/cppgc-object/binding.cc +++ b/test/addons/cppgc-object/binding.cc @@ -21,8 +21,7 @@ class CppGCed : public cppgc::GarbageCollected { assert(heap != nullptr); CppGCed* gc_object = cppgc::MakeGarbageCollected(heap->GetAllocationHandle()); - v8::Object::Wrap( - isolate, js_object, gc_object); + node::SetCppgcReference(isolate, js_object, gc_object); args.GetReturnValue().Set(js_object); } diff --git a/test/cctest/test_cppgc.cc b/test/cctest/test_cppgc.cc index ad3b5406d18..a8bbd7db0f7 100644 --- a/test/cctest/test_cppgc.cc +++ b/test/cctest/test_cppgc.cc @@ -23,8 +23,7 @@ class CppGCed : public cppgc::GarbageCollected { CHECK_NOT_NULL(heap); CppGCed* gc_object = cppgc::MakeGarbageCollected(heap->GetAllocationHandle()); - v8::Object::Wrap( - isolate, js_object, gc_object); + node::SetCppgcReference(isolate, js_object, gc_object); kConstructCount++; args.GetReturnValue().Set(js_object); }