You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by jb...@apache.org on 2010/07/22 19:51:26 UTC

svn commit: r966772 - in /commons/sandbox/gsoc/2010/scxml-js/trunk: ./ src/javascript/scxml/cgf/backends/js/ src/xslt/backends/js/ src/xslt/ir-compiler/ test/ test/prefix_events/ test/prefix_events/scripts/

Author: jbeard
Date: Thu Jul 22 17:51:25 2010
New Revision: 966772

URL: http://svn.apache.org/viewvc?rev=966772&view=rev
Log:
Merge branch 'core-events'

Added:
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/addEventRegularExpressions.xsl   (with props)
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/copyEnumeratedEventTransitions.xsl   (with props)
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/expandStarEvent.xsl
      - copied, changed from r966771, commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/enumerateEvents.xsl
    commons/sandbox/gsoc/2010/scxml-js/trunk/test/prefix_events/
    commons/sandbox/gsoc/2010/scxml-js/trunk/test/prefix_events/TestPrefixEvents.xml   (with props)
    commons/sandbox/gsoc/2010/scxml-js/trunk/test/prefix_events/scripts/
    commons/sandbox/gsoc/2010/scxml-js/trunk/test/prefix_events/scripts/unitTest.js   (with props)
Modified:
    commons/sandbox/gsoc/2010/scxml-js/trunk/build.js
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/AbstractEnumeratedStatechartGenerator.js
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/AbstractStatechartGenerator.js
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/StatePatternStatechartGenerator.js
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractEnumeratedStatechartGenerator.xsl
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractStatechartGenerator.xsl
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StatePatternStatechartGenerator.xsl
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StateTableStatechartGenerator.xsl
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/SwitchyardStatechartGenerator.xsl
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/enumerateEvents.xsl
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/nameTransitions.xsl
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/numberStatesAndTransitions.xsl
    commons/sandbox/gsoc/2010/scxml-js/trunk/test/test_with_xsltproc.sh

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/build.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/build.js?rev=966772&r1=966771&r2=966772&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/build.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/build.js Thu Jul 22 17:51:25 2010
@@ -80,6 +80,7 @@ require.def("build",
 				ConditionalTransition :"test/conditional_transition/TestConditionalTransition.xml",
 				InPredicate :"test/in_predicate/TestInPredicate.xml",
 				EventSystemProperties :"test/event_system_properties/TestEventSystemProperties.xml",
+				PrefixEvents:"test/prefix_events/TestPrefixEvents.xml"
 			}
 
 			//FIXME: this violates Don't Repeat Yourself; these paths are written here and in the module
@@ -111,7 +112,8 @@ require.def("build",
 					"test/kitchen_sink/scripts/unitTest_executableContent",
 					"test/conditional_transition/scripts/unitTest",
 					"test/in_predicate/scripts/unitTest",
-					"test/event_system_properties/scripts/unitTest"
+					"test/event_system_properties/scripts/unitTest",
+					"test/prefix_events/scripts/unitTest"
 			]
 
 			//gets populated at run-time

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/AbstractEnumeratedStatechartGenerator.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/AbstractEnumeratedStatechartGenerator.js?rev=966772&r1=966771&r2=966772&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/AbstractEnumeratedStatechartGenerator.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/AbstractEnumeratedStatechartGenerator.js Thu Jul 22 17:51:25 2010
@@ -7,18 +7,30 @@ require.def(
 		"xml!src/xslt/ir-compiler/flattenTransitions.xsl",
 		"xml!src/xslt/ir-compiler/appendTransitionInformation.xsl",
 		"xml!src/xslt/ir-compiler/nameTransitions.xsl",
+		"xml!src/xslt/ir-compiler/copyEnumeratedEventTransitions.xsl",
+		"xml!src/xslt/ir-compiler/enumerateEvents.xsl",
+		"xml!src/xslt/ir-compiler/addEventRegularExpressions.xsl",
+		"xml!src/xslt/ir-compiler/expandStarEvent.xsl",
 		"xml!src/xslt/ir-compiler/numberStatesAndTransitions.xsl" ],
 	function(
 		AbstractStatechartGenerator,
 		flattenTransitions,
 		appendTransitionInformation,
 		nameTransitions,
+		copyEnumeratedEventTransitions,
+		enumerateEvents,
+		addEventRegularExpressions,
+		expandStarEvent,
 		numberStatesAndTransitions
 	){
 		return {
 			"transformations" : AbstractStatechartGenerator.transformations.concat([flattenTransitions,
 													appendTransitionInformation,
 													nameTransitions,
+													copyEnumeratedEventTransitions,
+													enumerateEvents,
+													addEventRegularExpressions,
+													expandStarEvent,
 													numberStatesAndTransitions] )
 		};
 	}

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/AbstractStatechartGenerator.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/AbstractStatechartGenerator.js?rev=966772&r1=966771&r2=966772&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/AbstractStatechartGenerator.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/AbstractStatechartGenerator.js Thu Jul 22 17:51:25 2010
@@ -3,7 +3,6 @@ require.def(
 	"src/javascript/scxml/cgf/backends/js/AbstractStatechartGenerator",
 
 	[
-		"xml!src/xslt/ir-compiler/enumerateEvents.xsl",
 		"xml!src/xslt/ir-compiler/normalizeInitialStates.xsl",
 		"xml!src/xslt/ir-compiler/generateUniqueStateIds.xsl",
 		"xml!src/xslt/ir-compiler/generateUniqueInitialStateIds.xsl",
@@ -14,7 +13,6 @@ require.def(
 		"xml!src/xslt/ir-compiler/appendStateInformation.xsl",
 		"xml!src/xslt/ir-compiler/appendBasicStateInformation.xsl" ],
 	function(
-		enumerateEvents,
 		normalizeInitialStates,
 		generateUniqueStateIds,
 		generateUniqueInitialStateIds,
@@ -28,7 +26,6 @@ require.def(
 
 		return {
 			"transformations" : [
-				enumerateEvents,
 				normalizeInitialStates,
 				generateUniqueStateIds,
 				generateUniqueInitialStateIds,

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/StatePatternStatechartGenerator.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/StatePatternStatechartGenerator.js?rev=966772&r1=966771&r2=966772&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/StatePatternStatechartGenerator.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/StatePatternStatechartGenerator.js Thu Jul 22 17:51:25 2010
@@ -5,17 +5,30 @@ require.def(
 	[
 		"src/javascript/scxml/cgf/backends/js/AbstractStatechartGenerator",
 		"xml!src/xslt/ir-compiler/appendTransitionInformation.xsl",
+		"xml!src/xslt/ir-compiler/copyEnumeratedEventTransitions.xsl",
+		"xml!src/xslt/ir-compiler/enumerateEvents.xsl",
+		"xml!src/xslt/ir-compiler/addEventRegularExpressions.xsl",
+		"xml!src/xslt/ir-compiler/expandStarEvent.xsl",
 		"xml!build/StatePatternStatechartGenerator_combined.xsl" //preprocessed stylesheet
 	],
 
 	function(
 		AbstractStatechartGenerator,
 		appendTransitionInformation,
+		copyEnumeratedEventTransitions,
+		enumerateEvents,
+		addEventRegularExpressions,
+		expandStarEvent,
 		StatePatternStatechartGenerator
 	){
 
 		return {
-			"transformations" : AbstractStatechartGenerator.transformations.concat(appendTransitionInformation),
+			"transformations" : AbstractStatechartGenerator.transformations.concat([
+				appendTransitionInformation,
+				copyEnumeratedEventTransitions,
+				enumerateEvents,
+				addEventRegularExpressions,
+				expandStarEvent]),
 			"code" : StatePatternStatechartGenerator
 		};
 

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractEnumeratedStatechartGenerator.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractEnumeratedStatechartGenerator.xsl?rev=966772&r1=966771&r2=966772&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractEnumeratedStatechartGenerator.xsl (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractEnumeratedStatechartGenerator.xsl Thu Jul 22 17:51:25 2010
@@ -37,6 +37,7 @@
 		select="'currentConfiguration.map(function(state){return STATE_INT_ID_TO_OBJECT_MAP[state]})'"/>
 
 	<variable name="eventToNameMap" select="'TRIGGER_ID_TO_NAME_MAP[e]'"/>
+	<variable name="prefixEventDispatchInvocation" select="'$dispatchPrefixEvent(state,e)'"/>
 
 	<template name="genContextHooks">
 		//enumeration of states int id's
@@ -57,7 +58,7 @@
 		</for-each>
 
 		//enumeration of triggers
-		<for-each select="$eventsEnum">
+		<for-each select="$enumeratedEventsEnum">
 			var <value-of select="c:name"/> = <value-of select="c:id"/>;
 		</for-each>
 
@@ -70,12 +71,61 @@
 		//transition functions
 		<call-template name="genTriggerHandlerFunctions"/>
 
+		<call-template name="genPrefixDispatchHandlerFunction"/>
+
 		<call-template name="genEnumeratedHooks"/>
+
+	</template>
+
+	<template name="genPrefixDispatchHandlerFunction">
+		<!-- this is quite similar in form and function to 
+			the work done in SwitchyardStatechartGenerator.xsl -->
+			<call-template name="genPrefixDispatchHandlerSwitchyard">
+				<with-param name="basicStates" select="$basicStates"/>
+			</call-template>
+	</template>
+
+
+	<template name="genPrefixDispatchHandlerSwitchyard">
+		<param name="basicStates"/>
+	
+		function $dispatchPrefixEvent(state,e){
+			switch(state) {
+				<for-each select="$basicStates[s:transition[@event]]">
+					<call-template name="genPrefixDispatchHandlerStateCase">
+						<with-param name="s" select="."/>
+					</call-template>
+				</for-each>
+			}
+		}
+		
+	</template>
+
+	<template name="genPrefixDispatchHandlerStateCase">
+		<param name="s"/>
+
+		case <value-of select="$s/@c:enumId"/>:
+
+			<for-each select="$s/s:transition[@event]">
+				<!-- look up regexp name -->
+				<variable name="eventName" select="@event"/>
+				<variable name="regexpName" select="$allEventsEnum[c:name/text() = $eventName]/c:regexp/c:name"/>
+				
+				if(e.match(<value-of select="$regexpName"/>)
+					<if test="@cond">
+						&amp;&amp; <value-of select="@cond"/>
+					</if>){
+
+					<value-of select="@c:tName"/>();
+					break;
+				}
+			</for-each>
+			break;
 	</template>
 
 	<template name="genTriggerExternalObject"> 
 			this.TRIGGERS = { 
-				<for-each select="$eventsEnum">
+				<for-each select="$enumeratedEventsEnum">
 					<value-of select="c:name"/> : <value-of select="c:name"/>
 					<if test="not(position() = last())"> , </if>
 				</for-each>
@@ -85,7 +135,7 @@
 
 	<template name="genTriggerIdToNameMap">
 		var TRIGGER_ID_TO_NAME_MAP = [
-			<for-each select="$eventsEnum">
+			<for-each select="$enumeratedEventsEnum">
 				'<value-of select="c:name"/>' 
 				<if test="not(position() = last())"> , </if>
 			</for-each>
@@ -98,7 +148,7 @@
 
 			<variable name="state" select="."/>
 
-			<for-each select="$eventsEnum/c:name">
+			<for-each select="$allEventsEnum/c:name">
 				<variable name="eventName">
 					<value-of select="."/>
 				</variable>
@@ -179,24 +229,6 @@
 		}
 	</template>
 
-	<template match="s:send">
-		<variable name="sendEvent" select="@event"/>
-		<variable name="sendDelay" select="number(@delay)"/>
-
-		<choose>
-			<when test="$sendDelay">
-				//set timeout
-				toReturn = window.setTimeout(function(){
-					self.GEN(<value-of select="$sendEvent"/>);
-				}, <value-of select="$sendDelay*1000"/>);
-			</when>
-			<otherwise>
-				//just add the event to the outer queue
-				toReturn = innerEventQueue.push(<value-of select="$sendEvent"/>);
-			</otherwise>
-		</choose>
-	</template>
-
 	<template name="genHistoryTriggerDispatcherHistoryStateReference">
 		<param name="s"/>
 
@@ -206,7 +238,18 @@
 	<template name="genExternalTriggerDispatcherRunToCompletionEventValue">
 		<param name="eventName"/>
 
-		<value-of select="$eventName"/>
+		<!-- enumerated events correspond to a local variable, 
+			and so don't need to be surrounded by quotes, whereas enumerated
+			events will be pattern-matched later on, and so do need to be surrounded
+			by quotes --> 
+		<choose>
+			<when test="$enumeratedEventsEnum[c:name/text() = $eventName]">
+				<value-of select="$eventName"/>
+			</when>
+			<otherwise>
+				"<value-of select="$eventName"/>"
+			</otherwise>
+		</choose>
 	</template>
 
 	<template name="genStateHooks"/>

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractStatechartGenerator.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractStatechartGenerator.xsl?rev=966772&r1=966771&r2=966772&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractStatechartGenerator.xsl (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractStatechartGenerator.xsl Thu Jul 22 17:51:25 2010
@@ -28,7 +28,8 @@
 	<param name="noSome" select="false()"/>
 
 	<!-- these variables get overridden by subclasses -->
-	<variable name="dispatchInvocation"/>
+	<variable name="enumeratedEventDispatchInvocation"/>
+	<variable name="prefixEventDispatchInvocation"/>
 	<variable name="currentConfigurationExpression"/>
 	<variable name="defaultEventLiteral"/>
 	<variable name="inPredicateFunctionStateReference"/>
@@ -49,7 +50,8 @@
 	<variable name="compositeStates" 
 		select="$allStates[.//*[(self::s:state or self::s:parallel or self::s:final or self::s:initial or self::s:scxml or self::s:history)]]"/>
 
-	<variable name="eventsEnum" select="/s:scxml/c:eventsEnum/c:event"/>
+	<variable name="allEventsEnum" select="/s:scxml/c:allEventsEnum/c:event"/>
+	<variable name="enumeratedEventsEnum" select="/s:scxml/c:enumeratedEventsEnum/c:event"/>
 
 	<!-- Variables we don't use, but which might be useful at some point -->
 	<!--
@@ -63,6 +65,20 @@
 
 	<variable name="abstractStateName" select="'AbstractState'"/>
 
+	<!-- helper template to safely get a state's parent's name -->
+	<template name="getParentNameFromState">
+		<param name="s"/>
+
+		<choose>
+			<when test="$s/../@id">
+				<value-of select="$s/../@id"/>
+			</when>
+			<otherwise>
+				<value-of select="$abstractStateName"/>
+			</otherwise>
+		</choose>
+	</template>
+
 	<template match="/s:scxml">
 
 		<if test="$noIndexOf">
@@ -99,9 +115,13 @@
 				//variable declarations relating to data model
 				<apply-templates select=".//s:datamodel"/>
 
+				<call-template name="genEventRegularExpressions">
+					<with-param name="events" select="$allEventsEnum"/>
+				</call-template>
+
 				//abstract state
 				<call-template name="genAbstractState">
-					<with-param name="events" select="$eventsEnum"/>
+					<with-param name="events" select="$enumeratedEventsEnum"/>
 				</call-template>
 
 				//states
@@ -118,7 +138,7 @@
 				</call-template>
 
 				//trigger methods for synchronous interaction
-				<for-each select="$eventsEnum">
+				<for-each select="$allEventsEnum[not(c:name/text() = '*')]">
 					<call-template name="genExternalTriggerDispatcher">
 						<with-param name="event" select="."/>
 					</call-template>
@@ -163,6 +183,22 @@
 			<if test="position() != last()">, </if>
 		</for-each>;
 	</template>
+
+	<template name="genEventRegularExpressions">
+		<param name="events"/>
+
+		var <for-each select="$events/c:regexp">
+			<value-of select="c:name"/> = <value-of select="c:value"/>	
+			<choose>
+				<when test="position() = last()">
+				;
+				</when>
+				<otherwise>
+				,
+				</otherwise>
+			</choose>
+		</for-each>
+	</template>
 	
 	<template name="genAbstractState">
 		<param name="events"/>
@@ -175,6 +211,8 @@
 			</for-each>
 
 			this.$default = function(){};
+
+			this.$dispatchPrefixEvent = function(){};
 		}
 	</template>
 
@@ -184,15 +222,10 @@
 		<variable name="stateName" select="$state/@id"/>
 
 		<variable name="parentName">
-			<choose>
-				<when test="$state/../@id">
-					<value-of select="$state/../@id"/>
-				</when>
-				<otherwise>
-					<value-of select="$abstractStateName"/>
-				</otherwise>
-			</choose>
-		</variable>
+			<call-template name="getParentNameFromState">
+				<with-param name="s" select="$state"/>
+			</call-template>
+		</variable>	
 
 
 		<variable name="historyState" select="$state/s:history"/>
@@ -367,7 +400,27 @@
 	<!-- external communications module -->
 
 	<template match="s:send">
-	<!--TODO-->
+		<variable select="@event" name="eventName"/>
+
+		<choose>
+			<when test="@delay">
+				<!-- FIXME: this stuff needs to be fixed -->
+				<!--
+				window.setTimeout(function(){
+					self.GEN("<value-of select="@event"/>");
+				},<value-of select="number(@delay)*1000"/>);
+				-->
+			</when>
+			<otherwise>
+				<!--FIXME: hook up data part of this -->
+				innerEventQueue.push(
+						<call-template name="genExternalTriggerDispatcherRunToCompletionEventValue">
+							<with-param name="eventName" select="$eventName"/>
+						</call-template>,
+						null,
+						<value-of select="boolean($enumeratedEventsEnum[c:name/text() = $eventName])"/> );
+			</otherwise>
+		</choose>
 	</template>
 
 	<template match="s:cancel">
@@ -418,13 +471,15 @@
 	<template name="genExternalTriggerDispatcher">
 		<param name="event"/>
 
-		this.<value-of select="$event/c:name"/> = function(data){
+		this["<value-of select="$event/c:name"/>"] = function(data){
 			if(isInStableState){
 				runToCompletion(
+				//TODO: conditionally wrap in quotes for enumerated pattern
 					<call-template name="genExternalTriggerDispatcherRunToCompletionEventValue">
 						<with-param name="eventName" select="$event/c:name"/>
 					</call-template>
-				,data);
+				,data,
+				<value-of select="boolean($enumeratedEventsEnum[c:name/text() = $event/c:name/text()])"/>)
 			}else{
 				return undefined;
 			}
@@ -459,16 +514,16 @@
 			}
 		}
 
-		function runToCompletion(e,data){
+		function runToCompletion(e,data,isEnumeratedEvent){
 			isInStableState = false;
 
 			if(e){
-				innerEventQueue.push(e,data);
+				innerEventQueue.push(e,data,isEnumeratedEvent);
 			}
 
 			do{
 				//take any available default transitions
-				microstep(<value-of select="$defaultEventLiteral"/>);
+				microstep(<value-of select="$defaultEventLiteral"/>,null,true);
 
 				if(!hasTakenDefaultTransition){
 					
@@ -478,7 +533,7 @@
 						break;
 					}else{
 						//microstep, then dequeue next event sending in event
-						microstep(innerEventQueue.shift(),innerEventQueue.shift());
+						microstep(innerEventQueue.shift(),innerEventQueue.shift(),innerEventQueue.shift());
 					}
 				}else{
 					//he has taken a default transition, so reset the global variable to false and loop again
@@ -490,18 +545,35 @@
 			isInStableState = true;
 		}
 
-		function microstep(e,data){
-			currentConfiguration.forEach(function(state){
-				if(!isPreempted){
-					//we set the event as a global, rather than passing it into the function invocation as a parameter,
-					//because in cases of default events, the event object will be populated with previous event's data
-					if(e !== <value-of select="$defaultEventLiteral"/> ){
-						_event.name=<value-of select="$eventToNameMap"/>;
-						_event.data=data;
+		function microstep(e,data,isEnumeratedEvent){
+			if(isEnumeratedEvent){
+				//e does not contain a dot, so dispatch as an enumerated event
+				currentConfiguration.forEach(function(state){
+					if(!isPreempted){ 
+						//we set the event as a global, rather than passing it into the function invocation as a parameter,
+						//because in cases of default events, the event object will be populated with previous event's data
+						if(e !== <value-of select="$defaultEventLiteral"/> ){
+							_event.name=<value-of select="$eventToNameMap"/>;
+							_event.data=data;
+						}
+						<value-of select="$enumeratedEventDispatchInvocation"/>
 					}
-					<value-of select="$dispatchInvocation"/>
-				}
-			});
+				});
+			}else{
+				//e contains a dot, so dispatch as a prefix event
+				currentConfiguration.forEach(function(state){
+					if(!isPreempted){ 
+						//we set the event as a global, rather than passing it into the function invocation as a parameter,
+						//because in cases of default events, the event object will be populated with previous event's data
+						//NOTE: e will always be a string here, even in enumerated techniques
+						if(e !== <value-of select="$defaultEventLiteral"/> ){
+							_event.name=e;
+							_event.data=data;
+						}
+						<value-of select="$prefixEventDispatchInvocation"/>
+					}
+				});
+			}
 
 			//reset the isPreempted flag
 			isPreempted = false;

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StatePatternStatechartGenerator.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StatePatternStatechartGenerator.xsl?rev=966772&r1=966771&r2=966772&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StatePatternStatechartGenerator.xsl (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StatePatternStatechartGenerator.xsl Thu Jul 22 17:51:25 2010
@@ -22,7 +22,8 @@
 
 	<import href="AbstractStatechartGenerator.xsl"/>
 
-	<variable name="dispatchInvocation" select="'state[e]();'"/>
+	<variable name="enumeratedEventDispatchInvocation" select="'state[e]();'"/>
+	<variable name="prefixEventDispatchInvocation" select="'state.$dispatchPrefixEvent(e)'"/>
 	<variable name="defaultEventLiteral" select="'&quot;$default&quot;'"/>
 	<variable name="currentConfigurationExpression" select="'currentConfiguration.slice()'"/>
 	<variable name="inPredicateFunctionStateReference" select="'state'"/>
@@ -39,12 +40,12 @@
 
 		<!-- iterate through groups of transitions, grouped by event -->
 		<!--FIXME: this is likely to be a bit slow, as we're iterating through all events -->
-		<for-each select="$eventsEnum/c:name">
+		<for-each select="$enumeratedEventsEnum/c:name">
 			<variable name="eventName">
 				<value-of select="."/>
 			</variable>
 
-			<variable name="transitionsForEvent" select="$state/s:transition[@event = $eventName]"/>
+			<variable name="transitionsForEvent" select="$state/c:enumeratedEventTransitions/c:enumeratedTransition[@event = $eventName]"/>
 			<if test="$transitionsForEvent">
 				<call-template name="genTriggerDispatcherContext">
 					<with-param name="s" select="$state"/>
@@ -55,7 +56,7 @@
 		</for-each>
 
 		<!-- now do default transitions -->
-		<variable name="defaultTransitionsForState" select="$state/s:transition[not(@event)]"/>
+		<variable name="defaultTransitionsForState" select="$state/c:enumeratedEventTransitions/c:enumeratedTransition[not(@event)]"/>
 		<if test="$defaultTransitionsForState">
 			<call-template name="genTriggerDispatcherContext">
 				<with-param name="s" select="$state"/>
@@ -63,6 +64,37 @@
 				<with-param name="eventName" select="'$default'"/>
 			</call-template>
 		</if>
+
+		<!-- now do prefix event handler -->
+		<!-- TODO: consolidate all of these references to dispatchPrefixEvent into a global variable -->
+		this.$dispatchPrefixEvent = function(e){
+			<!-- we skip default events, as these will always be enumerated, hence will never end up in this region -->
+			<for-each select="$state/s:transition[@event]">
+				<!-- look up regexp name -->
+				<variable name="eventName" select="@event"/>
+				<variable name="regexpName" select="$allEventsEnum[c:name/text() = $eventName]/c:regexp/c:name"/>
+				
+				if(e.match(<value-of select="$regexpName"/>)
+					<if test="@cond">
+						&amp;&amp; <value-of select="@cond"/>
+					</if>){
+					<call-template name="genTriggerDispatcherContents">
+						<with-param name="s" select="$state"/>
+						<with-param name="transitions" select="."/>
+						<with-param name="eventName" select="$eventName"/>
+					</call-template>
+				}
+			</for-each>
+
+			<variable name="parentName">
+				<call-template name="getParentNameFromState">
+					<with-param name="s" select="$state"/>
+				</call-template>
+			</variable>	
+
+			<value-of select="$parentName"/>.$dispatchPrefixEvent(e);
+		}
+		
 	</template>
 
 	<template name="genParallelSubstateConfigurationSetString">
@@ -118,17 +150,11 @@
 
 			<!-- if by this point he hasn't returned, then none of the transitions passed, 
 				and we need to pass the transition up the hierarchy chain -->
-
 			<variable name="parentName">
-				<choose>
-					<when test="$s/../@id">
-						<value-of select="$s/../@id"/>
-					</when>
-					<otherwise>
-						<value-of select="$abstractStateName"/>
-					</otherwise>
-				</choose>
-			</variable>
+				<call-template name="getParentNameFromState">
+					<with-param name="s" select="$s"/>
+				</call-template>
+			</variable>	
 
 			<value-of select="$parentName"/>['<value-of select="$eventName"/>']();
 		}
@@ -146,17 +172,4 @@
 		"<value-of select="$eventName"/>"
 	</template>
 
-	<template match="s:send">
-		<choose>
-			<when test="@delay">
-				window.setTimeout(function(){
-					self.GEN("<value-of select="@event"/>");
-				},<value-of select="number(@delay)*1000"/>);
-			</when>
-			<otherwise>
-				innerEventQueue.push("<value-of select="@event"/>");
-			</otherwise>
-		</choose>
-	</template>
-
 </stylesheet>

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StateTableStatechartGenerator.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StateTableStatechartGenerator.xsl?rev=966772&r1=966771&r2=966772&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StateTableStatechartGenerator.xsl (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StateTableStatechartGenerator.xsl Thu Jul 22 17:51:25 2010
@@ -22,7 +22,7 @@
 
 	<import href="AbstractEnumeratedStatechartGenerator.xsl"/>
 
-	<variable name="dispatchInvocation" select="'STATE_TRANSITION_TABLE[state][e]();'"/>
+	<variable name="enumeratedEventDispatchInvocation" select="'STATE_TRANSITION_TABLE[state][e]();'"/>
 
 	<variable name="nullTransitionFunctionName" select="'$nt'"/>
 
@@ -50,7 +50,7 @@
 
 				<text>[</text>
 
-					<for-each select="$eventsEnum">
+					<for-each select="$enumeratedEventsEnum">
 						<sort select="c:id" data-type="number"/>	
 
 						<variable name="currentEvent" select="."/>
@@ -61,8 +61,8 @@
 						<!-- conditionally instantiating this variable to a node-set.
 							hacky syntax, see http://dpawson.co.uk/xsl/sect2/N8090.html#d10871e1456 -->
 						<variable name="correspondingTransitions" 
-							select="$currentState/s:transition[$isDefaultTransition][not(@event)] | 
-								$currentState/s:transition[not($isDefaultTransition)][@event = $currentEvent/c:name]"/>
+							select="$currentState/c:enumeratedEventTransitions/c:enumeratedTransition[$isDefaultTransition][not(@event)] | 
+								$currentState/c:enumeratedEventTransitions/c:enumeratedTransition[not($isDefaultTransition)][@event = $currentEvent/c:name]"/>
 
 						<!--
 						<message>

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/SwitchyardStatechartGenerator.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/SwitchyardStatechartGenerator.xsl?rev=966772&r1=966771&r2=966772&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/SwitchyardStatechartGenerator.xsl (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/SwitchyardStatechartGenerator.xsl Thu Jul 22 17:51:25 2010
@@ -22,7 +22,7 @@
 
 	<import href="AbstractEnumeratedStatechartGenerator.xsl"/>
 
-	<variable name="dispatchInvocation" select="'dispatch(state,e)'"/>
+	<variable name="enumeratedEventDispatchInvocation" select="'dispatch(state,e)'"/>
 
 	<template name="genEnumeratedHooks">
 			//state transition table
@@ -51,7 +51,7 @@
 
 		case <value-of select="$s/@c:enumId"/>:
 			switch(e) {
-				<for-each select="$s/s:transition">
+				<for-each select="$s/c:enumeratedEventTransitions/c:enumeratedTransition">
 					<call-template name="genEventCase">
 						<with-param name="t" select="."/>
 					</call-template>

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/addEventRegularExpressions.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/addEventRegularExpressions.xsl?rev=966772&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/addEventRegularExpressions.xsl (added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/addEventRegularExpressions.xsl Thu Jul 22 17:51:25 2010
@@ -0,0 +1,146 @@
+<?xml version="1.0"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+	xmlns:s="http://www.w3.org/2005/07/scxml"
+	xmlns="http://www.w3.org/2005/07/scxml"
+	xmlns:c="http://commons.apache.org/scxml-js"
+	version="1.0">
+	<xsl:output method="xml"/>
+
+	<!-- identity transform -->
+	<xsl:template match="@*|node()">
+		<xsl:copy>
+			<xsl:apply-templates select="@*|node()"/>
+		</xsl:copy>
+	</xsl:template>
+
+
+	<xsl:template name="escapePeriods">
+		<xsl:param name="eventName" /> 
+
+		<xsl:variable name="first" select="substring-before($eventName, '.')" /> 
+		<xsl:variable name="remaining" select="substring-after($eventName, '.')" /> 
+
+		<!--
+		<xsl:message>
+			eventName:<xsl:value-of select="$eventName"/>
+			first:<xsl:value-of select="$first"/>
+			remaining:<xsl:value-of select="$remaining"/>
+		</xsl:message>
+		-->
+
+		<xsl:choose>
+			<xsl:when test="$first and $remaining">
+				<xsl:value-of select="$first" /><xsl:text>\.</xsl:text>
+
+				<xsl:call-template name="escapePeriods">
+					<xsl:with-param name="eventName" select="$remaining" /> 
+				</xsl:call-template>
+			</xsl:when>
+			<xsl:otherwise>
+				<xsl:value-of select="$eventName"/>
+			</xsl:otherwise>
+		</xsl:choose>
+
+	</xsl:template>
+
+	<xsl:template name="replacePeriodsWithUnderscores">
+		<xsl:param name="eventName" /> 
+
+		<xsl:variable name="first" select="substring-before($eventName, '.')" /> 
+		<xsl:variable name="remaining" select="substring-after($eventName, '.')" /> 
+
+		<!--
+		<xsl:message>
+			eventName:<xsl:value-of select="$eventName"/>
+			first:<xsl:value-of select="$first"/>
+			remaining:<xsl:value-of select="$remaining"/>
+		</xsl:message>
+		-->
+
+		<xsl:choose>
+			<xsl:when test="$first and $remaining">
+				<xsl:value-of select="$first" /><xsl:text>_</xsl:text>
+
+				<xsl:call-template name="replacePeriodsWithUnderscores">
+					<xsl:with-param name="eventName" select="$remaining" /> 
+				</xsl:call-template>
+			</xsl:when>
+			<xsl:otherwise>
+				<xsl:value-of select="$eventName"/>
+			</xsl:otherwise>
+		</xsl:choose>
+
+	</xsl:template>
+
+	<!-- recursive template -->
+	<xsl:template name="eventNameToJsRegExpLiteral">
+	    <xsl:param name="eventName" /> 
+
+	    <xsl:text>/^(</xsl:text>
+	    <xsl:call-template name="escapePeriods">
+		    <xsl:with-param name="eventName" select="$eventName" />
+	    </xsl:call-template>
+	    <xsl:text>)/</xsl:text>
+	</xsl:template>
+
+	<xsl:template match="/s:scxml/c:allEventsEnum/c:event">
+
+		<xsl:variable name="safeRegexpName">
+			<xsl:choose>
+				<xsl:when test="c:name/text() = '*'">
+					<xsl:text>star</xsl:text>
+				</xsl:when>
+				<xsl:otherwise>
+					<xsl:call-template name="replacePeriodsWithUnderscores">
+						<xsl:with-param name="eventName" select="c:name"/>
+					</xsl:call-template>
+				</xsl:otherwise>
+			</xsl:choose>
+		</xsl:variable>
+		<xsl:variable name="regexpName" select="concat($safeRegexpName,'_Regexp_',generate-id())"/>
+
+		<xsl:variable name="regexpValue">
+			<xsl:choose>
+				<xsl:when test="c:name/text() = '*'">
+					<xsl:text>/.*/</xsl:text>
+				</xsl:when>
+				<xsl:otherwise>
+					<xsl:call-template name="eventNameToJsRegExpLiteral">
+						<xsl:with-param name="eventName" select="c:name/text()"/>
+					</xsl:call-template>
+				</xsl:otherwise>
+			</xsl:choose>
+		</xsl:variable>
+	
+		<xsl:copy>
+			<xsl:apply-templates select="@*"/>
+
+			<c:regexp>
+				<c:name><xsl:value-of select="$regexpName"/></c:name>
+				<c:value><xsl:value-of select="$regexpValue"/></c:value>
+			</c:regexp>
+
+			<xsl:apply-templates select="node()"/>
+		</xsl:copy>
+	</xsl:template>
+
+
+</xsl:stylesheet>
+
+

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/addEventRegularExpressions.xsl
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/copyEnumeratedEventTransitions.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/copyEnumeratedEventTransitions.xsl?rev=966772&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/copyEnumeratedEventTransitions.xsl (added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/copyEnumeratedEventTransitions.xsl Thu Jul 22 17:51:25 2010
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!--
+    Document   : separateEnumeratedEventTransitions.xsl
+    Created on : July 20, 2010, 1:33 PM
+    Author     : jacob
+    Description:
+        Purpose of transformation follows.
+-->
+
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+	xmlns:s="http://www.w3.org/2005/07/scxml"
+	xmlns="http://www.w3.org/2005/07/scxml"
+	xmlns:c="http://commons.apache.org/scxml-js"
+	version="1.0">
+	<xsl:output method="xml"/>
+
+	<!-- identity transform -->
+	<xsl:template match="@*|node()">
+		<xsl:copy>
+			<xsl:apply-templates select="@*|node()"/>
+		</xsl:copy>
+	</xsl:template>
+
+	<xsl:template match="s:*[s:transition]">
+		<xsl:copy>
+			<xsl:apply-templates select="@*|node()"/>
+
+			<c:enumeratedEventTransitions>
+				<xsl:for-each select="s:transition[not(@event) or not(contains(@event,'.'))]">
+					<c:enumeratedTransition>
+						<xsl:apply-templates select="@*|node()"/>
+					</c:enumeratedTransition>
+				</xsl:for-each>
+			</c:enumeratedEventTransitions>
+		</xsl:copy>
+	</xsl:template>
+
+
+</xsl:stylesheet>

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/copyEnumeratedEventTransitions.xsl
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/enumerateEvents.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/enumerateEvents.xsl?rev=966772&r1=966771&r2=966772&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/enumerateEvents.xsl (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/enumerateEvents.xsl Thu Jul 22 17:51:25 2010
@@ -26,7 +26,8 @@ source document under the namespaced <ev
 	version="1.0">
 	<xsl:output method="xml"/>
 
-	<xsl:key name="events" match="s:transition" use="@event"/>	<!-- used for generating unique list -->
+	<xsl:key name="enumeratedEvents" match="c:enumeratedTransition" use="@event"/>	<!-- used for generating unique list -->
+	<xsl:key name="allEvents" match="s:transition" use="@event"/>	<!-- used for generating unique list -->
 
 	<!-- we copy them, so that we can use their positions as identifiers -->
 
@@ -38,12 +39,13 @@ source document under the namespaced <ev
 	</xsl:template>
 
 	<xsl:template match="/s:scxml">
-		<xsl:variable name="uniqueEvents" select="//s:transition[generate-id(.)=generate-id(key('events',@event)[1])]/@event"/>
+		<xsl:variable name="uniqueEvents" select="//s:transition[generate-id(.)=generate-id(key('allEvents',@event)[1])]/@event"/>
+		<xsl:variable name="uniqueEnumeratedEvents" select="//c:enumeratedTransition[generate-id(.)=generate-id(key('enumeratedEvents',@event)[1])][not(@event='*')]/@event"/>
 
 		<xsl:copy>
 			<xsl:apply-templates select="@*|node()"/>
 	
-			<c:eventsEnum>
+			<c:enumeratedEventsEnum>
 				<!-- start with default event -->
 				<!-- FIXME: this may be a bit specfic to the JavaScript backend, hence a bit evil. might be better to separate this out -->
 				<c:event>
@@ -55,6 +57,27 @@ source document under the namespaced <ev
 					</c:id>
 				</c:event>
 
+				<xsl:for-each select="$uniqueEnumeratedEvents">
+					<c:event>
+						<c:name>
+							<xsl:value-of select="."/>
+						</c:name>
+						<c:id>
+							<xsl:value-of select="position()"/>
+						</c:id>
+					</c:event>
+				</xsl:for-each>	
+			</c:enumeratedEventsEnum>
+			<c:allEventsEnum>
+				<c:event>
+					<c:name>
+						<xsl:value-of select="'$default'"/>
+					</c:name>
+					<c:id>
+						<xsl:value-of select="0"/>
+					</c:id>
+				</c:event>
+
 				<xsl:for-each select="$uniqueEvents">
 					<c:event>
 						<c:name>
@@ -65,7 +88,7 @@ source document under the namespaced <ev
 						</c:id>
 					</c:event>
 				</xsl:for-each>	
-			</c:eventsEnum>
+			</c:allEventsEnum>
 		</xsl:copy>
 	</xsl:template>
 

Copied: commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/expandStarEvent.xsl (from r966771, commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/enumerateEvents.xsl)
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/expandStarEvent.xsl?p2=commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/expandStarEvent.xsl&p1=commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/enumerateEvents.xsl&r1=966771&r2=966772&rev=966772&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/enumerateEvents.xsl (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/expandStarEvent.xsl Thu Jul 22 17:51:25 2010
@@ -15,10 +15,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
 -->
-<!--
-This stylesheet creates a list of unique transition events, and adds it to the
-source document under the namespaced <eventsEnum> element.
--->
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
 	xmlns:s="http://www.w3.org/2005/07/scxml"
 	xmlns="http://www.w3.org/2005/07/scxml"
@@ -26,9 +22,7 @@ source document under the namespaced <ev
 	version="1.0">
 	<xsl:output method="xml"/>
 
-	<xsl:key name="events" match="s:transition" use="@event"/>	<!-- used for generating unique list -->
-
-	<!-- we copy them, so that we can use their positions as identifiers -->
+	<xsl:variable name="enumeratedEventsEnum" select="/s:scxml/c:enumeratedEventsEnum/c:event"/>
 
 	<!-- identity transform -->
 	<xsl:template match="@*|node()">
@@ -37,38 +31,25 @@ source document under the namespaced <ev
 		</xsl:copy>
 	</xsl:template>
 
-	<xsl:template match="/s:scxml">
-		<xsl:variable name="uniqueEvents" select="//s:transition[generate-id(.)=generate-id(key('events',@event)[1])]/@event"/>
+	<xsl:template match="c:enumeratedTransition[@event='*']">
 
-		<xsl:copy>
-			<xsl:apply-templates select="@*|node()"/>
-	
-			<c:eventsEnum>
-				<!-- start with default event -->
-				<!-- FIXME: this may be a bit specfic to the JavaScript backend, hence a bit evil. might be better to separate this out -->
-				<c:event>
-					<c:name>
-						<xsl:value-of select="'$default'"/>
-					</c:name>
-					<c:id>
-						<xsl:value-of select="0"/>
-					</c:id>
-				</c:event>
-
-				<xsl:for-each select="$uniqueEvents">
-					<c:event>
-						<c:name>
-							<xsl:value-of select="."/>
-						</c:name>
-						<c:id>
-							<xsl:value-of select="position()"/>
-						</c:id>
-					</c:event>
-				</xsl:for-each>	
-			</c:eventsEnum>
-		</xsl:copy>
+		<xsl:variable name="currentEnumeratedEventTransition" select="."/>
+
+		<xsl:for-each select="$enumeratedEventsEnum[not(c:name/text() = '$default')]">
+			<c:enumeratedTransition>
+				<xsl:apply-templates select="$currentEnumeratedEventTransition/@*[not(self::event)]"/>
+
+				<xsl:attribute name="event">
+					<xsl:value-of select="c:name"/>
+				</xsl:attribute>
+
+				<xsl:apply-templates select="$currentEnumeratedEventTransition/node()"/>
+			</c:enumeratedTransition>
+		</xsl:for-each>
 	</xsl:template>
 
 
 </xsl:stylesheet>
 
+
+

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/nameTransitions.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/nameTransitions.xsl?rev=966772&r1=966771&r2=966772&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/nameTransitions.xsl (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/nameTransitions.xsl Thu Jul 22 17:51:25 2010
@@ -41,12 +41,43 @@ enuemrated statechart backends.
 		</xsl:copy>
 	</xsl:template>
 
+	<xsl:template name="replacePeriodsWithUnderscores">
+		<xsl:param name="eventName" /> 
+
+		<xsl:variable name="first" select="substring-before($eventName, '.')" /> 
+		<xsl:variable name="remaining" select="substring-after($eventName, '.')" /> 
+
+		<!--
+		<xsl:message>
+			eventName:<xsl:value-of select="$eventName"/>
+			first:<xsl:value-of select="$first"/>
+			remaining:<xsl:value-of select="$remaining"/>
+		</xsl:message>
+		-->
+
+		<xsl:choose>
+			<xsl:when test="$first and $remaining">
+				<xsl:value-of select="$first" /><xsl:text>_</xsl:text>
+
+				<xsl:call-template name="replacePeriodsWithUnderscores">
+					<xsl:with-param name="eventName" select="$remaining" /> 
+				</xsl:call-template>
+			</xsl:when>
+			<xsl:otherwise>
+				<xsl:value-of select="$eventName"/>
+			</xsl:otherwise>
+		</xsl:choose>
+
+	</xsl:template>
+
 	<xsl:template match="s:transition">
 
 		<xsl:variable name="eventName">
 			<xsl:choose>
 				<xsl:when test="@event">
-					<xsl:value-of select="@event"/>
+				    <xsl:call-template name="replacePeriodsWithUnderscores">
+					    <xsl:with-param name="eventName" select="@event" />
+				    </xsl:call-template>
 				</xsl:when>
 				<xsl:otherwise>
 					<xsl:value-of select="'$default'"/>
@@ -58,7 +89,14 @@ enuemrated statechart backends.
 			<xsl:apply-templates select="@*"/>
 
 			<xsl:attribute name="tName" namespace="http://commons.apache.org/scxml-js">
-				<xsl:value-of select="concat(../@id,'_',$eventName)"/>
+				<xsl:choose>
+					<xsl:when test="$eventName='*'">
+						<xsl:value-of select="concat(../@id,'_star')"/>
+					</xsl:when>
+					<xsl:otherwise>
+						<xsl:value-of select="concat(../@id,'_',$eventName)"/>
+					</xsl:otherwise>
+				</xsl:choose>
 			</xsl:attribute>
 
 			<xsl:apply-templates select="node()"/>

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/numberStatesAndTransitions.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/numberStatesAndTransitions.xsl?rev=966772&r1=966771&r2=966772&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/numberStatesAndTransitions.xsl (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/numberStatesAndTransitions.xsl Thu Jul 22 17:51:25 2010
@@ -16,13 +16,6 @@
 	</xsl:template>
 
 	<xsl:template match="s:state[@c:isBasic] | s:final | s:initial | s:history">
-
-		<!-- what we want to ask is, what is his position in the nodeset that we've constructed? 
-			but we can't use position normally... can only be used wrt to the context node
-			i think the easiest thing to think about is just iterating through these state nodes in a for-each
-			fashion. but... yah, can't do that in the top-down recursive manner that we're doing.
-
-		-->
 	
 		<xsl:variable name="stateNum">
 			<xsl:number level="any" 
@@ -59,17 +52,10 @@
 	</xsl:template>
 
 
-	<xsl:template match="s:transition">
+	<xsl:template match="c:enumeratedTransition">
 
-		<!-- what we want to ask is, what is his position in the nodeset that we've constructed? 
-			but we can't use position normally... can only be used wrt to the context node
-			i think the easiest thing to think about is just iterating through these state nodes in a for-each
-			fashion. but... yah, can't do that in the top-down recursive manner that we're doing.
-
-		-->
-	
 		<xsl:variable name="transitionNum">
-			<xsl:number level="any" count="s:transition"/>
+			<xsl:number level="any" count="c:enumeratedTransition"/>
 		</xsl:variable>
 
 		<!--

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/test/prefix_events/TestPrefixEvents.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/test/prefix_events/TestPrefixEvents.xml?rev=966772&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/test/prefix_events/TestPrefixEvents.xml (added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/test/prefix_events/TestPrefixEvents.xml Thu Jul 22 17:51:25 2010
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+<scxml 
+	xmlns="http://www.w3.org/2005/07/scxml"
+	version="1.0"
+	profile="ecmascript">
+
+	<initial>
+		<transition target="a1"/>
+	</initial>
+
+	<!-- given event foo.bar, foo should be selected, and we should end in state b1-->
+	<state id="a1">
+		<transition event="foo" target="b1"/>	
+		<transition event="foo.bar" target="a2"/>
+	</state>
+
+	<state id="a2"/>
+
+	<!-- Given event foo, we should end in state c1 --> 
+	<state id="b1">
+		<transition event="foo.bar" target="b2"/>	
+		<transition event="foo" target="c1"/>
+	</state>
+
+	<state id="b2"/>
+
+	<!-- Given event foo.bar, we should end in state d1-->
+	<state id="c1">
+		<transition event="foo.bar.bat" target="c2"/>
+		<transition event="foo.bar" target="d1"/>
+	</state>
+
+	<state id="c2"/>
+
+	<!-- given event foo.bar.bat, foo.bar should be selected, and we should end in state e1 -->
+	<state id="d1">
+		<transition event="foo.bar" target="e1"/>
+		<transition event="foo.bar.bat" target="d2"/>
+	</state>
+
+	<state id="d2"/>
+
+	<!-- given event foo.bar.bat, foo.bar.bat should be selected, and we should end in state f1 -->
+	<state id="e1">
+		<transition event="foo.bar.bat" target="f1"/>
+		<transition event="foo.bar" target="e2"/>
+	</state>
+
+	<state id="e2"/>
+
+	<!-- given event foo, * should be select, and we should end in g1 -->
+	<state id="f1">
+		<transition event="*" target="g1"/>
+		<transition event="foo" target="f2"/>
+	</state>
+
+	<state id="f2"/>
+
+	<!-- given event foo, foo should be selected, and we should end in h1 -->
+	<state id="g1">
+		<transition event="foo" target="h1"/>
+		<transition event="*" target="g2"/>
+	</state>
+
+	<state id="g2"/>
+
+	<!-- given event foo.bar, * should be selected, and we should end in i1 -->
+	<state id="h1">
+		<transition event="*" target="i1"/>
+		<transition event="foo.bar" target="i2"/>
+	</state>
+
+	<state id="i2"/>
+
+	<!-- given event foo.bar, foo.bar should be selected, and we should end in j1 -->
+	<state id="i1">
+		<transition event="foo.bar" target="j1"/>
+		<transition event="*" target="i2"/>
+	</state>
+
+	<state id="i2"/>
+
+	<!-- given event foo.bar, * should be select, and we should end in k1 -->
+	<state id="j1">
+		<transition event="foo.bar.bat" target="j2"/>
+		<transition event="*" target="k1"/>
+	</state>
+
+	<state id="j2"/>
+
+	<!-- given event w00t, * should be select, and we should end in l1 -->
+	<state id="k1">
+		<transition event="foo.bar" target="k2"/>
+		<transition event="*" target="l1"/>
+	</state>
+
+	<state id="k2"/>
+
+	<state id="l1"/>
+
+</scxml>

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/test/prefix_events/TestPrefixEvents.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/test/prefix_events/scripts/unitTest.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/test/prefix_events/scripts/unitTest.js?rev=966772&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/test/prefix_events/scripts/unitTest.js (added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/test/prefix_events/scripts/unitTest.js Thu Jul 22 17:51:25 2010
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+require.def( "test/prefix_events/scripts/unitTest",
+{
+
+	scxmlTest : "test/prefix_events/TestPrefixEvents.xml",
+
+	register:function(scConstructor){
+
+		//TODO: can load this using RequireJS, so we don't need to use the dojo module system?
+		dojo.require("doh.runner");
+		var sc;
+		doh.register("testPrefixEvents",[
+				{
+					name:"testAll",
+					//timeout:5000,
+					setUp:function(){
+						sc = new scConstructor()
+						sc.initialize();
+					},
+					runTest:function(){
+						var $ = function(conf){return conf.map(function(s){return s.toString()})};
+
+						//sanity tests
+						var conf0 = sc.getCurrentConfiguration();
+						console.log($(conf0));
+						doh.assertEqual(sc._states.a1,conf0[0]);
+
+						console.info("sending event foo.bar")
+						sc["foo.bar"]()
+						var conf1 = sc.getCurrentConfiguration();
+						console.log($(conf1));
+						doh.assertEqual(sc._states.b1,conf1[0]);
+
+
+						console.info("sending event foo")
+						sc.foo()
+						var conf2 = sc.getCurrentConfiguration();
+						console.log($(conf2));
+						doh.assertEqual(sc._states.c1,conf2[0]);
+
+						console.info("sending event foo.bar")
+						sc["foo.bar"]()
+						var conf3 = sc.getCurrentConfiguration();
+						console.log($(conf3));
+						doh.assertEqual(sc._states.d1,conf3[0]);
+
+						console.info("sending event foo.bar.bat")
+						sc["foo.bar.bat"]()
+						var conf4 = sc.getCurrentConfiguration();
+						console.log($(conf4));
+						doh.assertEqual(sc._states.e1,conf4[0]);
+
+						console.info("sending event foo.bar.bat")
+						sc["foo.bar.bat"]()
+						var conf5 = sc.getCurrentConfiguration();
+						console.log($(conf5));
+						doh.assertEqual(sc._states.f1,conf5[0]);
+
+
+						console.info("sending event foo")
+						sc["foo"]()
+						var conf6 = sc.getCurrentConfiguration();
+						console.log($(conf6));
+						doh.assertEqual(sc._states.g1,conf6[0]);
+
+						console.info("sending event foo")
+						sc["foo"]()
+						var conf7 = sc.getCurrentConfiguration();
+						console.log($(conf7));
+						doh.assertEqual(sc._states.h1,conf7[0]);
+
+
+						console.info("sending event foo.bar")
+						sc["foo.bar"]()
+						var conf8 = sc.getCurrentConfiguration();
+						console.log($(conf8));
+						doh.assertEqual(sc._states.i1,conf8[0]);
+
+						console.info("sending event foo.bar")
+						sc["foo.bar"]()
+						var conf9 = sc.getCurrentConfiguration();
+						console.log($(conf9));
+						doh.assertEqual(sc._states.j1,conf9[0]);
+
+
+						console.info("sending event foo.bar")
+						sc["foo.bar"]()
+						var conf10 = sc.getCurrentConfiguration();
+						console.log($(conf10));
+						doh.assertEqual(sc._states.k1,conf10[0]);
+
+						//TODO: fix GEN so that we can send in events that are not specified in the statechart
+						//console.info("sending event w00t")
+						//sc.GEN("w00t")()
+						//var conf11 = sc.getCurrentConfiguration();
+						//console.log($(conf11));
+						//doh.assertEqual(sc._states.l1,conf11[0]);
+					},
+					tearDown:function(){
+						 sc.destroy();
+					}
+				}
+		]);
+	}
+})
+
+

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/test/prefix_events/scripts/unitTest.js
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/test/test_with_xsltproc.sh
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/test/test_with_xsltproc.sh?rev=966772&r1=966771&r2=966772&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/test/test_with_xsltproc.sh (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/test/test_with_xsltproc.sh Thu Jul 22 17:51:25 2010
@@ -1,6 +1,6 @@
 #!/bin/sh
-
-xsltproc ../src/xslt/ir-compiler/enumerateEvents.xsl kitchen_sink/KitchenSink_executableContent.xml | \
+#cat prefix_events/TestPrefixEvents.xml | \
+cat simple2.xml | \
 xsltproc ../src/xslt/ir-compiler/normalizeInitialStates.xsl - | \
 xsltproc ../src/xslt/ir-compiler/generateUniqueStateIds.xsl - | \
 xsltproc ../src/xslt/ir-compiler/generateUniqueInitialStateIds.xsl - | \
@@ -13,11 +13,17 @@ xsltproc ../src/xslt/ir-compiler/appendB
 xsltproc ../src/xslt/ir-compiler/flattenTransitions.xsl - | \
 xsltproc ../src/xslt/ir-compiler/appendTransitionInformation.xsl - | \
 xsltproc ../src/xslt/ir-compiler/nameTransitions.xsl - | \
+#
+xsltproc ../src/xslt/ir-compiler/copyEnumeratedEventTransitions.xsl - | \
+xsltproc ../src/xslt/ir-compiler/enumerateEvents.xsl - | \
+xsltproc ../src/xslt/ir-compiler/addEventRegularExpressions.xsl - | \
+xsltproc ../src/xslt/ir-compiler/expandStarEvent.xsl - | \
+#
 xsltproc ../src/xslt/ir-compiler/numberStatesAndTransitions.xsl - | \
 xmlindent > tmp_IR.xml;
 
 #uncomment to compile IR to js
-xsltproc ../build/StatePatternStatechartGenerator_combined.xsl tmp_IR.xml > out.js
+xsltproc ../build/StateTableStatechartGenerator_combined.xsl tmp_IR.xml > out.js
 
 #uncomment to prettify js. need to have beautify.js, beautify-cl.js and beautify-html.js in this directory
 #java -cp ../lib/java/js.jar org.mozilla.javascript.tools.shell.Main -debug beautify-cl.js -i 4 out.js > out_pretty.js