-
-
Notifications
You must be signed in to change notification settings - Fork 499
doc: add inline comment hints on finalizer signatures #1738
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
Open
legendecas
wants to merge
1
commit into
nodejs:main
Choose a base branch
from
legendecas:finalizer
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -422,12 +422,16 @@ class BasicEnv { | |
| #endif // NAPI_VERSION > 8 | ||
|
|
||
| #ifdef NODE_API_EXPERIMENTAL_HAS_POST_FINALIZER | ||
| // FinalizerType must implement `void operator()(Env env)`. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should the Markdown documentation files also be updated to reflect the implementation signature for the callbacks? 🤔 |
||
| template <typename FinalizerType> | ||
| inline void PostFinalizer(FinalizerType finalizeCallback) const; | ||
|
|
||
| // FinalizerType must implement `void operator()(Env env, T* data)`. | ||
| template <typename FinalizerType, typename T> | ||
| inline void PostFinalizer(FinalizerType finalizeCallback, T* data) const; | ||
|
|
||
| // FinalizerType must implement `void operator()(Env env, T* data, | ||
| // Hint* hint)`. | ||
| template <typename FinalizerType, typename T, typename Hint> | ||
| inline void PostFinalizer(FinalizerType finalizeCallback, | ||
| T* data, | ||
|
|
@@ -1107,9 +1111,12 @@ class Object : public TypeTaggable { | |
| const Function& constructor ///< Constructor function | ||
| ) const; | ||
|
|
||
| // Finalizer must implement `void operator()(Env env, T* data)`. | ||
| template <typename Finalizer, typename T> | ||
| inline void AddFinalizer(Finalizer finalizeCallback, T* data) const; | ||
|
|
||
| // Finalizer must implement `void operator()(Env env, T* data, | ||
| // Hint* hint)`. | ||
| template <typename Finalizer, typename T, typename Hint> | ||
| inline void AddFinalizer(Finalizer finalizeCallback, | ||
| T* data, | ||
|
|
@@ -1157,7 +1164,8 @@ class External : public TypeTaggable { | |
| // Finalizer must implement `void operator()(Env env, T* data)`. | ||
| template <typename Finalizer> | ||
| static External New(napi_env env, T* data, Finalizer finalizeCallback); | ||
| // Finalizer must implement `void operator()(Env env, T* data, Hint* hint)`. | ||
| // Finalizer must implement `void operator()(Env env, T* data, | ||
| // Hint* hint)`. | ||
| template <typename Finalizer, typename Hint> | ||
| static External New(napi_env env, | ||
| T* data, | ||
|
|
@@ -1712,7 +1720,8 @@ class Buffer : public Uint8Array { | |
| T* data, | ||
| size_t length, | ||
| Finalizer finalizeCallback); | ||
| // Finalizer must implement `void operator()(Env env, T* data, Hint* hint)`. | ||
| // Finalizer must implement `void operator()(Env env, T* data, | ||
| // Hint* hint)`. | ||
| template <typename Finalizer, typename Hint> | ||
| static Buffer<T> New(napi_env env, | ||
| T* data, | ||
|
|
@@ -1728,7 +1737,8 @@ class Buffer : public Uint8Array { | |
| T* data, | ||
| size_t length, | ||
| Finalizer finalizeCallback); | ||
| // Finalizer must implement `void operator()(Env env, T* data, Hint* hint)`. | ||
| // Finalizer must implement `void operator()(Env env, T* data, | ||
| // Hint* hint)`. | ||
| template <typename Finalizer, typename Hint> | ||
| static Buffer<T> NewOrCopy(napi_env env, | ||
| T* data, | ||
|
|
@@ -2825,6 +2835,7 @@ class ThreadSafeFunction { | |
| ContextType* context); | ||
|
|
||
| // This API may only be called from the main thread. | ||
| // Finalizer must implement `void operator()(Env env)`. | ||
| template <typename ResourceString, typename Finalizer> | ||
| static ThreadSafeFunction New(napi_env env, | ||
| const Function& callback, | ||
|
|
@@ -2834,6 +2845,8 @@ class ThreadSafeFunction { | |
| Finalizer finalizeCallback); | ||
|
|
||
| // This API may only be called from the main thread. | ||
| // Finalizer must implement | ||
| // `void operator()(Env env, FinalizerDataType* data)`. | ||
| template <typename ResourceString, | ||
| typename Finalizer, | ||
| typename FinalizerDataType> | ||
|
|
@@ -2846,6 +2859,8 @@ class ThreadSafeFunction { | |
| FinalizerDataType* data); | ||
|
|
||
| // This API may only be called from the main thread. | ||
| // Finalizer must implement | ||
| // `void operator()(Env env, ContextType* context)`. | ||
| template <typename ResourceString, typename ContextType, typename Finalizer> | ||
| static ThreadSafeFunction New(napi_env env, | ||
| const Function& callback, | ||
|
|
@@ -2856,6 +2871,8 @@ class ThreadSafeFunction { | |
| Finalizer finalizeCallback); | ||
|
|
||
| // This API may only be called from the main thread. | ||
| // Finalizer must implement `void operator()(Env env, | ||
| // FinalizerDataType* data, ContextType* context)`. | ||
| template <typename ResourceString, | ||
| typename ContextType, | ||
| typename Finalizer, | ||
|
|
@@ -2889,6 +2906,7 @@ class ThreadSafeFunction { | |
| ContextType* context); | ||
|
|
||
| // This API may only be called from the main thread. | ||
| // Finalizer must implement `void operator()(Env env)`. | ||
| template <typename ResourceString, typename Finalizer> | ||
| static ThreadSafeFunction New(napi_env env, | ||
| const Function& callback, | ||
|
|
@@ -2899,6 +2917,8 @@ class ThreadSafeFunction { | |
| Finalizer finalizeCallback); | ||
|
|
||
| // This API may only be called from the main thread. | ||
| // Finalizer must implement | ||
| // `void operator()(Env env, FinalizerDataType* data)`. | ||
| template <typename ResourceString, | ||
| typename Finalizer, | ||
| typename FinalizerDataType> | ||
|
|
@@ -2912,6 +2932,8 @@ class ThreadSafeFunction { | |
| FinalizerDataType* data); | ||
|
|
||
| // This API may only be called from the main thread. | ||
| // Finalizer must implement | ||
| // `void operator()(Env env, ContextType* context)`. | ||
| template <typename ResourceString, typename ContextType, typename Finalizer> | ||
| static ThreadSafeFunction New(napi_env env, | ||
| const Function& callback, | ||
|
|
@@ -2923,6 +2945,8 @@ class ThreadSafeFunction { | |
| Finalizer finalizeCallback); | ||
|
|
||
| // This API may only be called from the main thread. | ||
| // Finalizer must implement `void operator()(Env env, | ||
| // FinalizerDataType* data, ContextType* context)`. | ||
| template <typename ResourceString, | ||
| typename ContextType, | ||
| typename Finalizer, | ||
|
|
@@ -3067,6 +3091,8 @@ class TypedThreadSafeFunction { | |
| // This API may only be called from the main thread. | ||
| // Creates a new threadsafe function with: | ||
| // Callback [missing] Resource [missing] Finalizer [passed] | ||
| // Finalizer must implement `void operator()(Env env, | ||
| // FinalizerDataType* data, ContextType* context)`. | ||
| template <typename ResourceString, | ||
| typename Finalizer, | ||
| typename FinalizerDataType = void> | ||
|
|
@@ -3082,6 +3108,8 @@ class TypedThreadSafeFunction { | |
| // This API may only be called from the main thread. | ||
| // Creates a new threadsafe function with: | ||
| // Callback [missing] Resource [passed] Finalizer [passed] | ||
| // Finalizer must implement `void operator()(Env env, | ||
| // FinalizerDataType* data, ContextType* context)`. | ||
| template <typename ResourceString, | ||
| typename Finalizer, | ||
| typename FinalizerDataType = void> | ||
|
|
@@ -3124,6 +3152,8 @@ class TypedThreadSafeFunction { | |
| // This API may only be called from the main thread. | ||
| // Creates a new threadsafe function with: | ||
| // Callback [passed] Resource [missing] Finalizer [passed] | ||
| // Finalizer must implement `void operator()(Env env, | ||
| // FinalizerDataType* data, ContextType* context)`. | ||
| template <typename ResourceString, | ||
| typename Finalizer, | ||
| typename FinalizerDataType = void> | ||
|
|
@@ -3140,6 +3170,8 @@ class TypedThreadSafeFunction { | |
| // This API may only be called from the main thread. | ||
| // Creates a new threadsafe function with: | ||
| // Callback [passed] Resource [passed] Finalizer [passed] | ||
| // Finalizer must implement `void operator()(Env env, | ||
| // FinalizerDataType* data, ContextType* context)`. | ||
| template <typename CallbackType, | ||
| typename ResourceString, | ||
| typename Finalizer, | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Have we considered using C++ Concepts for this instead of these human-only annotations?
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.
(Though clearly this doesn't need to block the PR...)
Uh oh!
There was an error while loading. Please reload this page.
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.
it will be a semver-major to bump minimum c++ version to c++20. Right now node-addon-api still supports c++17 as in node v18/v20
node-addon-api/package.json
Line 478 in 13c28f6