Skip to content

Commit

Permalink
chore(deps): remove upraises (#44)
Browse files Browse the repository at this point in the history
Removes upraises. One of the tasks in
#37.
  • Loading branch information
diegomrsantos authored Aug 14, 2024
1 parent f0c6b05 commit ce555a7
Show file tree
Hide file tree
Showing 15 changed files with 23 additions and 28 deletions.
1 change: 0 additions & 1 deletion quic.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ requires "stew >= 0.1.0 & < 0.2.0"
requires "chronos >= 3.0.0 & < 4.0.0"
requires "nimcrypto >= 0.6.0 & < 0.7.0"
requires "ngtcp2 >= 0.32.0 & < 0.34.0"
requires "upraises >= 0.1.0 & < 0.2.0"
requires "unittest2 >= 0.2.2 & < 0.3.0"
requires "chronicles >= 0.10.2"
2 changes: 0 additions & 2 deletions quic/basics.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import pkg/chronos
import pkg/upraises
import pkg/stew/results
import ./udp/datagram
import ./errors
Expand All @@ -8,4 +7,3 @@ export chronos
export datagram
export results
export errors
export upraises
6 changes: 3 additions & 3 deletions quic/connection.nim
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type
remote: TransportAddress
quic: QuicConnection
loop: Future[void]
onClose: Opt[proc() {.gcsafe, upraises: [].}]
onClose: Opt[proc() {.gcsafe, raises: [].}]
closed: AsyncEvent
IncomingConnection = ref object of Connection
OutgoingConnection = ref object of Connection
Expand All @@ -32,7 +32,7 @@ proc `onNewId=`*(connection: Connection, callback: IdCallback) =
proc `onRemoveId=`*(connection: Connection, callback: IdCallback) =
connection.quic.onRemoveId = callback

proc `onClose=`*(connection: Connection, callback: proc() {.gcsafe, upraises: [].}) =
proc `onClose=`*(connection: Connection, callback: proc() {.gcsafe, raises: [].}) =
connection.onClose = Opt.some(callback)

proc drop*(connection: Connection) {.async.} =
Expand Down Expand Up @@ -67,7 +67,7 @@ proc stopSending(connection: Connection) {.async.} =
await connection.loop.cancelAndWait()
trace "Stopped sending loop"

method closeUdp(connection: Connection) {.async, base, upraises: [].} =
method closeUdp(connection: Connection) {.async, base, raises: [].} =
discard

method closeUdp(connection: OutgoingConnection) {.async.} =
Expand Down
4 changes: 2 additions & 2 deletions quic/helpers/asyncloop.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pkg/[chronos, upraises]
import pkg/chronos

proc asyncLoop*(repeat: proc: Future[void] {.gcsafe, upraises: [CatchableError].}): Future[void] {.async.} =
proc asyncLoop*(repeat: proc: Future[void] {.gcsafe, raises: [CatchableError].}): Future[void] {.async.} =
## Repeatedly calls the async proc `repeat` until cancelled.
## Any `Error`s that are raised in `repeat` are considered fatal and therefore
## re-raised as `Defect`s.
Expand Down
2 changes: 1 addition & 1 deletion quic/listener.nim
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ proc addConnection(listener: Listener, connection: Connection,
listener.connections[newId] = connection
connection.onRemoveId = proc(oldId: ConnectionId) =
listener.connections.del(oldId)
connection.onClose = proc {.upraises: [].} =
connection.onClose = proc {.raises: [].} =
for id in connection.ids & firstId:
listener.connections.del(id)
listener.incoming.putNoWait(connection)
Expand Down
8 changes: 4 additions & 4 deletions quic/transport/ngtcp2/connection/drainingstate.nim
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@ proc newDrainingConnection*(ids: seq[ConnectionId],
state.init(ids, duration)
state

proc onTimeout(state: DrainingConnection) {.upraises: [].} =
proc onTimeout(state: DrainingConnection) {.raises: [].} =
state.done.fire()

push: {.locks: "unknown", upraises: [QuicError].}
{.push locks: "unknown", raises: [QuicError].}

method enter*(state: DrainingConnection, connection: QuicConnection) =
procCall enter(ConnectionState(state), connection)
state.connection = Opt.some(connection)
state.timeout = newTimeout(proc {.upraises: [].} = state.onTimeout())
state.timeout = newTimeout(proc {.raises: [].} = state.onTimeout())
state.timeout.set(state.duration)

method leave(state: DrainingConnection) =
procCall leave(ConnectionState(state))
state.timeout.stop()
state.connection = Opt.none(QuicConnection)

method ids(state: DrainingConnection): seq[ConnectionId] {.upraises: [].} =
method ids(state: DrainingConnection): seq[ConnectionId] {.raises: [].} =
state.ids

method send(state: DrainingConnection) =
Expand Down
2 changes: 1 addition & 1 deletion quic/transport/ngtcp2/connection/openstate.nim
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ method leave(state: OpenConnection) =
state.quicConnection = Opt.none(QuicConnection)
trace "Left OpenConnection state"

method ids(state: OpenConnection): seq[ConnectionId] {.upraises: [].} =
method ids(state: OpenConnection): seq[ConnectionId] {.raises: [].} =
state.ngtcp2Connection.ids

method send(state: OpenConnection) =
Expand Down
4 changes: 2 additions & 2 deletions quic/transport/ngtcp2/native/connection.nim
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type
buffer*: array[4096, byte]
flowing*: AsyncEvent
timeout*: Timeout
onSend*: proc(datagram: Datagram) {.gcsafe, upraises:[].}
onSend*: proc(datagram: Datagram) {.gcsafe, raises:[].}
onIncomingStream*: proc(stream: Stream)
onHandshakeDone*: proc()
onNewId*: Opt[proc(id: ConnectionId)]
Expand All @@ -36,7 +36,7 @@ proc destroy*(connection: Ngtcp2Connection) =
connection.onNewId = Opt.none(proc(id: ConnectionId))
connection.onRemoveId = Opt.none(proc(id: ConnectionId))

proc handleTimeout(connection: Ngtcp2Connection) {.gcsafe, upraises:[].}
proc handleTimeout(connection: Ngtcp2Connection) {.gcsafe, raises:[].}

proc newConnection*(path: Path): Ngtcp2Connection =
let connection = Ngtcp2Connection()
Expand Down
2 changes: 1 addition & 1 deletion quic/transport/packets.nim
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ./packets/length
import ./packets/read
import ./packets/write

push: {.upraises: [QuicError].}
{.push raises: [QuicError].}

export packet
export length
Expand Down
2 changes: 1 addition & 1 deletion quic/transport/packets/length.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ./varints
import ./packet
import ./packetnumber

push: {.upraises: [].}
{.push raises: [].}

proc len*(packet: Packet): int =
case packet.form
Expand Down
2 changes: 0 additions & 2 deletions quic/transport/packets/packet.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import ../connectionid
import ../version
import ./packetnumber

push: {.upraises: [].}

export connectionid
export PacketNumber

Expand Down
2 changes: 1 addition & 1 deletion quic/transport/packets/read.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import ./varints
import ./packet
import ./reader

push: {.upraises: [QuicError].}
{.push raises: [QuicError].}

export reader

Expand Down
8 changes: 4 additions & 4 deletions quic/transport/quicconnection.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ type
outgoing*: AsyncQueue[Datagram]
incoming*: AsyncQueue[Stream]
handshake*: AsyncEvent
disconnect*: Opt[proc(): Future[void] {.gcsafe, upraises: [].}]
disconnect*: Opt[proc(): Future[void] {.gcsafe, raises: [].}]
onNewId*: IdCallback
onRemoveId*: IdCallback
ConnectionState* = ref object of RootObj
entered: bool
IdCallback* = proc(id: ConnectionId) {.gcsafe, upraises: [].}
IdCallback* = proc(id: ConnectionId) {.gcsafe, raises: [].}
ConnectionError* = object of QuicError

push: {.base, locks: "unknown", upraises: [QuicError].}
{.push base, locks: "unknown", raises: [QuicError].}

method enter*(state: ConnectionState, connection: QuicConnection) =
doAssert not state.entered # states are not reentrant
Expand All @@ -29,7 +29,7 @@ method enter*(state: ConnectionState, connection: QuicConnection) =
method leave*(state: ConnectionState) =
discard

method ids*(state: ConnectionState): seq[ConnectionId] {.upraises: [].} =
method ids*(state: ConnectionState): seq[ConnectionId] {.raises: [].} =
doAssert false # override this method

method send*(state: ConnectionState) =
Expand Down
2 changes: 1 addition & 1 deletion quic/transport/stream.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type
entered: bool
StreamError* = object of QuicError

push: {.locks:"unknown", upraises: [QuicError].}
{.push locks:"unknown", raises: [QuicError].}

method enter*(state: StreamState, stream: Stream) {.base.} =
doAssert not state.entered # states are not reentrant
Expand Down
4 changes: 2 additions & 2 deletions quic/transport/timeout.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import ../basics

type Timeout* = ref object
timer: Opt[TimerCallback]
onExpiry: proc () {.gcsafe, upraises:[].}
onExpiry: proc () {.gcsafe, raises:[].}
expired: AsyncEvent

proc setTimer(timeout: Timeout, moment: Moment) =
Expand All @@ -13,7 +13,7 @@ proc setTimer(timeout: Timeout, moment: Moment) =

const skip = proc () = discard

proc newTimeout*(onExpiry: proc () {.gcsafe, upraises:[].} = skip): Timeout =
proc newTimeout*(onExpiry: proc () {.gcsafe, raises:[].} = skip): Timeout =
Timeout(onExpiry: onExpiry, expired: newAsyncEvent())

proc stop*(timeout: Timeout) =
Expand Down

0 comments on commit ce555a7

Please sign in to comment.