mirror of
https://github.com/status-im/nim-stew.git
synced 2025-01-09 11:45:42 +00:00
Alternative API for reading custom pragmas; The Nim one is too broken in 0.19.6
This commit is contained in:
parent
061543d039
commit
5b6881588c
@ -125,6 +125,17 @@ proc skipPragma*(n: NimNode): NimNode =
|
|||||||
if n.kind == nnkPragmaExpr: n[0]
|
if n.kind == nnkPragmaExpr: n[0]
|
||||||
else: n
|
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
|
# FIXED NewLit
|
||||||
|
|
||||||
proc newLitFixed*(c: char): NimNode {.compileTime.} =
|
proc newLitFixed*(c: char): NimNode {.compileTime.} =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user