Skip to content

Add declarative FFI struct layouts - #698

Merged
yogthos merged 1 commit into
jolt-lang:mainfrom
casselc:agent/ffi-struct-layouts
Aug 22, 2026
Merged

yogthos merged 1 commit into
jolt-lang:mainfrom
casselc:agent/ffi-struct-layouts

Conversation

@casselc

@casselc casselc commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • add literal, data-only [:struct ...] descriptors through jolt.ffi/layout
  • derive native size, alignment, and nested field offsets from lexically scoped Chez define-ftype declarations
  • add layout-size, layout-alignment, field-offset, read-field, and write-field
  • reject empty or malformed descriptors and unsupported field kinds at compile time
  • compare flat, padded, and nested layouts against C ABI witnesses

Descriptors are immutable data rather than entries in a mutable registry. This initial surface supports fixed-size scalar fields and nested structs; arrays, unions, bitfields, packing, and recursive descriptors remain unsupported.

Stack

This is 1 of 3 in the FFI stack:

  1. This PR: declarative struct layouts
  2. Pass and return FFI structs by value #699: by-value aggregate calls
  3. FFI: add scoped allocation helpers #700: scoped allocation helpers

GitHub native stacks do not support cross-fork branches, so the three PRs target main and are linked explicitly.

Validation

  • rebased onto official v0.7.22 (8990efe2)
  • pinned Chez 10.4.1 wrapper preflight
  • focused FFI: bindings 19/19, exact widths 51/51, layouts 25/25; public API test passed
  • layout public API passed from source and a rebuilt standalone binary
  • Chez seed reminted to a two-pass byte fixpoint
  • Gambit seed regenerated and gambitseedcheck passed
  • serial make -j1 test: 82 CI targets and 3 test targets passed
  • unit gate: 1394/1394
  • git diff --check
  • fork CI passed on Linux x86-64 and macOS arm64

@casselc
casselc marked this pull request as ready for review August 22, 2026 18:25
@yogthos

yogthos commented Aug 22, 2026

Copy link
Copy Markdown
Member

Nice, this should make FFI more ergonomic. :)

@yogthos
yogthos force-pushed the agent/ffi-struct-layouts branch from 62c6fd7 to b98659c Compare August 22, 2026 21:58
@yogthos
yogthos merged commit c6f25d0 into jolt-lang:main Aug 22, 2026
3 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.

2 participants