Commit b2d2536
Adds the raw binary I/O surface that estate ABI-test ports need
(raze-tui's 16-byte RazeEvent record, future tree-sitter-k9 / tree-
sitter-a2ml grammar fixtures, half of bofig's contract tests).
Stdlib (`stdlib/Deno.affine`):
+ bytes_new(n) -> new Uint8Array(n)
+ bytes_fill(n, byte) -> new Uint8Array(n).fill(byte & 0xFF)
+ bytes_set_u8(b, off, v) -> DataView.setUint8(off, v & 0xFF), 0
+ bytes_set_u16_le(b, o, v) -> DataView.setUint16(o, v & 0xFFFF, true), 0
+ bytes_set_u32_le(b, o, v) -> DataView.setUint32(o, v >>> 0, true), 0
+ bytes_set_i32_le(b, o, v) -> DataView.setInt32(o, v | 0, true), 0
+ bytes_get_u8(b, off) -> DataView.getUint8(off)
+ bytes_get_u16_le(b, off) -> DataView.getUint16(off, true)
+ bytes_get_u32_le(b, off) -> DataView.getUint32(off, true)
+ bytes_get_i32_le(b, off) -> DataView.getInt32(off, true)
All multi-byte ints are little-endian — the estate's C ABI contracts
(raze-tui `raze-events.ads`, Idris2 `Events.idr`) are LE-pinned.
Setters return `Int = 0` for expression-statement composition; bounds
remain caller's responsibility (out-of-range offsets throw RangeError
at the host boundary). Pair with `bytesLength` from STEP 3 / #504 for
bounds-checks.
Tests:
+ tests/codegen-deno/bytes_binary_io.{affine,deno.js,harness.mjs}
round-trips a raze-tui-shaped RazeEvent (LE i32 + u32 + u8 +
u16 × 2) with field-level equality, plus boundary cases
(u32 max, i32 -1, byte-order byte-by-byte check via DataView,
bytes_fill masking).
✓ All 353 dune-runtest tests pass.
✓ All codegen-Deno-ESM harnesses pass.
Out of scope: BE variants (not needed by any estate ABI today);
64-bit getters/setters (defer to `*_i64_le` follow-up if current
STEP 4 candidates exceed 32-bit).
Refs: hyperpolymath/standards#239 (umbrella), hyperpolymath/standards#326
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 83d82d3 commit b2d2536
5 files changed
Lines changed: 516 additions & 0 deletions
File tree
- lib
- stdlib
- tests/codegen-deno
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
464 | 464 | | |
465 | 465 | | |
466 | 466 | | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
467 | 480 | | |
468 | 481 | | |
469 | 482 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
76 | 119 | | |
77 | 120 | | |
78 | 121 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
0 commit comments