@scriptc/cli-darwin-arm64 0.2.0 → 0.2.2
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 +84 -19
- 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_async_dyn.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_bigint.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_console.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_crypto_async.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_dyn_invoke.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_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_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_http.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_http2.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_net.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_node_builtin.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_qs.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_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_symbol.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_url.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_async_dyn.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_bigint.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_console.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_crypto_async.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_dyn_invoke.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_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_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_http.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_http2.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_net.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_node_builtin.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_qs.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_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_symbol.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_web.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/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_bigint.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_console_native.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_dyn_invoke.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_exception.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_grapheme.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_node_builtin.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_string.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_url.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_bigint.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_console_native.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_dyn_invoke.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_exception.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_grapheme.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_node_builtin.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_string.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_url.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_bigint.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_console_native.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_dyn_invoke.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_exception.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_grapheme.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_node_builtin.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_string.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_url.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_bigint.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_console_native.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_dyn_invoke.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_exception.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_grapheme.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_node_builtin.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_string.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_url.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/licenses/v8-number-radix.txt +61 -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_async_dyn.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_bigint.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_console.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_crypto_async.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_dyn_invoke.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_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_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_http.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_http2.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_net.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_node_builtin.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_qs.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_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_symbol.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_url.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_async_dyn.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_bigint.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_console.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_crypto_async.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_dyn_invoke.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_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_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_http.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_http2.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_net.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_node_builtin.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_qs.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_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_symbol.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_web.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/package.json +1 -1
- package/dist/lib/runtime-darwin-arm64/runtime-pack.json +549 -545
- package/dist/lib/runtime-sources/package.json +1 -1
- package/dist/lib/runtime-sources/src/scr_abort.c +5 -0
- package/dist/lib/runtime-sources/src/scr_array.c +16 -0
- package/dist/lib/runtime-sources/src/scr_assert.c +1 -0
- package/dist/lib/runtime-sources/src/scr_async.c +38 -5
- package/dist/lib/runtime-sources/src/scr_async_dyn.c +208 -40
- package/dist/lib/runtime-sources/src/scr_bigint.c +8 -0
- package/dist/lib/runtime-sources/src/scr_bytes.c +431 -41
- package/dist/lib/runtime-sources/src/scr_bytes_io.c +628 -12
- package/dist/lib/runtime-sources/src/scr_child.c +544 -17
- package/dist/lib/runtime-sources/src/scr_console.c +1 -1
- package/dist/lib/runtime-sources/src/scr_crypto_async.c +22 -2
- package/dist/lib/runtime-sources/src/scr_dyn_invoke.c +344 -73
- package/dist/lib/runtime-sources/src/scr_error.c +52 -5
- package/dist/lib/runtime-sources/src/scr_exception.c +21 -5
- package/dist/lib/runtime-sources/src/scr_fetch.c +311 -3
- package/dist/lib/runtime-sources/src/scr_file_handle.c +31 -0
- package/dist/lib/runtime-sources/src/scr_http.c +3 -0
- package/dist/lib/runtime-sources/src/scr_island.c +1226 -405
- package/dist/lib/runtime-sources/src/scr_island_manifest.h +11 -9
- package/dist/lib/runtime-sources/src/scr_json.c +1594 -139
- package/dist/lib/runtime-sources/src/scr_json.test.ts +1 -0
- package/dist/lib/runtime-sources/src/scr_lib.c +816 -34
- package/dist/lib/runtime-sources/src/scr_map.c +47 -0
- package/dist/lib/runtime-sources/src/scr_node_builtin.c +10 -0
- package/dist/lib/runtime-sources/src/scr_object.c +11 -0
- package/dist/lib/runtime-sources/src/scr_qs.c +10 -0
- package/dist/lib/runtime-sources/src/scr_regex.c +148 -72
- package/dist/lib/runtime-sources/src/scr_runtime.h +257 -41
- package/dist/lib/runtime-sources/src/scr_stream.c +197 -0
- package/dist/lib/runtime-sources/src/scr_string.c +16 -1
- package/dist/lib/runtime-sources/src/scr_symbol.c +5 -0
- package/dist/lib/runtime-sources/src/scr_text_decoder_labels.h +225 -0
- package/dist/lib/runtime-sources/src/scr_url.c +206 -10
- package/dist/lib/runtime-sources/src/scr_web.c +129 -26
- package/dist/lib/runtime-sources/vendor/v8-number-radix/LICENSE +61 -0
- package/package.json +1 -1
|
@@ -28,6 +28,8 @@ static void scr_ipc_release(ScrIpc *ipc);
|
|
|
28
28
|
static void scr_ipc_service(void);
|
|
29
29
|
static bool scr_ipc_pending(void);
|
|
30
30
|
static bool scr_ipc_close_ready(const ScrIpc *ipc);
|
|
31
|
+
static void scr_child_fire_spawn(ScrChild *c);
|
|
32
|
+
static void scr_child_drop_spawn_listeners(ScrChild *c);
|
|
31
33
|
|
|
32
34
|
static ScrArr *scr_fork_argv(double target, uintptr_t read_handle,
|
|
33
35
|
uintptr_t write_handle, ScrArr *args) {
|
|
@@ -1273,6 +1275,9 @@ struct ScrChild {
|
|
|
1273
1275
|
ScrChildState state;
|
|
1274
1276
|
bool settled;
|
|
1275
1277
|
bool close_done;
|
|
1278
|
+
bool spawn_done;
|
|
1279
|
+
ScrClosure **spawn_cbs;
|
|
1280
|
+
size_t n_spawn, cap_spawn;
|
|
1276
1281
|
bool has_code;
|
|
1277
1282
|
bool killed;
|
|
1278
1283
|
bool reffed;
|
|
@@ -1294,6 +1299,7 @@ struct ScrChild {
|
|
|
1294
1299
|
ScrChildStream *out_stream;
|
|
1295
1300
|
ScrChildStream *err_stream;
|
|
1296
1301
|
ScrChildWriter *in_stream;
|
|
1302
|
+
ScrDyn *out_dyn, *err_dyn, *in_dyn;
|
|
1297
1303
|
ScrIpc *ipc;
|
|
1298
1304
|
struct ScrChild *next; /* the pending registry */
|
|
1299
1305
|
};
|
|
@@ -1308,6 +1314,7 @@ static size_t scr_children_reffed_n = 0;
|
|
|
1308
1314
|
static size_t scr_children_unwatched = 0;
|
|
1309
1315
|
|
|
1310
1316
|
static void scr_child_drop_terminal_listeners(ScrChild *c) {
|
|
1317
|
+
scr_child_drop_spawn_listeners(c);
|
|
1311
1318
|
for (size_t i = 0; i < c->n_exit; i++) scr_closure_release(c->exit_cbs[i].cb);
|
|
1312
1319
|
for (size_t i = 0; i < c->n_err; i++) scr_closure_release(c->err_cbs[i].cb);
|
|
1313
1320
|
free(c->exit_cbs);
|
|
@@ -1343,6 +1350,9 @@ void scr_child_release(ScrChild *c) {
|
|
|
1343
1350
|
scr_child_drop_listeners(c); /* only reachable pre-settle via leaks */
|
|
1344
1351
|
scr_str_release(c->err_msg);
|
|
1345
1352
|
scr_str_release(c->exec_display);
|
|
1353
|
+
scr_dyn_release(c->out_dyn);
|
|
1354
|
+
scr_dyn_release(c->err_dyn);
|
|
1355
|
+
scr_dyn_release(c->in_dyn);
|
|
1346
1356
|
scr_child_stream_release(c->out_stream);
|
|
1347
1357
|
scr_child_stream_release(c->err_stream);
|
|
1348
1358
|
scr_child_writer_release(c->in_stream);
|
|
@@ -2466,7 +2476,8 @@ bool scr_children_pending(void) {
|
|
|
2466
2476
|
|
|
2467
2477
|
bool scr_children_failed_pending(void) {
|
|
2468
2478
|
for (ScrChild *c = scr_children; c; c = c->next) {
|
|
2469
|
-
if (c->state == SCR_CHILD_SPAWN_FAILED && !c->settled)
|
|
2479
|
+
if ((c->state == SCR_CHILD_SPAWN_FAILED && !c->settled) ||
|
|
2480
|
+
(c->state == SCR_CHILD_RUNNING && !c->spawn_done)) return true;
|
|
2470
2481
|
}
|
|
2471
2482
|
return false;
|
|
2472
2483
|
}
|
|
@@ -2592,6 +2603,10 @@ static void scr_child_settle(ScrChild *c) {
|
|
|
2592
2603
|
* ordering), then every running child answers WaitForSingleObject(h, 0)
|
|
2593
2604
|
* — the WNOHANG analogue; spawn failures settle on their first pass. */
|
|
2594
2605
|
void scr_children_poll(void) {
|
|
2606
|
+
for (ScrChild *c = scr_children; c; c = c->next) {
|
|
2607
|
+
if (c->state == SCR_CHILD_RUNNING && !c->spawn_done) scr_child_fire_spawn(c);
|
|
2608
|
+
if (scr_exc_pending()) return;
|
|
2609
|
+
}
|
|
2595
2610
|
scr_ipc_service();
|
|
2596
2611
|
if (scr_exc_pending()) return;
|
|
2597
2612
|
scr_child_writers_service();
|
|
@@ -3541,6 +3556,9 @@ struct ScrChild {
|
|
|
3541
3556
|
ScrChildState state;
|
|
3542
3557
|
bool settled; /* terminal event delivered; listeners released */
|
|
3543
3558
|
bool close_done;
|
|
3559
|
+
bool spawn_done;
|
|
3560
|
+
ScrClosure **spawn_cbs;
|
|
3561
|
+
size_t n_spawn, cap_spawn;
|
|
3544
3562
|
bool unwatched; /* no kqueue NOTE_EXIT armed: the loop must poll for it */
|
|
3545
3563
|
bool has_code;
|
|
3546
3564
|
bool killed; /* a kill() successfully sent a signal (Node's flag) */
|
|
@@ -3565,6 +3583,7 @@ struct ScrChild {
|
|
|
3565
3583
|
ScrChildStream *out_stream;
|
|
3566
3584
|
ScrChildStream *err_stream;
|
|
3567
3585
|
ScrChildWriter *in_stream;
|
|
3586
|
+
ScrDyn *out_dyn, *err_dyn, *in_dyn;
|
|
3568
3587
|
ScrIpc *ipc;
|
|
3569
3588
|
struct ScrChild *next; /* the pending registry */
|
|
3570
3589
|
};
|
|
@@ -3716,6 +3735,7 @@ bool scr_children_wait(double max_wait_ms) {
|
|
|
3716
3735
|
}
|
|
3717
3736
|
|
|
3718
3737
|
static void scr_child_drop_terminal_listeners(ScrChild *c) {
|
|
3738
|
+
scr_child_drop_spawn_listeners(c);
|
|
3719
3739
|
for (size_t i = 0; i < c->n_exit; i++) scr_closure_release(c->exit_cbs[i].cb);
|
|
3720
3740
|
for (size_t i = 0; i < c->n_err; i++) scr_closure_release(c->err_cbs[i].cb);
|
|
3721
3741
|
free(c->exit_cbs);
|
|
@@ -3751,6 +3771,9 @@ void scr_child_release(ScrChild *c) {
|
|
|
3751
3771
|
scr_child_drop_listeners(c); /* only reachable pre-settle via leaks */
|
|
3752
3772
|
scr_str_release(c->err_msg);
|
|
3753
3773
|
scr_str_release(c->exec_display);
|
|
3774
|
+
scr_dyn_release(c->out_dyn);
|
|
3775
|
+
scr_dyn_release(c->err_dyn);
|
|
3776
|
+
scr_dyn_release(c->in_dyn);
|
|
3754
3777
|
scr_child_stream_release(c->out_stream);
|
|
3755
3778
|
scr_child_stream_release(c->err_stream);
|
|
3756
3779
|
scr_child_writer_release(c->in_stream);
|
|
@@ -5080,7 +5103,8 @@ bool scr_children_pending(void) {
|
|
|
5080
5103
|
* the loop's only-unref'd-children exit gate must not skip it. */
|
|
5081
5104
|
bool scr_children_failed_pending(void) {
|
|
5082
5105
|
for (ScrChild *c = scr_children; c; c = c->next) {
|
|
5083
|
-
if (c->state == SCR_CHILD_SPAWN_FAILED && !c->settled)
|
|
5106
|
+
if ((c->state == SCR_CHILD_SPAWN_FAILED && !c->settled) ||
|
|
5107
|
+
(c->state == SCR_CHILD_RUNNING && !c->spawn_done)) return true;
|
|
5084
5108
|
}
|
|
5085
5109
|
return false;
|
|
5086
5110
|
}
|
|
@@ -5200,6 +5224,10 @@ static void scr_child_settle(ScrChild *c) {
|
|
|
5200
5224
|
* callbacks — a throw stops the pass and leaves the exception pending
|
|
5201
5225
|
* for the loop. */
|
|
5202
5226
|
void scr_children_poll(void) {
|
|
5227
|
+
for (ScrChild *c = scr_children; c; c = c->next) {
|
|
5228
|
+
if (c->state == SCR_CHILD_RUNNING && !c->spawn_done) scr_child_fire_spawn(c);
|
|
5229
|
+
if (scr_exc_pending()) return;
|
|
5230
|
+
}
|
|
5203
5231
|
scr_ipc_service();
|
|
5204
5232
|
if (scr_exc_pending()) return;
|
|
5205
5233
|
scr_child_writers_service();
|
|
@@ -5252,6 +5280,224 @@ void scr_children_poll(void) {
|
|
|
5252
5280
|
|
|
5253
5281
|
#endif /* !_WIN32 */
|
|
5254
5282
|
|
|
5283
|
+
static void scr_child_drop_spawn_listeners(ScrChild *c) {
|
|
5284
|
+
for (size_t i = 0; i < c->n_spawn; i++) scr_closure_release(c->spawn_cbs[i]);
|
|
5285
|
+
free(c->spawn_cbs);
|
|
5286
|
+
c->spawn_cbs = NULL;
|
|
5287
|
+
c->n_spawn = c->cap_spawn = 0;
|
|
5288
|
+
}
|
|
5289
|
+
|
|
5290
|
+
void scr_child_ref(ScrChild *c) {
|
|
5291
|
+
if (!c->settled && !c->reffed) {
|
|
5292
|
+
c->reffed = true;
|
|
5293
|
+
scr_children_reffed_n++;
|
|
5294
|
+
}
|
|
5295
|
+
}
|
|
5296
|
+
|
|
5297
|
+
void scr_child_on_spawn(ScrChild *c, ScrClosure *cb) {
|
|
5298
|
+
if (c->spawn_done || c->settled) { scr_closure_release(cb); return; }
|
|
5299
|
+
if (c->n_spawn == c->cap_spawn) {
|
|
5300
|
+
c->cap_spawn = c->cap_spawn ? c->cap_spawn * 2 : 2;
|
|
5301
|
+
ScrClosure **grown = realloc(c->spawn_cbs, c->cap_spawn * sizeof *grown);
|
|
5302
|
+
if (!grown) scr_trap("scriptc: out of memory\n");
|
|
5303
|
+
c->spawn_cbs = grown;
|
|
5304
|
+
}
|
|
5305
|
+
c->spawn_cbs[c->n_spawn++] = cb;
|
|
5306
|
+
}
|
|
5307
|
+
|
|
5308
|
+
/* Success is observable on the next loop pass, before any data or exit
|
|
5309
|
+
* event. Detaching the snapshot keeps listeners registered by a callback
|
|
5310
|
+
* from participating in an event that has already started. */
|
|
5311
|
+
static void scr_child_fire_spawn(ScrChild *c) {
|
|
5312
|
+
c->spawn_done = true;
|
|
5313
|
+
ScrClosure **callbacks = c->spawn_cbs;
|
|
5314
|
+
size_t count = c->n_spawn;
|
|
5315
|
+
c->spawn_cbs = NULL;
|
|
5316
|
+
c->n_spawn = c->cap_spawn = 0;
|
|
5317
|
+
for (size_t i = 0; i < count; i++) {
|
|
5318
|
+
if (!scr_exc_pending()) ((void (*)(ScrClosure *))callbacks[i]->fn)(callbacks[i]);
|
|
5319
|
+
scr_closure_release(callbacks[i]);
|
|
5320
|
+
}
|
|
5321
|
+
free(callbacks);
|
|
5322
|
+
}
|
|
5323
|
+
|
|
5324
|
+
/* Options produced by JavaScript helpers use the same native spawn core
|
|
5325
|
+
* as inline options. Materialize typed views only for normalization;
|
|
5326
|
+
* descriptor reads still execute getters and propagate their exceptions. */
|
|
5327
|
+
static ScrDyn *scr_spawn_option(const ScrDyn *options, const char *name) {
|
|
5328
|
+
if (options->kind == SCR_DYN_TYPED_REF) {
|
|
5329
|
+
ScrDyn *view = scr_dyn_typed_ref_materialize(options);
|
|
5330
|
+
if (!view) return NULL;
|
|
5331
|
+
ScrDyn *value = scr_spawn_option(view, name);
|
|
5332
|
+
scr_dyn_release(view);
|
|
5333
|
+
return value;
|
|
5334
|
+
}
|
|
5335
|
+
return scr_dyn_obj_read(options, name, strlen(name));
|
|
5336
|
+
}
|
|
5337
|
+
|
|
5338
|
+
static void scr_spawn_refuse(const char *feature) {
|
|
5339
|
+
ScrJsonBuf message;
|
|
5340
|
+
scr_jb_init(&message);
|
|
5341
|
+
scr_jb_puts(&message, "spawn with ");
|
|
5342
|
+
scr_jb_puts(&message, feature);
|
|
5343
|
+
scr_jb_puts(&message, " has no native lowering");
|
|
5344
|
+
ScrStr *text = scr_jb_finish(&message);
|
|
5345
|
+
scr_throw_error_msg_code(SCR_ERR_ERROR, text->data, text->len, "SC2020");
|
|
5346
|
+
scr_str_release(text);
|
|
5347
|
+
}
|
|
5348
|
+
|
|
5349
|
+
static bool scr_spawn_stdio_mode(const ScrDyn *value, int slot,
|
|
5350
|
+
double *mode, double *fd) {
|
|
5351
|
+
if (value->kind == SCR_DYN_UNDEF || value->kind == SCR_DYN_NULL) {
|
|
5352
|
+
*mode = 3;
|
|
5353
|
+
return true;
|
|
5354
|
+
}
|
|
5355
|
+
if (value->kind == SCR_DYN_STR) {
|
|
5356
|
+
const ScrStr *s = value->v.str;
|
|
5357
|
+
if (s->len == 4 && !memcmp(s->data, "pipe", 4)) { *mode = 3; return true; }
|
|
5358
|
+
if (s->len == 6 && !memcmp(s->data, "ignore", 6)) { *mode = 0; return true; }
|
|
5359
|
+
if (s->len == 7 && !memcmp(s->data, "inherit", 7)) { *mode = 1; return true; }
|
|
5360
|
+
}
|
|
5361
|
+
if (slot > 0 && value->kind == SCR_DYN_NUM && isfinite(value->v.num) &&
|
|
5362
|
+
value->v.num >= 0 && value->v.num <= 2147483647 && floor(value->v.num) == value->v.num) {
|
|
5363
|
+
*mode = 2;
|
|
5364
|
+
*fd = value->v.num;
|
|
5365
|
+
return true;
|
|
5366
|
+
}
|
|
5367
|
+
scr_spawn_refuse("this stdio slot");
|
|
5368
|
+
return false;
|
|
5369
|
+
}
|
|
5370
|
+
|
|
5371
|
+
ScrChild *scr_spawn_dynamic(ScrStr *cmd, ScrArr *args, const ScrDyn *options) {
|
|
5372
|
+
ScrDyn *view = options->kind == SCR_DYN_TYPED_REF
|
|
5373
|
+
? scr_dyn_typed_ref_materialize(options) : scr_dyn_retain((ScrDyn *)options);
|
|
5374
|
+
ScrDyn *stdio = NULL, *value = NULL, *env = NULL, *keys = NULL;
|
|
5375
|
+
ScrArr *pairs = NULL;
|
|
5376
|
+
ScrStr *cwd = NULL;
|
|
5377
|
+
ScrChild *child = NULL;
|
|
5378
|
+
bool detached = false, shell = false, has_env = false;
|
|
5379
|
+
double modes[3] = {3, 3, 3}, fds[3] = {0, 0, 0};
|
|
5380
|
+
if (!view) goto done;
|
|
5381
|
+
if (view->kind != SCR_DYN_UNDEF &&
|
|
5382
|
+
(view->kind == SCR_DYN_NULL || !scr_dyn_is_object(view))) {
|
|
5383
|
+
scr_dyn_arg_type_fail("options", "of type object", view);
|
|
5384
|
+
goto done;
|
|
5385
|
+
}
|
|
5386
|
+
if (view->kind == SCR_DYN_UNDEF) {
|
|
5387
|
+
scr_dyn_release(view);
|
|
5388
|
+
view = scr_dyn_new_obj();
|
|
5389
|
+
}
|
|
5390
|
+
|
|
5391
|
+
/* Retain explicit boundaries for native process features that the
|
|
5392
|
+
* inline lowering does not implement either. Undefined is an omission. */
|
|
5393
|
+
static const char *const unsupported[] = {
|
|
5394
|
+
"uid", "gid", "argv0", "signal", "timeout", "killSignal",
|
|
5395
|
+
};
|
|
5396
|
+
for (size_t i = 0; i < sizeof unsupported / sizeof unsupported[0]; i++) {
|
|
5397
|
+
value = scr_spawn_option(view, unsupported[i]);
|
|
5398
|
+
if (!value || scr_exc_pending()) goto done;
|
|
5399
|
+
if (value->kind != SCR_DYN_UNDEF) {
|
|
5400
|
+
scr_spawn_refuse(unsupported[i]);
|
|
5401
|
+
goto done;
|
|
5402
|
+
}
|
|
5403
|
+
scr_dyn_release(value); value = NULL;
|
|
5404
|
+
}
|
|
5405
|
+
value = scr_spawn_option(view, "windowsVerbatimArguments");
|
|
5406
|
+
if (!value || scr_exc_pending()) goto done;
|
|
5407
|
+
if (scr_dyn_truthy(value)) { scr_spawn_refuse("windowsVerbatimArguments"); goto done; }
|
|
5408
|
+
scr_dyn_release(value); value = NULL;
|
|
5409
|
+
|
|
5410
|
+
cwd = scr_str_new("", 0);
|
|
5411
|
+
value = scr_spawn_option(view, "cwd");
|
|
5412
|
+
if (!value || scr_exc_pending()) goto done;
|
|
5413
|
+
if (value->kind != SCR_DYN_UNDEF && value->kind != SCR_DYN_NULL) {
|
|
5414
|
+
if (value->kind != SCR_DYN_STR) {
|
|
5415
|
+
scr_dyn_prop_type_fail("options.cwd", "of type string or an instance of Buffer or URL", value);
|
|
5416
|
+
goto done;
|
|
5417
|
+
}
|
|
5418
|
+
scr_str_release(cwd); cwd = scr_str_retain(value->v.str);
|
|
5419
|
+
}
|
|
5420
|
+
scr_dyn_release(value); value = NULL;
|
|
5421
|
+
static const char *const booleans[] = {"detached", "shell", "windowsHide"};
|
|
5422
|
+
for (size_t i = 0; i < sizeof booleans / sizeof booleans[0]; i++) {
|
|
5423
|
+
value = scr_spawn_option(view, booleans[i]);
|
|
5424
|
+
if (!value || scr_exc_pending()) goto done;
|
|
5425
|
+
if (value->kind != SCR_DYN_UNDEF) {
|
|
5426
|
+
if (i == 1 && value->kind == SCR_DYN_STR) {
|
|
5427
|
+
scr_spawn_refuse("a custom shell executable");
|
|
5428
|
+
goto done;
|
|
5429
|
+
}
|
|
5430
|
+
if (value->kind != SCR_DYN_BOOL) {
|
|
5431
|
+
char name[40]; snprintf(name, sizeof name, "options.%s", booleans[i]);
|
|
5432
|
+
scr_dyn_prop_type_fail(name, i == 1 ? "of type boolean or string" : "of type boolean", value);
|
|
5433
|
+
goto done;
|
|
5434
|
+
}
|
|
5435
|
+
if (i == 0) detached = value->v.b;
|
|
5436
|
+
else if (i == 1) shell = value->v.b;
|
|
5437
|
+
}
|
|
5438
|
+
scr_dyn_release(value); value = NULL;
|
|
5439
|
+
}
|
|
5440
|
+
if (shell && scr_arr_len(args) != 0) {
|
|
5441
|
+
scr_spawn_refuse("shell enabled and separate arguments");
|
|
5442
|
+
goto done;
|
|
5443
|
+
}
|
|
5444
|
+
stdio = scr_spawn_option(view, "stdio");
|
|
5445
|
+
if (!stdio || scr_exc_pending()) goto done;
|
|
5446
|
+
if (stdio->kind == SCR_DYN_TYPED_REF) {
|
|
5447
|
+
ScrDyn *expanded = scr_dyn_typed_ref_materialize(stdio);
|
|
5448
|
+
scr_dyn_release(stdio); stdio = expanded;
|
|
5449
|
+
if (!stdio) goto done;
|
|
5450
|
+
}
|
|
5451
|
+
if (stdio->kind == SCR_DYN_ARR) {
|
|
5452
|
+
if (stdio->v.arr.len > 3) { scr_spawn_refuse("additional stdio descriptors"); goto done; }
|
|
5453
|
+
for (int i = 0; i < 3; i++) {
|
|
5454
|
+
value = scr_dyn_arr_at(stdio, i);
|
|
5455
|
+
if (!scr_spawn_stdio_mode(value, i, &modes[i], &fds[i])) goto done;
|
|
5456
|
+
scr_dyn_release(value); value = NULL;
|
|
5457
|
+
}
|
|
5458
|
+
} else if (stdio->kind == SCR_DYN_STR || stdio->kind == SCR_DYN_UNDEF || stdio->kind == SCR_DYN_NULL) {
|
|
5459
|
+
if (!scr_spawn_stdio_mode(stdio, 0, &modes[0], &fds[0])) goto done;
|
|
5460
|
+
modes[1] = modes[2] = modes[0];
|
|
5461
|
+
} else { scr_spawn_refuse("this stdio option"); goto done; }
|
|
5462
|
+
|
|
5463
|
+
pairs = scr_arr_new(SCR_ELEM_STR, 8);
|
|
5464
|
+
env = scr_spawn_option(view, "env");
|
|
5465
|
+
if (!env || scr_exc_pending()) goto done;
|
|
5466
|
+
if (env->kind == SCR_DYN_TYPED_REF) {
|
|
5467
|
+
ScrDyn *expanded = scr_dyn_typed_ref_materialize(env);
|
|
5468
|
+
scr_dyn_release(env); env = expanded;
|
|
5469
|
+
if (!env) goto done;
|
|
5470
|
+
}
|
|
5471
|
+
if (env->kind != SCR_DYN_UNDEF && env->kind != SCR_DYN_NULL) {
|
|
5472
|
+
has_env = true;
|
|
5473
|
+
keys = scr_dyn_for_in_keys(env);
|
|
5474
|
+
if (!keys || scr_exc_pending()) goto done;
|
|
5475
|
+
for (size_t i = 0; i < keys->v.arr.len; i++) {
|
|
5476
|
+
ScrStr *key = keys->v.arr.items[i]->v.str;
|
|
5477
|
+
value = scr_spawn_option(env, key->data);
|
|
5478
|
+
if (!value || scr_exc_pending()) goto done;
|
|
5479
|
+
if (value->kind != SCR_DYN_UNDEF) {
|
|
5480
|
+
ScrStr *text = scr_dyn_string_coerce_js(value);
|
|
5481
|
+
if (!text) goto done;
|
|
5482
|
+
scr_arr_push_ref(pairs, scr_str_retain(key));
|
|
5483
|
+
scr_arr_push_ref(pairs, text);
|
|
5484
|
+
}
|
|
5485
|
+
scr_dyn_release(value); value = NULL;
|
|
5486
|
+
}
|
|
5487
|
+
}
|
|
5488
|
+
child = scr_spawn_opts(cmd, args, modes[0], modes[1], modes[2],
|
|
5489
|
+
fds[1], fds[2], detached, shell, has_env, pairs, cwd);
|
|
5490
|
+
done:
|
|
5491
|
+
scr_dyn_release(view);
|
|
5492
|
+
scr_dyn_release(stdio);
|
|
5493
|
+
scr_dyn_release(value);
|
|
5494
|
+
scr_dyn_release(env);
|
|
5495
|
+
scr_dyn_release(keys);
|
|
5496
|
+
scr_arr_release(pairs);
|
|
5497
|
+
scr_str_release(cwd);
|
|
5498
|
+
return child;
|
|
5499
|
+
}
|
|
5500
|
+
|
|
5255
5501
|
/* ── fork JSON IPC (shared by Windows and POSIX) ────────────────────── */
|
|
5256
5502
|
|
|
5257
5503
|
typedef struct {
|
|
@@ -5744,30 +5990,300 @@ void scr_process_ipc_on_disconnect(ScrClosure *cb, bool once) {
|
|
|
5744
5990
|
scr_ipc_add_disconnect(scr_process_ipc, cb, once);
|
|
5745
5991
|
}
|
|
5746
5992
|
|
|
5747
|
-
|
|
5748
|
-
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
|
|
5752
|
-
*
|
|
5753
|
-
|
|
5993
|
+
static SCR_TL const ScrChildStreamOps *scr_child_stream_ops;
|
|
5994
|
+
static SCR_TL ScrDyn *(*scr_child_readable_box)(void *);
|
|
5995
|
+
static SCR_TL ScrDyn *(*scr_child_writable_box)(void *);
|
|
5996
|
+
|
|
5997
|
+
void scr_child_dyn_streams_install(const ScrChildStreamOps *ops,
|
|
5998
|
+
ScrDyn *(*readable_box)(void *), ScrDyn *(*writable_box)(void *)) {
|
|
5999
|
+
scr_child_stream_ops = ops;
|
|
6000
|
+
scr_child_readable_box = readable_box;
|
|
6001
|
+
scr_child_writable_box = writable_box;
|
|
6002
|
+
}
|
|
6003
|
+
|
|
6004
|
+
static ScrClosure *scr_child_bridge_callback(void *stream, void *fire) {
|
|
6005
|
+
ScrClosure *cb = scr_closure_new(fire, 1);
|
|
6006
|
+
cb->caps[0] = scr_box_new_obj(scr_child_stream_ops->retain,
|
|
6007
|
+
scr_child_stream_ops->release, scr_child_stream_ops->trace);
|
|
6008
|
+
scr_box_set_ref(cb->caps[0], scr_child_stream_ops->retain(stream));
|
|
6009
|
+
return cb;
|
|
6010
|
+
}
|
|
6011
|
+
static void scr_child_bridge_data(ScrClosure *cb, ScrBytes *chunk) {
|
|
6012
|
+
ScrStream *stream = scr_box_get_ref(cb->caps[0]);
|
|
6013
|
+
scr_child_stream_ops->push(stream, chunk);
|
|
6014
|
+
scr_child_stream_ops->release(stream);
|
|
6015
|
+
}
|
|
6016
|
+
static void scr_child_bridge_end(ScrClosure *cb) {
|
|
6017
|
+
ScrStream *stream = scr_box_get_ref(cb->caps[0]);
|
|
6018
|
+
scr_child_stream_ops->end(stream);
|
|
6019
|
+
scr_child_stream_ops->release(stream);
|
|
6020
|
+
}
|
|
6021
|
+
static ScrDyn *scr_child_bridge_readable(ScrChildStream *reader, ScrDyn **cached) {
|
|
6022
|
+
if (!reader) return scr_dyn_new_null();
|
|
6023
|
+
if (!scr_child_stream_ops) {
|
|
6024
|
+
static const char message[] = "ChildProcess standard streams require the native stream surface";
|
|
6025
|
+
scr_throw_error_msg_code(SCR_ERR_ERROR, message, sizeof message - 1, "SC2020");
|
|
6026
|
+
return NULL;
|
|
6027
|
+
}
|
|
6028
|
+
if (!*cached) {
|
|
6029
|
+
ScrStream *stream = scr_child_stream_ops->readable();
|
|
6030
|
+
scr_child_stream_on_data(reader, scr_child_bridge_callback(stream, (void *)scr_child_bridge_data),
|
|
6031
|
+
scr_child_bridge_data, false);
|
|
6032
|
+
scr_child_stream_on_end(reader, scr_child_bridge_callback(stream, (void *)scr_child_bridge_end), false);
|
|
6033
|
+
*cached = scr_child_readable_box(stream);
|
|
6034
|
+
scr_child_stream_ops->release(stream);
|
|
6035
|
+
}
|
|
6036
|
+
return scr_dyn_retain(*cached);
|
|
6037
|
+
}
|
|
6038
|
+
static void scr_child_bridge_write_error(ScrClosure *, ScrStr *);
|
|
6039
|
+
static void scr_child_bridge_final_error(ScrClosure *, ScrStr *);
|
|
6040
|
+
static void scr_child_bridge_write_drained(ScrClosure *);
|
|
6041
|
+
static void scr_child_bridge_final_finished(ScrClosure *);
|
|
6042
|
+
|
|
6043
|
+
/* Each pending native stream operation owns its callback until the pipe
|
|
6044
|
+
* actually drains or closes. Remove the alternate completion listener
|
|
6045
|
+
* before finishing the operation, which may synchronously start another. */
|
|
6046
|
+
static void scr_child_bridge_remove_error(ScrChildWriter *writer, ScrChildErrFn fn) {
|
|
6047
|
+
for (size_t i = writer->n_write_err; i > 0; i--) {
|
|
6048
|
+
if (writer->err_ls[i - 1].fn != fn) continue;
|
|
6049
|
+
scr_closure_release(writer->err_ls[i - 1].cb);
|
|
6050
|
+
memmove(writer->err_ls + i - 1, writer->err_ls + i,
|
|
6051
|
+
(writer->n_write_err - i) * sizeof *writer->err_ls);
|
|
6052
|
+
writer->n_write_err--;
|
|
6053
|
+
}
|
|
6054
|
+
}
|
|
6055
|
+
static void scr_child_bridge_remove_zero(ScrChildStreamEndL *listeners, size_t *count, void *fn) {
|
|
6056
|
+
for (size_t i = *count; i > 0; i--) {
|
|
6057
|
+
if (listeners[i - 1].cb->fn != fn) continue;
|
|
6058
|
+
scr_closure_release(listeners[i - 1].cb);
|
|
6059
|
+
memmove(listeners + i - 1, listeners + i, (*count - i) * sizeof *listeners);
|
|
6060
|
+
(*count)--;
|
|
6061
|
+
}
|
|
6062
|
+
}
|
|
6063
|
+
static ScrClosure *scr_child_bridge_operation(ScrStream *stream, ScrChildWriter *writer, void *fn) {
|
|
6064
|
+
ScrClosure *cb = scr_closure_new(fn, 2);
|
|
6065
|
+
cb->caps[0] = scr_box_new_obj(scr_child_stream_ops->retain,
|
|
6066
|
+
scr_child_stream_ops->release, scr_child_stream_ops->trace);
|
|
6067
|
+
cb->caps[1] = scr_box_new_obj(scr_child_writer_retain_v, scr_child_writer_release_v, NULL);
|
|
6068
|
+
scr_box_set_ref(cb->caps[0], scr_child_stream_ops->retain(stream));
|
|
6069
|
+
scr_box_set_ref(cb->caps[1], scr_child_writer_retain(writer));
|
|
6070
|
+
return cb;
|
|
6071
|
+
}
|
|
6072
|
+
static void scr_child_bridge_write_drained(ScrClosure *cb) {
|
|
6073
|
+
ScrStream *stream = scr_box_get_ref(cb->caps[0]);
|
|
6074
|
+
ScrChildWriter *writer = scr_box_get_ref(cb->caps[1]);
|
|
6075
|
+
scr_child_bridge_remove_error(writer, scr_child_bridge_write_error);
|
|
6076
|
+
scr_child_stream_ops->write_done(stream, NULL);
|
|
6077
|
+
scr_child_writer_release(writer);
|
|
6078
|
+
scr_child_stream_ops->release(stream);
|
|
6079
|
+
}
|
|
6080
|
+
static void scr_child_bridge_final_finished(ScrClosure *cb) {
|
|
6081
|
+
ScrStream *stream = scr_box_get_ref(cb->caps[0]);
|
|
6082
|
+
ScrChildWriter *writer = scr_box_get_ref(cb->caps[1]);
|
|
6083
|
+
scr_child_bridge_remove_error(writer, scr_child_bridge_final_error);
|
|
6084
|
+
scr_child_stream_ops->final_done(stream, NULL);
|
|
6085
|
+
scr_child_writer_release(writer);
|
|
6086
|
+
scr_child_stream_ops->release(stream);
|
|
6087
|
+
}
|
|
6088
|
+
static void scr_child_bridge_operation_error(ScrClosure *cb, ScrStr *message, bool final) {
|
|
6089
|
+
ScrStream *stream = scr_box_get_ref(cb->caps[0]);
|
|
6090
|
+
ScrChildWriter *writer = scr_box_get_ref(cb->caps[1]);
|
|
6091
|
+
if (final) scr_child_bridge_remove_zero(writer->finish_ls, &writer->n_finish, (void *)scr_child_bridge_final_finished);
|
|
6092
|
+
else scr_child_bridge_remove_zero(writer->drain_ls, &writer->n_drain, (void *)scr_child_bridge_write_drained);
|
|
6093
|
+
ScrError *error = scr_error_new(SCR_ERR_ERROR, message);
|
|
6094
|
+
if (writer->err_code) scr_error_set_code(error, writer->err_code);
|
|
6095
|
+
if (final) scr_child_stream_ops->final_done(stream, error);
|
|
6096
|
+
else scr_child_stream_ops->write_done(stream, error);
|
|
6097
|
+
scr_child_writer_release(writer);
|
|
6098
|
+
scr_child_stream_ops->release(stream);
|
|
6099
|
+
}
|
|
6100
|
+
static void scr_child_bridge_write_error(ScrClosure *cb, ScrStr *message) {
|
|
6101
|
+
scr_child_bridge_operation_error(cb, message, false);
|
|
6102
|
+
}
|
|
6103
|
+
static void scr_child_bridge_final_error(ScrClosure *cb, ScrStr *message) {
|
|
6104
|
+
scr_child_bridge_operation_error(cb, message, true);
|
|
6105
|
+
}
|
|
6106
|
+
static void scr_child_bridge_write(ScrClosure *cb, ScrStream *stream, ScrBytes *chunk) {
|
|
6107
|
+
ScrChildWriter *writer = scr_box_get_ref(cb->caps[0]);
|
|
6108
|
+
scr_child_writer_write_bytes(writer, chunk);
|
|
6109
|
+
bool pending = scr_child_writer_queued(writer) > 0;
|
|
6110
|
+
#ifdef _WIN32
|
|
6111
|
+
pending = pending || writer->write_pending;
|
|
6112
|
+
#endif
|
|
6113
|
+
if (pending || writer->error_pending) {
|
|
6114
|
+
scr_child_writer_on_error(writer,
|
|
6115
|
+
scr_child_bridge_operation(stream, writer, (void *)scr_child_bridge_write_error),
|
|
6116
|
+
scr_child_bridge_write_error, true);
|
|
6117
|
+
if (!writer->error_pending) {
|
|
6118
|
+
writer->need_drain = true;
|
|
6119
|
+
scr_child_writer_on_drain(writer,
|
|
6120
|
+
scr_child_bridge_operation(stream, writer, (void *)scr_child_bridge_write_drained), true);
|
|
6121
|
+
}
|
|
6122
|
+
} else scr_child_stream_ops->write_done(stream, NULL);
|
|
6123
|
+
scr_child_writer_release(writer);
|
|
6124
|
+
}
|
|
6125
|
+
static void scr_child_bridge_final(ScrClosure *cb, ScrStream *stream) {
|
|
6126
|
+
ScrChildWriter *writer = scr_box_get_ref(cb->caps[0]);
|
|
6127
|
+
scr_child_writer_on_error(writer,
|
|
6128
|
+
scr_child_bridge_operation(stream, writer, (void *)scr_child_bridge_final_error),
|
|
6129
|
+
scr_child_bridge_final_error, true);
|
|
6130
|
+
scr_child_writer_on_finish(writer,
|
|
6131
|
+
scr_child_bridge_operation(stream, writer, (void *)scr_child_bridge_final_finished), true);
|
|
6132
|
+
scr_child_writer_end(writer);
|
|
6133
|
+
scr_child_writer_release(writer);
|
|
6134
|
+
}
|
|
6135
|
+
static ScrClosure *scr_child_writer_bridge_callback(ScrChildWriter *writer, void *fire) {
|
|
6136
|
+
ScrClosure *cb = scr_closure_new(fire, 1);
|
|
6137
|
+
cb->caps[0] = scr_box_new_obj(scr_child_writer_retain_v, scr_child_writer_release_v, NULL);
|
|
6138
|
+
scr_box_set_ref(cb->caps[0], scr_child_writer_retain(writer));
|
|
6139
|
+
return cb;
|
|
6140
|
+
}
|
|
6141
|
+
static ScrDyn *scr_child_bridge_writable(ScrChildWriter *writer, ScrDyn **cached) {
|
|
6142
|
+
if (!writer) return scr_dyn_new_null();
|
|
6143
|
+
if (!scr_child_stream_ops) {
|
|
6144
|
+
static const char message[] = "ChildProcess standard streams require the native stream surface";
|
|
6145
|
+
scr_throw_error_msg_code(SCR_ERR_ERROR, message, sizeof message - 1, "SC2020");
|
|
6146
|
+
return NULL;
|
|
6147
|
+
}
|
|
6148
|
+
if (!*cached) {
|
|
6149
|
+
ScrStream *stream = scr_child_stream_ops->writable(
|
|
6150
|
+
scr_child_writer_bridge_callback(writer, (void *)scr_child_bridge_write), scr_child_bridge_write,
|
|
6151
|
+
scr_child_writer_bridge_callback(writer, (void *)scr_child_bridge_final), scr_child_bridge_final);
|
|
6152
|
+
*cached = scr_child_writable_box(stream);
|
|
6153
|
+
scr_child_stream_ops->release(stream);
|
|
6154
|
+
}
|
|
6155
|
+
return scr_dyn_retain(*cached);
|
|
6156
|
+
}
|
|
6157
|
+
|
|
6158
|
+
/* ── checked-dynamic ChildProcess dispatch ──────────────────────────── */
|
|
6159
|
+
static void scr_child_dyn_fire(ScrClosure *cb, ScrDyn *const *args, size_t argc) {
|
|
6160
|
+
ScrDyn *fn = scr_box_get_ref(cb->caps[0]);
|
|
6161
|
+
ScrDyn *self = scr_box_get_ref(cb->caps[1]);
|
|
6162
|
+
scr_dyn_this_push_dyn(self);
|
|
6163
|
+
ScrDyn *result = scr_dyn_call(fn, args, argc, "child listener");
|
|
6164
|
+
scr_dyn_this_pop();
|
|
6165
|
+
scr_dyn_release(result);
|
|
6166
|
+
scr_dyn_release(self);
|
|
6167
|
+
scr_dyn_release(fn);
|
|
6168
|
+
}
|
|
6169
|
+
|
|
6170
|
+
static void scr_child_dyn_spawn(ScrClosure *cb) { scr_child_dyn_fire(cb, NULL, 0); }
|
|
6171
|
+
static void scr_child_dyn_exit(ScrClosure *cb, bool has_code, double code, const char *signal) {
|
|
6172
|
+
ScrDyn *args[2] = { has_code ? scr_dyn_new_num(code) : scr_dyn_new_null(),
|
|
6173
|
+
signal ? NULL : scr_dyn_new_null() };
|
|
6174
|
+
if (signal) {
|
|
6175
|
+
ScrStr *name = scr_str_new(signal, strlen(signal));
|
|
6176
|
+
args[1] = scr_dyn_new_str(name);
|
|
6177
|
+
scr_str_release(name);
|
|
6178
|
+
}
|
|
6179
|
+
scr_child_dyn_fire(cb, args, 2);
|
|
6180
|
+
scr_dyn_release(args[0]);
|
|
6181
|
+
scr_dyn_release(args[1]);
|
|
6182
|
+
}
|
|
6183
|
+
static void scr_child_dyn_error(ScrClosure *cb, ScrStr *message) {
|
|
6184
|
+
ScrError *error = scr_error_new(SCR_ERR_ERROR, message);
|
|
6185
|
+
if (scr_child_err_code) scr_error_set_code(error, scr_child_err_code);
|
|
6186
|
+
else if (scr_child_writer_err_code) scr_error_set_code(error, scr_child_writer_err_code);
|
|
6187
|
+
ScrDyn *arg = scr_dyn_from_error(error);
|
|
6188
|
+
scr_error_release(error);
|
|
6189
|
+
scr_child_dyn_fire(cb, &arg, 1);
|
|
6190
|
+
scr_dyn_release(arg);
|
|
6191
|
+
}
|
|
6192
|
+
|
|
6193
|
+
static ScrClosure *scr_child_dyn_listener(ScrDyn *fn, ScrDyn *self, void *fire) {
|
|
6194
|
+
ScrClosure *cb = scr_closure_new(fire, 2);
|
|
6195
|
+
cb->caps[0] = scr_box_new_obj(scr_dyn_retain_v, scr_dyn_release_v, scr_dyn_trace_v);
|
|
6196
|
+
cb->caps[1] = scr_box_new_obj(scr_dyn_retain_v, scr_dyn_release_v, scr_dyn_trace_v);
|
|
6197
|
+
scr_box_set_ref(cb->caps[0], scr_dyn_retain(fn));
|
|
6198
|
+
scr_box_set_ref(cb->caps[1], scr_dyn_retain(self));
|
|
6199
|
+
return cb;
|
|
6200
|
+
}
|
|
6201
|
+
|
|
6202
|
+
static bool scr_child_dyn_matches(ScrClosure *cb, void *fire, const ScrDyn *fn) {
|
|
6203
|
+
if (cb->fn != fire) return false;
|
|
6204
|
+
ScrDyn *listener = scr_box_get_ref(cb->caps[0]);
|
|
6205
|
+
bool matches = scr_dyn_strict_eq(listener, fn);
|
|
6206
|
+
scr_dyn_release(listener);
|
|
6207
|
+
return matches;
|
|
6208
|
+
}
|
|
6209
|
+
|
|
5754
6210
|
static ScrDyn *scr_child_dyn_invoke(
|
|
5755
6211
|
void *h, ScrDyn *self, const char *method,
|
|
5756
6212
|
ScrDyn *const *args, size_t argc, const char *what) {
|
|
5757
|
-
(void)h;
|
|
5758
|
-
(void)self;
|
|
5759
|
-
(void)method;
|
|
5760
|
-
(void)args;
|
|
5761
|
-
(void)argc;
|
|
5762
6213
|
(void)what;
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
6214
|
+
ScrChild *child = h;
|
|
6215
|
+
if (!strcmp(method, "ref") || !strcmp(method, "unref")) {
|
|
6216
|
+
if (!strcmp(method, "ref")) scr_child_ref(child); else scr_child_unref(child);
|
|
6217
|
+
return scr_dyn_retain(self);
|
|
6218
|
+
}
|
|
6219
|
+
if (!strcmp(method, "kill")) {
|
|
6220
|
+
const ScrDyn *signal = argc ? args[0] : scr_dyn_undefined();
|
|
6221
|
+
bool killed;
|
|
6222
|
+
if (signal->kind == SCR_DYN_NUM) killed = scr_child_kill_num(child, signal->v.num);
|
|
6223
|
+
else if (signal->kind == SCR_DYN_STR) killed = scr_child_kill(child, signal->v.str);
|
|
6224
|
+
else if (signal->kind == SCR_DYN_UNDEF) {
|
|
6225
|
+
ScrStr *name = scr_str_new("SIGTERM", 7);
|
|
6226
|
+
killed = scr_child_kill(child, name);
|
|
6227
|
+
scr_str_release(name);
|
|
6228
|
+
} else { scr_dyn_arg_type_fail("signal", "of type string or number", signal); return NULL; }
|
|
6229
|
+
return scr_exc_pending() ? NULL : scr_dyn_new_bool(killed);
|
|
6230
|
+
}
|
|
6231
|
+
bool remove = !strcmp(method, "removeListener") || !strcmp(method, "off");
|
|
6232
|
+
if (!strcmp(method, "on") || !strcmp(method, "once") || !strcmp(method, "addListener") || remove) {
|
|
6233
|
+
const ScrDyn *event = argc ? args[0] : scr_dyn_undefined();
|
|
6234
|
+
ScrDyn *listener = argc > 1 ? args[1] : scr_dyn_undefined();
|
|
6235
|
+
if (listener->kind != SCR_DYN_FUNC) scr_dyn_arg_type_fail("listener", "of type function", listener);
|
|
6236
|
+
if (scr_exc_pending()) return NULL;
|
|
6237
|
+
if (event->kind != SCR_DYN_STR) { scr_dyn_arg_type_fail("event", "of type string", event); return NULL; }
|
|
6238
|
+
const ScrStr *name = event->v.str;
|
|
6239
|
+
bool spawn = name->len == 5 && !memcmp(name->data, "spawn", 5);
|
|
6240
|
+
bool exit = name->len == 4 && !memcmp(name->data, "exit", 4);
|
|
6241
|
+
bool close = name->len == 5 && !memcmp(name->data, "close", 5);
|
|
6242
|
+
bool error = name->len == 5 && !memcmp(name->data, "error", 5);
|
|
6243
|
+
if (spawn || exit || close || error) {
|
|
6244
|
+
void *fire = spawn ? (void *)scr_child_dyn_spawn : error ? (void *)scr_child_dyn_error : (void *)scr_child_dyn_exit;
|
|
6245
|
+
if (remove) {
|
|
6246
|
+
if (spawn) {
|
|
6247
|
+
for (size_t i = child->n_spawn; i > 0; i--) if (scr_child_dyn_matches(child->spawn_cbs[i-1], fire, listener)) {
|
|
6248
|
+
scr_closure_release(child->spawn_cbs[i-1]);
|
|
6249
|
+
memmove(child->spawn_cbs+i-1, child->spawn_cbs+i, (child->n_spawn-i)*sizeof *child->spawn_cbs);
|
|
6250
|
+
child->n_spawn--; break;
|
|
6251
|
+
}
|
|
6252
|
+
} else if (error) {
|
|
6253
|
+
for (size_t i = child->n_err; i > 0; i--) if (scr_child_dyn_matches(child->err_cbs[i-1].cb, fire, listener)) {
|
|
6254
|
+
scr_closure_release(child->err_cbs[i-1].cb);
|
|
6255
|
+
memmove(child->err_cbs+i-1, child->err_cbs+i, (child->n_err-i)*sizeof *child->err_cbs);
|
|
6256
|
+
child->n_err--; break;
|
|
6257
|
+
}
|
|
6258
|
+
} else {
|
|
6259
|
+
ScrChildExitEntry *entries = close ? child->close_cbs : child->exit_cbs;
|
|
6260
|
+
size_t *count = close ? &child->n_close : &child->n_exit;
|
|
6261
|
+
for (size_t i = *count; i > 0; i--) if (scr_child_dyn_matches(entries[i-1].cb, fire, listener)) {
|
|
6262
|
+
scr_closure_release(entries[i-1].cb);
|
|
6263
|
+
memmove(entries+i-1, entries+i, (*count-i)*sizeof *entries);
|
|
6264
|
+
(*count)--; break;
|
|
6265
|
+
}
|
|
6266
|
+
}
|
|
6267
|
+
} else {
|
|
6268
|
+
ScrClosure *cb = scr_child_dyn_listener(listener, self, fire);
|
|
6269
|
+
if (spawn) scr_child_on_spawn(child, cb);
|
|
6270
|
+
else if (error) scr_child_on_error(child, cb, scr_child_dyn_error);
|
|
6271
|
+
else if (close) scr_child_on_close(child, cb, scr_child_dyn_exit);
|
|
6272
|
+
else scr_child_on_exit(child, cb, scr_child_dyn_exit);
|
|
6273
|
+
}
|
|
6274
|
+
return scr_dyn_retain(self);
|
|
6275
|
+
}
|
|
6276
|
+
}
|
|
6277
|
+
static const char msg[] = "This ChildProcess method or event has no native lowering";
|
|
6278
|
+
scr_throw_error_msg_code(SCR_ERR_ERROR, msg, sizeof msg - 1, "SC2020");
|
|
5766
6279
|
return NULL;
|
|
5767
6280
|
}
|
|
5768
6281
|
|
|
5769
6282
|
static ScrDyn *scr_child_dyn_get(void *h, const char *key, size_t key_len) {
|
|
5770
6283
|
ScrChild *child = (ScrChild *)h;
|
|
6284
|
+
if (key_len == 6 && !memcmp(key, "stdout", 6)) return scr_child_bridge_readable(child->out_stream, &child->out_dyn);
|
|
6285
|
+
if (key_len == 6 && !memcmp(key, "stderr", 6)) return scr_child_bridge_readable(child->err_stream, &child->err_dyn);
|
|
6286
|
+
if (key_len == 5 && !memcmp(key, "stdin", 5)) return scr_child_bridge_writable(child->in_stream, &child->in_dyn);
|
|
5771
6287
|
if (key_len == 6 && memcmp(key, "killed", 6) == 0) {
|
|
5772
6288
|
return scr_dyn_new_bool(scr_child_killed(child));
|
|
5773
6289
|
}
|
|
@@ -5806,3 +6322,14 @@ static const ScrDynHandleOps scr_child_dyn_ops = {
|
|
|
5806
6322
|
void scr_child_dyn_install(void) {
|
|
5807
6323
|
scr_dyn_handle_install(SCR_DYNH_CHILD, &scr_child_dyn_ops);
|
|
5808
6324
|
}
|
|
6325
|
+
|
|
6326
|
+
void scr_child_on_dyn(ScrChild *child, ScrStr *event, ScrDyn *listener) {
|
|
6327
|
+
scr_child_dyn_install();
|
|
6328
|
+
ScrDyn *self = scr_dyn_new_handle(child, SCR_DYNH_CHILD);
|
|
6329
|
+
ScrDyn *name = scr_dyn_new_str(event);
|
|
6330
|
+
ScrDyn *args[] = { name, listener };
|
|
6331
|
+
ScrDyn *result = scr_child_dyn_invoke(child, self, "on", args, 2, "child listener");
|
|
6332
|
+
scr_dyn_release(result);
|
|
6333
|
+
scr_dyn_release(name);
|
|
6334
|
+
scr_dyn_release(self);
|
|
6335
|
+
}
|