Workaround nim bug, startList made public

This commit is contained in:
Yuriy Glukhov 2018-05-16 10:37:26 +03:00 committed by zah
parent 6dddfdf675
commit 63af57837d

View File

@ -120,7 +120,7 @@ proc appendRawList(self; bytes: BytesRange) =
output.add(bytes)
maybeClosePendingLists()
proc startList(self; listSize: int) =
proc startList*(self; listSize: int) =
if listSize == 0:
appendRawList(BytesRange())
else:
@ -186,12 +186,7 @@ proc append*[T](self; listOrBlob: openarray[T]) =
for i in 0 ..< listOrBlob.len:
self.append listOrBlob[i]
proc append*(self; data: object|tuple, wrapInList = wrapObjectsInList) =
# TODO: This append proc should be overloaded by `BytesRange` after
# nim bug #7416 is fixed.
when data is BytesRange:
appendBytesRange(data)
else:
proc appendTupleOrObject(self; data: object|tuple, wrapInList: bool) =
mixin enumerateRlpFields, append
const wrapInList = wrapObjectsInList
@ -205,6 +200,17 @@ proc append*(self; data: object|tuple, wrapInList = wrapObjectsInList) =
template op(x) = append(self, x)
enumerateRlpFields(data, op)
proc append*(self; data: object, wrapInList = wrapObjectsInList) {.inline.} =
# TODO: This append proc should be overloaded by `BytesRange` after
# nim bug #7416 is fixed.
when data is BytesRange:
self.appendBytesRange(data)
else:
self.appendTupleOrObject(data, wrapInList)
proc append*(self; data: tuple, wrapInList = wrapObjectsInList) {.inline.} =
self.appendTupleOrObject(data, wrapInList)
proc initRlpList*(listSize: int): RlpWriter =
result = initRlpWriter()
startList(result, listSize)