From 47f5eeb0d50ce144e67211b94ade5c213aa6b71d Mon Sep 17 00:00:00 2001 From: Gus Caplan Date: Wed, 24 Jun 2020 20:16:04 -0500 Subject: [PATCH] n-api: add version to wasm registration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/34045 Reviewed-By: James M Snell Reviewed-By: Gabriel Schulhof Reviewed-By: Tobias Nießen --- src/node_api.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/node_api.h b/src/node_api.h index 7f48d8c8465520..2f1b45572d8130 100644 --- a/src/node_api.h +++ b/src/node_api.h @@ -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 @@ -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)