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 de78da7

Browse filesBrowse files
addaleaxaduh95
authored andcommitted
src: move Node-API version detection to where it is used
`src/js_native_api_types.h` and other files actually depend on the moved macros being evaluated, so before this change there was an implicit requirement that `src/js_native_api.h` would be included separately before any include of `src/js_native_api_types.h`, direct or transitive. PR-URL: #60512 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 07bcd28 commit de78da7
Copy full SHA for de78da7

File tree

Expand file treeCollapse file tree

2 files changed

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

2 files changed

+28
-28
lines changed
Open diff view settings
Collapse file

‎src/js_native_api.h‎

Copy file name to clipboardExpand all lines: src/js_native_api.h
-28Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,6 @@
55
#include <stdbool.h> // NOLINT(modernize-deprecated-headers)
66
#include <stddef.h> // NOLINT(modernize-deprecated-headers)
77

8-
// Use INT_MAX, this should only be consumed by the pre-processor anyway.
9-
#define NAPI_VERSION_EXPERIMENTAL 2147483647
10-
#ifndef NAPI_VERSION
11-
#ifdef NAPI_EXPERIMENTAL
12-
#define NAPI_VERSION NAPI_VERSION_EXPERIMENTAL
13-
#else
14-
// The baseline version for N-API.
15-
// The NAPI_VERSION controls which version will be used by default when
16-
// compilling a native addon. If the addon developer specifically wants to use
17-
// functions available in a new version of N-API that is not yet ported in all
18-
// LTS versions, they can set NAPI_VERSION knowing that they have specifically
19-
// depended on that version.
20-
#define NAPI_VERSION 8
21-
#endif
22-
#endif
23-
24-
#if defined(NAPI_EXPERIMENTAL) && \
25-
!defined(NODE_API_EXPERIMENTAL_NO_WARNING) && \
26-
!defined(NODE_WANT_INTERNALS)
27-
#ifdef _MSC_VER
28-
#pragma message("NAPI_EXPERIMENTAL is enabled. " \
29-
"Experimental features may be unstable.")
30-
#else
31-
#warning "NAPI_EXPERIMENTAL is enabled. " \
32-
"Experimental features may be unstable."
33-
#endif
34-
#endif
35-
368
#include "js_native_api_types.h"
379

3810
// If you need __declspec(dllimport), either include <node_api.h> instead, or
Collapse file

‎src/js_native_api_types.h‎

Copy file name to clipboardExpand all lines: src/js_native_api_types.h
+28Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,34 @@
11
#ifndef SRC_JS_NATIVE_API_TYPES_H_
22
#define SRC_JS_NATIVE_API_TYPES_H_
33

4+
// Use INT_MAX, this should only be consumed by the pre-processor anyway.
5+
#define NAPI_VERSION_EXPERIMENTAL 2147483647
6+
#ifndef NAPI_VERSION
7+
#ifdef NAPI_EXPERIMENTAL
8+
#define NAPI_VERSION NAPI_VERSION_EXPERIMENTAL
9+
#else
10+
// The baseline version for N-API.
11+
// The NAPI_VERSION controls which version will be used by default when
12+
// compilling a native addon. If the addon developer specifically wants to use
13+
// functions available in a new version of N-API that is not yet ported in all
14+
// LTS versions, they can set NAPI_VERSION knowing that they have specifically
15+
// depended on that version.
16+
#define NAPI_VERSION 8
17+
#endif
18+
#endif
19+
20+
#if defined(NAPI_EXPERIMENTAL) && \
21+
!defined(NODE_API_EXPERIMENTAL_NO_WARNING) && \
22+
!defined(NODE_WANT_INTERNALS)
23+
#ifdef _MSC_VER
24+
#pragma message("NAPI_EXPERIMENTAL is enabled. " \
25+
"Experimental features may be unstable.")
26+
#else
27+
#warning "NAPI_EXPERIMENTAL is enabled. " \
28+
"Experimental features may be unstable."
29+
#endif
30+
#endif
31+
432
// This file needs to be compatible with C compilers.
533
// This is a public include file, and these includes have essentially
634
// became part of it's API.

0 commit comments

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