@scriptc/cli-darwin-arm64 0.2.4 → 0.2.6
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/THIRD_PARTY_NOTICES +1 -1
- package/dist/bin/scriptc +0 -0
- package/dist/bin/scriptc.json +1 -1
- package/dist/lib/declarations/scriptc-node-fallback.d.ts +972 -245
- package/dist/lib/declarations/scriptc-overrides.d.ts +5 -1
- package/dist/lib/declarations/scriptc.d.ts +22 -2
- package/dist/lib/llvm/bin/scriptc-llvm-codegen +0 -0
- package/dist/lib/llvm/package.json +1 -1
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_async.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_child.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_closure.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_console.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_context.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_copying.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_cycle.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_dgram.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_events.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_events_emitter.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_fetch.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_file_handle.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_number.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_readline.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_shared.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_stream.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_tls.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_union.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_async.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_async_dyn.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_bigint_assert.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_child.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_closure.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_console.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_context.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_copying.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_crypto_async.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_cycle.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_dc.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_dgram.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_dyn_handle.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_events.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_events_emitter.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_fetch.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_ffi.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_ffi_queue.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_file_handle.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_http.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_http2.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_inspect.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_loop_epoll.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_loop_kqueue.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_loop_wsapoll.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_net.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_number.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_path.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_qs.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_readline.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_shared.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_stream.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_test.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_tls.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_tls_ca.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_union.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_url_params.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_util.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_util_compare.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_util_style.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_watch.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default-workers/scr_zlib.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_async.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_child.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_closure.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_console.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_context.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_copying.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_cycle.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_dgram.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_events.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_events_emitter.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_file_handle.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_island.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_number.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_readline.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_shared.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_stream.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_tls.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_union.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic-text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/text-decoder-legacy-workers/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/workers/scr_mailbox.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/workers/scr_message.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/workers/scr_worker.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/workers/scr_worker_events.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_closure.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_context.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_copying.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_cycle.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_events_emitter.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_number.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_shared.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_union.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_closure.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_context.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_copying.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_cycle.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_events_emitter.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_number.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_shared.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_union.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_closure.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_console.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_context.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_copying.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_cycle.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_events_emitter.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_inspect.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_number.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_shared.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_union.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_zlib.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_closure.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_console.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_context.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_copying.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_cycle.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_events_emitter.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_inspect.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_number.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_shared.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_union.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_zlib.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_async.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_child.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_closure.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_console.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_context.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_copying.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_cycle.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_dgram.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_events.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_events_emitter.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_fetch.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_file_handle.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_number.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_readline.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_shared.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_stream.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_tls.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_union.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_util_compare.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_async.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_async_dyn.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_bigint_assert.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_child.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_closure.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_console.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_context.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_copying.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_crypto_async.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_cycle.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_dc.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_dgram.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_dyn_handle.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_events.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_events_emitter.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_fetch.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_ffi.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_ffi_queue.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_file_handle.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_http.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_http2.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_inspect.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_loop_epoll.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_loop_kqueue.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_loop_wsapoll.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_net.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_number.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_path.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_qs.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_readline.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_shared.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_stream.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_test.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_tls.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_tls_ca.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_union.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_url_params.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_util.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_util_compare.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_util_style.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_watch.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default-workers/scr_zlib.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_async.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_child.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_closure.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_console.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_context.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_copying.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_cycle.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_dgram.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_events.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_events_emitter.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_file_handle.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_island.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_number.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_readline.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_shared.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_stream.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_tls.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_union.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_util_compare.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic-text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/text-decoder-legacy-workers/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/workers/scr_mailbox.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/workers/scr_message.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/workers/scr_worker.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/workers/scr_worker_events.o +0 -0
- package/dist/lib/runtime-darwin-arm64/package.json +1 -1
- package/dist/lib/runtime-darwin-arm64/runtime-pack.json +3318 -790
- package/dist/lib/runtime-sources/package.json +1 -1
- package/dist/lib/runtime-sources/src/scr_array.c +479 -46
- package/dist/lib/runtime-sources/src/scr_assert.c +3 -3
- package/dist/lib/runtime-sources/src/scr_async.c +401 -71
- package/dist/lib/runtime-sources/src/scr_async.test.ts +16 -6
- package/dist/lib/runtime-sources/src/scr_async_dyn.c +30 -30
- package/dist/lib/runtime-sources/src/scr_bytes.c +487 -221
- package/dist/lib/runtime-sources/src/scr_bytes.test.c +85 -0
- package/dist/lib/runtime-sources/src/scr_bytes_io.c +45 -64
- package/dist/lib/runtime-sources/src/scr_child.c +48 -30
- package/dist/lib/runtime-sources/src/scr_closure.c +21 -11
- package/dist/lib/runtime-sources/src/scr_console.c +27 -5
- package/dist/lib/runtime-sources/src/scr_context.c +167 -0
- package/dist/lib/runtime-sources/src/scr_context.test.c +118 -0
- package/dist/lib/runtime-sources/src/scr_context.test.ts +47 -0
- package/dist/lib/runtime-sources/src/scr_copying.c +13 -2
- package/dist/lib/runtime-sources/src/scr_cycle.c +112 -12
- package/dist/lib/runtime-sources/src/scr_dc.c +8 -8
- package/dist/lib/runtime-sources/src/scr_dgram.c +10 -7
- package/dist/lib/runtime-sources/src/scr_error.c +26 -14
- package/dist/lib/runtime-sources/src/scr_events.c +45 -31
- package/dist/lib/runtime-sources/src/scr_events_emitter.c +34 -1
- package/dist/lib/runtime-sources/src/scr_exception.c +26 -7
- package/dist/lib/runtime-sources/src/scr_fetch.c +23 -20
- package/dist/lib/runtime-sources/src/scr_fetch_curl.c +1 -1
- package/dist/lib/runtime-sources/src/scr_ffi.c +3 -3
- package/dist/lib/runtime-sources/src/scr_file_handle.c +1 -0
- package/dist/lib/runtime-sources/src/scr_http.c +20 -16
- package/dist/lib/runtime-sources/src/scr_http2.c +10 -8
- package/dist/lib/runtime-sources/src/scr_inspect.c +1 -0
- package/dist/lib/runtime-sources/src/scr_island.c +1 -1
- package/dist/lib/runtime-sources/src/scr_json.c +652 -189
- package/dist/lib/runtime-sources/src/scr_json.test.c +339 -1
- package/dist/lib/runtime-sources/src/scr_json.test.ts +59 -25
- package/dist/lib/runtime-sources/src/scr_key.h +92 -0
- package/dist/lib/runtime-sources/src/scr_lib.c +256 -136
- package/dist/lib/runtime-sources/src/scr_mailbox.c +233 -0
- package/dist/lib/runtime-sources/src/scr_mailbox.h +28 -0
- package/dist/lib/runtime-sources/src/scr_mailbox.test.c +86 -0
- package/dist/lib/runtime-sources/src/scr_mailbox.test.ts +46 -0
- package/dist/lib/runtime-sources/src/scr_map.c +240 -107
- package/dist/lib/runtime-sources/src/scr_message.c +443 -0
- package/dist/lib/runtime-sources/src/scr_message.h +14 -0
- package/dist/lib/runtime-sources/src/scr_message.test.c +152 -0
- package/dist/lib/runtime-sources/src/scr_message.test.ts +44 -0
- package/dist/lib/runtime-sources/src/scr_net.c +14 -12
- package/dist/lib/runtime-sources/src/scr_number.c +36 -4
- package/dist/lib/runtime-sources/src/scr_numeric.h +25 -0
- package/dist/lib/runtime-sources/src/scr_numeric.test.c +37 -0
- package/dist/lib/runtime-sources/src/scr_numeric.test.ts +33 -0
- package/dist/lib/runtime-sources/src/scr_object.c +9 -4
- package/dist/lib/runtime-sources/src/scr_path.c +1 -1
- package/dist/lib/runtime-sources/src/scr_readline.c +8 -8
- package/dist/lib/runtime-sources/src/scr_regex.c +351 -167
- package/dist/lib/runtime-sources/src/scr_runtime.h +207 -34
- package/dist/lib/runtime-sources/src/scr_shared.c +280 -0
- package/dist/lib/runtime-sources/src/scr_shared.test.c +113 -0
- package/dist/lib/runtime-sources/src/scr_shared.test.ts +45 -0
- package/dist/lib/runtime-sources/src/scr_stream.c +9 -9
- package/dist/lib/runtime-sources/src/scr_string.c +365 -141
- package/dist/lib/runtime-sources/src/scr_test.c +8 -8
- package/dist/lib/runtime-sources/src/scr_tls.c +12 -12
- package/dist/lib/runtime-sources/src/scr_tls_ca.c +34 -12
- package/dist/lib/runtime-sources/src/scr_union.c +10 -5
- package/dist/lib/runtime-sources/src/scr_util_compare.c +1 -0
- package/dist/lib/runtime-sources/src/scr_util_style.c +11 -11
- package/dist/lib/runtime-sources/src/scr_watch.c +16 -6
- package/dist/lib/runtime-sources/src/scr_worker.c +232 -0
- package/dist/lib/runtime-sources/src/scr_worker.h +42 -0
- package/dist/lib/runtime-sources/src/scr_worker.test.c +115 -0
- package/dist/lib/runtime-sources/src/scr_worker.test.ts +49 -0
- package/dist/lib/runtime-sources/src/scr_worker_events.c +443 -0
- package/dist/lib/runtime-sources/src/scr_zlib.c +6 -0
- package/package.json +1 -1
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* encoding conversions (utf8 with WHATWG replacement, hex, base64) match
|
|
8
8
|
* Node byte-for-byte — the differential corpus holds them to it. */
|
|
9
9
|
#include "scr_runtime.h"
|
|
10
|
+
#include "scr_numeric.h"
|
|
10
11
|
#include "scr_text_decoder_labels.h"
|
|
11
12
|
#ifdef SCR_TEXT_DECODER_LEGACY
|
|
12
13
|
#include "scr_text_decoder_data.h"
|
|
@@ -116,24 +117,49 @@ double scr_bytes_to_u8_clamp(double value) {
|
|
|
116
117
|
|
|
117
118
|
/* ── lifecycle ─────────────────────────────────────────────────────────── */
|
|
118
119
|
|
|
119
|
-
|
|
120
|
+
/* Adopt private malloc storage without clearing or copying its contents. The
|
|
121
|
+
* caller transfers ownership; views keep it alive through the usual owner. */
|
|
122
|
+
ScrBytes *scr_bytes_take_data(uint8_t *data, size_t len) {
|
|
123
|
+
if (!data && len) scr_trap("scriptc: NULL owned byte storage\n");
|
|
120
124
|
ScrBytes *b = malloc(sizeof(ScrBytes));
|
|
121
125
|
if (!b) scr_bytes_oom();
|
|
122
126
|
b->rc = 1;
|
|
123
127
|
b->len = len;
|
|
124
|
-
b->elem =
|
|
125
|
-
b->data =
|
|
128
|
+
b->elem = SCR_BYTES_U8;
|
|
129
|
+
b->data = data ? data : malloc(1);
|
|
126
130
|
if (!b->data) scr_bytes_oom();
|
|
127
131
|
b->backing = NULL;
|
|
128
132
|
b->is_buffer = false;
|
|
129
133
|
b->is_data_view = false;
|
|
130
134
|
b->external = false;
|
|
135
|
+
b->shared = NULL;
|
|
131
136
|
#ifdef SCR_RC_AUDIT
|
|
132
137
|
scr_live_bytes++;
|
|
133
138
|
#endif
|
|
134
139
|
return b;
|
|
135
140
|
}
|
|
136
141
|
|
|
142
|
+
/* Only complete, non-observable initialization may use private storage. */
|
|
143
|
+
static ScrBytes *scr_bytes_alloc_private(ScrBytesElem elem, size_t len) {
|
|
144
|
+
size_t width = scr_bytes_elem_size(elem);
|
|
145
|
+
if (len > SIZE_MAX / width) scr_bytes_oom();
|
|
146
|
+
uint8_t *data = malloc(len ? len * width : 1);
|
|
147
|
+
if (!data) scr_bytes_oom();
|
|
148
|
+
ScrBytes *b = scr_bytes_take_data(data, len);
|
|
149
|
+
b->elem = elem;
|
|
150
|
+
return b;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
static ScrBytes *scr_bytes_alloc(ScrBytesElem elem, size_t len) {
|
|
154
|
+
size_t width = scr_bytes_elem_size(elem);
|
|
155
|
+
if (len > SIZE_MAX / width) scr_bytes_oom();
|
|
156
|
+
uint8_t *data = calloc(len ? len : 1, width);
|
|
157
|
+
if (!data) scr_bytes_oom();
|
|
158
|
+
ScrBytes *b = scr_bytes_take_data(data, len);
|
|
159
|
+
b->elem = elem;
|
|
160
|
+
return b;
|
|
161
|
+
}
|
|
162
|
+
|
|
137
163
|
ScrBytes *scr_bytes_from_external(void *data, size_t length) {
|
|
138
164
|
ScrBytes *b = scr_bytes_alloc(SCR_BYTES_U8, 0);
|
|
139
165
|
/* Keep the owned empty allocation for NULL/zero-length views: existing
|
|
@@ -168,13 +194,14 @@ ScrBytes *scr_bytes_from_data(const uint8_t *data, size_t len) {
|
|
|
168
194
|
if (data == NULL && len != 0) {
|
|
169
195
|
scr_trap("scriptc: native callback passed a NULL span with nonzero length\n");
|
|
170
196
|
}
|
|
171
|
-
ScrBytes *b =
|
|
197
|
+
ScrBytes *b = scr_bytes_alloc_private(SCR_BYTES_U8, len);
|
|
172
198
|
if (len != 0) memcpy(b->data, data, len);
|
|
173
199
|
return b;
|
|
174
200
|
}
|
|
175
201
|
|
|
176
202
|
ScrBytes *scr_bytes_copy(const ScrBytes *src) {
|
|
177
|
-
|
|
203
|
+
SCR_SHARED_GUARD(src, NULL);
|
|
204
|
+
ScrBytes *b = scr_bytes_alloc_private(src->elem, src->len);
|
|
178
205
|
memcpy(b->data, src->data, src->len * scr_bytes_elem_size(src->elem));
|
|
179
206
|
return b;
|
|
180
207
|
}
|
|
@@ -190,19 +217,14 @@ ScrBytes *scr_bytes_as_buffer(ScrBytes *bytes) {
|
|
|
190
217
|
return scr_bytes_retain(bytes);
|
|
191
218
|
}
|
|
192
219
|
|
|
193
|
-
ScrBytes *scr_bytes_convert(ScrBytesElem elem, const ScrBytes *src) {
|
|
194
|
-
if (elem == src->elem) return scr_bytes_copy(src);
|
|
195
|
-
ScrBytes *out = scr_bytes_alloc(elem, src->len);
|
|
196
|
-
for (size_t i = 0; i < src->len; i++) scr_bytes_set(out, (double)i, scr_bytes_get(src, (double)i));
|
|
197
|
-
return out;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
220
|
void scr_bytes_release(ScrBytes *b) {
|
|
201
221
|
if (!b || b->rc == SIZE_MAX) return; /* NULL: an uninitialized `let` local */
|
|
202
222
|
if (--b->rc == 0) {
|
|
203
223
|
scr_weak_dispose(b);
|
|
204
224
|
if (b->backing) {
|
|
205
225
|
scr_bytes_release(b->backing); /* a view: data points into the owner */
|
|
226
|
+
} else if (b->shared) {
|
|
227
|
+
scr_shared_release(b->shared);
|
|
206
228
|
} else if (!b->external) {
|
|
207
229
|
free(b->data);
|
|
208
230
|
}
|
|
@@ -219,6 +241,7 @@ void scr_bytes_release_v(void *b) { scr_bytes_release((ScrBytes *)b); }
|
|
|
219
241
|
double scr_bytes_len(const ScrBytes *b) { return (double)b->len; }
|
|
220
242
|
|
|
221
243
|
void scr_bytes_copy_contents(ScrBytes *dst, const ScrBytes *src) {
|
|
244
|
+
SCR_SHARED_GUARD(dst, src);
|
|
222
245
|
if (dst->elem != src->elem || dst->len != src->len) {
|
|
223
246
|
scr_trap("scriptc: typed array snapshot shape changed\n");
|
|
224
247
|
}
|
|
@@ -246,14 +269,11 @@ static size_t scr_bytes_check_index(const ScrBytes *b, double i) {
|
|
|
246
269
|
/* ToUint32: NaN/±Infinity → 0, truncate toward zero, wrap mod 2^32.
|
|
247
270
|
* ToUint8 is its low byte (2^8 divides 2^32, so the residues agree). */
|
|
248
271
|
static uint32_t scr_bytes_to_u32(double v) {
|
|
249
|
-
|
|
250
|
-
double t = trunc(v);
|
|
251
|
-
t = fmod(t, 4294967296.0);
|
|
252
|
-
if (t < 0) t += 4294967296.0;
|
|
253
|
-
return (uint32_t)t;
|
|
272
|
+
return scr_numeric_to_u32(v);
|
|
254
273
|
}
|
|
255
274
|
|
|
256
275
|
double scr_bytes_get(const ScrBytes *b, double i) {
|
|
276
|
+
SCR_SHARED_GUARD(b, NULL);
|
|
257
277
|
size_t idx = scr_bytes_check_index(b, i);
|
|
258
278
|
switch (b->elem) {
|
|
259
279
|
case SCR_BYTES_U8: case SCR_BYTES_U8C:
|
|
@@ -298,6 +318,7 @@ double scr_bytes_get(const ScrBytes *b, double i) {
|
|
|
298
318
|
}
|
|
299
319
|
|
|
300
320
|
void scr_bytes_set(ScrBytes *b, double i, double v) {
|
|
321
|
+
SCR_SHARED_GUARD(b, NULL);
|
|
301
322
|
if (!(i >= 0) || i != trunc(i) || i >= (double)b->len) return;
|
|
302
323
|
size_t idx = (size_t)i;
|
|
303
324
|
switch (b->elem) {
|
|
@@ -336,6 +357,87 @@ void scr_bytes_set(ScrBytes *b, double i, double v) {
|
|
|
336
357
|
}
|
|
337
358
|
}
|
|
338
359
|
|
|
360
|
+
/* Dispatch once per bounded block, not once per element. Loads and stores
|
|
361
|
+
* use memcpy so views and external storage need no stronger alignment or
|
|
362
|
+
* aliasing promise. A bounded scratch block avoids a kind-pair code matrix. */
|
|
363
|
+
static void scr_bytes_read_numbers(double *out, const uint8_t *src, ScrBytesElem elem, size_t count) {
|
|
364
|
+
#define SCR_READ_NUMBERS(kind, type) \
|
|
365
|
+
case kind: \
|
|
366
|
+
for (size_t i = 0; i < count; i++) { \
|
|
367
|
+
type value; \
|
|
368
|
+
memcpy(&value, src + i * sizeof value, sizeof value); \
|
|
369
|
+
out[i] = (double)value; \
|
|
370
|
+
} \
|
|
371
|
+
return
|
|
372
|
+
switch (elem) {
|
|
373
|
+
case SCR_BYTES_U8C:
|
|
374
|
+
SCR_READ_NUMBERS(SCR_BYTES_U8, uint8_t);
|
|
375
|
+
SCR_READ_NUMBERS(SCR_BYTES_I8, int8_t);
|
|
376
|
+
SCR_READ_NUMBERS(SCR_BYTES_U16, uint16_t);
|
|
377
|
+
SCR_READ_NUMBERS(SCR_BYTES_I16, int16_t);
|
|
378
|
+
SCR_READ_NUMBERS(SCR_BYTES_U32, uint32_t);
|
|
379
|
+
SCR_READ_NUMBERS(SCR_BYTES_I32, int32_t);
|
|
380
|
+
SCR_READ_NUMBERS(SCR_BYTES_F32, float);
|
|
381
|
+
SCR_READ_NUMBERS(SCR_BYTES_F64, double);
|
|
382
|
+
}
|
|
383
|
+
#undef SCR_READ_NUMBERS
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
static void scr_bytes_write_numbers(uint8_t *dst, ScrBytesElem elem, const double *src, size_t count) {
|
|
387
|
+
#define SCR_WRITE_NUMBERS(type, expression) \
|
|
388
|
+
for (size_t i = 0; i < count; i++) { \
|
|
389
|
+
type value = (expression); \
|
|
390
|
+
memcpy(dst + i * sizeof value, &value, sizeof value); \
|
|
391
|
+
} \
|
|
392
|
+
return
|
|
393
|
+
switch (elem) {
|
|
394
|
+
case SCR_BYTES_U8: case SCR_BYTES_I8: {
|
|
395
|
+
SCR_WRITE_NUMBERS(uint8_t, (uint8_t)scr_numeric_to_u32(src[i]));
|
|
396
|
+
}
|
|
397
|
+
case SCR_BYTES_U8C: {
|
|
398
|
+
SCR_WRITE_NUMBERS(uint8_t, (uint8_t)scr_bytes_to_u8_clamp(src[i]));
|
|
399
|
+
}
|
|
400
|
+
case SCR_BYTES_U16: case SCR_BYTES_I16: {
|
|
401
|
+
SCR_WRITE_NUMBERS(uint16_t, (uint16_t)scr_numeric_to_u32(src[i]));
|
|
402
|
+
}
|
|
403
|
+
case SCR_BYTES_U32: case SCR_BYTES_I32: {
|
|
404
|
+
SCR_WRITE_NUMBERS(uint32_t, scr_numeric_to_u32(src[i]));
|
|
405
|
+
}
|
|
406
|
+
case SCR_BYTES_F32: {
|
|
407
|
+
SCR_WRITE_NUMBERS(float, (float)src[i]);
|
|
408
|
+
}
|
|
409
|
+
case SCR_BYTES_F64: {
|
|
410
|
+
memcpy(dst, src, count * sizeof(double));
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
#undef SCR_WRITE_NUMBERS
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/* Caller guarantees disjoint spans, or snapshots the source before entry. */
|
|
418
|
+
static void scr_bytes_convert_span(uint8_t *dst, ScrBytesElem dest_elem,
|
|
419
|
+
const uint8_t *src, ScrBytesElem src_elem, size_t count) {
|
|
420
|
+
size_t source_width = scr_bytes_elem_size(src_elem);
|
|
421
|
+
size_t dest_width = scr_bytes_elem_size(dest_elem);
|
|
422
|
+
double values[128];
|
|
423
|
+
while (count) {
|
|
424
|
+
size_t block = count < 128 ? count : 128;
|
|
425
|
+
scr_bytes_read_numbers(values, src, src_elem, block);
|
|
426
|
+
scr_bytes_write_numbers(dst, dest_elem, values, block);
|
|
427
|
+
src += block * source_width;
|
|
428
|
+
dst += block * dest_width;
|
|
429
|
+
count -= block;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
ScrBytes *scr_bytes_convert(ScrBytesElem elem, const ScrBytes *src) {
|
|
434
|
+
SCR_SHARED_GUARD(src, NULL);
|
|
435
|
+
if (elem == src->elem) return scr_bytes_copy(src);
|
|
436
|
+
ScrBytes *out = scr_bytes_alloc_private(elem, src->len);
|
|
437
|
+
scr_bytes_convert_span(out->data, elem, src->data, src->elem, src->len);
|
|
438
|
+
return out;
|
|
439
|
+
}
|
|
440
|
+
|
|
339
441
|
/* ── slice (copy) / subarray (view) ────────────────────────────────────── */
|
|
340
442
|
|
|
341
443
|
/* Relative index: ToIntegerOrInfinity, negatives from the end, clamped. */
|
|
@@ -349,16 +451,18 @@ static size_t scr_bytes_rel_index(double i, size_t len) {
|
|
|
349
451
|
}
|
|
350
452
|
|
|
351
453
|
ScrBytes *scr_bytes_slice(const ScrBytes *b, double start, double end) {
|
|
454
|
+
SCR_SHARED_GUARD(b, NULL);
|
|
352
455
|
size_t s = scr_bytes_rel_index(start, b->len);
|
|
353
456
|
size_t e = scr_bytes_rel_index(end, b->len);
|
|
354
457
|
size_t count = e > s ? e - s : 0;
|
|
355
458
|
size_t esize = scr_bytes_elem_size(b->elem);
|
|
356
|
-
ScrBytes *out =
|
|
459
|
+
ScrBytes *out = scr_bytes_alloc_private(b->elem, count);
|
|
357
460
|
memcpy(out->data, b->data + s * esize, count * esize);
|
|
358
461
|
return out;
|
|
359
462
|
}
|
|
360
463
|
|
|
361
464
|
ScrBytes *scr_bytes_copy_within(ScrBytes *b, double target, double start, double end) {
|
|
465
|
+
SCR_SHARED_GUARD(b, NULL);
|
|
362
466
|
size_t t = scr_bytes_rel_index(target, b->len);
|
|
363
467
|
size_t s = scr_bytes_rel_index(start, b->len);
|
|
364
468
|
size_t e = scr_bytes_rel_index(end, b->len);
|
|
@@ -374,9 +478,26 @@ ScrBytes *scr_bytes_copy_within(ScrBytes *b, double target, double start, double
|
|
|
374
478
|
* rounding), slice-clamped relative indices; answers the receiver +1
|
|
375
479
|
* (chaining). Never throws — Buffer's throwing fill family is separate. */
|
|
376
480
|
ScrBytes *scr_bytes_fill_elem(ScrBytes *b, double v, double start, double end) {
|
|
481
|
+
SCR_SHARED_GUARD(b, NULL);
|
|
377
482
|
size_t s = scr_bytes_rel_index(start, b->len);
|
|
378
483
|
size_t e = scr_bytes_rel_index(end, b->len);
|
|
379
|
-
|
|
484
|
+
if (e > s) {
|
|
485
|
+
size_t width = scr_bytes_elem_size(b->elem);
|
|
486
|
+
uint8_t pattern[8];
|
|
487
|
+
scr_bytes_write_numbers(pattern, b->elem, &v, 1);
|
|
488
|
+
uint8_t *dst = b->data + s * width;
|
|
489
|
+
size_t bytes = (e - s) * width;
|
|
490
|
+
if (width == 1) memset(dst, pattern[0], bytes);
|
|
491
|
+
else {
|
|
492
|
+
memcpy(dst, pattern, width);
|
|
493
|
+
size_t filled = width;
|
|
494
|
+
while (filled < bytes) {
|
|
495
|
+
size_t copy = filled < bytes - filled ? filled : bytes - filled;
|
|
496
|
+
memcpy(dst + filled, dst, copy);
|
|
497
|
+
filled += copy;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
}
|
|
380
501
|
return scr_bytes_retain(b);
|
|
381
502
|
}
|
|
382
503
|
|
|
@@ -401,6 +522,7 @@ ScrBytes *scr_bytes_subarray(ScrBytes *b, double start, double end) {
|
|
|
401
522
|
v->is_buffer = b->is_buffer;
|
|
402
523
|
v->is_data_view = false;
|
|
403
524
|
v->external = false;
|
|
525
|
+
v->shared = owner->shared;
|
|
404
526
|
#ifdef SCR_RC_AUDIT
|
|
405
527
|
scr_live_bytes++;
|
|
406
528
|
#endif
|
|
@@ -408,22 +530,34 @@ ScrBytes *scr_bytes_subarray(ScrBytes *b, double start, double end) {
|
|
|
408
530
|
}
|
|
409
531
|
|
|
410
532
|
void scr_bytes_set_from(ScrBytes *dst, const ScrBytes *src, double offset) {
|
|
533
|
+
SCR_SHARED_GUARD(dst, src);
|
|
411
534
|
double t = (offset != offset) ? 0 : trunc(offset);
|
|
412
535
|
if (!(t >= 0) || (double)src->len + t > (double)dst->len) {
|
|
413
536
|
static const char msg[] = "offset is out of bounds";
|
|
414
537
|
scr_throw_error_msg(SCR_ERR_RANGE, msg, sizeof msg - 1);
|
|
415
538
|
return;
|
|
416
539
|
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
copy->len * scr_bytes_elem_size(copy->elem));
|
|
422
|
-
scr_bytes_release(copy);
|
|
540
|
+
size_t width = scr_bytes_elem_size(dst->elem);
|
|
541
|
+
uint8_t *target = dst->data + (size_t)t * width;
|
|
542
|
+
if (dst->elem == src->elem) {
|
|
543
|
+
memmove(target, src->data, src->len * width);
|
|
423
544
|
return;
|
|
424
545
|
}
|
|
425
|
-
size_t
|
|
426
|
-
|
|
546
|
+
size_t source_bytes = src->len * scr_bytes_elem_size(src->elem);
|
|
547
|
+
size_t dest_bytes = src->len * width;
|
|
548
|
+
uintptr_t to = (uintptr_t)target, from = (uintptr_t)src->data;
|
|
549
|
+
bool overlap = to <= from ? from - to < dest_bytes : to - from < source_bytes;
|
|
550
|
+
if (overlap) {
|
|
551
|
+
/* Snapshot raw source bytes before cross-kind writes. Distinct external
|
|
552
|
+
* wrappers can alias even without a shared backing identity. */
|
|
553
|
+
uint8_t *copy = malloc(source_bytes ? source_bytes : 1);
|
|
554
|
+
if (!copy) scr_bytes_oom();
|
|
555
|
+
memcpy(copy, src->data, source_bytes);
|
|
556
|
+
scr_bytes_convert_span(target, dst->elem, copy, src->elem, src->len);
|
|
557
|
+
free(copy);
|
|
558
|
+
} else {
|
|
559
|
+
scr_bytes_convert_span(target, dst->elem, src->data, src->elem, src->len);
|
|
560
|
+
}
|
|
427
561
|
}
|
|
428
562
|
|
|
429
563
|
/* Checked-native array-like sources. Runtime objects with an unsupported
|
|
@@ -504,7 +638,7 @@ ScrBytes *scr_bytes_from_dyn(ScrBytesElem elem, const ScrDyn *value, bool from)
|
|
|
504
638
|
return out;
|
|
505
639
|
}
|
|
506
640
|
if (value->kind == SCR_DYN_BYTES) return scr_bytes_convert(elem, value->v.bytes);
|
|
507
|
-
if (!from &&
|
|
641
|
+
if (!from && scr_buffer_storage_is(value)) return scr_array_buffer_view(elem, value, scr_dyn_undefined(), scr_dyn_undefined());
|
|
508
642
|
if (!from && (value->kind == SCR_DYN_NUM || value->kind == SCR_DYN_BOOL ||
|
|
509
643
|
value->kind == SCR_DYN_STR || value->kind == SCR_DYN_NULL || value->kind == SCR_DYN_UNDEF)) {
|
|
510
644
|
double number;
|
|
@@ -615,6 +749,7 @@ ScrBytes *scr_dataview_new(ScrBytes *src, double byte_off, bool has_len, double
|
|
|
615
749
|
v->is_buffer = false;
|
|
616
750
|
v->is_data_view = true;
|
|
617
751
|
v->external = false;
|
|
752
|
+
v->shared = owner->shared;
|
|
618
753
|
#ifdef SCR_RC_AUDIT
|
|
619
754
|
scr_live_bytes++;
|
|
620
755
|
#endif
|
|
@@ -663,6 +798,7 @@ static size_t scr_dataview_get_size(ScrDataViewGet kind) {
|
|
|
663
798
|
}
|
|
664
799
|
|
|
665
800
|
double scr_dataview_get(const ScrBytes *b, double byte_off, ScrDataViewGet kind, bool le) {
|
|
801
|
+
SCR_SHARED_GUARD(b, NULL);
|
|
666
802
|
size_t width = scr_dataview_get_size(kind);
|
|
667
803
|
/* ToIndex, then the view-relative bounds check — Node's ONE constant
|
|
668
804
|
* message for every failure mode (negative, NaN is fine, too large). */
|
|
@@ -711,6 +847,7 @@ double scr_dataview_get(const ScrBytes *b, double byte_off, ScrDataViewGet kind,
|
|
|
711
847
|
}
|
|
712
848
|
|
|
713
849
|
void scr_dataview_set(ScrBytes *b, double byte_off, double value, ScrDataViewGet kind, bool le) {
|
|
850
|
+
SCR_SHARED_GUARD(b, NULL);
|
|
714
851
|
size_t width = scr_dataview_get_size(kind);
|
|
715
852
|
/* ToIndex + the view-relative bounds check — the getters' ONE message. */
|
|
716
853
|
double off = (byte_off != byte_off) ? 0 : trunc(byte_off);
|
|
@@ -766,79 +903,85 @@ static void scr_td_invalid(const char *encoding) {
|
|
|
766
903
|
scr_throw_error_msg_code(SCR_ERR_TYPE, message, (size_t)n, "ERR_ENCODING_INVALID_ENCODED_DATA");
|
|
767
904
|
}
|
|
768
905
|
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
906
|
+
/* Stop before the first non-ASCII byte; every word load stays in the span. */
|
|
907
|
+
static size_t scr_bytes_ascii_prefix(const uint8_t *data, size_t len) {
|
|
908
|
+
size_t i = 0;
|
|
909
|
+
while (len - i >= sizeof(uint64_t)) {
|
|
910
|
+
uint64_t word;
|
|
911
|
+
memcpy(&word, data + i, sizeof word);
|
|
912
|
+
if (word & UINT64_C(0x8080808080808080)) break;
|
|
913
|
+
i += sizeof word;
|
|
772
914
|
}
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
if (byte
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
needed = 3; cp = byte & 0x7;
|
|
803
|
-
} else {
|
|
804
|
-
if (fatal) { free(out); scr_td_invalid("utf-8"); return NULL; }
|
|
805
|
-
memcpy(out + o, "\xef\xbf\xbd", 3);
|
|
806
|
-
o += 3;
|
|
807
|
-
}
|
|
808
|
-
continue;
|
|
809
|
-
}
|
|
810
|
-
if (byte < lower || byte > upper) {
|
|
811
|
-
/* Invalid continuation: replace the subpart, REPROCESS this byte. */
|
|
812
|
-
if (fatal) { free(out); scr_td_invalid("utf-8"); return NULL; }
|
|
813
|
-
memcpy(out + o, "\xef\xbf\xbd", 3);
|
|
814
|
-
o += 3;
|
|
815
|
-
needed = 0; lower = 0x80; upper = 0xbf;
|
|
816
|
-
i--;
|
|
817
|
-
continue;
|
|
818
|
-
}
|
|
819
|
-
lower = 0x80; upper = 0xbf;
|
|
820
|
-
cp = (cp << 6) | (byte & 0x3f);
|
|
821
|
-
if (--needed == 0) {
|
|
822
|
-
/* Re-encode the (valid, non-surrogate, <= 10FFFF) code point. */
|
|
823
|
-
if (cp <= 0x7f) {
|
|
824
|
-
out[o++] = (char)cp;
|
|
825
|
-
} else if (cp <= 0x7ff) {
|
|
826
|
-
out[o++] = (char)(0xc0 | (cp >> 6));
|
|
827
|
-
out[o++] = (char)(0x80 | (cp & 0x3f));
|
|
828
|
-
} else if (cp <= 0xffff) {
|
|
829
|
-
out[o++] = (char)(0xe0 | (cp >> 12));
|
|
830
|
-
out[o++] = (char)(0x80 | ((cp >> 6) & 0x3f));
|
|
831
|
-
out[o++] = (char)(0x80 | (cp & 0x3f));
|
|
832
|
-
} else {
|
|
833
|
-
out[o++] = (char)(0xf0 | (cp >> 18));
|
|
834
|
-
out[o++] = (char)(0x80 | ((cp >> 12) & 0x3f));
|
|
835
|
-
out[o++] = (char)(0x80 | ((cp >> 6) & 0x3f));
|
|
836
|
-
out[o++] = (char)(0x80 | (cp & 0x3f));
|
|
915
|
+
while (i < len && data[i] < 0x80) i++;
|
|
916
|
+
return i;
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
/* Length of the well-formed prefix. On failure, next skips exactly the
|
|
920
|
+
* maximal invalid subpart; an offending continuation is reprocessed. */
|
|
921
|
+
static size_t scr_bytes_utf8_prefix(const uint8_t *data, size_t len, size_t *next) {
|
|
922
|
+
size_t i = 0;
|
|
923
|
+
while (i < len) {
|
|
924
|
+
i += scr_bytes_ascii_prefix(data + i, len - i);
|
|
925
|
+
if (i == len) break;
|
|
926
|
+
size_t start = i;
|
|
927
|
+
unsigned byte = data[i++], count;
|
|
928
|
+
unsigned low = 0x80, high = 0xbf;
|
|
929
|
+
if (byte < 0x80) continue;
|
|
930
|
+
if (byte >= 0xc2 && byte <= 0xdf) count = 1;
|
|
931
|
+
else if (byte >= 0xe0 && byte <= 0xef) {
|
|
932
|
+
count = 2;
|
|
933
|
+
if (byte == 0xe0) low = 0xa0;
|
|
934
|
+
if (byte == 0xed) high = 0x9f;
|
|
935
|
+
} else if (byte >= 0xf0 && byte <= 0xf4) {
|
|
936
|
+
count = 3;
|
|
937
|
+
if (byte == 0xf0) low = 0x90;
|
|
938
|
+
if (byte == 0xf4) high = 0x8f;
|
|
939
|
+
} else { *next = i; return start; }
|
|
940
|
+
for (unsigned j = 0; j < count; j++) {
|
|
941
|
+
if (i == len || data[i] < low || data[i] > high) {
|
|
942
|
+
*next = i;
|
|
943
|
+
return start;
|
|
837
944
|
}
|
|
945
|
+
i++;
|
|
946
|
+
low = 0x80;
|
|
947
|
+
high = 0xbf;
|
|
838
948
|
}
|
|
839
949
|
}
|
|
840
|
-
|
|
841
|
-
|
|
950
|
+
*next = len;
|
|
951
|
+
return len;
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
/* Measure first, then write into final string storage. Invalid input can
|
|
955
|
+
* expand, but neither valid prefixes nor retained output need a 3x buffer. */
|
|
956
|
+
static size_t scr_bytes_utf8_repair(const uint8_t *in, size_t n,
|
|
957
|
+
size_t prefix, size_t next, char *out) {
|
|
958
|
+
size_t written = 0, offset = 0;
|
|
959
|
+
for (;;) {
|
|
960
|
+
if (prefix > SIZE_MAX - written) scr_bytes_oom();
|
|
961
|
+
if (out && prefix) memcpy(out + written, in + offset, prefix);
|
|
962
|
+
written += prefix;
|
|
963
|
+
if (prefix == n - offset) return written;
|
|
964
|
+
if (written > SIZE_MAX - 3) scr_bytes_oom();
|
|
965
|
+
if (out) memcpy(out + written, "\xef\xbf\xbd", 3);
|
|
966
|
+
written += 3;
|
|
967
|
+
offset += next;
|
|
968
|
+
prefix = scr_bytes_utf8_prefix(in + offset, n - offset, &next);
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
static ScrStr *scr_bytes_decode_utf8_options(const uint8_t *in, size_t n, bool fatal) {
|
|
973
|
+
if (in == NULL && n != 0) {
|
|
974
|
+
scr_trap("scriptc: native callback passed a NULL span with nonzero length\n");
|
|
975
|
+
}
|
|
976
|
+
if (n == 0) return scr_str_new("", 0);
|
|
977
|
+
size_t next;
|
|
978
|
+
size_t prefix = scr_bytes_utf8_prefix(in, n, &next);
|
|
979
|
+
if (prefix == n) return scr_str_new((const char *)in, n);
|
|
980
|
+
if (fatal) { scr_td_invalid("utf-8"); return NULL; }
|
|
981
|
+
size_t length = scr_bytes_utf8_repair(in, n, prefix, next, NULL);
|
|
982
|
+
ScrStr *s = scr_str_alloc_raw(length, length);
|
|
983
|
+
scr_bytes_utf8_repair(in, n, prefix, next, s->data);
|
|
984
|
+
s->data[length] = '\0';
|
|
842
985
|
return s;
|
|
843
986
|
}
|
|
844
987
|
|
|
@@ -855,6 +998,7 @@ ScrStr *scr_str_from_utf8_lossy(const uint8_t *bytes, size_t len) {
|
|
|
855
998
|
* difference — a leading UTF-8 BOM is stripped (ignoreBOM defaults to
|
|
856
999
|
* false in the spec; Buffer.toString keeps the BOM as U+FEFF). */
|
|
857
1000
|
ScrStr *scr_text_decode_options(const ScrBytes *b, bool fatal, bool ignore_bom) {
|
|
1001
|
+
SCR_SHARED_GUARD(b, NULL);
|
|
858
1002
|
const uint8_t *in = b->data;
|
|
859
1003
|
size_t n = b->len;
|
|
860
1004
|
if (!ignore_bom && n >= 3 && in[0] == 0xef && in[1] == 0xbb && in[2] == 0xbf) {
|
|
@@ -877,7 +1021,7 @@ ScrBytes *scr_bytes_buffer_source(const ScrDyn *value) {
|
|
|
877
1021
|
ScrBytes *bytes = value->v.bytes;
|
|
878
1022
|
return scr_bytes_buffer_view(bytes, SCR_BYTES_U8, scr_bytes_byte_offset(bytes), true, scr_bytes_byte_len(bytes));
|
|
879
1023
|
}
|
|
880
|
-
if (
|
|
1024
|
+
if (scr_buffer_storage_is(value)) {
|
|
881
1025
|
return scr_array_buffer_view(SCR_BYTES_U8, value, scr_dyn_undefined(), scr_dyn_undefined());
|
|
882
1026
|
}
|
|
883
1027
|
static const char message[] = "The input argument must be an instance of SharedArrayBuffer, ArrayBuffer or ArrayBufferView.";
|
|
@@ -1048,12 +1192,14 @@ static ScrStr *scr_strdec_step(const ScrStr *enc, double pending, const ScrBytes
|
|
|
1048
1192
|
|
|
1049
1193
|
/* decoder.write(chunk): the decoded complete prefix (+1). */
|
|
1050
1194
|
ScrStr *scr_strdec_write(const ScrStr *enc, double pending, const ScrBytes *chunk) {
|
|
1195
|
+
SCR_SHARED_GUARD(chunk, NULL);
|
|
1051
1196
|
double hold;
|
|
1052
1197
|
return scr_strdec_step(enc, pending, chunk, true, &hold);
|
|
1053
1198
|
}
|
|
1054
1199
|
|
|
1055
1200
|
/* The decoder state AFTER a write: the packed trailing partial sequence. */
|
|
1056
1201
|
double scr_strdec_next(const ScrStr *enc, double pending, const ScrBytes *chunk) {
|
|
1202
|
+
SCR_SHARED_GUARD(chunk, NULL);
|
|
1057
1203
|
double hold = 0;
|
|
1058
1204
|
scr_strdec_step(enc, pending, chunk, false, &hold);
|
|
1059
1205
|
return hold;
|
|
@@ -1094,6 +1240,7 @@ static void scr_bytes_to_str_bounds(const ScrBytes *b, double start, double end,
|
|
|
1094
1240
|
* form). Delegates to the whole-buffer decoder
|
|
1095
1241
|
* through a stack view — no allocation, no rc traffic. */
|
|
1096
1242
|
ScrStr *scr_bytes_to_str_range(const ScrBytes *b, const ScrStr *enc, double start, double end) {
|
|
1243
|
+
SCR_SHARED_GUARD(b, NULL);
|
|
1097
1244
|
size_t s0, e0;
|
|
1098
1245
|
scr_bytes_to_str_bounds(b, start, end, &s0, &e0);
|
|
1099
1246
|
ScrBytes view = { .rc = 1, .len = e0 - s0, .elem = b->elem, .data = b->data + s0, .backing = NULL };
|
|
@@ -1109,23 +1256,30 @@ static ScrStr *scr_bytes_encode_b64(const uint8_t *in, size_t n, bool url) {
|
|
|
1109
1256
|
static const char url_abc[] =
|
|
1110
1257
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
|
1111
1258
|
const char *abc = url ? url_abc : std_abc;
|
|
1112
|
-
size_t
|
|
1113
|
-
|
|
1114
|
-
if (
|
|
1115
|
-
size_t
|
|
1116
|
-
|
|
1259
|
+
size_t groups = n / 3, tail = n % 3;
|
|
1260
|
+
size_t suffix = tail ? (url ? tail + 1 : 4) : 0;
|
|
1261
|
+
if (groups > (SIZE_MAX - suffix) / 4) scr_bytes_oom();
|
|
1262
|
+
size_t outlen = groups * 4 + suffix;
|
|
1263
|
+
ScrStr *s = scr_str_alloc_raw(outlen, outlen);
|
|
1264
|
+
char *out = s->data;
|
|
1265
|
+
size_t i = 0, o = 0;
|
|
1266
|
+
for (; i < groups * 3; i += 3) {
|
|
1267
|
+
unsigned v = ((unsigned)in[i] << 16) | ((unsigned)in[i + 1] << 8) | in[i + 2];
|
|
1268
|
+
out[o++] = abc[v >> 18];
|
|
1269
|
+
out[o++] = abc[(v >> 12) & 63];
|
|
1270
|
+
out[o++] = abc[(v >> 6) & 63];
|
|
1271
|
+
out[o++] = abc[v & 63];
|
|
1272
|
+
}
|
|
1273
|
+
if (tail) {
|
|
1117
1274
|
unsigned v = (unsigned)in[i] << 16;
|
|
1118
|
-
if (
|
|
1119
|
-
|
|
1120
|
-
out[o++] = abc[(v >> 18) & 63];
|
|
1275
|
+
if (tail == 2) v |= (unsigned)in[i + 1] << 8;
|
|
1276
|
+
out[o++] = abc[v >> 18];
|
|
1121
1277
|
out[o++] = abc[(v >> 12) & 63];
|
|
1122
|
-
if (
|
|
1123
|
-
else if (!url) out[o++] = '=';
|
|
1124
|
-
if (i + 2 < n) out[o++] = abc[v & 63];
|
|
1278
|
+
if (tail == 2) out[o++] = abc[(v >> 6) & 63];
|
|
1125
1279
|
else if (!url) out[o++] = '=';
|
|
1280
|
+
if (!url) out[o++] = '=';
|
|
1126
1281
|
}
|
|
1127
|
-
|
|
1128
|
-
free(out);
|
|
1282
|
+
out[outlen] = '\0';
|
|
1129
1283
|
return s;
|
|
1130
1284
|
}
|
|
1131
1285
|
|
|
@@ -1689,6 +1843,7 @@ static ScrStr *scr_td_iso_2022_jp_decode(const ScrBytes *b, bool fatal) {
|
|
|
1689
1843
|
}
|
|
1690
1844
|
|
|
1691
1845
|
ScrStr *scr_text_decode_legacy_options(const ScrBytes *b, double encoding_value, bool fatal, bool ignore_bom) {
|
|
1846
|
+
SCR_SHARED_GUARD(b, NULL);
|
|
1692
1847
|
unsigned encoding = (unsigned)encoding_value;
|
|
1693
1848
|
if (encoding == 36) encoding = 7; /* ISO-8859-8-I */
|
|
1694
1849
|
if (encoding == 37) encoding = SCR_TD_GB18030; /* GBK */
|
|
@@ -1729,6 +1884,7 @@ static size_t scr_td_utf8_tail(const uint8_t *bytes, size_t n) {
|
|
|
1729
1884
|
|
|
1730
1885
|
ScrStr *scr_text_decode_stream(ScrDyn *state, const ScrBytes *input,
|
|
1731
1886
|
double encoding, bool fatal, bool ignore_bom, bool stream) {
|
|
1887
|
+
SCR_SHARED_GUARD(input, NULL);
|
|
1732
1888
|
if (encoding == 36) encoding = 7; /* ISO-8859-8-I is a single-byte decoder. */
|
|
1733
1889
|
ScrDyn *saved = scr_dyn_obj_read(state, "pending", 7);
|
|
1734
1890
|
size_t pending = saved->kind == SCR_DYN_BYTES ? saved->v.bytes->len : 0;
|
|
@@ -1816,8 +1972,14 @@ ScrDyn *scr_text_encode_into(const ScrDyn *source, const ScrDyn *destination) {
|
|
|
1816
1972
|
}
|
|
1817
1973
|
const ScrStr *text = source->v.str;
|
|
1818
1974
|
ScrBytes *dest = destination->v.bytes;
|
|
1975
|
+
SCR_SHARED_GUARD(dest, NULL);
|
|
1819
1976
|
size_t read = 0, written = 0;
|
|
1820
|
-
|
|
1977
|
+
size_t limit = text->len < dest->len ? text->len : dest->len;
|
|
1978
|
+
while (written < limit) {
|
|
1979
|
+
size_t ascii = scr_bytes_ascii_prefix((const uint8_t *)text->data + written, limit - written);
|
|
1980
|
+
written += ascii;
|
|
1981
|
+
read += ascii;
|
|
1982
|
+
if (written == limit) break;
|
|
1821
1983
|
size_t end = written;
|
|
1822
1984
|
uint32_t cp = scr_bytes_next_cp((const uint8_t *)text->data, &end);
|
|
1823
1985
|
if (end > dest->len) break;
|
|
@@ -1832,7 +1994,7 @@ ScrDyn *scr_text_encode_into(const ScrDyn *source, const ScrDyn *destination) {
|
|
|
1832
1994
|
}
|
|
1833
1995
|
|
|
1834
1996
|
static ScrBytes *scr_buffer_validation_input(const ScrDyn *input) {
|
|
1835
|
-
if ((input->kind == SCR_DYN_BYTES && !input->v.bytes->is_data_view) ||
|
|
1997
|
+
if ((input->kind == SCR_DYN_BYTES && !input->v.bytes->is_data_view) || scr_buffer_storage_is(input)) {
|
|
1836
1998
|
return scr_bytes_buffer_source(input);
|
|
1837
1999
|
}
|
|
1838
2000
|
scr_dyn_arg_type_fail("input", "an instance of ArrayBuffer, Buffer, or TypedArray", input);
|
|
@@ -1840,33 +2002,15 @@ static ScrBytes *scr_buffer_validation_input(const ScrDyn *input) {
|
|
|
1840
2002
|
}
|
|
1841
2003
|
|
|
1842
2004
|
static bool scr_buffer_utf8_valid(const uint8_t *data, size_t len) {
|
|
1843
|
-
size_t
|
|
1844
|
-
|
|
1845
|
-
unsigned byte = data[i++], count;
|
|
1846
|
-
unsigned low = 0x80, high = 0xbf;
|
|
1847
|
-
if (byte < 0x80) continue;
|
|
1848
|
-
if (byte >= 0xc2 && byte <= 0xdf) count = 1;
|
|
1849
|
-
else if (byte >= 0xe0 && byte <= 0xef) {
|
|
1850
|
-
count = 2;
|
|
1851
|
-
if (byte == 0xe0) low = 0xa0;
|
|
1852
|
-
if (byte == 0xed) high = 0x9f;
|
|
1853
|
-
} else if (byte >= 0xf0 && byte <= 0xf4) {
|
|
1854
|
-
count = 3;
|
|
1855
|
-
if (byte == 0xf0) low = 0x90;
|
|
1856
|
-
if (byte == 0xf4) high = 0x8f;
|
|
1857
|
-
} else return false;
|
|
1858
|
-
if (count > len - i || data[i] < low || data[i] > high) return false;
|
|
1859
|
-
i++;
|
|
1860
|
-
for (unsigned j = 1; j < count; j++, i++) if (data[i] < 0x80 || data[i] > 0xbf) return false;
|
|
1861
|
-
}
|
|
1862
|
-
return true;
|
|
2005
|
+
size_t next;
|
|
2006
|
+
return scr_bytes_utf8_prefix(data, len, &next) == len;
|
|
1863
2007
|
}
|
|
1864
2008
|
|
|
1865
2009
|
bool scr_buffer_is_ascii(const ScrDyn *input) {
|
|
1866
2010
|
ScrBytes *bytes = scr_buffer_validation_input(input);
|
|
1867
2011
|
if (!bytes) return false;
|
|
1868
|
-
|
|
1869
|
-
|
|
2012
|
+
SCR_SHARED_GUARD(bytes, NULL);
|
|
2013
|
+
bool result = scr_bytes_ascii_prefix(bytes->data, bytes->len) == bytes->len;
|
|
1870
2014
|
scr_bytes_release(bytes);
|
|
1871
2015
|
return result;
|
|
1872
2016
|
}
|
|
@@ -1874,6 +2018,7 @@ bool scr_buffer_is_ascii(const ScrDyn *input) {
|
|
|
1874
2018
|
bool scr_buffer_is_utf8(const ScrDyn *input) {
|
|
1875
2019
|
ScrBytes *bytes = scr_buffer_validation_input(input);
|
|
1876
2020
|
if (!bytes) return false;
|
|
2021
|
+
SCR_SHARED_GUARD(bytes, NULL);
|
|
1877
2022
|
bool result = scr_buffer_utf8_valid(bytes->data, bytes->len);
|
|
1878
2023
|
scr_bytes_release(bytes);
|
|
1879
2024
|
return result;
|
|
@@ -1964,6 +2109,7 @@ ScrBytes *scr_buffer_transcode(const ScrDyn *source, const ScrDyn *from, const S
|
|
|
1964
2109
|
return NULL;
|
|
1965
2110
|
}
|
|
1966
2111
|
const ScrBytes *input = source->v.bytes;
|
|
2112
|
+
SCR_BYTES_SNAPSHOT(input);
|
|
1967
2113
|
size_t len = input->len;
|
|
1968
2114
|
if (!len) { ScrBytes *empty = scr_bytes_alloc(SCR_BYTES_U8, 0); empty->is_buffer = true; return empty; }
|
|
1969
2115
|
int from_encoding = scr_transcode_encoding(from), to_encoding = scr_transcode_encoding(to);
|
|
@@ -2021,63 +2167,66 @@ static bool scr_enc_is(const ScrStr *enc, const char *name) {
|
|
|
2021
2167
|
* surrogate becomes U+FFFD — Node keeps it as a lone UTF-16 unit, which
|
|
2022
2168
|
* UTF-8 string storage cannot hold (SEMANTICS.md divergence; stdout
|
|
2023
2169
|
* agrees byte-for-byte because Node's own write replaces it there too). */
|
|
2170
|
+
/* Consume one scalar, replacing an unpaired surrogate at the storage boundary. */
|
|
2171
|
+
static uint32_t scr_bytes_utf16le_cp(const uint8_t *in, size_t units, size_t *u) {
|
|
2172
|
+
uint32_t cu = (uint32_t)in[*u * 2] | ((uint32_t)in[*u * 2 + 1] << 8);
|
|
2173
|
+
(*u)++;
|
|
2174
|
+
if (cu >= 0xd800 && cu <= 0xdbff && *u < units) {
|
|
2175
|
+
uint32_t lo = (uint32_t)in[*u * 2] | ((uint32_t)in[*u * 2 + 1] << 8);
|
|
2176
|
+
if (lo >= 0xdc00 && lo <= 0xdfff) {
|
|
2177
|
+
(*u)++;
|
|
2178
|
+
return 0x10000 + ((cu - 0xd800) << 10) + (lo - 0xdc00);
|
|
2179
|
+
}
|
|
2180
|
+
}
|
|
2181
|
+
return cu >= 0xd800 && cu <= 0xdfff ? 0xfffd : cu;
|
|
2182
|
+
}
|
|
2183
|
+
|
|
2024
2184
|
static ScrStr *scr_bytes_decode_utf16le(const uint8_t *in, size_t n) {
|
|
2025
2185
|
size_t units = n / 2;
|
|
2026
|
-
|
|
2027
|
-
|
|
2186
|
+
if (units > SIZE_MAX / 3) scr_bytes_oom();
|
|
2187
|
+
ScrStr *s = scr_str_alloc_raw(0, units * 3);
|
|
2028
2188
|
size_t o = 0;
|
|
2029
|
-
for (size_t u = 0; u < units; u
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
uint32_t lo = (uint32_t)in[(u + 1) * 2] | ((uint32_t)in[(u + 1) * 2 + 1] << 8);
|
|
2033
|
-
if (lo >= 0xdc00 && lo <= 0xdfff) {
|
|
2034
|
-
o = scr_bytes_put_cp(out, o, 0x10000 + ((cu - 0xd800) << 10) + (lo - 0xdc00));
|
|
2035
|
-
u++;
|
|
2036
|
-
continue;
|
|
2037
|
-
}
|
|
2038
|
-
}
|
|
2039
|
-
o = scr_bytes_put_cp(out, o, cu >= 0xd800 && cu <= 0xdfff ? 0xfffd : cu);
|
|
2040
|
-
}
|
|
2041
|
-
ScrStr *s = scr_str_new(out, o);
|
|
2042
|
-
free(out);
|
|
2189
|
+
for (size_t u = 0; u < units;) o = scr_bytes_put_cp(s->data, o, scr_bytes_utf16le_cp(in, units, &u));
|
|
2190
|
+
s->len = o;
|
|
2191
|
+
s->data[o] = '\0';
|
|
2043
2192
|
return s;
|
|
2044
2193
|
}
|
|
2045
2194
|
|
|
2046
2195
|
ScrStr *scr_bytes_to_str(const ScrBytes *b, const ScrStr *enc) {
|
|
2196
|
+
SCR_SHARED_GUARD(b, NULL);
|
|
2047
2197
|
const uint8_t *in = b->data;
|
|
2048
2198
|
size_t n = b->len; /* u8: len == byte length */
|
|
2049
2199
|
/* Implicit native string/number coercions have no encoding argument. */
|
|
2050
2200
|
if (!enc) return scr_bytes_decode_utf8(in, n);
|
|
2051
2201
|
if (scr_enc_is(enc, "hex")) {
|
|
2052
|
-
|
|
2053
|
-
|
|
2202
|
+
if (n > SIZE_MAX / 2) scr_bytes_oom();
|
|
2203
|
+
ScrStr *s = scr_str_alloc_raw(n * 2, n * 2);
|
|
2204
|
+
char *out = s->data;
|
|
2054
2205
|
for (size_t i = 0; i < n; i++) {
|
|
2055
2206
|
out[i * 2] = scr_hex_digits[in[i] >> 4];
|
|
2056
2207
|
out[i * 2 + 1] = scr_hex_digits[in[i] & 0xf];
|
|
2057
2208
|
}
|
|
2058
|
-
|
|
2059
|
-
free(out);
|
|
2209
|
+
out[n * 2] = '\0';
|
|
2060
2210
|
return s;
|
|
2061
2211
|
}
|
|
2062
2212
|
if (scr_enc_is(enc, "base64")) return scr_bytes_encode_b64(in, n, false);
|
|
2063
2213
|
if (scr_enc_is(enc, "base64url")) return scr_bytes_encode_b64(in, n, true);
|
|
2064
2214
|
if (scr_enc_is(enc, "latin1")) {
|
|
2065
2215
|
/* Each byte is U+00XX ("binary" normalizes here upstream). */
|
|
2066
|
-
|
|
2067
|
-
|
|
2216
|
+
size_t high = 0;
|
|
2217
|
+
for (size_t i = 0; i < n; i++) high += in[i] >> 7;
|
|
2218
|
+
if (n > SIZE_MAX - high) scr_bytes_oom();
|
|
2219
|
+
ScrStr *s = scr_str_alloc_raw(n + high, n + high);
|
|
2068
2220
|
size_t o = 0;
|
|
2069
|
-
for (size_t i = 0; i < n; i++) o = scr_bytes_put_cp(
|
|
2070
|
-
|
|
2071
|
-
free(out);
|
|
2221
|
+
for (size_t i = 0; i < n; i++) o = scr_bytes_put_cp(s->data, o, in[i]);
|
|
2222
|
+
s->data[o] = '\0';
|
|
2072
2223
|
return s;
|
|
2073
2224
|
}
|
|
2074
2225
|
if (scr_enc_is(enc, "ascii")) {
|
|
2075
2226
|
/* Node's ascii decode masks the high bit: byte & 0x7f. */
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
ScrStr *s = scr_str_new(out, n);
|
|
2080
|
-
free(out);
|
|
2227
|
+
ScrStr *s = scr_str_alloc_raw(n, n);
|
|
2228
|
+
for (size_t i = 0; i < n; i++) s->data[i] = (char)(in[i] & 0x7f);
|
|
2229
|
+
s->data[n] = '\0';
|
|
2081
2230
|
return s;
|
|
2082
2231
|
}
|
|
2083
2232
|
if (scr_enc_is(enc, "utf16le")) return scr_bytes_decode_utf16le(in, n);
|
|
@@ -2158,13 +2307,72 @@ static int scr_hex_val(uint8_t c) {
|
|
|
2158
2307
|
return -1;
|
|
2159
2308
|
}
|
|
2160
2309
|
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2310
|
+
/* Both alphabets are accepted by both Buffer base64 encoding names. */
|
|
2311
|
+
static const int8_t scr_b64_values[256] = {
|
|
2312
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
2313
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
2314
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, 62, -1, 63,
|
|
2315
|
+
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
|
|
2316
|
+
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
|
|
2317
|
+
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, 63,
|
|
2318
|
+
-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
|
|
2319
|
+
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1,
|
|
2320
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
2321
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
2322
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
2323
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
2324
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
2325
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
2326
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
2327
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
2328
|
+
};
|
|
2329
|
+
|
|
2330
|
+
/* Conversion destinations are private until their initialized length is set.
|
|
2331
|
+
* General typed-array allocation must remain zero-filled. */
|
|
2332
|
+
static ScrBytes *scr_bytes_conversion_storage(size_t capacity) {
|
|
2333
|
+
uint8_t *data = malloc(capacity ? capacity : 1);
|
|
2334
|
+
if (!data) scr_bytes_oom();
|
|
2335
|
+
return scr_bytes_take_data(data, 0);
|
|
2336
|
+
}
|
|
2337
|
+
|
|
2338
|
+
static ScrBytes *scr_bytes_decode_b64(const uint8_t *in, size_t n) {
|
|
2339
|
+
ScrBytes *b = scr_bytes_conversion_storage(n / 4 * 3 + 2);
|
|
2340
|
+
size_t i = 0, o = 0;
|
|
2341
|
+
unsigned acc = 0, have = 0;
|
|
2342
|
+
while (i < n) {
|
|
2343
|
+
/* Common complete groups need neither per-character branches nor state. */
|
|
2344
|
+
if (have == 0 && n - i >= 4) {
|
|
2345
|
+
int a = scr_b64_values[in[i]], c = scr_b64_values[in[i + 1]];
|
|
2346
|
+
int d = scr_b64_values[in[i + 2]], e = scr_b64_values[in[i + 3]];
|
|
2347
|
+
if ((a | c | d | e) >= 0) {
|
|
2348
|
+
unsigned v = ((unsigned)a << 18) | ((unsigned)c << 12) | ((unsigned)d << 6) | (unsigned)e;
|
|
2349
|
+
b->data[o++] = (uint8_t)(v >> 16);
|
|
2350
|
+
b->data[o++] = (uint8_t)(v >> 8);
|
|
2351
|
+
b->data[o++] = (uint8_t)v;
|
|
2352
|
+
i += 4;
|
|
2353
|
+
continue;
|
|
2354
|
+
}
|
|
2355
|
+
}
|
|
2356
|
+
uint8_t byte = in[i++];
|
|
2357
|
+
if (byte == '=') break;
|
|
2358
|
+
int v = scr_b64_values[byte];
|
|
2359
|
+
if (v < 0) continue;
|
|
2360
|
+
acc = (acc << 6) | (unsigned)v;
|
|
2361
|
+
if (++have == 4) {
|
|
2362
|
+
b->data[o++] = (uint8_t)(acc >> 16);
|
|
2363
|
+
b->data[o++] = (uint8_t)(acc >> 8);
|
|
2364
|
+
b->data[o++] = (uint8_t)acc;
|
|
2365
|
+
acc = 0;
|
|
2366
|
+
have = 0;
|
|
2367
|
+
}
|
|
2368
|
+
}
|
|
2369
|
+
if (have == 2) b->data[o++] = (uint8_t)(acc >> 4);
|
|
2370
|
+
else if (have == 3) {
|
|
2371
|
+
b->data[o++] = (uint8_t)(acc >> 10);
|
|
2372
|
+
b->data[o++] = (uint8_t)(acc >> 2);
|
|
2373
|
+
}
|
|
2374
|
+
b->len = o;
|
|
2375
|
+
return b;
|
|
2168
2376
|
}
|
|
2169
2377
|
|
|
2170
2378
|
ScrBytes *scr_bytes_from_str(const ScrStr *s, const ScrStr *enc) {
|
|
@@ -2173,7 +2381,7 @@ ScrBytes *scr_bytes_from_str(const ScrStr *s, const ScrStr *enc) {
|
|
|
2173
2381
|
if (scr_enc_is(enc, "latin1") || scr_enc_is(enc, "ascii")) {
|
|
2174
2382
|
/* Node writes charCodeAt(i) & 0xFF for BOTH spellings — an astral
|
|
2175
2383
|
* code point contributes its two surrogates' low bytes. */
|
|
2176
|
-
ScrBytes *b =
|
|
2384
|
+
ScrBytes *b = scr_bytes_conversion_storage(n);
|
|
2177
2385
|
size_t o = 0, i = 0;
|
|
2178
2386
|
while (i < n) {
|
|
2179
2387
|
uint32_t cp = scr_bytes_next_cp(in, &i);
|
|
@@ -2189,7 +2397,8 @@ ScrBytes *scr_bytes_from_str(const ScrStr *s, const ScrStr *enc) {
|
|
|
2189
2397
|
return b;
|
|
2190
2398
|
}
|
|
2191
2399
|
if (scr_enc_is(enc, "utf16le")) {
|
|
2192
|
-
|
|
2400
|
+
if (n > SIZE_MAX / 2) scr_bytes_oom();
|
|
2401
|
+
ScrBytes *b = scr_bytes_conversion_storage(n * 2);
|
|
2193
2402
|
size_t o = 0, i = 0;
|
|
2194
2403
|
while (i < n) {
|
|
2195
2404
|
uint32_t cp = scr_bytes_next_cp(in, &i);
|
|
@@ -2208,61 +2417,70 @@ ScrBytes *scr_bytes_from_str(const ScrStr *s, const ScrStr *enc) {
|
|
|
2208
2417
|
b->len = o;
|
|
2209
2418
|
return b;
|
|
2210
2419
|
}
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
unsigned acc = 0;
|
|
2233
|
-
int have = 0;
|
|
2234
|
-
for (size_t i = 0; i < n; i++) {
|
|
2235
|
-
int v = scr_b64_val(in[i]);
|
|
2236
|
-
if (v < 0) continue;
|
|
2237
|
-
acc = (acc << 6) | (unsigned)v;
|
|
2238
|
-
if (++have == 4) {
|
|
2239
|
-
b->data[o++] = (uint8_t)(acc >> 16);
|
|
2240
|
-
b->data[o++] = (uint8_t)(acc >> 8);
|
|
2241
|
-
b->data[o++] = (uint8_t)acc;
|
|
2242
|
-
acc = 0;
|
|
2243
|
-
have = 0;
|
|
2420
|
+
bool hex = scr_enc_is(enc, "hex");
|
|
2421
|
+
if (hex || scr_enc_is(enc, "base64") || scr_enc_is(enc, "base64url")) {
|
|
2422
|
+
/* Node interprets encoded text as the low byte of each UTF-16 unit.
|
|
2423
|
+
* ASCII can borrow storage; non-ASCII must preserve that truncation. */
|
|
2424
|
+
ScrBytes *narrowed = NULL;
|
|
2425
|
+
if (scr_bytes_ascii_prefix(in, n) != n) {
|
|
2426
|
+
ScrStr *latin1 = scr_str_new("latin1", 6);
|
|
2427
|
+
narrowed = scr_bytes_from_str(s, latin1);
|
|
2428
|
+
scr_str_release(latin1);
|
|
2429
|
+
in = narrowed->data;
|
|
2430
|
+
n = narrowed->len;
|
|
2431
|
+
}
|
|
2432
|
+
ScrBytes *b;
|
|
2433
|
+
if (hex) {
|
|
2434
|
+
/* Stop at the first invalid pair, discarding an odd tail. */
|
|
2435
|
+
b = scr_bytes_conversion_storage(n / 2);
|
|
2436
|
+
size_t o = 0;
|
|
2437
|
+
for (size_t i = 0; i + 1 < n; i += 2) {
|
|
2438
|
+
int hi = scr_hex_val(in[i]), lo = scr_hex_val(in[i + 1]);
|
|
2439
|
+
if (hi < 0 || lo < 0) break;
|
|
2440
|
+
b->data[o++] = (uint8_t)((hi << 4) | lo);
|
|
2244
2441
|
}
|
|
2442
|
+
b->len = o;
|
|
2443
|
+
} else {
|
|
2444
|
+
b = scr_bytes_decode_b64(in, n);
|
|
2245
2445
|
}
|
|
2246
|
-
|
|
2247
|
-
else if (have == 3) {
|
|
2248
|
-
b->data[o++] = (uint8_t)(acc >> 10);
|
|
2249
|
-
b->data[o++] = (uint8_t)(acc >> 2);
|
|
2250
|
-
}
|
|
2251
|
-
b->len = o;
|
|
2446
|
+
scr_bytes_release(narrowed);
|
|
2252
2447
|
return b;
|
|
2253
2448
|
}
|
|
2254
2449
|
/* utf8: ScrStr storage IS the bytes */
|
|
2255
|
-
ScrBytes *b =
|
|
2450
|
+
ScrBytes *b = scr_bytes_conversion_storage(n);
|
|
2256
2451
|
memcpy(b->data, in, n);
|
|
2452
|
+
b->len = n;
|
|
2257
2453
|
return b;
|
|
2258
2454
|
}
|
|
2259
2455
|
|
|
2456
|
+
/* Runtime encoding variables share the output conversion alias/error table.
|
|
2457
|
+
* Buffer.from treats an empty encoding as utf8, even for an empty source. */
|
|
2458
|
+
ScrBytes *scr_bytes_from_str_checked(const ScrStr *s, const ScrStr *enc) {
|
|
2459
|
+
ScrStr *normalized = enc->len ? scr_bytes_normalize_encoding(enc) : scr_str_new("utf8", 4);
|
|
2460
|
+
if (!normalized) return NULL;
|
|
2461
|
+
ScrBytes *out = scr_bytes_from_str(s, normalized);
|
|
2462
|
+
scr_str_release(normalized);
|
|
2463
|
+
return out;
|
|
2464
|
+
}
|
|
2465
|
+
|
|
2260
2466
|
ScrBytes *scr_bytes_from_arr(ScrBytesElem elem, const ScrArr *arr) {
|
|
2261
|
-
ScrBytes *b =
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2467
|
+
ScrBytes *b = scr_bytes_alloc_private(elem, arr->len);
|
|
2468
|
+
size_t width = scr_bytes_elem_size(elem);
|
|
2469
|
+
double values[128];
|
|
2470
|
+
for (size_t start = 0; start < arr->len;) {
|
|
2471
|
+
size_t count = arr->len - start < 128 ? arr->len - start : 128;
|
|
2472
|
+
for (size_t i = 0; i < count; i++) {
|
|
2473
|
+
size_t index = start + i;
|
|
2474
|
+
/* Sparse tails and explicit undefined retain ordinary iteration
|
|
2475
|
+
* semantics. Numeric array slots own no conversion callbacks. */
|
|
2476
|
+
if (index < arr->cap) {
|
|
2477
|
+
if (arr->present[index] == SCR_ARR_VALUE)
|
|
2478
|
+
memcpy(&values[i], &arr->data[index], sizeof(double));
|
|
2479
|
+
else values[i] = NAN;
|
|
2480
|
+
} else values[i] = scr_arr_get_number(arr, (double)index);
|
|
2481
|
+
}
|
|
2482
|
+
scr_bytes_write_numbers(b->data + start * width, elem, values, count);
|
|
2483
|
+
start += count;
|
|
2266
2484
|
}
|
|
2267
2485
|
return b;
|
|
2268
2486
|
}
|
|
@@ -2305,6 +2523,7 @@ bool scr_bytes_validate_off(const char *name, double value, double max) {
|
|
|
2305
2523
|
}
|
|
2306
2524
|
|
|
2307
2525
|
bool scr_bytes_equals(const ScrBytes *a, const ScrBytes *b) {
|
|
2526
|
+
SCR_SHARED_GUARD(a, b);
|
|
2308
2527
|
return a->len == b->len && memcmp(a->data, b->data, a->len) == 0;
|
|
2309
2528
|
}
|
|
2310
2529
|
|
|
@@ -2314,6 +2533,7 @@ bool scr_bytes_equals(const ScrBytes *a, const ScrBytes *b) {
|
|
|
2314
2533
|
* Node's exactly. */
|
|
2315
2534
|
double scr_bytes_compare(const ScrBytes *src, const ScrBytes *target, double nargs,
|
|
2316
2535
|
double ts, double te, double ss, double se) {
|
|
2536
|
+
SCR_SHARED_GUARD(src, target);
|
|
2317
2537
|
size_t n = (size_t)nargs;
|
|
2318
2538
|
if (n < 1) ts = 0;
|
|
2319
2539
|
else if (!scr_bytes_validate_off("targetStart", ts, 9007199254740991.0)) return 0;
|
|
@@ -2342,6 +2562,7 @@ double scr_bytes_compare(const ScrBytes *src, const ScrBytes *target, double nar
|
|
|
2342
2562
|
* count from the end, and a still-negative backward search answers -1),
|
|
2343
2563
|
* and the utf16le alignment stride. */
|
|
2344
2564
|
double scr_bytes_index_of(const ScrBytes *b, const ScrBytes *needle, double off, double align, bool fwd) {
|
|
2565
|
+
SCR_SHARED_GUARD(b, needle);
|
|
2345
2566
|
size_t len = b->len, nlen = needle->len;
|
|
2346
2567
|
size_t step = align == 2 ? 2 : 1;
|
|
2347
2568
|
double o = (off != off) ? (fwd ? 0 : (double)len) : trunc(off);
|
|
@@ -2372,6 +2593,7 @@ double scr_bytes_index_of(const ScrBytes *b, const ScrBytes *needle, double off,
|
|
|
2372
2593
|
}
|
|
2373
2594
|
|
|
2374
2595
|
double scr_bytes_index_of_num(const ScrBytes *b, double v, double off, bool fwd) {
|
|
2596
|
+
SCR_SHARED_GUARD(b, NULL);
|
|
2375
2597
|
uint8_t byte = (uint8_t)scr_bytes_to_u32(v);
|
|
2376
2598
|
ScrBytes needle = { .rc = 1, .len = 1, .elem = SCR_BYTES_U8, .data = &byte, .backing = NULL };
|
|
2377
2599
|
return scr_bytes_index_of(b, &needle, off, 1, fwd);
|
|
@@ -2408,16 +2630,19 @@ static ScrBytes *scr_bytes_fill_core(ScrBytes *b, const uint8_t *pat, size_t pat
|
|
|
2408
2630
|
}
|
|
2409
2631
|
|
|
2410
2632
|
ScrBytes *scr_bytes_fill(ScrBytes *b, const ScrBytes *pattern, double nargs, double offset, double end) {
|
|
2633
|
+
SCR_SHARED_GUARD(b, pattern);
|
|
2411
2634
|
return scr_bytes_fill_core(b, pattern->data, pattern->len, false, nargs, offset, end);
|
|
2412
2635
|
}
|
|
2413
2636
|
|
|
2414
2637
|
ScrBytes *scr_bytes_fill_num(ScrBytes *b, double v, double nargs, double offset, double end) {
|
|
2638
|
+
SCR_SHARED_GUARD(b, NULL);
|
|
2415
2639
|
uint8_t byte = (uint8_t)scr_bytes_to_u32(v);
|
|
2416
2640
|
return scr_bytes_fill_core(b, &byte, 1, false, nargs, offset, end);
|
|
2417
2641
|
}
|
|
2418
2642
|
|
|
2419
2643
|
ScrBytes *scr_bytes_fill_str(ScrBytes *b, const ScrStr *s, const ScrStr *enc,
|
|
2420
2644
|
double nargs, double offset, double end) {
|
|
2645
|
+
SCR_SHARED_GUARD(b, NULL);
|
|
2421
2646
|
ScrBytes *pat = scr_bytes_from_str(s, enc);
|
|
2422
2647
|
ScrBytes *r = scr_bytes_fill_core(b, pat->data, pat->len, true, nargs, offset, end);
|
|
2423
2648
|
scr_bytes_release(pat);
|
|
@@ -2430,6 +2655,7 @@ ScrBytes *scr_bytes_fill_str(ScrBytes *b, const ScrStr *s, const ScrStr *enc,
|
|
|
2430
2655
|
* bounded by the source length. Returns the byte count copied. */
|
|
2431
2656
|
double scr_bytes_copy_into(const ScrBytes *src, ScrBytes *dst, double nargs,
|
|
2432
2657
|
double ts, double ss, double se) {
|
|
2658
|
+
SCR_SHARED_GUARD(src, dst);
|
|
2433
2659
|
size_t n = (size_t)nargs;
|
|
2434
2660
|
ts = n < 1 ? 0 : trunc(ts);
|
|
2435
2661
|
ss = n < 2 ? 0 : trunc(ss);
|
|
@@ -2452,6 +2678,7 @@ double scr_bytes_copy_into(const ScrBytes *src, ScrBytes *dst, double nargs,
|
|
|
2452
2678
|
* (+1, chaining like fill). A length off the width is Node's constant
|
|
2453
2679
|
* ERR_INVALID_BUFFER_SIZE RangeError. */
|
|
2454
2680
|
ScrBytes *scr_bytes_swap(ScrBytes *b, double width) {
|
|
2681
|
+
SCR_SHARED_GUARD(b, NULL);
|
|
2455
2682
|
size_t w = (size_t)width;
|
|
2456
2683
|
if (b->len % w != 0) {
|
|
2457
2684
|
char msg[64];
|
|
@@ -2477,6 +2704,7 @@ ScrBytes *scr_bytes_swap(ScrBytes *b, double width) {
|
|
|
2477
2704
|
* lone lead), byte-level for the rest. Returns the bytes written. */
|
|
2478
2705
|
double scr_bytes_write_str(ScrBytes *b, const ScrStr *s, const ScrStr *enc,
|
|
2479
2706
|
double offset, double len, bool has_len) {
|
|
2707
|
+
SCR_SHARED_GUARD(b, NULL);
|
|
2480
2708
|
if (!scr_bytes_validate_off("offset", offset, (double)b->len)) return 0;
|
|
2481
2709
|
size_t o = (size_t)offset;
|
|
2482
2710
|
size_t remaining = b->len - o;
|
|
@@ -2487,6 +2715,36 @@ double scr_bytes_write_str(ScrBytes *b, const ScrStr *s, const ScrStr *enc,
|
|
|
2487
2715
|
} else {
|
|
2488
2716
|
budget = remaining;
|
|
2489
2717
|
}
|
|
2718
|
+
/* UTF-8 already has its final representation. Copy only the requested
|
|
2719
|
+
* prefix, backing off when the destination ends inside a scalar. */
|
|
2720
|
+
if (scr_enc_is(enc, "utf8")) {
|
|
2721
|
+
size_t k = s->len < budget ? s->len : budget;
|
|
2722
|
+
if (k < s->len) {
|
|
2723
|
+
while (k > 0 && ((uint8_t)s->data[k] & 0xc0) == 0x80) k--;
|
|
2724
|
+
}
|
|
2725
|
+
if (k) memcpy(b->data + o, s->data, k);
|
|
2726
|
+
return (double)k;
|
|
2727
|
+
}
|
|
2728
|
+
bool utf16 = scr_enc_is(enc, "utf16le");
|
|
2729
|
+
if (utf16 || scr_enc_is(enc, "latin1") || scr_enc_is(enc, "ascii")) {
|
|
2730
|
+
size_t i = 0, written = 0, width = utf16 ? 2 : 1;
|
|
2731
|
+
while (i < s->len && budget - written >= width) {
|
|
2732
|
+
uint32_t cp = scr_bytes_next_cp((const uint8_t *)s->data, &i);
|
|
2733
|
+
uint32_t first = cp, second = 0;
|
|
2734
|
+
if (cp > 0xffff) {
|
|
2735
|
+
cp -= 0x10000;
|
|
2736
|
+
first = 0xd800 + (cp >> 10);
|
|
2737
|
+
second = 0xdc00 + (cp & 0x3ff);
|
|
2738
|
+
}
|
|
2739
|
+
b->data[o + written++] = (uint8_t)first;
|
|
2740
|
+
if (utf16) b->data[o + written++] = (uint8_t)(first >> 8);
|
|
2741
|
+
if (second && budget - written >= width) {
|
|
2742
|
+
b->data[o + written++] = (uint8_t)second;
|
|
2743
|
+
if (utf16) b->data[o + written++] = (uint8_t)(second >> 8);
|
|
2744
|
+
}
|
|
2745
|
+
}
|
|
2746
|
+
return (double)written;
|
|
2747
|
+
}
|
|
2490
2748
|
ScrBytes *encd = scr_bytes_from_str(s, enc);
|
|
2491
2749
|
size_t k = encd->len < budget ? encd->len : budget;
|
|
2492
2750
|
if (k < encd->len) {
|
|
@@ -2550,7 +2808,7 @@ ScrBytes *scr_bytes_concat_len(const ScrArr *list, double total) {
|
|
|
2550
2808
|
return NULL;
|
|
2551
2809
|
}
|
|
2552
2810
|
size_t take = part->len < b->len - o ? part->len : b->len - o;
|
|
2553
|
-
|
|
2811
|
+
scr_bytes_read(part, 0, b->data + o, take);
|
|
2554
2812
|
o += take;
|
|
2555
2813
|
scr_bytes_release(part);
|
|
2556
2814
|
}
|
|
@@ -2616,7 +2874,7 @@ ScrBytes *scr_bytes_concat(const ScrArr *list) {
|
|
|
2616
2874
|
scr_bytes_release(b);
|
|
2617
2875
|
return NULL;
|
|
2618
2876
|
}
|
|
2619
|
-
|
|
2877
|
+
scr_bytes_read(part, 0, b->data + o, part->len);
|
|
2620
2878
|
o += part->len;
|
|
2621
2879
|
scr_bytes_release(part);
|
|
2622
2880
|
}
|
|
@@ -2747,6 +3005,7 @@ static size_t scr_bytes_num_width(ScrBytesNumKind kind) {
|
|
|
2747
3005
|
}
|
|
2748
3006
|
|
|
2749
3007
|
double scr_bytes_read_num(const ScrBytes *b, double offset, ScrBytesNumKind kind, bool le) {
|
|
3008
|
+
SCR_SHARED_GUARD(b, NULL);
|
|
2750
3009
|
size_t width = scr_bytes_num_width(kind);
|
|
2751
3010
|
if (!scr_bytes_rw_check(b, offset, width)) return 0;
|
|
2752
3011
|
const uint8_t *p = b->data + (size_t)offset;
|
|
@@ -2781,6 +3040,7 @@ double scr_bytes_read_num(const ScrBytes *b, double offset, ScrBytesNumKind kind
|
|
|
2781
3040
|
}
|
|
2782
3041
|
|
|
2783
3042
|
double scr_bytes_write_num(ScrBytes *b, double value, double offset, ScrBytesNumKind kind, bool le) {
|
|
3043
|
+
SCR_SHARED_GUARD(b, NULL);
|
|
2784
3044
|
size_t width = scr_bytes_num_width(kind);
|
|
2785
3045
|
uint64_t u;
|
|
2786
3046
|
if (kind == SCR_BN_F32 || kind == SCR_BN_F64) {
|
|
@@ -2812,6 +3072,7 @@ double scr_bytes_write_num(ScrBytes *b, double value, double offset, ScrBytesNum
|
|
|
2812
3072
|
/* readUIntLE/BE / readIntLE/BE — the variable-width family: byteLength
|
|
2813
3073
|
* validates FIRST (1-6, its own error ladder), then the offset gate. */
|
|
2814
3074
|
double scr_bytes_read_var(const ScrBytes *b, double offset, double byte_length, bool sign, bool le) {
|
|
3075
|
+
SCR_SHARED_GUARD(b, NULL);
|
|
2815
3076
|
if (floor(byte_length) != byte_length || byte_length < 1 || byte_length > 6) {
|
|
2816
3077
|
scr_bytes_bounds_error(byte_length, 6, "byteLength");
|
|
2817
3078
|
return 0;
|
|
@@ -2832,6 +3093,7 @@ double scr_bytes_read_var(const ScrBytes *b, double offset, double byte_length,
|
|
|
2832
3093
|
/* writeUIntLE/BE / writeIntLE/BE: byteLength, then value, then offset —
|
|
2833
3094
|
* Node's exact check order. Returns offset + byteLength. */
|
|
2834
3095
|
double scr_bytes_write_var(ScrBytes *b, double value, double offset, double byte_length, bool sign, bool le) {
|
|
3096
|
+
SCR_SHARED_GUARD(b, NULL);
|
|
2835
3097
|
if (floor(byte_length) != byte_length || byte_length < 1 || byte_length > 6) {
|
|
2836
3098
|
scr_bytes_bounds_error(byte_length, 6, "byteLength");
|
|
2837
3099
|
return 0;
|
|
@@ -2849,6 +3111,7 @@ double scr_bytes_write_var(ScrBytes *b, double value, double offset, double byte
|
|
|
2849
3111
|
}
|
|
2850
3112
|
|
|
2851
3113
|
bool scr_bytes_read_u64_raw(const ScrBytes *b, double offset, bool le, uint64_t *out) {
|
|
3114
|
+
SCR_SHARED_GUARD(b, NULL);
|
|
2852
3115
|
if (!scr_bytes_rw_check(b, offset, 8)) return false;
|
|
2853
3116
|
const uint8_t *p = b->data + (size_t)offset;
|
|
2854
3117
|
uint64_t value = 0;
|
|
@@ -2858,6 +3121,7 @@ bool scr_bytes_read_u64_raw(const ScrBytes *b, double offset, bool le, uint64_t
|
|
|
2858
3121
|
}
|
|
2859
3122
|
|
|
2860
3123
|
bool scr_bytes_write_u64_raw(ScrBytes *b, double offset, bool le, uint64_t value) {
|
|
3124
|
+
SCR_SHARED_GUARD(b, NULL);
|
|
2861
3125
|
if (!scr_bytes_rw_check(b, offset, 8)) return false;
|
|
2862
3126
|
uint8_t *p = b->data + (size_t)offset;
|
|
2863
3127
|
for (size_t i = 0; i < 8; i++) p[le ? i : 7 - i] = (uint8_t)(value >> (8 * i));
|
|
@@ -2875,6 +3139,7 @@ static bool scr_dataview_u64_check(const ScrBytes *b, double byte_off) {
|
|
|
2875
3139
|
}
|
|
2876
3140
|
|
|
2877
3141
|
bool scr_dataview_read_u64_raw(const ScrBytes *b, double offset, bool le, uint64_t *out) {
|
|
3142
|
+
SCR_SHARED_GUARD(b, NULL);
|
|
2878
3143
|
double off = (offset != offset) ? 0 : trunc(offset);
|
|
2879
3144
|
if (!scr_dataview_u64_check(b, offset)) return false;
|
|
2880
3145
|
const uint8_t *p = b->data + (size_t)off;
|
|
@@ -2885,6 +3150,7 @@ bool scr_dataview_read_u64_raw(const ScrBytes *b, double offset, bool le, uint64
|
|
|
2885
3150
|
}
|
|
2886
3151
|
|
|
2887
3152
|
bool scr_dataview_write_u64_raw(ScrBytes *b, double offset, bool le, uint64_t value) {
|
|
3153
|
+
SCR_SHARED_GUARD(b, NULL);
|
|
2888
3154
|
double off = (offset != offset) ? 0 : trunc(offset);
|
|
2889
3155
|
if (!scr_dataview_u64_check(b, offset)) return false;
|
|
2890
3156
|
uint8_t *p = b->data + (size_t)off;
|