File indexing completed on 2026-09-06 09:12:13
0001 #ifndef SRC_JS_NATIVE_API_TYPES_H_
0002 #define SRC_JS_NATIVE_API_TYPES_H_
0003
0004
0005 #define NAPI_VERSION_EXPERIMENTAL 2147483647
0006 #ifndef NAPI_VERSION
0007 #ifdef NAPI_EXPERIMENTAL
0008 #define NAPI_VERSION NAPI_VERSION_EXPERIMENTAL
0009 #else
0010
0011
0012
0013
0014
0015 #define NAPI_VERSION 8
0016 #endif
0017 #endif
0018
0019 #if defined(NAPI_EXPERIMENTAL) && \
0020 !defined(NODE_API_EXPERIMENTAL_NO_WARNING) && \
0021 !defined(NODE_WANT_INTERNALS)
0022 #ifdef _MSC_VER
0023 #pragma message("NAPI_EXPERIMENTAL is enabled. " \
0024 "Experimental features may be unstable.")
0025 #else
0026 #warning "NAPI_EXPERIMENTAL is enabled. " \
0027 "Experimental features may be unstable."
0028 #endif
0029 #endif
0030
0031
0032
0033
0034 #include <stddef.h> // NOLINT(modernize-deprecated-headers)
0035 #include <stdint.h> // NOLINT(modernize-deprecated-headers)
0036
0037 #if !defined __cplusplus || (defined(_MSC_VER) && _MSC_VER < 1900)
0038 typedef uint16_t char16_t;
0039 #endif
0040
0041 #ifndef NAPI_CDECL
0042 #ifdef _WIN32
0043 #define NAPI_CDECL __cdecl
0044 #else
0045 #define NAPI_CDECL
0046 #endif
0047 #endif
0048
0049
0050
0051 typedef struct napi_env__* napi_env;
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073 #if !defined(NAPI_EXPERIMENTAL) || \
0074 (defined(NAPI_EXPERIMENTAL) && \
0075 (defined(NODE_API_EXPERIMENTAL_NOGC_ENV_OPT_OUT) || \
0076 defined(NODE_API_EXPERIMENTAL_BASIC_ENV_OPT_OUT)))
0077 typedef struct napi_env__* node_api_nogc_env;
0078 #else
0079 typedef const struct napi_env__* node_api_nogc_env;
0080 #endif
0081 typedef node_api_nogc_env node_api_basic_env;
0082
0083 typedef struct napi_value__* napi_value;
0084 typedef struct napi_ref__* napi_ref;
0085 typedef struct napi_handle_scope__* napi_handle_scope;
0086 typedef struct napi_escapable_handle_scope__* napi_escapable_handle_scope;
0087 typedef struct napi_callback_info__* napi_callback_info;
0088 typedef struct napi_deferred__* napi_deferred;
0089
0090 typedef enum {
0091 napi_default = 0,
0092 napi_writable = 1 << 0,
0093 napi_enumerable = 1 << 1,
0094 napi_configurable = 1 << 2,
0095
0096
0097
0098 napi_static = 1 << 10,
0099
0100 #if NAPI_VERSION >= 8
0101
0102 napi_default_method = napi_writable | napi_configurable,
0103
0104
0105 napi_default_jsproperty = napi_writable | napi_enumerable | napi_configurable,
0106 #endif
0107 } napi_property_attributes;
0108
0109 typedef enum {
0110
0111 napi_undefined,
0112 napi_null,
0113 napi_boolean,
0114 napi_number,
0115 napi_string,
0116 napi_symbol,
0117 napi_object,
0118 napi_function,
0119 napi_external,
0120 napi_bigint,
0121 } napi_valuetype;
0122
0123 typedef enum {
0124 napi_int8_array,
0125 napi_uint8_array,
0126 napi_uint8_clamped_array,
0127 napi_int16_array,
0128 napi_uint16_array,
0129 napi_int32_array,
0130 napi_uint32_array,
0131 napi_float32_array,
0132 napi_float64_array,
0133 napi_bigint64_array,
0134 napi_biguint64_array,
0135 #define NODE_API_HAS_FLOAT16_ARRAY
0136 napi_float16_array,
0137 } napi_typedarray_type;
0138
0139 typedef enum {
0140 napi_ok,
0141 napi_invalid_arg,
0142 napi_object_expected,
0143 napi_string_expected,
0144 napi_name_expected,
0145 napi_function_expected,
0146 napi_number_expected,
0147 napi_boolean_expected,
0148 napi_array_expected,
0149 napi_generic_failure,
0150 napi_pending_exception,
0151 napi_cancelled,
0152 napi_escape_called_twice,
0153 napi_handle_scope_mismatch,
0154 napi_callback_scope_mismatch,
0155 napi_queue_full,
0156 napi_closing,
0157 napi_bigint_expected,
0158 napi_date_expected,
0159 napi_arraybuffer_expected,
0160 napi_detachable_arraybuffer_expected,
0161 napi_would_deadlock,
0162 napi_no_external_buffers_allowed,
0163 napi_cannot_run_js,
0164 } napi_status;
0165
0166
0167
0168
0169
0170
0171
0172
0173 typedef napi_value(NAPI_CDECL* napi_callback)(napi_env env,
0174 napi_callback_info info);
0175 typedef void(NAPI_CDECL* napi_finalize)(napi_env env,
0176 void* finalize_data,
0177 void* finalize_hint);
0178
0179 #if !defined(NAPI_EXPERIMENTAL) || \
0180 (defined(NAPI_EXPERIMENTAL) && \
0181 (defined(NODE_API_EXPERIMENTAL_NOGC_ENV_OPT_OUT) || \
0182 defined(NODE_API_EXPERIMENTAL_BASIC_ENV_OPT_OUT)))
0183 typedef napi_finalize node_api_nogc_finalize;
0184 #else
0185 typedef void(NAPI_CDECL* node_api_nogc_finalize)(node_api_nogc_env env,
0186 void* finalize_data,
0187 void* finalize_hint);
0188 #endif
0189 typedef node_api_nogc_finalize node_api_basic_finalize;
0190
0191
0192 typedef void(NAPI_CDECL* node_api_noenv_finalize)(void* finalize_data,
0193 void* finalize_hint);
0194
0195 typedef struct {
0196
0197 const char* utf8name;
0198 napi_value name;
0199
0200 napi_callback method;
0201 napi_callback getter;
0202 napi_callback setter;
0203 napi_value value;
0204
0205 napi_property_attributes attributes;
0206 void* data;
0207 } napi_property_descriptor;
0208
0209 typedef struct {
0210 const char* error_message;
0211 void* engine_reserved;
0212 uint32_t engine_error_code;
0213 napi_status error_code;
0214 } napi_extended_error_info;
0215
0216 #if NAPI_VERSION >= 6
0217 typedef enum {
0218 napi_key_include_prototypes,
0219 napi_key_own_only
0220 } napi_key_collection_mode;
0221
0222 typedef enum {
0223 napi_key_all_properties = 0,
0224 napi_key_writable = 1,
0225 napi_key_enumerable = 1 << 1,
0226 napi_key_configurable = 1 << 2,
0227 napi_key_skip_strings = 1 << 3,
0228 napi_key_skip_symbols = 1 << 4
0229 } napi_key_filter;
0230
0231 typedef enum {
0232 napi_key_keep_numbers,
0233 napi_key_numbers_to_strings
0234 } napi_key_conversion;
0235 #endif
0236
0237 #if NAPI_VERSION >= 8
0238 typedef struct {
0239 uint64_t lower;
0240 uint64_t upper;
0241 } napi_type_tag;
0242 #endif
0243
0244 #endif