ReviewOS

zig-utils/zig-js

C API: implement the JSTypedArray and ArrayBuffer embedding surface

#136
Closed chris opened this 9 days ago ·
9 days ago

Parents: #135, #134

Implement the public JSTypedArray.h surface on top of the existing ArrayBufferData and TypedArrayData runtime model.

Acceptance

  • Implement JSValueGetTypedArrayType.
  • Implement all JSObjectMakeTypedArray variants.
  • Implement typed-array bytes, length, byte-length, byte-offset, and buffer accessors.
  • Implement ArrayBuffer no-copy construction, bytes access, and byte length.
  • Preserve exact no-copy deallocator ownership: exactly once on failure or finalization, never early or twice.
  • Reject wrong-realm, detached, out-of-bounds, misaligned, invalid-type, and overflow cases with JSC-compatible results/exceptions.
  • Add focused Zig tests for construction, geometry, byte aliasing, failure release, arena teardown, and GC finalization.
  • Add the checked-in public headers and a C compile-link-runtime test. Header inventory ownership is tracked by #135.
  • Document lifetime and pointer-validity rules.

Landed

  • 82b8e50 — context/GC-owned external backing lifetime records.
  • 7bf1712 — 13 public TypedArray/ArrayBuffer exports, six focused tests, README and API documentation.
  • b4993f5 — macOS 27-compatible checked-in headers and complete pinned inventory.
  • 63b4d38 — automated inventory/export audit plus passing C and C++ runtime hosts.

Verification

  • zig build test: 783 passed, 0 skipped, 0 failed, 0 leaked.
  • Focused owned/view/no-copy/finalization filters passed.
  • zig build succeeded and nm verified all 13 symbols in libzig-js.a.
  • zig build test-c-api passed: 117 declarations audited; C and C++ hosts compiled, linked, and ran; no-copy deallocator fired exactly once.
9 days ago

Implementation progress landed directly on main in 82b8e50a and 7bf1712f.

Evidence: all six new focused tests pass; the complete unit gate is 783/783 with zero skips/failures/leaks; the static library build succeeds and exports all 13 new ABI symbols. This remains open only for the checked-in public-header inventory and C compile-link-runtime gate owned with #135.

Sign in to comment on this issue.