Skip to content

Commit 70fa6aa

Browse files
committed
Fix code for Xcode6.3 beta2.
1 parent 3b5d315 commit 70fa6aa

File tree

3 files changed

+27
-16
lines changed

3 files changed

+27
-16
lines changed

SwiftState/HierarchicalStateMachine.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public class HierarchicalStateMachine<S: StateType, E: StateEventType>: StateMac
6161
{
6262
assert(state is HSM.State, "HSM state must be String.")
6363

64-
let components = split(state as HSM.State, { $0 == "." }, maxSplit: 1)
64+
let components = split(state as! HSM.State, maxSplit: 1) { $0 == "." }
6565

6666
switch components.count {
6767
case 2:
@@ -85,7 +85,7 @@ public class HierarchicalStateMachine<S: StateType, E: StateEventType>: StateMac
8585
let (submachine, substate) = self._submachineTupleForState(self._state)
8686

8787
if let submachine = submachine {
88-
self._state = "\(submachine.name).\(submachine.state)" as State
88+
self._state = "\(submachine.name).\(submachine.state)" as! State
8989
}
9090

9191
return self._state
@@ -147,7 +147,7 @@ public class HierarchicalStateMachine<S: StateType, E: StateEventType>: StateMac
147147
// try changing submachine-internal state
148148
if fromSubmachine != nil && toSubmachine != nil && fromSubmachine === toSubmachine {
149149

150-
if toSubmachine!.canTryState(toSubstate, forEvent: event as HSM.Event) {
150+
if toSubmachine!.canTryState(toSubstate, forEvent: event as! HSM.Event) {
151151

152152
//
153153
// NOTE:

SwiftState/StateMachine.swift

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,17 @@ public class StateMachineRouteID<S: StateType, E: StateEventType>
2626
self.transition = transition
2727
self.routeKey = routeKey
2828
self.event = event
29+
30+
self.bundledRouteIDs = nil
2931
}
3032

3133
private init(bundledRouteIDs: [StateMachineRouteID<S, E>]?)
3234
{
3335
self.bundledRouteIDs = bundledRouteIDs
36+
37+
self.transition = nil
38+
self.routeKey = nil
39+
self.event = nil
3440
}
3541
}
3642

@@ -48,11 +54,16 @@ public class StateMachineHandlerID<S: StateType, E: StateEventType>
4854
{
4955
self.transition = transition
5056
self.handlerKey = handlerKey
57+
58+
self.bundledHandlerIDs = nil
5159
}
5260

5361
private init(bundledHandlerIDs: [StateMachineHandlerID<S, E>]?)
5462
{
5563
self.bundledHandlerIDs = bundledHandlerIDs
64+
65+
self.transition = nil
66+
self.handlerKey = nil
5667
}
5768
}
5869

@@ -77,7 +88,7 @@ internal class _StateMachineHandlerInfo<S: StateType, E: StateEventType>
7788
public class StateMachine<S: StateType, E: StateEventType>
7889
{
7990
public typealias HandlerOrder = UInt8
80-
public typealias Handler = ((context: HandlerContext) -> Void)
91+
public typealias Handler = (HandlerContext -> Void)
8192
public typealias HandlerContext = (event: Event, transition: Transition, order: HandlerOrder, userInfo: Any?)
8293

8394
internal typealias State = S
@@ -227,7 +238,7 @@ public class StateMachine<S: StateType, E: StateEventType>
227238
let order = handlerInfo.order
228239
let handler = handlerInfo.handler
229240

230-
handler(context: HandlerContext(event: event, transition: transition, order: order, userInfo: userInfo))
241+
handler(HandlerContext(event: event, transition: transition, order: order, userInfo: userInfo))
231242
}
232243

233244
didTransit = true
@@ -237,7 +248,7 @@ public class StateMachine<S: StateType, E: StateEventType>
237248
let order = handlerInfo.order
238249
let handler = handlerInfo.handler
239250

240-
handler(context: HandlerContext(event: event, transition: transition, order: order, userInfo: userInfo))
251+
handler(HandlerContext(event: event, transition: transition, order: order, userInfo: userInfo))
241252
}
242253
}
243254

@@ -339,7 +350,7 @@ public class StateMachine<S: StateType, E: StateEventType>
339350
return self.addRoute(route)
340351
}
341352

342-
public func addRoute(transition: Transition, condition: @autoclosure () -> Bool) -> RouteID
353+
public func addRoute(transition: Transition, @autoclosure(escaping) condition: () -> Bool) -> RouteID
343354
{
344355
return self.addRoute(transition, condition: { t in condition() })
345356
}
@@ -389,7 +400,7 @@ public class StateMachine<S: StateType, E: StateEventType>
389400
return self.addRoute(route, handler: handler)
390401
}
391402

392-
public func addRoute(transition: Transition, condition: @autoclosure () -> Bool, handler: Handler) -> (RouteID, HandlerID)
403+
public func addRoute(transition: Transition, @autoclosure(escaping) condition: () -> Bool, handler: Handler) -> (RouteID, HandlerID)
393404
{
394405
return self.addRoute(transition, condition: { t in condition() }, handler: handler)
395406
}
@@ -404,7 +415,7 @@ public class StateMachine<S: StateType, E: StateEventType>
404415
let handlerID = self.addHandler(transition) { [weak self] context in
405416
if let self_ = self {
406417
if self_._canPassCondition(condition, transition: context.transition) {
407-
handler(context: context)
418+
handler(context)
408419
}
409420
}
410421
}
@@ -621,7 +632,7 @@ public class StateMachine<S: StateType, E: StateEventType>
621632
return self.addRouteChain(routeChain, handler: handler)
622633
}
623634

624-
public func addRouteChain(chain: TransitionChain, condition: @autoclosure () -> Bool, handler: Handler) -> (RouteID, HandlerID)
635+
public func addRouteChain(chain: TransitionChain, @autoclosure(escaping) condition: () -> Bool, handler: Handler) -> (RouteID, HandlerID)
625636
{
626637
return self.addRouteChain(chain, condition: { t in condition() }, handler: handler)
627638
}
@@ -744,7 +755,7 @@ public class StateMachine<S: StateType, E: StateEventType>
744755
if chainingCount < allCount {
745756
shouldStop = true
746757
if isError {
747-
handler(context: context)
758+
handler(context)
748759
}
749760
}
750761
}
@@ -759,7 +770,7 @@ public class StateMachine<S: StateType, E: StateEventType>
759770
shouldStop = true
760771

761772
if !isError {
762-
handler(context: context)
773+
handler(context)
763774
}
764775
}
765776
}
@@ -787,7 +798,7 @@ public class StateMachine<S: StateType, E: StateEventType>
787798
return self.addRouteEvent(event, routes: routes)
788799
}
789800

790-
public func addRouteEvent(event: Event, transitions: [Transition], condition: @autoclosure () -> Bool) -> [RouteID]
801+
public func addRouteEvent(event: Event, transitions: [Transition], @autoclosure(escaping) condition: () -> Bool) -> [RouteID]
791802
{
792803
return self.addRouteEvent(event, transitions: transitions, condition: { t in condition() })
793804
}
@@ -819,7 +830,7 @@ public class StateMachine<S: StateType, E: StateEventType>
819830
return (routeIDs, handlerID)
820831
}
821832

822-
public func addRouteEvent(event: Event, transitions: [Transition], condition: @autoclosure () -> Bool, handler: Handler) -> ([RouteID], HandlerID)
833+
public func addRouteEvent(event: Event, transitions: [Transition], @autoclosure(escaping) condition: () -> Bool, handler: Handler) -> ([RouteID], HandlerID)
823834
{
824835
return self.addRouteEvent(event, transitions: transitions, condition: { t in condition() }, handler: handler)
825836
}
@@ -846,7 +857,7 @@ public class StateMachine<S: StateType, E: StateEventType>
846857

847858
let handlerID = self.addHandler(nil => nil, order: order) { [weak self] context in
848859
if context.event == event {
849-
handler(context: context)
860+
handler(context)
850861
}
851862
}
852863

SwiftState/StateRoute.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public struct StateRoute<S: StateType>
2222
self.condition = condition
2323
}
2424

25-
public init(transition: Transition, condition: @autoclosure () -> Bool)
25+
public init(transition: Transition, @autoclosure(escaping) condition: () -> Bool)
2626
{
2727
self.init(transition: transition, condition: { t in condition() })
2828
}

0 commit comments

Comments
 (0)