Ivan FB 8f15afce5c
feat: multi-parameter {.ffiEvent.} via synthesised envelope
`{.ffiEvent.}` previously accepted exactly one parameter, forcing every
multi-field event to declare a hand-written {.ffi.} payload type. The macro
now bundles two or more parameters into a synthesised, registered envelope
object named `<WireNamePascalCase>Payload`, whose fields are the parameters,
and dispatches an instance of it. A single parameter still rides the wire
directly (scalar or existing {.ffi.} object), so this is backwards
compatible. Because the envelope is registered like any {.ffi.} type, the
foreign bindings gain it as a first-class struct plus a typed handler.

The timer example gains an `on_job_scheduled(jobId, willRunCount)` event to
exercise the path; the C++ and Rust bindings are regenerated accordingly.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-25 03:05:37 +02:00
..
2026-05-16 01:08:42 +02:00
2026-06-10 16:30:30 -03:00

timer example

This example is a self-contained Nimble project demonstrating how to import nim-ffi and use the .ffiCtor. / .ffi. abstraction.

Usage

  1. Change into the example directory:

    cd examples/timer
    
  2. Install the local ffi dependency:

    nimble install -y ../..
    
  3. Build the example library:

    nimble build
    
  4. 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