@scriptc/runtime 0.0.11 → 0.0.13
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/package.json +1 -1
- package/src/scr_assert.c +13 -13
- package/src/scr_async.c +53 -8
- package/src/scr_async_dyn.c +163 -47
- package/src/scr_bytes_io.c +5 -5
- package/src/scr_dc.c +8 -8
- package/src/scr_dgram.c +1 -1
- package/src/scr_dyn_handle.c +5 -5
- package/src/scr_dyn_invoke.c +42 -18
- package/src/scr_error.c +3 -3
- package/src/scr_events_emitter.c +1 -1
- package/src/scr_http.c +1080 -34
- package/src/scr_http2.c +53 -3
- package/src/scr_inspect.c +3 -3
- package/src/scr_island.c +134 -25
- package/src/scr_json.c +124 -68
- package/src/scr_net.c +254 -35
- package/src/scr_qs.c +1 -1
- package/src/scr_runtime.h +278 -124
- package/src/scr_stream.c +4 -4
- package/src/scr_tls.c +42 -5
- package/src/scr_tls_ca.c +288 -0
- package/src/scr_web.c +1 -1
package/src/scr_runtime.h
CHANGED
|
@@ -397,7 +397,7 @@ enum {
|
|
|
397
397
|
|
|
398
398
|
extern ScrVt scr_error_vts[5]; /* indexed by SCR_ERR_*; main() stamps pre/post */
|
|
399
399
|
|
|
400
|
-
struct ScrDyn; /* full declaration below (the
|
|
400
|
+
struct ScrDyn; /* full declaration below (the checked-dynamic tree section) */
|
|
401
401
|
|
|
402
402
|
/* DOMException: the ScrError prefix (identical member order — an upcast is
|
|
403
403
|
* a pointer reinterpret) plus the WebIDL slots. The extra slots are HIDDEN
|
|
@@ -415,11 +415,11 @@ typedef struct ScrDomException {
|
|
|
415
415
|
struct ScrDyn *cause; /* owned; NULL when has_cause is false */
|
|
416
416
|
} ScrDomException;
|
|
417
417
|
|
|
418
|
-
/* new DOMException(message?, nameOrOptions?) — both
|
|
419
|
-
* NULL-tolerant (NULL = absent = the
|
|
420
|
-
* throws (
|
|
418
|
+
/* new DOMException(message?, nameOrOptions?) — both dyn args borrowed,
|
|
419
|
+
* NULL-tolerant (NULL = absent = the dyn undefined). Returns +1. Never
|
|
420
|
+
* throws (dyn ToString is total). Lives in scr_json.c (the args are dyn
|
|
421
421
|
* values); the dyn-free half below stays in scr_error.c so the error
|
|
422
|
-
* unit links without the
|
|
422
|
+
* unit links without the checked-dynamic tree. */
|
|
423
423
|
ScrError *scr_domex_new(const struct ScrDyn *message, const struct ScrDyn *name_or_options);
|
|
424
424
|
/* scr_error.c's dyn-free DOMException half: the blank allocation the
|
|
425
425
|
* constructors fill, the WebIDL name→legacy-code table, and the cause
|
|
@@ -429,7 +429,7 @@ double scr_domex_code_of(const ScrStr *name);
|
|
|
429
429
|
void scr_domex_install_cause_drop(void (*fn)(void *obj));
|
|
430
430
|
double scr_domex_code(ScrError *e); /* borrowed receiver */
|
|
431
431
|
bool scr_domex_has_cause(ScrError *e); /* borrowed receiver */
|
|
432
|
-
struct ScrDyn *scr_domex_cause(ScrError *e); /* +1 (
|
|
432
|
+
struct ScrDyn *scr_domex_cause(ScrError *e); /* +1 (dyn undefined when absent) */
|
|
433
433
|
/* structuredClone of a DOMException: WebIDL serialization — name/message
|
|
434
434
|
* copy, the code re-derives, cause does not serialize. Borrowed receiver
|
|
435
435
|
* and options (validated; throws on bad options / non-empty transfer).
|
|
@@ -672,9 +672,9 @@ void scr_qs_parse_into(ScrMap *out, const ScrStr *qs, const ScrStr *sep,
|
|
|
672
672
|
const ScrStr *eq, double max_keys, uint32_t str_tag,
|
|
673
673
|
uint32_t arr_tag);
|
|
674
674
|
|
|
675
|
-
/* querystring.stringify — Node's stringify over a borrowed
|
|
675
|
+
/* querystring.stringify — Node's stringify over a borrowed dyn value (the
|
|
676
676
|
* frontend dynFroms the typed record; JS-world dyn values pass straight
|
|
677
|
-
* through). Non-object
|
|
677
|
+
* through). Non-object dyn values answer "" like Node; object keys iterate in
|
|
678
678
|
* JS own-key order (scr_dyn_obj_keys — array-index keys ascending first,
|
|
679
679
|
* then insertion order, Node's ObjectKeys). Values serialize per Node's
|
|
680
680
|
* encodeStringified: strings escape, finite numbers render shortest-
|
|
@@ -692,8 +692,8 @@ ScrStr *scr_qs_stringify(const struct ScrDyn *obj, const ScrStr *sep,
|
|
|
692
692
|
* well-formed-UTF-8 invariant. Borrows s; result +1. */
|
|
693
693
|
ScrStr *scr_encode_uri(ScrStr *s);
|
|
694
694
|
/* atob/btoa — the WHATWG base64 globals (Node globals since v16). The
|
|
695
|
-
* argument is a borrowed
|
|
696
|
-
*
|
|
695
|
+
* argument is a borrowed dyn value: WebIDL ToString runs here over the
|
|
696
|
+
* dyn kind (Node's atob(null) decodes "null"). scr_atob decodes
|
|
697
697
|
* forgiving-base64 (ASCII whitespace stripped, %4==0 strips up to two
|
|
698
698
|
* '=', %4==1 refuses, leftover bits discarded) into the latin1 code
|
|
699
699
|
* points as a UTF-8 string; malformed input THROWS the catchable
|
|
@@ -1558,7 +1558,7 @@ void scr_stream_st_trace(ScrStreamState *st, ScrTraceVisit visit, void *ctx);
|
|
|
1558
1558
|
/* The dyn-flavored completion-callback glues (the JS lane's implicitly-
|
|
1559
1559
|
* any option callbacks / underscore methods): the emitted invoke thunks
|
|
1560
1560
|
* mint a callable dyn (scr_dyn_new_func) over a 1-cap closure boxing the
|
|
1561
|
-
* retained stream, with the kind's glue — arguments arrive as
|
|
1561
|
+
* retained stream, with the kind's glue — arguments arrive as dyn
|
|
1562
1562
|
* values (error: null/undefined, a {message} object, or a string;
|
|
1563
1563
|
* transform/flush data: bytes, a string, or absent). */
|
|
1564
1564
|
typedef struct ScrDyn ScrDyn; /* full declaration below (C11 repeat) */
|
|
@@ -1613,7 +1613,7 @@ ScrPromise *scr_sp_pipeline(double n, ScrStream **streams);
|
|
|
1613
1613
|
* and settle at the terminal point (right after 'close', the eos timing
|
|
1614
1614
|
* Node's consumers share) — text answers the utf8 decode, json parses
|
|
1615
1615
|
* the text (malformed input rejects with the parse's SyntaxError; the
|
|
1616
|
-
* result is a +1
|
|
1616
|
+
* result is a +1 dyn tree), buffer the concatenated bytes. Stream
|
|
1617
1617
|
* errors reject; an early close rejects ERR_STREAM_PREMATURE_CLOSE; a
|
|
1618
1618
|
* stream with no readable side rejects Node's async-iterable TypeError.
|
|
1619
1619
|
* Streams borrowed; +1 promises. */
|
|
@@ -1809,7 +1809,7 @@ ScrStr *scr_caught_to_string(const ScrCaught *c);
|
|
|
1809
1809
|
* checks. */
|
|
1810
1810
|
void *scr_caught_check_obj(const ScrCaught *c, size_t pre, size_t post,
|
|
1811
1811
|
const char *cls);
|
|
1812
|
-
/* The snapshot as a
|
|
1812
|
+
/* The snapshot as a dyn value (scr_json.c): identity-preserving for dyn
|
|
1813
1813
|
* payloads and %Error instances, scalars by value, the type-erased empty
|
|
1814
1814
|
* object for the rest (SEMANTICS.md 67). Borrows the box; +1. */
|
|
1815
1815
|
typedef struct ScrDyn ScrDyn; /* full definition below (C11 repeat) */
|
|
@@ -2062,7 +2062,7 @@ ScrPromise *scr_tp_set_immediate(void);
|
|
|
2062
2062
|
* A process-global name→channel registry; channel handles are 1-based
|
|
2063
2063
|
* f64 indexes into it (Node's channels are process-lived too, its
|
|
2064
2064
|
* WeakRef machinery aside — the registry tears down atexit before the
|
|
2065
|
-
* RC audit). Subscribers are
|
|
2065
|
+
* RC audit). Subscribers are dyn FUNCTION values, identity-matched by
|
|
2066
2066
|
* unsubscribe (the underlying closure, so re-boxings of one function
|
|
2067
2067
|
* still match — JS has ONE function object). publish calls each
|
|
2068
2068
|
* subscriber of a SNAPSHOT with (message, name); a subscriber's throw
|
|
@@ -2086,8 +2086,8 @@ ScrStr *scr_dc_chan_name(double handle);
|
|
|
2086
2086
|
* handlers object's five event keys (truthy slots route to the per-channel
|
|
2087
2087
|
* add/remove — a non-function slot throws there, Node's order);
|
|
2088
2088
|
* unsubscribe answers Node's all-found conjunction. traceSync/traceCallback
|
|
2089
|
-
* mirror Node's publish choreography over the
|
|
2090
|
-
* lowering builds the default `{}`), fn/thisArg/args are
|
|
2089
|
+
* mirror Node's publish choreography over the checked-dynamic tree: ctx must be an OBJ (the
|
|
2090
|
+
* lowering builds the default `{}`), fn/thisArg/args are dyn values (args
|
|
2091
2091
|
* an ARR of the call arguments); the traced call binds thisArg as the
|
|
2092
2092
|
* ambient receiver; result/error stamp onto ctx before end/error publish;
|
|
2093
2093
|
* a traced throw and a subscriber throw both propagate (MAY THROW). All
|
|
@@ -2553,15 +2553,15 @@ double scr_os_ifaddrs_scopeid(const ScrIfaddrs *s, size_t i);
|
|
|
2553
2553
|
void scr_os_ifaddrs_free(ScrIfaddrs *s);
|
|
2554
2554
|
|
|
2555
2555
|
/* ── JSON + dynamic values (scr_json.c) ─────────────────────────────
|
|
2556
|
-
* A dyn value — the compiled form of `unknown` — is a refcounted JSON
|
|
2556
|
+
* A dyn value — the compiled form of `unknown` — is a refcounted JSON dyn
|
|
2557
2557
|
* tree: the result of JSON.parse, inert until a CHECKED CAST validates it
|
|
2558
2558
|
* against a static type. The compiler emits the validation walkers
|
|
2559
2559
|
* (sc_dc_* builders / sc_dm_* match predicates) and the type-directed
|
|
2560
2560
|
* stringify serializers (sc_jw_*) per program; this runtime slice provides
|
|
2561
|
-
* the
|
|
2561
|
+
* the checked-dynamic tree itself, the RFC 8259 parser, the shared failure path
|
|
2562
2562
|
* (scr_dyn_check_fail), and the output buffer the serializers append to.
|
|
2563
2563
|
*
|
|
2564
|
-
* Ownership: the
|
|
2564
|
+
* Ownership: the checked-dynamic tree owns its children (strings, items, entry keys+values);
|
|
2565
2565
|
* releasing the root releases the tree recursively. scr_json_parse borrows
|
|
2566
2566
|
* the text and returns +1 — or THROWS a catchable string shaped like Node's
|
|
2567
2567
|
* V8 messages ("Unexpected end of JSON input"; approximate fidelity, see
|
|
@@ -2577,15 +2577,15 @@ typedef enum {
|
|
|
2577
2577
|
SCR_DYN_ARR,
|
|
2578
2578
|
SCR_DYN_OBJ,
|
|
2579
2579
|
/* The undefined VALUE. Never produced by the parser (JSON text has no
|
|
2580
|
-
* undefined) — it enters the
|
|
2580
|
+
* undefined) — it enters the checked-dynamic tree through index-signature overflow reads
|
|
2581
2581
|
* (a missing key), optional-chain unit paths on dyn results, and the
|
|
2582
|
-
* compiler's static→
|
|
2582
|
+
* compiler's static→dyn converters (an undefined-armed union's unit
|
|
2583
2583
|
* arm). One immortal instance (scr_dyn_undefined); JSON serialization
|
|
2584
2584
|
* drops object members holding it and prints null for array slots,
|
|
2585
2585
|
* exactly Node. dynCheck matches it against exactly the undefined arm. */
|
|
2586
2586
|
SCR_DYN_UNDEF,
|
|
2587
2587
|
/* A Uint8Array/Buffer VALUE. Never produced by the parser — it enters
|
|
2588
|
-
* the
|
|
2588
|
+
* the checked-dynamic tree through the compiler's static→dyn converters (a bytes<u8>
|
|
2589
2589
|
* value flowing into an `unknown` slot: stdin chunks passed to
|
|
2590
2590
|
* unknown-typed helpers). Owns a ScrBytes payload (a COPY of the static
|
|
2591
2591
|
* source — the boundary's aliasing stance). typeof answers "object"
|
|
@@ -2594,13 +2594,13 @@ typedef enum {
|
|
|
2594
2594
|
* object form ({"0":1}), and dynCheck extracts a fresh copy against a
|
|
2595
2595
|
* Uint8Array target. */
|
|
2596
2596
|
SCR_DYN_BYTES,
|
|
2597
|
-
/* A FUNCTION value. Never produced by the parser — it enters the
|
|
2598
|
-
* through the compiler's static→
|
|
2597
|
+
/* A FUNCTION value. Never produced by the parser — it enters the checked-dynamic tree
|
|
2598
|
+
* through the compiler's static→dyn converters (a typed closure flowing
|
|
2599
2599
|
* into an `unknown` slot: `mustCall(fn)`-style untyped JS helpers). Owns
|
|
2600
2600
|
* a ScrClosure plus a compiler-emitted CALL THUNK that validates dyn
|
|
2601
2601
|
* arguments into the closure's declared parameter types (per-arg
|
|
2602
2602
|
* dynCheck — JS arity semantics: extra args ignored, missing args are
|
|
2603
|
-
* the undefined
|
|
2603
|
+
* the undefined dyn value) and converts the result back to a dyn value.
|
|
2604
2604
|
* `sig` is the compiler's interned signature key: dynCheck against an
|
|
2605
2605
|
* IDENTICAL function type unwraps the closure directly; any other
|
|
2606
2606
|
* (adaptable) function target wraps the box in a per-target adapter
|
|
@@ -2612,7 +2612,7 @@ typedef enum {
|
|
|
2612
2612
|
/* A NATIVE HANDLE value (httpReq/httpRes/netSocket crossing the checked-
|
|
2613
2613
|
* dynamic boundary — `server.on('request', mustCall((req, res) => ...))`
|
|
2614
2614
|
* makes the listener dyn, so the event tuple must box). Never produced
|
|
2615
|
-
* by the parser — it enters the
|
|
2615
|
+
* by the parser — it enters the checked-dynamic tree through the compiler's static→dyn
|
|
2616
2616
|
* converters and the per-target function adapters. Boxes by REFERENCE
|
|
2617
2617
|
* (a retained pointer + a handle-type tag): handles are stateful I/O
|
|
2618
2618
|
* objects, so identity is the HANDLE, not the box — strict equality
|
|
@@ -2627,12 +2627,12 @@ typedef enum {
|
|
|
2627
2627
|
* "[object Object]" (Object.prototype.toString — Node's answer for
|
|
2628
2628
|
* these classes), JSON serialization and util.inspect fence loudly. */
|
|
2629
2629
|
SCR_DYN_HANDLE,
|
|
2630
|
-
/* A PROMISE value. Never produced by the parser — it enters the
|
|
2631
|
-
* through the compiler's static→
|
|
2630
|
+
/* A PROMISE value. Never produced by the parser — it enters the checked-dynamic tree
|
|
2631
|
+
* through the compiler's static→dyn converters (a promise flowing into
|
|
2632
2632
|
* an `any`/`unknown` slot: the traced-function boundary of
|
|
2633
2633
|
* dc.tracingChannel.tracePromise, a dyn-boxed async closure's return).
|
|
2634
2634
|
* Boxes by REFERENCE (a retained ScrPromise + the boundary contract
|
|
2635
|
-
* that a
|
|
2635
|
+
* that a dyn-crossing promise settles with a dyn payload: promise<dyn>
|
|
2636
2636
|
* boxes its ScrPromise directly, other inner types box an ADAPTER
|
|
2637
2637
|
* promise whose emitted settle callback converts the payload — see
|
|
2638
2638
|
* scr_dyn_new_promise_adapting). Identity is the PROMISE, not the box
|
|
@@ -2646,31 +2646,31 @@ typedef enum {
|
|
|
2646
2646
|
* (the dyn→closure stance): a cycle THROUGH a dyn-boxed promise is
|
|
2647
2647
|
* merely never collected. */
|
|
2648
2648
|
SCR_DYN_PROMISE,
|
|
2649
|
-
/* An ISLAND (engine-held) value — the jsval→
|
|
2650
|
-
* produced by the parser — it enters the
|
|
2649
|
+
/* An ISLAND (engine-held) value — the jsval→dyn crossing. Never
|
|
2650
|
+
* produced by the parser — it enters the checked-dynamic tree through the gated
|
|
2651
2651
|
* constructor scr_dyn_from_jsval (scr_island.c): an 'any'-typed value
|
|
2652
2652
|
* flowing into an 'unknown'/'object'/JS-residue slot. Boxes by
|
|
2653
2653
|
* REFERENCE (a retained ScrJsval cell). The constructor SCALAR-
|
|
2654
2654
|
* NORMALIZES: engine numbers/strings/booleans/null/undefined convert
|
|
2655
|
-
* to the native
|
|
2655
|
+
* to the native dyn kinds at wrap time, so JSVAL nodes only ever hold
|
|
2656
2656
|
* engine objects, arrays, and functions (plus the symbol/bigint edge —
|
|
2657
|
-
* kinds the
|
|
2657
|
+
* kinds the checked-dynamic tree cannot represent at all). Identity is the CELL's
|
|
2658
2658
|
* engine value: strict equality routes to the engine's === (two wraps
|
|
2659
2659
|
* of one engine value compare equal), and scr_jsval_from_dyn unwraps
|
|
2660
2660
|
* the SAME cell back (+1) — the boundary is identity-preserving for
|
|
2661
2661
|
* engine-born values. typeof/truthiness/String() route to the engine
|
|
2662
|
-
* per use (scr_dyn_jsval_ops); every
|
|
2662
|
+
* per use (scr_dyn_jsval_ops); every dyn walk without an armed route
|
|
2663
2663
|
* (JSON, structuredClone, deepStrictEqual, inspect, keyed access,
|
|
2664
2664
|
* calls, iteration) throws the LOUD "not supported yet" ladder — never
|
|
2665
2665
|
* a silent wrong answer. The dyn→cell edge is NOT visible to the cycle
|
|
2666
|
-
* collector (the dyn→closure stance): a cycle
|
|
2667
|
-
* object → host closure →
|
|
2666
|
+
* collector (the dyn→closure stance): a cycle dyn → cell → engine
|
|
2667
|
+
* object → host closure → dyn is merely never collected (the
|
|
2668
2668
|
* documented cross-boundary-cycle divergence). Enum position: LAST —
|
|
2669
2669
|
* the LLVM backend hardcodes the preceding kind numbers. */
|
|
2670
2670
|
SCR_DYN_JSVAL,
|
|
2671
2671
|
} ScrDynKind;
|
|
2672
2672
|
|
|
2673
|
-
/* The handle-type tags the
|
|
2673
|
+
/* The handle-type tags the checked-dynamic tree can carry. The set is deliberately the
|
|
2674
2674
|
* HANDLE kinds whose member surfaces already have complete static
|
|
2675
2675
|
* lowerings (the http/net receiver surface); new kinds join by adding a
|
|
2676
2676
|
* tag + an ops registration in their owning unit. */
|
|
@@ -2681,6 +2681,8 @@ typedef enum {
|
|
|
2681
2681
|
SCR_DYNH_NET_SERVER, /* ScrNetServer — net.Server (http.Server rides the same handle) */
|
|
2682
2682
|
SCR_DYNH_H2_SESSION, /* ScrH2Session — Http2Session (client & server) */
|
|
2683
2683
|
SCR_DYNH_H2_STREAM, /* ScrH2Stream — Http2Stream (client & server) */
|
|
2684
|
+
SCR_DYNH_HTTP_CLIENT, /* ScrHttpClientReq — http.ClientRequest */
|
|
2685
|
+
SCR_DYNH_HTTP_AGENT, /* ScrHttpAgent — http.Agent / https.Agent */
|
|
2684
2686
|
SCR_DYNH_COUNT,
|
|
2685
2687
|
} ScrDynHandleTag;
|
|
2686
2688
|
|
|
@@ -2688,7 +2690,7 @@ typedef struct ScrDyn ScrDyn;
|
|
|
2688
2690
|
typedef struct ScrBytes ScrBytes; /* full definition below (C11 repeat) */
|
|
2689
2691
|
typedef struct ScrClosure ScrClosure; /* full definition below (C11 repeat) */
|
|
2690
2692
|
typedef struct ScrJsval ScrJsval; /* opaque island cell (C11 repeat; the
|
|
2691
|
-
* always-linked
|
|
2693
|
+
* always-linked dyn core never touches
|
|
2692
2694
|
* its engine value — only the gated ops
|
|
2693
2695
|
* installed by scr_dyn_from_jsval do) */
|
|
2694
2696
|
|
|
@@ -2696,7 +2698,7 @@ typedef struct ScrJsval ScrJsval; /* opaque island cell (C11 repeat; the
|
|
|
2696
2698
|
* dyn arguments against the boxed closure's declared parameter types (a
|
|
2697
2699
|
* mismatch throws the catchable path-annotated TypeError and returns NULL
|
|
2698
2700
|
* with the exception pending), calls through the closure, and returns the
|
|
2699
|
-
* result as an owned (+1)
|
|
2701
|
+
* result as an owned (+1) dyn value. `args` entries are BORROWED. */
|
|
2700
2702
|
typedef ScrDyn *(*ScrDynThunk)(ScrClosure *clo, ScrDyn *const *args, size_t argc);
|
|
2701
2703
|
|
|
2702
2704
|
/* Object member. Keys are malloc'd UTF-8 bytes (NUL-terminated for
|
|
@@ -2717,7 +2719,7 @@ struct ScrDyn {
|
|
|
2717
2719
|
* its elements ("1,2,3"). Everything else ignores it. */
|
|
2718
2720
|
bool buffer;
|
|
2719
2721
|
/* SCR_DYN_OBJ flavor: true for Object.create(null)'s dictionary — an
|
|
2720
|
-
* object with NO prototype. Method dispatch needs nothing (the
|
|
2722
|
+
* object with NO prototype. Method dispatch needs nothing (the checked-dynamic tree's
|
|
2721
2723
|
* OBJ dispatch is already own-member-only, which IS Node's null-proto
|
|
2722
2724
|
* answer); util.inspect prefixes "[Object: null prototype]", and
|
|
2723
2725
|
* deepStrictEqual separates it from plain objects (Node compares
|
|
@@ -2748,7 +2750,7 @@ struct ScrDyn {
|
|
|
2748
2750
|
* settle — the settle-releases-listeners story. */
|
|
2749
2751
|
struct { void *ptr; ScrDynHandleTag tag; } handle;
|
|
2750
2752
|
/* SCR_DYN_PROMISE: the retained promise. The boundary contract: it
|
|
2751
|
-
* settles with a
|
|
2753
|
+
* settles with a dyn payload (SCR_EXC_REF ScrDyn fulfillment or a
|
|
2752
2754
|
* void fulfillment awaiters read as the undefined value) — the
|
|
2753
2755
|
* emitted converters guarantee it (direct box for promise<dyn>,
|
|
2754
2756
|
* adapter promise otherwise). */
|
|
@@ -2776,22 +2778,22 @@ ScrDyn *scr_json_parse(ScrStr *text);
|
|
|
2776
2778
|
/* BORROWED member lookup on a SCR_DYN_OBJ; NULL when the key is absent. */
|
|
2777
2779
|
ScrDyn *scr_dyn_obj_get(const ScrDyn *d, const char *key, size_t key_len);
|
|
2778
2780
|
|
|
2779
|
-
/* Object.keys/values/entries over the
|
|
2780
|
-
* keys ascending first),
|
|
2781
|
+
/* Object.keys/values/entries over the checked-dynamic tree: JS own-key order (array-index
|
|
2782
|
+
* keys ascending first), dyn-array results (+1); values/entries RETAIN
|
|
2781
2783
|
* member nodes. null/undefined receivers throw Node's catchable
|
|
2782
2784
|
* TypeError. */
|
|
2783
2785
|
ScrDyn *scr_dyn_obj_keys(const ScrDyn *v);
|
|
2784
|
-
/* Object.hasOwn over a
|
|
2786
|
+
/* Object.hasOwn over a dyn receiver: OBJ member presence, ARR index
|
|
2785
2787
|
* bounds ("length" included); nullish receivers throw Node's ToObject
|
|
2786
2788
|
* TypeError; every other kind answers false. */
|
|
2787
2789
|
bool scr_dyn_has_own(const ScrDyn *v, const ScrStr *key);
|
|
2788
|
-
/* Object.assign over
|
|
2790
|
+
/* Object.assign over dyn values (+1 target back; ToObject TypeError on a
|
|
2789
2791
|
* nullish target). Sources copy their own enumerable keys exactly as
|
|
2790
2792
|
* Object.keys lists them: OBJ members, ARR/STR/BYTES index keys; nullish
|
|
2791
2793
|
* and scalar/function/handle sources copy nothing. */
|
|
2792
2794
|
ScrDyn *scr_dyn_assign(ScrDyn *target, const ScrDyn *src);
|
|
2793
2795
|
/* Variadic Object.assign (the spread-source form): the compiler packs
|
|
2794
|
-
* every source into one fresh
|
|
2796
|
+
* every source into one fresh dyn array — pack_push retains a plain
|
|
2795
2797
|
* source in (BORROWED), pack_push_spread flattens a spread source through
|
|
2796
2798
|
* the spread-call walk (V8's exact TypeError texts, `what` spelling the
|
|
2797
2799
|
* spread expression; MAY THROW pending) — then assign_all copies each
|
|
@@ -2807,8 +2809,8 @@ ScrDyn *scr_dyn_assign_all(ScrDyn *target, const ScrDyn *sources);
|
|
|
2807
2809
|
ScrDyn *scr_dyn_obj_values(const ScrDyn *v);
|
|
2808
2810
|
ScrDyn *scr_dyn_obj_entries(const ScrDyn *v);
|
|
2809
2811
|
|
|
2810
|
-
/*
|
|
2811
|
-
* and index-signature overflow machinery build
|
|
2812
|
+
/* dyn construction — the compiler-emitted static→dyn converters (sc_td_*)
|
|
2813
|
+
* and index-signature overflow machinery build dyn values directly.
|
|
2812
2814
|
* Constructors return +1; _new_str RETAINS the string into the node.
|
|
2813
2815
|
* arr_push and obj_set take OWNERSHIP of the value (+1 moves in); obj_set
|
|
2814
2816
|
* COPIES the key bytes and replaces a duplicate key's value (later wins,
|
|
@@ -2836,25 +2838,35 @@ ScrBytes *scr_dyn_bytes_copy_out(const ScrDyn *d);
|
|
|
2836
2838
|
void scr_dyn_arr_push(ScrDyn *arr, ScrDyn *item);
|
|
2837
2839
|
/* Spread completion for a runtime-arity argument list (`f(...xs)` in the
|
|
2838
2840
|
* checked-dynamic tier): flattens `src` into `arr` per JS's spread over the
|
|
2839
|
-
*
|
|
2841
|
+
* dyn's iterable kinds — arrays element-by-element (retained), strings by
|
|
2840
2842
|
* code POINT (the string iterator), bytes by byte — and throws V8's exact
|
|
2841
2843
|
* SPREAD-CALL TypeError for every other kind (pending; callers check):
|
|
2842
2844
|
* nullish sources spell the spread expression (`what`), everything else is
|
|
2843
2845
|
* the generic "Spread syntax requires ..." text. Borrows src. */
|
|
2844
2846
|
void scr_dyn_arr_push_spread(ScrDyn *arr, const ScrDyn *src, const char *what);
|
|
2845
|
-
/* Destructuring pack over a
|
|
2847
|
+
/* Destructuring pack over a dyn source: iterable kinds (arrays, strings by
|
|
2846
2848
|
* code point, bytes) collect into a fresh array (+1); every other kind
|
|
2847
2849
|
* throws V8's destructuring TypeError — `msg` verbatim when non-empty (the
|
|
2848
2850
|
* compile-time source spelling), else the runtime kind wording. Borrows
|
|
2849
2851
|
* both; NULL with the exception pending on the throw. */
|
|
2850
2852
|
ScrDyn *scr_dyn_iter_pack(const ScrDyn *src, const ScrStr *msg);
|
|
2853
|
+
/* The for-of-over-dyn pack accessors (the emitted index loop drives them
|
|
2854
|
+
* over a scr_dyn_iter_pack result, which is ARR by construction).
|
|
2855
|
+
* scr_dyn_arr_len answers 0 for non-ARR kinds; scr_dyn_arr_at answers the
|
|
2856
|
+
* undefined singleton past the end (both never throw). scr_dyn_arr_at is
|
|
2857
|
+
* +1. */
|
|
2858
|
+
double scr_dyn_arr_len(const ScrDyn *d);
|
|
2859
|
+
ScrDyn *scr_dyn_arr_at(const ScrDyn *d, double i);
|
|
2851
2860
|
void scr_dyn_obj_set(ScrDyn *obj, const char *key, size_t key_len, ScrDyn *value);
|
|
2852
2861
|
/* The checked-dynamic keyed WRITE (`h.k = v` on a dyn receiver): OBJ sets
|
|
2853
2862
|
* the member (JS: later writes win, insertion order); undefined/null and
|
|
2854
2863
|
* non-object kinds throw Node's catchable TypeErrors (strict-mode
|
|
2855
2864
|
* wording). All three operands BORROWED (the value is retained in). */
|
|
2856
2865
|
void scr_dyn_key_set(ScrDyn *recv, ScrStr *key, ScrDyn *value);
|
|
2857
|
-
/*
|
|
2866
|
+
/* `key in v` with a runtime key — the dynHasKey fold per value (OBJ own
|
|
2867
|
+
* members, ARR length/valid indices, false elsewhere). Never throws. */
|
|
2868
|
+
bool scr_dyn_has_key(const ScrDyn *v, const ScrStr *key);
|
|
2869
|
+
/* Bare `typeof v` on a dyn value: the dyn kind's JS answer (+1 string;
|
|
2858
2870
|
* null answers "object"). Never throws. */
|
|
2859
2871
|
ScrStr *scr_dyn_typeof(const ScrDyn *d);
|
|
2860
2872
|
/* Receiver-kind-dispatched toString() (Buffer-flavored bytes decode per
|
|
@@ -2865,7 +2877,7 @@ ScrStr *scr_dyn_to_string(const ScrDyn *d, const ScrStr *enc);
|
|
|
2865
2877
|
* null-prototype dictionary throws "<what> is not a function" — its
|
|
2866
2878
|
* prototype chain has no toString (Node's answer). */
|
|
2867
2879
|
ScrStr *scr_dyn_to_string_method(const ScrDyn *d, const ScrStr *enc, const ScrStr *what);
|
|
2868
|
-
/* JS String() over the
|
|
2880
|
+
/* JS String() over the dyn kind (units render "null"/"undefined" where
|
|
2869
2881
|
* scr_dyn_to_string throws) — the web globals' WebIDL ToString. +1. */
|
|
2870
2882
|
ScrStr *scr_dyn_string_coerce(const ScrDyn *d);
|
|
2871
2883
|
/* JS ToString WITH the object protocol (user toString/valueOf members
|
|
@@ -2874,14 +2886,14 @@ ScrStr *scr_dyn_string_coerce(const ScrDyn *d);
|
|
|
2874
2886
|
ScrStr *scr_dyn_string_coerce_js(const ScrDyn *d);
|
|
2875
2887
|
|
|
2876
2888
|
/* `d instanceof TypeError` (and the other builtin error classes) on a
|
|
2877
|
-
* checked-dynamic value: the from_error cache resolves the
|
|
2889
|
+
* checked-dynamic value: the from_error cache resolves the dyn encoding
|
|
2878
2890
|
* back to its runtime error and the class's stamped preorder interval
|
|
2879
|
-
* answers. A
|
|
2891
|
+
* answers. A dyn value that never came from an error answers false. */
|
|
2880
2892
|
bool scr_dyn_err_instanceof(const ScrDyn *d, double kind);
|
|
2881
2893
|
|
|
2882
|
-
/* structuredClone over the
|
|
2894
|
+
/* structuredClone over the checked-dynamic tree: JSON-safe data + bytes deep-copy;
|
|
2883
2895
|
* functions/handles throw the spec's catchable DataCloneError; cycles
|
|
2884
|
-
* throw the scriptc fence (the
|
|
2896
|
+
* throw the scriptc fence (the checked-dynamic tree cannot represent them). Option
|
|
2885
2897
|
* validation (shared with scr_domex_clone) throws Node's exact
|
|
2886
2898
|
* TypeErrors; any non-empty transfer list throws DataCloneError. The
|
|
2887
2899
|
* _missing form is the zero-argument call: always throws Node's
|
|
@@ -2889,13 +2901,13 @@ bool scr_dyn_err_instanceof(const ScrDyn *d, double kind);
|
|
|
2889
2901
|
ScrDyn *scr_structured_clone(const ScrDyn *value, const ScrDyn *options);
|
|
2890
2902
|
ScrDyn *scr_structured_clone_missing(void);
|
|
2891
2903
|
ScrDyn *scr_structured_clone_transfer_fail(void); /* always throws DataCloneError */
|
|
2892
|
-
/* Validates a structuredClone options
|
|
2904
|
+
/* Validates a structuredClone options dyn value (throws on failure —
|
|
2893
2905
|
* callers must check scr_exc_pending). Borrowed, NULL-tolerant. */
|
|
2894
2906
|
void scr_sc_validate_options(const ScrDyn *options);
|
|
2895
|
-
/* An %Error as the boundary's
|
|
2907
|
+
/* An %Error as the boundary's dyn shape ({name, message[, code]}).
|
|
2896
2908
|
* Borrows; +1. */
|
|
2897
2909
|
ScrDyn *scr_dyn_from_error(const ScrError *e);
|
|
2898
|
-
/* The reverse extraction, riding the same identity cache: a
|
|
2910
|
+
/* The reverse extraction, riding the same identity cache: a dyn error
|
|
2899
2911
|
* that came from a runtime ScrError answers THAT instance (+1;
|
|
2900
2912
|
* out-and-back crossings compare reference-equal); alien %error objects
|
|
2901
2913
|
* rebuild once and enter the cache. Borrows d. */
|
|
@@ -2904,16 +2916,16 @@ ScrError *scr_error_from_dyn(const ScrDyn *d); /* scr_async_dyn.c (gated) */
|
|
|
2904
2916
|
* the gated extraction reads/writes through these). */
|
|
2905
2917
|
ScrError *scr_errdyn_err_of(const ScrDyn *d); /* +1 or NULL */
|
|
2906
2918
|
void scr_errdyn_put(ScrError *e, ScrDyn *d); /* retains both sides */
|
|
2907
|
-
/* ToBoolean over the
|
|
2919
|
+
/* ToBoolean over the dyn kind (JS-exact); borrowed, never throws. */
|
|
2908
2920
|
bool scr_dyn_truthy(const ScrDyn *d);
|
|
2909
|
-
/* JS String() over a
|
|
2921
|
+
/* JS String() over a dyn value (arrays join, [object Object], the error
|
|
2910
2922
|
* encoding renders "name: message"); borrowed, result +1, never throws. */
|
|
2911
2923
|
ScrStr *scr_dyn_display(const ScrDyn *d);
|
|
2912
|
-
/* JS === over two
|
|
2924
|
+
/* JS === over two dyn values: scalars by value, units by kind, everything
|
|
2913
2925
|
* reference-shaped by node identity. Borrowed; never throws. */
|
|
2914
2926
|
bool scr_dyn_strict_eq(const ScrDyn *a, const ScrDyn *b);
|
|
2915
2927
|
/* Prototype-method dispatch on a dyn receiver (`recv.m(...)` where `m` is
|
|
2916
|
-
* a name a
|
|
2928
|
+
* a name a dyn-representable prototype declares — push/slice/forEach/
|
|
2917
2929
|
* apply/...): implemented (kind, name) pairs run JS-exact semantics; a
|
|
2918
2930
|
* real-but-unimplemented method throws a LOUD "not supported yet" Error;
|
|
2919
2931
|
* a name the kind's prototype lacks throws Node's "<what> is not a
|
|
@@ -2925,14 +2937,14 @@ ScrDyn *scr_dyn_invoke(ScrDyn *recv, const char *method, ScrDyn *const *args, si
|
|
|
2925
2937
|
* for anonymous) and "length" (the boxed arity). Returns +1, or NULL when
|
|
2926
2938
|
* the key answers nothing (the caller's undefined). Never throws. */
|
|
2927
2939
|
ScrDyn *scr_dyn_fn_get(const ScrDyn *d, const char *key, size_t key_len);
|
|
2928
|
-
/* Object.defineProperties over
|
|
2940
|
+
/* Object.defineProperties over dyn values (targets: OBJ and FUNC): each
|
|
2929
2941
|
* descriptor's `value` becomes a plain own property — writable/enumerable/
|
|
2930
|
-
* configurable are accepted and IGNORED (
|
|
2942
|
+
* configurable are accepted and IGNORED (dyn properties are plain data
|
|
2931
2943
|
* properties; SEMANTICS.md), get/set throw the loud unsupported Error.
|
|
2932
2944
|
* Returns the target (+1, JS's return), or NULL with a pending catchable
|
|
2933
2945
|
* TypeError (non-object target/descriptor — Node's messages). */
|
|
2934
2946
|
ScrDyn *scr_dyn_define_props(ScrDyn *target, ScrDyn *descs);
|
|
2935
|
-
/* Boxes a closure as a callable
|
|
2947
|
+
/* Boxes a closure as a callable dyn value. Ownership of `clo` MOVES in
|
|
2936
2948
|
* (callers retain first when they keep their own reference); `sig`/`name`
|
|
2937
2949
|
* must be static literals (the box never frees them; name may be NULL). */
|
|
2938
2950
|
ScrDyn *scr_dyn_new_func(ScrClosure *clo, ScrDynThunk thunk, uint32_t arity, const char *sig, const char *name);
|
|
@@ -2942,7 +2954,7 @@ ScrDyn *scr_dyn_new_func(ScrClosure *clo, ScrDynThunk thunk, uint32_t arity, con
|
|
|
2942
2954
|
* boxed thunk (per-arg checks live there). `args` entries are BORROWED;
|
|
2943
2955
|
* the result is owned (+1), or NULL with the exception pending. */
|
|
2944
2956
|
ScrDyn *scr_dyn_call(const ScrDyn *d, ScrDyn *const *args, size_t argc, const char *what);
|
|
2945
|
-
/* scr_dyn_call over a
|
|
2957
|
+
/* scr_dyn_call over a dyn ARRAY's elements (the spread-application form —
|
|
2946
2958
|
* `f(...args)` after the emitted argument array is built): argv IS the
|
|
2947
2959
|
* array's items. Borrows both; result owned (+1), or NULL pending. */
|
|
2948
2960
|
ScrDyn *scr_dyn_apply(const ScrDyn *d, const ScrDyn *args, const char *what);
|
|
@@ -2964,7 +2976,7 @@ typedef struct ScrDynPath {
|
|
|
2964
2976
|
* scriptc-specific behavior — JS `as` never checks (SEMANTICS.md). */
|
|
2965
2977
|
void scr_dyn_check_fail(const ScrDynPath *path, const char *want, const ScrDyn *got);
|
|
2966
2978
|
|
|
2967
|
-
/* ── native handles in the
|
|
2979
|
+
/* ── native handles in the checked-dynamic tree (SCR_DYN_HANDLE) ────────────────────────
|
|
2968
2980
|
* Per-tag dispatch ops, registered by the handle's owning unit
|
|
2969
2981
|
* (scr_http_dyn_install / scr_net_dyn_install — emitted main() calls
|
|
2970
2982
|
* them exactly when the unit is linked, the scr_net_install story), so
|
|
@@ -2983,7 +2995,7 @@ typedef struct ScrDynHandleOps {
|
|
|
2983
2995
|
ScrDyn *(*invoke)(void *h, ScrDyn *self, const char *method, ScrDyn *const *args, size_t argc, const char *what);
|
|
2984
2996
|
/* Property READ with a static equivalent (req.url, res.statusCode):
|
|
2985
2997
|
* +1 boxed value; NULL = no such modeled property (the caller answers
|
|
2986
|
-
* the undefined singleton — the
|
|
2998
|
+
* the undefined singleton — the checked-dynamic tree's own-property stance); may throw
|
|
2987
2999
|
* the loud ladder for real-but-unmodeled names (NULL + pending). */
|
|
2988
3000
|
ScrDyn *(*get)(void *h, const char *key, size_t key_len);
|
|
2989
3001
|
/* Property WRITE with a static equivalent (res.statusCode = 200):
|
|
@@ -3019,13 +3031,13 @@ ScrDyn *scr_dyn_new_handle(void *h, ScrDynHandleTag tag);
|
|
|
3019
3031
|
void *scr_dyn_handle_unbox(const ScrDyn *d, ScrDynHandleTag tag, const ScrDynPath *path, const char *want);
|
|
3020
3032
|
/* Keyed read on a HANDLE box (the emitted sc_dyn_key_get's arm): the
|
|
3021
3033
|
* tag's modeled properties answer boxed values; everything else answers
|
|
3022
|
-
* the undefined singleton (the
|
|
3034
|
+
* the undefined singleton (the checked-dynamic tree's own-property stance — SEMANTICS.md)
|
|
3023
3035
|
* unless the ops fence it loudly. +1, or NULL with a pending exception. */
|
|
3024
3036
|
ScrDyn *scr_dyn_handle_key_get(const ScrDyn *d, const ScrStr *k);
|
|
3025
3037
|
|
|
3026
|
-
/* ── promises in the
|
|
3038
|
+
/* ── promises in the checked-dynamic tree (SCR_DYN_PROMISE) ────────────────────────────
|
|
3027
3039
|
* Boxes by REFERENCE (+1 box; retains p). The boundary contract: p
|
|
3028
|
-
* settles with a
|
|
3040
|
+
* settles with a dyn payload — promise<dyn> boxes directly; other inner
|
|
3029
3041
|
* types go through scr_dyn_new_promise_adapting, which parks an emitted
|
|
3030
3042
|
* payload-converting adapter (the Promise.race cb-waiter machinery) on
|
|
3031
3043
|
* `src` and boxes the fresh destination promise instead. Rejections copy
|
|
@@ -3042,7 +3054,7 @@ ScrDyn *scr_dyn_new_promise_adapting(ScrPromise *src,
|
|
|
3042
3054
|
/* BORROWED peek at the boxed promise; NULL when d is not a promise box. */
|
|
3043
3055
|
ScrPromise *scr_dyn_promise_of(const ScrDyn *d);
|
|
3044
3056
|
|
|
3045
|
-
/* ── island values in the
|
|
3057
|
+
/* ── island values in the checked-dynamic tree (SCR_DYN_JSVAL) ─────────────────────────
|
|
3046
3058
|
* Engine routing ops for JSVAL nodes, installed by the gated constructor
|
|
3047
3059
|
* (scr_dyn_from_jsval, scr_island.c — the scr_dyn_alloc_promise hook
|
|
3048
3060
|
* story: JSVAL nodes exist only after the constructor ran, so the ops
|
|
@@ -3062,7 +3074,7 @@ typedef struct ScrDynJsvalOps {
|
|
|
3062
3074
|
/* ── the routed operation set (lane dyn-routing-ops) ────────────────
|
|
3063
3075
|
* Each routes to the engine at the moment of use and converts at the
|
|
3064
3076
|
* boundary: dyn ARGUMENTS cross through scr_jsval_from_dyn (wrapped
|
|
3065
|
-
* cells unwrap by reference,
|
|
3077
|
+
* cells unwrap by reference, dyn data deep-copies, dyn FUNC boxes
|
|
3066
3078
|
* cross through the generic host-function shim), engine RESULTS come
|
|
3067
3079
|
* back through scr_dyn_from_jsval (scalar-normalizing). Fallible ops
|
|
3068
3080
|
* bridge the ENGINE's exception catchably and answer NULL/false/-1. */
|
|
@@ -3077,19 +3089,28 @@ typedef struct ScrDynJsvalOps {
|
|
|
3077
3089
|
bool (*is_nullish)(ScrJsval *cell); /* engine undefined/null; never throws
|
|
3078
3090
|
* (always false today — the wrap
|
|
3079
3091
|
* constructor scalar-normalizes) */
|
|
3080
|
-
/* Object.keys/values/entries (mode 0/1/2) as a NATIVE
|
|
3081
|
-
* keys are
|
|
3082
|
-
*
|
|
3092
|
+
/* Object.keys/values/entries (mode 0/1/2) as a NATIVE dyn array (+1):
|
|
3093
|
+
* keys are dyn strings, values wrap per element, entries are native
|
|
3094
|
+
* dyn pairs. NULL with the engine's exception pending on refusal. */
|
|
3083
3095
|
ScrDyn *(*obj_walk)(ScrJsval *cell, int mode);
|
|
3084
3096
|
int (*has_own)(ScrJsval *cell, const ScrStr *k); /* 0/1; -1 = pending */
|
|
3085
3097
|
/* Object.assign(target, src) with the ENGINE target: src converts per
|
|
3086
|
-
* member semantics (a wrapped src spreads by reference;
|
|
3098
|
+
* member semantics (a wrapped src spreads by reference; dyn data
|
|
3087
3099
|
* enters as the usual deep copy). false = pending. */
|
|
3088
3100
|
bool (*assign)(ScrJsval *cell, const ScrDyn *src);
|
|
3089
3101
|
/* JSON.stringify text of the engine value (+1) — the engine's own
|
|
3090
3102
|
* stringify (toJSON protocols, cycle TypeErrors). NULL + pending when
|
|
3091
3103
|
* not JSON-representable. */
|
|
3092
3104
|
ScrStr *(*to_json)(ScrJsval *cell);
|
|
3105
|
+
/* Drain the ENGINE's own iterator protocol into a fresh dyn array
|
|
3106
|
+
* (elements wrap back scalar-normalized) — the for-of/destructuring/
|
|
3107
|
+
* spread arm over a wrapped value. The guard's TypeError wording on a
|
|
3108
|
+
* non-iterable: spread true takes V8's spread-call text; otherwise the
|
|
3109
|
+
* compile-time spelling `spell` verbatim when non-NULL (the named-
|
|
3110
|
+
* source form), else the kind wording. An iterating getter/next throw
|
|
3111
|
+
* bridges with the ENGINE's message. +1, or NULL with the exception
|
|
3112
|
+
* pending. */
|
|
3113
|
+
ScrDyn *(*iter_drain)(ScrJsval *cell, bool spread, const ScrStr *spell);
|
|
3093
3114
|
} ScrDynJsvalOps;
|
|
3094
3115
|
|
|
3095
3116
|
/* The allocator view the gated constructor uses (installs the ops);
|
|
@@ -3115,7 +3136,7 @@ bool scr_dyn_isl_fence(const ScrDyn *d, const char *what);
|
|
|
3115
3136
|
* normalized) — the retired `.length -> fence` row. d MUST be a JSVAL
|
|
3116
3137
|
* node; NULL with the engine's exception bridged catchably. */
|
|
3117
3138
|
ScrDyn *scr_dyn_isl_key_get(const ScrDyn *d, const ScrStr *k);
|
|
3118
|
-
/* The `??`/optional-chain nullish test over a
|
|
3139
|
+
/* The `??`/optional-chain nullish test over a dyn value: UNDEF/NULL
|
|
3119
3140
|
* native, JSVAL through the engine's own test (defensively — the wrap
|
|
3120
3141
|
* constructor scalar-normalizes engine null/undefined away), every other
|
|
3121
3142
|
* kind false. Never throws. */
|
|
@@ -3141,7 +3162,7 @@ bool scr_dyn_is_nullish(const ScrDyn *d);
|
|
|
3141
3162
|
void scr_dyn_this_push(void *h, ScrDynHandleTag tag); /* h BORROWED (the firing site holds it); NULL binds undefined */
|
|
3142
3163
|
void scr_dyn_this_push_dyn(const ScrDyn *v); /* retained for the window */
|
|
3143
3164
|
void scr_dyn_this_pop(void);
|
|
3144
|
-
/* The innermost binding as a
|
|
3165
|
+
/* The innermost binding as a dyn value (+1): a boxed handle, the pushed
|
|
3145
3166
|
* dyn value, or the undefined singleton (empty stack, NULL handle, or a
|
|
3146
3167
|
* handle whose tag has no installed ops — a unit that fires without its
|
|
3147
3168
|
* dyn half never binds). */
|
|
@@ -3153,7 +3174,7 @@ ScrDyn *scr_dyn_this_get(void);
|
|
|
3153
3174
|
void scr_dyn_chunk_enc(bool utf8);
|
|
3154
3175
|
ScrDyn *scr_dyn_new_chunk(const ScrBytes *b);
|
|
3155
3176
|
|
|
3156
|
-
/* util.format's %j over a
|
|
3177
|
+
/* util.format's %j over a dyn value: the JSON.stringify text (+1),
|
|
3157
3178
|
* "undefined" when the root drops (undefined/function), or NULL with a
|
|
3158
3179
|
* pending exception (a runtime handle inside the tree fences loudly). */
|
|
3159
3180
|
ScrStr *scr_dyn_format_j(const ScrDyn *d);
|
|
@@ -3191,7 +3212,7 @@ void scr_throw_lowering_fence(const ScrStr *msg);
|
|
|
3191
3212
|
size_t scr_num_received(double v, char out[48]);
|
|
3192
3213
|
/* Listener-closure builders for the handle dispatchers' .on(...) paths:
|
|
3193
3214
|
* a runtime-built ScrClosure whose capture is the boxed dyn listener and
|
|
3194
|
-
* whose invoke boxes the event tuple back into the
|
|
3215
|
+
* whose invoke boxes the event tuple back into the checked-dynamic tree and calls through
|
|
3195
3216
|
* the checked-dynamic machinery. The matching fn-pointer shapes are the
|
|
3196
3217
|
* per-event thunk types the registration entries take (fire0's zero-arg
|
|
3197
3218
|
* convention / ScrNetDataFn / ScrChildErrFn). cb borrowed; result +1. */
|
|
@@ -3250,7 +3271,7 @@ void scr_jb_edge_idx(ScrJsonBuf *b, size_t i);
|
|
|
3250
3271
|
|
|
3251
3272
|
/* Circular guard for the compiler-emitted typed→dyn converters (sc_td_*
|
|
3252
3273
|
* over cycle-capable containers): enter TRAPS on a value already being
|
|
3253
|
-
* converted (a cyclic value has no finite
|
|
3274
|
+
* converted (a cyclic value has no finite dyn copy — Node shares the
|
|
3254
3275
|
* reference instead; SEMANTICS.md), else pushes. */
|
|
3255
3276
|
void scr_dyn_from_enter(const void *v);
|
|
3256
3277
|
void scr_dyn_from_leave(void);
|
|
@@ -3269,7 +3290,7 @@ void scr_jb_put_json_str(ScrJsonBuf *b, const ScrStr *s);
|
|
|
3269
3290
|
* the exception PENDING and appends nothing — the loud path, never a
|
|
3270
3291
|
* fabricated rendering. */
|
|
3271
3292
|
void scr_dyn_isl_tostr_buf(ScrJsonBuf *b, const ScrDyn *d);
|
|
3272
|
-
/* JSON-serialize a
|
|
3293
|
+
/* JSON-serialize a dyn value into the buffer — the sc_jw_* walker for the
|
|
3273
3294
|
* dyn leaves the compiler cannot type: object members holding undefined
|
|
3274
3295
|
* DROP, array slots holding undefined print null (exactly Node). */
|
|
3275
3296
|
void scr_jb_put_dyn(ScrJsonBuf *b, const ScrDyn *d);
|
|
@@ -3313,23 +3334,23 @@ bool scr_await_bool(ScrPromise *p);
|
|
|
3313
3334
|
ScrStr *scr_await_str(ScrPromise *p); /* +1 */
|
|
3314
3335
|
void *scr_await_ref(ScrPromise *p); /* +1 via the stored retain */
|
|
3315
3336
|
void scr_await_void(ScrPromise *p);
|
|
3316
|
-
/* The
|
|
3317
|
-
* payload as a
|
|
3337
|
+
/* The checked-dynamic tree-crossing await (SCR_DYN_PROMISE's boundary contract): the
|
|
3338
|
+
* payload as a dyn value (+1; void fulfillments answer the undefined
|
|
3318
3339
|
* value), or NULL with the rejection re-thrown into the awaiter. */
|
|
3319
3340
|
ScrDyn *scr_await_dyn(ScrPromise *p);
|
|
3320
|
-
/* `await v` over a checked-dynamic VALUE:
|
|
3341
|
+
/* `await v` over a checked-dynamic VALUE: dyn promises adopt, everything
|
|
3321
3342
|
* else takes JS's one-hop non-thenable await and answers itself (+1). */
|
|
3322
3343
|
ScrDyn *scr_await_dyn_value(ScrDyn *v);
|
|
3323
|
-
/* .then/.catch/.finally over a
|
|
3344
|
+
/* .then/.catch/.finally over a dyn promise (scr_dyn_invoke's promise arm
|
|
3324
3345
|
* and the compiled dyn-receiver path): one reaction fiber per
|
|
3325
|
-
* registration — awaits src, runs the
|
|
3326
|
-
* pass the settlement through; a returned
|
|
3346
|
+
* registration — awaits src, runs the checked-dynamic tree handler (non-callable handlers
|
|
3347
|
+
* pass the settlement through; a returned dyn promise is adopted), and
|
|
3327
3348
|
* settles a fresh result promise, answered BOXED (+1). Microtask-exact
|
|
3328
3349
|
* ordering rides the fiber machinery. */
|
|
3329
3350
|
ScrDyn *scr_dyn_promise_then(ScrPromise *src, ScrDyn *onf, ScrDyn *onr, ScrDyn *onfin);
|
|
3330
3351
|
/* ── AsyncLocalStorage (node:async_hooks — scr_async.c) ───────────────
|
|
3331
3352
|
* Stores are process-lived f64 handles; the CONTEXT is an immutable
|
|
3332
|
-
* refcounted snapshot of (store →
|
|
3353
|
+
* refcounted snapshot of (store → dyn value) entries riding the fiber
|
|
3333
3354
|
* machinery: one active-slot pointer (the exc-cell pattern) swapped at
|
|
3334
3355
|
* every fiber switch, inherited by spawned fibers (Node's init-time
|
|
3335
3356
|
* capture). enter answers the PREVIOUS snapshot (owned) for restore —
|
|
@@ -3357,30 +3378,51 @@ ScrAlsCtx *scr_als_enter_absent(double id); /* exit()'s cleared arm */
|
|
|
3357
3378
|
void scr_als_restore(ScrAlsCtx *prev); /* moves prev back in */
|
|
3358
3379
|
void scr_als_enter_with(double id, ScrDyn *value); /* no restore point (enterWith) */
|
|
3359
3380
|
void scr_als_disable(double id);
|
|
3360
|
-
/* run/exit: enter (or clear), call the
|
|
3381
|
+
/* run/exit: enter (or clear), call the dyn function with the forwarded
|
|
3361
3382
|
* argument vector, restore (the finally). Result +1 or NULL pending. */
|
|
3362
3383
|
ScrDyn *scr_als_run(double id, ScrDyn *value, ScrDyn *fn, ScrDyn *args);
|
|
3363
3384
|
ScrDyn *scr_als_exit_run(double id, ScrDyn *fn, ScrDyn *args);
|
|
3364
3385
|
|
|
3365
|
-
/* process.on('unhandledRejection', fn):
|
|
3366
|
-
* never-observed rejection at loop end — (reason, promise),
|
|
3367
|
-
* the default report and the exit-1 (Node's handled-event
|
|
3368
|
-
* end-of-turn vs loop-end timing is a SEMANTICS.md
|
|
3369
|
-
*
|
|
3370
|
-
|
|
3386
|
+
/* process.on/once('unhandledRejection', fn): dyn listeners dispatched
|
|
3387
|
+
* per never-observed rejection at loop end — (reason, promise),
|
|
3388
|
+
* suppressing the default report and the exit-1 (Node's handled-event
|
|
3389
|
+
* contract; the end-of-turn vs loop-end timing is a SEMANTICS.md
|
|
3390
|
+
* divergence). `once` auto-removes after one delivery; off removes by
|
|
3391
|
+
* closure identity (the warning registry's story). Throws Node's
|
|
3392
|
+
* ERR_INVALID_ARG_TYPE on a non-function. */
|
|
3393
|
+
void scr_process_on_unhandled_rejection(ScrDyn *fn, bool once);
|
|
3394
|
+
void scr_process_off_unhandled_rejection(ScrDyn *fn);
|
|
3395
|
+
/* process.on/once/off('rejectionHandled', fn): the sibling registry.
|
|
3396
|
+
* Under the loop-exhaustion model the event's ONE firing window is a
|
|
3397
|
+
* handler attached DURING an unhandledRejection listener (a rejection
|
|
3398
|
+
* handled any earlier never enters the report at all — the same
|
|
3399
|
+
* documented divergence); dispatch is synchronous at the attach, with
|
|
3400
|
+
* the promise, Node's payload. */
|
|
3401
|
+
void scr_process_on_rejection_handled(ScrDyn *fn, bool once);
|
|
3402
|
+
void scr_process_off_rejection_handled(ScrDyn *fn);
|
|
3371
3403
|
/* The loop-end delivery hook the registration above installs
|
|
3372
3404
|
* (scr_async_dyn.c → scr_report_unhandled_rejections; NULL = default
|
|
3373
3405
|
* report). Runtime-internal. */
|
|
3374
3406
|
extern bool (*scr_urj_deliver_fn)(ScrPromise *p);
|
|
3375
|
-
/*
|
|
3407
|
+
/* The late-handled hook (scr_async_dyn.c installs it when a
|
|
3408
|
+
* 'rejectionHandled' listener registers): scr_async.c calls it when a
|
|
3409
|
+
* promise the report already delivered as unhandled gains a handler.
|
|
3410
|
+
* Runtime-internal. */
|
|
3411
|
+
extern void (*scr_rjh_notify_fn)(ScrPromise *p);
|
|
3412
|
+
/* The attach-time handled mark (a dyn then/catch carrying a rejection
|
|
3413
|
+
* handler): marks an already-rejected source observed — Node's attach
|
|
3414
|
+
* moment — firing the late-handled hook when the report already
|
|
3415
|
+
* delivered it. Runtime-internal. */
|
|
3416
|
+
void scr_promise_mark_handled(ScrPromise *p);
|
|
3417
|
+
/* A rejected promise's reason as a dyn value (identity-preserving for
|
|
3376
3418
|
* dyn payloads and %Error instances). +1. */
|
|
3377
3419
|
ScrDyn *scr_promise_reason_dyn(const ScrPromise *p);
|
|
3378
3420
|
/* process warnings (scr_lib.c — always linked so any unit can emit a
|
|
3379
|
-
* deprecation):
|
|
3421
|
+
* deprecation): dyn listeners plus Node's default stderr report
|
|
3380
3422
|
* ("(node:pid) [CODE] Name: message" and a detail second line). Emission
|
|
3381
3423
|
* is SYNCHRONOUS at the call (Node defers a tick — SEMANTICS.md 138's
|
|
3382
3424
|
* precedent). scr_process_emit_warning takes the ARGUMENT VECTOR as one
|
|
3383
|
-
*
|
|
3425
|
+
* dyn array and applies Node's full grammar/TypeErrors; scr_emit_warning
|
|
3384
3426
|
* is the C-side deprecation entry. */
|
|
3385
3427
|
void scr_process_on_warning(ScrDyn *fn);
|
|
3386
3428
|
void scr_process_off_warning(ScrDyn *fn);
|
|
@@ -3460,7 +3502,7 @@ void scr_set_timeout(ScrClosure *cb, double ms); /* cb ownership moves in */
|
|
|
3460
3502
|
* works). An unknown handle is a no-op, like Node. */
|
|
3461
3503
|
double scr_set_interval(ScrClosure *cb, double ms); /* cb ownership moves in */
|
|
3462
3504
|
/* `new Promise(setImmediate)`: a fresh promise an armed immediate
|
|
3463
|
-
* fulfills with the undefined
|
|
3505
|
+
* fulfills with the undefined dyn value (+1). */
|
|
3464
3506
|
ScrPromise *scr_immediate_promise(void);
|
|
3465
3507
|
void scr_clear_interval(double handle);
|
|
3466
3508
|
/* The island timer bridge (scr_web.c): a one-shot entry WITH a clear
|
|
@@ -3497,7 +3539,7 @@ double scr_set_immediate(ScrClosure *cb); /* cb ownership moves in */
|
|
|
3497
3539
|
* synchronously on a non-function; borrowed. */
|
|
3498
3540
|
void scr_queue_microtask(ScrClosure *cb);
|
|
3499
3541
|
void scr_queue_microtask_dyn(const ScrDyn *cb);
|
|
3500
|
-
/* setImmediate AS A
|
|
3542
|
+
/* setImmediate AS A dyn VALUE (the traceCallback shape): a minted dyn
|
|
3501
3543
|
* callable that schedules args[0](args[1..]) on the immediate queue and
|
|
3502
3544
|
* answers undefined; a non-function first argument throws Node's
|
|
3503
3545
|
* ERR_INVALID_ARG_TYPE. Result +1. */
|
|
@@ -3947,24 +3989,24 @@ ScrJsval *scr_jsval_from_f64(double v);
|
|
|
3947
3989
|
ScrJsval *scr_jsval_from_bool(bool v);
|
|
3948
3990
|
ScrJsval *scr_jsval_from_str(const ScrStr *s);
|
|
3949
3991
|
ScrJsval *scr_jsval_from_json(const ScrStr *json);
|
|
3950
|
-
/* A CHECKED-DYNAMIC (
|
|
3992
|
+
/* A CHECKED-DYNAMIC (dyn) value entering the island — deep copy for data
|
|
3951
3993
|
* kinds (a boxed handle/promise throws the catchable TypeError). A JSVAL
|
|
3952
3994
|
* node unwraps to its OWN cell (+1) — an engine value that crossed into
|
|
3953
|
-
* the
|
|
3995
|
+
* the checked-dynamic tree and back is the SAME engine value, by reference (nested JSVAL
|
|
3954
3996
|
* members embed their engine values directly). A boxed FUNCTION crosses
|
|
3955
3997
|
* as one generic host-function shim over its uniform ScrDynThunk: the
|
|
3956
|
-
* shim wraps engine arguments as
|
|
3957
|
-
* the thunk, and converts the
|
|
3998
|
+
* shim wraps engine arguments as dyn values (scalar-normalizing), calls
|
|
3999
|
+
* the thunk, and converts the dyn result back — each crossing mints a
|
|
3958
4000
|
* fresh engine function (identity is not preserved for re-crossings;
|
|
3959
4001
|
* SEMANTICS.md). NULL with a pending exception on failure. Borrows d. */
|
|
3960
4002
|
ScrJsval *scr_jsval_from_dyn(const ScrDyn *d);
|
|
3961
4003
|
|
|
3962
|
-
/* The jsval→
|
|
4004
|
+
/* The jsval→dyn crossing (the IR's dynFromJsval): wraps an island value
|
|
3963
4005
|
* as a SCR_DYN_JSVAL node, SCALAR-NORMALIZING first — engine numbers/
|
|
3964
|
-
* strings/booleans/null/undefined convert to the native
|
|
4006
|
+
* strings/booleans/null/undefined convert to the native dyn kinds (the
|
|
3965
4007
|
* strict exits cannot fail on engine-reported scalars), so JSVAL nodes
|
|
3966
4008
|
* only ever hold engine objects/arrays/functions (and the symbol/bigint
|
|
3967
|
-
* edge). Installs the
|
|
4009
|
+
* edge). Installs the checked-dynamic tree's engine-routing ops on first use. Borrows
|
|
3968
4010
|
* the cell (retains it into the node); +1 out; never throws. */
|
|
3969
4011
|
ScrDyn *scr_dyn_from_jsval(ScrJsval *cell);
|
|
3970
4012
|
|
|
@@ -4058,6 +4100,11 @@ enum {
|
|
|
4058
4100
|
SCR_ISLP_BOOL = 2,
|
|
4059
4101
|
SCR_ISLP_STR = 3,
|
|
4060
4102
|
SCR_ISLP_JSVAL = 4,
|
|
4103
|
+
/* Promise<any[]> — the fulfillment is a native array of engine cells
|
|
4104
|
+
* (the jsval-element-array spelling): it re-enters the engine as a
|
|
4105
|
+
* fresh engine array whose ELEMENTS are the same engine values (the
|
|
4106
|
+
* loadPlugins shape: identity crosses, the spine is a copy). */
|
|
4107
|
+
SCR_ISLP_JSVAL_ARR = 5,
|
|
4061
4108
|
};
|
|
4062
4109
|
|
|
4063
4110
|
/* Wrap a scriptc promise as an ENGINE promise (async callbacks crossing
|
|
@@ -4118,6 +4165,11 @@ ScrStr *scr_jsval_exit_str(ScrJsval *v);
|
|
|
4118
4165
|
/* Uint8Array exit (engine Buffers pass — they ARE Uint8Arrays): a fresh
|
|
4119
4166
|
* u8 COPY (+1), the boundary's aliasing stance; NULL = thrown. */
|
|
4120
4167
|
ScrBytes *scr_jsval_exit_bytes(ScrJsval *v);
|
|
4168
|
+
/* `any[]`-declared slot exit (the jsval-element-array spelling):
|
|
4169
|
+
* Array.isArray-gated, elements BY REFERENCE into a native array of
|
|
4170
|
+
* engine cells (identity crosses, the spine is a snapshot copy). +1;
|
|
4171
|
+
* NULL = thrown. */
|
|
4172
|
+
ScrArr *scr_jsval_exit_jsval_arr(ScrJsval *v);
|
|
4121
4173
|
ScrStr *scr_jsval_to_json(ScrJsval *v);
|
|
4122
4174
|
|
|
4123
4175
|
/* The import boundary (libCall island.import): loads an embedded module —
|
|
@@ -4457,7 +4509,7 @@ double scr_bytes_compare(const ScrBytes *src, const ScrBytes *target, double nar
|
|
|
4457
4509
|
* Returns false after arming the pending throw. */
|
|
4458
4510
|
bool scr_bytes_validate_off(const char *name, double value, double max);
|
|
4459
4511
|
/* The checked-dynamic compare/equals validators (scr_bytes_io.c): Node's
|
|
4460
|
-
* argument ladder over
|
|
4512
|
+
* argument ladder over dyn-boxed arguments — a non-bytes value throws
|
|
4461
4513
|
* ERR_INVALID_ARG_TYPE with the API's own argument name ("buf1"/"buf2",
|
|
4462
4514
|
* "otherBuffer", "target"), non-number offsets ERR_INVALID_ARG_TYPE
|
|
4463
4515
|
* "of type number", out-of-range numbers the validateOffset RangeError;
|
|
@@ -4470,12 +4522,12 @@ double scr_bytes_compare_chk(const ScrBytes *src, const ScrDyn *target,
|
|
|
4470
4522
|
/* new Buffer(number, encoding)'s string-arm type error (always throws;
|
|
4471
4523
|
* borrowed). */
|
|
4472
4524
|
ScrBytes *scr_buffer_new_string_fail(const ScrDyn *got);
|
|
4473
|
-
/* fs._toUnixTimestamp over a
|
|
4525
|
+
/* fs._toUnixTimestamp over a dyn time value: numeric strings and finite
|
|
4474
4526
|
* numbers coerce (negatives answer now/1000), the rest throw Node's
|
|
4475
4527
|
* ERR_INVALID_ARG_TYPE. Borrowed. */
|
|
4476
4528
|
double scr_fs_to_unix_timestamp(const ScrDyn *t);
|
|
4477
4529
|
/* The fs argument-validation ladders (the fs.*Chk libCalls): Node-order
|
|
4478
|
-
* validation over
|
|
4530
|
+
* validation over dyn values with Node's exact typed errors; a pass
|
|
4479
4531
|
* meets the real operation where one exists (mkdtempSync, macOS
|
|
4480
4532
|
* lchmodSync) or the compiler-rendered fence. All borrowed; the Chk
|
|
4481
4533
|
* forms without results always leave an exception pending. */
|
|
@@ -4536,7 +4588,7 @@ ScrStr *scr_insp_buffer(ScrBytes *b); /* <Buffer aa bb ...>, 50-byte cap */
|
|
|
4536
4588
|
* depth when a code makes it composite. */
|
|
4537
4589
|
ScrStr *scr_insp_error(ScrError *e, double recurse, double depth);
|
|
4538
4590
|
/* The checked-dynamic tree: shape lives in the value, so the whole
|
|
4539
|
-
* traversal is here. dyn-boxed bytes render in the
|
|
4591
|
+
* traversal is here. dyn-boxed bytes render in the checked-dynamic tree's documented
|
|
4540
4592
|
* Uint8Array identity. */
|
|
4541
4593
|
ScrStr *scr_insp_dyn(ScrDyn *d, double recurse, double depth);
|
|
4542
4594
|
/* format's %s / rest-args twin: dyn strings pass verbatim. */
|
|
@@ -4597,7 +4649,7 @@ double scr_bytes_write_var(ScrBytes *b, double value, double offset, double byte
|
|
|
4597
4649
|
* Buffer forms of scr_lib.c's utf8 pair, byte-exact and NUL-safe.
|
|
4598
4650
|
* Failures THROW catchably (scr_fs_throw, Node-shaped messages). */
|
|
4599
4651
|
ScrBytes *scr_fs_read_file_bytes(ScrStr *path); /* +1 */
|
|
4600
|
-
/* readFileSync's runtime-encoding form (scr_bytes_io.c's note): +1
|
|
4652
|
+
/* readFileSync's runtime-encoding form (scr_bytes_io.c's note): +1 dyn
|
|
4601
4653
|
* value — a Buffer box for undefined/null, a string for utf8 — or NULL
|
|
4602
4654
|
* with the exception pending. */
|
|
4603
4655
|
ScrDyn *scr_fs_read_file_sync_dyn(ScrStr *path, const ScrDyn *enc);
|
|
@@ -4793,6 +4845,22 @@ void scr_net_sock_end_bytes(ScrNetSocket *s, ScrBytes *data /*borrowed*/);
|
|
|
4793
4845
|
void scr_net_sock_write_dynv(ScrNetSocket *s, const ScrDyn *d /*borrowed*/);
|
|
4794
4846
|
void scr_net_sock_end_dynv(ScrNetSocket *s, const ScrDyn *d /*borrowed*/);
|
|
4795
4847
|
void scr_net_sock_destroy(ScrNetSocket *s);
|
|
4848
|
+
/* Flow control (pause/resume — see the struct's flag comments), the
|
|
4849
|
+
* FIN-flushed destroy (destroySoon), TCP_NODELAY, the deferred write/
|
|
4850
|
+
* finish callbacks (write(chunk, cb) / end(cb) — sweep-fired), and the
|
|
4851
|
+
* counters/flags the compat surface reads. */
|
|
4852
|
+
ScrNetSocket *scr_net_sock_pause(ScrNetSocket *s); /* +1: chaining */
|
|
4853
|
+
ScrNetSocket *scr_net_sock_resume(ScrNetSocket *s); /* +1: chaining */
|
|
4854
|
+
ScrNetSocket *scr_net_sock_set_nodelay(ScrNetSocket *s, bool enable); /* +1: chaining */
|
|
4855
|
+
void scr_net_sock_destroy_soon(ScrNetSocket *s);
|
|
4856
|
+
void scr_net_sock_on_finish(ScrNetSocket *s, ScrClosure *cb /*moves*/);
|
|
4857
|
+
void scr_net_sock_on_write_flush(ScrNetSocket *s, ScrClosure *cb /*moves*/);
|
|
4858
|
+
double scr_net_sock_bytes_written(ScrNetSocket *s);
|
|
4859
|
+
bool scr_net_sock_readable(ScrNetSocket *s);
|
|
4860
|
+
/* The deferred dial (the http agent's maxSockets queue): the socket
|
|
4861
|
+
* registers "connecting" and buffers writes; dial_start runs the dial. */
|
|
4862
|
+
ScrNetSocket *scr_net_connect_deferred(double port, ScrStr *host /*borrowed, nullable*/); /* +1 */
|
|
4863
|
+
void scr_net_sock_dial_start(ScrNetSocket *s);
|
|
4796
4864
|
void scr_net_sock_set_timeout(ScrNetSocket *s, double ms);
|
|
4797
4865
|
void scr_net_sock_on_timeout(ScrNetSocket *s, ScrClosure *cb /*moves*/, bool once);
|
|
4798
4866
|
ScrStr *scr_net_sock_remote_address(ScrNetSocket *s); /* +1 or NULL (undefined arm) */
|
|
@@ -4819,6 +4887,7 @@ void scr_net_sock_unshift_bytes(ScrNetSocket *s, ScrBytes *data /*borrowed*/);
|
|
|
4819
4887
|
void scr_net_server_emit_connection(ScrNetServer *srv, ScrNetSocket *sock /*borrowed*/);
|
|
4820
4888
|
void scr_net_data_thunk0(ScrClosure *cb, ScrBytes *chunk);
|
|
4821
4889
|
void scr_net_data_thunk_bytes(ScrClosure *cb, ScrBytes *chunk);
|
|
4890
|
+
void scr_net_data_thunk_str(ScrClosure *cb, ScrBytes *chunk);
|
|
4822
4891
|
/* The dynCheck-adapted listener's flavor: boxes the chunk as a
|
|
4823
4892
|
* Buffer-flavored dyn (toString decodes utf8, Node's 'data' payload). */
|
|
4824
4893
|
void scr_net_data_thunk_dyn(ScrClosure *cb, ScrBytes *chunk);
|
|
@@ -4827,7 +4896,7 @@ void scr_net_conn_thunk_sock(ScrClosure *cb, ScrNetSocket *sock);
|
|
|
4827
4896
|
void scr_net_install(void);
|
|
4828
4897
|
/* Registers the netSocket handle-dispatch ops (SCR_DYNH_NET_SOCKET) —
|
|
4829
4898
|
* emitted main() calls this alongside scr_net_install exactly when the
|
|
4830
|
-
* net unit is linked, so the always-linked
|
|
4899
|
+
* net unit is linked, so the always-linked dyn core never references
|
|
4831
4900
|
* this unit's entry points. */
|
|
4832
4901
|
void scr_net_dyn_install(void);
|
|
4833
4902
|
#ifdef SCR_RC_AUDIT
|
|
@@ -4922,7 +4991,7 @@ ScrNetServer *scr_tls_create_server(const char *cert, size_t cert_len, const cha
|
|
|
4922
4991
|
* drop exactly like Node drops them). cert/key values are PEM strings,
|
|
4923
4992
|
* Buffers, or one-element arrays of those; `ca` (client side)
|
|
4924
4993
|
* concatenates array entries into one trust-anchor bundle. The *_dyn
|
|
4925
|
-
* creators walk a
|
|
4994
|
+
* creators walk a dyn options record (the checked-dynamic JS lane's
|
|
4926
4995
|
* shape) and mint the same servers the literal path mints; NULL returns
|
|
4927
4996
|
* carry a pending exception. scr_tls_pem_from_dyn is the literal path's
|
|
4928
4997
|
* runtime-valued cert/key extraction (`what` names the fence). */
|
|
@@ -4999,6 +5068,29 @@ void scr_tls_sni_answer(ScrClosure *self, bool has_err, ScrSecureCtx *ctx /*move
|
|
|
4999
5068
|
long scr_secure_ctx_live_count(void);
|
|
5000
5069
|
#endif
|
|
5001
5070
|
|
|
5071
|
+
/* ── node:tls, the CA-store introspection slice (scr_tls_ca.c — its own
|
|
5072
|
+
* unit and link gate; plain PEM-block bookkeeping, NO mbedTLS, so a
|
|
5073
|
+
* getCACertificates-only binary never builds the archive; cc.ts also
|
|
5074
|
+
* compiles it whenever scr_tls.c does). The HOST bundle (the
|
|
5075
|
+
* /etc/ssl/cert.pem probe order scr_tls.c documents) stands in for both
|
|
5076
|
+
* Node's compiled-in Mozilla roots ('bundled', rootCertificates) and the
|
|
5077
|
+
* platform store ('system') — the established SEMANTICS divergence,
|
|
5078
|
+
* extended to introspection; 'extra' reads NODE_EXTRA_CA_CERTS. Arrays
|
|
5079
|
+
* are cached per type (+1 retained answers each call — Node's own
|
|
5080
|
+
* caching, and the identity the suite pins with strictEqual). */
|
|
5081
|
+
ScrArr *scr_tls_ca_get(ScrStr *type); /* +1; throws ERR_INVALID_ARG_VALUE on unknown types */
|
|
5082
|
+
ScrArr *scr_tls_ca_root(void); /* +1; === getCACertificates("bundled") */
|
|
5083
|
+
/* Replaces the 'default' set: entries filter to their PEM certificate
|
|
5084
|
+
* blocks (deduped byte-exactly — Node dedupes by X509 identity); a
|
|
5085
|
+
* non-empty array yielding no blocks throws Node's
|
|
5086
|
+
* ERR_CRYPTO_OPERATION_FAILED and leaves the set unchanged. Borrows. */
|
|
5087
|
+
void scr_tls_ca_set_default(ScrArr *certs);
|
|
5088
|
+
/* scr_tls.c's anchor consult: true iff setDefaultCACertificates ran;
|
|
5089
|
+
* *pem/*len then carry the concatenated NUL-terminated blocks (len 0 =
|
|
5090
|
+
* the empty set — verification fails, Node's own consequence), and *gen
|
|
5091
|
+
* a counter that bumps per set so the parsed chain re-parses on change. */
|
|
5092
|
+
bool scr_tls_ca_default_override(const char **pem, size_t *len, uint64_t *gen);
|
|
5093
|
+
|
|
5002
5094
|
/* ── node:http, the server slice (scr_http.c — compiled only when the
|
|
5003
5095
|
* program uses it; rides scr_net.c wholesale, design note atop the
|
|
5004
5096
|
* file). http.createServer returns an ORDINARY ScrNetServer (listen/
|
|
@@ -5154,6 +5246,23 @@ void scr_http_upgrade_thunk3(ScrClosure *cb, ScrHttpReq *req, ScrNetSocket *sock
|
|
|
5154
5246
|
double scr_http_req_status(ScrHttpReq *r); /* < 0 = the undefined arm (server request) */
|
|
5155
5247
|
ScrNetSocket *scr_http_req_socket(ScrHttpReq *r); /* +1 */
|
|
5156
5248
|
void scr_http_req_resume(ScrHttpReq *r);
|
|
5249
|
+
/* pause()/resume() hold and drain 'data'/'end' delivery (the parser keeps
|
|
5250
|
+
* consuming; the drain rides the emit queue); setTimeout delegates to the
|
|
5251
|
+
* socket's idle timer; the flags back req.destroyed/req.readable. */
|
|
5252
|
+
void scr_http_req_pause(ScrHttpReq *r);
|
|
5253
|
+
void scr_http_req_set_timeout(ScrHttpReq *r, double ms, ScrClosure *cb /*moves, nullable*/);
|
|
5254
|
+
bool scr_http_req_destroyed_flag(ScrHttpReq *r);
|
|
5255
|
+
bool scr_http_req_readable(ScrHttpReq *r);
|
|
5256
|
+
/* flushHeaders/cork/uncork/writableCorked, the res.req backref, the
|
|
5257
|
+
* socket-delegated setTimeout, and write(chunk, cb)'s deferred callback. */
|
|
5258
|
+
void scr_http_res_flush_headers(ScrHttpRes *r);
|
|
5259
|
+
void scr_http_res_cork(ScrHttpRes *r);
|
|
5260
|
+
void scr_http_res_uncork(ScrHttpRes *r);
|
|
5261
|
+
double scr_http_res_writable_corked(ScrHttpRes *r);
|
|
5262
|
+
bool scr_http_res_destroyed_flag(ScrHttpRes *r);
|
|
5263
|
+
void scr_http_res_set_req(ScrHttpRes *r, ScrHttpReq *req /*borrowed, nullable*/);
|
|
5264
|
+
void scr_http_res_set_timeout(ScrHttpRes *r, double ms, ScrClosure *cb /*moves, nullable*/);
|
|
5265
|
+
void scr_http_res_on_write_flush(ScrHttpRes *r, ScrClosure *cb /*moves*/);
|
|
5157
5266
|
/* req.setEncoding(enc) — the socket twin's contract; may throw. */
|
|
5158
5267
|
void scr_http_req_set_encoding(ScrHttpReq *r, ScrStr *enc /*borrowed*/);
|
|
5159
5268
|
void scr_http_req_destroy(ScrHttpReq *r);
|
|
@@ -5218,6 +5327,30 @@ ScrHttpClientReq *scr_http_request_ex(ScrStr *host /*borrowed*/, double port,
|
|
|
5218
5327
|
ScrHttpClientReq *scr_http_request_url(ScrStr *url /*borrowed*/, ScrStr *method /*borrowed*/,
|
|
5219
5328
|
bool auto_end, ScrClosure *cb /*moves, nullable*/,
|
|
5220
5329
|
ScrHttpRespFn fn); /* +1 */
|
|
5330
|
+
/* ── the http Agent (new http.Agent(opts) — option surface, getName, and
|
|
5331
|
+
* the maxSockets queue over one-dial-per-request connections; keep-alive
|
|
5332
|
+
* POOLING is not modeled: keepAlive: true fences at construction).
|
|
5333
|
+
* agent_new answers the SCR_DYNH_HTTP_AGENT handle (+1 dyn) or throws.
|
|
5334
|
+
* max_sockets/max_free arrive < 0 for "unset" (Infinity / 256);
|
|
5335
|
+
* timeout_ms < 0 = no idle timer. request_agent_ex threads the agent dyn
|
|
5336
|
+
* (undefined/null = the default path; false = one-shot with Connection:
|
|
5337
|
+
* close; an Agent handle = queue accounting); port < 0 means "no port
|
|
5338
|
+
* option" — the agent's (settable) defaultPort, then the scheme's. */
|
|
5339
|
+
ScrDyn *scr_http_agent_new(bool secure, bool keep_alive, double ka_msecs,
|
|
5340
|
+
double max_sockets, double max_free, double timeout_ms,
|
|
5341
|
+
double port /* < 0 = unset: the option-merge default */); /* +1 */
|
|
5342
|
+
ScrHttpClientReq *scr_http_request_agent_ex(ScrStr *host /*borrowed*/, double port,
|
|
5343
|
+
ScrStr *path /*borrowed*/, ScrStr *method /*borrowed*/,
|
|
5344
|
+
double timeout_ms, ScrArr *header_pairs /*borrowed*/,
|
|
5345
|
+
bool auto_end, const ScrDyn *agent /*borrowed*/,
|
|
5346
|
+
ScrClosure *cb /*moves, nullable*/,
|
|
5347
|
+
ScrHttpRespFn fn, int default_port,
|
|
5348
|
+
void (*wrap)(ScrNetSocket *, void *), void *wrap_ctx); /* +1 */
|
|
5349
|
+
ScrHttpClientReq *scr_http_request_agent(ScrStr *host /*borrowed*/, double port,
|
|
5350
|
+
ScrStr *path /*borrowed*/, ScrStr *method /*borrowed*/,
|
|
5351
|
+
double timeout_ms, ScrArr *header_pairs /*borrowed*/,
|
|
5352
|
+
bool auto_end, const ScrDyn *agent /*borrowed*/,
|
|
5353
|
+
ScrClosure *cb /*moves, nullable*/, ScrHttpRespFn fn); /* +1 */
|
|
5221
5354
|
#ifdef SCR_RC_AUDIT
|
|
5222
5355
|
long scr_http_live_count(void);
|
|
5223
5356
|
#endif
|
|
@@ -5262,6 +5395,19 @@ ScrNetServer *scr_http2_create_server_req(ScrClosure *handler /*moves*/, ScrHttp
|
|
|
5262
5395
|
* the same session machinery behind an mbedTLS handshake whose ALPN
|
|
5263
5396
|
* advertises h2 alone — protocol-identical after establishment. */
|
|
5264
5397
|
ScrNetServer *scr_http2_create_secure_server(const char *cert, size_t cert_len, const char *key, size_t key_len); /* +1 */
|
|
5398
|
+
/* createSecureServer(options, handler): the eager COMPAT handler as the
|
|
5399
|
+
* first 'request' listener over the ALPN=h2 server (the createServerReq
|
|
5400
|
+
* route, secured). */
|
|
5401
|
+
ScrNetServer *scr_http2_create_secure_server_req(const char *cert, size_t cert_len, const char *key, size_t key_len, ScrClosure *handler /*moves, nullable*/, ScrHttpReqFn fn); /* +1 */
|
|
5402
|
+
/* createSecureServer with a RUNTIME options record (the divergence-66
|
|
5403
|
+
* stance): allowHTTP1 picks the flavor at runtime, cert/key ride the
|
|
5404
|
+
* shared TLS server walk (out-of-bounds members throw the catchable
|
|
5405
|
+
* fence), h2 session-tuning keys drop like the literal walk ignores
|
|
5406
|
+
* them. +1, or NULL with the exception pending. */
|
|
5407
|
+
ScrNetServer *scr_http2_create_secure_server_dyn(const struct ScrDyn *opts /*borrowed*/, ScrClosure *handler /*moves, nullable*/, ScrHttpReqFn fn);
|
|
5408
|
+
/* The TLS server-options walk (scr_tls.c) — runtime-internal, shared
|
|
5409
|
+
* with scr_http2.c's createSecureServerDyn. */
|
|
5410
|
+
bool scr_tls_srv_opts_walk(const struct ScrDyn *opts, const char *api, ScrBytes **cert_out, ScrBytes **key_out);
|
|
5265
5411
|
void scr_http2_server_on_stream(ScrNetServer *s, ScrClosure *cb /*moves*/, ScrH2StreamFn fn, bool once);
|
|
5266
5412
|
void scr_http2_server_on_session(ScrNetServer *s, ScrClosure *cb /*moves*/, ScrH2SessionFn fn, bool once);
|
|
5267
5413
|
|
|
@@ -5349,7 +5495,7 @@ void scr_http2_goaway_thunk0(ScrClosure *cb, double code, double last);
|
|
|
5349
5495
|
|
|
5350
5496
|
void scr_net_sock_set_native_established(ScrNetSocket *s, ScrNetNativeEventFn fn);
|
|
5351
5497
|
|
|
5352
|
-
/* Registers the h2 session/stream
|
|
5498
|
+
/* Registers the h2 session/stream dyn handle ops (the emitted main()
|
|
5353
5499
|
* calls it when the unit is linked — the scr_net_dyn_install story). */
|
|
5354
5500
|
void scr_http2_dyn_install(void);
|
|
5355
5501
|
|
|
@@ -5368,6 +5514,14 @@ ScrHttpClientReq *scr_https_request(ScrStr *host /*borrowed*/, double port,
|
|
|
5368
5514
|
bool auto_end, bool reject_unauthorized,
|
|
5369
5515
|
const char *ca /*borrowed, len 0 = none*/, size_t ca_len,
|
|
5370
5516
|
ScrClosure *cb /*moves, nullable*/, ScrHttpRespFn fn); /* +1 */
|
|
5517
|
+
/* The agent-threaded twin (the scr_http_request_agent story over TLS). */
|
|
5518
|
+
ScrHttpClientReq *scr_https_request_agent(ScrStr *host /*borrowed*/, double port,
|
|
5519
|
+
ScrStr *path /*borrowed*/, ScrStr *method /*borrowed*/,
|
|
5520
|
+
double timeout_ms, ScrArr *header_pairs /*borrowed*/,
|
|
5521
|
+
bool auto_end, bool reject_unauthorized,
|
|
5522
|
+
const char *ca /*borrowed, len 0 = none*/, size_t ca_len,
|
|
5523
|
+
const struct ScrDyn *agent /*borrowed*/,
|
|
5524
|
+
ScrClosure *cb /*moves, nullable*/, ScrHttpRespFn fn); /* +1 */
|
|
5371
5525
|
/* The fetch unit's https leg (defined in scr_tls.c): a client transport
|
|
5372
5526
|
* context (SNI/verify against the URL hostname — the DIALED address may
|
|
5373
5527
|
* be a resolved IP) plus the wrap hook scr_http_request_ex installs on
|
|
@@ -5412,7 +5566,7 @@ void scr_dgram_bind(ScrDgramSocket *s, double port, ScrStr *host /*borrowed*/, S
|
|
|
5412
5566
|
void scr_dgram_connect(ScrDgramSocket *s, double port, ScrStr *host /*borrowed*/, ScrClosure *cb /*moves, nullable*/);
|
|
5413
5567
|
void scr_dgram_send_str(ScrDgramSocket *s, ScrStr *data /*borrowed*/, double port, ScrStr *host /*borrowed*/);
|
|
5414
5568
|
void scr_dgram_send_bytes(ScrDgramSocket *s, ScrBytes *data /*borrowed*/, double port, ScrStr *host /*borrowed*/);
|
|
5415
|
-
/* The send argument-validation ladder over
|
|
5569
|
+
/* The send argument-validation ladder over dyn arguments (Node's
|
|
5416
5570
|
* signature shuffle, slice bounds, list/type contracts, port/address
|
|
5417
5571
|
* validation, and the connected-state errors); a fully-validated
|
|
5418
5572
|
* unconnected single-payload send RUNS, the rest meet the fence. */
|
|
@@ -5576,14 +5730,14 @@ void scr_assert_neq_fail(const char *insp, size_t ilen, bool deep,
|
|
|
5576
5730
|
ScrStr *msg, bool has_msg);
|
|
5577
5731
|
/* strictEqual/notStrictEqual/deepStrictEqual/notDeepStrictEqual where
|
|
5578
5732
|
* either operand is a checked-dynamic value (the frontend boxes a static
|
|
5579
|
-
* side into the
|
|
5733
|
+
* side into the checked-dynamic tree first). Strict pair: SameValue over the dyn kinds —
|
|
5580
5734
|
* Object.is numbers, byte-equal strings, units by kind, node identity
|
|
5581
5735
|
* for arrays/objects/bytes, BOXED-CLOSURE identity for functions. Deep
|
|
5582
|
-
* pair: the structural
|
|
5736
|
+
* pair: the structural dyn walk (per-element arrays, key-set objects,
|
|
5583
5737
|
* brand-aware bytes via the buffer flavor bit, closure identity for
|
|
5584
5738
|
* functions). Generated messages reproduce assertion_error.js — the
|
|
5585
5739
|
* scalar simple/stacked forms byte-exactly, composite values rendered
|
|
5586
|
-
* compact:false/sorted through the
|
|
5740
|
+
* compact:false/sorted through the checked-dynamic tree and diffed with the real myers
|
|
5587
5741
|
* line printer (the design note atop scr_assert.c's dyn section lists
|
|
5588
5742
|
* the divergences). Borrows everything; throws on the failing verdict. */
|
|
5589
5743
|
void scr_assert_eq_dyn(ScrDyn *a, ScrDyn *b, bool negated, bool deep,
|
|
@@ -5592,7 +5746,7 @@ void scr_assert_eq_dyn(ScrDyn *a, ScrDyn *b, bool negated, bool deep,
|
|
|
5592
5746
|
* promise fulfilled): "Missing expected exception|rejection" with Node's
|
|
5593
5747
|
* details — ` (${expected.name})` when the expected class/shape carries a
|
|
5594
5748
|
* name (has_ename), then `: message` or `.`. */
|
|
5595
|
-
/* Node's expectsError over an error-INSTANCE expected: the expected
|
|
5749
|
+
/* Node's expectsError over an error-INSTANCE expected: the expected dyn
|
|
5596
5750
|
* error's keys (minus the %error marker) each deep-compare against the
|
|
5597
5751
|
* caught value's; mismatches throw the deep-equal AssertionError. */
|
|
5598
5752
|
void scr_assert_expects_err_dyn(ScrDyn *actual, ScrDyn *expected, ScrStr *msg, bool has_msg);
|
|
@@ -5630,7 +5784,7 @@ void scr_assert_iferror_err(ScrError *err);
|
|
|
5630
5784
|
void scr_assert_iferror_f64(double x);
|
|
5631
5785
|
void scr_assert_iferror_str(ScrStr *s);
|
|
5632
5786
|
void scr_assert_iferror_bool(bool b);
|
|
5633
|
-
/* The checked-dynamic argument:
|
|
5787
|
+
/* The checked-dynamic argument: dyn-kind dispatch — units pass quietly,
|
|
5634
5788
|
* %error-marked objects throw with the error's message, everything else
|
|
5635
5789
|
* with the inspection. */
|
|
5636
5790
|
void scr_assert_iferror_dyn(const ScrDyn *v);
|