| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,8 +2,8 @@ | |||
| 2 | 2 | #define SRC_JS_NATIVE_API_H_ | |
| 3 | 3 | ||
| 4 | 4 | // This file needs to be compatible with C compilers. | |
| 5 | - #include <stddef.h> // NOLINT(modernize-deprecated-headers) | ||
| 6 | 5 | #include <stdbool.h> // NOLINT(modernize-deprecated-headers) | |
| 6 | + #include <stddef.h> // NOLINT(modernize-deprecated-headers) | ||
| 7 | 7 | ||
| 8 | 8 | // Use INT_MAX, this should only be consumed by the pre-processor anyway. | |
| 9 | 9 | #define NAPI_VERSION_EXPERIMENTAL 2147483647 | |
@@ -26,14 +26,15 @@ | |||
| 26 | 26 | // If you need __declspec(dllimport), either include <node_api.h> instead, or | |
| 27 | 27 | // define NAPI_EXTERN as __declspec(dllimport) on the compiler's command line. | |
| 28 | 28 | #ifndef NAPI_EXTERN | |
| 29 | - #ifdef _WIN32 | ||
| 30 | - #define NAPI_EXTERN __declspec(dllexport) | ||
| 31 | - #elif defined(__wasm32__) | ||
| 32 | - #define NAPI_EXTERN __attribute__((visibility("default"))) \ | ||
| 33 | - __attribute__((__import_module__("napi"))) | ||
| 34 | - #else | ||
| 35 | - #define NAPI_EXTERN __attribute__((visibility("default"))) | ||
| 36 | - #endif | ||
| 29 | + #ifdef _WIN32 | ||
| 30 | + #define NAPI_EXTERN __declspec(dllexport) | ||
| 31 | + #elif defined(__wasm32__) | ||
| 32 | + #define NAPI_EXTERN \ | ||
| 33 | + __attribute__((visibility("default"))) \ | ||
| 34 | + __attribute__((__import_module__("napi"))) | ||
| 35 | + #else | ||
| 36 | + #define NAPI_EXTERN __attribute__((visibility("default"))) | ||
| 37 | + #endif | ||
| 37 | 38 | #endif | |
| 38 | 39 | ||
| 39 | 40 | #define NAPI_AUTO_LENGTH SIZE_MAX | |
@@ -49,8 +50,7 @@ | |||
| 49 | 50 | EXTERN_C_START | |
| 50 | 51 | ||
| 51 | 52 | NAPI_EXTERN napi_status | |
| 52 | - napi_get_last_error_info(napi_env env, | ||
| 53 | - const napi_extended_error_info** result); | ||
| 53 | + napi_get_last_error_info(napi_env env, const napi_extended_error_info** result); | ||
| 54 | 54 | ||
| 55 | 55 | // Getters for defined singletons | |
| 56 | 56 | NAPI_EXTERN napi_status napi_get_undefined(napi_env env, napi_value* result); | |
@@ -145,18 +145,12 @@ NAPI_EXTERN napi_status napi_get_value_bool(napi_env env, | |||
| 145 | 145 | bool* result); | |
| 146 | 146 | ||
| 147 | 147 | // Copies LATIN-1 encoded bytes from a string into a buffer. | |
| 148 | - NAPI_EXTERN napi_status napi_get_value_string_latin1(napi_env env, | ||
| 149 | - napi_value value, | ||
| 150 | - char* buf, | ||
| 151 | - size_t bufsize, | ||
| 152 | - size_t* result); | ||
| 148 | + NAPI_EXTERN napi_status napi_get_value_string_latin1( | ||
| 149 | + napi_env env, napi_value value, char* buf, size_t bufsize, size_t* result); | ||
| 153 | 150 | ||
| 154 | 151 | // Copies UTF-8 encoded bytes from a string into a buffer. | |
| 155 | - NAPI_EXTERN napi_status napi_get_value_string_utf8(napi_env env, | ||
| 156 | - napi_value value, | ||
| 157 | - char* buf, | ||
| 158 | - size_t bufsize, | ||
| 159 | - size_t* result); | ||
| 152 | + NAPI_EXTERN napi_status napi_get_value_string_utf8( | ||
| 153 | + napi_env env, napi_value value, char* buf, size_t bufsize, size_t* result); | ||
| 160 | 154 | ||
| 161 | 155 | // Copies UTF-16 encoded bytes from a string into a buffer. | |
| 162 | 156 | NAPI_EXTERN napi_status napi_get_value_string_utf16(napi_env env, | |
@@ -208,17 +202,17 @@ NAPI_EXTERN napi_status napi_has_own_property(napi_env env, | |||
| 208 | 202 | napi_value key, | |
| 209 | 203 | bool* result); | |
| 210 | 204 | NAPI_EXTERN napi_status napi_set_named_property(napi_env env, | |
| 211 | - napi_value object, | ||
| 212 | - const char* utf8name, | ||
| 213 | - napi_value value); | ||
| 205 | + napi_value object, | ||
| 206 | + const char* utf8name, | ||
| 207 | + napi_value value); | ||
| 214 | 208 | NAPI_EXTERN napi_status napi_has_named_property(napi_env env, | |
| 215 | - napi_value object, | ||
| 216 | - const char* utf8name, | ||
| 217 | - bool* result); | ||
| 209 | + napi_value object, | ||
| 210 | + const char* utf8name, | ||
| 211 | + bool* result); | ||
| 218 | 212 | NAPI_EXTERN napi_status napi_get_named_property(napi_env env, | |
| 219 | - napi_value object, | ||
| 220 | - const char* utf8name, | ||
| 221 | - napi_value* result); | ||
| 213 | + napi_value object, | ||
| 214 | + const char* utf8name, | ||
| 215 | + napi_value* result); | ||
| 222 | 216 | NAPI_EXTERN napi_status napi_set_element(napi_env env, | |
| 223 | 217 | napi_value object, | |
| 224 | 218 | uint32_t index, | |
@@ -359,12 +353,10 @@ NAPI_EXTERN napi_status napi_open_handle_scope(napi_env env, | |||
| 359 | 353 | napi_handle_scope* result); | |
| 360 | 354 | NAPI_EXTERN napi_status napi_close_handle_scope(napi_env env, | |
| 361 | 355 | napi_handle_scope scope); | |
| 362 | - NAPI_EXTERN napi_status | ||
| 363 | - napi_open_escapable_handle_scope(napi_env env, | ||
| 364 | - napi_escapable_handle_scope* result); | ||
| 365 | - NAPI_EXTERN napi_status | ||
| 366 | - napi_close_escapable_handle_scope(napi_env env, | ||
| 367 | - napi_escapable_handle_scope scope); | ||
| 356 | + NAPI_EXTERN napi_status napi_open_escapable_handle_scope( | ||
| 357 | + napi_env env, napi_escapable_handle_scope* result); | ||
| 358 | + NAPI_EXTERN napi_status napi_close_escapable_handle_scope( | ||
| 359 | + napi_env env, napi_escapable_handle_scope scope); | ||
| 368 | 360 | ||
| 369 | 361 | NAPI_EXTERN napi_status napi_escape_handle(napi_env env, | |
| 370 | 362 | napi_escapable_handle_scope scope, | |
@@ -377,11 +369,11 @@ NAPI_EXTERN napi_status napi_throw_error(napi_env env, | |||
| 377 | 369 | const char* code, | |
| 378 | 370 | const char* msg); | |
| 379 | 371 | NAPI_EXTERN napi_status napi_throw_type_error(napi_env env, | |
| 380 | - const char* code, | ||
| 381 | - const char* msg); | ||
| 372 | + const char* code, | ||
| 373 | + const char* msg); | ||
| 382 | 374 | NAPI_EXTERN napi_status napi_throw_range_error(napi_env env, | |
| 383 | - const char* code, | ||
| 384 | - const char* msg); | ||
| 375 | + const char* code, | ||
| 376 | + const char* msg); | ||
| 385 | 377 | #ifdef NAPI_EXPERIMENTAL | |
| 386 | 378 | NAPI_EXTERN napi_status node_api_throw_syntax_error(napi_env env, | |
| 387 | 379 | const char* code, | |
@@ -542,8 +534,7 @@ NAPI_EXTERN napi_status napi_set_instance_data(napi_env env, | |||
| 542 | 534 | napi_finalize finalize_cb, | |
| 543 | 535 | void* finalize_hint); | |
| 544 | 536 | ||
| 545 | - NAPI_EXTERN napi_status napi_get_instance_data(napi_env env, | ||
| 546 | - void** data); | ||
| 537 | + NAPI_EXTERN napi_status napi_get_instance_data(napi_env env, void** data); | ||
| 547 | 538 | #endif // NAPI_VERSION >= 6 | |
| 548 | 539 | ||
| 549 | 540 | #if NAPI_VERSION >= 7 | |
@@ -567,10 +558,8 @@ napi_check_object_type_tag(napi_env env, | |||
| 567 | 558 | napi_value value, | |
| 568 | 559 | const napi_type_tag* type_tag, | |
| 569 | 560 | bool* result); | |
| 570 | - NAPI_EXTERN napi_status napi_object_freeze(napi_env env, | ||
| 571 | - napi_value object); | ||
| 572 | - NAPI_EXTERN napi_status napi_object_seal(napi_env env, | ||
| 573 | - napi_value object); | ||
| 561 | + NAPI_EXTERN napi_status napi_object_freeze(napi_env env, napi_value object); | ||
| 562 | + NAPI_EXTERN napi_status napi_object_seal(napi_env env, napi_value object); | ||
| 574 | 563 | #endif // NAPI_VERSION >= 8 | |
| 575 | 564 | ||
| 576 | 565 | EXTERN_C_END | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,7 +8,7 @@ | |||
| 8 | 8 | #include <stdint.h> // NOLINT(modernize-deprecated-headers) | |
| 9 | 9 | ||
| 10 | 10 | #if !defined __cplusplus || (defined(_MSC_VER) && _MSC_VER < 1900) | |
| 11 | - typedef uint16_t char16_t; | ||
| 11 | + typedef uint16_t char16_t; | ||
| 12 | 12 | #endif | |
| 13 | 13 | ||
| 14 | 14 | // JSVM API types are all opaque pointers for ABI stability | |
@@ -36,9 +36,7 @@ typedef enum { | |||
| 36 | 36 | napi_default_method = napi_writable | napi_configurable, | |
| 37 | 37 | ||
| 38 | 38 | // Default for object properties, like in JS obj[prop]. | |
| 39 | - napi_default_jsproperty = napi_writable | | ||
| 40 | - napi_enumerable | | ||
| 41 | - napi_configurable, | ||
| 39 | + napi_default_jsproperty = napi_writable | napi_enumerable | napi_configurable, | ||
| 42 | 40 | #endif // NAPI_VERSION >= 8 | |
| 43 | 41 | } napi_property_attributes; | |
| 44 | 42 | ||
@@ -102,8 +100,7 @@ typedef enum { | |||
| 102 | 100 | // * the definition of `napi_status` in doc/api/n-api.md to reflect the newly | |
| 103 | 101 | // added value(s). | |
| 104 | 102 | ||
| 105 | - typedef napi_value (*napi_callback)(napi_env env, | ||
| 106 | - napi_callback_info info); | ||
| 103 | + typedef napi_value (*napi_callback)(napi_env env, napi_callback_info info); | ||
| 107 | 104 | typedef void (*napi_finalize)(napi_env env, | |
| 108 | 105 | void* finalize_data, | |
| 109 | 106 | void* finalize_hint); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments