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.
62 lines
1.2 KiB
Nim
62 lines
1.2 KiB
Nim
import zap, zap/gensupport, collections/iface
|
|
|
|
# file: examples/person.zap
|
|
|
|
type
|
|
Person* = ref object
|
|
name*: string
|
|
email*: string
|
|
phones*: seq[Person_PhoneNumber]
|
|
birthdate*: Date
|
|
notes*: seq[string]
|
|
isAwesome*: bool
|
|
isCloseFriend*: bool
|
|
usosIds*: seq[int64]
|
|
|
|
Person_PhoneNumber* = ref object
|
|
number*: string
|
|
`type`*: Person_PhoneNumber_Type
|
|
|
|
Person_PhoneNumber_Type* {.pure.} = enum
|
|
mobile = 0, home = 1, work = 2
|
|
|
|
Date* = ref object
|
|
year*: int16
|
|
month*: uint8
|
|
day*: uint8
|
|
|
|
PersonContainer* = ref object
|
|
person*: AnyPointer
|
|
|
|
|
|
|
|
makeStructCoders(Person, [], [
|
|
(name, 0, PointerFlag.text, true),
|
|
(email, 1, PointerFlag.text, true),
|
|
(phones, 2, PointerFlag.none, true),
|
|
(birthdate, 3, PointerFlag.none, true),
|
|
(notes, 4, PointerFlag.text, true),
|
|
(usosIds, 5, PointerFlag.none, true)
|
|
], [
|
|
(isAwesome, 0, false, true),
|
|
(isCloseFriend, 1, true, true)
|
|
])
|
|
|
|
makeStructCoders(Person_PhoneNumber, [
|
|
(`type`, 0, Person_PhoneNumber_Type(0), true)
|
|
], [
|
|
(number, 0, PointerFlag.text, true)
|
|
], [])
|
|
|
|
makeStructCoders(Date, [
|
|
(year, 0, 0, true),
|
|
(month, 2, 0, true),
|
|
(day, 3, 0, true)
|
|
], [], [])
|
|
|
|
makeStructCoders(PersonContainer, [], [
|
|
(person, 0, PointerFlag.none, true)
|
|
], [])
|
|
|
|
|