Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added support for specifying multiple events on a single transition. …

…This will not yet work for optimized transition selectors.
  • Loading branch information...
commit 18f2d5e6871435b654c4c50498c7c163453b5103 1 parent 5c2d83c
@jbeard4 authored
View
6 src/main/coffeescript/scxml/scxml-dynamic-name-match-transition-selector.coffee
@@ -7,8 +7,8 @@ define ->
retrieveEventRe = (name) -> eventNameReCache[name] ?= eventNameToRe name
nameMatch = (t,eventNames) ->
- tEvent = t.event
- f = if tEvent is "*" then -> true else (name) -> retrieveEventRe(tEvent).test(name)
+ tEvents = t.events
+ f = if "*" in tEvents then -> true else (name) -> (tEvent for tEvent in tEvents when retrieveEventRe(tEvent).test(name)).length
(name for name in eventNames when f name).length
- (state,eventNames,evaluator) -> (t for t in state.transitions when (not t.event or nameMatch t,eventNames) and (not t.cond or evaluator(t)))
+ (state,eventNames,evaluator) -> (t for t in state.transitions when (not t.events or nameMatch t,eventNames) and (not t.cond or evaluator(t)))
View
25 src/main/coffeescript/util/annotate-scxml-json.coffee
@@ -167,24 +167,27 @@ define ["scxml/state-kinds-enum"],(stateKinds) ->
[tagName,attributes,children] = deconstructNode transitionNode,true
+ #wildcard "*" event will show up on transition.events, but will not show up in uniqueEvents
if attributes.event
- #strip off trailing ".*"
- #TODO: split up space-delimited events
- m = attributes.event.match stripStarFromEventNameRe
- if m
- normalizedEvent = m[1]
- if not (m and normalizedEvent) then throw new Error "Unable to parse event: #{attributes.event}"
-
- attributes.event = normalizedEvent #transform the model so that the event is now a normalized event
-
- if attributes.event isnt "*" then uniqueEvents[attributes.event] = true
+ events =
+ if attributes.event is "*" then [attributes.event]
+ else for event in attributes.event.trim().split(/\s+/)
+ #strip off trailing ".*"
+ #TODO: split up space-delimited events
+ m = event.match stripStarFromEventNameRe
+ if m
+ normalizedEvent = m[1]
+ if not (m and normalizedEvent) then throw new Error "Unable to parse event: #{event}" else event
+
+ for event in events
+ if event isnt "*" then uniqueEvents[event] = true
transition =
documentOrder : transitions.length
id : transitions.length
source : parentState.id
cond : attributes.cond
- event : attributes.event
+ events : events
actions : (transformActionNode child for child in children)
targets : attributes?.target?.trim().split(/\s+/) #this will either be a list, or undefined
Please sign in to comment.
Something went wrong with that request. Please try again.