Alternative API for reading custom pragmas; The Nim one is too broken in 0.19.6

This commit is contained in:
Zahary Karadjov 2019-07-10 13:36:56 +03:00
parent 061543d039
commit 5b6881588c
No known key found for this signature in database
GPG Key ID: C8936F8A3073D609
1 changed files with 11 additions and 0 deletions

View File

@ -125,6 +125,17 @@ proc skipPragma*(n: NimNode): NimNode =
if n.kind == nnkPragmaExpr: n[0]
else: n
macro hasCustomPragmaFixed*(T: type, field: static string, pragma: typed{nkSym}): untyped =
let
Tresolved = getType(T)[1]
Timpl = getImpl(Tresolved)
for f in recordFields(Timpl):
if eqIdent(f.name, field):
return newLit(f.pragmas.findPragma(pragma) != nil)
error "The type " & $Tresolved & " doesn't have a field named " & field
# FIXED NewLit
proc newLitFixed*(c: char): NimNode {.compileTime.} =