-
Notifications
You must be signed in to change notification settings - Fork 465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix misleading documentation concerning finalize callbacks #384
Conversation
destroyed. It must implement `operator()`, accept a `void*` (which is the | ||
`externalData` pointer), and return `void`. | ||
destroyed. It must implement `operator()` with parameters `(Napi::Env, void*)`, | ||
and return `void`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we missed a couple of parameters I think the signature is
static void FinalizeCallback(napi_env env, void* data, void* hint);
@computerquip any chance you can update to include the last parameter as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mhdawson:
From N-API napi_finalizer
function pointer type always has 3 parameter, but in node-addon-api
it's different.
- for
ArrayBuffer::New(..., finalizeCallback, finalizeHint)
we have Finalizer(Env, void* data, Hint* hint)
, likenapi_finalizer
- for
ArrayBuffer::New(..., finalizeCallback)
we have Finalizer(Env, void* data)
template <typename T, typename Finalizer, typename Hint = void>
struct FinalizeData {
static inline
void Wrapper(napi_env env, void* data, void* finalizeHint) {
FinalizeData* finalizeData = static_cast<FinalizeData*>(finalizeHint);
finalizeData->callback(Env(env), static_cast<T*>(data));
delete finalizeData;
}
static inline
void WrapperWithHint(napi_env env, void* data, void* finalizeHint) {
FinalizeData* finalizeData = static_cast<FinalizeData*>(finalizeHint);
finalizeData->callback(Env(env), static_cast<T*>(data), finalizeData->hint);
delete finalizeData;
}
Finalizer callback;
Hint* hint;
};
- External::New - ArrayBuffer::New - Buffer::New Ref: nodejs#384 Fixes: nodejs#383
Closing since this appears to be adopted in another pull request: #414 |
- External::New - ArrayBuffer::New - Buffer::New PR-URL: nodejs/node-addon-api#414 Fixes: nodejs/node-addon-api#383 Refs: nodejs/node-addon-api#384 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
- External::New - ArrayBuffer::New - Buffer::New PR-URL: nodejs/node-addon-api#414 Fixes: nodejs/node-addon-api#383 Refs: nodejs/node-addon-api#384 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
- External::New - ArrayBuffer::New - Buffer::New PR-URL: nodejs/node-addon-api#414 Fixes: nodejs/node-addon-api#383 Refs: nodejs/node-addon-api#384 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
- External::New - ArrayBuffer::New - Buffer::New PR-URL: nodejs/node-addon-api#414 Fixes: nodejs/node-addon-api#383 Refs: nodejs/node-addon-api#384 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Documentation fixes as discussed in #383