Skip to content

Commit 5fd5bf4

Browse files
committed
update embedding API and add C tests
1 parent ce04172 commit 5fd5bf4

36 files changed

+4822
-2213
lines changed

.clang-format

+4
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ JavaScriptWrapImports: true
7979
KeepEmptyLinesAtTheStartOfBlocks: false
8080
MacroBlockBegin: ''
8181
MacroBlockEnd: ''
82+
Macros:
83+
- "NODE_ENUM(a,b) = enum class b"
84+
- "NODE_ENUM_FLAGS(a,b) = enum class b"
85+
- "NODE_ENUM_ITEM (a,b) = b"
8286
MaxEmptyLinesToKeep: 1
8387
NamespaceIndentation: None
8488
ObjCBlockIndentWidth: 2

node.gyp

+16-7
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@
241241
'src/node_dir.h',
242242
'src/node_dotenv.h',
243243
'src/node_embedding_api.h',
244+
'src/node_embedding_api_cpp.h',
244245
'src/node_errors.h',
245246
'src/node_exit_code.h',
246247
'src/node_external_reference.h',
@@ -1267,14 +1268,22 @@
12671268
'sources': [
12681269
'src/node_snapshot_stub.cc',
12691270
'test/embedding/embedtest.cc',
1270-
'test/embedding/embedtest_c_api.cc',
1271-
'test/embedding/embedtest_c_api_common.cc',
1271+
'test/embedding/embedtest_c_api_common.c',
12721272
'test/embedding/embedtest_c_api_common.h',
1273-
'test/embedding/embedtest_c_api_env.cc',
1274-
'test/embedding/embedtest_c_api_modules.cc',
1275-
'test/embedding/embedtest_c_api_preload.cc',
1276-
'test/embedding/embedtest_c_api_run_main.cc',
1277-
'test/embedding/embedtest_c_api_threading.cc',
1273+
'test/embedding/embedtest_c_api_env.c',
1274+
'test/embedding/embedtest_c_api_modules.c',
1275+
'test/embedding/embedtest_c_api_preload.c',
1276+
'test/embedding/embedtest_c_api_run_main.c',
1277+
'test/embedding/embedtest_c_api_threading.c',
1278+
'test/embedding/embedtest_c_api.c',
1279+
'test/embedding/embedtest_c_cpp_api_common.cc',
1280+
'test/embedding/embedtest_c_cpp_api_common.h',
1281+
'test/embedding/embedtest_c_cpp_api_env.cc',
1282+
'test/embedding/embedtest_c_cpp_api_modules.cc',
1283+
'test/embedding/embedtest_c_cpp_api_preload.cc',
1284+
'test/embedding/embedtest_c_cpp_api_run_main.cc',
1285+
'test/embedding/embedtest_c_cpp_api_threading.cc',
1286+
'test/embedding/embedtest_c_cpp_api.cc',
12781287
'test/embedding/embedtest_main.cc',
12791288
],
12801289

src/js_native_api.h

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
#define SRC_JS_NATIVE_API_H_
33

44
// This file needs to be compatible with C compilers.
5-
#include <stdbool.h> // NOLINT(modernize-deprecated-headers)
6-
#include <stddef.h> // NOLINT(modernize-deprecated-headers)
75

86
// Use INT_MAX, this should only be consumed by the pre-processor anyway.
97
#define NAPI_VERSION_EXPERIMENTAL 2147483647

src/js_native_api_types.h

+8-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@
44
// This file needs to be compatible with C compilers.
55
// This is a public include file, and these includes have essentially
66
// became part of it's API.
7-
#include <stddef.h> // NOLINT(modernize-deprecated-headers)
8-
#include <stdint.h> // NOLINT(modernize-deprecated-headers)
7+
#ifdef __cplusplus
8+
#include <cstddef>
9+
#include <cstdint>
10+
#else
11+
#include <stdbool.h> // NOLINT(modernize-deprecated-headers)
12+
#include <stddef.h> // NOLINT(modernize-deprecated-headers)
13+
#include <stdint.h> // NOLINT(modernize-deprecated-headers)
14+
#endif
915

1016
#if !defined __cplusplus || (defined(_MSC_VER) && _MSC_VER < 1900)
1117
typedef uint16_t char16_t;

0 commit comments

Comments
 (0)