-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
node-api: Add API to check safety of calling JS #43805
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6295,6 +6295,24 @@ node_api_get_module_file_name(napi_env env, const char** result); | |
`result` may be an empty string if the add-on loading process fails to establish | ||
the add-on's file name during loading. | ||
|
||
#### `napi_can_call_into_js` | ||
|
||
<!-- YAML | ||
added: REPLACEME | ||
--> | ||
|
||
> Stability: 1 - Experimental | ||
|
||
```c | ||
NAPI_EXTERN napi_status napi_can_call_into_js(napi_env env); | ||
``` | ||
|
||
* `[in] env`: The environment that the API is invoked under. | ||
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. Same here. |
||
|
||
Returns `napi_ok` if the API succeeded. | ||
|
||
This API is used to check if it is safe to call into JavaScript. | ||
|
||
[ABI Stability]: https://nodejs.org/en/docs/guides/abi-stability/ | ||
[AppVeyor]: https://www.appveyor.com | ||
[C++ Addons]: addons.md | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -566,6 +566,11 @@ NAPI_EXTERN napi_status NAPI_CDECL napi_object_seal(napi_env env, | |
napi_value object); | ||
#endif // NAPI_VERSION >= 8 | ||
|
||
#ifdef NAPI_EXPERIMENTAL | ||
NAPI_EXTERN napi_status NAPI_CDECL napi_can_call_into_js(napi_env env, | ||
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. From dicussion in Node-api team meeting today new methods should use Overall there was agreement that adding a method makes sense. The other suggestion was that we need a unit test. |
||
bool* result); | ||
#endif | ||
|
||
EXTERN_C_END | ||
|
||
#endif // SRC_JS_NATIVE_API_H_ |
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.
This is missing the
bool* result
parameter.