mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
node-api: rename internal NAPI_VERSION definition
PR-URL: https://github.com/nodejs/node/pull/48501 Reviewed-By: Gabriel Schulhof <gabrielschulhof@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Vladimir Morozov <vmorozov@microsoft.com> Reviewed-By: Michael Dawson <midawson@redhat.com>
This commit is contained in:
parent
86ba5bea9e
commit
6ffacbf0f9
@ -3167,7 +3167,7 @@ napi_status NAPI_CDECL napi_get_dataview_info(napi_env env,
|
||||
napi_status NAPI_CDECL napi_get_version(napi_env env, uint32_t* result) {
|
||||
CHECK_ENV(env);
|
||||
CHECK_ARG(env, result);
|
||||
*result = NAPI_VERSION;
|
||||
*result = NODE_API_SUPPORTED_VERSION_MAX;
|
||||
return napi_clear_last_error(env);
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ void ThrowNodeApiVersionError(node::Environment* node_env,
|
||||
error_message += " requires Node-API version ";
|
||||
error_message += std::to_string(module_api_version);
|
||||
error_message += ", but this version of Node.js only supports version ";
|
||||
error_message += NODE_STRINGIFY(NAPI_VERSION) " add-ons.";
|
||||
error_message += NODE_STRINGIFY(NODE_API_SUPPORTED_VERSION_MAX) " add-ons.";
|
||||
node_env->ThrowError(error_message.c_str());
|
||||
}
|
||||
|
||||
@ -172,7 +172,7 @@ inline napi_env NewEnv(v8::Local<v8::Context> context,
|
||||
// Validate module_api_version.
|
||||
if (module_api_version < NODE_API_DEFAULT_MODULE_API_VERSION) {
|
||||
module_api_version = NODE_API_DEFAULT_MODULE_API_VERSION;
|
||||
} else if (module_api_version > NAPI_VERSION &&
|
||||
} else if (module_api_version > NODE_API_SUPPORTED_VERSION_MAX &&
|
||||
module_api_version != NAPI_VERSION_EXPERIMENTAL) {
|
||||
node::Environment* node_env = node::Environment::GetCurrent(context);
|
||||
CHECK_NOT_NULL(node_env);
|
||||
@ -673,15 +673,16 @@ node::addon_context_register_func get_node_api_context_register_func(
|
||||
const char* module_name,
|
||||
int32_t module_api_version) {
|
||||
static_assert(
|
||||
NAPI_VERSION == 9,
|
||||
NODE_API_SUPPORTED_VERSION_MAX == 9,
|
||||
"New version of Node-API requires adding another else-if statement below "
|
||||
"for the new version and updating this assert condition.");
|
||||
if (module_api_version <= NODE_API_DEFAULT_MODULE_API_VERSION) {
|
||||
return node_api_context_register_func<NODE_API_DEFAULT_MODULE_API_VERSION>;
|
||||
} else if (module_api_version == 9) {
|
||||
if (module_api_version == 9) {
|
||||
return node_api_context_register_func<9>;
|
||||
} else if (module_api_version == NAPI_VERSION_EXPERIMENTAL) {
|
||||
return node_api_context_register_func<NAPI_VERSION_EXPERIMENTAL>;
|
||||
} else if (module_api_version >= NODE_API_SUPPORTED_VERSION_MIN &&
|
||||
module_api_version <= NODE_API_DEFAULT_MODULE_API_VERSION) {
|
||||
return node_api_context_register_func<NODE_API_DEFAULT_MODULE_API_VERSION>;
|
||||
} else {
|
||||
v8impl::ThrowNodeApiVersionError(node_env, module_name, module_api_version);
|
||||
return nullptr;
|
||||
|
@ -82,7 +82,7 @@ Metadata::Versions::Versions() {
|
||||
ares = ARES_VERSION_STR;
|
||||
modules = NODE_STRINGIFY(NODE_MODULE_VERSION);
|
||||
nghttp2 = NGHTTP2_VERSION;
|
||||
napi = NODE_STRINGIFY(NAPI_VERSION);
|
||||
napi = NODE_STRINGIFY(NODE_API_SUPPORTED_VERSION_MAX);
|
||||
llhttp =
|
||||
NODE_STRINGIFY(LLHTTP_VERSION_MAJOR)
|
||||
"."
|
||||
|
@ -91,9 +91,10 @@
|
||||
*/
|
||||
#define NODE_MODULE_VERSION 115
|
||||
|
||||
// The NAPI_VERSION provided by this version of the runtime. This is the version
|
||||
// which the Node binary being built supports.
|
||||
#define NAPI_VERSION 9
|
||||
// The NAPI_VERSION supported by the runtime. This is the inclusive range of
|
||||
// versions which the Node.js binary being built supports.
|
||||
#define NODE_API_SUPPORTED_VERSION_MAX 9
|
||||
#define NODE_API_SUPPORTED_VERSION_MIN 1
|
||||
|
||||
// Node API modules use NAPI_VERSION 8 by default if it is not explicitly
|
||||
// specified. It must be always 8.
|
||||
|
@ -12,7 +12,7 @@ def get_napi_version():
|
||||
|
||||
f = open(napi_version_h)
|
||||
|
||||
regex = '^#define NAPI_VERSION'
|
||||
regex = '^#define NODE_API_SUPPORTED_VERSION_MAX'
|
||||
|
||||
for line in f:
|
||||
if re.match(regex, line):
|
||||
|
Loading…
Reference in New Issue
Block a user