ReviewOS

zig-utils/zig-js

C API: implement UTF-16, borrowed-character, sizing, and string equality APIs

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

Parents: #135, #134

Complete the JSStringRef.h public surface around the existing UTF-8/reference-counted string implementation.

Acceptance:

  • Implement JSStringCreateWithCharacters with exact UTF-16 and lone-surrogate behavior.
  • Implement JSStringGetCharactersPtr with stable lifetime through the matching JSStringRef retain interval.
  • Implement JSStringGetMaximumUTF8CStringSize without overflow.
  • Implement JSStringIsEqual and JSStringIsEqualToUTF8CString with null/invalid-input behavior.
  • Preserve atomic retain/release and exact UTF-8/UTF-16 length semantics.
  • Add C and C++ compile-link-runtime tests plus Unicode, embedded-NUL, invalid-UTF-8, overflow, and cross-thread lifetime coverage.

Landed

  • d27bdf5 — five missing JSString exports, stable UTF-16 storage, Unicode semantics, inventory and docs.
  • 16334585 — embedded-NUL, overflow, invalid UTF-8, cross-thread backing, and C++ ABI evidence.

Verification

  • zig test src/jsstring.zig: 4/4 passed.
  • focused C-API JSString suite: 7/7 passed, 0 leaked.
  • zig build test-c-api: inventory audit and C/C++ compile-link-runtime hosts passed.
  • Matrix: 61/117 functions complete; 64 public symbols present.

Sign in to comment on this issue.