Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/js_native_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ napi_create_reference(napi_env env,

// Deletes a reference. The referenced value is released, and may
// be GC'd unless there are other references to it.
NAPI_EXTERN napi_status NAPI_CDECL napi_delete_reference(napi_env env,
NAPI_EXTERN napi_status NAPI_CDECL napi_delete_reference(node_api_basic_env env,
napi_ref ref);

// Increments the reference count, optionally returning the resulting count.
Expand Down
3 changes: 2 additions & 1 deletion src/js_native_api_v8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2773,7 +2773,8 @@ napi_status NAPI_CDECL napi_create_reference(napi_env env,
// there are other references to it.
// For a napi_reference returned from `napi_wrap`, this must be called in the
// finalizer.
napi_status NAPI_CDECL napi_delete_reference(napi_env env, napi_ref ref) {
napi_status NAPI_CDECL napi_delete_reference(node_api_basic_env env,
napi_ref ref) {
// Omit NAPI_PREAMBLE and GET_RETURN_STATUS because V8 calls here cannot throw
// JS exceptions.
CHECK_ENV(env);
Expand Down
2 changes: 1 addition & 1 deletion test/js-native-api/6_object_wrap/myobject.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ MyObject::MyObject(double value)
: value_(value), env_(nullptr), wrapper_(nullptr) {}

MyObject::~MyObject() {
napi_delete_reference(env_, wrapper_);
napi_delete_reference(static_cast<node_api_basic_env>(env_), wrapper_);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind removing this change? As mentioned earlier, this is not necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes done

}

void MyObject::Destructor(node_api_basic_env env,
Expand Down
4 changes: 3 additions & 1 deletion test/js-native-api/7_factory_wrap/myobject.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ static int finalize_count = 0;

MyObject::MyObject() : env_(nullptr), wrapper_(nullptr) {}

MyObject::~MyObject() { napi_delete_reference(env_, wrapper_); }
MyObject::~MyObject() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind removing this unnecessary formatting?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

napi_delete_reference(env_, wrapper_);
}

void MyObject::Destructor(napi_env env,
void* nativeObject,
Expand Down