@@ -40,6 +40,7 @@ macro setters*(excludes: untyped, obj: untyped) =
40
40
## Optionally, you can exclude fields from generation
41
41
expectKind excludes, nnkBracket
42
42
excludeFields = excludes.mapIt($it)
43
+ echo obj[ 0].treeRepr
43
44
add obj[0 ][1 ], ident(" setters" )
44
45
obj
45
46
@@ -66,15 +67,17 @@ proc walkField(f: NimNode, id: NimNode) {.compileTime.} =
66
67
fieldName = $ x
67
68
procName = genProcIdent(x)
68
69
else : discard
70
+ let paramIdent = ident(id.strVal[0 ].toLowerAscii & id.strVal[1 ..^ 1 ])
69
71
var body = newStmtList()
70
72
add body, newCommentStmtNode(" Getter handle to return `" & $ fieldName & " `" )
73
+ add body, newDotExpr(paramIdent, ident(fieldName))
71
74
add genGetters[id.strVal],
72
75
newProc(
73
76
nnkPostfix.newTree(ident(" *" ), procName),
74
77
params = [
75
78
returnType,
76
79
nnkIdentDefs.newTree(
77
- ident(id.strVal[ 0 ].toLowerAscii & id.strVal[ 1 ..^ 1 ]) ,
80
+ paramIdent ,
78
81
id,
79
82
newEmptyNode()
80
83
),
@@ -105,6 +108,7 @@ macro getters*(obj: untyped) =
105
108
macro getters* (excludes: untyped , obj: untyped ) =
106
109
expectKind excludes, nnkBracket
107
110
excludeFields = excludes.mapIt($ it)
111
+ echo obj[0 ].treeRepr
108
112
add obj[0 ][1 ], ident(" getters" )
109
113
obj
110
114
0 commit comments