mirror of
https://github.com/logos-messaging/nim-ffi.git
synced 2026-06-20 16:29:31 +00:00
Adds the ergonomic native event surface to the C++ generator: `node.On<Event>(std::function<void(const <Payload>&)>)` registers a native listener; a per-event extern "C" trampoline reads the typed POD (`fromC(*reinterpret_cast<const ::<Payload>*>(msg))`) and invokes the handler — no CBOR. The handler is owned by the node (a `std::map` of `ListenerBase`) so its address stays valid until `removeEventListener`. The example registers `OnEchoFired` and receives a typed `EchoEvent` when Echo fires it. Verified end-to-end and ASAN-clean. With this the native C++ generator covers the full surface: requests (scalar/string/bool/seq/Option/nested), typed struct returns, and typed events. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>