MIRROR: javascript for 馃悳's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at mir/inline-method 174 lines 4.2 kB view raw
1#ifndef ANT_NAPI_H 2#define ANT_NAPI_H 3 4#include "types.h" 5 6#include <stdbool.h> 7#include <stdint.h> 8 9#ifndef NAPI_AUTO_LENGTH 10#define NAPI_AUTO_LENGTH SIZE_MAX 11#endif 12 13#ifndef NAPI_CDECL 14#ifdef _WIN32 15#define NAPI_CDECL __cdecl 16#else 17#define NAPI_CDECL 18#endif 19#endif 20 21#ifndef NAPI_EXTERN 22#if defined(_WIN32) 23#define NAPI_EXTERN __declspec(dllexport) 24#else 25#define NAPI_EXTERN __attribute__((visibility("default"), used)) 26#endif 27#endif 28 29typedef ant_value_t napi_value; 30#define NAPI_MODULE_VERSION 1 31 32typedef struct ant_napi_env__* napi_env; 33typedef napi_env node_api_basic_env; 34 35typedef struct napi_ref__* napi_ref; 36typedef struct napi_handle_scope__* napi_handle_scope; 37typedef struct napi_escapable_handle_scope__* napi_escapable_handle_scope; 38typedef struct napi_callback_info__* napi_callback_info; 39typedef struct napi_deferred__* napi_deferred; 40 41typedef struct napi_callback_scope__* napi_callback_scope; 42typedef struct napi_async_context__* napi_async_context; 43typedef struct napi_async_work__* napi_async_work; 44typedef struct napi_threadsafe_function__* napi_threadsafe_function; 45 46typedef enum { 47 napi_default = 0, 48 napi_writable = 1 << 0, 49 napi_enumerable = 1 << 1, 50 napi_configurable = 1 << 2, 51 napi_static = 1 << 10, 52} napi_property_attributes; 53 54typedef enum { 55 napi_undefined, 56 napi_null, 57 napi_boolean, 58 napi_number, 59 napi_string, 60 napi_symbol, 61 napi_object, 62 napi_function, 63 napi_external, 64 napi_bigint, 65} napi_valuetype; 66 67typedef enum { 68 napi_int8_array, 69 napi_uint8_array, 70 napi_uint8_clamped_array, 71 napi_int16_array, 72 napi_uint16_array, 73 napi_int32_array, 74 napi_uint32_array, 75 napi_float32_array, 76 napi_float64_array, 77 napi_bigint64_array, 78 napi_biguint64_array, 79} napi_typedarray_type; 80 81typedef enum { 82 napi_ok, 83 napi_invalid_arg, 84 napi_object_expected, 85 napi_string_expected, 86 napi_name_expected, 87 napi_function_expected, 88 napi_number_expected, 89 napi_boolean_expected, 90 napi_array_expected, 91 napi_generic_failure, 92 napi_pending_exception, 93 napi_cancelled, 94 napi_escape_called_twice, 95 napi_handle_scope_mismatch, 96 napi_callback_scope_mismatch, 97 napi_queue_full, 98 napi_closing, 99 napi_bigint_expected, 100 napi_date_expected, 101 napi_arraybuffer_expected, 102 napi_detachable_arraybuffer_expected, 103 napi_would_deadlock, 104 napi_no_external_buffers_allowed, 105 napi_cannot_run_js, 106} napi_status; 107 108typedef napi_value(NAPI_CDECL* napi_callback)(napi_env env, napi_callback_info info); 109typedef void(NAPI_CDECL* napi_finalize)(napi_env env, void* finalize_data, void* finalize_hint); 110typedef napi_finalize node_api_basic_finalize; 111 112typedef struct { 113 const char* utf8name; 114 napi_value name; 115 napi_callback method; 116 napi_callback getter; 117 napi_callback setter; 118 napi_value value; 119 napi_property_attributes attributes; 120 void* data; 121} napi_property_descriptor; 122 123typedef struct { 124 const char* error_message; 125 void* engine_reserved; 126 uint32_t engine_error_code; 127 napi_status error_code; 128} napi_extended_error_info; 129 130typedef struct { 131 uint32_t major; 132 uint32_t minor; 133 uint32_t patch; 134 const char* release; 135} napi_node_version; 136 137typedef void(NAPI_CDECL* napi_cleanup_hook)(void* arg); 138typedef void(NAPI_CDECL* napi_async_execute_callback)(napi_env env, void* data); 139typedef void(NAPI_CDECL* napi_async_complete_callback)(napi_env env, napi_status status, void* data); 140 141typedef void(NAPI_CDECL* napi_threadsafe_function_call_js)( 142 napi_env env, 143 napi_value js_callback, 144 void* context, 145 void* data 146); 147 148typedef enum { 149 napi_tsfn_release, 150 napi_tsfn_abort 151} napi_threadsafe_function_release_mode; 152 153typedef enum { 154 napi_tsfn_nonblocking, 155 napi_tsfn_blocking 156} napi_threadsafe_function_call_mode; 157 158typedef napi_value(NAPI_CDECL* napi_addon_register_func)(napi_env env, napi_value exports); 159 160typedef struct napi_module { 161 int nm_version; 162 unsigned int nm_flags; 163 const char* nm_filename; 164 napi_addon_register_func nm_register_func; 165 const char* nm_modname; 166 void* nm_priv; 167 void* reserved[4]; 168} napi_module; 169 170napi_env ant_napi_get_env(ant_t *js); 171ant_value_t napi_process_dlopen_js(ant_t *js, ant_value_t *args, int nargs); 172ant_value_t napi_load_native_module(ant_t *js, const char *module_path, ant_value_t ns); 173 174#endif