ReviewOS

zig-utils/zig-js

Bridge: implement JSContext, JSVirtualMachine, and JSValue behavior

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

Parent: #138 Depends on: Objective-C inventory child

Implement the behavioral bridge over the completed C API and context-group runtime.

Acceptance:

  • Implement JSContext and JSVirtualMachine creation, C-ref wrapping, global access, naming/inspectability, evaluation/source URLs, current callback accessors, exception property/handler, and keyed subscripting.
  • Implement JSValue factories/conversions, exact wrapper identity per VM/context, equality/type predicates, keyed/indexed subscripting, calls, construction, invocation, and promise bridging for every inventoried entry.
  • Cover NSString/NSNumber/NSNull, dates, arrays, dictionaries, NSError/JavaScript errors, ArrayBuffer/typed arrays, Objective-C objects, classes, selectors, and unsupported conversions explicitly.
  • Preserve exceptions and callback current-context/callee/this/arguments semantics across nested re-entry.
  • Add focused Zig/C-API tests plus Objective-C differential transcripts against system JavaScriptCore.
9 days ago

Initial runtime slice landed in 73fa100, focused evidence in fc13ccc, and the auditable inventory/docs in d06e264. The macOS runtime host now proves VM/context construction and identity, evaluation with source URLs and exception capture, context naming/inspectability, C-ref round trips, primitive JSValue factories, all ten published type predicates, and boolean/string conversion. zig build test-objc-api, test-objc-api-headers, objc-api-audit, and the existing C/C++ host gate pass. The inventory deliberately marks only 32/108 declarations implemented; 76 remain pending, including callback-current accessors, complete exception/callback re-entry semantics, collection/object conversion, property/call/construct/promise helpers, and managed/JSExport work owned by #159/#160.

9 days ago

Objective-C bridge progress is now 72/108 implemented (36 pending) through 6acc6d3. New evidence: recursive NSString/NSNumber/NSNull/NSDate/NSArray/NSDictionary conversion with cycle handling based on strict JS identity; property/index/call/construct/invoke helpers for supported conversions; CGPoint/CGSize/CGRect/NSRange conversion; six descriptor symbols; and a real Apple-clang archive/link path. zig build objc-api-jsc-diff compiles the same Foundation fixture against macOS 27.0 system JavaScriptCore and zig-js and matches all 6 rows (digest 90eb8830e80da5df). The runtime stress also covers Objective-C and JavaScript cyclic graphs. Remaining #158 work is deliberately still pending: arbitrary Objective-C wrappers/classes/selectors/blocks, callback-current state, complete exception re-entry, promise block bridging, and then promotion of the general id-taking interaction methods.

9 days ago

Completed through cb19adf. The pinned macOS SDK 27.0 inventory now audits at 108/108 implemented with zero pending declarations. zig build test-objc-api, zig build test-objc-api-headers, and zig build test-c-api pass; the system-JSC Objective-C differential matches all 15 rows (73e8bff0363ae6c5). README and API documentation publish the exact coverage, link requirements, lifetime boundary, and reproduction commands.

Sign in to comment on this issue.