Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6ffacbf

Browse filesBrowse files
legendecasmhdawson
authored andcommitted
node-api: rename internal NAPI_VERSION definition
PR-URL: #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>
1 parent 86ba5be commit 6ffacbf
Copy full SHA for 6ffacbf

File tree

Expand file treeCollapse file tree

5 files changed

+14
-12
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

5 files changed

+14
-12
lines changed
Open diff view settings
Collapse file

‎src/js_native_api_v8.cc‎

Copy file name to clipboardExpand all lines: src/js_native_api_v8.cc
+1-1Lines 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_SUPPORTED_VERSION_MAX;
31713171
return napi_clear_last_error(env);
31723172
}
31733173

Collapse file

‎src/node_api.cc‎

Copy file name to clipboardExpand all lines: src/node_api.cc
+7-6Lines changed: 7 additions & 6 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_SUPPORTED_VERSION_MAX) " 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_SUPPORTED_VERSION_MAX &&
176176
module_api_version != NAPI_VERSION_EXPERIMENTAL) {
177177
node::Environment* node_env = node::Environment::GetCurrent(context);
178178
CHECK_NOT_NULL(node_env);
@@ -673,15 +673,16 @@ 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_SUPPORTED_VERSION_MAX == 9,
677677
"New version of Node-API requires adding another else-if statement below "
678678
"for the new version and updating this assert condition.");
679-
if (module_api_version <= NODE_API_DEFAULT_MODULE_API_VERSION) {
680-
return node_api_context_register_func<NODE_API_DEFAULT_MODULE_API_VERSION>;
681-
} else if (module_api_version == 9) {
679+
if (module_api_version == 9) {
682680
return node_api_context_register_func<9>;
683681
} else if (module_api_version == NAPI_VERSION_EXPERIMENTAL) {
684682
return node_api_context_register_func<NAPI_VERSION_EXPERIMENTAL>;
683+
} else if (module_api_version >= NODE_API_SUPPORTED_VERSION_MIN &&
684+
module_api_version <= NODE_API_DEFAULT_MODULE_API_VERSION) {
685+
return node_api_context_register_func<NODE_API_DEFAULT_MODULE_API_VERSION>;
685686
} else {
686687
v8impl::ThrowNodeApiVersionError(node_env, module_name, module_api_version);
687688
return nullptr;
Collapse file

‎src/node_metadata.cc‎

Copy file name to clipboardExpand all lines: src/node_metadata.cc
+1-1Lines 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_SUPPORTED_VERSION_MAX);
8686
llhttp =
8787
NODE_STRINGIFY(LLHTTP_VERSION_MAJOR)
8888
"."
Collapse file

‎src/node_version.h‎

Copy file name to clipboardExpand all lines: src/node_version.h
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,10 @@
9191
*/
9292
#define NODE_MODULE_VERSION 115
9393

94-
// The NAPI_VERSION provided by this version of the runtime. This is the version
95-
// which the Node binary being built supports.
96-
#define NAPI_VERSION 9
94+
// The NAPI_VERSION supported by the runtime. This is the inclusive range of
95+
// versions which the Node.js binary being built supports.
96+
#define NODE_API_SUPPORTED_VERSION_MAX 9
97+
#define NODE_API_SUPPORTED_VERSION_MIN 1
9798

9899
// Node API modules use NAPI_VERSION 8 by default if it is not explicitly
99100
// specified. It must be always 8.
Collapse file

‎tools/getnapibuildversion.py‎

Copy file name to clipboardExpand all lines: tools/getnapibuildversion.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def get_napi_version():
1212

1313
f = open(napi_version_h)
1414

15-
regex = '^#define NAPI_VERSION'
15+
regex = '^#define NODE_API_SUPPORTED_VERSION_MAX'
1616

1717
for line in f:
1818
if re.match(regex, line):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.