Skip to content

Commit 1b78b7b

Browse files
committed
node-api: rename internal NAPI_VERSION definition
1 parent 51ca71c commit 1b78b7b

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

src/js_native_api_v8.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3167,7 +3167,7 @@ napi_status NAPI_CDECL napi_get_dataview_info(napi_env env,
31673167
napi_status NAPI_CDECL napi_get_version(napi_env env, uint32_t* result) {
31683168
CHECK_ENV(env);
31693169
CHECK_ARG(env, result);
3170-
*result = NAPI_VERSION;
3170+
*result = NODE_API_MODULE_API_VERSION;
31713171
return napi_clear_last_error(env);
31723172
}
31733173

src/node_api.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ void ThrowNodeApiVersionError(node::Environment* node_env,
160160
error_message += " requires Node-API version ";
161161
error_message += std::to_string(module_api_version);
162162
error_message += ", but this version of Node.js only supports version ";
163-
error_message += NODE_STRINGIFY(NAPI_VERSION) " add-ons.";
163+
error_message += NODE_STRINGIFY(NODE_API_MODULE_API_VERSION) " add-ons.";
164164
node_env->ThrowError(error_message.c_str());
165165
}
166166

@@ -172,7 +172,7 @@ inline napi_env NewEnv(v8::Local<v8::Context> context,
172172
// Validate module_api_version.
173173
if (module_api_version < NODE_API_DEFAULT_MODULE_API_VERSION) {
174174
module_api_version = NODE_API_DEFAULT_MODULE_API_VERSION;
175-
} else if (module_api_version > NAPI_VERSION &&
175+
} else if (module_api_version > NODE_API_MODULE_API_VERSION &&
176176
module_api_version != NAPI_VERSION_EXPERIMENTAL) {
177177
node::Environment* node_env = node::Environment::GetCurrent(context);
178178
CHECK_NOT_NULL(node_env);
@@ -673,7 +673,7 @@ node::addon_context_register_func get_node_api_context_register_func(
673673
const char* module_name,
674674
int32_t module_api_version) {
675675
static_assert(
676-
NAPI_VERSION == 9,
676+
NODE_API_MODULE_API_VERSION == 9,
677677
"New version of Node-API requires adding another else-if statement below "
678678
"for the new version and updating this assert condition.");
679679
if (module_api_version <= NODE_API_DEFAULT_MODULE_API_VERSION) {

src/node_metadata.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Metadata::Versions::Versions() {
8282
ares = ARES_VERSION_STR;
8383
modules = NODE_STRINGIFY(NODE_MODULE_VERSION);
8484
nghttp2 = NGHTTP2_VERSION;
85-
napi = NODE_STRINGIFY(NAPI_VERSION);
85+
napi = NODE_STRINGIFY(NODE_API_MODULE_API_VERSION);
8686
llhttp =
8787
NODE_STRINGIFY(LLHTTP_VERSION_MAJOR)
8888
"."

src/node_version.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@
9393

9494
// The NAPI_VERSION provided by this version of the runtime. This is the version
9595
// which the Node binary being built supports.
96-
#define NAPI_VERSION 9
96+
// Distinguished from NAPI_VERSION intentionally to avoid re-defining
97+
// NAPI_VERSION unexpectedly when both node_version.h and js_native_api.h are
98+
// included.
99+
#define NODE_API_MODULE_API_VERSION 9
97100

98101
// Node API modules use NAPI_VERSION 8 by default if it is not explicitly
99102
// specified. It must be always 8.

0 commit comments

Comments
 (0)