Skip to content
This repository has been archived by the owner on Aug 2, 2024. It is now read-only.

Commit

Permalink
Merge pull request #19 from WeltN24/Swift4
Browse files Browse the repository at this point in the history
migrate to swift 4
  • Loading branch information
toupper authored Mar 20, 2018
2 parents fddc036 + 0630b73 commit b8bdd81
Show file tree
Hide file tree
Showing 16 changed files with 74 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cache:
bundler: true
directories:
- "./Carthage"
osx_image: xcode8.3
osx_image: xcode9.2

# before_install:
before_script:
Expand Down
4 changes: 2 additions & 2 deletions Cartfile.private
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github "Quick/Quick" "v0.10.0"
github "Quick/Nimble" "v5.1.1"
github "Quick/Quick" ~> 1.2.0
github "Quick/Nimble" ~> 7.0.2
4 changes: 2 additions & 2 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github "Quick/Nimble" "v5.1.1"
github "Quick/Quick" "v0.10.0"
github "Quick/Nimble" "v7.0.3"
github "Quick/Quick" "v1.2.0"
6 changes: 3 additions & 3 deletions PiedPiper/Future+Recover.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ extension Future {
- returns: A new Future that will behave as this Future, except when this Future fails. In that case, it will succeed with the rescue value
*/
public func recover(_ handler: @escaping (Void) -> T) -> Future<T> {
public func recover(_ handler: @escaping () -> T) -> Future<T> {
return _recover { recovered in
recovered.succeed(handler())
}
Expand All @@ -47,7 +47,7 @@ extension Future {
- returns: A new Future that will behave as this Future, except when this Future fails. In that case, it will mimic the outcome of the Future provided by the handler
*/
public func recover(_ handler: @escaping (Void) -> Future<T>) -> Future<T> {
public func recover(_ handler: @escaping () -> Future<T>) -> Future<T> {
return _recover { recovered in
recovered.mimic(handler())
}
Expand All @@ -60,7 +60,7 @@ extension Future {
- returns: A new Future that will behave as this Future, except when this Future fails. In that case, it will mimic the outcome of the Result provided by the handler
*/
public func recover(_ handler: @escaping (Void) -> Result<T>) -> Future<T> {
public func recover(_ handler: @escaping () -> Result<T>) -> Future<T> {
return _recover { recovered in
recovered.mimic(handler())
}
Expand Down
4 changes: 2 additions & 2 deletions PiedPiper/Future+Retry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation
- returns: A future that fails if all the generated futures have failed, or succeeds if one of the generated futures succeeds
*/
public func retry<T>(_ count: Int, every delay: TimeInterval, futureClosure: @escaping (Void) -> Future<T>) -> Future<T> {
public func retry<T>(_ count: Int, every delay: TimeInterval, futureClosure: @escaping () -> Future<T>) -> Future<T> {
if count <= 0 {
return futureClosure()
}
Expand All @@ -18,7 +18,7 @@ public func retry<T>(_ count: Int, every delay: TimeInterval, futureClosure: @es

result.mimic(
futureClosure()
.recover { Void -> Future<T> in
.recover { () -> Future<T> in
let delayed = Promise<T>()

GCD.delay(delay, closure: {}).onSuccess {
Expand Down
4 changes: 2 additions & 2 deletions PiedPiper/Future.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ open class Future<T>: Async {
The initialized future will succeed if the result of the closure is .Some, and will fail with a FutureInitializationError.ClosureReturnedNil if it's .None. The future will report on the main queue
*/
public convenience init(closure: @escaping (Void) -> T?) {
public convenience init(closure: @escaping () -> T?) {
let promise = Promise<T>()

self.init(promise: promise)
Expand Down Expand Up @@ -95,7 +95,7 @@ open class Future<T>: Async {
- returns: The updated Future
*/
@discardableResult
public func onCancel(_ callback: @escaping (Void) -> Void) -> Future<T> {
public func onCancel(_ callback: @escaping () -> Void) -> Future<T> {
promise.onCancel(callback)

return self
Expand Down
8 changes: 4 additions & 4 deletions PiedPiper/GCD.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public struct GCD: GCDQueue {
- returns: The result of the execution of the closure
*/
@discardableResult
public static func main<T>(_ closure: @escaping ((Void) -> T)) -> AsyncDispatch<T> {
public static func main<T>(_ closure: @escaping (() -> T)) -> AsyncDispatch<T> {
return mainQueue.async(closure)
}

Expand All @@ -25,7 +25,7 @@ public struct GCD: GCDQueue {
- returns: The result of the execution of the closure
*/
@discardableResult
static public func background<T>(_ closure: @escaping ((Void) -> T)) -> AsyncDispatch<T> {
static public func background<T>(_ closure: @escaping (() -> T)) -> AsyncDispatch<T> {
return backgroundQueue.async(closure)
}

Expand All @@ -45,7 +45,7 @@ public struct GCD: GCDQueue {
}

@discardableResult
static func delay<T>(_ time: TimeInterval, closure: @escaping (Void) -> T) -> Future<T> {
static func delay<T>(_ time: TimeInterval, closure: @escaping () -> T) -> Future<T> {
let result = Promise<T>()

let time = DispatchTime.now() + Double(Int64(time * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
Expand Down Expand Up @@ -132,7 +132,7 @@ extension GCDQueue {
- returns: An AsyncDispatch object. You can keep chaining async calls on this object
*/
@discardableResult
public func async<T>(_ closure: @escaping (Void) -> T) -> AsyncDispatch<T> {
public func async<T>(_ closure: @escaping () -> T) -> AsyncDispatch<T> {
let innerResult = Promise<T>()
let result = AsyncDispatch<T>(operation: innerResult.future)

Expand Down
4 changes: 2 additions & 2 deletions PiedPiper/Promise.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ open class Promise<T>: Async {

private var failureListeners: [(Error) -> Void] = []
private var successListeners: [(T) -> Void] = []
private var cancelListeners: [(Void) -> Void] = []
private var cancelListeners: [() -> Void] = []
private var error: Error?
private var value: T?
private var canceled = false
Expand Down Expand Up @@ -188,7 +188,7 @@ open class Promise<T>: Async {
- returns: The updated Promise
*/
@discardableResult
public func onCancel(_ callback: @escaping (Void) -> Void) -> Promise<T> {
public func onCancel(_ callback: @escaping () -> Void) -> Promise<T> {
if canceled {
callback()
} else {
Expand Down
42 changes: 30 additions & 12 deletions PiedPiperSample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -436,23 +436,23 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0800;
LastUpgradeCheck = 0920;
ORGANIZATIONNAME = WeltN24;
TargetAttributes = {
52B29CF31CEA236E00B5B277 = {
CreatedOnToolsVersion = 7.3.1;
};
52BED2A31CE870F2002C045A = {
CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 0800;
LastSwiftMigration = 0920;
};
52BED2CF1CE87175002C045A = {
CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 0800;
LastSwiftMigration = 0920;
};
52BED3011CE8719D002C045A = {
CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 0800;
LastSwiftMigration = 0920;
ProvisioningStyle = Manual;
TestTargetID = 52BED2A31CE870F2002C045A;
};
Expand Down Expand Up @@ -663,7 +663,7 @@
PRODUCT_NAME = PiedPiper;
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand All @@ -689,7 +689,7 @@
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand All @@ -704,14 +704,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -751,14 +757,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -792,7 +804,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = de.weltn24.PiedPiperSample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -806,7 +819,8 @@
PRODUCT_BUNDLE_IDENTIFIER = de.weltn24.PiedPiperSample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -831,7 +845,8 @@
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos appletvos appletvsimulator watchos watchsimulator";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2,3,4";
TVOS_DEPLOYMENT_TARGET = 9.0;
VALID_ARCHS = "arm64 armv7 armv7s armv7k";
Expand Down Expand Up @@ -862,7 +877,8 @@
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos appletvos appletvsimulator watchos watchsimulator";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2,3,4";
TVOS_DEPLOYMENT_TARGET = 9.0;
VALID_ARCHS = "arm64 armv7 armv7s armv7k";
Expand All @@ -885,7 +901,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = de.weltn24.PiedPiperTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PiedPiperSample.app/PiedPiperSample";
};
name = Debug;
Expand All @@ -904,7 +921,8 @@
PRODUCT_BUNDLE_IDENTIFIER = de.weltn24.PiedPiperTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PiedPiperSample.app/PiedPiperSample";
};
name = Release;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0920"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
Expand All @@ -36,6 +37,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0920"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
Expand Down Expand Up @@ -55,6 +56,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
Loading

0 comments on commit b8bdd81

Please sign in to comment.