visaljs 0.0.9 → 0.0.11
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 +12 -4
- package/THIRD_PARTY_LICENSES +31 -1
- package/cli.js +3745 -890
- package/node/include/js_node.h +12 -1
- package/node/prelude/_http_common.js +29 -0
- package/node/prelude/async_hooks.js +50 -11
- package/node/prelude/child_process.js +31 -4
- package/node/prelude/console.js +311 -143
- package/node/prelude/crypto.js +6 -4
- package/node/prelude/dgram.js +1169 -0
- package/node/prelude/diagnostics_channel.js +3 -1
- package/node/prelude/dns.js +250 -45
- package/node/prelude/dns_promises.js +8 -2
- package/node/prelude/fs_promises.js +9 -1
- package/node/prelude/http.js +405 -94
- package/node/prelude/https.js +13 -4
- package/node/prelude/internal/console_class.js +7 -0
- package/node/prelude/internal/console_global.js +25 -0
- package/node/prelude/internal/crypto/key_encryption.js +217 -0
- package/node/prelude/internal/crypto/keys.js +161 -26
- package/node/prelude/internal/crypto/random.js +24 -0
- package/node/prelude/internal/crypto/util.js +2 -1
- package/node/prelude/internal/crypto_x509.js +161 -0
- package/node/prelude/internal/dns_classes.js +6 -0
- package/node/prelude/internal/dns_resolver.js +371 -0
- package/node/prelude/internal/errors.js +9 -0
- package/node/prelude/internal/events_on.js +82 -37
- package/node/prelude/internal/features.js +8 -4
- package/node/prelude/internal/fs_filehandle.js +10 -4
- package/node/prelude/internal/http_chars.ts +22 -0
- package/node/prelude/internal/perf_histogram.js +1 -1
- package/node/prelude/internal/process_more.js +32 -17
- package/node/prelude/internal/process_signals.js +8 -2
- package/node/prelude/internal/punycode.ts +163 -0
- package/node/prelude/internal/readline.js +648 -274
- package/node/prelude/internal/readline_editor.js +1240 -0
- package/node/prelude/internal/string_width.js +43 -0
- package/node/prelude/internal/tls/common.js +145 -33
- package/node/prelude/internal/tls/wrap.js +182 -49
- package/node/prelude/internal/tls/x509.js +4 -1
- package/node/prelude/internal/udp.js +177 -0
- package/node/prelude/net.js +30 -14
- package/node/prelude/os.js +24 -6
- package/node/prelude/perf_hooks.js +37 -2
- package/node/prelude/punycode.js +2 -130
- package/node/prelude/readline.js +113 -4
- package/node/prelude/readline_promises.js +56 -32
- package/node/prelude/tls.js +21 -4
- package/node/prelude/util.js +3 -16
- package/node/src/host_dns.c +623 -0
- package/node/src/host_http.c +12 -0
- package/node/src/host_net.c +46 -0
- package/node/src/host_os.c +1 -6
- package/node/src/host_sys.c +79 -0
- package/node/src/host_udp.c +418 -0
- package/node/third_party/c-ares/LICENSE.md +24 -0
- package/node/third_party/c-ares/config/darwin/ares_config.h +573 -0
- package/node/third_party/c-ares/config/freebsd/ares_config.h +573 -0
- package/node/third_party/c-ares/config/linux/ares_config.h +573 -0
- package/node/third_party/c-ares/config/openbsd/ares_config.h +583 -0
- package/node/third_party/c-ares/include/ares.h +1237 -0
- package/node/third_party/c-ares/include/ares_build.h +202 -0
- package/node/third_party/c-ares/include/ares_dns.h +127 -0
- package/node/third_party/c-ares/include/ares_dns_record.h +1119 -0
- package/node/third_party/c-ares/include/ares_nameser.h +510 -0
- package/node/third_party/c-ares/include/ares_version.h +47 -0
- package/node/third_party/c-ares/src/lib/ares_addrinfo2hostent.c +305 -0
- package/node/third_party/c-ares/src/lib/ares_addrinfo_localhost.c +245 -0
- package/node/third_party/c-ares/src/lib/ares_android.c +496 -0
- package/node/third_party/c-ares/src/lib/ares_android.h +38 -0
- package/node/third_party/c-ares/src/lib/ares_cancel.c +87 -0
- package/node/third_party/c-ares/src/lib/ares_close_sockets.c +137 -0
- package/node/third_party/c-ares/src/lib/ares_conn.c +511 -0
- package/node/third_party/c-ares/src/lib/ares_conn.h +202 -0
- package/node/third_party/c-ares/src/lib/ares_cookie.c +461 -0
- package/node/third_party/c-ares/src/lib/ares_data.c +168 -0
- package/node/third_party/c-ares/src/lib/ares_data.h +92 -0
- package/node/third_party/c-ares/src/lib/ares_destroy.c +159 -0
- package/node/third_party/c-ares/src/lib/ares_free_hostent.c +54 -0
- package/node/third_party/c-ares/src/lib/ares_free_string.c +33 -0
- package/node/third_party/c-ares/src/lib/ares_freeaddrinfo.c +67 -0
- package/node/third_party/c-ares/src/lib/ares_getaddrinfo.c +806 -0
- package/node/third_party/c-ares/src/lib/ares_getenv.c +38 -0
- package/node/third_party/c-ares/src/lib/ares_getenv.h +34 -0
- package/node/third_party/c-ares/src/lib/ares_gethostbyaddr.c +229 -0
- package/node/third_party/c-ares/src/lib/ares_gethostbyname.c +341 -0
- package/node/third_party/c-ares/src/lib/ares_getnameinfo.c +437 -0
- package/node/third_party/c-ares/src/lib/ares_hosts_file.c +960 -0
- package/node/third_party/c-ares/src/lib/ares_inet_net_pton.h +31 -0
- package/node/third_party/c-ares/src/lib/ares_init.c +631 -0
- package/node/third_party/c-ares/src/lib/ares_ipv6.h +115 -0
- package/node/third_party/c-ares/src/lib/ares_library_init.c +190 -0
- package/node/third_party/c-ares/src/lib/ares_metrics.c +261 -0
- package/node/third_party/c-ares/src/lib/ares_options.c +492 -0
- package/node/third_party/c-ares/src/lib/ares_parse_into_addrinfo.c +179 -0
- package/node/third_party/c-ares/src/lib/ares_private.h +648 -0
- package/node/third_party/c-ares/src/lib/ares_process.c +1649 -0
- package/node/third_party/c-ares/src/lib/ares_qcache.c +442 -0
- package/node/third_party/c-ares/src/lib/ares_query.c +151 -0
- package/node/third_party/c-ares/src/lib/ares_search.c +623 -0
- package/node/third_party/c-ares/src/lib/ares_send.c +300 -0
- package/node/third_party/c-ares/src/lib/ares_set_socket_functions.c +590 -0
- package/node/third_party/c-ares/src/lib/ares_setup.h +224 -0
- package/node/third_party/c-ares/src/lib/ares_socket.c +427 -0
- package/node/third_party/c-ares/src/lib/ares_socket.h +163 -0
- package/node/third_party/c-ares/src/lib/ares_sortaddrinfo.c +447 -0
- package/node/third_party/c-ares/src/lib/ares_strerror.c +91 -0
- package/node/third_party/c-ares/src/lib/ares_sysconfig.c +642 -0
- package/node/third_party/c-ares/src/lib/ares_sysconfig_files.c +851 -0
- package/node/third_party/c-ares/src/lib/ares_sysconfig_mac.c +373 -0
- package/node/third_party/c-ares/src/lib/ares_sysconfig_win.c +673 -0
- package/node/third_party/c-ares/src/lib/ares_timeout.c +162 -0
- package/node/third_party/c-ares/src/lib/ares_update_servers.c +1376 -0
- package/node/third_party/c-ares/src/lib/ares_version.c +36 -0
- package/node/third_party/c-ares/src/lib/config-dos.h +114 -0
- package/node/third_party/c-ares/src/lib/config-win32.h +396 -0
- package/node/third_party/c-ares/src/lib/dsa/ares_array.c +409 -0
- package/node/third_party/c-ares/src/lib/dsa/ares_htable.c +451 -0
- package/node/third_party/c-ares/src/lib/dsa/ares_htable.h +174 -0
- package/node/third_party/c-ares/src/lib/dsa/ares_htable_asvp.c +224 -0
- package/node/third_party/c-ares/src/lib/dsa/ares_htable_dict.c +230 -0
- package/node/third_party/c-ares/src/lib/dsa/ares_htable_strvp.c +210 -0
- package/node/third_party/c-ares/src/lib/dsa/ares_htable_szvp.c +188 -0
- package/node/third_party/c-ares/src/lib/dsa/ares_htable_vpstr.c +186 -0
- package/node/third_party/c-ares/src/lib/dsa/ares_htable_vpvp.c +194 -0
- package/node/third_party/c-ares/src/lib/dsa/ares_llist.c +385 -0
- package/node/third_party/c-ares/src/lib/dsa/ares_slist.c +479 -0
- package/node/third_party/c-ares/src/lib/dsa/ares_slist.h +207 -0
- package/node/third_party/c-ares/src/lib/event/ares_event.h +191 -0
- package/node/third_party/c-ares/src/lib/event/ares_event_configchg.c +746 -0
- package/node/third_party/c-ares/src/lib/event/ares_event_epoll.c +192 -0
- package/node/third_party/c-ares/src/lib/event/ares_event_kqueue.c +248 -0
- package/node/third_party/c-ares/src/lib/event/ares_event_poll.c +140 -0
- package/node/third_party/c-ares/src/lib/event/ares_event_select.c +159 -0
- package/node/third_party/c-ares/src/lib/event/ares_event_thread.c +575 -0
- package/node/third_party/c-ares/src/lib/event/ares_event_wake_pipe.c +172 -0
- package/node/third_party/c-ares/src/lib/event/ares_event_win32.c +981 -0
- package/node/third_party/c-ares/src/lib/event/ares_event_win32.h +161 -0
- package/node/third_party/c-ares/src/lib/include/ares_array.h +276 -0
- package/node/third_party/c-ares/src/lib/include/ares_buf.h +732 -0
- package/node/third_party/c-ares/src/lib/include/ares_htable_asvp.h +130 -0
- package/node/third_party/c-ares/src/lib/include/ares_htable_dict.h +123 -0
- package/node/third_party/c-ares/src/lib/include/ares_htable_strvp.h +130 -0
- package/node/third_party/c-ares/src/lib/include/ares_htable_szvp.h +118 -0
- package/node/third_party/c-ares/src/lib/include/ares_htable_vpstr.h +111 -0
- package/node/third_party/c-ares/src/lib/include/ares_htable_vpvp.h +128 -0
- package/node/third_party/c-ares/src/lib/include/ares_llist.h +239 -0
- package/node/third_party/c-ares/src/lib/include/ares_mem.h +41 -0
- package/node/third_party/c-ares/src/lib/include/ares_str.h +261 -0
- package/node/third_party/c-ares/src/lib/inet_net_pton.c +451 -0
- package/node/third_party/c-ares/src/lib/inet_ntop.c +219 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_create_query.c +78 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_expand_name.c +99 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_expand_string.c +107 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_fds.c +80 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_getsock.c +85 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_parse_a_reply.c +107 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_parse_aaaa_reply.c +109 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_parse_caa_reply.c +137 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_parse_mx_reply.c +110 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_parse_naptr_reply.c +132 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_parse_ns_reply.c +154 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_parse_ptr_reply.c +213 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_parse_soa_reply.c +115 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_parse_srv_reply.c +114 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_parse_txt_reply.c +144 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_parse_uri_reply.c +113 -0
- package/node/third_party/c-ares/src/lib/record/ares_dns_mapping.c +982 -0
- package/node/third_party/c-ares/src/lib/record/ares_dns_multistring.c +309 -0
- package/node/third_party/c-ares/src/lib/record/ares_dns_multistring.h +72 -0
- package/node/third_party/c-ares/src/lib/record/ares_dns_name.c +736 -0
- package/node/third_party/c-ares/src/lib/record/ares_dns_parse.c +1360 -0
- package/node/third_party/c-ares/src/lib/record/ares_dns_private.h +273 -0
- package/node/third_party/c-ares/src/lib/record/ares_dns_record.c +1701 -0
- package/node/third_party/c-ares/src/lib/record/ares_dns_write.c +1229 -0
- package/node/third_party/c-ares/src/lib/str/ares_buf.c +1510 -0
- package/node/third_party/c-ares/src/lib/str/ares_str.c +562 -0
- package/node/third_party/c-ares/src/lib/str/ares_strsplit.c +90 -0
- package/node/third_party/c-ares/src/lib/str/ares_strsplit.h +51 -0
- package/node/third_party/c-ares/src/lib/thirdparty/apple/dnsinfo.h +122 -0
- package/node/third_party/c-ares/src/lib/util/ares_iface_ips.c +640 -0
- package/node/third_party/c-ares/src/lib/util/ares_iface_ips.h +140 -0
- package/node/third_party/c-ares/src/lib/util/ares_math.c +167 -0
- package/node/third_party/c-ares/src/lib/util/ares_math.h +58 -0
- package/node/third_party/c-ares/src/lib/util/ares_rand.c +389 -0
- package/node/third_party/c-ares/src/lib/util/ares_rand.h +36 -0
- package/node/third_party/c-ares/src/lib/util/ares_threads.c +613 -0
- package/node/third_party/c-ares/src/lib/util/ares_threads.h +60 -0
- package/node/third_party/c-ares/src/lib/util/ares_time.h +49 -0
- package/node/third_party/c-ares/src/lib/util/ares_timeval.c +95 -0
- package/node/third_party/c-ares/src/lib/util/ares_uri.c +1627 -0
- package/node/third_party/c-ares/src/lib/util/ares_uri.h +252 -0
- package/node/third_party/c-ares/src/lib/windows_port.c +29 -0
- package/package.json +1 -1
- package/prebuilt/darwin-arm64/cares-a6286c65ca9374a3.a +0 -0
- package/prebuilt/darwin-x64/cares-a6286c65ca9374a3.a +0 -0
- package/prebuilt/linux-arm64/cares-4ba05ac8e948af8e.a +0 -0
- package/prebuilt/linux-arm64-musl/cares-4ba05ac8e948af8e.a +0 -0
- package/prebuilt/linux-x64/cares-4ba05ac8e948af8e.a +0 -0
- package/prebuilt/linux-x64-musl/cares-4ba05ac8e948af8e.a +0 -0
- package/prebuilt/win32-x64/boringssl-ce573858472b7fc9.a +0 -0
- package/prebuilt/win32-x64/brotli-20d86a61f30baeb3.a +0 -0
- package/prebuilt/win32-x64/cares-49c9ec95162b912d.a +0 -0
- package/prebuilt/win32-x64/uv-b11bae65d7fced82.a +0 -0
- package/prebuilt/win32-x64/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/win32-x64/zstd-015315ac7c784c73.a +0 -0
- package/runtime/include/js_buffer.h +185 -0
- package/runtime/include/js_builtins.h +58 -0
- package/runtime/include/js_crypto.h +11 -0
- package/runtime/include/js_exception.h +3 -0
- package/runtime/include/js_function.h +1 -1
- package/runtime/include/js_gc.h +13 -10
- package/runtime/include/js_jobs.h +2 -0
- package/runtime/include/js_object.h +79 -3
- package/runtime/include/js_ops.h +27 -0
- package/runtime/include/js_runtime.h +1 -0
- package/runtime/include/js_web.h +0 -3
- package/runtime/include/jscontext.h +8 -0
- package/runtime/src/builtins.c +17 -4
- package/runtime/src/crypto_internal.h +1 -0
- package/runtime/src/crypto_subtle.c +66 -7
- package/runtime/src/crypto_tls.c +265 -19
- package/runtime/src/function.c +37 -10
- package/runtime/src/gc.c +76 -93
- package/runtime/src/inspect.c +18 -1
- package/runtime/src/iterator.c +5 -1
- package/runtime/src/jobs.c +37 -22
- package/runtime/src/object.c +91 -8
- package/runtime/src/os.c +16 -6
- package/runtime/src/os.h +2 -0
- package/runtime/src/process.c +97 -10
- package/runtime/src/typedarray.c +23 -0
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/* MIT License
|
|
2
|
+
*
|
|
3
|
+
* Copyright (c) 2024 Brad House
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
* in the Software without restriction, including without limitation the rights
|
|
8
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
* furnished to do so, subject to the following conditions:
|
|
11
|
+
*
|
|
12
|
+
* The above copyright notice and this permission notice (including the next
|
|
13
|
+
* paragraph) shall be included in all copies or substantial portions of the
|
|
14
|
+
* Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*
|
|
24
|
+
* SPDX-License-Identifier: MIT
|
|
25
|
+
*/
|
|
26
|
+
#ifndef __ARES_URI_H
|
|
27
|
+
#define __ARES_URI_H
|
|
28
|
+
|
|
29
|
+
/*! \addtogroup ares_uri URI parser and writer implementation
|
|
30
|
+
*
|
|
31
|
+
* This is a fairly complete URI parser and writer implementation (RFC 3986) for
|
|
32
|
+
* schemes which use the :// syntax. Does not currently support URIs without an
|
|
33
|
+
* authority section, such as "mailto:person@example.com".
|
|
34
|
+
*
|
|
35
|
+
* Its implementation is overkill for our current needs to be able to express
|
|
36
|
+
* DNS server configuration, but there was really no reason not to support
|
|
37
|
+
* a greater subset of the specification.
|
|
38
|
+
*
|
|
39
|
+
* @{
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
struct ares_uri;
|
|
44
|
+
|
|
45
|
+
/*! URI object */
|
|
46
|
+
typedef struct ares_uri ares_uri_t;
|
|
47
|
+
|
|
48
|
+
/*! Create a new URI object
|
|
49
|
+
*
|
|
50
|
+
* \return new ares_uri_t, must be freed with ares_uri_destroy()
|
|
51
|
+
*/
|
|
52
|
+
ares_uri_t *ares_uri_create(void);
|
|
53
|
+
|
|
54
|
+
/*! Destroy an initialized URI object
|
|
55
|
+
*
|
|
56
|
+
* \param[in] uri Initialized URI object
|
|
57
|
+
*/
|
|
58
|
+
void ares_uri_destroy(ares_uri_t *uri);
|
|
59
|
+
|
|
60
|
+
/*! Set the URI scheme. Automatically lower-cases the scheme provided.
|
|
61
|
+
* Only allows Alpha, Digit, +, -, and . characters. Maximum length is
|
|
62
|
+
* 15 characters. This is required to be set to write a URI.
|
|
63
|
+
*
|
|
64
|
+
* \param[in] uri Initialized URI object
|
|
65
|
+
* \param[in] scheme Scheme to set the object to use
|
|
66
|
+
* \return ARES_SUCCESS on success
|
|
67
|
+
*/
|
|
68
|
+
ares_status_t ares_uri_set_scheme(ares_uri_t *uri, const char *scheme);
|
|
69
|
+
|
|
70
|
+
/*! Retrieve the currently configured URI scheme.
|
|
71
|
+
*
|
|
72
|
+
* \param[in] uri Initialized URI object
|
|
73
|
+
* \return string containing URI scheme
|
|
74
|
+
*/
|
|
75
|
+
const char *ares_uri_get_scheme(const ares_uri_t *uri);
|
|
76
|
+
|
|
77
|
+
/*! Set the username in the URI object
|
|
78
|
+
*
|
|
79
|
+
* \param[in] uri Initialized URI object
|
|
80
|
+
* \param[in] username Username to set. May be NULL to unset existing username.
|
|
81
|
+
* \return ARES_SUCCESS on success
|
|
82
|
+
*/
|
|
83
|
+
ares_status_t ares_uri_set_username(ares_uri_t *uri, const char *username);
|
|
84
|
+
|
|
85
|
+
/*! Retrieve the currently configured username.
|
|
86
|
+
*
|
|
87
|
+
* \param[in] uri Initialized URI object
|
|
88
|
+
* \return string containing username, maybe NULL if not set.
|
|
89
|
+
*/
|
|
90
|
+
const char *ares_uri_get_username(const ares_uri_t *uri);
|
|
91
|
+
|
|
92
|
+
/*! Set the password in the URI object
|
|
93
|
+
*
|
|
94
|
+
* \param[in] uri Initialized URI object
|
|
95
|
+
* \param[in] password Password to set. May be NULL to unset existing password.
|
|
96
|
+
* \return ARES_SUCCESS on success
|
|
97
|
+
*/
|
|
98
|
+
ares_status_t ares_uri_set_password(ares_uri_t *uri, const char *password);
|
|
99
|
+
|
|
100
|
+
/*! Retrieve the currently configured password.
|
|
101
|
+
*
|
|
102
|
+
* \param[in] uri Initialized URI object
|
|
103
|
+
* \return string containing password, maybe NULL if not set.
|
|
104
|
+
*/
|
|
105
|
+
const char *ares_uri_get_password(const ares_uri_t *uri);
|
|
106
|
+
|
|
107
|
+
/*! Set the host or ip address in the URI object. This is required to be
|
|
108
|
+
* set to write a URI. The character set is strictly validated.
|
|
109
|
+
*
|
|
110
|
+
* \param[in] uri Initialized URI object
|
|
111
|
+
* \param[in] host IPv4, IPv6, or hostname to set.
|
|
112
|
+
* \return ARES_SUCCESS on success
|
|
113
|
+
*/
|
|
114
|
+
ares_status_t ares_uri_set_host(ares_uri_t *uri, const char *host);
|
|
115
|
+
|
|
116
|
+
/*! Retrieve the currently configured host (or ip address). IPv6 addresses
|
|
117
|
+
* May include a link-local scope (e.g. fe80::b542:84df:1719:65e3%en0).
|
|
118
|
+
*
|
|
119
|
+
* \param[in] uri Initialized URI object
|
|
120
|
+
* \return string containing host, maybe NULL if not set.
|
|
121
|
+
*/
|
|
122
|
+
const char *ares_uri_get_host(const ares_uri_t *uri);
|
|
123
|
+
|
|
124
|
+
/*! Set the port to use in the URI object. A port value of 0 will omit
|
|
125
|
+
* the port from the URI when written, thus using the scheme's default.
|
|
126
|
+
*
|
|
127
|
+
* \param[in] uri Initialized URI object
|
|
128
|
+
* \param[in] port Port to set. Use 0 to unset.
|
|
129
|
+
* \return ARES_SUCCESS on success
|
|
130
|
+
*/
|
|
131
|
+
ares_status_t ares_uri_set_port(ares_uri_t *uri, unsigned short port);
|
|
132
|
+
|
|
133
|
+
/*! Retrieve the currently configured port
|
|
134
|
+
*
|
|
135
|
+
* \param[in] uri Initialized URI object
|
|
136
|
+
* \return port number, or 0 if not set.
|
|
137
|
+
*/
|
|
138
|
+
unsigned short ares_uri_get_port(const ares_uri_t *uri);
|
|
139
|
+
|
|
140
|
+
/*! Set the path in the URI object. Unsupported characters will be URI-encoded
|
|
141
|
+
* when written.
|
|
142
|
+
*
|
|
143
|
+
* \param[in] uri Initialized URI object
|
|
144
|
+
* \param[in] path Path to set. May be NULL to unset existing path.
|
|
145
|
+
* \return ARES_SUCCESS on success
|
|
146
|
+
*/
|
|
147
|
+
ares_status_t ares_uri_set_path(ares_uri_t *uri, const char *path);
|
|
148
|
+
|
|
149
|
+
/*! Retrieves the path in the URI object. If retrieved after parse, this
|
|
150
|
+
* value will be URI-decoded already.
|
|
151
|
+
*
|
|
152
|
+
* \param[in] uri Initialized URI object
|
|
153
|
+
* \return path string, or NULL if not set.
|
|
154
|
+
*/
|
|
155
|
+
const char *ares_uri_get_path(const ares_uri_t *uri);
|
|
156
|
+
|
|
157
|
+
/*! Set a new query key/value pair. There is no set order for query keys
|
|
158
|
+
* when output in the URI, they will be emitted in a random order. Keys are
|
|
159
|
+
* case-insensitive. Query keys and values will be automatically URI-encoded
|
|
160
|
+
* when written.
|
|
161
|
+
*
|
|
162
|
+
* \param[in] uri Initialized URI object
|
|
163
|
+
* \param[in] key Query key to use, must be non-zero length.
|
|
164
|
+
* \param[in] val Query value to use, may be NULL.
|
|
165
|
+
* \return ARES_SUCCESS on success
|
|
166
|
+
*/
|
|
167
|
+
ares_status_t ares_uri_set_query_key(ares_uri_t *uri, const char *key,
|
|
168
|
+
const char *val);
|
|
169
|
+
|
|
170
|
+
/*! Delete a specific query key.
|
|
171
|
+
*
|
|
172
|
+
* \param[in] uri Initialized URI object
|
|
173
|
+
* \param[in] key Key to delete.
|
|
174
|
+
* \return ARES_SUCCESS if deleted, ARES_ENOTFOUND if not found
|
|
175
|
+
*/
|
|
176
|
+
ares_status_t ares_uri_del_query_key(ares_uri_t *uri, const char *key);
|
|
177
|
+
|
|
178
|
+
/*! Retrieve the value associated with a query key. Keys are case-insensitive.
|
|
179
|
+
*
|
|
180
|
+
* \param[in] uri Initialized URI object
|
|
181
|
+
* \param[in] key Key to retrieve.
|
|
182
|
+
* \return string representing value, may be NULL if either not found or
|
|
183
|
+
* NULL value set. There is currently no way to indicate the
|
|
184
|
+
* difference.
|
|
185
|
+
*/
|
|
186
|
+
const char *ares_uri_get_query_key(const ares_uri_t *uri, const char *key);
|
|
187
|
+
|
|
188
|
+
/*! Retrieve a complete list of query keys.
|
|
189
|
+
*
|
|
190
|
+
* \param[in] uri Initialized URI object
|
|
191
|
+
* \param[out] num Number of keys.
|
|
192
|
+
* \return NULL on failure or no keys. Use
|
|
193
|
+
* ares_free_array(keys, num, ares_free) when done with array.
|
|
194
|
+
*/
|
|
195
|
+
char **ares_uri_get_query_keys(const ares_uri_t *uri, size_t *num);
|
|
196
|
+
|
|
197
|
+
/*! Set the fragment in the URI object. Unsupported characters will be
|
|
198
|
+
* URI-encoded when written.
|
|
199
|
+
*
|
|
200
|
+
* \param[in] uri Initialized URI object
|
|
201
|
+
* \param[in] fragment Fragment to set. May be NULL to unset existing fragment.
|
|
202
|
+
* \return ARES_SUCCESS on success
|
|
203
|
+
*/
|
|
204
|
+
ares_status_t ares_uri_set_fragment(ares_uri_t *uri, const char *fragment);
|
|
205
|
+
|
|
206
|
+
/*! Retrieves the fragment in the URI object. If retrieved after parse, this
|
|
207
|
+
* value will be URI-decoded already.
|
|
208
|
+
*
|
|
209
|
+
* \param[in] uri Initialized URI object
|
|
210
|
+
* \return fragment string, or NULL if not set.
|
|
211
|
+
*/
|
|
212
|
+
const char *ares_uri_get_fragment(const ares_uri_t *uri);
|
|
213
|
+
|
|
214
|
+
/*! Parse the provided URI buffer into a new URI object.
|
|
215
|
+
*
|
|
216
|
+
* \param[out] out Returned new URI object. free with ares_uri_destroy().
|
|
217
|
+
* \param[in] buf Buffer object containing the URI
|
|
218
|
+
* \return ARES_SUCCESS on successful parse. On failure the 'buf' object will
|
|
219
|
+
* be restored to its initial state in case another parser needs to
|
|
220
|
+
* be attempted.
|
|
221
|
+
*/
|
|
222
|
+
ares_status_t ares_uri_parse_buf(ares_uri_t **out, ares_buf_t *buf);
|
|
223
|
+
|
|
224
|
+
/*! Parse the provided URI string into a new URI object.
|
|
225
|
+
*
|
|
226
|
+
* \param[out] out Returned new URI object. free with ares_uri_destroy().
|
|
227
|
+
* \param[in] uri URI string to parse
|
|
228
|
+
* \return ARES_SUCCESS on successful parse
|
|
229
|
+
*/
|
|
230
|
+
ares_status_t ares_uri_parse(ares_uri_t **out, const char *uri);
|
|
231
|
+
|
|
232
|
+
/*! Write URI object to a new string buffer. Requires at least the scheme
|
|
233
|
+
* and host to be set for this to succeed.
|
|
234
|
+
*
|
|
235
|
+
* \param[out] out Returned new URI string. Free with ares_free().
|
|
236
|
+
* \param[in] uri Initialized URI object.
|
|
237
|
+
* \return ARES_SUCCESS on successful write.
|
|
238
|
+
*/
|
|
239
|
+
ares_status_t ares_uri_write(char **out, const ares_uri_t *uri);
|
|
240
|
+
|
|
241
|
+
/*! Write URI object to an existing ares_buf_t object. Requires at least the
|
|
242
|
+
* scheme and host to be set for this to succeed.
|
|
243
|
+
*
|
|
244
|
+
* \param[in] uri Initialized URI object.
|
|
245
|
+
* \param[in,out] buf Destination buf object.
|
|
246
|
+
* \return ARES_SUCCESS on successful write.
|
|
247
|
+
*/
|
|
248
|
+
ares_status_t ares_uri_write_buf(const ares_uri_t *uri, ares_buf_t *buf);
|
|
249
|
+
|
|
250
|
+
/*! @} */
|
|
251
|
+
|
|
252
|
+
#endif /* __ARES_URI_H */
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**********************************************************************
|
|
2
|
+
*
|
|
3
|
+
* Copyright (c) 1998 Massachusetts Institute of Technology
|
|
4
|
+
* Copyright (C) Daniel Stenberg
|
|
5
|
+
*
|
|
6
|
+
* SPDX-License-Identifier: MIT
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
#include "ares_private.h"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
/* only do the following on windows
|
|
13
|
+
*/
|
|
14
|
+
#if defined(_WIN32) && !defined(MSDOS)
|
|
15
|
+
|
|
16
|
+
# ifdef __WATCOMC__
|
|
17
|
+
/*
|
|
18
|
+
* Watcom needs a DllMain() in order to initialise the clib startup code.
|
|
19
|
+
*/
|
|
20
|
+
BOOL WINAPI DllMain(HINSTANCE hnd, DWORD reason, LPVOID reserved)
|
|
21
|
+
{
|
|
22
|
+
(void)hnd;
|
|
23
|
+
(void)reason;
|
|
24
|
+
(void)reserved;
|
|
25
|
+
return (TRUE);
|
|
26
|
+
}
|
|
27
|
+
# endif
|
|
28
|
+
|
|
29
|
+
#endif /* WIN32 builds only */
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
#include <stdint.h>
|
|
11
11
|
#include <string.h>
|
|
12
12
|
|
|
13
|
+
#include "js_convert.h"
|
|
13
14
|
#include "js_object.h"
|
|
15
|
+
#include "js_ops.h"
|
|
14
16
|
|
|
15
17
|
#define JS_BUFFER_RESIZABLE 0x01u
|
|
16
18
|
#define JS_BUFFER_DETACHED 0x02u
|
|
@@ -76,4 +78,187 @@ int js_typed_array_type(JSValue v);
|
|
|
76
78
|
/* A new, zeroed Uint8Array of `length` bytes; its bytes are js_buffer_source_bytes'. */
|
|
77
79
|
JS_WARN_UNUSED JSValue js_new_uint8_array(JSContext *ctx, size_t length);
|
|
78
80
|
|
|
81
|
+
/* ---- Generated code: a typed array's elements inline ------------------------------------------ */
|
|
82
|
+
|
|
83
|
+
/* The bytes of element i of a typed array generated code may read or write inline: a view of a
|
|
84
|
+
* fixed-size buffer (it can't shrink below the view, so i < length is in bounds), not detached,
|
|
85
|
+
* not immutable (for a write). NULL for anything else, which takes js_get_elem / js_set_elem. */
|
|
86
|
+
static JS_FAST_PATH uint8_t *js_ta_inline_elem(JSContext *ctx, JSValue obj, int32_t i, bool write) {
|
|
87
|
+
if (!js_is_object(obj) || js_as_object(obj)->shape->cls != ctx->rt->typed_array_class) return NULL;
|
|
88
|
+
const JSTypedArray *ta = (const JSTypedArray *)js_as_object(obj);
|
|
89
|
+
const JSArrayBuffer *b = js_as_array_buffer(ta->buffer);
|
|
90
|
+
uint32_t bad = JS_BUFFER_DETACHED | JS_BUFFER_RESIZABLE | (write ? JS_BUFFER_IMMUTABLE : 0);
|
|
91
|
+
if (ta->length_tracking || i < 0 || (size_t)i >= ta->length || (b->flags & bad)) return NULL;
|
|
92
|
+
return b->data + ta->byte_offset;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/* obj[i]: a dense array's element or a typed array's (Int8, Uint8, Int32, Float64) inline. */
|
|
96
|
+
static JS_FAST_PATH JSValue js_get_index_ta(JSContext *ctx, JSValue obj, JSValue key) {
|
|
97
|
+
if (JS_LIKELY(js_is_int32(key)) && !js_is_array(obj)) {
|
|
98
|
+
int32_t i = js_as_int32(key);
|
|
99
|
+
const uint8_t *p = js_ta_inline_elem(ctx, obj, i, false);
|
|
100
|
+
if (p) switch (((const JSTypedArray *)js_as_object(obj))->type) {
|
|
101
|
+
case JS_TA_UINT8: case JS_TA_UINT8C: return js_int32(p[i]);
|
|
102
|
+
case JS_TA_INT8: return js_int32((int8_t)p[i]);
|
|
103
|
+
case JS_TA_INT32: { int32_t v; memcpy(&v, p + 4 * (size_t)i, 4); return js_int32(v); }
|
|
104
|
+
case JS_TA_FLOAT64: { double v; memcpy(&v, p + 8 * (size_t)i, 8); return js_number(v); }
|
|
105
|
+
default: break;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return js_get_index(ctx, obj, key);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/* obj[i] = v: the same, for a Number v (no ToNumber code to run). */
|
|
112
|
+
static JS_FAST_PATH int js_set_index_ta(JSContext *ctx, JSValue obj, JSValue key, JSValue v, bool strict) {
|
|
113
|
+
if (JS_LIKELY(js_is_int32(key)) && js_is_number(v) && !js_is_array(obj)) {
|
|
114
|
+
int32_t i = js_as_int32(key);
|
|
115
|
+
uint8_t *p = js_ta_inline_elem(ctx, obj, i, true);
|
|
116
|
+
if (p) switch (((const JSTypedArray *)js_as_object(obj))->type) {
|
|
117
|
+
case JS_TA_UINT8: case JS_TA_INT8: p[i] = (uint8_t)(js_is_int32(v) ? js_as_int32(v) : js_double_to_int32(js_as_number(v))); return 1;
|
|
118
|
+
case JS_TA_INT32: { int32_t x = js_is_int32(v) ? js_as_int32(v) : js_double_to_int32(js_as_number(v)); memcpy(p + 4 * (size_t)i, &x, 4); return 1; }
|
|
119
|
+
case JS_TA_FLOAT64: { double x = js_as_number(v); memcpy(p + 8 * (size_t)i, &x, 8); return 1; }
|
|
120
|
+
default: break;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return js_set_index(ctx, obj, key, v, strict);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/* The same with a double key (an unboxed index): an integral one is the int32 key (-0 too: "0"). */
|
|
127
|
+
static inline JSValue js_get_index_ta_f64(JSContext *ctx, JSValue obj, double key) {
|
|
128
|
+
int32_t i = (int32_t)key;
|
|
129
|
+
if (key >= -2147483648.0 && key <= 2147483647.0 && (double)i == key) return js_get_index_ta(ctx, obj, js_int32(i));
|
|
130
|
+
return js_get_index_f64(ctx, obj, key);
|
|
131
|
+
}
|
|
132
|
+
static inline int js_set_index_ta_f64(JSContext *ctx, JSValue obj, double key, JSValue v, bool strict) {
|
|
133
|
+
int32_t i = (int32_t)key;
|
|
134
|
+
if (key >= -2147483648.0 && key <= 2147483647.0 && (double)i == key) return js_set_index_ta(ctx, obj, js_int32(i), v, strict);
|
|
135
|
+
return js_set_index_f64(ctx, obj, key, v, strict);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/* A typed array's elements as generated code holds them (the typed-arrays pass): taken once,
|
|
139
|
+
* for an array nothing else can reach, so nothing detaches or resizes its buffer. Empty (length
|
|
140
|
+
* 0) when the value isn't a typed array of that type: every access then takes the generic path. */
|
|
141
|
+
typedef struct JSTAView {
|
|
142
|
+
uint8_t *base;
|
|
143
|
+
size_t length;
|
|
144
|
+
int type; /* the element type it's for: a slow path that may have run code takes it again */
|
|
145
|
+
} JSTAView;
|
|
146
|
+
|
|
147
|
+
static inline JSTAView js_ta_view(JSContext *ctx, JSValue obj, int type) {
|
|
148
|
+
JSTAView v = { NULL, 0, type };
|
|
149
|
+
if (!js_is_object(obj) || js_as_object(obj)->shape->cls != ctx->rt->typed_array_class) return v;
|
|
150
|
+
const JSTypedArray *ta = (const JSTypedArray *)js_as_object(obj);
|
|
151
|
+
const JSArrayBuffer *b = js_as_array_buffer(ta->buffer);
|
|
152
|
+
if (ta->type != type || ta->length_tracking || (b->flags & (JS_BUFFER_DETACHED | JS_BUFFER_RESIZABLE | JS_BUFFER_IMMUTABLE)) || !b->data) return v;
|
|
153
|
+
v.base = b->data + ta->byte_offset;
|
|
154
|
+
v.length = ta->length;
|
|
155
|
+
return v;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/* Whether v is a typed array of that element type (a typed function's typed array parameter). */
|
|
159
|
+
static inline bool js_ta_is(JSContext *ctx, JSValue v, int type) {
|
|
160
|
+
return js_is_object(v) && js_as_object(v)->shape->cls == ctx->rt->typed_array_class && ((const JSTypedArray *)js_as_object(v))->type == type;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/* The index a key names when it's in the view, else false. */
|
|
164
|
+
static JS_FAST_PATH bool js_tav_index(const JSTAView *v, JSValue key, size_t *i) {
|
|
165
|
+
if (!js_is_int32(key) || js_as_int32(key) < 0 || (size_t)js_as_int32(key) >= v->length) return false;
|
|
166
|
+
*i = (size_t)js_as_int32(key);
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
static JS_FAST_PATH bool js_tav_index_d(const JSTAView *v, double key, size_t *i) {
|
|
170
|
+
if (!(key >= 0 && key < (double)v->length) || (double)(size_t)key != key) return false;
|
|
171
|
+
*i = (size_t)key;
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/* Each element type's read and write (a Number, converted as the spec's NumericToRawBytes). */
|
|
176
|
+
#define JS_TAV_ACCESS(name, ctype, box, unbox) \
|
|
177
|
+
static JS_FAST_PATH JSValue js_tav_get_##name(JSContext *ctx, JSTAView *v, JSValue obj, JSValue key) { \
|
|
178
|
+
size_t i; \
|
|
179
|
+
if (JS_LIKELY(js_tav_index(v, key, &i))) { ctype x; memcpy(&x, v->base + i * sizeof x, sizeof x); return box(x); } \
|
|
180
|
+
JSValue r = js_get_elem(ctx, obj, key); \
|
|
181
|
+
*v = js_ta_view(ctx, obj, v->type); /* a getter may have run */ \
|
|
182
|
+
return r; \
|
|
183
|
+
} \
|
|
184
|
+
static JS_FAST_PATH JSValue js_tav_get_##name##_d(JSContext *ctx, JSTAView *v, JSValue obj, double key) { \
|
|
185
|
+
size_t i; \
|
|
186
|
+
if (JS_LIKELY(js_tav_index_d(v, key, &i))) { ctype x; memcpy(&x, v->base + i * sizeof x, sizeof x); return box(x); } \
|
|
187
|
+
JSValue r = js_get_elem(ctx, obj, js_number(key)); \
|
|
188
|
+
*v = js_ta_view(ctx, obj, v->type); \
|
|
189
|
+
return r; \
|
|
190
|
+
} \
|
|
191
|
+
static JS_FAST_PATH JSValue js_tav_get_##name##_i(JSContext *ctx, JSTAView *v, JSValue obj, int32_t key) { \
|
|
192
|
+
if (JS_LIKELY((uint32_t)key < v->length)) { ctype x; memcpy(&x, v->base + (size_t)(uint32_t)key * sizeof x, sizeof x); return box(x); } \
|
|
193
|
+
JSValue r = js_get_elem(ctx, obj, js_int32(key)); \
|
|
194
|
+
*v = js_ta_view(ctx, obj, v->type); \
|
|
195
|
+
return r; \
|
|
196
|
+
} \
|
|
197
|
+
static JS_FAST_PATH int js_tav_set_##name##_i(JSContext *ctx, JSTAView *v, JSValue obj, int32_t key, JSValue val, bool strict) { \
|
|
198
|
+
if (JS_LIKELY(js_is_number(val) && (uint32_t)key < v->length)) { ctype x = unbox(val); memcpy(v->base + (size_t)(uint32_t)key * sizeof x, &x, sizeof x); return 1; } \
|
|
199
|
+
int r = js_set_elem(ctx, obj, js_int32(key), val, strict); \
|
|
200
|
+
*v = js_ta_view(ctx, obj, v->type); \
|
|
201
|
+
return r; \
|
|
202
|
+
} \
|
|
203
|
+
static JS_FAST_PATH JSValue js_tav_get_##name##_l(JSContext *ctx, JSTAView *v, JSValue obj, int64_t key) { \
|
|
204
|
+
if (JS_LIKELY((uint64_t)key < v->length)) { ctype x; memcpy(&x, v->base + (size_t)key * sizeof x, sizeof x); return box(x); } \
|
|
205
|
+
JSValue r = js_get_elem(ctx, obj, js_number((double)key)); \
|
|
206
|
+
*v = js_ta_view(ctx, obj, v->type); \
|
|
207
|
+
return r; \
|
|
208
|
+
} \
|
|
209
|
+
static JS_FAST_PATH int js_tav_set_##name##_l(JSContext *ctx, JSTAView *v, JSValue obj, int64_t key, JSValue val, bool strict) { \
|
|
210
|
+
if (JS_LIKELY(js_is_number(val) && (uint64_t)key < v->length)) { ctype x = unbox(val); memcpy(v->base + (size_t)key * sizeof x, &x, sizeof x); return 1; } \
|
|
211
|
+
int r = js_set_elem(ctx, obj, js_number((double)key), val, strict); \
|
|
212
|
+
*v = js_ta_view(ctx, obj, v->type); \
|
|
213
|
+
return r; \
|
|
214
|
+
} \
|
|
215
|
+
static JS_FAST_PATH int js_tav_set_##name(JSContext *ctx, JSTAView *v, JSValue obj, JSValue key, JSValue val, bool strict) { \
|
|
216
|
+
size_t i; \
|
|
217
|
+
if (JS_LIKELY(js_is_number(val) && js_tav_index(v, key, &i))) { ctype x = unbox(val); memcpy(v->base + i * sizeof x, &x, sizeof x); return 1; } \
|
|
218
|
+
int r = js_set_elem(ctx, obj, key, val, strict); /* valueOf, a setter: they may have run */ \
|
|
219
|
+
*v = js_ta_view(ctx, obj, v->type); \
|
|
220
|
+
return r; \
|
|
221
|
+
} \
|
|
222
|
+
static JS_FAST_PATH int js_tav_set_##name##_d(JSContext *ctx, JSTAView *v, JSValue obj, double key, JSValue val, bool strict) { \
|
|
223
|
+
size_t i; \
|
|
224
|
+
if (JS_LIKELY(js_is_number(val) && js_tav_index_d(v, key, &i))) { ctype x = unbox(val); memcpy(v->base + i * sizeof x, &x, sizeof x); return 1; } \
|
|
225
|
+
int r = js_set_elem(ctx, obj, js_number(key), val, strict); \
|
|
226
|
+
*v = js_ta_view(ctx, obj, v->type); \
|
|
227
|
+
return r; \
|
|
228
|
+
}
|
|
229
|
+
static JS_FAST_PATH int32_t js_tav_to_int32(JSValue v) { return js_is_int32(v) ? js_as_int32(v) : js_double_to_int32(js_as_number(v)); }
|
|
230
|
+
#define JS_TAV_INT(x) js_int32((int32_t)(x))
|
|
231
|
+
JS_TAV_ACCESS(i8, int8_t, JS_TAV_INT, (int8_t)js_tav_to_int32)
|
|
232
|
+
JS_TAV_ACCESS(u8, uint8_t, JS_TAV_INT, (uint8_t)js_tav_to_int32)
|
|
233
|
+
JS_TAV_ACCESS(i32, int32_t, JS_TAV_INT, js_tav_to_int32)
|
|
234
|
+
JS_TAV_ACCESS(f64, double, js_number, js_as_number)
|
|
235
|
+
|
|
236
|
+
/* A Float64Array's element as a double, for typed code ("use static": its type is number):
|
|
237
|
+
* past the end, undefined as a number (NaN). False with an exception pending. And a store of a
|
|
238
|
+
* double, boxed only on the slow path. */
|
|
239
|
+
static inline bool js_tav_num_slow(JSContext *ctx, JSTAView *v, JSValue obj, JSValue key, double *out) {
|
|
240
|
+
JSValue r = js_get_elem(ctx, obj, key);
|
|
241
|
+
*v = js_ta_view(ctx, obj, v->type);
|
|
242
|
+
if (js_is_exception(r)) return false;
|
|
243
|
+
if (js_is_number(r)) { *out = js_as_number(r); return true; }
|
|
244
|
+
return js_to_number(ctx, out, r) == 0;
|
|
245
|
+
}
|
|
246
|
+
#define JS_TAV_F64(suffix, ktype, in_view, boxed_key) \
|
|
247
|
+
static JS_FAST_PATH bool js_tav_num_f64##suffix(JSContext *ctx, JSTAView *v, JSValue obj, ktype key, double *out) { \
|
|
248
|
+
size_t i; \
|
|
249
|
+
if (JS_LIKELY(in_view)) { memcpy(out, v->base + i * 8, 8); return true; } \
|
|
250
|
+
return js_tav_num_slow(ctx, v, obj, boxed_key, out); \
|
|
251
|
+
} \
|
|
252
|
+
static JS_FAST_PATH int js_tav_put_f64##suffix(JSContext *ctx, JSTAView *v, JSValue obj, ktype key, double x, bool strict) { \
|
|
253
|
+
size_t i; \
|
|
254
|
+
if (JS_LIKELY(in_view)) { memcpy(v->base + i * 8, &x, 8); return 1; } \
|
|
255
|
+
int r = js_set_elem(ctx, obj, boxed_key, js_number(x), strict); \
|
|
256
|
+
*v = js_ta_view(ctx, obj, v->type); \
|
|
257
|
+
return r; \
|
|
258
|
+
}
|
|
259
|
+
JS_TAV_F64(, JSValue, js_tav_index(v, key, &i), key)
|
|
260
|
+
JS_TAV_F64(_d, double, js_tav_index_d(v, key, &i), js_number(key))
|
|
261
|
+
JS_TAV_F64(_i, int32_t, ((i = (size_t)(uint32_t)key) < v->length), js_int32(key))
|
|
262
|
+
JS_TAV_F64(_l, int64_t, ((i = (size_t)(uint64_t)key) < v->length), js_number((double)key))
|
|
263
|
+
|
|
79
264
|
#endif /* JS_BUFFER_H */
|
|
@@ -211,7 +211,65 @@ static inline JSValue js_call_char_code_at(JSContext *ctx, JSValue f, JSValue s,
|
|
|
211
211
|
return js_call_site(ctx, f, s, 1, &i, site);
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
+
/* s.charCodeAt(i) in typed code ("use static"), which trusts the built-ins to be the standard
|
|
215
|
+
* ones (char_code_at): s is a string; its unit read inline, else (a rope, an index out of
|
|
216
|
+
* range) the built-in's answer. */
|
|
217
|
+
static inline double js_string_char_code_at(JSContext *ctx, JSValue s, double i) {
|
|
218
|
+
JSStrView v;
|
|
219
|
+
if (JS_LIKELY(i >= 0 && i < 4294967295.0 && js_string_units(s, &v) && (uint32_t)i < v.length && (double)(uint32_t)i == i))
|
|
220
|
+
return (double)js_view_at(v, (uint32_t)i);
|
|
221
|
+
JSValue index = js_number(i);
|
|
222
|
+
return js_as_number(js_core_string_proto_char_code_at(ctx, JS_UNDEFINED, s, 1, &index, JS_UNDEFINED));
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/* s.charCodeAt(i) in typed code for an index the optimizer proved in s: the unit, an int32 (a
|
|
226
|
+
* rope not yet flattened takes the built-in). */
|
|
227
|
+
static inline int32_t js_string_unit_at(JSContext *ctx, JSValue s, uint32_t i) {
|
|
228
|
+
JSStrView v;
|
|
229
|
+
if (JS_LIKELY(js_string_units(s, &v))) return (int32_t)js_view_at(v, i);
|
|
230
|
+
return (int32_t)js_string_char_code_at(ctx, s, (double)i);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/* Function.prototype.apply and call: generated code tells them by their entry. */
|
|
234
|
+
JSValue js_function_proto_apply(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
235
|
+
JSValue js_function_proto_call(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
236
|
+
|
|
237
|
+
/* f.apply(t, args), `m` the value of f.apply: when m is the built-in and f callable, f is called
|
|
238
|
+
* without the built-in in between, with a short dense array's elements copied to the stack (its
|
|
239
|
+
* elements are its own data properties: reading them runs no code; copied, as f may change the
|
|
240
|
+
* array). Anything else is the call of m. */
|
|
241
|
+
static inline JSValue js_call_apply(JSContext *ctx, JSValue m, JSValue f, JSValue t, JSValue args, const char *site) {
|
|
242
|
+
if (JS_LIKELY(js_is_function(m) && js_as_function(m)->entry == js_function_proto_apply && js_is_callable(f))) {
|
|
243
|
+
if (js_is_nullish(args)) return js_call(ctx, f, t, 0, NULL);
|
|
244
|
+
if (js_is_array(args)) {
|
|
245
|
+
JSObject *a = js_as_object(args);
|
|
246
|
+
JSElements *e = a->elements;
|
|
247
|
+
uint32_t n = js_array_length(a);
|
|
248
|
+
JSValue copy[8];
|
|
249
|
+
if (e->kind == JS_ELEMENTS_DENSE && e->length == n && n <= 8) {
|
|
250
|
+
uint32_t i = 0;
|
|
251
|
+
while (i < n && !js_is_empty(e->data[i])) copy[i] = e->data[i], i++;
|
|
252
|
+
if (i == n) return js_call(ctx, f, t, n, copy);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return js_call_site(ctx, m, f, 2, (const JSValue[]){ t, args }, site);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/* f.call(t, …), `m` the value of f.call: f called directly when m is the built-in and f callable.
|
|
260
|
+
* argv: t, then the arguments. */
|
|
261
|
+
static inline JSValue js_call_call(JSContext *ctx, JSValue m, JSValue f, uint32_t argc, const JSValue *argv, const char *site) {
|
|
262
|
+
if (JS_LIKELY(js_is_function(m) && js_as_function(m)->entry == js_function_proto_call && js_is_callable(f)))
|
|
263
|
+
return js_call(ctx, f, argc ? argv[0] : JS_UNDEFINED, argc ? argc - 1 : 0, argc ? argv + 1 : NULL);
|
|
264
|
+
return js_call_site(ctx, m, f, argc, argv, site);
|
|
265
|
+
}
|
|
266
|
+
|
|
214
267
|
/* String.fromCharCode(c): a unit up to 0xFF is a static one-unit string. */
|
|
268
|
+
/* Static code's String.fromCharCode(c), trusted to be the built-in: c's unit (ToUint16). */
|
|
269
|
+
static inline JSValue js_from_char_code_unit(JSContext *ctx, uint16_t unit) {
|
|
270
|
+
return unit <= 0xFF ? js_char_string((uint8_t)unit) : js_new_string_utf16(ctx, &unit, 1);
|
|
271
|
+
}
|
|
272
|
+
|
|
215
273
|
static inline JSValue js_call_from_char_code(JSContext *ctx, JSValue f, JSValue this_val, JSValue c, const char *site) {
|
|
216
274
|
if (JS_LIKELY(js_is_function(f) && js_as_function(f)->entry == js_core_string_from_char_code && js_is_int32(c)
|
|
217
275
|
&& (uint32_t)js_as_int32(c) <= 0xFF))
|
|
@@ -64,6 +64,11 @@ JS_CRYPTO_PRIMITIVE(js_tls_context_add_roots)
|
|
|
64
64
|
JS_CRYPTO_PRIMITIVE(js_tls_context_add_ca)
|
|
65
65
|
JS_CRYPTO_PRIMITIVE(js_tls_context_set_cert)
|
|
66
66
|
JS_CRYPTO_PRIMITIVE(js_tls_context_set_key)
|
|
67
|
+
JS_CRYPTO_PRIMITIVE(js_tls_context_add_credential)
|
|
68
|
+
JS_CRYPTO_PRIMITIVE(js_tls_context_allow_partial_chain)
|
|
69
|
+
JS_CRYPTO_PRIMITIVE(js_tls_context_ticket_keys)
|
|
70
|
+
JS_CRYPTO_PRIMITIVE(js_tls_context_set_sessions)
|
|
71
|
+
JS_CRYPTO_PRIMITIVE(js_tls_pkcs12)
|
|
67
72
|
JS_CRYPTO_PRIMITIVE(js_tls_root_certificates)
|
|
68
73
|
JS_CRYPTO_PRIMITIVE(js_tls_new)
|
|
69
74
|
JS_CRYPTO_PRIMITIVE(js_tls_run)
|
|
@@ -72,10 +77,16 @@ JS_CRYPTO_PRIMITIVE(js_tls_info)
|
|
|
72
77
|
JS_CRYPTO_PRIMITIVE(js_tls_peer_certs)
|
|
73
78
|
JS_CRYPTO_PRIMITIVE(js_tls_verify_error)
|
|
74
79
|
JS_CRYPTO_PRIMITIVE(js_tls_session)
|
|
80
|
+
JS_CRYPTO_PRIMITIVE(js_tls_ticket)
|
|
75
81
|
JS_CRYPTO_PRIMITIVE(js_tls_export_keying_material)
|
|
76
82
|
JS_CRYPTO_PRIMITIVE(js_tls_set_no_renegotiation)
|
|
83
|
+
JS_CRYPTO_PRIMITIVE(js_tls_enable_keylog)
|
|
84
|
+
JS_CRYPTO_PRIMITIVE(js_tls_set_max_send_fragment)
|
|
77
85
|
JS_CRYPTO_PRIMITIVE(js_tls_finished)
|
|
78
86
|
JS_CRYPTO_PRIMITIVE(js_tls_ciphers)
|
|
87
|
+
JS_CRYPTO_PRIMITIVE(js_x509_check)
|
|
88
|
+
JS_CRYPTO_PRIMITIVE(js_x509_check_issued)
|
|
89
|
+
JS_CRYPTO_PRIMITIVE(js_x509_check_key)
|
|
79
90
|
#undef JS_CRYPTO_PRIMITIVE
|
|
80
91
|
|
|
81
92
|
#endif /* JS_CRYPTO_H */
|
|
@@ -28,6 +28,9 @@ JS_WARN_UNUSED JSValue js_throw_reference_error(JSContext *ctx, const char *fmt,
|
|
|
28
28
|
JS_WARN_UNUSED JSValue js_throw_syntax_error(JSContext *ctx, const char *fmt, ...);
|
|
29
29
|
JS_WARN_UNUSED JSValue js_throw_uri_error(JSContext *ctx, const char *fmt, ...);
|
|
30
30
|
JS_WARN_UNUSED JSValue js_throw_stack_overflow(JSContext *ctx); /* RangeError: Maximum call stack size exceeded */
|
|
31
|
+
/* ERR_INVALID_ARG_TYPE: `The "dest" argument must be <expected>. Received …` (Node's wording
|
|
32
|
+
* of the value). Generated code calls it: a "use static" function's checked entry. */
|
|
33
|
+
JS_WARN_UNUSED JSValue js_throw_invalid_arg_type(JSContext *ctx, const char *name, const char *expected, JSValue value);
|
|
31
34
|
|
|
32
35
|
/* ---- Catching ---------------------------------------------------------- */
|
|
33
36
|
|
|
@@ -79,7 +79,7 @@ typedef struct JSFunction { /* kind = FUNCTION */
|
|
|
79
79
|
JSContext *realm; /* the realm the function was created in */
|
|
80
80
|
uint32_t flags;
|
|
81
81
|
uint32_t pad_;
|
|
82
|
-
struct JSShape *instance_shape; /*
|
|
82
|
+
struct JSShape *instance_shape; /* the root shape of the objects `new` makes with it as new.target: inline slots for all their constructors add */
|
|
83
83
|
} JSFunction;
|
|
84
84
|
|
|
85
85
|
extern const JSClass js_class_function;
|