@encharm/cws 4.3.0 → 4.4.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/README.md +5 -7
- package/dist/bindings/cws_darwin_arm64_node108.node +0 -0
- package/dist/bindings/cws_darwin_arm64_node115.node +0 -0
- package/dist/bindings/cws_darwin_arm64_node83.node +0 -0
- package/dist/bindings/cws_darwin_arm64_node93.node +0 -0
- package/dist/bindings/cws_darwin_x64_node108.node +0 -0
- package/dist/bindings/cws_darwin_x64_node115.node +0 -0
- package/dist/bindings/cws_darwin_x64_node83.node +0 -0
- package/dist/bindings/cws_darwin_x64_node93.node +0 -0
- package/dist/bindings/cws_linux_arm64_node108.node +0 -0
- package/dist/bindings/cws_linux_arm64_node115.node +0 -0
- package/dist/bindings/cws_linux_arm64_node83.node +0 -0
- package/dist/bindings/cws_linux_arm64_node93.node +0 -0
- package/dist/bindings/cws_linux_x64_node108.node +0 -0
- package/dist/bindings/cws_linux_x64_node115.node +0 -0
- package/dist/bindings/cws_linux_x64_node83.node +0 -0
- package/dist/bindings/cws_linux_x64_node93.node +0 -0
- package/dist/bindings/cws_win32_x64_node108.node +0 -0
- package/dist/bindings/cws_win32_x64_node115.node +0 -0
- package/dist/bindings/cws_win32_x64_node83.node +0 -0
- package/dist/bindings/cws_win32_x64_node93.node +0 -0
- package/dist/shared.js +1 -1
- package/package.json +5 -5
- package/src/Addon.cpp +4 -12
- package/src/Addon.h +55 -90
- package/src/Socket.h +1 -0
- package/src/cSNode.cpp +3 -8
- package/src/headers/20/acorn_version.h +6 -0
- package/src/headers/20/aliased_buffer-inl.h +243 -0
- package/src/headers/20/aliased_buffer.h +206 -0
- package/src/headers/20/aliased_struct-inl.h +54 -0
- package/src/headers/20/aliased_struct.h +63 -0
- package/src/headers/20/async_wrap-inl.h +93 -0
- package/src/headers/20/async_wrap.h +252 -0
- package/src/headers/20/base64-inl.h +193 -0
- package/src/headers/20/base64.h +53 -0
- package/src/headers/20/base64_version.h +6 -0
- package/src/headers/20/base_object-inl.h +316 -0
- package/src/headers/20/base_object.h +320 -0
- package/src/headers/20/base_object_types.h +73 -0
- package/src/headers/20/blob_serializer_deserializer-inl.h +361 -0
- package/src/headers/20/blob_serializer_deserializer.h +132 -0
- package/src/headers/20/callback_queue-inl.h +97 -0
- package/src/headers/20/callback_queue.h +79 -0
- package/src/headers/20/cares_wrap.h +524 -0
- package/src/headers/20/cjs_module_lexer_version.h +6 -0
- package/src/headers/20/cleanup_queue-inl.h +62 -0
- package/src/headers/20/cleanup_queue.h +85 -0
- package/src/headers/20/connect_wrap.h +26 -0
- package/src/headers/20/connection_wrap.h +29 -0
- package/src/headers/20/cppgc/DEPS +8 -0
- package/src/headers/20/cppgc/OWNERS +2 -0
- package/src/headers/20/cppgc/README.md +135 -0
- package/src/headers/20/cppgc/allocation.h +310 -0
- package/src/headers/20/cppgc/common.h +28 -0
- package/src/headers/20/cppgc/cross-thread-persistent.h +466 -0
- package/src/headers/20/cppgc/custom-space.h +97 -0
- package/src/headers/20/cppgc/default-platform.h +67 -0
- package/src/headers/20/cppgc/ephemeron-pair.h +30 -0
- package/src/headers/20/cppgc/explicit-management.h +100 -0
- package/src/headers/20/cppgc/garbage-collected.h +106 -0
- package/src/headers/20/cppgc/heap-consistency.h +309 -0
- package/src/headers/20/cppgc/heap-handle.h +48 -0
- package/src/headers/20/cppgc/heap-state.h +82 -0
- package/src/headers/20/cppgc/heap-statistics.h +120 -0
- package/src/headers/20/cppgc/heap.h +202 -0
- package/src/headers/20/cppgc/internal/api-constants.h +68 -0
- package/src/headers/20/cppgc/internal/atomic-entry-flag.h +48 -0
- package/src/headers/20/cppgc/internal/base-page-handle.h +45 -0
- package/src/headers/20/cppgc/internal/caged-heap-local-data.h +111 -0
- package/src/headers/20/cppgc/internal/caged-heap.h +61 -0
- package/src/headers/20/cppgc/internal/compiler-specific.h +38 -0
- package/src/headers/20/cppgc/internal/finalizer-trait.h +93 -0
- package/src/headers/20/cppgc/internal/gc-info.h +157 -0
- package/src/headers/20/cppgc/internal/logging.h +50 -0
- package/src/headers/20/cppgc/internal/member-storage.h +248 -0
- package/src/headers/20/cppgc/internal/name-trait.h +137 -0
- package/src/headers/20/cppgc/internal/persistent-node.h +214 -0
- package/src/headers/20/cppgc/internal/pointer-policies.h +243 -0
- package/src/headers/20/cppgc/internal/write-barrier.h +487 -0
- package/src/headers/20/cppgc/liveness-broker.h +78 -0
- package/src/headers/20/cppgc/macros.h +35 -0
- package/src/headers/20/cppgc/member.h +604 -0
- package/src/headers/20/cppgc/name-provider.h +65 -0
- package/src/headers/20/cppgc/object-size-trait.h +58 -0
- package/src/headers/20/cppgc/persistent.h +373 -0
- package/src/headers/20/cppgc/platform.h +158 -0
- package/src/headers/20/cppgc/prefinalizer.h +75 -0
- package/src/headers/20/cppgc/process-heap-statistics.h +36 -0
- package/src/headers/20/cppgc/sentinel-pointer.h +32 -0
- package/src/headers/20/cppgc/source-location.h +92 -0
- package/src/headers/20/cppgc/testing.h +106 -0
- package/src/headers/20/cppgc/trace-trait.h +120 -0
- package/src/headers/20/cppgc/type-traits.h +250 -0
- package/src/headers/20/cppgc/visitor.h +426 -0
- package/src/headers/20/crypto/crypto_clienthello.h +131 -0
- package/src/headers/20/crypto/crypto_context.h +160 -0
- package/src/headers/20/crypto/crypto_keys.h +416 -0
- package/src/headers/20/crypto/crypto_tls.h +295 -0
- package/src/headers/20/crypto/crypto_util.h +805 -0
- package/src/headers/20/crypto_clienthello.h +131 -0
- package/src/headers/20/debug_utils-inl.h +226 -0
- package/src/headers/20/debug_utils.h +188 -0
- package/src/headers/20/diagnosticfilename-inl.h +33 -0
- package/src/headers/20/encoding_binding.h +59 -0
- package/src/headers/20/env-inl.h +923 -0
- package/src/headers/20/env.h +1193 -0
- package/src/headers/20/env_properties.h +444 -0
- package/src/headers/20/handle_wrap.h +123 -0
- package/src/headers/20/histogram-inl.h +107 -0
- package/src/headers/20/histogram.h +240 -0
- package/src/headers/20/inspector_agent.h +144 -0
- package/src/headers/20/inspector_io.h +78 -0
- package/src/headers/20/inspector_profiler.h +149 -0
- package/src/headers/20/inspector_socket.h +60 -0
- package/src/headers/20/inspector_socket_server.h +110 -0
- package/src/headers/20/js_native_api.h +591 -0
- package/src/headers/20/js_native_api_types.h +168 -0
- package/src/headers/20/js_native_api_v8.h +426 -0
- package/src/headers/20/js_native_api_v8_internals.h +39 -0
- package/src/headers/20/js_stream.h +52 -0
- package/src/headers/20/json_parser.h +38 -0
- package/src/headers/20/json_utils.h +172 -0
- package/src/headers/20/memory_tracker-inl.h +356 -0
- package/src/headers/20/memory_tracker.h +289 -0
- package/src/headers/20/module_wrap.h +117 -0
- package/src/headers/20/node.h +1514 -0
- package/src/headers/20/node_api.h +260 -0
- package/src/headers/20/node_api_internals.h +42 -0
- package/src/headers/20/node_api_types.h +52 -0
- package/src/headers/20/node_binding.h +142 -0
- package/src/headers/20/node_blob.h +159 -0
- package/src/headers/20/node_bob-inl.h +36 -0
- package/src/headers/20/node_bob.h +107 -0
- package/src/headers/20/node_buffer.h +92 -0
- package/src/headers/20/node_builtins.h +197 -0
- package/src/headers/20/node_constants.h +79 -0
- package/src/headers/20/node_context_data.h +98 -0
- package/src/headers/20/node_contextify.h +182 -0
- package/src/headers/20/node_crypto.h +56 -0
- package/src/headers/20/node_dir.h +52 -0
- package/src/headers/20/node_dotenv.h +37 -0
- package/src/headers/20/node_errors.h +313 -0
- package/src/headers/20/node_exit_code.h +54 -0
- package/src/headers/20/node_external_reference.h +172 -0
- package/src/headers/20/node_file-inl.h +357 -0
- package/src/headers/20/node_file.h +524 -0
- package/src/headers/20/node_http2.h +1146 -0
- package/src/headers/20/node_http2_state.h +147 -0
- package/src/headers/20/node_http_common-inl.h +201 -0
- package/src/headers/20/node_http_common.h +532 -0
- package/src/headers/20/node_i18n.h +145 -0
- package/src/headers/20/node_internals.h +443 -0
- package/src/headers/20/node_main_instance.h +67 -0
- package/src/headers/20/node_mem-inl.h +112 -0
- package/src/headers/20/node_mem.h +45 -0
- package/src/headers/20/node_messaging.h +377 -0
- package/src/headers/20/node_metadata.h +138 -0
- package/src/headers/20/node_mutex.h +323 -0
- package/src/headers/20/node_object_wrap.h +132 -0
- package/src/headers/20/node_options-inl.h +478 -0
- package/src/headers/20/node_options.h +538 -0
- package/src/headers/20/node_perf.h +166 -0
- package/src/headers/20/node_perf_common.h +98 -0
- package/src/headers/20/node_platform.h +195 -0
- package/src/headers/20/node_process-inl.h +26 -0
- package/src/headers/20/node_process.h +99 -0
- package/src/headers/20/node_realm-inl.h +139 -0
- package/src/headers/20/node_realm.h +184 -0
- package/src/headers/20/node_report.h +42 -0
- package/src/headers/20/node_revert.h +82 -0
- package/src/headers/20/node_root_certs.h +3443 -0
- package/src/headers/20/node_sea.h +56 -0
- package/src/headers/20/node_shadow_realm.h +46 -0
- package/src/headers/20/node_snapshot_builder.h +54 -0
- package/src/headers/20/node_snapshotable.h +164 -0
- package/src/headers/20/node_sockaddr-inl.h +266 -0
- package/src/headers/20/node_sockaddr.h +405 -0
- package/src/headers/20/node_stat_watcher.h +73 -0
- package/src/headers/20/node_threadsafe_cow-inl.h +54 -0
- package/src/headers/20/node_threadsafe_cow.h +105 -0
- package/src/headers/20/node_union_bytes.h +81 -0
- package/src/headers/20/node_url.h +92 -0
- package/src/headers/20/node_v8.h +77 -0
- package/src/headers/20/node_v8_platform-inl.h +205 -0
- package/src/headers/20/node_version.h +109 -0
- package/src/headers/20/node_wasi.h +184 -0
- package/src/headers/20/node_wasm_web_api.h +55 -0
- package/src/headers/20/node_watchdog.h +154 -0
- package/src/headers/20/node_worker.h +151 -0
- package/src/headers/20/permission/child_process_permission.h +28 -0
- package/src/headers/20/permission/fs_permission.h +152 -0
- package/src/headers/20/permission/permission.h +71 -0
- package/src/headers/20/permission/permission_base.h +49 -0
- package/src/headers/20/permission/worker_permission.h +28 -0
- package/src/headers/20/pipe_wrap.h +80 -0
- package/src/headers/20/req_wrap-inl.h +171 -0
- package/src/headers/20/req_wrap.h +77 -0
- package/src/headers/20/spawn_sync.h +242 -0
- package/src/headers/20/stream_base-inl.h +173 -0
- package/src/headers/20/stream_base.h +469 -0
- package/src/headers/20/stream_pipe.h +76 -0
- package/src/headers/20/stream_wrap.h +131 -0
- package/src/headers/20/string_bytes.h +120 -0
- package/src/headers/20/string_decoder-inl.h +37 -0
- package/src/headers/20/string_decoder.h +50 -0
- package/src/headers/20/string_search.h +638 -0
- package/src/headers/20/tcp_wrap.h +105 -0
- package/src/headers/20/threadpoolwork-inl.h +70 -0
- package/src/headers/20/timer_wrap-inl.h +32 -0
- package/src/headers/20/timer_wrap.h +85 -0
- package/src/headers/20/timers.h +70 -0
- package/src/headers/20/tracing/agent.h +195 -0
- package/src/headers/20/tracing/trace_event.h +720 -0
- package/src/headers/20/tracing/trace_event_common.h +1109 -0
- package/src/headers/20/tty_wrap.h +65 -0
- package/src/headers/20/udp_wrap.h +227 -0
- package/src/headers/20/undici_version.h +6 -0
- package/src/headers/20/util-inl.h +623 -0
- package/src/headers/20/util.h +988 -0
- package/src/headers/20/v8-cppgc.h +245 -0
- package/src/headers/20/v8-fast-api-calls.h +957 -0
- package/dist/bindings/cws_darwin_arm64_node64.node +0 -0
- package/dist/bindings/cws_darwin_arm64_node72.node +0 -0
- package/dist/bindings/cws_darwin_arm64_node79.node +0 -0
- package/dist/bindings/cws_darwin_x64_node64.node +0 -0
- package/dist/bindings/cws_darwin_x64_node72.node +0 -0
- package/dist/bindings/cws_darwin_x64_node79.node +0 -0
- package/dist/bindings/cws_linux_x64_node64.node +0 -0
- package/dist/bindings/cws_linux_x64_node72.node +0 -0
- package/dist/bindings/cws_linux_x64_node79.node +0 -0
- package/dist/bindings/cws_win32_x64_node64.node +0 -0
- package/dist/bindings/cws_win32_x64_node72.node +0 -0
- package/dist/bindings/cws_win32_x64_node79.node +0 -0
|
@@ -0,0 +1,120 @@
|
|
|
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_STRING_BYTES_H_
|
|
23
|
+
#define SRC_STRING_BYTES_H_
|
|
24
|
+
|
|
25
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
26
|
+
|
|
27
|
+
// Decodes a v8::Local<v8::String> or Buffer to a raw char*
|
|
28
|
+
|
|
29
|
+
#include "v8.h"
|
|
30
|
+
#include "env-inl.h"
|
|
31
|
+
|
|
32
|
+
#include <string>
|
|
33
|
+
|
|
34
|
+
namespace node {
|
|
35
|
+
|
|
36
|
+
class StringBytes {
|
|
37
|
+
public:
|
|
38
|
+
class InlineDecoder : public MaybeStackBuffer<char> {
|
|
39
|
+
public:
|
|
40
|
+
inline v8::Maybe<bool> Decode(Environment* env,
|
|
41
|
+
v8::Local<v8::String> string,
|
|
42
|
+
enum encoding enc) {
|
|
43
|
+
size_t storage;
|
|
44
|
+
if (!StringBytes::StorageSize(env->isolate(), string, enc).To(&storage))
|
|
45
|
+
return v8::Nothing<bool>();
|
|
46
|
+
AllocateSufficientStorage(storage);
|
|
47
|
+
const size_t length =
|
|
48
|
+
StringBytes::Write(env->isolate(), out(), storage, string, enc);
|
|
49
|
+
|
|
50
|
+
// No zero terminator is included when using this method.
|
|
51
|
+
SetLength(length);
|
|
52
|
+
return v8::Just(true);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
inline size_t size() const { return length(); }
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// Fast, but can be 2 bytes oversized for Base64, and
|
|
59
|
+
// as much as triple UTF-8 strings <= 65536 chars in length
|
|
60
|
+
static v8::Maybe<size_t> StorageSize(v8::Isolate* isolate,
|
|
61
|
+
v8::Local<v8::Value> val,
|
|
62
|
+
enum encoding enc);
|
|
63
|
+
|
|
64
|
+
// Precise byte count, but slightly slower for Base64 and
|
|
65
|
+
// very much slower for UTF-8
|
|
66
|
+
static v8::Maybe<size_t> Size(v8::Isolate* isolate,
|
|
67
|
+
v8::Local<v8::Value> val,
|
|
68
|
+
enum encoding enc);
|
|
69
|
+
|
|
70
|
+
// Write the bytes from the string or buffer into the char*
|
|
71
|
+
// returns the number of bytes written, which will always be
|
|
72
|
+
// <= buflen. Use StorageSize/Size first to know how much
|
|
73
|
+
// memory to allocate.
|
|
74
|
+
static size_t Write(v8::Isolate* isolate,
|
|
75
|
+
char* buf,
|
|
76
|
+
size_t buflen,
|
|
77
|
+
v8::Local<v8::Value> val,
|
|
78
|
+
enum encoding enc);
|
|
79
|
+
|
|
80
|
+
// Take the bytes in the src, and turn it into a Buffer or String.
|
|
81
|
+
static v8::MaybeLocal<v8::Value> Encode(v8::Isolate* isolate,
|
|
82
|
+
const char* buf,
|
|
83
|
+
size_t buflen,
|
|
84
|
+
enum encoding encoding,
|
|
85
|
+
v8::Local<v8::Value>* error);
|
|
86
|
+
|
|
87
|
+
// Warning: This reverses endianness on BE platforms, even though the
|
|
88
|
+
// signature using uint16_t implies that it should not.
|
|
89
|
+
// However, the brokenness is already public API and can't therefore
|
|
90
|
+
// be changed easily.
|
|
91
|
+
static v8::MaybeLocal<v8::Value> Encode(v8::Isolate* isolate,
|
|
92
|
+
const uint16_t* buf,
|
|
93
|
+
size_t buflen,
|
|
94
|
+
v8::Local<v8::Value>* error);
|
|
95
|
+
|
|
96
|
+
static v8::MaybeLocal<v8::Value> Encode(v8::Isolate* isolate,
|
|
97
|
+
const char* buf,
|
|
98
|
+
enum encoding encoding,
|
|
99
|
+
v8::Local<v8::Value>* error);
|
|
100
|
+
|
|
101
|
+
static size_t hex_encode(const char* src,
|
|
102
|
+
size_t slen,
|
|
103
|
+
char* dst,
|
|
104
|
+
size_t dlen);
|
|
105
|
+
|
|
106
|
+
static std::string hex_encode(const char* src, size_t slen);
|
|
107
|
+
|
|
108
|
+
private:
|
|
109
|
+
static size_t WriteUCS2(v8::Isolate* isolate,
|
|
110
|
+
char* buf,
|
|
111
|
+
size_t buflen,
|
|
112
|
+
v8::Local<v8::String> str,
|
|
113
|
+
int flags);
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
} // namespace node
|
|
117
|
+
|
|
118
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
119
|
+
|
|
120
|
+
#endif // SRC_STRING_BYTES_H_
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#ifndef SRC_STRING_DECODER_INL_H_
|
|
2
|
+
#define SRC_STRING_DECODER_INL_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#include "string_decoder.h"
|
|
7
|
+
|
|
8
|
+
namespace node {
|
|
9
|
+
|
|
10
|
+
void StringDecoder::SetEncoding(enum encoding encoding) {
|
|
11
|
+
state_[kBufferedBytes] = 0;
|
|
12
|
+
state_[kMissingBytes] = 0;
|
|
13
|
+
state_[kEncodingField] = encoding;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
enum encoding StringDecoder::Encoding() const {
|
|
17
|
+
return static_cast<enum encoding>(state_[kEncodingField]);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
unsigned StringDecoder::BufferedBytes() const {
|
|
21
|
+
return state_[kBufferedBytes];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
unsigned StringDecoder::MissingBytes() const {
|
|
25
|
+
return state_[kMissingBytes];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
char* StringDecoder::IncompleteCharacterBuffer() {
|
|
29
|
+
return reinterpret_cast<char*>(state_ + kIncompleteCharactersStart);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
} // namespace node
|
|
34
|
+
|
|
35
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
36
|
+
|
|
37
|
+
#endif // SRC_STRING_DECODER_INL_H_
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#ifndef SRC_STRING_DECODER_H_
|
|
2
|
+
#define SRC_STRING_DECODER_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#include "node.h"
|
|
7
|
+
|
|
8
|
+
namespace node {
|
|
9
|
+
|
|
10
|
+
class StringDecoder {
|
|
11
|
+
public:
|
|
12
|
+
StringDecoder() { state_[kEncodingField] = BUFFER; }
|
|
13
|
+
inline void SetEncoding(enum encoding encoding);
|
|
14
|
+
inline enum encoding Encoding() const;
|
|
15
|
+
|
|
16
|
+
inline char* IncompleteCharacterBuffer();
|
|
17
|
+
inline unsigned MissingBytes() const;
|
|
18
|
+
inline unsigned BufferedBytes() const;
|
|
19
|
+
|
|
20
|
+
// Decode a string from the specified encoding.
|
|
21
|
+
// The value pointed to by `nread` will be modified to reflect that
|
|
22
|
+
// less data may have been read because it ended on an incomplete character
|
|
23
|
+
// and more data may have been read because a previously incomplete character
|
|
24
|
+
// was finished.
|
|
25
|
+
v8::MaybeLocal<v8::String> DecodeData(v8::Isolate* isolate,
|
|
26
|
+
const char* data,
|
|
27
|
+
size_t* nread);
|
|
28
|
+
// Flush an incomplete character. For character encodings like UTF8 this
|
|
29
|
+
// means printing replacement characters, buf for e.g. Base64 the returned
|
|
30
|
+
// string contains more data.
|
|
31
|
+
v8::MaybeLocal<v8::String> FlushData(v8::Isolate* isolate);
|
|
32
|
+
|
|
33
|
+
enum Fields {
|
|
34
|
+
kIncompleteCharactersStart = 0,
|
|
35
|
+
kIncompleteCharactersEnd = 4,
|
|
36
|
+
kMissingBytes = 4,
|
|
37
|
+
kBufferedBytes = 5,
|
|
38
|
+
kEncodingField = 6,
|
|
39
|
+
kNumFields = 7
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
private:
|
|
43
|
+
uint8_t state_[kNumFields] = {};
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
} // namespace node
|
|
47
|
+
|
|
48
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
49
|
+
|
|
50
|
+
#endif // SRC_STRING_DECODER_H_
|