Skip to content

Commit

Permalink
n-api: add version to wasm registration
Browse files Browse the repository at this point in the history
PR-URL: #34045
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Gabriel Schulhof <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
  • Loading branch information
devsnek authored and codebytere committed Jul 12, 2020
1 parent d3737a1 commit 47f5eeb
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/node_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,17 @@ typedef struct {
} \
EXTERN_C_END

#define NAPI_MODULE_INITIALIZER_X(base, version) \
NAPI_MODULE_INITIALIZER_X_HELPER(base, version)
#define NAPI_MODULE_INITIALIZER_X_HELPER(base, version) base##version

#ifdef __wasm32__
#define NAPI_WASM_INITIALIZER \
NAPI_MODULE_INITIALIZER_X(napi_register_wasm_v, NAPI_MODULE_VERSION)
#define NAPI_MODULE(modname, regfunc) \
EXTERN_C_START \
NAPI_MODULE_EXPORT napi_value _napi_register(napi_env env, \
napi_value exports) { \
NAPI_MODULE_EXPORT napi_value NAPI_WASM_INITIALIZER(napi_env env, \
napi_value exports) { \
return regfunc(env, exports); \
} \
EXTERN_C_END
Expand All @@ -88,10 +94,6 @@ typedef struct {

#define NAPI_MODULE_INITIALIZER_BASE napi_register_module_v

#define NAPI_MODULE_INITIALIZER_X(base, version) \
NAPI_MODULE_INITIALIZER_X_HELPER(base, version)
#define NAPI_MODULE_INITIALIZER_X_HELPER(base, version) base##version

#define NAPI_MODULE_INITIALIZER \
NAPI_MODULE_INITIALIZER_X(NAPI_MODULE_INITIALIZER_BASE, \
NAPI_MODULE_VERSION)
Expand Down

0 comments on commit 47f5eeb

Please sign in to comment.