Skip to content

C API: implement JSClassRef definitions, callbacks, and property-name APIs #137

Description

@chrisbbreuer

Parents: #135, #134

Implement the public class/object callback model required by real JavaScriptCore embedders.

Acceptance:

  • Implement JSClassCreate, retain, release, parent retention, and deep-copied definitions.
  • Materialize static functions on shared automatic prototypes and as own functions for NoAutomaticPrototype.
  • Materialize static value accessors with exact handled/fallback and attribute semantics.
  • Honor inherited initialize/finalize callbacks with parent-first/child-first ordering.
  • Honor property, deletion, enumeration, conversion, call, constructor, and instanceof callbacks.
  • Implement JSPropertyNameArray and JSPropertyNameAccumulator lifecycle/APIs.
  • Integrate callback-owned objects with exactly-once GC finalization and context teardown.
  • Define deterministic exception propagation and wrong-context behavior for every callback family.
  • Add complete C ABI conformance coverage for static members, every callback family, enumeration, and exception paths.

Progress

  • 29178a3 lands the ownership foundation: atomic JSClassRef retain/release, retained parents, deep copies of class/static names and sentinel tables, per-object exact/ancestor identity, parent-first initialize, child-first finalize, and host private-data coexistence.
  • Arena teardown and precise-GC collection both finalize class instances exactly once. Focused Zig tests pass without leaks; real C/C++ hosts pass.
  • The system-JSC differential fixture now covers inherited class identity: 7/7 rows match (2dd418694a0f2741).
  • The pinned public matrix is 97/117 complete, 20 pending, with 98 public symbols and 9 zig-js extensions present.
  • A pinned system-JSC probe establishes the next static-member model: static value accessors are own per-instance properties, static functions live on a shared class prototype, and inherited property-name snapshots include both.
  • 0da233c adds per-context GC-rooted class prototypes, retained cache ownership, inherited/static function placement, and distinct own functions for NoAutomaticPrototype. C/C++ hosts pass, the focused GC-root test passes without leaks, and the JSC differential is 10/10 (99ffdeb6b62b08d1).
  • 00372b1 routes static-value get/set/has through the interpreter internal-method layer. Null getters remain absent, true setters consume writes, and false setters decline without creating accidental data properties, matching system JSC.
  • 9e5421a adds JSC-compatible static-value descriptors plus deterministic child-first own-key enumeration. C/C++ hosts pass, and the system-JSC differential now matches 14/14 rows (5469cad196099616). Static-value deletion remains before the static-values acceptance item can close.
  • 50abb92 completes static-value deletion attributes and routes inherited deleteProperty callbacks through [[Delete]]: true consumes, false falls through child-to-parent then ordinary deletion, and exceptions propagate. C/C++ hosts pass; the differential matches 17/17 rows (95d11a24046d59b6).
  • 417375c implements inherited dynamic hasProperty/getProperty/setProperty dispatch, getter-only presence fallback, handled versus ordinary-write setter behavior, mixed static/dynamic ordering, reflection, and get/set exception propagation. C/C++ hosts pass; the differential matches 23/23 rows (086732cdbe02b61a).
  • cf99d29 implements getPropertyNames, retained/deduplicated property-name snapshots, all six array/accumulator APIs, prototype-inclusive C snapshots, and exact JSC Object.keys/Reflect.ownKeys/for-in behavior. The inventory is 103/117 complete with 14 pending and 104 public symbols; C/C++ hosts pass and the differential matches 25/25 rows (6cd37c97bdb91aa0).
  • f0cdff0 completes inherited call/constructor/hasInstance/conversion callbacks and JSObjectMakeConstructor, including JSC construct-only behavior, callback exceptions, default class-instance construction, and retained class ownership through precise GC. The matrix is 104/117 complete with 13 pending and 105 public symbols; C/C++ hosts pass, focused GC tests pass 2/2 without leaks, and the differential matches 30/30 rows (49887167fbda291a).
  • e831e7b adds focused realm-validation and invalid-return coverage. Foreign values/exceptions, null required results, non-object constructor returns, and object-valued conversions become deterministic local exceptions. The focused test passes 2/2 without leaks; the promoted matrix is 105/117 complete with 12 pending and no C API: implement JSClassRef definitions, callbacks, and property-name APIs #137-owned entry left pending.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions