Move stuff around; Add some missing overloads

This commit is contained in:
Zahary Karadjov 2020-05-05 23:57:27 +03:00
commit 65b43d9e38
No known key found for this signature in database
GPG key ID: C8936F8A3073D609
4 changed files with 50 additions and 36 deletions

View file

@ -53,11 +53,11 @@ type
FileInputStream = ref object of InputStream
file: File
template Async*(s: InputStream): AsyncInputStream =
AsyncInputStream(s)
template Sync*(s: InputStream): InputStream = s
template Async*(s: InputStream): AsyncInputStream = AsyncInputStream(s)
template Sync*(s: AsyncInputStream): InputStream =
InputStream(s)
template Sync*(s: AsyncInputStream): InputStream = InputStream(s)
template Async*(s: AsyncInputStream): AsyncInputStream = s
proc disconnectInputDevice(s: InputStream) =
# TODO
@ -578,9 +578,17 @@ proc advance*(s: InputStream) =
else:
flipPage s
proc advance*(s: InputStream, n: Natural) =
# TODO This is silly, implement it properly
for i in 0 ..< n:
advance s
template advance*(s: AsyncInputStream) =
advance InputStream(s)
template advance*(s: AsyncInputStream, n: Natural) =
advance InputStream(s), n
proc drainBuffersInto*(s: InputStream, dstAddr: ptr byte, dstLen: Natural): Natural =
var
dst = dstAddr