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.
33 lines
691 B
Nim
33 lines
691 B
Nim
import persondef, zap
|
|
|
|
let p = new(Person)
|
|
let d = new(Date)
|
|
|
|
p.usosIds = @[1.int64, 2, 3, 4, 5, 6, 7, 8]
|
|
p.birthdate = d
|
|
p.isAwesome = true
|
|
p.isCloseFriend = false
|
|
p.name = "Hello"
|
|
p.notes = @[nil, "nope", "just a note", ""]
|
|
p.phones = @[]
|
|
let num = new(Person_PhoneNumber)
|
|
num.number = "hello"
|
|
num.`type` = Person_PhoneNumber_Type.work
|
|
p.phones.add num
|
|
let num2 = new(Person_PhoneNumber)
|
|
num2.number = "world"
|
|
num2.`type` = Person_PhoneNumber_Type.mobile
|
|
p.phones.add num2
|
|
p.email = "[email protected]"
|
|
d.year = 2016
|
|
d.month = 12
|
|
d.day = 5
|
|
|
|
let packed = packPointer(p)
|
|
echo packed.repr
|
|
|
|
writeFile("person.bin", packed)
|
|
|
|
let p1 = newUnpackerFlat(packed).unpackPointer(0, Person)
|
|
echo p1.repr
|