@encharm/cws 4.1.0 → 4.2.0
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/bindings/cws_linux_108.node +0 -0
- package/dist/bindings/cws_linux_64.node +0 -0
- package/dist/bindings/cws_linux_72.node +0 -0
- package/dist/bindings/cws_linux_79.node +0 -0
- package/dist/bindings/cws_linux_83.node +0 -0
- package/dist/bindings/cws_linux_93.node +0 -0
- package/dist/bindings/cws_win32_64.node +0 -0
- package/dist/bindings/cws_win32_72.node +0 -0
- package/dist/bindings/cws_win32_79.node +0 -0
- package/dist/bindings/cws_win32_83.node +0 -0
- package/dist/bindings/cws_win32_93.node +0 -0
- package/package.json +1 -1
- package/src/Addon.h +24 -2
- package/src/HTTPSocket.cpp +1 -1
- package/src/headers/{13 → 18}/aliased_buffer.h +61 -9
- package/src/headers/18/aliased_struct-inl.h +54 -0
- package/src/headers/18/aliased_struct.h +63 -0
- package/src/headers/{12 → 18}/async_wrap-inl.h +0 -0
- package/src/headers/{12 → 18}/async_wrap.h +26 -2
- package/src/headers/{12/base64.h → 18/base64-inl.h} +78 -86
- package/src/headers/18/base64.h +69 -0
- package/src/headers/{12 → 18}/base_object-inl.h +46 -25
- package/src/headers/{12 → 18}/base_object.h +82 -17
- package/src/headers/{12 → 18}/callback_queue-inl.h +9 -9
- package/src/headers/{12 → 18}/callback_queue.h +13 -5
- package/src/headers/18/cares_wrap.h +523 -0
- package/src/headers/{12 → 18}/connect_wrap.h +0 -0
- package/src/headers/{12 → 18}/connection_wrap.h +0 -0
- package/src/headers/18/crypto/crypto_aes.h +89 -0
- package/src/headers/{13/node_crypto_bio.h → 18/crypto/crypto_bio.h} +3 -4
- package/src/headers/18/crypto/crypto_cipher.h +291 -0
- package/src/headers/{13/node_crypto_clienthello-inl.h → 18/crypto/crypto_clienthello-inl.h} +4 -5
- package/src/headers/{13/node_crypto_clienthello.h → 18/crypto/crypto_clienthello.h} +3 -4
- package/src/headers/{12/node_crypto_common.h → 18/crypto/crypto_common.h} +49 -36
- package/src/headers/18/crypto/crypto_context.h +147 -0
- package/src/headers/18/crypto/crypto_dh.h +156 -0
- package/src/headers/18/crypto/crypto_dsa.h +77 -0
- package/src/headers/18/crypto/crypto_ec.h +170 -0
- package/src/headers/{12/node_crypto_groups.h → 18/crypto/crypto_groups.h} +3 -3
- package/src/headers/18/crypto/crypto_hash.h +89 -0
- package/src/headers/18/crypto/crypto_hkdf.h +65 -0
- package/src/headers/18/crypto/crypto_hmac.h +94 -0
- package/src/headers/18/crypto/crypto_keygen.h +305 -0
- package/src/headers/18/crypto/crypto_keys.h +420 -0
- package/src/headers/18/crypto/crypto_pbkdf2.h +76 -0
- package/src/headers/18/crypto/crypto_random.h +130 -0
- package/src/headers/18/crypto/crypto_rsa.h +141 -0
- package/src/headers/18/crypto/crypto_scrypt.h +87 -0
- package/src/headers/18/crypto/crypto_sig.h +168 -0
- package/src/headers/18/crypto/crypto_spkac.h +21 -0
- package/src/headers/18/crypto/crypto_timing.h +20 -0
- package/src/headers/{13/tls_wrap.h → 18/crypto/crypto_tls.h} +137 -66
- package/src/headers/18/crypto/crypto_util.h +791 -0
- package/src/headers/18/crypto/crypto_x509.h +143 -0
- package/src/headers/{12 → 18}/debug_utils-inl.h +0 -0
- package/src/headers/{13 → 18}/debug_utils.h +7 -4
- package/src/headers/{12 → 18}/diagnosticfilename-inl.h +0 -0
- package/src/headers/{12 → 18}/env-inl.h +397 -304
- package/src/headers/{12 → 18}/env.h +397 -172
- package/src/headers/{12 → 18}/handle_wrap.h +7 -3
- package/src/headers/18/histogram-inl.h +107 -0
- package/src/headers/18/histogram.h +239 -0
- package/src/headers/{13 → 18}/inspector_agent.h +4 -7
- package/src/headers/{12 → 18}/inspector_io.h +0 -0
- package/src/headers/{13 → 18}/inspector_profiler.h +17 -5
- package/src/headers/{12 → 18}/inspector_socket.h +0 -0
- package/src/headers/{12 → 18}/inspector_socket_server.h +0 -0
- package/src/headers/18/js_native_api.h +571 -0
- package/src/headers/{13 → 18}/js_native_api_types.h +30 -7
- package/src/headers/{12 → 18}/js_native_api_v8.h +220 -83
- package/src/headers/{12 → 18}/js_native_api_v8_internals.h +6 -5
- package/src/headers/{12 → 18}/js_stream.h +0 -0
- package/src/headers/{12 → 18}/json_utils.h +0 -0
- package/src/headers/{13 → 18}/memory_tracker-inl.h +6 -5
- package/src/headers/{13 → 18}/memory_tracker.h +0 -7
- package/src/headers/{13 → 18}/module_wrap.h +24 -7
- package/src/headers/{13 → 18}/node.h +329 -68
- package/src/headers/18/node_api.h +288 -0
- package/src/headers/18/node_api_internals.h +38 -0
- package/src/headers/{12 → 18}/node_api_types.h +12 -9
- package/src/headers/{12 → 18}/node_binding.h +0 -0
- package/src/headers/18/node_blob.h +191 -0
- package/src/headers/18/node_bob-inl.h +37 -0
- package/src/headers/18/node_bob.h +111 -0
- package/src/headers/{13 → 18}/node_buffer.h +0 -0
- package/src/headers/{13 → 18}/node_constants.h +5 -1
- package/src/headers/{12 → 18}/node_context_data.h +5 -0
- package/src/headers/{12 → 18}/node_contextify.h +37 -2
- package/src/headers/{10/node_win32_perfctr_provider.h → 18/node_crypto.h} +30 -31
- package/src/headers/{12 → 18}/node_dir.h +0 -0
- package/src/headers/{12 → 18}/node_dtrace.h +0 -0
- package/src/headers/{12 → 18}/node_errors.h +90 -24
- package/src/headers/18/node_external_reference.h +145 -0
- package/src/headers/{13 → 18}/node_file-inl.h +38 -21
- package/src/headers/{12 → 18}/node_file.h +74 -13
- package/src/headers/{13 → 18}/node_http2.h +365 -269
- package/src/headers/{12 → 18}/node_http2_state.h +40 -50
- package/src/headers/{13 → 18}/node_http_common-inl.h +25 -5
- package/src/headers/{13 → 18}/node_http_common.h +24 -20
- package/src/headers/{13 → 18}/node_i18n.h +2 -1
- package/src/headers/{12 → 18}/node_internals.h +39 -41
- package/src/headers/{13 → 18}/node_main_instance.h +15 -18
- package/src/headers/{12 → 18}/node_mem-inl.h +0 -0
- package/src/headers/{12 → 18}/node_mem.h +1 -1
- package/src/headers/{13 → 18}/node_messaging.h +170 -23
- package/src/headers/{12 → 18}/node_metadata.h +17 -4
- package/src/headers/{12 → 18}/node_mutex.h +77 -1
- package/src/headers/{12 → 18}/node_native_module.h +11 -1
- package/src/headers/{13 → 18}/node_native_module_env.h +14 -8
- package/src/headers/{12 → 18}/node_object_wrap.h +0 -0
- package/src/headers/{13 → 18}/node_options-inl.h +51 -21
- package/src/headers/{13 → 18}/node_options.h +46 -14
- package/src/headers/18/node_perf.h +168 -0
- package/src/headers/{12 → 18}/node_perf_common.h +16 -22
- package/src/headers/{12 → 18}/node_platform.h +21 -16
- package/src/headers/18/node_process-inl.h +26 -0
- package/src/headers/18/node_process.h +97 -0
- package/src/headers/{13 → 18}/node_report.h +2 -2
- package/src/headers/{13 → 18}/node_revert.h +10 -0
- package/src/headers/{12 → 18}/node_root_certs.h +439 -651
- package/src/headers/18/node_snapshot_builder.h +43 -0
- package/src/headers/18/node_snapshotable.h +130 -0
- package/src/headers/{12 → 18}/node_sockaddr-inl.h +100 -4
- package/src/headers/18/node_sockaddr.h +405 -0
- package/src/headers/{12 → 18}/node_stat_watcher.h +7 -1
- package/src/headers/{12 → 18}/node_union_bytes.h +0 -0
- package/src/headers/{13 → 18}/node_url.h +18 -1
- package/src/headers/18/node_v8.h +41 -0
- package/src/headers/{12 → 18}/node_v8_platform-inl.h +10 -0
- package/src/headers/{13 → 18}/node_version.h +7 -7
- package/src/headers/{12 → 18}/node_wasi.h +0 -0
- package/src/headers/18/node_wasm_web_api.h +55 -0
- package/src/headers/{13 → 18}/node_watchdog.h +0 -0
- package/src/headers/{10 → 18}/node_win32_etw_provider-inl.h +7 -6
- package/src/headers/{10 → 18}/node_win32_etw_provider.h +0 -0
- package/src/headers/{13 → 18}/node_worker.h +24 -17
- package/src/headers/{12 → 18}/pipe_wrap.h +2 -0
- package/src/headers/{12 → 18}/req_wrap-inl.h +0 -0
- package/src/headers/{12 → 18}/req_wrap.h +1 -1
- package/src/headers/{12 → 18}/spawn_sync.h +0 -0
- package/src/headers/{13 → 18}/stream_base-inl.h +58 -22
- package/src/headers/{13 → 18}/stream_base.h +29 -3
- package/src/headers/{13 → 18}/stream_pipe.h +8 -3
- package/src/headers/{12 → 18}/stream_wrap.h +4 -1
- package/src/headers/{13 → 18}/string_bytes.h +0 -7
- package/src/headers/{12 → 18}/string_decoder-inl.h +0 -0
- package/src/headers/{10 → 18}/string_decoder.h +0 -0
- package/src/headers/{13 → 18}/string_search.h +2 -2
- package/src/headers/{12 → 18}/tcp_wrap.h +4 -0
- package/src/headers/{12 → 18}/threadpoolwork-inl.h +0 -0
- package/src/headers/18/timer_wrap-inl.h +32 -0
- package/src/headers/18/timer_wrap.h +85 -0
- package/src/headers/{13 → 18}/tracing/agent.h +1 -1
- package/src/headers/{12 → 18}/tracing/node_trace_buffer.h +0 -0
- package/src/headers/{12 → 18}/tracing/node_trace_writer.h +0 -0
- package/src/headers/{13 → 18}/tracing/trace_event.h +23 -13
- package/src/headers/{12 → 18}/tracing/trace_event_common.h +0 -0
- package/src/headers/{12 → 18}/tracing/traced_value.h +0 -0
- package/src/headers/{13 → 18}/tty_wrap.h +2 -1
- package/src/headers/{13 → 18}/udp_wrap.h +5 -0
- package/src/headers/{13 → 18}/util-inl.h +69 -15
- package/src/headers/{13 → 18}/util.h +93 -31
- package/src/headers/18/v8-fast-api-calls.h +939 -0
- package/src/headers/{12 → 18}/v8abbr.h +2 -2
- package/src/headers/10/aliased_buffer.h +0 -241
- package/src/headers/10/async_wrap-inl.h +0 -106
- package/src/headers/10/async_wrap.h +0 -218
- package/src/headers/10/base64.h +0 -197
- package/src/headers/10/base_object-inl.h +0 -132
- package/src/headers/10/base_object.h +0 -115
- package/src/headers/10/connect_wrap.h +0 -28
- package/src/headers/10/connection_wrap.h +0 -30
- package/src/headers/10/debug_utils.h +0 -128
- package/src/headers/10/env-inl.h +0 -906
- package/src/headers/10/env.h +0 -1046
- package/src/headers/10/handle_wrap.h +0 -114
- package/src/headers/10/inspector_agent.h +0 -137
- package/src/headers/10/inspector_io.h +0 -97
- package/src/headers/10/inspector_socket.h +0 -59
- package/src/headers/10/inspector_socket_server.h +0 -104
- package/src/headers/10/js_stream.h +0 -57
- package/src/headers/10/memory_tracker-inl.h +0 -318
- package/src/headers/10/memory_tracker.h +0 -246
- package/src/headers/10/module_wrap.h +0 -100
- package/src/headers/10/node.h +0 -863
- package/src/headers/10/node_api.h +0 -752
- package/src/headers/10/node_api_types.h +0 -171
- package/src/headers/10/node_buffer.h +0 -90
- package/src/headers/10/node_code_cache.h +0 -17
- package/src/headers/10/node_constants.h +0 -74
- package/src/headers/10/node_context_data.h +0 -39
- package/src/headers/10/node_contextify.h +0 -141
- package/src/headers/10/node_counters.h +0 -59
- package/src/headers/10/node_crypto.h +0 -699
- package/src/headers/10/node_crypto_bio.h +0 -177
- package/src/headers/10/node_crypto_clienthello-inl.h +0 -92
- package/src/headers/10/node_crypto_clienthello.h +0 -131
- package/src/headers/10/node_crypto_groups.h +0 -416
- package/src/headers/10/node_dtrace.h +0 -84
- package/src/headers/10/node_errors.h +0 -118
- package/src/headers/10/node_file.h +0 -373
- package/src/headers/10/node_http2.h +0 -1304
- package/src/headers/10/node_http2_state.h +0 -158
- package/src/headers/10/node_i18n.h +0 -69
- package/src/headers/10/node_internals.h +0 -952
- package/src/headers/10/node_javascript.h +0 -41
- package/src/headers/10/node_messaging.h +0 -219
- package/src/headers/10/node_mutex.h +0 -191
- package/src/headers/10/node_object_wrap.h +0 -130
- package/src/headers/10/node_options-inl.h +0 -444
- package/src/headers/10/node_options.h +0 -397
- package/src/headers/10/node_perf.h +0 -134
- package/src/headers/10/node_perf_common.h +0 -96
- package/src/headers/10/node_persistent.h +0 -30
- package/src/headers/10/node_platform.h +0 -170
- package/src/headers/10/node_revert.h +0 -75
- package/src/headers/10/node_root_certs.h +0 -3393
- package/src/headers/10/node_stat_watcher.h +0 -65
- package/src/headers/10/node_url.h +0 -193
- package/src/headers/10/node_version.h +0 -120
- package/src/headers/10/node_watchdog.h +0 -114
- package/src/headers/10/node_worker.h +0 -94
- package/src/headers/10/pipe_wrap.h +0 -76
- package/src/headers/10/req_wrap-inl.h +0 -166
- package/src/headers/10/req_wrap.h +0 -61
- package/src/headers/10/sharedarraybuffer_metadata.h +0 -67
- package/src/headers/10/spawn_sync.h +0 -240
- package/src/headers/10/stream_base-inl.h +0 -458
- package/src/headers/10/stream_base.h +0 -378
- package/src/headers/10/stream_pipe.h +0 -72
- package/src/headers/10/stream_wrap.h +0 -130
- package/src/headers/10/string_bytes.h +0 -126
- package/src/headers/10/string_decoder-inl.h +0 -38
- package/src/headers/10/string_search.h +0 -620
- package/src/headers/10/tcp_wrap.h +0 -99
- package/src/headers/10/tls_wrap.h +0 -195
- package/src/headers/10/tracing/agent.h +0 -178
- package/src/headers/10/tracing/node_trace_buffer.h +0 -83
- package/src/headers/10/tracing/node_trace_writer.h +0 -75
- package/src/headers/10/tracing/trace_event.h +0 -706
- package/src/headers/10/tracing/trace_event_common.h +0 -1102
- package/src/headers/10/tracing/traced_value.h +0 -68
- package/src/headers/10/tty_wrap.h +0 -63
- package/src/headers/10/udp_wrap.h +0 -102
- package/src/headers/10/util-inl.h +0 -459
- package/src/headers/10/util.h +0 -508
- package/src/headers/10/v8abbr.h +0 -121
- package/src/headers/12/aliased_buffer.h +0 -263
- package/src/headers/12/debug_utils.h +0 -181
- package/src/headers/12/histogram-inl.h +0 -83
- package/src/headers/12/histogram.h +0 -98
- package/src/headers/12/http_parser_adaptor.h +0 -24
- package/src/headers/12/inspector_agent.h +0 -147
- package/src/headers/12/inspector_profiler.h +0 -137
- package/src/headers/12/js_native_api.h +0 -541
- package/src/headers/12/js_native_api_types.h +0 -139
- package/src/headers/12/memory_tracker-inl.h +0 -339
- package/src/headers/12/memory_tracker.h +0 -283
- package/src/headers/12/module_wrap.h +0 -99
- package/src/headers/12/node.h +0 -887
- package/src/headers/12/node_api.h +0 -239
- package/src/headers/12/node_buffer.h +0 -92
- package/src/headers/12/node_constants.h +0 -80
- package/src/headers/12/node_crypto.h +0 -800
- package/src/headers/12/node_crypto_bio.h +0 -195
- package/src/headers/12/node_crypto_clienthello-inl.h +0 -91
- package/src/headers/12/node_crypto_clienthello.h +0 -132
- package/src/headers/12/node_file-inl.h +0 -289
- package/src/headers/12/node_http2.h +0 -1311
- package/src/headers/12/node_http_parser_impl.h +0 -994
- package/src/headers/12/node_i18n.h +0 -144
- package/src/headers/12/node_main_instance.h +0 -97
- package/src/headers/12/node_messaging.h +0 -227
- package/src/headers/12/node_native_module_env.h +0 -65
- package/src/headers/12/node_options-inl.h +0 -447
- package/src/headers/12/node_options.h +0 -479
- package/src/headers/12/node_perf.h +0 -181
- package/src/headers/12/node_process.h +0 -41
- package/src/headers/12/node_report.h +0 -47
- package/src/headers/12/node_revert.h +0 -78
- package/src/headers/12/node_sockaddr.h +0 -123
- package/src/headers/12/node_url.h +0 -188
- package/src/headers/12/node_version.h +0 -98
- package/src/headers/12/node_watchdog.h +0 -152
- package/src/headers/12/node_win32_etw_provider-inl.h +0 -287
- package/src/headers/12/node_win32_etw_provider.h +0 -99
- package/src/headers/12/node_worker.h +0 -142
- package/src/headers/12/sharedarraybuffer_metadata.h +0 -72
- package/src/headers/12/stream_base-inl.h +0 -323
- package/src/headers/12/stream_base.h +0 -431
- package/src/headers/12/stream_pipe.h +0 -72
- package/src/headers/12/string_bytes.h +0 -142
- package/src/headers/12/string_decoder.h +0 -50
- package/src/headers/12/string_search.h +0 -638
- package/src/headers/12/tls_wrap.h +0 -221
- package/src/headers/12/tracing/agent.h +0 -195
- package/src/headers/12/tracing/trace_event.h +0 -710
- package/src/headers/12/tty_wrap.h +0 -64
- package/src/headers/12/udp_wrap.h +0 -222
- package/src/headers/12/util-inl.h +0 -529
- package/src/headers/12/util.h +0 -765
- package/src/headers/13/async_wrap-inl.h +0 -94
- package/src/headers/13/async_wrap.h +0 -224
- package/src/headers/13/base64.h +0 -197
- package/src/headers/13/base_object-inl.h +0 -353
- package/src/headers/13/base_object.h +0 -229
- package/src/headers/13/connect_wrap.h +0 -26
- package/src/headers/13/connection_wrap.h +0 -30
- package/src/headers/13/debug_utils-inl.h +0 -223
- package/src/headers/13/diagnosticfilename-inl.h +0 -33
- package/src/headers/13/env-inl.h +0 -1293
- package/src/headers/13/env.h +0 -1469
- package/src/headers/13/handle_wrap.h +0 -117
- package/src/headers/13/histogram-inl.h +0 -83
- package/src/headers/13/histogram.h +0 -98
- package/src/headers/13/inspector_io.h +0 -78
- package/src/headers/13/inspector_socket.h +0 -60
- package/src/headers/13/inspector_socket_server.h +0 -110
- package/src/headers/13/js_native_api.h +0 -541
- package/src/headers/13/js_native_api_v8.h +0 -303
- package/src/headers/13/js_native_api_v8_internals.h +0 -38
- package/src/headers/13/js_stream.h +0 -52
- package/src/headers/13/json_utils.h +0 -160
- package/src/headers/13/node_api.h +0 -239
- package/src/headers/13/node_api_types.h +0 -44
- package/src/headers/13/node_binding.h +0 -99
- package/src/headers/13/node_context_data.h +0 -39
- package/src/headers/13/node_contextify.h +0 -161
- package/src/headers/13/node_crypto.h +0 -800
- package/src/headers/13/node_crypto_common.h +0 -138
- package/src/headers/13/node_crypto_groups.h +0 -415
- package/src/headers/13/node_dir.h +0 -52
- package/src/headers/13/node_dtrace.h +0 -86
- package/src/headers/13/node_errors.h +0 -210
- package/src/headers/13/node_file.h +0 -364
- package/src/headers/13/node_http2_state.h +0 -144
- package/src/headers/13/node_internals.h +0 -405
- package/src/headers/13/node_mem-inl.h +0 -112
- package/src/headers/13/node_mem.h +0 -41
- package/src/headers/13/node_metadata.h +0 -109
- package/src/headers/13/node_mutex.h +0 -247
- package/src/headers/13/node_native_module.h +0 -99
- package/src/headers/13/node_object_wrap.h +0 -132
- package/src/headers/13/node_perf.h +0 -181
- package/src/headers/13/node_perf_common.h +0 -97
- package/src/headers/13/node_platform.h +0 -190
- package/src/headers/13/node_process.h +0 -41
- package/src/headers/13/node_root_certs.h +0 -3424
- package/src/headers/13/node_sockaddr-inl.h +0 -170
- package/src/headers/13/node_sockaddr.h +0 -123
- package/src/headers/13/node_stat_watcher.h +0 -66
- package/src/headers/13/node_union_bytes.h +0 -103
- package/src/headers/13/node_v8_platform-inl.h +0 -184
- package/src/headers/13/node_wasi.h +0 -108
- package/src/headers/13/node_win32_etw_provider-inl.h +0 -287
- package/src/headers/13/node_win32_etw_provider.h +0 -99
- package/src/headers/13/pipe_wrap.h +0 -78
- package/src/headers/13/req_wrap-inl.h +0 -170
- package/src/headers/13/req_wrap.h +0 -77
- package/src/headers/13/spawn_sync.h +0 -242
- package/src/headers/13/stream_wrap.h +0 -130
- package/src/headers/13/string_decoder-inl.h +0 -37
- package/src/headers/13/string_decoder.h +0 -50
- package/src/headers/13/tcp_wrap.h +0 -101
- package/src/headers/13/threadpoolwork-inl.h +0 -57
- package/src/headers/13/tracing/node_trace_buffer.h +0 -83
- package/src/headers/13/tracing/node_trace_writer.h +0 -75
- package/src/headers/13/tracing/trace_event_common.h +0 -1109
- package/src/headers/13/tracing/traced_value.h +0 -70
- package/src/headers/13/v8abbr.h +0 -124
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
// Copyright 2016 the V8 project authors. All rights reserved.
|
|
2
|
-
// Use of this source code is governed by a BSD-style license that can be
|
|
3
|
-
// found in the LICENSE file.
|
|
4
|
-
|
|
5
|
-
#ifndef SRC_TRACING_TRACED_VALUE_H_
|
|
6
|
-
#define SRC_TRACING_TRACED_VALUE_H_
|
|
7
|
-
|
|
8
|
-
#include "node_internals.h"
|
|
9
|
-
#include "v8.h"
|
|
10
|
-
|
|
11
|
-
#include <stddef.h>
|
|
12
|
-
#include <memory>
|
|
13
|
-
#include <string>
|
|
14
|
-
|
|
15
|
-
namespace node {
|
|
16
|
-
namespace tracing {
|
|
17
|
-
|
|
18
|
-
class TracedValue : public v8::ConvertableToTraceFormat {
|
|
19
|
-
public:
|
|
20
|
-
~TracedValue() override;
|
|
21
|
-
|
|
22
|
-
static std::unique_ptr<TracedValue> Create();
|
|
23
|
-
static std::unique_ptr<TracedValue> CreateArray();
|
|
24
|
-
|
|
25
|
-
void EndDictionary();
|
|
26
|
-
void EndArray();
|
|
27
|
-
|
|
28
|
-
// These methods assume that |name| is a long lived "quoted" string.
|
|
29
|
-
void SetInteger(const char* name, int value);
|
|
30
|
-
void SetDouble(const char* name, double value);
|
|
31
|
-
void SetBoolean(const char* name, bool value);
|
|
32
|
-
void SetNull(const char* name);
|
|
33
|
-
void SetString(const char* name, const char* value);
|
|
34
|
-
void SetString(const char* name, const std::string& value) {
|
|
35
|
-
SetString(name, value.c_str());
|
|
36
|
-
}
|
|
37
|
-
void BeginDictionary(const char* name);
|
|
38
|
-
void BeginArray(const char* name);
|
|
39
|
-
|
|
40
|
-
void AppendInteger(int);
|
|
41
|
-
void AppendDouble(double);
|
|
42
|
-
void AppendBoolean(bool);
|
|
43
|
-
void AppendNull();
|
|
44
|
-
void AppendString(const char*);
|
|
45
|
-
void AppendString(const std::string& value) { AppendString(value.c_str()); }
|
|
46
|
-
void BeginArray();
|
|
47
|
-
void BeginDictionary();
|
|
48
|
-
|
|
49
|
-
// ConvertableToTraceFormat implementation.
|
|
50
|
-
void AppendAsTraceFormat(std::string* out) const override;
|
|
51
|
-
|
|
52
|
-
private:
|
|
53
|
-
explicit TracedValue(bool root_is_array = false);
|
|
54
|
-
|
|
55
|
-
void WriteComma();
|
|
56
|
-
void WriteName(const char* name);
|
|
57
|
-
|
|
58
|
-
std::string data_;
|
|
59
|
-
bool first_item_;
|
|
60
|
-
bool root_is_array_;
|
|
61
|
-
|
|
62
|
-
DISALLOW_COPY_AND_ASSIGN(TracedValue);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
} // namespace tracing
|
|
66
|
-
} // namespace node
|
|
67
|
-
|
|
68
|
-
#endif // SRC_TRACING_TRACED_VALUE_H_
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
// Copyright Joyent, Inc. and other Node contributors.
|
|
2
|
-
//
|
|
3
|
-
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
4
|
-
// copy of this software and associated documentation files (the
|
|
5
|
-
// "Software"), to deal in the Software without restriction, including
|
|
6
|
-
// without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
-
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
8
|
-
// persons to whom the Software is furnished to do so, subject to the
|
|
9
|
-
// following conditions:
|
|
10
|
-
//
|
|
11
|
-
// The above copyright notice and this permission notice shall be included
|
|
12
|
-
// in all copies or substantial portions of the Software.
|
|
13
|
-
//
|
|
14
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
15
|
-
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
-
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
17
|
-
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
18
|
-
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
19
|
-
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
20
|
-
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
21
|
-
|
|
22
|
-
#ifndef SRC_TTY_WRAP_H_
|
|
23
|
-
#define SRC_TTY_WRAP_H_
|
|
24
|
-
|
|
25
|
-
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
26
|
-
|
|
27
|
-
#include "env.h"
|
|
28
|
-
#include "uv.h"
|
|
29
|
-
#include "stream_wrap.h"
|
|
30
|
-
|
|
31
|
-
namespace node {
|
|
32
|
-
|
|
33
|
-
class TTYWrap : public LibuvStreamWrap {
|
|
34
|
-
public:
|
|
35
|
-
static void Initialize(v8::Local<v8::Object> target,
|
|
36
|
-
v8::Local<v8::Value> unused,
|
|
37
|
-
v8::Local<v8::Context> context);
|
|
38
|
-
|
|
39
|
-
SET_NO_MEMORY_INFO()
|
|
40
|
-
SET_MEMORY_INFO_NAME(TTYWrap)
|
|
41
|
-
SET_SELF_SIZE(TTYWrap)
|
|
42
|
-
|
|
43
|
-
private:
|
|
44
|
-
TTYWrap(Environment* env,
|
|
45
|
-
v8::Local<v8::Object> object,
|
|
46
|
-
int fd,
|
|
47
|
-
bool readable,
|
|
48
|
-
int* init_err);
|
|
49
|
-
|
|
50
|
-
static void GuessHandleType(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
51
|
-
static void IsTTY(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
52
|
-
static void GetWindowSize(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
53
|
-
static void SetRawMode(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
54
|
-
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
55
|
-
|
|
56
|
-
uv_tty_t handle_;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
} // namespace node
|
|
60
|
-
|
|
61
|
-
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
62
|
-
|
|
63
|
-
#endif // SRC_TTY_WRAP_H_
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
// Copyright Joyent, Inc. and other Node contributors.
|
|
2
|
-
//
|
|
3
|
-
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
4
|
-
// copy of this software and associated documentation files (the
|
|
5
|
-
// "Software"), to deal in the Software without restriction, including
|
|
6
|
-
// without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
-
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
8
|
-
// persons to whom the Software is furnished to do so, subject to the
|
|
9
|
-
// following conditions:
|
|
10
|
-
//
|
|
11
|
-
// The above copyright notice and this permission notice shall be included
|
|
12
|
-
// in all copies or substantial portions of the Software.
|
|
13
|
-
//
|
|
14
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
15
|
-
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
-
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
17
|
-
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
18
|
-
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
19
|
-
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
20
|
-
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
21
|
-
|
|
22
|
-
#ifndef SRC_UDP_WRAP_H_
|
|
23
|
-
#define SRC_UDP_WRAP_H_
|
|
24
|
-
|
|
25
|
-
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
26
|
-
|
|
27
|
-
#include "async_wrap.h"
|
|
28
|
-
#include "env.h"
|
|
29
|
-
#include "handle_wrap.h"
|
|
30
|
-
#include "uv.h"
|
|
31
|
-
#include "v8.h"
|
|
32
|
-
|
|
33
|
-
namespace node {
|
|
34
|
-
|
|
35
|
-
class UDPWrap: public HandleWrap {
|
|
36
|
-
public:
|
|
37
|
-
enum SocketType {
|
|
38
|
-
SOCKET
|
|
39
|
-
};
|
|
40
|
-
static void Initialize(v8::Local<v8::Object> target,
|
|
41
|
-
v8::Local<v8::Value> unused,
|
|
42
|
-
v8::Local<v8::Context> context);
|
|
43
|
-
static void GetFD(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
44
|
-
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
45
|
-
static void Bind(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
46
|
-
static void Send(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
47
|
-
static void Bind6(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
48
|
-
static void Send6(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
49
|
-
static void RecvStart(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
50
|
-
static void RecvStop(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
51
|
-
static void AddMembership(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
52
|
-
static void DropMembership(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
53
|
-
static void SetMulticastInterface(
|
|
54
|
-
const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
55
|
-
static void SetMulticastTTL(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
56
|
-
static void SetMulticastLoopback(
|
|
57
|
-
const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
58
|
-
static void SetBroadcast(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
59
|
-
static void SetTTL(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
60
|
-
static void BufferSize(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
61
|
-
|
|
62
|
-
static v8::Local<v8::Object> Instantiate(Environment* env,
|
|
63
|
-
AsyncWrap* parent,
|
|
64
|
-
SocketType type);
|
|
65
|
-
SET_NO_MEMORY_INFO()
|
|
66
|
-
SET_MEMORY_INFO_NAME(UDPWrap)
|
|
67
|
-
SET_SELF_SIZE(UDPWrap)
|
|
68
|
-
|
|
69
|
-
private:
|
|
70
|
-
typedef uv_udp_t HandleType;
|
|
71
|
-
|
|
72
|
-
template <typename T,
|
|
73
|
-
int (*F)(const typename T::HandleType*, sockaddr*, int*)>
|
|
74
|
-
friend void GetSockOrPeerName(const v8::FunctionCallbackInfo<v8::Value>&);
|
|
75
|
-
|
|
76
|
-
UDPWrap(Environment* env, v8::Local<v8::Object> object);
|
|
77
|
-
|
|
78
|
-
static void DoBind(const v8::FunctionCallbackInfo<v8::Value>& args,
|
|
79
|
-
int family);
|
|
80
|
-
static void DoSend(const v8::FunctionCallbackInfo<v8::Value>& args,
|
|
81
|
-
int family);
|
|
82
|
-
static void SetMembership(const v8::FunctionCallbackInfo<v8::Value>& args,
|
|
83
|
-
uv_membership membership);
|
|
84
|
-
|
|
85
|
-
static void OnAlloc(uv_handle_t* handle,
|
|
86
|
-
size_t suggested_size,
|
|
87
|
-
uv_buf_t* buf);
|
|
88
|
-
static void OnSend(uv_udp_send_t* req, int status);
|
|
89
|
-
static void OnRecv(uv_udp_t* handle,
|
|
90
|
-
ssize_t nread,
|
|
91
|
-
const uv_buf_t* buf,
|
|
92
|
-
const struct sockaddr* addr,
|
|
93
|
-
unsigned int flags);
|
|
94
|
-
|
|
95
|
-
uv_udp_t handle_;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
} // namespace node
|
|
99
|
-
|
|
100
|
-
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
101
|
-
|
|
102
|
-
#endif // SRC_UDP_WRAP_H_
|
|
@@ -1,459 +0,0 @@
|
|
|
1
|
-
// Copyright Joyent, Inc. and other Node contributors.
|
|
2
|
-
//
|
|
3
|
-
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
4
|
-
// copy of this software and associated documentation files (the
|
|
5
|
-
// "Software"), to deal in the Software without restriction, including
|
|
6
|
-
// without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
-
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
8
|
-
// persons to whom the Software is furnished to do so, subject to the
|
|
9
|
-
// following conditions:
|
|
10
|
-
//
|
|
11
|
-
// The above copyright notice and this permission notice shall be included
|
|
12
|
-
// in all copies or substantial portions of the Software.
|
|
13
|
-
//
|
|
14
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
15
|
-
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
-
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
17
|
-
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
18
|
-
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
19
|
-
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
20
|
-
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
21
|
-
|
|
22
|
-
#ifndef SRC_UTIL_INL_H_
|
|
23
|
-
#define SRC_UTIL_INL_H_
|
|
24
|
-
|
|
25
|
-
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
26
|
-
|
|
27
|
-
#include <cstring>
|
|
28
|
-
#include "util.h"
|
|
29
|
-
|
|
30
|
-
#if defined(_MSC_VER)
|
|
31
|
-
#include <intrin.h>
|
|
32
|
-
#define BSWAP_2(x) _byteswap_ushort(x)
|
|
33
|
-
#define BSWAP_4(x) _byteswap_ulong(x)
|
|
34
|
-
#define BSWAP_8(x) _byteswap_uint64(x)
|
|
35
|
-
#else
|
|
36
|
-
#define BSWAP_2(x) ((x) << 8) | ((x) >> 8)
|
|
37
|
-
#define BSWAP_4(x) \
|
|
38
|
-
(((x) & 0xFF) << 24) | \
|
|
39
|
-
(((x) & 0xFF00) << 8) | \
|
|
40
|
-
(((x) >> 8) & 0xFF00) | \
|
|
41
|
-
(((x) >> 24) & 0xFF)
|
|
42
|
-
#define BSWAP_8(x) \
|
|
43
|
-
(((x) & 0xFF00000000000000ull) >> 56) | \
|
|
44
|
-
(((x) & 0x00FF000000000000ull) >> 40) | \
|
|
45
|
-
(((x) & 0x0000FF0000000000ull) >> 24) | \
|
|
46
|
-
(((x) & 0x000000FF00000000ull) >> 8) | \
|
|
47
|
-
(((x) & 0x00000000FF000000ull) << 8) | \
|
|
48
|
-
(((x) & 0x0000000000FF0000ull) << 24) | \
|
|
49
|
-
(((x) & 0x000000000000FF00ull) << 40) | \
|
|
50
|
-
(((x) & 0x00000000000000FFull) << 56)
|
|
51
|
-
#endif
|
|
52
|
-
|
|
53
|
-
namespace node {
|
|
54
|
-
|
|
55
|
-
template <typename T>
|
|
56
|
-
ListNode<T>::ListNode() : prev_(this), next_(this) {}
|
|
57
|
-
|
|
58
|
-
template <typename T>
|
|
59
|
-
ListNode<T>::~ListNode() {
|
|
60
|
-
Remove();
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
template <typename T>
|
|
64
|
-
void ListNode<T>::Remove() {
|
|
65
|
-
prev_->next_ = next_;
|
|
66
|
-
next_->prev_ = prev_;
|
|
67
|
-
prev_ = this;
|
|
68
|
-
next_ = this;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
template <typename T>
|
|
72
|
-
bool ListNode<T>::IsEmpty() const {
|
|
73
|
-
return prev_ == this;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
template <typename T, ListNode<T> (T::*M)>
|
|
77
|
-
ListHead<T, M>::Iterator::Iterator(ListNode<T>* node) : node_(node) {}
|
|
78
|
-
|
|
79
|
-
template <typename T, ListNode<T> (T::*M)>
|
|
80
|
-
T* ListHead<T, M>::Iterator::operator*() const {
|
|
81
|
-
return ContainerOf(M, node_);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
template <typename T, ListNode<T> (T::*M)>
|
|
85
|
-
const typename ListHead<T, M>::Iterator&
|
|
86
|
-
ListHead<T, M>::Iterator::operator++() {
|
|
87
|
-
node_ = node_->next_;
|
|
88
|
-
return *this;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
template <typename T, ListNode<T> (T::*M)>
|
|
92
|
-
bool ListHead<T, M>::Iterator::operator!=(const Iterator& that) const {
|
|
93
|
-
return node_ != that.node_;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
template <typename T, ListNode<T> (T::*M)>
|
|
97
|
-
ListHead<T, M>::~ListHead() {
|
|
98
|
-
while (IsEmpty() == false)
|
|
99
|
-
head_.next_->Remove();
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
template <typename T, ListNode<T> (T::*M)>
|
|
103
|
-
void ListHead<T, M>::PushBack(T* element) {
|
|
104
|
-
ListNode<T>* that = &(element->*M);
|
|
105
|
-
head_.prev_->next_ = that;
|
|
106
|
-
that->prev_ = head_.prev_;
|
|
107
|
-
that->next_ = &head_;
|
|
108
|
-
head_.prev_ = that;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
template <typename T, ListNode<T> (T::*M)>
|
|
112
|
-
void ListHead<T, M>::PushFront(T* element) {
|
|
113
|
-
ListNode<T>* that = &(element->*M);
|
|
114
|
-
head_.next_->prev_ = that;
|
|
115
|
-
that->prev_ = &head_;
|
|
116
|
-
that->next_ = head_.next_;
|
|
117
|
-
head_.next_ = that;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
template <typename T, ListNode<T> (T::*M)>
|
|
121
|
-
bool ListHead<T, M>::IsEmpty() const {
|
|
122
|
-
return head_.IsEmpty();
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
template <typename T, ListNode<T> (T::*M)>
|
|
126
|
-
T* ListHead<T, M>::PopFront() {
|
|
127
|
-
if (IsEmpty())
|
|
128
|
-
return nullptr;
|
|
129
|
-
ListNode<T>* node = head_.next_;
|
|
130
|
-
node->Remove();
|
|
131
|
-
return ContainerOf(M, node);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
template <typename T, ListNode<T> (T::*M)>
|
|
135
|
-
typename ListHead<T, M>::Iterator ListHead<T, M>::begin() const {
|
|
136
|
-
return Iterator(head_.next_);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
template <typename T, ListNode<T> (T::*M)>
|
|
140
|
-
typename ListHead<T, M>::Iterator ListHead<T, M>::end() const {
|
|
141
|
-
return Iterator(const_cast<ListNode<T>*>(&head_));
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
template <typename Inner, typename Outer>
|
|
145
|
-
constexpr uintptr_t OffsetOf(Inner Outer::*field) {
|
|
146
|
-
return reinterpret_cast<uintptr_t>(&(static_cast<Outer*>(0)->*field));
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
template <typename Inner, typename Outer>
|
|
150
|
-
ContainerOfHelper<Inner, Outer>::ContainerOfHelper(Inner Outer::*field,
|
|
151
|
-
Inner* pointer)
|
|
152
|
-
: pointer_(
|
|
153
|
-
reinterpret_cast<Outer*>(
|
|
154
|
-
reinterpret_cast<uintptr_t>(pointer) - OffsetOf(field))) {}
|
|
155
|
-
|
|
156
|
-
template <typename Inner, typename Outer>
|
|
157
|
-
template <typename TypeName>
|
|
158
|
-
ContainerOfHelper<Inner, Outer>::operator TypeName*() const {
|
|
159
|
-
return static_cast<TypeName*>(pointer_);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
template <typename Inner, typename Outer>
|
|
163
|
-
inline ContainerOfHelper<Inner, Outer> ContainerOf(Inner Outer::*field,
|
|
164
|
-
Inner* pointer) {
|
|
165
|
-
return ContainerOfHelper<Inner, Outer>(field, pointer);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
template <class TypeName>
|
|
169
|
-
inline v8::Local<TypeName> PersistentToLocal(
|
|
170
|
-
v8::Isolate* isolate,
|
|
171
|
-
const Persistent<TypeName>& persistent) {
|
|
172
|
-
if (persistent.IsWeak()) {
|
|
173
|
-
return WeakPersistentToLocal(isolate, persistent);
|
|
174
|
-
} else {
|
|
175
|
-
return StrongPersistentToLocal(persistent);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
template <class TypeName>
|
|
180
|
-
inline v8::Local<TypeName> StrongPersistentToLocal(
|
|
181
|
-
const Persistent<TypeName>& persistent) {
|
|
182
|
-
return *reinterpret_cast<v8::Local<TypeName>*>(
|
|
183
|
-
const_cast<Persistent<TypeName>*>(&persistent));
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
template <class TypeName>
|
|
187
|
-
inline v8::Local<TypeName> WeakPersistentToLocal(
|
|
188
|
-
v8::Isolate* isolate,
|
|
189
|
-
const Persistent<TypeName>& persistent) {
|
|
190
|
-
return v8::Local<TypeName>::New(isolate, persistent);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
inline v8::Local<v8::String> OneByteString(v8::Isolate* isolate,
|
|
194
|
-
const char* data,
|
|
195
|
-
int length) {
|
|
196
|
-
return v8::String::NewFromOneByte(isolate,
|
|
197
|
-
reinterpret_cast<const uint8_t*>(data),
|
|
198
|
-
v8::NewStringType::kNormal,
|
|
199
|
-
length).ToLocalChecked();
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
inline v8::Local<v8::String> OneByteString(v8::Isolate* isolate,
|
|
203
|
-
const signed char* data,
|
|
204
|
-
int length) {
|
|
205
|
-
return v8::String::NewFromOneByte(isolate,
|
|
206
|
-
reinterpret_cast<const uint8_t*>(data),
|
|
207
|
-
v8::NewStringType::kNormal,
|
|
208
|
-
length).ToLocalChecked();
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
inline v8::Local<v8::String> OneByteString(v8::Isolate* isolate,
|
|
212
|
-
const unsigned char* data,
|
|
213
|
-
int length) {
|
|
214
|
-
return v8::String::NewFromOneByte(
|
|
215
|
-
isolate, data, v8::NewStringType::kNormal, length)
|
|
216
|
-
.ToLocalChecked();
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
void SwapBytes16(char* data, size_t nbytes) {
|
|
220
|
-
CHECK_EQ(nbytes % 2, 0);
|
|
221
|
-
|
|
222
|
-
#if defined(_MSC_VER)
|
|
223
|
-
int align = reinterpret_cast<uintptr_t>(data) % sizeof(uint16_t);
|
|
224
|
-
if (align == 0) {
|
|
225
|
-
// MSVC has no strict aliasing, and is able to highly optimize this case.
|
|
226
|
-
uint16_t* data16 = reinterpret_cast<uint16_t*>(data);
|
|
227
|
-
size_t len16 = nbytes / sizeof(*data16);
|
|
228
|
-
for (size_t i = 0; i < len16; i++) {
|
|
229
|
-
data16[i] = BSWAP_2(data16[i]);
|
|
230
|
-
}
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
#endif
|
|
234
|
-
|
|
235
|
-
uint16_t temp;
|
|
236
|
-
for (size_t i = 0; i < nbytes; i += sizeof(temp)) {
|
|
237
|
-
memcpy(&temp, &data[i], sizeof(temp));
|
|
238
|
-
temp = BSWAP_2(temp);
|
|
239
|
-
memcpy(&data[i], &temp, sizeof(temp));
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
void SwapBytes32(char* data, size_t nbytes) {
|
|
244
|
-
CHECK_EQ(nbytes % 4, 0);
|
|
245
|
-
|
|
246
|
-
#if defined(_MSC_VER)
|
|
247
|
-
int align = reinterpret_cast<uintptr_t>(data) % sizeof(uint32_t);
|
|
248
|
-
// MSVC has no strict aliasing, and is able to highly optimize this case.
|
|
249
|
-
if (align == 0) {
|
|
250
|
-
uint32_t* data32 = reinterpret_cast<uint32_t*>(data);
|
|
251
|
-
size_t len32 = nbytes / sizeof(*data32);
|
|
252
|
-
for (size_t i = 0; i < len32; i++) {
|
|
253
|
-
data32[i] = BSWAP_4(data32[i]);
|
|
254
|
-
}
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
#endif
|
|
258
|
-
|
|
259
|
-
uint32_t temp;
|
|
260
|
-
for (size_t i = 0; i < nbytes; i += sizeof(temp)) {
|
|
261
|
-
memcpy(&temp, &data[i], sizeof(temp));
|
|
262
|
-
temp = BSWAP_4(temp);
|
|
263
|
-
memcpy(&data[i], &temp, sizeof(temp));
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
void SwapBytes64(char* data, size_t nbytes) {
|
|
268
|
-
CHECK_EQ(nbytes % 8, 0);
|
|
269
|
-
|
|
270
|
-
#if defined(_MSC_VER)
|
|
271
|
-
int align = reinterpret_cast<uintptr_t>(data) % sizeof(uint64_t);
|
|
272
|
-
if (align == 0) {
|
|
273
|
-
// MSVC has no strict aliasing, and is able to highly optimize this case.
|
|
274
|
-
uint64_t* data64 = reinterpret_cast<uint64_t*>(data);
|
|
275
|
-
size_t len64 = nbytes / sizeof(*data64);
|
|
276
|
-
for (size_t i = 0; i < len64; i++) {
|
|
277
|
-
data64[i] = BSWAP_8(data64[i]);
|
|
278
|
-
}
|
|
279
|
-
return;
|
|
280
|
-
}
|
|
281
|
-
#endif
|
|
282
|
-
|
|
283
|
-
uint64_t temp;
|
|
284
|
-
for (size_t i = 0; i < nbytes; i += sizeof(temp)) {
|
|
285
|
-
memcpy(&temp, &data[i], sizeof(temp));
|
|
286
|
-
temp = BSWAP_8(temp);
|
|
287
|
-
memcpy(&data[i], &temp, sizeof(temp));
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
char ToLower(char c) {
|
|
292
|
-
return c >= 'A' && c <= 'Z' ? c + ('a' - 'A') : c;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
std::string ToLower(const std::string& in) {
|
|
296
|
-
std::string out(in.size(), 0);
|
|
297
|
-
for (size_t i = 0; i < in.size(); ++i)
|
|
298
|
-
out[i] = ToLower(in[i]);
|
|
299
|
-
return out;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
bool StringEqualNoCase(const char* a, const char* b) {
|
|
303
|
-
do {
|
|
304
|
-
if (*a == '\0')
|
|
305
|
-
return *b == '\0';
|
|
306
|
-
if (*b == '\0')
|
|
307
|
-
return *a == '\0';
|
|
308
|
-
} while (ToLower(*a++) == ToLower(*b++));
|
|
309
|
-
return false;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
bool StringEqualNoCaseN(const char* a, const char* b, size_t length) {
|
|
313
|
-
for (size_t i = 0; i < length; i++) {
|
|
314
|
-
if (ToLower(a[i]) != ToLower(b[i]))
|
|
315
|
-
return false;
|
|
316
|
-
if (a[i] == '\0')
|
|
317
|
-
return true;
|
|
318
|
-
}
|
|
319
|
-
return true;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
template <typename T>
|
|
323
|
-
inline T MultiplyWithOverflowCheck(T a, T b) {
|
|
324
|
-
auto ret = a * b;
|
|
325
|
-
if (a != 0)
|
|
326
|
-
CHECK_EQ(b, ret / a);
|
|
327
|
-
|
|
328
|
-
return ret;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
// These should be used in our code as opposed to the native
|
|
332
|
-
// versions as they abstract out some platform and or
|
|
333
|
-
// compiler version specific functionality.
|
|
334
|
-
// malloc(0) and realloc(ptr, 0) have implementation-defined behavior in
|
|
335
|
-
// that the standard allows them to either return a unique pointer or a
|
|
336
|
-
// nullptr for zero-sized allocation requests. Normalize by always using
|
|
337
|
-
// a nullptr.
|
|
338
|
-
template <typename T>
|
|
339
|
-
T* UncheckedRealloc(T* pointer, size_t n) {
|
|
340
|
-
size_t full_size = MultiplyWithOverflowCheck(sizeof(T), n);
|
|
341
|
-
|
|
342
|
-
if (full_size == 0) {
|
|
343
|
-
free(pointer);
|
|
344
|
-
return nullptr;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
void* allocated = realloc(pointer, full_size);
|
|
348
|
-
|
|
349
|
-
if (UNLIKELY(allocated == nullptr)) {
|
|
350
|
-
// Tell V8 that memory is low and retry.
|
|
351
|
-
LowMemoryNotification();
|
|
352
|
-
allocated = realloc(pointer, full_size);
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
return static_cast<T*>(allocated);
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
// As per spec realloc behaves like malloc if passed nullptr.
|
|
359
|
-
template <typename T>
|
|
360
|
-
inline T* UncheckedMalloc(size_t n) {
|
|
361
|
-
if (n == 0) n = 1;
|
|
362
|
-
return UncheckedRealloc<T>(nullptr, n);
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
template <typename T>
|
|
366
|
-
inline T* UncheckedCalloc(size_t n) {
|
|
367
|
-
if (n == 0) n = 1;
|
|
368
|
-
MultiplyWithOverflowCheck(sizeof(T), n);
|
|
369
|
-
return static_cast<T*>(calloc(n, sizeof(T)));
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
template <typename T>
|
|
373
|
-
inline T* Realloc(T* pointer, size_t n) {
|
|
374
|
-
T* ret = UncheckedRealloc(pointer, n);
|
|
375
|
-
CHECK_IMPLIES(n > 0, ret != nullptr);
|
|
376
|
-
return ret;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
template <typename T>
|
|
380
|
-
inline T* Malloc(size_t n) {
|
|
381
|
-
T* ret = UncheckedMalloc<T>(n);
|
|
382
|
-
CHECK_IMPLIES(n > 0, ret != nullptr);
|
|
383
|
-
return ret;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
template <typename T>
|
|
387
|
-
inline T* Calloc(size_t n) {
|
|
388
|
-
T* ret = UncheckedCalloc<T>(n);
|
|
389
|
-
CHECK_IMPLIES(n > 0, ret != nullptr);
|
|
390
|
-
return ret;
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
// Shortcuts for char*.
|
|
394
|
-
inline char* Malloc(size_t n) { return Malloc<char>(n); }
|
|
395
|
-
inline char* Calloc(size_t n) { return Calloc<char>(n); }
|
|
396
|
-
inline char* UncheckedMalloc(size_t n) { return UncheckedMalloc<char>(n); }
|
|
397
|
-
inline char* UncheckedCalloc(size_t n) { return UncheckedCalloc<char>(n); }
|
|
398
|
-
|
|
399
|
-
// This is a helper in the .cc file so including util-inl.h doesn't include more
|
|
400
|
-
// headers than we really need to.
|
|
401
|
-
void ThrowErrStringTooLong(v8::Isolate* isolate);
|
|
402
|
-
|
|
403
|
-
v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
|
|
404
|
-
const std::string& str) {
|
|
405
|
-
v8::Isolate* isolate = context->GetIsolate();
|
|
406
|
-
if (UNLIKELY(str.size() >= static_cast<size_t>(v8::String::kMaxLength))) {
|
|
407
|
-
// V8 only has a TODO comment about adding an exception when the maximum
|
|
408
|
-
// string size is exceeded.
|
|
409
|
-
ThrowErrStringTooLong(isolate);
|
|
410
|
-
return v8::MaybeLocal<v8::Value>();
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
return v8::String::NewFromUtf8(
|
|
414
|
-
isolate, str.data(), v8::NewStringType::kNormal, str.size())
|
|
415
|
-
.FromMaybe(v8::Local<v8::String>());
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
template <typename T>
|
|
419
|
-
v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
|
|
420
|
-
const std::vector<T>& vec) {
|
|
421
|
-
v8::Isolate* isolate = context->GetIsolate();
|
|
422
|
-
v8::EscapableHandleScope handle_scope(isolate);
|
|
423
|
-
|
|
424
|
-
v8::Local<v8::Array> arr = v8::Array::New(isolate, vec.size());
|
|
425
|
-
for (size_t i = 0; i < vec.size(); ++i) {
|
|
426
|
-
v8::Local<v8::Value> val;
|
|
427
|
-
if (!ToV8Value(context, vec[i]).ToLocal(&val) ||
|
|
428
|
-
arr->Set(context, i, val).IsNothing()) {
|
|
429
|
-
return v8::MaybeLocal<v8::Value>();
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
return handle_scope.Escape(arr);
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
template <typename T, typename U>
|
|
437
|
-
v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
|
|
438
|
-
const std::unordered_map<T, U>& map) {
|
|
439
|
-
v8::Isolate* isolate = context->GetIsolate();
|
|
440
|
-
v8::EscapableHandleScope handle_scope(isolate);
|
|
441
|
-
|
|
442
|
-
v8::Local<v8::Map> ret = v8::Map::New(isolate);
|
|
443
|
-
for (const auto& item : map) {
|
|
444
|
-
v8::Local<v8::Value> first, second;
|
|
445
|
-
if (!ToV8Value(context, item.first).ToLocal(&first) ||
|
|
446
|
-
!ToV8Value(context, item.second).ToLocal(&second) ||
|
|
447
|
-
ret->Set(context, first, second).IsEmpty()) {
|
|
448
|
-
return v8::MaybeLocal<v8::Value>();
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
return handle_scope.Escape(ret);
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
} // namespace node
|
|
456
|
-
|
|
457
|
-
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
458
|
-
|
|
459
|
-
#endif // SRC_UTIL_INL_H_
|