Skip to content

Commit 917b3be

Browse files
committed
Update for Swift 5.0
1 parent ed939d4 commit 917b3be

File tree

8 files changed

+35
-29
lines changed

8 files changed

+35
-29
lines changed

Sources/EventType.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,8 @@ public func == <E>(lhs: E, rhs: Event<E>) -> Bool
8686
/// Useful for creating StateMachine without events, i.e. `StateMachine<MyState, NoEvent>`.
8787
public enum NoEvent: EventType
8888
{
89-
public var hashValue: Int
89+
public func hash(into hasher: inout Hasher)
9090
{
91-
return 0
9291
}
9392
}
9493

Sources/Transition.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,10 @@ public struct Transition<S: StateType>: Hashable
3636
self.init(fromState: .some(fromState), toState: .some(toState))
3737
}
3838

39-
public var hashValue: Int
39+
public func hash(into hasher: inout Hasher)
4040
{
41-
return self.fromState.hashValue &+ self.toState.hashValue.byteSwapped
41+
hasher.combine(fromState.hashValue)
42+
hasher.combine(toState.hashValue.byteSwapped)
4243
}
4344
}
4445

SwiftState.xcodeproj/project.pbxproj

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@
297297
isa = PBXProject;
298298
attributes = {
299299
LastSwiftUpdateCheck = 0700;
300-
LastUpgradeCheck = 0900;
300+
LastUpgradeCheck = 1020;
301301
ORGANIZATIONNAME = "Yasuhiro Inami";
302302
TargetAttributes = {
303303
1FA61FFF1996601000460108 = {
@@ -312,10 +312,11 @@
312312
};
313313
buildConfigurationList = 1FA61FFA1996601000460108 /* Build configuration list for PBXProject "SwiftState" */;
314314
compatibilityVersion = "Xcode 3.2";
315-
developmentRegion = English;
315+
developmentRegion = en;
316316
hasScannedForEncodings = 0;
317317
knownRegions = (
318318
en,
319+
Base,
319320
);
320321
mainGroup = 1FA61FF61996601000460108;
321322
productRefGroup = 1FA620011996601000460108 /* Products */;
@@ -408,6 +409,7 @@
408409
baseConfigurationReference = 1FD79FA51C17412600CE7060 /* Debug.xcconfig */;
409410
buildSettings = {
410411
ALWAYS_SEARCH_USER_PATHS = NO;
412+
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
411413
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
412414
CLANG_CXX_LIBRARY = "libc++";
413415
CLANG_ENABLE_MODULES = YES;
@@ -416,12 +418,14 @@
416418
CLANG_WARN_BOOL_CONVERSION = YES;
417419
CLANG_WARN_COMMA = YES;
418420
CLANG_WARN_CONSTANT_CONVERSION = YES;
421+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
419422
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
420423
CLANG_WARN_EMPTY_BODY = YES;
421424
CLANG_WARN_ENUM_CONVERSION = YES;
422425
CLANG_WARN_INFINITE_RECURSION = YES;
423426
CLANG_WARN_INT_CONVERSION = YES;
424427
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
428+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
425429
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
426430
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
427431
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -462,6 +466,7 @@
462466
baseConfigurationReference = 1FD79FA61C17412600CE7060 /* Release.xcconfig */;
463467
buildSettings = {
464468
ALWAYS_SEARCH_USER_PATHS = NO;
469+
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
465470
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
466471
CLANG_CXX_LIBRARY = "libc++";
467472
CLANG_ENABLE_MODULES = YES;
@@ -470,12 +475,14 @@
470475
CLANG_WARN_BOOL_CONVERSION = YES;
471476
CLANG_WARN_COMMA = YES;
472477
CLANG_WARN_CONSTANT_CONVERSION = YES;
478+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
473479
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
474480
CLANG_WARN_EMPTY_BODY = YES;
475481
CLANG_WARN_ENUM_CONVERSION = YES;
476482
CLANG_WARN_INFINITE_RECURSION = YES;
477483
CLANG_WARN_INT_CONVERSION = YES;
478484
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
485+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
479486
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
480487
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
481488
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -498,6 +505,7 @@
498505
GCC_WARN_UNUSED_FUNCTION = YES;
499506
GCC_WARN_UNUSED_VARIABLE = YES;
500507
MTL_ENABLE_DEBUG_INFO = NO;
508+
SWIFT_COMPILATION_MODE = wholemodule;
501509
VERSIONING_SYSTEM = "apple-generic";
502510
VERSION_INFO_PREFIX = "";
503511
};
@@ -519,7 +527,7 @@
519527
PRODUCT_BUNDLE_IDENTIFIER = "com.inamiy.$(PRODUCT_NAME:rfc1034identifier)";
520528
PRODUCT_NAME = "$(PROJECT_NAME)";
521529
SKIP_INSTALL = YES;
522-
SWIFT_VERSION = 4.0;
530+
SWIFT_VERSION = 5.0;
523531
};
524532
name = Debug;
525533
};
@@ -539,7 +547,7 @@
539547
PRODUCT_BUNDLE_IDENTIFIER = "com.inamiy.$(PRODUCT_NAME:rfc1034identifier)";
540548
PRODUCT_NAME = "$(PROJECT_NAME)";
541549
SKIP_INSTALL = YES;
542-
SWIFT_VERSION = 4.0;
550+
SWIFT_VERSION = 5.0;
543551
};
544552
name = Release;
545553
};
@@ -559,7 +567,7 @@
559567
INFOPLIST_FILE = Tests/SwiftStateTests/Info.plist;
560568
PRODUCT_BUNDLE_IDENTIFIER = "com.inamiy.$(PRODUCT_NAME:rfc1034identifier)";
561569
PRODUCT_NAME = "$(TARGET_NAME)";
562-
SWIFT_VERSION = 4.0;
570+
SWIFT_VERSION = 5.0;
563571
};
564572
name = Debug;
565573
};
@@ -575,7 +583,7 @@
575583
INFOPLIST_FILE = Tests/SwiftStateTests/Info.plist;
576584
PRODUCT_BUNDLE_IDENTIFIER = "com.inamiy.$(PRODUCT_NAME:rfc1034identifier)";
577585
PRODUCT_NAME = "$(TARGET_NAME)";
578-
SWIFT_VERSION = 4.0;
586+
SWIFT_VERSION = 5.0;
579587
};
580588
name = Release;
581589
};

SwiftState.xcodeproj/xcshareddata/xcschemes/SwiftState.xcscheme

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0900"
3+
LastUpgradeVersion = "1020"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -26,9 +26,8 @@
2626
buildConfiguration = "Debug"
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29-
language = ""
30-
shouldUseLaunchSchemeArgsEnv = "YES"
31-
codeCoverageEnabled = "YES">
29+
codeCoverageEnabled = "YES"
30+
shouldUseLaunchSchemeArgsEnv = "YES">
3231
<Testables>
3332
<TestableReference
3433
skipped = "NO">
@@ -57,7 +56,6 @@
5756
buildConfiguration = "Debug"
5857
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
5958
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
60-
language = ""
6159
launchStyle = "0"
6260
useCustomWorkingDirectory = "NO"
6361
ignoresPersistentStateOnLaunch = "NO"

Tests/SwiftStateTests/HierarchicalMachineTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ private enum _MainState: StateType
1515
case subMachine1(_SubState)
1616
case subMachine2(_SubState)
1717

18-
var hashValue: Int
18+
func hash(into hasher: inout Hasher)
1919
{
2020
switch self {
2121
case .mainState0:
22-
return "MainState0".hashValue
22+
hasher.combine("MainState0".hashValue)
2323
case let .subMachine1(state):
24-
return "SubMachine1-\(state)".hashValue
24+
hasher.combine("SubMachine1-\(state)".hashValue)
2525
case let .subMachine2(state):
26-
return "SubMachine2-\(state)".hashValue
26+
hasher.combine("SubMachine2-\(state)".hashValue)
2727
}
2828
}
2929
}

Tests/SwiftStateTests/MyEvent.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ enum StrEvent: EventType
1717
{
1818
case str(String)
1919

20-
var hashValue: Int
20+
func hash(into hasher: inout Hasher)
2121
{
2222
switch self {
23-
case .str(let str): return str.hashValue
23+
case .str(let str): hasher.combine(str.hashValue)
2424
}
2525
}
2626
}

Tests/SwiftStateTests/MyState.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ enum StrState: StateType
1717
{
1818
case str(String)
1919

20-
var hashValue: Int
20+
func hash(into hasher: inout Hasher)
2121
{
2222
switch self {
23-
case .str(let str): return str.hashValue
23+
case .str(let str): hasher.combine(str.hashValue)
2424
}
2525
}
2626
}

Tests/SwiftStateTests/RouteMappingTests.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ private enum _State: StateType, Hashable
2121
case pending
2222
case loading(Int)
2323

24-
var hashValue: Int
24+
func hash(into hasher: inout Hasher)
2525
{
2626
switch self {
2727
case .pending:
28-
return "Pending".hashValue
28+
hasher.combine("Pending".hashValue)
2929
case let .loading(x):
30-
return "Loading\(x)".hashValue
30+
hasher.combine("Loading\(x)".hashValue)
3131
}
3232
}
3333
}
@@ -49,13 +49,13 @@ private enum _Event: SwiftState.EventType, Hashable
4949
case cancelAction
5050
case loadAction(Int)
5151

52-
var hashValue: Int
52+
func hash(into hasher: inout Hasher)
5353
{
5454
switch self {
5555
case .cancelAction:
56-
return "CancelAction".hashValue
56+
hasher.combine("CancelAction".hashValue)
5757
case let .loadAction(x):
58-
return "LoadAction\(x)".hashValue
58+
hasher.combine("LoadAction\(x)".hashValue)
5959
}
6060
}
6161
}

0 commit comments

Comments
 (0)