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