Skip to content

Commit 151c046

Browse files
sealmovePMunch
authored andcommitted
generate extra parameters and arguments for custom write proc
1 parent 2287fd5 commit 151c046

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

binaryparse.nim

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,10 @@ proc decodeType(t: NimNode, stream: NimNode, seenFields: seq[string]):
230230
i = 1
231231
while i < t.len:
232232
customProcRead.add(t[i])
233+
customProcWrite.add(t[i])
233234
inc i
234235
customProcRead.replace(seenFields)
236+
customProcWrite.replace(seenFields)
235237
return (
236238
size: BiggestInt(0),
237239
endian: defaultEndian,
@@ -354,7 +356,7 @@ proc createWriteStatement(
354356
kind = info.kind
355357
custom = info.customWriter
356358
if custom != nil:
357-
custom.add(field)
359+
custom.insert(2, field)
358360
result = (quote do:
359361
`custom`
360362
)
@@ -733,6 +735,7 @@ macro createParser*(name: untyped, paramsAndDef: varargs[untyped]): untyped =
733735
let `name` = (get: `readerName`, put: `writerName`)
734736
for p in extraParams:
735737
result[0][3].add p
738+
result[1][3].add p
736739

737740
when defined(binaryparseEcho):
738741
echo result.toStrLit

0 commit comments

Comments
 (0)