mirror of
https://github.com/logos-messaging/nim-ffi.git
synced 2026-08-06 06:53:21 +00:00
Avoid magic ret-code integers in the generated callback helpers. The C trampolines already reference NIMFFI_RET_STALE_WARN; mirror that in the other two backends: define the canonical NIMFFI_RET_* set once in the C++ header prelude (guarded so a mixed TU keeps a single definition) and emit module-level NIMFFI_RET_* consts in the Rust crate, then use the named constants for the stale-warn, ok, and missing-callback checks instead of 3/0/2. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
timer example
This example is a self-contained Nimble project demonstrating how to import nim-ffi and use the .ffiCtor. / .ffi. abstraction.
Usage
-
Change into the example directory:
cd examples/timer -
Install the local
ffidependency:nimble install -y ../.. -
Build the example library:
nimble build -
Generate bindings:
nimble genbindings_rust nimble genbindings_cpp
Rust example clients
The Rust client lives in examples/timer/rust_client.
-
Run the sync example:
cd examples/timer/rust_client cargo run --bin rust_client -
Run the Tokio example:
cd examples/timer/rust_client cargo run --bin tokio_client
C++ example
The generated C++ example lives in examples/timer/cpp_bindings.
Build and run it with:
cd examples/timer/cpp_bindings
cmake -S . -B build
cmake --build build
./build/example