Skip to content

Commit

Permalink
present napi_get_cb_info and napi_*_callback_scope as js-capable
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielschulhof committed Oct 27, 2023
1 parent 18c0766 commit a4bdd92
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/js_native_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ NAPI_EXTERN napi_status NAPI_CDECL napi_instanceof(napi_env env,

// Gets all callback info in a single call. (Ugly, but faster.)
NAPI_EXTERN napi_status NAPI_CDECL napi_get_cb_info(
node_api_nogc_env env, // [in] Node-API environment handle
napi_env env, // [in] Node-API environment handle
napi_callback_info cbinfo, // [in] Opaque callback-info handle
size_t* argc, // [in-out] Specifies the size of the provided argv array
// and receives the actual count of args.
Expand Down
2 changes: 1 addition & 1 deletion src/js_native_api_v8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1979,7 +1979,7 @@ napi_status NAPI_CDECL napi_get_null(napi_env env, napi_value* result) {

// Gets all callback info in a single call. (Ugly, but faster.)
napi_status NAPI_CDECL napi_get_cb_info(
node_api_nogc_env env, // [in] NAPI environment handle
napi_env env, // [in] NAPI environment handle
napi_callback_info cbinfo, // [in] Opaque callback-info handle
size_t* argc, // [in-out] Specifies the size of the provided argv array
// and receives the actual count of args.
Expand Down
5 changes: 2 additions & 3 deletions src/node_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ NAPI_NO_RETURN void NAPI_CDECL napi_fatal_error(const char* location,
}

napi_status NAPI_CDECL
napi_open_callback_scope(node_api_nogc_env env,
napi_open_callback_scope(napi_env env,
napi_value /** ignored */,
napi_async_context async_context_handle,
napi_callback_scope* result) {
Expand All @@ -897,11 +897,10 @@ napi_open_callback_scope(node_api_nogc_env env,
return napi_clear_last_error(env);
}

napi_status NAPI_CDECL napi_close_callback_scope(node_api_nogc_env nogc_env,
napi_status NAPI_CDECL napi_close_callback_scope(napi_env env,
napi_callback_scope scope) {
// Omit NAPI_PREAMBLE and GET_RETURN_STATUS because V8 calls here cannot throw
// JS exceptions.
napi_env env = const_cast<napi_env>(nogc_env);
CHECK_ENV(env);
CHECK_ARG(env, scope);
if (env->open_callback_scopes == 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/node_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,13 @@ NAPI_EXTERN napi_status NAPI_CDECL napi_remove_env_cleanup_hook(
node_api_nogc_env env, napi_cleanup_hook fun, void* arg);

NAPI_EXTERN napi_status NAPI_CDECL
napi_open_callback_scope(node_api_nogc_env env,
napi_open_callback_scope(napi_env env,
napi_value resource_object,
napi_async_context context,
napi_callback_scope* result);

NAPI_EXTERN napi_status NAPI_CDECL
napi_close_callback_scope(node_api_nogc_env env, napi_callback_scope scope);
napi_close_callback_scope(napi_env env, napi_callback_scope scope);

#endif // NAPI_VERSION >= 3

Expand Down

0 comments on commit a4bdd92

Please sign in to comment.