Another useful form of isTuple

This commit is contained in:
Zahary Karadjov 2019-08-14 17:29:14 +02:00
parent 343c2073cc
commit 4f685ab7ec
No known key found for this signature in database
GPG Key ID: C8936F8A3073D609
1 changed files with 4 additions and 2 deletions

View File

@ -24,13 +24,15 @@ proc findPragma*(pragmas: NimNode, pragmaSym: NimNode): NimNode =
return p
func isTuple*(t: NimNode): bool =
t.kind == nnkBracketExpr and t[0].kind == nnkSym and t[0].repr == "tuple"
t.kind == nnkBracketExpr and t[0].kind == nnkSym and eqIdent(t[0], "tuple")
macro isTuple*(T: type): untyped =
newLit(isTuple(getType(T)[1]))
template readPragma*(field: FieldDescription, pragmaName: static string): NimNode =
let p = findPragma(field.pragmas, bindSym(pragmaName))
if p != nil and p.len == 2: p[1] else: p
proc recordFields*(typeImpl: NimNode): seq[FieldDescription] =
# TODO: This doesn't support inheritance yet
if typeImpl.isTuple: