@kungfu-tech/libnode-win32-x64 22.22.3-kf.0 → 22.22.3-kf.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/node/include/acorn_version.h +6 -0
- package/dist/node/include/aliased_buffer-inl.h +244 -0
- package/dist/node/include/aliased_buffer.h +206 -0
- package/dist/node/include/aliased_struct-inl.h +54 -0
- package/dist/node/include/aliased_struct.h +63 -0
- package/dist/node/include/amaro_version.h +6 -0
- package/dist/node/include/async_context_frame.h +33 -0
- package/dist/node/include/async_wrap-inl.h +96 -0
- package/dist/node/include/async_wrap.h +243 -0
- package/dist/node/include/base_object-inl.h +335 -0
- package/dist/node/include/base_object.h +342 -0
- package/dist/node/include/base_object_types.h +74 -0
- package/dist/node/include/blob_serializer_deserializer-inl.h +385 -0
- package/dist/node/include/blob_serializer_deserializer.h +132 -0
- package/dist/node/include/callback_queue-inl.h +97 -0
- package/dist/node/include/callback_queue.h +79 -0
- package/dist/node/include/cares_wrap.h +447 -0
- package/dist/node/include/cjs_module_lexer_version.h +6 -0
- package/dist/node/include/cleanup_queue-inl.h +36 -0
- package/dist/node/include/cleanup_queue.h +79 -0
- package/dist/node/include/compile_cache.h +104 -0
- package/dist/node/include/connect_wrap.h +26 -0
- package/dist/node/include/connection_wrap.h +30 -0
- package/dist/node/include/cppgc/allocation.h +310 -0
- package/dist/node/include/cppgc/common.h +28 -0
- package/dist/node/include/cppgc/cross-thread-persistent.h +466 -0
- package/dist/node/include/cppgc/custom-space.h +97 -0
- package/dist/node/include/cppgc/default-platform.h +67 -0
- package/dist/node/include/cppgc/ephemeron-pair.h +30 -0
- package/dist/node/include/cppgc/explicit-management.h +100 -0
- package/dist/node/include/cppgc/garbage-collected.h +106 -0
- package/dist/node/include/cppgc/heap-consistency.h +309 -0
- package/dist/node/include/cppgc/heap-handle.h +48 -0
- package/dist/node/include/cppgc/heap-state.h +82 -0
- package/dist/node/include/cppgc/heap-statistics.h +120 -0
- package/dist/node/include/cppgc/heap.h +202 -0
- package/dist/node/include/cppgc/internal/api-constants.h +87 -0
- package/dist/node/include/cppgc/internal/atomic-entry-flag.h +48 -0
- package/dist/node/include/cppgc/internal/base-page-handle.h +45 -0
- package/dist/node/include/cppgc/internal/caged-heap-local-data.h +121 -0
- package/dist/node/include/cppgc/internal/caged-heap.h +68 -0
- package/dist/node/include/cppgc/internal/compiler-specific.h +38 -0
- package/dist/node/include/cppgc/internal/finalizer-trait.h +93 -0
- package/dist/node/include/cppgc/internal/gc-info.h +148 -0
- package/dist/node/include/cppgc/internal/logging.h +50 -0
- package/dist/node/include/cppgc/internal/member-storage.h +256 -0
- package/dist/node/include/cppgc/internal/name-trait.h +137 -0
- package/dist/node/include/cppgc/internal/persistent-node.h +214 -0
- package/dist/node/include/cppgc/internal/pointer-policies.h +243 -0
- package/dist/node/include/cppgc/internal/write-barrier.h +487 -0
- package/dist/node/include/cppgc/liveness-broker.h +78 -0
- package/dist/node/include/cppgc/macros.h +35 -0
- package/dist/node/include/cppgc/member.h +629 -0
- package/dist/node/include/cppgc/name-provider.h +65 -0
- package/dist/node/include/cppgc/object-size-trait.h +58 -0
- package/dist/node/include/cppgc/persistent.h +377 -0
- package/dist/node/include/cppgc/platform.h +163 -0
- package/dist/node/include/cppgc/prefinalizer.h +75 -0
- package/dist/node/include/cppgc/process-heap-statistics.h +36 -0
- package/dist/node/include/cppgc/sentinel-pointer.h +39 -0
- package/dist/node/include/cppgc/source-location.h +16 -0
- package/dist/node/include/cppgc/testing.h +106 -0
- package/dist/node/include/cppgc/trace-trait.h +128 -0
- package/dist/node/include/cppgc/type-traits.h +271 -0
- package/dist/node/include/cppgc/visitor.h +504 -0
- package/dist/node/include/crypto/crypto_aes.h +88 -0
- package/dist/node/include/crypto/crypto_bio.h +193 -0
- package/dist/node/include/crypto/crypto_cipher.h +293 -0
- package/dist/node/include/crypto/crypto_clienthello-inl.h +90 -0
- package/dist/node/include/crypto/crypto_clienthello.h +131 -0
- package/dist/node/include/crypto/crypto_common.h +64 -0
- package/dist/node/include/crypto/crypto_context.h +171 -0
- package/dist/node/include/crypto/crypto_dh.h +126 -0
- package/dist/node/include/crypto/crypto_dsa.h +52 -0
- package/dist/node/include/crypto/crypto_ec.h +164 -0
- package/dist/node/include/crypto/crypto_hash.h +91 -0
- package/dist/node/include/crypto/crypto_hkdf.h +61 -0
- package/dist/node/include/crypto/crypto_hmac.h +92 -0
- package/dist/node/include/crypto/crypto_keygen.h +299 -0
- package/dist/node/include/crypto/crypto_keys.h +392 -0
- package/dist/node/include/crypto/crypto_pbkdf2.h +74 -0
- package/dist/node/include/crypto/crypto_random.h +124 -0
- package/dist/node/include/crypto/crypto_rsa.h +136 -0
- package/dist/node/include/crypto/crypto_scrypt.h +85 -0
- package/dist/node/include/crypto/crypto_sig.h +165 -0
- package/dist/node/include/crypto/crypto_spkac.h +21 -0
- package/dist/node/include/crypto/crypto_timing.h +20 -0
- package/dist/node/include/crypto/crypto_tls.h +305 -0
- package/dist/node/include/crypto/crypto_util.h +725 -0
- package/dist/node/include/crypto/crypto_x509.h +140 -0
- package/dist/node/include/dataqueue/queue.h +306 -0
- package/dist/node/include/debug_utils-inl.h +278 -0
- package/dist/node/include/debug_utils.h +196 -0
- package/dist/node/include/diagnosticfilename-inl.h +33 -0
- package/dist/node/include/embedded_data.h +17 -0
- package/dist/node/include/encoding_binding.h +61 -0
- package/dist/node/include/env-inl.h +984 -0
- package/dist/node/include/env.h +1287 -0
- package/dist/node/include/env_properties.h +540 -0
- package/dist/node/include/handle_wrap.h +123 -0
- package/dist/node/include/histogram-inl.h +107 -0
- package/dist/node/include/histogram.h +279 -0
- package/dist/node/include/inspector/io_agent.h +30 -0
- package/dist/node/include/inspector/main_thread_interface.h +116 -0
- package/dist/node/include/inspector/network_agent.h +94 -0
- package/dist/node/include/inspector/network_inspector.h +45 -0
- package/dist/node/include/inspector/network_requests_buffer.h +195 -0
- package/dist/node/include/inspector/network_resource_manager.h +29 -0
- package/dist/node/include/inspector/node_json.h +24 -0
- package/dist/node/include/inspector/node_string.h +101 -0
- package/dist/node/include/inspector/protocol_helper.h +27 -0
- package/dist/node/include/inspector/runtime_agent.h +41 -0
- package/dist/node/include/inspector/target_agent.h +75 -0
- package/dist/node/include/inspector/tracing_agent.h +43 -0
- package/dist/node/include/inspector/worker_agent.h +40 -0
- package/dist/node/include/inspector/worker_inspector.h +124 -0
- package/dist/node/include/inspector_agent.h +165 -0
- package/dist/node/include/inspector_io.h +78 -0
- package/dist/node/include/inspector_profiler.h +149 -0
- package/dist/node/include/inspector_socket.h +60 -0
- package/dist/node/include/inspector_socket_server.h +110 -0
- package/dist/node/include/js_native_api.h +607 -0
- package/dist/node/include/js_native_api_types.h +226 -0
- package/dist/node/include/js_native_api_v8.h +485 -0
- package/dist/node/include/js_native_api_v8_internals.h +45 -0
- package/dist/node/include/js_stream.h +52 -0
- package/dist/node/include/json_utils.h +172 -0
- package/dist/node/include/large_pages/node_large_page.h +34 -0
- package/dist/node/include/libplatform/libplatform-export.h +29 -0
- package/dist/node/include/libplatform/libplatform.h +112 -0
- package/dist/node/include/libplatform/v8-tracing.h +333 -0
- package/dist/node/include/memory_tracker-inl.h +359 -0
- package/dist/node/include/memory_tracker.h +289 -0
- package/dist/node/include/module_wrap.h +216 -0
- package/dist/node/include/node.h +1593 -0
- package/dist/node/include/node_api.h +265 -0
- package/dist/node/include/node_api_internals.h +48 -0
- package/dist/node/include/node_api_types.h +56 -0
- package/dist/node/include/node_binding.h +161 -0
- package/dist/node/include/node_blob.h +159 -0
- package/dist/node/include/node_bob-inl.h +36 -0
- package/dist/node/include/node_bob.h +107 -0
- package/dist/node/include/node_buffer.h +92 -0
- package/dist/node/include/node_builtins.h +220 -0
- package/dist/node/include/node_config_file.h +46 -0
- package/dist/node/include/node_constants.h +82 -0
- package/dist/node/include/node_context_data.h +168 -0
- package/dist/node/include/node_contextify.h +204 -0
- package/dist/node/include/node_crypto.h +56 -0
- package/dist/node/include/node_debug.h +30 -0
- package/dist/node/include/node_dir.h +52 -0
- package/dist/node/include/node_dotenv.h +45 -0
- package/dist/node/include/node_errors.h +380 -0
- package/dist/node/include/node_exit_code.h +54 -0
- package/dist/node/include/node_external_reference.h +165 -0
- package/dist/node/include/node_file-inl.h +406 -0
- package/dist/node/include/node_file.h +537 -0
- package/dist/node/include/node_http2.h +1177 -0
- package/dist/node/include/node_http2_state.h +159 -0
- package/dist/node/include/node_http_common-inl.h +202 -0
- package/dist/node/include/node_http_common.h +535 -0
- package/dist/node/include/node_i18n.h +132 -0
- package/dist/node/include/node_internals.h +483 -0
- package/dist/node/include/node_main_instance.h +67 -0
- package/dist/node/include/node_mem-inl.h +113 -0
- package/dist/node/include/node_mem.h +45 -0
- package/dist/node/include/node_messaging.h +389 -0
- package/dist/node/include/node_metadata.h +164 -0
- package/dist/node/include/node_modules.h +91 -0
- package/dist/node/include/node_mutex.h +323 -0
- package/dist/node/include/node_object_wrap.h +132 -0
- package/dist/node/include/node_options-inl.h +490 -0
- package/dist/node/include/node_options.h +615 -0
- package/dist/node/include/node_perf.h +166 -0
- package/dist/node/include/node_perf_common.h +102 -0
- package/dist/node/include/node_platform.h +238 -0
- package/dist/node/include/node_process-inl.h +26 -0
- package/dist/node/include/node_process.h +112 -0
- package/dist/node/include/node_realm-inl.h +151 -0
- package/dist/node/include/node_realm.h +183 -0
- package/dist/node/include/node_report.h +43 -0
- package/dist/node/include/node_revert.h +82 -0
- package/dist/node/include/node_root_certs.h +3520 -0
- package/dist/node/include/node_sea.h +74 -0
- package/dist/node/include/node_shadow_realm.h +46 -0
- package/dist/node/include/node_snapshot_builder.h +57 -0
- package/dist/node/include/node_snapshotable.h +174 -0
- package/dist/node/include/node_sockaddr-inl.h +257 -0
- package/dist/node/include/node_sockaddr.h +394 -0
- package/dist/node/include/node_sqlite.h +270 -0
- package/dist/node/include/node_stat_watcher.h +73 -0
- package/dist/node/include/node_task_runner.h +92 -0
- package/dist/node/include/node_threadsafe_cow-inl.h +54 -0
- package/dist/node/include/node_threadsafe_cow.h +105 -0
- package/dist/node/include/node_union_bytes.h +81 -0
- package/dist/node/include/node_url.h +96 -0
- package/dist/node/include/node_v8.h +77 -0
- package/dist/node/include/node_v8_platform-inl.h +185 -0
- package/dist/node/include/node_version.h +110 -0
- package/dist/node/include/node_wasi.h +184 -0
- package/dist/node/include/node_wasm_web_api.h +55 -0
- package/dist/node/include/node_watchdog.h +154 -0
- package/dist/node/include/node_webstorage.h +60 -0
- package/dist/node/include/node_worker.h +158 -0
- package/dist/node/include/path.h +33 -0
- package/dist/node/include/permission/addon_permission.h +31 -0
- package/dist/node/include/permission/child_process_permission.h +31 -0
- package/dist/node/include/permission/fs_permission.h +167 -0
- package/dist/node/include/permission/inspector_permission.h +31 -0
- package/dist/node/include/permission/permission.h +138 -0
- package/dist/node/include/permission/permission_base.h +65 -0
- package/dist/node/include/permission/wasi_permission.h +31 -0
- package/dist/node/include/permission/worker_permission.h +31 -0
- package/dist/node/include/pipe_wrap.h +80 -0
- package/dist/node/include/quic/application.h +159 -0
- package/dist/node/include/quic/bindingdata.h +272 -0
- package/dist/node/include/quic/cid.h +127 -0
- package/dist/node/include/quic/data.h +148 -0
- package/dist/node/include/quic/defs.h +245 -0
- package/dist/node/include/quic/endpoint.h +458 -0
- package/dist/node/include/quic/http3.h +15 -0
- package/dist/node/include/quic/logstream.h +81 -0
- package/dist/node/include/quic/packet.h +152 -0
- package/dist/node/include/quic/preferredaddress.h +72 -0
- package/dist/node/include/quic/session.h +443 -0
- package/dist/node/include/quic/sessionticket.h +108 -0
- package/dist/node/include/quic/streams.h +232 -0
- package/dist/node/include/quic/tlscontext.h +227 -0
- package/dist/node/include/quic/tokens.h +256 -0
- package/dist/node/include/quic/transportparams.h +165 -0
- package/dist/node/include/req_wrap-inl.h +171 -0
- package/dist/node/include/req_wrap.h +77 -0
- package/dist/node/include/spawn_sync.h +243 -0
- package/dist/node/include/stream_base-inl.h +173 -0
- package/dist/node/include/stream_base.h +478 -0
- package/dist/node/include/stream_pipe.h +76 -0
- package/dist/node/include/stream_wrap.h +132 -0
- package/dist/node/include/string_bytes.h +113 -0
- package/dist/node/include/string_decoder-inl.h +31 -0
- package/dist/node/include/string_decoder.h +49 -0
- package/dist/node/include/tcp_wrap.h +105 -0
- package/dist/node/include/threadpoolwork-inl.h +70 -0
- package/dist/node/include/timer_wrap-inl.h +32 -0
- package/dist/node/include/timer_wrap.h +85 -0
- package/dist/node/include/timers.h +70 -0
- package/dist/node/include/tracing/agent.h +195 -0
- package/dist/node/include/tracing/node_trace_buffer.h +83 -0
- package/dist/node/include/tracing/node_trace_writer.h +75 -0
- package/dist/node/include/tracing/trace_event.h +722 -0
- package/dist/node/include/tracing/trace_event_common.h +1109 -0
- package/dist/node/include/tracing/traced_value.h +129 -0
- package/dist/node/include/tty_wrap.h +65 -0
- package/dist/node/include/udp_wrap.h +230 -0
- package/dist/node/include/undici_version.h +6 -0
- package/dist/node/include/util-inl.h +700 -0
- package/dist/node/include/util.h +1021 -0
- package/dist/node/include/uv/aix.h +32 -0
- package/dist/node/include/uv/bsd.h +34 -0
- package/dist/node/include/uv/darwin.h +61 -0
- package/dist/node/include/uv/errno.h +483 -0
- package/dist/node/include/uv/linux.h +34 -0
- package/dist/node/include/uv/os390.h +33 -0
- package/dist/node/include/uv/posix.h +31 -0
- package/dist/node/include/uv/sunos.h +44 -0
- package/dist/node/include/uv/threadpool.h +37 -0
- package/dist/node/include/uv/tree.h +521 -0
- package/dist/node/include/uv/unix.h +512 -0
- package/dist/node/include/uv/version.h +43 -0
- package/dist/node/include/uv/win.h +698 -0
- package/dist/node/include/uv.h +1990 -0
- package/dist/node/include/v8-array-buffer.h +525 -0
- package/dist/node/include/v8-callbacks.h +462 -0
- package/dist/node/include/v8-container.h +183 -0
- package/dist/node/include/v8-context.h +485 -0
- package/dist/node/include/v8-cppgc.h +245 -0
- package/dist/node/include/v8-data.h +80 -0
- package/dist/node/include/v8-date.h +48 -0
- package/dist/node/include/v8-debug.h +168 -0
- package/dist/node/include/v8-embedder-heap.h +82 -0
- package/dist/node/include/v8-embedder-state-scope.h +52 -0
- package/dist/node/include/v8-exception.h +223 -0
- package/dist/node/include/v8-extension.h +62 -0
- package/dist/node/include/v8-external.h +37 -0
- package/dist/node/include/v8-fast-api-calls.h +984 -0
- package/dist/node/include/v8-forward.h +82 -0
- package/dist/node/include/v8-function-callback.h +607 -0
- package/dist/node/include/v8-function.h +140 -0
- package/dist/node/include/v8-handle-base.h +137 -0
- package/dist/node/include/v8-initialization.h +289 -0
- package/dist/node/include/v8-inspector-protocol.h +13 -0
- package/dist/node/include/v8-inspector.h +419 -0
- package/dist/node/include/v8-internal.h +1397 -0
- package/dist/node/include/v8-isolate.h +1767 -0
- package/dist/node/include/v8-json.h +47 -0
- package/dist/node/include/v8-local-handle.h +758 -0
- package/dist/node/include/v8-locker.h +138 -0
- package/dist/node/include/v8-maybe.h +160 -0
- package/dist/node/include/v8-memory-span.h +198 -0
- package/dist/node/include/v8-message.h +233 -0
- package/dist/node/include/v8-metrics.h +264 -0
- package/dist/node/include/v8-microtask-queue.h +157 -0
- package/dist/node/include/v8-microtask.h +28 -0
- package/dist/node/include/v8-object.h +824 -0
- package/dist/node/include/v8-persistent-handle.h +582 -0
- package/dist/node/include/v8-platform.h +1358 -0
- package/dist/node/include/v8-primitive-object.h +118 -0
- package/dist/node/include/v8-primitive.h +877 -0
- package/dist/node/include/v8-profiler.h +1302 -0
- package/dist/node/include/v8-promise.h +174 -0
- package/dist/node/include/v8-proxy.h +50 -0
- package/dist/node/include/v8-regexp.h +106 -0
- package/dist/node/include/v8-script.h +904 -0
- package/dist/node/include/v8-snapshot.h +266 -0
- package/dist/node/include/v8-source-location.h +92 -0
- package/dist/node/include/v8-statistics.h +238 -0
- package/dist/node/include/v8-template.h +1297 -0
- package/dist/node/include/v8-traced-handle.h +432 -0
- package/dist/node/include/v8-typed-array.h +390 -0
- package/dist/node/include/v8-unwinder-state.h +31 -0
- package/dist/node/include/v8-unwinder.h +132 -0
- package/dist/node/include/v8-util.h +665 -0
- package/dist/node/include/v8-value-serializer-version.h +24 -0
- package/dist/node/include/v8-value-serializer.h +316 -0
- package/dist/node/include/v8-value.h +655 -0
- package/dist/node/include/v8-version-string.h +38 -0
- package/dist/node/include/v8-version.h +20 -0
- package/dist/node/include/v8-wasm-trap-handler-posix.h +31 -0
- package/dist/node/include/v8-wasm-trap-handler-win.h +28 -0
- package/dist/node/include/v8-wasm.h +201 -0
- package/dist/node/include/v8-weak-callback-info.h +80 -0
- package/dist/node/include/v8.h +88 -0
- package/dist/node/include/v8config.h +981 -0
- package/dist/node/include/zlib_version.h +6 -0
- package/dist/node/libnode.dll +0 -0
- package/dist/node/libnode.lib +0 -0
- package/dist/node/libnodebuildinfo.json +10 -0
- package/dist/node/link_node.lib +0 -0
- package/dist/node/link_node.node +0 -0
- package/libnode.release.json +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,485 @@
|
|
|
1
|
+
#ifndef SRC_JS_NATIVE_API_V8_H_
|
|
2
|
+
#define SRC_JS_NATIVE_API_V8_H_
|
|
3
|
+
|
|
4
|
+
#include "js_native_api_types.h"
|
|
5
|
+
#include "js_native_api_v8_internals.h"
|
|
6
|
+
|
|
7
|
+
inline napi_status napi_clear_last_error(node_api_basic_env env);
|
|
8
|
+
|
|
9
|
+
namespace v8impl {
|
|
10
|
+
|
|
11
|
+
// Base class to track references and finalizers in a doubly linked list.
|
|
12
|
+
class RefTracker {
|
|
13
|
+
public:
|
|
14
|
+
using RefList = RefTracker;
|
|
15
|
+
|
|
16
|
+
RefTracker() = default;
|
|
17
|
+
virtual ~RefTracker() = default;
|
|
18
|
+
virtual void Finalize() {}
|
|
19
|
+
|
|
20
|
+
inline void Link(RefList* list) {
|
|
21
|
+
prev_ = list;
|
|
22
|
+
next_ = list->next_;
|
|
23
|
+
if (next_ != nullptr) {
|
|
24
|
+
next_->prev_ = this;
|
|
25
|
+
}
|
|
26
|
+
list->next_ = this;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
inline void Unlink() {
|
|
30
|
+
if (prev_ != nullptr) {
|
|
31
|
+
prev_->next_ = next_;
|
|
32
|
+
}
|
|
33
|
+
if (next_ != nullptr) {
|
|
34
|
+
next_->prev_ = prev_;
|
|
35
|
+
}
|
|
36
|
+
prev_ = nullptr;
|
|
37
|
+
next_ = nullptr;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static void FinalizeAll(RefList* list) {
|
|
41
|
+
while (list->next_ != nullptr) {
|
|
42
|
+
list->next_->Finalize();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
private:
|
|
47
|
+
RefList* next_ = nullptr;
|
|
48
|
+
RefList* prev_ = nullptr;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
} // end of namespace v8impl
|
|
52
|
+
|
|
53
|
+
struct napi_env__ {
|
|
54
|
+
explicit napi_env__(v8::Local<v8::Context> context,
|
|
55
|
+
int32_t module_api_version)
|
|
56
|
+
: isolate(context->GetIsolate()),
|
|
57
|
+
context_persistent(isolate, context),
|
|
58
|
+
module_api_version(module_api_version) {
|
|
59
|
+
napi_clear_last_error(this);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
inline v8::Local<v8::Context> context() const {
|
|
63
|
+
return v8impl::PersistentToLocal::Strong(context_persistent);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
inline void Ref() { refs++; }
|
|
67
|
+
inline void Unref() {
|
|
68
|
+
if (--refs == 0) DeleteMe();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
virtual bool can_call_into_js() const { return true; }
|
|
72
|
+
|
|
73
|
+
static inline void HandleThrow(napi_env env, v8::Local<v8::Value> value) {
|
|
74
|
+
if (env->terminatedOrTerminating()) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
env->isolate->ThrowException(value);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// i.e. whether v8 exited or is about to exit
|
|
81
|
+
inline bool terminatedOrTerminating() {
|
|
82
|
+
return this->isolate->IsExecutionTerminating() || !can_call_into_js();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// v8 uses a special exception to indicate termination, the
|
|
86
|
+
// `handle_exception` callback should identify such case using
|
|
87
|
+
// terminatedOrTerminating() before actually handle the exception
|
|
88
|
+
template <typename T, typename U = decltype(HandleThrow)>
|
|
89
|
+
inline void CallIntoModule(T&& call, U&& handle_exception = HandleThrow) {
|
|
90
|
+
int open_handle_scopes_before = open_handle_scopes;
|
|
91
|
+
int open_callback_scopes_before = open_callback_scopes;
|
|
92
|
+
napi_clear_last_error(this);
|
|
93
|
+
call(this);
|
|
94
|
+
CHECK_EQ(open_handle_scopes, open_handle_scopes_before);
|
|
95
|
+
CHECK_EQ(open_callback_scopes, open_callback_scopes_before);
|
|
96
|
+
if (!last_exception.IsEmpty()) {
|
|
97
|
+
handle_exception(this, last_exception.Get(this->isolate));
|
|
98
|
+
last_exception.Reset();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
virtual void CallFinalizer(napi_finalize cb, void* data, void* hint) = 0;
|
|
103
|
+
|
|
104
|
+
// Invoke finalizer from V8 garbage collector.
|
|
105
|
+
void InvokeFinalizerFromGC(v8impl::RefTracker* finalizer);
|
|
106
|
+
|
|
107
|
+
// Enqueue the finalizer to the napi_env's own queue of the second pass
|
|
108
|
+
// weak callback.
|
|
109
|
+
// Implementation should drain the queue at the time it is safe to call
|
|
110
|
+
// into JavaScript.
|
|
111
|
+
virtual void EnqueueFinalizer(v8impl::RefTracker* finalizer) {
|
|
112
|
+
pending_finalizers.emplace(finalizer);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Remove the finalizer from the scheduled second pass weak callback queue.
|
|
116
|
+
// The finalizer can be deleted after this call.
|
|
117
|
+
virtual void DequeueFinalizer(v8impl::RefTracker* finalizer) {
|
|
118
|
+
pending_finalizers.erase(finalizer);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
virtual void DeleteMe() {
|
|
122
|
+
// First we must finalize those references that have `napi_finalizer`
|
|
123
|
+
// callbacks. The reason is that addons might store other references which
|
|
124
|
+
// they delete during their `napi_finalizer` callbacks. If we deleted such
|
|
125
|
+
// references here first, they would be doubly deleted when the
|
|
126
|
+
// `napi_finalizer` deleted them subsequently.
|
|
127
|
+
v8impl::RefTracker::FinalizeAll(&finalizing_reflist);
|
|
128
|
+
v8impl::RefTracker::FinalizeAll(&reflist);
|
|
129
|
+
delete this;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
void CheckGCAccess() {
|
|
133
|
+
if (module_api_version == NAPI_VERSION_EXPERIMENTAL && in_gc_finalizer) {
|
|
134
|
+
v8impl::OnFatalError(
|
|
135
|
+
nullptr,
|
|
136
|
+
"Finalizer is calling a function that may affect GC state.\n"
|
|
137
|
+
"The finalizers are run directly from GC and must not affect GC "
|
|
138
|
+
"state.\n"
|
|
139
|
+
"Use `node_api_post_finalizer` from inside of the finalizer to work "
|
|
140
|
+
"around this issue.\n"
|
|
141
|
+
"It schedules the call as a new task in the event loop.");
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
v8::Isolate* const isolate; // Shortcut for context()->GetIsolate()
|
|
146
|
+
v8impl::Persistent<v8::Context> context_persistent;
|
|
147
|
+
|
|
148
|
+
v8impl::Persistent<v8::Value> last_exception;
|
|
149
|
+
|
|
150
|
+
// We store references in two different lists, depending on whether they have
|
|
151
|
+
// `napi_finalizer` callbacks, because we must first finalize the ones that
|
|
152
|
+
// have such a callback. See `~napi_env__()` above for details.
|
|
153
|
+
v8impl::RefTracker::RefList reflist;
|
|
154
|
+
v8impl::RefTracker::RefList finalizing_reflist;
|
|
155
|
+
// The invocation order of the finalizers is not determined.
|
|
156
|
+
std::unordered_set<v8impl::RefTracker*> pending_finalizers;
|
|
157
|
+
napi_extended_error_info last_error;
|
|
158
|
+
int open_handle_scopes = 0;
|
|
159
|
+
int open_callback_scopes = 0;
|
|
160
|
+
int refs = 1;
|
|
161
|
+
void* instance_data = nullptr;
|
|
162
|
+
int32_t module_api_version = NODE_API_DEFAULT_MODULE_API_VERSION;
|
|
163
|
+
bool in_gc_finalizer = false;
|
|
164
|
+
|
|
165
|
+
protected:
|
|
166
|
+
// Should not be deleted directly. Delete with `napi_env__::DeleteMe()`
|
|
167
|
+
// instead.
|
|
168
|
+
virtual ~napi_env__() = default;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
inline napi_status napi_clear_last_error(node_api_basic_env basic_env) {
|
|
172
|
+
napi_env env = const_cast<napi_env>(basic_env);
|
|
173
|
+
env->last_error.error_code = napi_ok;
|
|
174
|
+
env->last_error.engine_error_code = 0;
|
|
175
|
+
env->last_error.engine_reserved = nullptr;
|
|
176
|
+
env->last_error.error_message = nullptr;
|
|
177
|
+
return napi_ok;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
inline napi_status napi_set_last_error(node_api_basic_env basic_env,
|
|
181
|
+
napi_status error_code,
|
|
182
|
+
uint32_t engine_error_code = 0,
|
|
183
|
+
void* engine_reserved = nullptr) {
|
|
184
|
+
napi_env env = const_cast<napi_env>(basic_env);
|
|
185
|
+
env->last_error.error_code = error_code;
|
|
186
|
+
env->last_error.engine_error_code = engine_error_code;
|
|
187
|
+
env->last_error.engine_reserved = engine_reserved;
|
|
188
|
+
return error_code;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
#define RETURN_STATUS_IF_FALSE(env, condition, status) \
|
|
192
|
+
do { \
|
|
193
|
+
if (!(condition)) { \
|
|
194
|
+
return napi_set_last_error((env), (status)); \
|
|
195
|
+
} \
|
|
196
|
+
} while (0)
|
|
197
|
+
|
|
198
|
+
#define RETURN_STATUS_IF_FALSE_WITH_PREAMBLE(env, condition, status) \
|
|
199
|
+
do { \
|
|
200
|
+
if (!(condition)) { \
|
|
201
|
+
return napi_set_last_error( \
|
|
202
|
+
(env), try_catch.HasCaught() ? napi_pending_exception : (status)); \
|
|
203
|
+
} \
|
|
204
|
+
} while (0)
|
|
205
|
+
|
|
206
|
+
#define CHECK_ENV(env) \
|
|
207
|
+
do { \
|
|
208
|
+
if ((env) == nullptr) { \
|
|
209
|
+
return napi_invalid_arg; \
|
|
210
|
+
} \
|
|
211
|
+
} while (0)
|
|
212
|
+
|
|
213
|
+
#define CHECK_ENV_NOT_IN_GC(env) \
|
|
214
|
+
do { \
|
|
215
|
+
CHECK_ENV((env)); \
|
|
216
|
+
(env)->CheckGCAccess(); \
|
|
217
|
+
} while (0)
|
|
218
|
+
|
|
219
|
+
#define CHECK_ARG(env, arg) \
|
|
220
|
+
RETURN_STATUS_IF_FALSE((env), ((arg) != nullptr), napi_invalid_arg)
|
|
221
|
+
|
|
222
|
+
#define CHECK_ARG_WITH_PREAMBLE(env, arg) \
|
|
223
|
+
RETURN_STATUS_IF_FALSE_WITH_PREAMBLE( \
|
|
224
|
+
(env), ((arg) != nullptr), napi_invalid_arg)
|
|
225
|
+
|
|
226
|
+
#define CHECK_MAYBE_EMPTY(env, maybe, status) \
|
|
227
|
+
RETURN_STATUS_IF_FALSE((env), !((maybe).IsEmpty()), (status))
|
|
228
|
+
|
|
229
|
+
#define CHECK_MAYBE_EMPTY_WITH_PREAMBLE(env, maybe, status) \
|
|
230
|
+
RETURN_STATUS_IF_FALSE_WITH_PREAMBLE((env), !((maybe).IsEmpty()), (status))
|
|
231
|
+
|
|
232
|
+
// NAPI_PREAMBLE is not wrapped in do..while: try_catch must have function scope
|
|
233
|
+
#define NAPI_PREAMBLE(env) \
|
|
234
|
+
CHECK_ENV_NOT_IN_GC((env)); \
|
|
235
|
+
RETURN_STATUS_IF_FALSE( \
|
|
236
|
+
(env), (env)->last_exception.IsEmpty(), napi_pending_exception); \
|
|
237
|
+
RETURN_STATUS_IF_FALSE( \
|
|
238
|
+
(env), \
|
|
239
|
+
(env)->can_call_into_js(), \
|
|
240
|
+
(env->module_api_version >= 10 ? napi_cannot_run_js \
|
|
241
|
+
: napi_pending_exception)); \
|
|
242
|
+
napi_clear_last_error((env)); \
|
|
243
|
+
v8impl::TryCatch try_catch((env))
|
|
244
|
+
|
|
245
|
+
#define CHECK_TO_TYPE(env, type, context, result, src, status) \
|
|
246
|
+
do { \
|
|
247
|
+
CHECK_ARG((env), (src)); \
|
|
248
|
+
auto maybe = v8impl::V8LocalValueFromJsValue((src))->To##type((context)); \
|
|
249
|
+
CHECK_MAYBE_EMPTY((env), maybe, (status)); \
|
|
250
|
+
(result) = maybe.ToLocalChecked(); \
|
|
251
|
+
} while (0)
|
|
252
|
+
|
|
253
|
+
#define CHECK_TO_TYPE_WITH_PREAMBLE(env, type, context, result, src, status) \
|
|
254
|
+
do { \
|
|
255
|
+
CHECK_ARG_WITH_PREAMBLE((env), (src)); \
|
|
256
|
+
auto maybe = v8impl::V8LocalValueFromJsValue((src))->To##type((context)); \
|
|
257
|
+
CHECK_MAYBE_EMPTY_WITH_PREAMBLE((env), maybe, (status)); \
|
|
258
|
+
(result) = maybe.ToLocalChecked(); \
|
|
259
|
+
} while (0)
|
|
260
|
+
|
|
261
|
+
#define CHECK_TO_FUNCTION(env, result, src) \
|
|
262
|
+
do { \
|
|
263
|
+
CHECK_ARG((env), (src)); \
|
|
264
|
+
v8::Local<v8::Value> v8value = v8impl::V8LocalValueFromJsValue((src)); \
|
|
265
|
+
RETURN_STATUS_IF_FALSE((env), v8value->IsFunction(), napi_invalid_arg); \
|
|
266
|
+
(result) = v8value.As<v8::Function>(); \
|
|
267
|
+
} while (0)
|
|
268
|
+
|
|
269
|
+
#define CHECK_TO_OBJECT(env, context, result, src) \
|
|
270
|
+
CHECK_TO_TYPE((env), Object, (context), (result), (src), napi_object_expected)
|
|
271
|
+
|
|
272
|
+
#define CHECK_TO_OBJECT_WITH_PREAMBLE(env, context, result, src) \
|
|
273
|
+
CHECK_TO_TYPE_WITH_PREAMBLE( \
|
|
274
|
+
(env), Object, (context), (result), (src), napi_object_expected)
|
|
275
|
+
|
|
276
|
+
#define CHECK_TO_STRING(env, context, result, src) \
|
|
277
|
+
CHECK_TO_TYPE((env), String, (context), (result), (src), napi_string_expected)
|
|
278
|
+
|
|
279
|
+
#define GET_RETURN_STATUS(env) \
|
|
280
|
+
(!try_catch.HasCaught() \
|
|
281
|
+
? napi_ok \
|
|
282
|
+
: napi_set_last_error((env), napi_pending_exception))
|
|
283
|
+
|
|
284
|
+
#define THROW_RANGE_ERROR_IF_FALSE(env, condition, error, message) \
|
|
285
|
+
do { \
|
|
286
|
+
if (!(condition)) { \
|
|
287
|
+
napi_throw_range_error((env), (error), (message)); \
|
|
288
|
+
return napi_set_last_error((env), napi_generic_failure); \
|
|
289
|
+
} \
|
|
290
|
+
} while (0)
|
|
291
|
+
|
|
292
|
+
#define CHECK_MAYBE_EMPTY_WITH_PREAMBLE(env, maybe, status) \
|
|
293
|
+
RETURN_STATUS_IF_FALSE_WITH_PREAMBLE((env), !((maybe).IsEmpty()), (status))
|
|
294
|
+
|
|
295
|
+
#define STATUS_CALL(call) \
|
|
296
|
+
do { \
|
|
297
|
+
napi_status status = (call); \
|
|
298
|
+
if (status != napi_ok) return status; \
|
|
299
|
+
} while (0)
|
|
300
|
+
|
|
301
|
+
namespace v8impl {
|
|
302
|
+
|
|
303
|
+
//=== Conversion between V8 Handles and napi_value ========================
|
|
304
|
+
|
|
305
|
+
// This asserts v8::Local<> will always be implemented with a single
|
|
306
|
+
// pointer field so that we can pass it around as a void*.
|
|
307
|
+
static_assert(sizeof(v8::Local<v8::Value>) == sizeof(napi_value),
|
|
308
|
+
"Cannot convert between v8::Local<v8::Value> and napi_value");
|
|
309
|
+
|
|
310
|
+
inline napi_value JsValueFromV8LocalValue(v8::Local<v8::Value> local) {
|
|
311
|
+
return reinterpret_cast<napi_value>(*local);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
inline v8::Local<v8::Value> V8LocalValueFromJsValue(napi_value v) {
|
|
315
|
+
v8::Local<v8::Value> local;
|
|
316
|
+
memcpy(static_cast<void*>(&local), &v, sizeof(v));
|
|
317
|
+
return local;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// Adapter for napi_finalize callbacks.
|
|
321
|
+
class Finalizer {
|
|
322
|
+
public:
|
|
323
|
+
Finalizer(napi_env env,
|
|
324
|
+
napi_finalize finalize_callback,
|
|
325
|
+
void* finalize_data,
|
|
326
|
+
void* finalize_hint)
|
|
327
|
+
: env_(env),
|
|
328
|
+
finalize_callback_(finalize_callback),
|
|
329
|
+
finalize_data_(finalize_data),
|
|
330
|
+
finalize_hint_(finalize_hint) {}
|
|
331
|
+
|
|
332
|
+
napi_env env() { return env_; }
|
|
333
|
+
void* data() { return finalize_data_; }
|
|
334
|
+
|
|
335
|
+
void ResetEnv();
|
|
336
|
+
void ResetFinalizer();
|
|
337
|
+
void CallFinalizer();
|
|
338
|
+
|
|
339
|
+
private:
|
|
340
|
+
napi_env env_;
|
|
341
|
+
napi_finalize finalize_callback_;
|
|
342
|
+
void* finalize_data_;
|
|
343
|
+
void* finalize_hint_;
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
class TryCatch : public v8::TryCatch {
|
|
347
|
+
public:
|
|
348
|
+
explicit TryCatch(napi_env env) : v8::TryCatch(env->isolate), _env(env) {}
|
|
349
|
+
|
|
350
|
+
~TryCatch() {
|
|
351
|
+
if (HasCaught()) {
|
|
352
|
+
_env->last_exception.Reset(_env->isolate, Exception());
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
private:
|
|
357
|
+
napi_env _env;
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
// Wrapper around Finalizer that can be tracked.
|
|
361
|
+
class TrackedFinalizer final : public RefTracker {
|
|
362
|
+
public:
|
|
363
|
+
static TrackedFinalizer* New(napi_env env,
|
|
364
|
+
napi_finalize finalize_callback,
|
|
365
|
+
void* finalize_data,
|
|
366
|
+
void* finalize_hint);
|
|
367
|
+
~TrackedFinalizer() override;
|
|
368
|
+
|
|
369
|
+
void* data() { return finalizer_.data(); }
|
|
370
|
+
|
|
371
|
+
private:
|
|
372
|
+
TrackedFinalizer(napi_env env,
|
|
373
|
+
napi_finalize finalize_callback,
|
|
374
|
+
void* finalize_data,
|
|
375
|
+
void* finalize_hint);
|
|
376
|
+
void Finalize() override;
|
|
377
|
+
|
|
378
|
+
private:
|
|
379
|
+
Finalizer finalizer_;
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
// Ownership of a reference.
|
|
383
|
+
enum class ReferenceOwnership : uint8_t {
|
|
384
|
+
// The reference is owned by the runtime. No userland call is needed to
|
|
385
|
+
// destruct the reference.
|
|
386
|
+
kRuntime,
|
|
387
|
+
// The reference is owned by the userland. User code is responsible to delete
|
|
388
|
+
// the reference with appropriate node-api calls.
|
|
389
|
+
kUserland,
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
// Wrapper around v8impl::Persistent.
|
|
393
|
+
class Reference : public RefTracker {
|
|
394
|
+
public:
|
|
395
|
+
static Reference* New(napi_env env,
|
|
396
|
+
v8::Local<v8::Value> value,
|
|
397
|
+
uint32_t initial_refcount,
|
|
398
|
+
ReferenceOwnership ownership);
|
|
399
|
+
~Reference() override;
|
|
400
|
+
|
|
401
|
+
uint32_t Ref();
|
|
402
|
+
uint32_t Unref();
|
|
403
|
+
v8::Local<v8::Value> Get(napi_env env);
|
|
404
|
+
|
|
405
|
+
virtual void ResetFinalizer() {}
|
|
406
|
+
virtual void* Data() { return nullptr; }
|
|
407
|
+
|
|
408
|
+
uint32_t refcount() const { return refcount_; }
|
|
409
|
+
ReferenceOwnership ownership() { return ownership_; }
|
|
410
|
+
|
|
411
|
+
protected:
|
|
412
|
+
Reference(napi_env env,
|
|
413
|
+
v8::Local<v8::Value> value,
|
|
414
|
+
uint32_t initial_refcount,
|
|
415
|
+
ReferenceOwnership ownership);
|
|
416
|
+
virtual void CallUserFinalizer() {}
|
|
417
|
+
virtual void InvokeFinalizerFromGC();
|
|
418
|
+
|
|
419
|
+
private:
|
|
420
|
+
static void WeakCallback(const v8::WeakCallbackInfo<Reference>& data);
|
|
421
|
+
void SetWeak();
|
|
422
|
+
void Finalize() override;
|
|
423
|
+
|
|
424
|
+
private:
|
|
425
|
+
v8impl::Persistent<v8::Value> persistent_;
|
|
426
|
+
uint32_t refcount_;
|
|
427
|
+
ReferenceOwnership ownership_;
|
|
428
|
+
bool can_be_weak_;
|
|
429
|
+
};
|
|
430
|
+
|
|
431
|
+
// Reference that can store additional data.
|
|
432
|
+
class ReferenceWithData final : public Reference {
|
|
433
|
+
public:
|
|
434
|
+
static ReferenceWithData* New(napi_env env,
|
|
435
|
+
v8::Local<v8::Value> value,
|
|
436
|
+
uint32_t initial_refcount,
|
|
437
|
+
ReferenceOwnership ownership,
|
|
438
|
+
void* data);
|
|
439
|
+
|
|
440
|
+
void* Data() override { return data_; }
|
|
441
|
+
|
|
442
|
+
private:
|
|
443
|
+
ReferenceWithData(napi_env env,
|
|
444
|
+
v8::Local<v8::Value> value,
|
|
445
|
+
uint32_t initial_refcount,
|
|
446
|
+
ReferenceOwnership ownership,
|
|
447
|
+
void* data);
|
|
448
|
+
|
|
449
|
+
private:
|
|
450
|
+
void* data_;
|
|
451
|
+
};
|
|
452
|
+
|
|
453
|
+
// Reference that has a user finalizer callback.
|
|
454
|
+
class ReferenceWithFinalizer final : public Reference {
|
|
455
|
+
public:
|
|
456
|
+
static ReferenceWithFinalizer* New(napi_env env,
|
|
457
|
+
v8::Local<v8::Value> value,
|
|
458
|
+
uint32_t initial_refcount,
|
|
459
|
+
ReferenceOwnership ownership,
|
|
460
|
+
napi_finalize finalize_callback,
|
|
461
|
+
void* finalize_data,
|
|
462
|
+
void* finalize_hint);
|
|
463
|
+
~ReferenceWithFinalizer() override;
|
|
464
|
+
|
|
465
|
+
void ResetFinalizer() override { finalizer_.ResetFinalizer(); }
|
|
466
|
+
void* Data() override { return finalizer_.data(); }
|
|
467
|
+
|
|
468
|
+
private:
|
|
469
|
+
ReferenceWithFinalizer(napi_env env,
|
|
470
|
+
v8::Local<v8::Value> value,
|
|
471
|
+
uint32_t initial_refcount,
|
|
472
|
+
ReferenceOwnership ownership,
|
|
473
|
+
napi_finalize finalize_callback,
|
|
474
|
+
void* finalize_data,
|
|
475
|
+
void* finalize_hint);
|
|
476
|
+
void CallUserFinalizer() override;
|
|
477
|
+
void InvokeFinalizerFromGC() override;
|
|
478
|
+
|
|
479
|
+
private:
|
|
480
|
+
Finalizer finalizer_;
|
|
481
|
+
};
|
|
482
|
+
|
|
483
|
+
} // end of namespace v8impl
|
|
484
|
+
|
|
485
|
+
#endif // SRC_JS_NATIVE_API_V8_H_
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#ifndef SRC_JS_NATIVE_API_V8_INTERNALS_H_
|
|
2
|
+
#define SRC_JS_NATIVE_API_V8_INTERNALS_H_
|
|
3
|
+
|
|
4
|
+
// The V8 implementation of Node-API, including `js_native_api_v8.h` uses
|
|
5
|
+
// certain idioms which require definition here. For example, it uses a variant
|
|
6
|
+
// of persistent references which need not be reset in the constructor. It is
|
|
7
|
+
// the responsibility of this file to define these idioms. Optionally, this file
|
|
8
|
+
// may also define `NAPI_VERSION` and set it to the version of Node-API to be
|
|
9
|
+
// exposed.
|
|
10
|
+
|
|
11
|
+
// In the case of the Node.js implementation of Node-API some of the idioms are
|
|
12
|
+
// imported directly from Node.js by including `node_internals.h` below. Others
|
|
13
|
+
// are bridged to remove references to the `node` namespace. `node_version.h`,
|
|
14
|
+
// included below, defines `NAPI_VERSION`.
|
|
15
|
+
|
|
16
|
+
#include "node_version.h"
|
|
17
|
+
|
|
18
|
+
#include "env.h"
|
|
19
|
+
#include "gtest/gtest_prod.h"
|
|
20
|
+
#include "node_errors.h"
|
|
21
|
+
#include "node_internals.h"
|
|
22
|
+
|
|
23
|
+
#define NAPI_ARRAYSIZE(array) node::arraysize((array))
|
|
24
|
+
|
|
25
|
+
#define NAPI_FIXED_ONE_BYTE_STRING(isolate, string) \
|
|
26
|
+
node::FIXED_ONE_BYTE_STRING((isolate), (string))
|
|
27
|
+
|
|
28
|
+
#define NAPI_PRIVATE_KEY(context, suffix) \
|
|
29
|
+
(node::Environment::GetCurrent((context))->napi_##suffix())
|
|
30
|
+
|
|
31
|
+
namespace v8impl {
|
|
32
|
+
|
|
33
|
+
template <typename T>
|
|
34
|
+
using Persistent = v8::Global<T>;
|
|
35
|
+
|
|
36
|
+
using PersistentToLocal = node::PersistentToLocal;
|
|
37
|
+
|
|
38
|
+
[[noreturn]] inline void OnFatalError(const char* location,
|
|
39
|
+
const char* message) {
|
|
40
|
+
node::OnFatalError(location, message);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
} // end of namespace v8impl
|
|
44
|
+
|
|
45
|
+
#endif // SRC_JS_NATIVE_API_V8_INTERNALS_H_
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#ifndef SRC_JS_STREAM_H_
|
|
2
|
+
#define SRC_JS_STREAM_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#include "async_wrap.h"
|
|
7
|
+
#include "stream_base.h"
|
|
8
|
+
|
|
9
|
+
namespace node {
|
|
10
|
+
|
|
11
|
+
class Environment;
|
|
12
|
+
|
|
13
|
+
class JSStream : public AsyncWrap, public StreamBase {
|
|
14
|
+
public:
|
|
15
|
+
static void Initialize(v8::Local<v8::Object> target,
|
|
16
|
+
v8::Local<v8::Value> unused,
|
|
17
|
+
v8::Local<v8::Context> context,
|
|
18
|
+
void* priv);
|
|
19
|
+
|
|
20
|
+
bool IsAlive() override;
|
|
21
|
+
bool IsClosing() override;
|
|
22
|
+
int ReadStart() override;
|
|
23
|
+
int ReadStop() override;
|
|
24
|
+
|
|
25
|
+
int DoShutdown(ShutdownWrap* req_wrap) override;
|
|
26
|
+
int DoWrite(WriteWrap* w,
|
|
27
|
+
uv_buf_t* bufs,
|
|
28
|
+
size_t count,
|
|
29
|
+
uv_stream_t* send_handle) override;
|
|
30
|
+
|
|
31
|
+
SET_NO_MEMORY_INFO()
|
|
32
|
+
SET_MEMORY_INFO_NAME(JSStream)
|
|
33
|
+
SET_SELF_SIZE(JSStream)
|
|
34
|
+
|
|
35
|
+
protected:
|
|
36
|
+
JSStream(Environment* env, v8::Local<v8::Object> obj);
|
|
37
|
+
|
|
38
|
+
AsyncWrap* GetAsyncWrap() override;
|
|
39
|
+
|
|
40
|
+
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
41
|
+
static void ReadBuffer(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
42
|
+
static void EmitEOF(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
43
|
+
|
|
44
|
+
template <class Wrap>
|
|
45
|
+
static void Finish(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
} // namespace node
|
|
49
|
+
|
|
50
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
51
|
+
|
|
52
|
+
#endif // SRC_JS_STREAM_H_
|