commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbe...@apache.org
Subject svn commit: r1082576 - in /commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js: AbstractEnumeratedStatechartGenerator.xsl AbstractStatechartGenerator.xsl StatePatternStatechartGenerator.xsl
Date Thu, 17 Mar 2011 16:21:56 GMT
Author: jbeard
Date: Thu Mar 17 16:21:56 2011
New Revision: 1082576

URL: http://svn.apache.org/viewvc?rev=1082576&view=rev
Log:
Fixed bug where preempted basic states were not being generated correctly for each transition.
The LCA of the transition was being used, but really this should have been the top-most parallel
ancestor, which is still descendant of the lca.

Modified:
    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

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=1082576&r1=1082575&r2=1082576&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 Mar 17 16:21:56 2011
@@ -300,23 +300,11 @@
 		</choose>
 	</template>
 
-	<template name="genPreemptedBasicStatesSet">
-		<param name="t"/>
-
-		<!-- this should map parallel state id to set of preempted basic state descendants -->

-		
-		{
-			<!-- TODO: move this out into subclasses -->
-			<for-each select="$t/c:basicStateDescendantsOfNearestParallelDescendentOfLCA/c:basicStateDescendant">
-				<variable name="basicStateDescendantId" select="text()"/>
-				<variable name="descendantState" select="$allStates[@id=$basicStateDescendantId]"/>
-				<value-of select="$descendantState/@c:stateNum - 1"/> : true
-				<if test="position() != last()">,</if>
-			</for-each>
-		}
+	<template name="genStateRefIdentifier">
+		<param name="s"/>
+		<value-of select="$s/@c:stateNum - 1"/>
 	</template>
 
-
 	<template name="genStateHooks"/>
 	<template name="genEnumeratedHooks"/>
 	<template name="genTriggerIntEnum"/>

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=1082576&r1=1082575&r2=1082576&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 Mar 17 16:21:56 2011
@@ -64,6 +64,7 @@
 
 	<variable name="abstractStateName" select="'AbstractState'"/>
 	<variable name="delayedSendBaseVariableName" select="'_$timeoutId'"/>
+	<variable name="basicStateDescendantOfParallelStateHash" select="'$basicStateDescendantsOfParallelStates'"/>
 
 	<variable name="defaultIteratorVarName" select="concat(generate-id(),'_iterator')"/>
 	<variable name="defaultHoistVarName" select="concat(generate-id(),'_hoist')"/>
@@ -253,6 +254,7 @@
 					</call-template>
 				</for-each>
 
+				<call-template name="genParallelStateBasicSubstatesHash"/>
 		
 				//states enum for glass-box unit testing
 				<call-template name="genStatesEnum">
@@ -294,6 +296,22 @@
 
 	</template>
 
+	<template name="genParallelStateBasicSubstatesHash">
+		var <value-of select="$basicStateDescendantOfParallelStateHash"/> = {
+			<for-each select="//s:parallel">
+				<value-of select="@id"/> : {
+					<for-each select=".//*[@c:isBasic]">
+						<call-template name="genStateRefIdentifier">
+							<with-param name="s" select="."/>
+						</call-template> : true
+						<if test="not(position() = last())">,</if>
+					</for-each>
+				}
+				<if test="not(position() = last())">,</if>
+			</for-each>
+		}
+	</template>
+
 	<template match="s:datamodel">
 		var <for-each select="s:data">
 			<value-of select="@id"/> 
@@ -853,7 +871,7 @@
 		if(<value-of select="$historyStateReference"/>.lastConfiguration){
 
 			return {
-				preemptedBasicStates: <call-template name="genPreemptedBasicStatesSet"><with-param
name="t" select="$t"/></call-template>,
+				preemptedBasicStates : <call-template name="genPreemptedBasicStateReference"><with-param
name="t" select="$t"/></call-template>,
 				action: function(){
 					//transition action
 					<if test="$log">
@@ -1083,6 +1101,17 @@
 		</choose>
 	</template>
 
+	<template name="genPreemptedBasicStateReference">
+		<param name="t"/>
+
+		<choose>
+			<when test="$t/c:nearestParallelDescendantOfLCA">
+				<value-of select="$basicStateDescendantOfParallelStateHash"/>["<value-of select="$t/c:nearestParallelDescendantOfLCA"/>"]
+			</when>
+			<otherwise> {} </otherwise>
+		</choose>
+	</template>
+
 	<template name="genTriggerDispatcherInnerContents">
 		<param name="s"/>
 		<param name="t"/>
@@ -1093,7 +1122,7 @@
 			if(<value-of select="@cond"/>)
 		</if>
 		return {
-			preemptedBasicStates : <call-template name="genPreemptedBasicStatesSet"><with-param
name="t" select="$t"/></call-template>,
+			preemptedBasicStates : <call-template name="genPreemptedBasicStateReference"><with-param
name="t" select="$t"/></call-template>,
 			action : function(){
 				<if test="not($t/@event)">
 					hasTakenDefaultTransition = true;

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=1082576&r1=1082575&r2=1082576&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 Mar 17 16:21:56 2011
@@ -213,16 +213,9 @@
 		"<value-of select="$eventName"/>"
 	</template>
 
-       <template name="genPreemptedBasicStatesSet">
-               <param name="t"/>
-               
-               {
-                       <for-each select="$t/c:basicStateDescendantsOfNearestParallelDescendentOfLCA/c:basicStateDescendant">
-                               <value-of select="text()"/> : true
-                               <if test="position() != last()">,</if>
-                       </for-each>
-               }
-       </template>
-
+	<template name="genStateRefIdentifier">
+		<param name="s"/>
+		<value-of select="$s/@id"/>
+	</template>
 
 </stylesheet>



Mime
View raw message