mirror of
https://github.com/zap-proto/nim.git
synced 2026-10-30 15:04:34 +00:00
Rename the capnp/ module set to zap/ and the capnpc compiler to zapc; rename all .capnp schemas and fixtures to .zap; update every import, include guard (isInZap), generated-code emission, exception type (ZapFormatError), and the macro-generated zapUnpackStructImpl/ zapPackStructImpl identifiers to the ZAP brand. Zero capnp/Cap'n Proto references remain in source or build files; upstream MIT attribution (Sandstorm, Michał Zieliński) is preserved. Raise the nimble nim floor from the fictional 0.12.0 to the locked, verified 0.15.2 (matches nimenv.cfg/build.sh; code carries fixes through Nim 0.18). Rewrite TODO.md as honest, source-anchored known-limitations (two-word intersegment pointers, nested/named-union codegen, RPC interface inheritance) instead of a bare wishlist.
30 lines
548 B
Nim
30 lines
548 B
Nim
import zap, caprpc/rpcschema, posix, fuzzlib, collections
|
|
|
|
proc main() =
|
|
let packer = newPacker()
|
|
let data = stdin.readAll
|
|
|
|
try:
|
|
let u = newUnpacker(data)
|
|
copyPointer(u, 0, packer, 0)
|
|
except ZapFormatError:
|
|
return
|
|
|
|
let msg1 = packer.buffer
|
|
|
|
when not defined(fuzz):
|
|
echo data.encodeHex
|
|
echo msg1.encodeHex
|
|
|
|
let packer2 = newPacker()
|
|
let u1 = newUnpackerFlat(msg1)
|
|
copyPointer(u1, 0, packer2, 0)
|
|
let msg2 = packer2.buffer
|
|
|
|
when not defined(fuzz):
|
|
echo msg2.encodeHex
|
|
|
|
doAssert(msg1 == msg2)
|
|
|
|
runFuzz()
|