diff options
author | Gus Caplan <me@gus.host> | 2020-05-28 06:32:10 +0300 |
---|---|---|
committer | Gus Caplan <me@gus.host> | 2020-05-30 19:42:06 +0300 |
commit | b4ede54a7d235cfe58265b2b8c455298698460a8 (patch) | |
tree | 9956a6b84c5c6b22739aa11a52883e30b5f6f9e7 /src/node_api.h | |
parent | d79c33018606c2deeeb646e1e74ed7fe29737125 (diff) |
napi: add __wasm32__ guards
PR-URL: https://github.com/nodejs/node/pull/33597
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'src/node_api.h')
-rw-r--r-- | src/node_api.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/node_api.h b/src/node_api.h index a4d3cc60e9b..7f48d8c8465 100644 --- a/src/node_api.h +++ b/src/node_api.h @@ -5,6 +5,8 @@ #ifdef _WIN32 // Building native module against node #define NAPI_EXTERN __declspec(dllimport) + #elif defined(__wasm32__) + #define NAPI_EXTERN __attribute__((__import_module__("napi"))) #endif #endif #include "js_native_api.h" @@ -71,8 +73,18 @@ typedef struct { } \ EXTERN_C_END +#ifdef __wasm32__ +#define NAPI_MODULE(modname, regfunc) \ + EXTERN_C_START \ + NAPI_MODULE_EXPORT napi_value _napi_register(napi_env env, \ + napi_value exports) { \ + return regfunc(env, exports); \ + } \ + EXTERN_C_END +#else #define NAPI_MODULE(modname, regfunc) \ NAPI_MODULE_X(modname, regfunc, NULL, 0) // NOLINT (readability/null_usage) +#endif #define NAPI_MODULE_INITIALIZER_BASE napi_register_module_v @@ -196,6 +208,7 @@ NAPI_EXTERN napi_status napi_close_callback_scope(napi_env env, #if NAPI_VERSION >= 4 +#ifndef __wasm32__ // Calling into JS from other threads NAPI_EXTERN napi_status napi_create_threadsafe_function(napi_env env, @@ -231,6 +244,7 @@ napi_unref_threadsafe_function(napi_env env, napi_threadsafe_function func); NAPI_EXTERN napi_status napi_ref_threadsafe_function(napi_env env, napi_threadsafe_function func); +#endif // __wasm32__ #endif // NAPI_VERSION >= 4 |