Skip to content

Commit

Permalink
emnapi.h
Browse files Browse the repository at this point in the history
  • Loading branch information
toyobayashi committed Jun 19, 2021
1 parent bf921c1 commit 214f135
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 21 deletions.
15 changes: 15 additions & 0 deletions include/common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef EMNAPI_INCLUDE_COMMON_H_
#define EMNAPI_INCLUDE_COMMON_H_

#define NAPI_EXTERN __attribute__((visibility("default"))) \
__attribute__((__import_module__("env")))

#ifdef __cplusplus
#define EXTERN_C_START extern "C" {
#define EXTERN_C_END }
#else
#define EXTERN_C_START
#define EXTERN_C_END
#endif

#endif
24 changes: 24 additions & 0 deletions include/emnapi.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef EMNAPI_INCLUDE_EMNAPI_H_
#define EMNAPI_INCLUDE_EMNAPI_H_

#include "js_native_api_types.h"
#include "common.h"

EXTERN_C_START

NAPI_EXTERN
napi_status emnapi_get_module_property(napi_env env,
const char* utf8name,
napi_value* result);

NAPI_EXTERN
napi_status emnapi_create_external_uint8array(napi_env env,
void* external_data,
size_t byte_length,
napi_finalize finalize_cb,
void* finalize_hint,
napi_value* result);

EXTERN_C_END

#endif
22 changes: 1 addition & 21 deletions include/js_native_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,10 @@
#endif

#include "js_native_api_types.h"

// If you need __declspec(dllimport), either include <node_api.h> instead, or
// define NAPI_EXTERN as __declspec(dllimport) on the compiler's command line.
#ifndef NAPI_EXTERN
#ifdef _WIN32
#define NAPI_EXTERN __declspec(dllexport)
#elif defined(__wasm32__)
#define NAPI_EXTERN __attribute__((visibility("default"))) \
__attribute__((__import_module__("env")))
#else
#define NAPI_EXTERN __attribute__((visibility("default")))
#endif
#endif
#include "common.h"

#define NAPI_AUTO_LENGTH SIZE_MAX

#ifdef __cplusplus
#define EXTERN_C_START extern "C" {
#define EXTERN_C_END }
#else
#define EXTERN_C_START
#define EXTERN_C_END
#endif

EXTERN_C_START

NAPI_EXTERN napi_status
Expand Down

0 comments on commit 214f135

Please sign in to comment.