Ivan FB 028dbb56e6
feat(codegen): add C and Go (cgo) binding generators
0.2.0 carries each request as a single CBOR buffer over the exported ABI,
which is awkward for hand-written host bindings (every consumer would have
to encode CBOR and decode responses by hand). These two generators emit
ergonomic, ready-to-use bindings from the same {.ffi.} registry the C++/Rust
generators already consume.

- c.nim (targetLang=c): a self-contained <lib>.h with a small CBOR encoder,
  ffi_decode_text(), and `static inline <lib>_<proc>(ctx, cb, ud, args...)`
  wrappers that CBOR-encode and forward to the real export. The wrapper keeps
  the export's source name but is given a distinct symbol via an __asm__ label
  so the raw export's asm alias doesn't bind back to the wrapper (which would
  recurse). Scalar/string params only; others fall back to the raw CBOR decl.

- go.nim (targetLang=go): a single <lib>.go cgo package that #includes the
  generated <lib>.h and adds a condvar-backed response capture. This is the
  key bit: 0.2.0 removed the synchronous fast-path, so a caller can no longer
  read a result right after the call — the generated bridges block on the
  callback, turning each async export into a blocking Go method. Also emits a
  go.mod for importability.

Wired both into genBindings dispatch (targetLang "c"/"go") and added
genbindings_c / genbindings_go tasks. Both verified end-to-end against a
scalar-param test lib (build + run) and the real libwaku surface.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-31 00:06:46 +02:00
..
2026-05-18 20:00:57 +02:00
2026-05-25 15:51:56 +02:00
2026-05-16 01:08:42 +02:00