Skip to content

Commit 47f5eeb

Browse files
devsnekcodebytere
authored andcommitted
n-api: add version to wasm registration
PR-URL: #34045 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gabriel Schulhof <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
1 parent d3737a1 commit 47f5eeb

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/node_api.h

+8-6
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,17 @@ typedef struct {
7373
} \
7474
EXTERN_C_END
7575

76+
#define NAPI_MODULE_INITIALIZER_X(base, version) \
77+
NAPI_MODULE_INITIALIZER_X_HELPER(base, version)
78+
#define NAPI_MODULE_INITIALIZER_X_HELPER(base, version) base##version
79+
7680
#ifdef __wasm32__
81+
#define NAPI_WASM_INITIALIZER \
82+
NAPI_MODULE_INITIALIZER_X(napi_register_wasm_v, NAPI_MODULE_VERSION)
7783
#define NAPI_MODULE(modname, regfunc) \
7884
EXTERN_C_START \
79-
NAPI_MODULE_EXPORT napi_value _napi_register(napi_env env, \
80-
napi_value exports) { \
85+
NAPI_MODULE_EXPORT napi_value NAPI_WASM_INITIALIZER(napi_env env, \
86+
napi_value exports) { \
8187
return regfunc(env, exports); \
8288
} \
8389
EXTERN_C_END
@@ -88,10 +94,6 @@ typedef struct {
8894

8995
#define NAPI_MODULE_INITIALIZER_BASE napi_register_module_v
9096

91-
#define NAPI_MODULE_INITIALIZER_X(base, version) \
92-
NAPI_MODULE_INITIALIZER_X_HELPER(base, version)
93-
#define NAPI_MODULE_INITIALIZER_X_HELPER(base, version) base##version
94-
9597
#define NAPI_MODULE_INITIALIZER \
9698
NAPI_MODULE_INITIALIZER_X(NAPI_MODULE_INITIALIZER_BASE, \
9799
NAPI_MODULE_VERSION)

0 commit comments

Comments
 (0)