mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
node-api: update headers for better wasm support
PR-URL: https://github.com/nodejs/node/pull/49037 Reviewed-By: Gabriel Schulhof <gabrielschulhof@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
This commit is contained in:
1 parent
e8f024b4db
commit
e2f0ef2a60
2 files changed
+9
-8
No files matched your search
+1
-1
@@ -28,7 +28,7 @@
|
||||
#ifndef NAPI_EXTERN
|
||||
#ifdef _WIN32
|
||||
#define NAPI_EXTERN __declspec(dllexport)
|
||||
#elif defined(__wasm32__)
|
||||
#elif defined(__wasm__)
|
||||
#define NAPI_EXTERN \
|
||||
__attribute__((visibility("default"))) \
|
||||
__attribute__((__import_module__("napi")))
|
||||
|
||||
+8
-7
@@ -1,11 +1,11 @@
|
||||
#ifndef SRC_NODE_API_H_
|
||||
#define SRC_NODE_API_H_
|
||||
|
||||
#ifdef BUILDING_NODE_EXTENSION
|
||||
#if defined(BUILDING_NODE_EXTENSION) && !defined(NAPI_EXTERN)
|
||||
#ifdef _WIN32
|
||||
// Building native addon against node
|
||||
#define NAPI_EXTERN __declspec(dllimport)
|
||||
#elif defined(__wasm32__)
|
||||
#elif defined(__wasm__)
|
||||
#define NAPI_EXTERN __attribute__((__import_module__("napi")))
|
||||
#endif
|
||||
#endif
|
||||
@@ -17,8 +17,13 @@ struct uv_loop_s; // Forward declaration.
|
||||
#ifdef _WIN32
|
||||
#define NAPI_MODULE_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#define NAPI_MODULE_EXPORT \
|
||||
__attribute__((visibility("default"))) __attribute__((used))
|
||||
#else
|
||||
#define NAPI_MODULE_EXPORT __attribute__((visibility("default")))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define NAPI_NO_RETURN __attribute__((noreturn))
|
||||
@@ -49,7 +54,7 @@ typedef struct napi_module {
|
||||
NAPI_MODULE_INITIALIZER_X_HELPER(base, version)
|
||||
#define NAPI_MODULE_INITIALIZER_X_HELPER(base, version) base##version
|
||||
|
||||
#ifdef __wasm32__
|
||||
#ifdef __wasm__
|
||||
#define NAPI_MODULE_INITIALIZER_BASE napi_register_wasm_v
|
||||
#else
|
||||
#define NAPI_MODULE_INITIALIZER_BASE napi_register_module_v
|
||||
@@ -143,7 +148,6 @@ NAPI_EXTERN napi_status NAPI_CDECL napi_get_buffer_info(napi_env env,
|
||||
void** data,
|
||||
size_t* length);
|
||||
|
||||
#ifndef __wasm32__
|
||||
// Methods to manage simple async operations
|
||||
NAPI_EXTERN napi_status NAPI_CDECL
|
||||
napi_create_async_work(napi_env env,
|
||||
@@ -159,7 +163,6 @@ NAPI_EXTERN napi_status NAPI_CDECL napi_queue_async_work(napi_env env,
|
||||
napi_async_work work);
|
||||
NAPI_EXTERN napi_status NAPI_CDECL napi_cancel_async_work(napi_env env,
|
||||
napi_async_work work);
|
||||
#endif // __wasm32__
|
||||
|
||||
// version management
|
||||
NAPI_EXTERN napi_status NAPI_CDECL
|
||||
@@ -197,7 +200,6 @@ napi_close_callback_scope(napi_env env, napi_callback_scope scope);
|
||||
|
||||
#if NAPI_VERSION >= 4
|
||||
|
||||
#ifndef __wasm32__
|
||||
// Calling into JS from other threads
|
||||
NAPI_EXTERN napi_status NAPI_CDECL
|
||||
napi_create_threadsafe_function(napi_env env,
|
||||
@@ -231,7 +233,6 @@ napi_unref_threadsafe_function(napi_env env, napi_threadsafe_function func);
|
||||
|
||||
NAPI_EXTERN napi_status NAPI_CDECL
|
||||
napi_ref_threadsafe_function(napi_env env, napi_threadsafe_function func);
|
||||
#endif // __wasm32__
|
||||
|
||||
#endif // NAPI_VERSION >= 4
|
||||
|
||||
|
||||
Reference in new issue
Block a user