File indexing completed on 2025-02-21 10:05:22
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 typedef struct napi_env__* node_api_nogc_env;
0050 #else
0051 typedef const struct napi_env__* node_api_nogc_env;
0052 #endif
0053
0054 typedef struct napi_value__* napi_value;
0055 typedef struct napi_ref__* napi_ref;
0056 typedef struct napi_handle_scope__* napi_handle_scope;
0057 typedef struct napi_escapable_handle_scope__* napi_escapable_handle_scope;
0058 typedef struct napi_callback_info__* napi_callback_info;
0059 typedef struct napi_deferred__* napi_deferred;
0060
0061 typedef enum {
0062 napi_default = 0,
0063 napi_writable = 1 << 0,
0064 napi_enumerable = 1 << 1,
0065 napi_configurable = 1 << 2,
0066
0067
0068
0069 napi_static = 1 << 10,
0070
0071 #if NAPI_VERSION >= 8
0072
0073 napi_default_method = napi_writable | napi_configurable,
0074
0075
0076 napi_default_jsproperty = napi_writable | napi_enumerable | napi_configurable,
0077 #endif
0078 } napi_property_attributes;
0079
0080 typedef enum {
0081
0082 napi_undefined,
0083 napi_null,
0084 napi_boolean,
0085 napi_number,
0086 napi_string,
0087 napi_symbol,
0088 napi_object,
0089 napi_function,
0090 napi_external,
0091 napi_bigint,
0092 } napi_valuetype;
0093
0094 typedef enum {
0095 napi_int8_array,
0096 napi_uint8_array,
0097 napi_uint8_clamped_array,
0098 napi_int16_array,
0099 napi_uint16_array,
0100 napi_int32_array,
0101 napi_uint32_array,
0102 napi_float32_array,
0103 napi_float64_array,
0104 napi_bigint64_array,
0105 napi_biguint64_array,
0106 } napi_typedarray_type;
0107
0108 typedef enum {
0109 napi_ok,
0110 napi_invalid_arg,
0111 napi_object_expected,
0112 napi_string_expected,
0113 napi_name_expected,
0114 napi_function_expected,
0115 napi_number_expected,
0116 napi_boolean_expected,
0117 napi_array_expected,
0118 napi_generic_failure,
0119 napi_pending_exception,
0120 napi_cancelled,
0121 napi_escape_called_twice,
0122 napi_handle_scope_mismatch,
0123 napi_callback_scope_mismatch,
0124 napi_queue_full,
0125 napi_closing,
0126 napi_bigint_expected,
0127 napi_date_expected,
0128 napi_arraybuffer_expected,
0129 napi_detachable_arraybuffer_expected,
0130 napi_would_deadlock,
0131 napi_no_external_buffers_allowed,
0132 napi_cannot_run_js,
0133 } napi_status;
0134
0135
0136
0137
0138
0139
0140
0141
0142 typedef napi_value(NAPI_CDECL* napi_callback)(napi_env env,
0143 napi_callback_info info);
0144 typedef void(NAPI_CDECL* napi_finalize)(napi_env env,
0145 void* finalize_data,
0146 void* finalize_hint);
0147
0148 #if !defined(NAPI_EXPERIMENTAL) || \
0149 (defined(NAPI_EXPERIMENTAL) && \
0150 defined(NODE_API_EXPERIMENTAL_NOGC_ENV_OPT_OUT))
0151 typedef napi_finalize node_api_nogc_finalize;
0152 #else
0153 typedef void(NAPI_CDECL* node_api_nogc_finalize)(node_api_nogc_env env,
0154 void* finalize_data,
0155 void* finalize_hint);
0156 #endif
0157
0158 typedef struct {
0159
0160 const char* utf8name;
0161 napi_value name;
0162
0163 napi_callback method;
0164 napi_callback getter;
0165 napi_callback setter;
0166 napi_value value;
0167
0168 napi_property_attributes attributes;
0169 void* data;
0170 } napi_property_descriptor;
0171
0172 typedef struct {
0173 const char* error_message;
0174 void* engine_reserved;
0175 uint32_t engine_error_code;
0176 napi_status error_code;
0177 } napi_extended_error_info;
0178
0179 #if NAPI_VERSION >= 6
0180 typedef enum {
0181 napi_key_include_prototypes,
0182 napi_key_own_only
0183 } napi_key_collection_mode;
0184
0185 typedef enum {
0186 napi_key_all_properties = 0,
0187 napi_key_writable = 1,
0188 napi_key_enumerable = 1 << 1,
0189 napi_key_configurable = 1 << 2,
0190 napi_key_skip_strings = 1 << 3,
0191 napi_key_skip_symbols = 1 << 4
0192 } napi_key_filter;
0193
0194 typedef enum {
0195 napi_key_keep_numbers,
0196 napi_key_numbers_to_strings
0197 } napi_key_conversion;
0198 #endif
0199
0200 #if NAPI_VERSION >= 8
0201 typedef struct {
0202 uint64_t lower;
0203 uint64_t upper;
0204 } napi_type_tag;
0205 #endif
0206
0207 #endif