Apply fix for recent Nim devel changes. (#300)
This commit is contained in:
parent
41b82cdea3
commit
e9d0e2d208
|
@ -820,7 +820,7 @@ proc write*(wstream: AsyncStreamWriter, pbytes: pointer,
|
|||
except CatchableError as exc:
|
||||
raise newAsyncStreamWriteError(exc)
|
||||
|
||||
proc write*(wstream: AsyncStreamWriter, sbytes: seq[byte],
|
||||
proc write*(wstream: AsyncStreamWriter, sbytes: sink seq[byte],
|
||||
msglen = -1) {.async.} =
|
||||
## Write sequence of bytes ``sbytes`` of length ``msglen`` to writer
|
||||
## stream ``wstream``.
|
||||
|
@ -852,8 +852,11 @@ proc write*(wstream: AsyncStreamWriter, sbytes: seq[byte],
|
|||
wstream.bytesCount = wstream.bytesCount + uint64(length)
|
||||
else:
|
||||
var item = WriteItem(kind: Sequence)
|
||||
if not isLiteral(sbytes):
|
||||
shallowCopy(item.dataSeq, sbytes)
|
||||
when declared(shallowCopy):
|
||||
if not(isLiteral(sbytes)):
|
||||
shallowCopy(item.dataSeq, sbytes)
|
||||
else:
|
||||
item.dataSeq = sbytes
|
||||
else:
|
||||
item.dataSeq = sbytes
|
||||
item.size = length
|
||||
|
@ -869,7 +872,7 @@ proc write*(wstream: AsyncStreamWriter, sbytes: seq[byte],
|
|||
except CatchableError as exc:
|
||||
raise newAsyncStreamWriteError(exc)
|
||||
|
||||
proc write*(wstream: AsyncStreamWriter, sbytes: string,
|
||||
proc write*(wstream: AsyncStreamWriter, sbytes: sink string,
|
||||
msglen = -1) {.async.} =
|
||||
## Write string ``sbytes`` of length ``msglen`` to writer stream ``wstream``.
|
||||
##
|
||||
|
@ -900,8 +903,11 @@ proc write*(wstream: AsyncStreamWriter, sbytes: string,
|
|||
wstream.bytesCount = wstream.bytesCount + uint64(length)
|
||||
else:
|
||||
var item = WriteItem(kind: String)
|
||||
if not isLiteral(sbytes):
|
||||
shallowCopy(item.dataStr, sbytes)
|
||||
when declared(shallowCopy):
|
||||
if not(isLiteral(sbytes)):
|
||||
shallowCopy(item.dataStr, sbytes)
|
||||
else:
|
||||
item.dataStr = sbytes
|
||||
else:
|
||||
item.dataStr = sbytes
|
||||
item.size = length
|
||||
|
|
|
@ -768,13 +768,17 @@ proc send*(transp: DatagramTransport, pbytes: pointer,
|
|||
transp.resumeWrite()
|
||||
return retFuture
|
||||
|
||||
proc send*(transp: DatagramTransport, msg: string, msglen = -1): Future[void] =
|
||||
proc send*(transp: DatagramTransport, msg: sink string,
|
||||
msglen = -1): Future[void] =
|
||||
## Send string ``msg`` using transport ``transp`` to remote destination
|
||||
## address which was bounded on transport.
|
||||
var retFuture = newFutureStr[void]("datagram.transport.send(string)")
|
||||
transp.checkClosed(retFuture)
|
||||
if not isLiteral(msg):
|
||||
shallowCopy(retFuture.gcholder, msg)
|
||||
when declared(shallowCopy):
|
||||
if not(isLiteral(msg)):
|
||||
shallowCopy(retFuture.gcholder, msg)
|
||||
else:
|
||||
retFuture.gcholder = msg
|
||||
else:
|
||||
retFuture.gcholder = msg
|
||||
let length = if msglen <= 0: len(msg) else: msglen
|
||||
|
@ -786,14 +790,17 @@ proc send*(transp: DatagramTransport, msg: string, msglen = -1): Future[void] =
|
|||
transp.resumeWrite()
|
||||
return retFuture
|
||||
|
||||
proc send*[T](transp: DatagramTransport, msg: seq[T],
|
||||
proc send*[T](transp: DatagramTransport, msg: sink seq[T],
|
||||
msglen = -1): Future[void] =
|
||||
## Send string ``msg`` using transport ``transp`` to remote destination
|
||||
## address which was bounded on transport.
|
||||
var retFuture = newFutureSeq[void, T]("datagram.transport.send(seq)")
|
||||
transp.checkClosed(retFuture)
|
||||
if not isLiteral(msg):
|
||||
shallowCopy(retFuture.gcholder, msg)
|
||||
when declared(shallowCopy):
|
||||
if not(isLiteral(msg)):
|
||||
shallowCopy(retFuture.gcholder, msg)
|
||||
else:
|
||||
retFuture.gcholder = msg
|
||||
else:
|
||||
retFuture.gcholder = msg
|
||||
let length = if msglen <= 0: (len(msg) * sizeof(T)) else: (msglen * sizeof(T))
|
||||
|
@ -819,13 +826,16 @@ proc sendTo*(transp: DatagramTransport, remote: TransportAddress,
|
|||
return retFuture
|
||||
|
||||
proc sendTo*(transp: DatagramTransport, remote: TransportAddress,
|
||||
msg: string, msglen = -1): Future[void] =
|
||||
msg: sink string, msglen = -1): Future[void] =
|
||||
## Send string ``msg`` using transport ``transp`` to remote destination
|
||||
## address ``remote``.
|
||||
var retFuture = newFutureStr[void]("datagram.transport.sendTo(string)")
|
||||
transp.checkClosed(retFuture)
|
||||
if not isLiteral(msg):
|
||||
shallowCopy(retFuture.gcholder, msg)
|
||||
when declared(shallowCopy):
|
||||
if not(isLiteral(msg)):
|
||||
shallowCopy(retFuture.gcholder, msg)
|
||||
else:
|
||||
retFuture.gcholder = msg
|
||||
else:
|
||||
retFuture.gcholder = msg
|
||||
let length = if msglen <= 0: len(msg) else: msglen
|
||||
|
@ -839,13 +849,16 @@ proc sendTo*(transp: DatagramTransport, remote: TransportAddress,
|
|||
return retFuture
|
||||
|
||||
proc sendTo*[T](transp: DatagramTransport, remote: TransportAddress,
|
||||
msg: seq[T], msglen = -1): Future[void] =
|
||||
msg: sink seq[T], msglen = -1): Future[void] =
|
||||
## Send sequence ``msg`` using transport ``transp`` to remote destination
|
||||
## address ``remote``.
|
||||
var retFuture = newFutureSeq[void, T]("datagram.transport.sendTo(seq)")
|
||||
transp.checkClosed(retFuture)
|
||||
if not isLiteral(msg):
|
||||
shallowCopy(retFuture.gcholder, msg)
|
||||
when declared(shallowCopy):
|
||||
if not(isLiteral(msg)):
|
||||
shallowCopy(retFuture.gcholder, msg)
|
||||
else:
|
||||
retFuture.gcholder = msg
|
||||
else:
|
||||
retFuture.gcholder = msg
|
||||
let length = if msglen <= 0: (len(msg) * sizeof(T)) else: (msglen * sizeof(T))
|
||||
|
@ -864,7 +877,10 @@ proc peekMessage*(transp: DatagramTransport, msg: var seq[byte],
|
|||
if ReadError in transp.state:
|
||||
transp.state.excl(ReadError)
|
||||
raise transp.getError()
|
||||
shallowCopy(msg, transp.buffer)
|
||||
when declared(shallowCopy):
|
||||
shallowCopy(msg, transp.buffer)
|
||||
else:
|
||||
msg = transp.buffer
|
||||
msglen = transp.buflen
|
||||
|
||||
proc getMessage*(transp: DatagramTransport): seq[byte] {.
|
||||
|
|
|
@ -2116,7 +2116,8 @@ proc write*(transp: StreamTransport, pbytes: pointer,
|
|||
transp.resumeWrite()
|
||||
return retFuture
|
||||
|
||||
proc write*(transp: StreamTransport, msg: string, msglen = -1): Future[int] =
|
||||
proc write*(transp: StreamTransport, msg: sink string,
|
||||
msglen = -1): Future[int] =
|
||||
## Write data from string ``msg`` using transport ``transp``.
|
||||
var retFuture = newFutureStr[int]("stream.transport.write(string)")
|
||||
transp.checkClosed(retFuture)
|
||||
|
@ -2134,12 +2135,17 @@ proc write*(transp: StreamTransport, msg: string, msglen = -1): Future[int] =
|
|||
let
|
||||
written = nbytes - rbytes # In case fastWrite wrote some
|
||||
|
||||
pbytes = if not(isLiteral(msg)):
|
||||
shallowCopy(retFuture.gcholder, msg)
|
||||
cast[ptr byte](addr retFuture.gcholder[written])
|
||||
else:
|
||||
retFuture.gcholder = msg[written..<nbytes]
|
||||
cast[ptr byte](addr retFuture.gcholder[0])
|
||||
pbytes =
|
||||
when declared(shallowCopy):
|
||||
if not(isLiteral(msg)):
|
||||
shallowCopy(retFuture.gcholder, msg)
|
||||
cast[ptr byte](addr retFuture.gcholder[written])
|
||||
else:
|
||||
retFuture.gcholder = msg[written ..< nbytes]
|
||||
cast[ptr byte](addr retFuture.gcholder[0])
|
||||
else:
|
||||
retFuture.gcholder = msg[written ..< nbytes]
|
||||
cast[ptr byte](addr retFuture.gcholder[0])
|
||||
|
||||
var vector = StreamVector(kind: DataBuffer, writer: retFuture,
|
||||
buf: pbytes, buflen: rbytes, size: nbytes)
|
||||
|
@ -2147,7 +2153,8 @@ proc write*(transp: StreamTransport, msg: string, msglen = -1): Future[int] =
|
|||
transp.resumeWrite()
|
||||
return retFuture
|
||||
|
||||
proc write*[T](transp: StreamTransport, msg: seq[T], msglen = -1): Future[int] =
|
||||
proc write*[T](transp: StreamTransport, msg: sink seq[T],
|
||||
msglen = -1): Future[int] =
|
||||
## Write sequence ``msg`` using transport ``transp``.
|
||||
var retFuture = newFutureSeq[int, T]("stream.transport.write(seq)")
|
||||
transp.checkClosed(retFuture)
|
||||
|
@ -2165,12 +2172,17 @@ proc write*[T](transp: StreamTransport, msg: seq[T], msglen = -1): Future[int] =
|
|||
let
|
||||
written = nbytes - rbytes # In case fastWrite wrote some
|
||||
|
||||
pbytes = if not(isLiteral(msg)):
|
||||
shallowCopy(retFuture.gcholder, msg)
|
||||
cast[ptr byte](addr retFuture.gcholder[written])
|
||||
else:
|
||||
retFuture.gcholder = msg[written..<nbytes]
|
||||
cast[ptr byte](addr retFuture.gcholder[0])
|
||||
pbytes =
|
||||
when declared(shallowCopy):
|
||||
if not(isLiteral(msg)):
|
||||
shallowCopy(retFuture.gcholder, msg)
|
||||
cast[ptr byte](addr retFuture.gcholder[written])
|
||||
else:
|
||||
retFuture.gcholder = msg[written ..< nbytes]
|
||||
cast[ptr byte](addr retFuture.gcholder[0])
|
||||
else:
|
||||
retFuture.gcholder = msg[written ..< nbytes]
|
||||
cast[ptr byte](addr retFuture.gcholder[0])
|
||||
|
||||
var vector = StreamVector(kind: DataBuffer, writer: retFuture,
|
||||
buf: pbytes, buflen: rbytes, size: nbytes)
|
||||
|
|
Loading…
Reference in New Issue