From 16112d380978811a372eeb54e7c357e687c45266 Mon Sep 17 00:00:00 2001 From: Gabriel Schulhof Date: Tue, 4 Aug 2020 11:52:39 -0700 Subject: [PATCH] remove wrapper_ from napi_wrap examples Signed-off-by: Gabriel Schulhof Fixes: https://github.com/nodejs/node-addon-examples/issues/140 --- 6_object_wrap/napi/myobject.cc | 8 ++------ 6_object_wrap/napi/myobject.h | 1 - 7_factory_wrap/napi/myobject.cc | 8 ++------ 7_factory_wrap/napi/myobject.h | 1 - 8_passing_wrapped/napi/myobject.cc | 8 ++------ 8_passing_wrapped/napi/myobject.h | 1 - 6 files changed, 6 insertions(+), 21 deletions(-) diff --git a/6_object_wrap/napi/myobject.cc b/6_object_wrap/napi/myobject.cc index 4566940c..faf60531 100644 --- a/6_object_wrap/napi/myobject.cc +++ b/6_object_wrap/napi/myobject.cc @@ -2,11 +2,7 @@ #include MyObject::MyObject(double value) - : value_(value), env_(nullptr), wrapper_(nullptr) {} - -MyObject::~MyObject() { - napi_delete_reference(env_, wrapper_); -} + : value_(value), env_(nullptr) {} void MyObject::Destructor(napi_env env, void* nativeObject, @@ -105,7 +101,7 @@ napi_value MyObject::New(napi_env env, napi_callback_info info) { reinterpret_cast(obj), MyObject::Destructor, nullptr, // finalize_hint - &obj->wrapper_); + nullptr); assert(status == napi_ok); return jsthis; diff --git a/6_object_wrap/napi/myobject.h b/6_object_wrap/napi/myobject.h index 2e057733..18b84573 100644 --- a/6_object_wrap/napi/myobject.h +++ b/6_object_wrap/napi/myobject.h @@ -21,7 +21,6 @@ class MyObject { double value_; napi_env env_; - napi_ref wrapper_; }; #endif // TEST_ADDONS_NAPI_6_OBJECT_WRAP_MYOBJECT_H_ diff --git a/7_factory_wrap/napi/myobject.cc b/7_factory_wrap/napi/myobject.cc index 7684a676..e1ea0048 100644 --- a/7_factory_wrap/napi/myobject.cc +++ b/7_factory_wrap/napi/myobject.cc @@ -1,11 +1,7 @@ #include "myobject.h" #include -MyObject::MyObject() : env_(nullptr), wrapper_(nullptr) {} - -MyObject::~MyObject() { - napi_delete_reference(env_, wrapper_); -} +MyObject::MyObject() : env_(nullptr) {} void MyObject::Destructor(napi_env env, void* nativeObject, @@ -81,7 +77,7 @@ napi_value MyObject::New(napi_env env, napi_callback_info info) { reinterpret_cast(obj), MyObject::Destructor, nullptr, /* finalize_hint */ - &obj->wrapper_); + nullptr); assert(status == napi_ok); return jsthis; diff --git a/7_factory_wrap/napi/myobject.h b/7_factory_wrap/napi/myobject.h index b14e3ad4..2139a0f4 100644 --- a/7_factory_wrap/napi/myobject.h +++ b/7_factory_wrap/napi/myobject.h @@ -20,7 +20,6 @@ class MyObject { static napi_value PlusOne(napi_env env, napi_callback_info info); double counter_; napi_env env_; - napi_ref wrapper_; }; #endif // TEST_ADDONS_NAPI_7_FACTORY_WRAP_MYOBJECT_H_ diff --git a/8_passing_wrapped/napi/myobject.cc b/8_passing_wrapped/napi/myobject.cc index 7bc84bc4..67c7096f 100644 --- a/8_passing_wrapped/napi/myobject.cc +++ b/8_passing_wrapped/napi/myobject.cc @@ -1,11 +1,7 @@ #include "myobject.h" #include -MyObject::MyObject() : env_(nullptr), wrapper_(nullptr) {} - -MyObject::~MyObject() { - napi_delete_reference(env_, wrapper_); -} +MyObject::MyObject() : env_(nullptr) {} void MyObject::Destructor(napi_env env, void* nativeObject, @@ -75,7 +71,7 @@ napi_value MyObject::New(napi_env env, napi_callback_info info) { reinterpret_cast(obj), MyObject::Destructor, nullptr, // finalize_hint - &obj->wrapper_); + nullptr); assert(status == napi_ok); return jsthis; diff --git a/8_passing_wrapped/napi/myobject.h b/8_passing_wrapped/napi/myobject.h index 1437a3cf..87508117 100644 --- a/8_passing_wrapped/napi/myobject.h +++ b/8_passing_wrapped/napi/myobject.h @@ -20,7 +20,6 @@ class MyObject { static napi_value New(napi_env env, napi_callback_info info); double val_; napi_env env_; - napi_ref wrapper_; }; #endif // TEST_ADDONS_NAPI_8_PASSING_WRAPPED_MYOBJECT_H_