diff --git a/stew/shims/macros.nim b/stew/shims/macros.nim index 0104bb4..31eb6b6 100644 --- a/stew/shims/macros.nim +++ b/stew/shims/macros.nim @@ -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: