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