mirror of
https://github.com/logos-messaging/nim-ffi.git
synced 2026-06-20 16:29:31 +00:00
Adds ffi/codegen/swift.nim, wired into the targetLang dispatch and exposed as the `genbindings_swift` nimble task. It emits an idiomatic Swift wrapper over the native (zero-serialization) C ABI from c.nim — importing the C structs through the CMyTimer clang module and never touching CBOR. The one piece of real logic is callback-shape selection: ack / string / struct decoding is chosen per proc from FFIProcMeta.kind + returnTypeName, and struct returns are copied out inside the callback to honour the deep-free-after-callback ownership rule. A single struct param's fields are flattened into the Swift method signature; ctors keep argument labels. Procs needing seq/Option or multi-struct param marshaling are skipped with a logged notice rather than emitting broken Swift, so the wrapper always compiles. That marshaling, events, and async mapping are the next increments. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
nim-ffi
Allows exposing Nim projects to other languages
Example
examples/timer is now a self-contained Nimble project that imports nim-ffi directly.
Use cd examples/timer && nimble install -y ../.. && nimble build to compile the example.
Description
Languages
Nim
87.9%
Smarty
5.9%
C++
4.8%
CMake
1.4%