import macros proc getChildren(node: NimNode, nodeKind: NimNodeKind): seq[NimNode] = var stack: seq[NimNode] = @[node] result = @[] while stack.len() > 0: let newNode = stack.pop() for i in 0 ..< newNode.len(): let child = newNode[i] if child.kind == nodeKind: result.add(child) else: stack.add(child) macro `@`*(objName: typed, fields: untyped): untyped = let objImpl = objName.getImpl() let identDefs = objImpl.getChildren(nnkIdentDefs) result = newNimNode(nnkObjConstr).add(objImpl[0]) for i in 0..