diff --git a/.swift-version b/.swift-version index 16c5c8e..d0b9234 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -DEVELOPMENT-SNAPSHOT-2016-04-25-a +DEVELOPMENT-SNAPSHOT-2016-05-09-a diff --git a/Source/Venice/Coroutine/Coroutine.swift b/Source/Venice/Coroutine/Coroutine.swift index dacf673..f96ecdc 100644 --- a/Source/Venice/Coroutine/Coroutine.swift +++ b/Source/Venice/Coroutine/Coroutine.swift @@ -34,23 +34,23 @@ public extension Double { } /// Runs the expression in a lightweight coroutine. -public func co(_ routine: Void -> Void) { +public func co(_ routine: (Void) -> Void) { var _routine = routine CLibvenice.co(&_routine, { routinePointer in - UnsafeMutablePointer<(Void -> Void)>(routinePointer).pointee() + UnsafeMutablePointer<((Void) -> Void)>(routinePointer!).pointee() }, "co") } /// Runs the expression in a lightweight coroutine. -public func co(_ routine: @autoclosure(escaping) Void -> Void) { - var _routine: Void -> Void = routine +public func co(_ routine: @autoclosure(escaping) (Void) -> Void) { + var _routine: (Void) -> Void = routine CLibvenice.co(&_routine, { routinePointer in - UnsafeMutablePointer<(Void -> Void)>(routinePointer).pointee() + UnsafeMutablePointer<((Void) -> Void)>(routinePointer!).pointee() }, "co") } /// Runs the expression in a lightweight coroutine after the given duration. -public func after(_ napDuration: Double, routine: Void -> Void) { +public func after(_ napDuration: Double, routine: (Void) -> Void) { co { nap(for: napDuration) routine() @@ -58,7 +58,7 @@ public func after(_ napDuration: Double, routine: Void -> Void) { } /// Runs the expression in a lightweight coroutine periodically. Call done() to leave the loop. -public func every(_ napDuration: Double, routine: (done: Void -> Void) -> Void) { +public func every(_ napDuration: Double, routine: (done: (Void) -> Void) -> Void) { co { var done = false while !done { diff --git a/Source/Venice/FallibleChannel/FallibleChannel.swift b/Source/Venice/FallibleChannel/FallibleChannel.swift index 2c25c8b..db4075d 100644 --- a/Source/Venice/FallibleChannel/FallibleChannel.swift +++ b/Source/Venice/FallibleChannel/FallibleChannel.swift @@ -36,14 +36,14 @@ public enum ChannelResult { case value(T) case error(ErrorProtocol) - public func success(_ closure: @noescape T -> Void) { + public func success(_ closure: @noescape (T) -> Void) { switch self { case .value(let value): closure(value) default: break } } - public func failure(_ closure: @noescape ErrorProtocol -> Void) { + public func failure(_ closure: @noescape (ErrorProtocol) -> Void) { switch self { case .error(let error): closure(error) default: break diff --git a/Source/Venice/Select/Select.swift b/Source/Venice/Select/Select.swift index b0329c8..609e8e3 100644 --- a/Source/Venice/Select/Select.swift +++ b/Source/Venice/Select/Select.swift @@ -31,9 +31,9 @@ protocol SelectCase { final class ChannelReceiveCase: SelectCase { let channel: Channel - let closure: T -> Void + let closure: (T) -> Void - init(channel: Channel, closure: T -> Void) { + init(channel: Channel, closure: (T) -> Void) { self.channel = channel self.closure = closure } @@ -51,9 +51,9 @@ final class ChannelReceiveCase: SelectCase { final class ReceivingChannelReceiveCase: SelectCase { let channel: ReceivingChannel - let closure: T -> Void + let closure: (T) -> Void - init(channel: ReceivingChannel, closure: T -> Void) { + init(channel: ReceivingChannel, closure: (T) -> Void) { self.channel = channel self.closure = closure } @@ -71,9 +71,9 @@ final class ReceivingChannelReceiveCase: SelectCase { final class FallibleChannelReceiveCase: SelectCase { let channel: FallibleChannel - var closure: ChannelResult -> Void + var closure: (ChannelResult) -> Void - init(channel: FallibleChannel, closure: ChannelResult -> Void) { + init(channel: FallibleChannel, closure: (ChannelResult) -> Void) { self.channel = channel self.closure = closure } @@ -91,9 +91,9 @@ final class FallibleChannelReceiveCase: SelectCase { final class FallibleReceivingChannelReceiveCase: SelectCase { let channel: FallibleReceivingChannel - var closure: ChannelResult -> Void + var closure: (ChannelResult) -> Void - init(channel: FallibleReceivingChannel, closure: ChannelResult -> Void) { + init(channel: FallibleReceivingChannel, closure: (ChannelResult) -> Void) { self.channel = channel self.closure = closure } @@ -112,9 +112,9 @@ final class FallibleReceivingChannelReceiveCase: SelectCase { final class ChannelSendCase: SelectCase { let channel: Channel var value: T - let closure: Void -> Void + let closure: (Void) -> Void - init(channel: Channel, value: T, closure: Void -> Void) { + init(channel: Channel, value: T, closure: (Void) -> Void) { self.channel = channel self.value = value self.closure = closure @@ -132,9 +132,9 @@ final class ChannelSendCase: SelectCase { final class SendingChannelSendCase: SelectCase { let channel: SendingChannel var value: T - let closure: Void -> Void + let closure: (Void) -> Void - init(channel: SendingChannel, value: T, closure: Void -> Void) { + init(channel: SendingChannel, value: T, closure: (Void) -> Void) { self.channel = channel self.value = value self.closure = closure @@ -152,9 +152,9 @@ final class SendingChannelSendCase: SelectCase { final class FallibleChannelSendCase: SelectCase { let channel: FallibleChannel let value: T - let closure: Void -> Void + let closure: (Void) -> Void - init(channel: FallibleChannel, value: T, closure: Void -> Void) { + init(channel: FallibleChannel, value: T, closure: (Void) -> Void) { self.channel = channel self.value = value self.closure = closure @@ -172,9 +172,9 @@ final class FallibleChannelSendCase: SelectCase { final class FallibleSendingChannelSendCase: SelectCase { let channel: FallibleSendingChannel let value: T - let closure: Void -> Void + let closure: (Void) -> Void - init(channel: FallibleSendingChannel, value: T, closure: Void -> Void) { + init(channel: FallibleSendingChannel, value: T, closure: (Void) -> Void) { self.channel = channel self.value = value self.closure = closure @@ -192,9 +192,9 @@ final class FallibleSendingChannelSendCase: SelectCase { final class FallibleChannelSendErrorCase: SelectCase { let channel: FallibleChannel let error: ErrorProtocol - let closure: Void -> Void + let closure: (Void) -> Void - init(channel: FallibleChannel, error: ErrorProtocol, closure: Void -> Void) { + init(channel: FallibleChannel, error: ErrorProtocol, closure: (Void) -> Void) { self.channel = channel self.error = error self.closure = closure @@ -212,9 +212,9 @@ final class FallibleChannelSendErrorCase: SelectCase { final class FallibleSendingChannelSendErrorCase: SelectCase { let channel: FallibleSendingChannel let error: ErrorProtocol - let closure: Void -> Void + let closure: (Void) -> Void - init(channel: FallibleSendingChannel, error: ErrorProtocol, closure: Void -> Void) { + init(channel: FallibleSendingChannel, error: ErrorProtocol, closure: (Void) -> Void) { self.channel = channel self.error = error self.closure = closure @@ -231,9 +231,9 @@ final class FallibleSendingChannelSendErrorCase: SelectCase { final class TimeoutCase: SelectCase { let channel: Channel - let closure: Void -> Void + let closure: (Void) -> Void - init(channel: Channel, closure: Void -> Void) { + init(channel: Channel, closure: (Void) -> Void) { self.channel = channel self.closure = closure } @@ -249,79 +249,79 @@ final class TimeoutCase: SelectCase { public class SelectCaseBuilder { var cases: [SelectCase] = [] - var otherwise: (Void -> Void)? + var otherwise: ((Void) -> Void)? - public func received(valueFrom channel: Channel?, closure: T -> Void) { + public func received(valueFrom channel: Channel?, closure: (T) -> Void) { if let channel = channel { let selectCase = ChannelReceiveCase(channel: channel, closure: closure) cases.append(selectCase) } } - public func received(valueFrom channel: ReceivingChannel?, closure: T -> Void) { + public func received(valueFrom channel: ReceivingChannel?, closure: (T) -> Void) { if let channel = channel { let selectCase = ReceivingChannelReceiveCase(channel: channel, closure: closure) cases.append(selectCase) } } - public func received(resultFrom channel: FallibleChannel?, closure: ChannelResult -> Void) { + public func received(resultFrom channel: FallibleChannel?, closure: (ChannelResult) -> Void) { if let channel = channel { let selectCase = FallibleChannelReceiveCase(channel: channel, closure: closure) cases.append(selectCase) } } - public func received(resultFrom channel: FallibleReceivingChannel?, closure: ChannelResult -> Void) { + public func received(resultFrom channel: FallibleReceivingChannel?, closure: (ChannelResult) -> Void) { if let channel = channel { let selectCase = FallibleReceivingChannelReceiveCase(channel: channel, closure: closure) cases.append(selectCase) } } - public func sent(_ value: T, to channel: Channel?, closure: Void -> Void) { + public func sent(_ value: T, to channel: Channel?, closure: (Void) -> Void) { if let channel = channel where !channel.closed { let selectCase = ChannelSendCase(channel: channel, value: value, closure: closure) cases.append(selectCase) } } - public func sent(_ value: T, to channel: SendingChannel?, closure: Void -> Void) { + public func sent(_ value: T, to channel: SendingChannel?, closure: (Void) -> Void) { if let channel = channel where !channel.closed { let selectCase = SendingChannelSendCase(channel: channel, value: value, closure: closure) cases.append(selectCase) } } - public func sent(_ value: T, to channel: FallibleChannel?, closure: Void -> Void) { + public func sent(_ value: T, to channel: FallibleChannel?, closure: (Void) -> Void) { if let channel = channel where !channel.closed { let selectCase = FallibleChannelSendCase(channel: channel, value: value, closure: closure) cases.append(selectCase) } } - public func sent(_ value: T, to channel: FallibleSendingChannel?, closure: Void -> Void) { + public func sent(_ value: T, to channel: FallibleSendingChannel?, closure: (Void) -> Void) { if let channel = channel where !channel.closed { let selectCase = FallibleSendingChannelSendCase(channel: channel, value: value, closure: closure) cases.append(selectCase) } } - public func sent(_ error: ErrorProtocol, to channel: FallibleChannel?, closure: Void -> Void) { + public func sent(_ error: ErrorProtocol, to channel: FallibleChannel?, closure: (Void) -> Void) { if let channel = channel where !channel.closed { let selectCase = FallibleChannelSendErrorCase(channel: channel, error: error, closure: closure) cases.append(selectCase) } } - public func sent(_ error: ErrorProtocol, to channel: FallibleSendingChannel?, closure: Void -> Void) { + public func sent(_ error: ErrorProtocol, to channel: FallibleSendingChannel?, closure: (Void) -> Void) { if let channel = channel where !channel.closed { let selectCase = FallibleSendingChannelSendErrorCase(channel: channel, error: error, closure: closure) cases.append(selectCase) } } - public func timedOut(_ deadline: Double, closure: Void -> Void) { + public func timedOut(_ deadline: Double, closure: (Void) -> Void) { let done = Channel() co { wake(at: deadline) @@ -331,7 +331,7 @@ public class SelectCaseBuilder { cases.append(selectCase) } - public func otherwise(_ closure: Void -> Void) { + public func otherwise(_ closure: (Void) -> Void) { self.otherwise = closure } } @@ -342,7 +342,7 @@ private func select(_ builder: SelectCaseBuilder) { var clauses: [UnsafeMutablePointer] = [] for (index, selectCase) in builder.cases.enumerated() { - let clause = malloc(mill_clauselen()) + let clause = malloc(mill_clauselen())! clauses.append(clause) selectCase.register(clause, index: index) } @@ -372,7 +372,7 @@ public func sel(_ build: @noescape (when: SelectCaseBuilder) -> Void) { select(build) } -public func forSelect(_ build: @noescape (when: SelectCaseBuilder, done: Void -> Void) -> Void) { +public func forSelect(_ build: @noescape (when: SelectCaseBuilder, done: (Void) -> Void) -> Void) { let builder = SelectCaseBuilder() var keepRunning = true func done() { @@ -385,6 +385,6 @@ public func forSelect(_ build: @noescape (when: SelectCaseBuilder, done: Void -> } } -public func forSel(build: @noescape (when: SelectCaseBuilder, done: Void -> Void) -> Void) { +public func forSel(build: @noescape (when: SelectCaseBuilder, done: (Void) -> Void) -> Void) { forSelect(build) } diff --git a/Tests/Venice/VeniceTests.swift b/Tests/Venice/VeniceTests.swift index 582c205..bfaa5f3 100644 --- a/Tests/Venice/VeniceTests.swift +++ b/Tests/Venice/VeniceTests.swift @@ -8,7 +8,7 @@ class VeniceTests: XCTestCase { } extension VeniceTests { - static var allTests : [(String, VeniceTests -> () throws -> Void)] { + static var allTests : [(String, (VeniceTests) -> () throws -> Void)] { return [ ("testReality", testReality), ]