Skip to content

Cross homogeneous arrays typed instead of as JSON#74

Merged
colemancda merged 3 commits into
masterfrom
chore/drop-json-encoder
Jul 24, 2026
Merged

Cross homogeneous arrays typed instead of as JSON#74
colemancda merged 3 commits into
masterfrom
chore/drop-json-encoder

Conversation

@colemancda

@colemancda colemancda commented Jul 24, 2026

Copy link
Copy Markdown
Member

Summary

Takes the last high-frequency data off the JSON bridge path. After #73 only array-valued props still crossed as JSON text; now every homogeneous array (all elements one scalar kind) crosses typed too. The only remaining JSON is the two nested/heterogeneous props — alert buttons and NavigationStack searches — which have no natural single JNI type.

Encoding. An array value rides the existing per-value slot: a new array-kind tag marks the element type, and the bits slot packs (offset << 32 | count) into one of two per-node pools — a shared Array<String> and a shared LongArray (numbers bit-cast in, matching the scalar scheme). The bridge constructor gains exactly two parameters (stringPool, longPool); the same two pools serve both props and modifier args, so traits (an accessibility modifier arg) converts along with the node props. Classification is automatic in the materializer — an array of uniform scalar kind routes to a pool, anything nested or mixed falls back to the kindJSON literal.

No reader churn. The Kotlin constructor rebuilds a JsonArray of JsonPrimitives from the pools, so ViewNode's in-memory model stays JsonObject/JsonArray and every Render.kt array read is untouched — but no Json.parseToJsonElement runs for homogeneous arrays. Converted: keys (List/Lazy rows — the large, per-update one), titles, detents, traits, gradient colors.

Also drops the now-unused Materializer.jsonObjectLiteral (dead since modifier args went typed in #73).

Testing

  • 123 SwiftUICore tests pass; swift build --target ComposeUI and Kotlin android/desktop compiles pass.
  • On the Android emulator: gradient screen (numeric color array), List/catalog (string keys), confirmation dialog (nested buttons — still JSON, renders all actions and registers the choice), plus button/toggle/nav all correct.

@colemancda colemancda changed the title Drop the now-unused modifier-args JSON encoder Cross homogeneous arrays typed instead of as JSON Jul 24, 2026
@colemancda
colemancda merged commit 74696ae into master Jul 24, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant