mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 22:10:33 +00:00
Implement support for enum fields in JSON macro.
This commit is contained in:
@@ -1421,7 +1421,6 @@ proc processElseBranch(recCaseNode, elseBranch, jsonNode, kindType,
|
||||
## RecList
|
||||
## Sym "other"
|
||||
result = @[]
|
||||
# TODO: Remove duplication between processOfBranch
|
||||
let getEnumCall = createGetEnumCall(kindJsonNode, kindType)
|
||||
|
||||
# We need to build up a list of conditions from each ``of`` branch so that
|
||||
@@ -1525,6 +1524,13 @@ proc processType(typeName: NimNode, obj: NimNode,
|
||||
for field in obj[2]:
|
||||
let nodes = processObjField(field, jsonNode)
|
||||
result.add(nodes)
|
||||
of nnkEnumTy:
|
||||
let instType = toIdentNode(getTypeInst(typeName))
|
||||
let getEnumCall = createGetEnumCall(jsonNode, instType)
|
||||
result = quote do:
|
||||
(
|
||||
`getEnumCall`
|
||||
)
|
||||
of nnkSym:
|
||||
case ($typeName).normalize
|
||||
of "float":
|
||||
|
||||
Reference in New Issue
Block a user