mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 21:58:48 +02:00
test: rename n-api to node-api
This renames the macros used in the tests from `NAPI_*` to `NODE_API_*`. PR-URL: https://github.com/nodejs/node/pull/37217 Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Beth Griggs <bgriggs@redhat.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
parent
2ff1c83518
commit
4b7f23f868
52 changed files with 1371 additions and 1448 deletions
|
@ -6,16 +6,16 @@ static bool exceptionWasPending = false;
|
|||
static napi_value returnException(napi_env env, napi_callback_info info) {
|
||||
size_t argc = 1;
|
||||
napi_value args[1];
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));
|
||||
NODE_API_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));
|
||||
|
||||
napi_value global;
|
||||
NAPI_CALL(env, napi_get_global(env, &global));
|
||||
NODE_API_CALL(env, napi_get_global(env, &global));
|
||||
|
||||
napi_value result;
|
||||
napi_status status = napi_call_function(env, global, args[0], 0, 0, &result);
|
||||
if (status == napi_pending_exception) {
|
||||
napi_value ex;
|
||||
NAPI_CALL(env, napi_get_and_clear_last_exception(env, &ex));
|
||||
NODE_API_CALL(env, napi_get_and_clear_last_exception(env, &ex));
|
||||
return ex;
|
||||
}
|
||||
|
||||
|
@ -25,35 +25,35 @@ static napi_value returnException(napi_env env, napi_callback_info info) {
|
|||
static napi_value allowException(napi_env env, napi_callback_info info) {
|
||||
size_t argc = 1;
|
||||
napi_value args[1];
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));
|
||||
NODE_API_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));
|
||||
|
||||
napi_value global;
|
||||
NAPI_CALL(env, napi_get_global(env, &global));
|
||||
NODE_API_CALL(env, napi_get_global(env, &global));
|
||||
|
||||
napi_value result;
|
||||
napi_call_function(env, global, args[0], 0, 0, &result);
|
||||
// Ignore status and check napi_is_exception_pending() instead.
|
||||
|
||||
NAPI_CALL(env, napi_is_exception_pending(env, &exceptionWasPending));
|
||||
NODE_API_CALL(env, napi_is_exception_pending(env, &exceptionWasPending));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static napi_value wasPending(napi_env env, napi_callback_info info) {
|
||||
napi_value result;
|
||||
NAPI_CALL(env, napi_get_boolean(env, exceptionWasPending, &result));
|
||||
NODE_API_CALL(env, napi_get_boolean(env, exceptionWasPending, &result));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void finalizer(napi_env env, void *data, void *hint) {
|
||||
NAPI_CALL_RETURN_VOID(env,
|
||||
NODE_API_CALL_RETURN_VOID(env,
|
||||
napi_throw_error(env, NULL, "Error during Finalize"));
|
||||
}
|
||||
|
||||
static napi_value createExternal(napi_env env, napi_callback_info info) {
|
||||
napi_value external;
|
||||
|
||||
NAPI_CALL(env,
|
||||
NODE_API_CALL(env,
|
||||
napi_create_external(env, NULL, finalizer, NULL, &external));
|
||||
|
||||
return external;
|
||||
|
@ -62,21 +62,21 @@ static napi_value createExternal(napi_env env, napi_callback_info info) {
|
|||
EXTERN_C_START
|
||||
napi_value Init(napi_env env, napi_value exports) {
|
||||
napi_property_descriptor descriptors[] = {
|
||||
DECLARE_NAPI_PROPERTY("returnException", returnException),
|
||||
DECLARE_NAPI_PROPERTY("allowException", allowException),
|
||||
DECLARE_NAPI_PROPERTY("wasPending", wasPending),
|
||||
DECLARE_NAPI_PROPERTY("createExternal", createExternal),
|
||||
DECLARE_NODE_API_PROPERTY("returnException", returnException),
|
||||
DECLARE_NODE_API_PROPERTY("allowException", allowException),
|
||||
DECLARE_NODE_API_PROPERTY("wasPending", wasPending),
|
||||
DECLARE_NODE_API_PROPERTY("createExternal", createExternal),
|
||||
};
|
||||
NAPI_CALL(env, napi_define_properties(
|
||||
NODE_API_CALL(env, napi_define_properties(
|
||||
env, exports, sizeof(descriptors) / sizeof(*descriptors), descriptors));
|
||||
|
||||
napi_value error, code, message;
|
||||
NAPI_CALL(env, napi_create_string_utf8(env, "Error during Init",
|
||||
NODE_API_CALL(env, napi_create_string_utf8(env, "Error during Init",
|
||||
NAPI_AUTO_LENGTH, &message));
|
||||
NAPI_CALL(env, napi_create_string_utf8(env, "", NAPI_AUTO_LENGTH, &code));
|
||||
NAPI_CALL(env, napi_create_error(env, code, message, &error));
|
||||
NAPI_CALL(env, napi_set_named_property(env, error, "binding", exports));
|
||||
NAPI_CALL(env, napi_throw(env, error));
|
||||
NODE_API_CALL(env, napi_create_string_utf8(env, "", NAPI_AUTO_LENGTH, &code));
|
||||
NODE_API_CALL(env, napi_create_error(env, code, message, &error));
|
||||
NODE_API_CALL(env, napi_set_named_property(env, error, "binding", exports));
|
||||
NODE_API_CALL(env, napi_throw(env, error));
|
||||
|
||||
return exports;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue