ReviewOS

zig-utils/zig-js

C API: implement remaining value, BigInt, comparison, and JSON APIs

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

Parents: #135, #134

Complete JSValueRef.h beyond the currently implemented predicates, constructors, coercions, and TypedArray type query.

Acceptance:

  • Implement Symbol/BigInt predicates and Symbol construction.
  • Complete class-instance and instanceof-constructor checks.
    • JSValueIsObjectOfClass, including retained parent-class identity.
    • JSValueIsInstanceOfConstructor, including Symbol.hasInstance.
  • Implement JSRelationCondition comparison functions for value/int64/uint64/double.
  • Implement BigInt creation from double, signed/unsigned integers, and strings.
  • Implement JSON parse/stringify entry points with indentation and exception behavior.
  • Implement exact int32/uint32/int64/uint64 conversions.
  • Reconcile JSValueProtect/Unprotect ABI return types with the pinned public headers while retaining internal failure observability through a zig-js extension if needed.
  • Add C compile-link-runtime and differential behavior tests against the pinned JSC target.

Progress

  • fe78bfa changes the public functions to the pinned void ABI and adds ZJSValueProtect/ZJSValueUnprotect boolean extensions for invalid-handle, overflow, and unmatched-unprotect observability.
  • Focused protection/GC suite: 4/4 passed, 0 leaked. C and C++ compile-link-runtime hosts passed.
  • Matrix: 67/117 complete, 50 pending; 68 public symbols and 9 classified zig-js extensions present.
  • 8bc3421 adds real fresh-Symbol construction with realm prototype/unique identity, owned descriptions, and Symbol/BigInt predicates. Focused semantics and C/C++ host gates pass. Matrix: 70/117 complete, 47 pending; 71 public symbols present.
  • c6fa2e1 adds all four exact BigInt constructors, including non-integral double rejection, 64-bit boundaries, arbitrary-precision strings, and exception behavior. Focused and host gates pass. Matrix: 74/117 complete, 43 pending; 75 public symbols present.
  • 88fe93b exposes the production JSON parser/stringifier with invalid-input null behavior, owned output, indentation clamping, cycle/BigInt exception propagation, Unicode coverage, and C host evidence. Matrix: 76/117 complete, 41 pending; 77 public symbols present.
  • bc6c0aa adds exact IEEE-754/BigInt modulo conversions for all four integer widths, with system-JSC-derived vectors, huge finite values, 64-bit boundaries, Symbol exceptions, and C host coverage. Matrix: 80/117 complete, 37 pending; 81 public symbols present.
  • 3c63b3f implements all relation conditions through abstract equality/relational semantics, exact native integer RHS BigInts, NaN/exception handling, and repairs JSValueToNumber to match Number(value) for primitive/boxed BigInts. Focused and host gates pass. Matrix: 84/117 complete, 33 pending; 85 public symbols present.
  • 9bfe34e implements JSValueIsInstanceOfConstructor with ordinary/custom Symbol.hasInstance semantics, exception propagation, and C host coverage. JSValueIsObjectOfClass remains explicitly blocked on #137 rather than accepting opaque fake classes. Matrix: 85/117 complete, 32 pending; 86 public symbols present.
  • 8b267d8 adds zig build c-api-jsc-diff: it hash-verifies the pinned SDK, compiles one C value fixture against zig-js and system JavaScriptCore, and requires byte-for-byte output equality. Current result: 6/6 rows matched (be69af0f1afc1ae6). Only JSValueIsObjectOfClass remains, deliberately coupled to #137.
  • 29178a3 completes JSValueIsObjectOfClass on real retained class identity, including ancestors, GC/teardown lifetime, C host coverage, and a 7/7 system-JSC differential (2dd418694a0f2741). Matrix: 89/117 complete, 28 pending; 90 public symbols and 9 extensions present.

Sign in to comment on this issue.