Skip to content

feat: Bun's C ABI FFI bindings - #40

Open
fabrv wants to merge 3 commits into
zth:mainfrom
fabrv:bun-ffi
Open

fabrv wants to merge 3 commits into
zth:mainfrom
fabrv:bun-ffi

Conversation

@fabrv

@fabrv fabrv commented Mar 2, 2026 •

Copy link
Copy Markdown
Contributor

Bun's C ABI FFI bindings (FFI^2)

@fabrv

fabrv commented Mar 2, 2026

Copy link
Copy Markdown
Contributor Author

@zth @nojaf Please review 🙏

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds initial ReScript bindings for Bun’s bun:ffi module (FFI^2) and introduces accompanying FFI-focused tests plus small C fixtures to validate dlopen, typed pointers, and cc compilation.

Changes:

  • Add src/FFI.res bindings for bun:ffi (dlopen/linkSymbols, pointers, CString/JSCallback/CFunction, cc, viewSource, read helpers).
  • Add a new FFI test suite and small C sources used by the tests.
  • Add a precompiled test/ffi_testlib.so artifact for dlopen-based tests (plus bun.lock).

Reviewed changes

Copilot reviewed 6 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/ffi_testlib.so Adds a precompiled shared library used for dlopen tests.
test/ffi_testlib.c C fixture implementing simple functions (add/multiply/etc.) for FFI tests.
test/ffi_square.c C fixture for validating CC.compile from a file.
test/FFITest.res ReScript FFI test suite exercising suffix/dlopen/cstring/pointers/read/cc.
test/FFITest.js Generated JS output for the ReScript FFI test suite.
src/FFI.res New bun:ffi bindings for ReScript, including Read, CString, JSCallback, and CC.
src/FFI.js Generated JS output for the new FFI bindings module.
bun.lock Adds a Bun lockfile snapshot.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/FFI.res Outdated
Comment thread test/FFITest.res
Comment thread test/FFITest.res Outdated
@nojaf

nojaf commented Mar 2, 2026

Copy link
Copy Markdown
Collaborator

@fabrv I think the remarks are on point, can you take a look.

fabrv and others added 2 commits October 1, 2026 15:18
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@fabrv

fabrv commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

@nojaf Comments resolved. Please take another look. Thanks

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.

3 participants