mirror of
https://github.com/logos-messaging/nim-ffi.git
synced 2026-06-22 17:29:28 +00:00
Aligns the C++ generators with the C generator and the symbol naming: the native (zero-serialization, same-process) wrapper is the bare `<lib>.hpp` and the CBOR (inter-process) wrapper carries the `_cbor` suffix — mirroring the C headers (`<lib>.h` / `<lib>_cbor.h`) and the `<name>` / `<name>_cbor` exports. Previously native was `<lib>_native.hpp` and CBOR was the bare `<lib>.hpp`, which is backwards from the symbol convention and would collide on the native `<lib>.h` when both ABIs emit into one dir (ffiMode=both). With the flip, a single `genbindings_cpp` run now drops `<lib>.hpp` + `<lib>_cbor.hpp` side by side, exactly like c_bindings holds both `.h` headers. Consumers updated to match: the CBOR cpp_bindings driver and the C++ e2e suite include `*_cbor.hpp`; the native example includes the bare `<lib>.hpp`. Validated: native example runs on `my_timer.hpp`; C++ e2e suite 19/19 on the `_cbor.hpp` headers; check_bindings_cpp regen is deterministic. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1.4 KiB
1.4 KiB
C++ Bindings for nim-timer
Purpose
This folder contains auto-generated C++ bindings for the my_timer Nim library. It is generated from ../timer.nim (with the default both ABI mode) and provides:
my_timer_cbor.hpp: High-level C++ class (MyTimerCtx) wrapping the CBOR FFI interface (inter-process)my_timer.hpp+my_timer.h: the native (zero-serialization, same-process) wrapper and the C ABI it builds onmain.cpp: Example executable demonstrating how to use the CBOR bindingsCMakeLists.txt: Build configuration that compiles the Nim library and links the C++ example
The native header is the bare my_timer.hpp and the CBOR header carries the _cbor suffix — the same convention as the C bindings (my_timer.h / my_timer_cbor.h) and the underlying symbols (<name> / <name>_cbor).
How It's Generated
Generate or regenerate these bindings by running from the parent directory:
cd examples/timer
nimble genbindings_cpp
This command:
- Invokes the Nim compiler with
-d:targetLang:cppflag - Triggers
genBindings("examples/timer/cpp_bindings", "../timer.nim")intimer.nim - Creates/updates the generated binding files
Building the Example
cd examples/timer/cpp_bindings
cmake -S . -B build
cmake --build build
./build/example
Do Not Edit
The generated files in this folder are overwritten each time nimble genbindings_cpp runs. Any manual changes will be lost.