Commit 92457a156cd8d842c21cd3844247a755af01d144
1 parent
18d805d8
don't wrap object fields as default
Showing
1 changed file
with
5 additions
and
4 deletions
src/squeaknim.nim
@@ -164,7 +164,7 @@ macro exportSt*(body: stmt): stmt = | @@ -164,7 +164,7 @@ macro exportSt*(body: stmt): stmt = | ||
164 | "\t^self externalCallFailed\C!\C\C") | 164 | "\t^self externalCallFailed\C!\C\C") |
165 | stCode.add(st & "\C\t\"Generated by NimSqueak\"\C\t" & apicall) | 165 | stCode.add(st & "\C\t\"Generated by NimSqueak\"\C\t" & apicall) |
166 | 166 | ||
167 | -macro wrapObject*(typ: stmt): stmt = | 167 | +macro wrapObject*(typ: stmt; wrapFields=false): stmt = |
168 | ## Declares a SmallTalk wrapper class. | 168 | ## Declares a SmallTalk wrapper class. |
169 | var t = typ.getType() | 169 | var t = typ.getType() |
170 | if t.typeKind == ntyTypeDesc: | 170 | if t.typeKind == ntyTypeDesc: |
@@ -177,9 +177,10 @@ macro wrapObject*(typ: stmt): stmt = | @@ -177,9 +177,10 @@ macro wrapObject*(typ: stmt): stmt = | ||
177 | t = t[1] | 177 | t = t[1] |
178 | expectKind t, nnkRecList | 178 | expectKind t, nnkRecList |
179 | var fields = "" | 179 | var fields = "" |
180 | - for i in 0.. < t.len: | ||
181 | - expectKind t[i], nnkSym | ||
182 | - fields.addf "\t\t($# '$#')\C", $t[i], mapTypeToC(t[i]) | 180 | + if $wrapFields == "true": |
181 | + for i in 0.. < t.len: | ||
182 | + expectKind t[i], nnkSym | ||
183 | + fields.addf "\t\t($# '$#')\C", $t[i], mapTypeToC(t[i]) | ||
183 | 184 | ||
184 | let st = ("ExternalStructure subclass: #$1\C" & | 185 | let st = ("ExternalStructure subclass: #$1\C" & |
185 | "\tinstanceVariableNames: ''\C" & | 186 | "\tinstanceVariableNames: ''\C" & |