Where Online Learning is simpler!
The C and C++ Include Header Files
/usr/include/node/js_native_api_types.h
$ cat -n /usr/include/node/js_native_api_types.h 1 #ifndef SRC_JS_NATIVE_API_TYPES_H_ 2 #define SRC_JS_NATIVE_API_TYPES_H_ 3 4 // This file needs to be compatible with C compilers. 5 // This is a public include file, and these includes have essentially 6 // became part of it's API. 7 #include
// NOLINT(modernize-deprecated-headers) 8 #include
// NOLINT(modernize-deprecated-headers) 9 10 #if !defined __cplusplus || (defined(_MSC_VER) && _MSC_VER < 1900) 11 typedef uint16_t char16_t; 12 #endif 13 14 #ifndef NAPI_CDECL 15 #ifdef _WIN32 16 #define NAPI_CDECL __cdecl 17 #else 18 #define NAPI_CDECL 19 #endif 20 #endif 21 22 // JSVM API types are all opaque pointers for ABI stability 23 // typedef undefined structs instead of void* for compile time type safety 24 typedef struct napi_env__* napi_env; 25 26 // We need to mark APIs which can be called during garbage collection (GC), 27 // meaning that they do not affect the state of the JS engine, and can 28 // therefore be called synchronously from a finalizer that itself runs 29 // synchronously during GC. Such APIs can receive either a `napi_env` or a 30 // `node_api_basic_env` as their first parameter, because we should be able to 31 // also call them during normal, non-garbage-collecting operations, whereas 32 // APIs that affect the state of the JS engine can only receive a `napi_env` as 33 // their first parameter, because we must not call them during GC. In lieu of 34 // inheritance, we use the properties of the const qualifier to accomplish 35 // this, because both a const and a non-const value can be passed to an API 36 // expecting a const value, but only a non-const value can be passed to an API 37 // expecting a non-const value. 38 // 39 // In conjunction with appropriate CFLAGS to warn us if we're passing a const 40 // (basic) environment into an API that expects a non-const environment, and 41 // the definition of basic finalizer function pointer types below, which 42 // receive a basic environment as their first parameter, and can thus only call 43 // basic APIs (unless the user explicitly casts the environment), we achieve 44 // the ability to ensure at compile time that we do not call APIs that affect 45 // the state of the JS engine from a synchronous (basic) finalizer. 46 #if !defined(NAPI_EXPERIMENTAL) || \ 47 (defined(NAPI_EXPERIMENTAL) && \ 48 (defined(NODE_API_EXPERIMENTAL_NOGC_ENV_OPT_OUT) || \ 49 defined(NODE_API_EXPERIMENTAL_BASIC_ENV_OPT_OUT))) 50 typedef struct napi_env__* node_api_nogc_env; 51 #else 52 typedef const struct napi_env__* node_api_nogc_env; 53 #endif 54 typedef node_api_nogc_env node_api_basic_env; 55 56 typedef struct napi_value__* napi_value; 57 typedef struct napi_ref__* napi_ref; 58 typedef struct napi_handle_scope__* napi_handle_scope; 59 typedef struct napi_escapable_handle_scope__* napi_escapable_handle_scope; 60 typedef struct napi_callback_info__* napi_callback_info; 61 typedef struct napi_deferred__* napi_deferred; 62 63 typedef enum { 64 napi_default = 0, 65 napi_writable = 1 << 0, 66 napi_enumerable = 1 << 1, 67 napi_configurable = 1 << 2, 68 69 // Used with napi_define_class to distinguish static properties 70 // from instance properties. Ignored by napi_define_properties. 71 napi_static = 1 << 10, 72 73 #if NAPI_VERSION >= 8 74 // Default for class methods. 75 napi_default_method = napi_writable | napi_configurable, 76 77 // Default for object properties, like in JS obj[prop]. 78 napi_default_jsproperty = napi_writable | napi_enumerable | napi_configurable, 79 #endif // NAPI_VERSION >= 8 80 } napi_property_attributes; 81 82 typedef enum { 83 // ES6 types (corresponds to typeof) 84 napi_undefined, 85 napi_null, 86 napi_boolean, 87 napi_number, 88 napi_string, 89 napi_symbol, 90 napi_object, 91 napi_function, 92 napi_external, 93 napi_bigint, 94 } napi_valuetype; 95 96 typedef enum { 97 napi_int8_array, 98 napi_uint8_array, 99 napi_uint8_clamped_array, 100 napi_int16_array, 101 napi_uint16_array, 102 napi_int32_array, 103 napi_uint32_array, 104 napi_float32_array, 105 napi_float64_array, 106 napi_bigint64_array, 107 napi_biguint64_array, 108 } napi_typedarray_type; 109 110 typedef enum { 111 napi_ok, 112 napi_invalid_arg, 113 napi_object_expected, 114 napi_string_expected, 115 napi_name_expected, 116 napi_function_expected, 117 napi_number_expected, 118 napi_boolean_expected, 119 napi_array_expected, 120 napi_generic_failure, 121 napi_pending_exception, 122 napi_cancelled, 123 napi_escape_called_twice, 124 napi_handle_scope_mismatch, 125 napi_callback_scope_mismatch, 126 napi_queue_full, 127 napi_closing, 128 napi_bigint_expected, 129 napi_date_expected, 130 napi_arraybuffer_expected, 131 napi_detachable_arraybuffer_expected, 132 napi_would_deadlock, // unused 133 napi_no_external_buffers_allowed, 134 napi_cannot_run_js, 135 } napi_status; 136 // Note: when adding a new enum value to `napi_status`, please also update 137 // * `const int last_status` in the definition of `napi_get_last_error_info()' 138 // in file js_native_api_v8.cc. 139 // * `const char* error_messages[]` in file js_native_api_v8.cc with a brief 140 // message explaining the error. 141 // * the definition of `napi_status` in doc/api/n-api.md to reflect the newly 142 // added value(s). 143 144 typedef napi_value(NAPI_CDECL* napi_callback)(napi_env env, 145 napi_callback_info info); 146 typedef void(NAPI_CDECL* napi_finalize)(napi_env env, 147 void* finalize_data, 148 void* finalize_hint); 149 150 #if !defined(NAPI_EXPERIMENTAL) || \ 151 (defined(NAPI_EXPERIMENTAL) && \ 152 (defined(NODE_API_EXPERIMENTAL_NOGC_ENV_OPT_OUT) || \ 153 defined(NODE_API_EXPERIMENTAL_BASIC_ENV_OPT_OUT))) 154 typedef napi_finalize node_api_nogc_finalize; 155 #else 156 typedef void(NAPI_CDECL* node_api_nogc_finalize)(node_api_nogc_env env, 157 void* finalize_data, 158 void* finalize_hint); 159 #endif 160 typedef node_api_nogc_finalize node_api_basic_finalize; 161 162 typedef struct { 163 // One of utf8name or name should be NULL. 164 const char* utf8name; 165 napi_value name; 166 167 napi_callback method; 168 napi_callback getter; 169 napi_callback setter; 170 napi_value value; 171 172 napi_property_attributes attributes; 173 void* data; 174 } napi_property_descriptor; 175 176 typedef struct { 177 const char* error_message; 178 void* engine_reserved; 179 uint32_t engine_error_code; 180 napi_status error_code; 181 } napi_extended_error_info; 182 183 #if NAPI_VERSION >= 6 184 typedef enum { 185 napi_key_include_prototypes, 186 napi_key_own_only 187 } napi_key_collection_mode; 188 189 typedef enum { 190 napi_key_all_properties = 0, 191 napi_key_writable = 1, 192 napi_key_enumerable = 1 << 1, 193 napi_key_configurable = 1 << 2, 194 napi_key_skip_strings = 1 << 3, 195 napi_key_skip_symbols = 1 << 4 196 } napi_key_filter; 197 198 typedef enum { 199 napi_key_keep_numbers, 200 napi_key_numbers_to_strings 201 } napi_key_conversion; 202 #endif // NAPI_VERSION >= 6 203 204 #if NAPI_VERSION >= 8 205 typedef struct { 206 uint64_t lower; 207 uint64_t upper; 208 } napi_type_tag; 209 #endif // NAPI_VERSION >= 8 210 211 #endif // SRC_JS_NATIVE_API_TYPES_H_
Contact us
|
About us
|
Term of use
|
Copyright © 2000-2025 MyWebUniversity.com ™