commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbe...@apache.org
Subject svn commit: r954057 - in /commons/sandbox/gsoc/2010/scxml-js/trunk: src/scxml/cgf/SCXMLCompiler.js test/xslt/AbstractStatechartGenerator.xsl test/xslt/StatePatternStatechartGenerator.xsl
Date Sat, 12 Jun 2010 19:34:50 GMT
Author: jbeard
Date: Sat Jun 12 19:34:50 2010
New Revision: 954057

URL: http://svn.apache.org/viewvc?rev=954057&view=rev
Log:
Intermediate commit.

Modified:
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/SCXMLCompiler.js
    commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/AbstractStatechartGenerator.xsl
    commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/StatePatternStatechartGenerator.xsl

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/SCXMLCompiler.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/SCXMLCompiler.js?rev=954057&r1=954056&r2=954057&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/SCXMLCompiler.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/SCXMLCompiler.js Sat Jun 12 19:34:50
2010
@@ -140,7 +140,6 @@ require.def("src/scxml/cgf/SCXMLCompiler
 				verbose
 		*/
 		function compile(options){
-
 			if(!options.inFiles) return false;
 
 			var toReturn = options.inFiles.map(function(xmlFile){
@@ -298,7 +297,6 @@ require.def("src/scxml/cgf/SCXMLCompiler
 					ifNode.msdl::executableContent = "";
 					var currentPartition = ifNode.msdl::executableContent;
 
-					debugger;
 					util.foreach(ifNodeChildren,function(node){
 						if(node.localName() == "elseif" || 
 							node.localName() == "else"){
@@ -316,7 +314,7 @@ require.def("src/scxml/cgf/SCXMLCompiler
 				});
 				*/
 
-				print(scxmlRoot);
+				return scxmlRoot;
 
 
 				/*

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/AbstractStatechartGenerator.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/AbstractStatechartGenerator.xsl?rev=954057&r1=954056&r2=954057&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/AbstractStatechartGenerator.xsl (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/AbstractStatechartGenerator.xsl Sat
Jun 12 19:34:50 2010
@@ -15,9 +15,13 @@
 	<param name="currentConfigurationExpression"/>
 	<param name="defaultEventLiteral"/>
 
-	<!--//*[(self::state or self::parallel or self::final or self::initial or self::scxml
or self::history) and not(.//*[(self::state or self::parallel or self::final or self::initial
or self::scxml or self::history)])]-->
-	<!--TODO: hook up namespaces -->
-	<variable name="allStates" select="//*[(self::s:state or self::s:parallel or self::s:final
or self::s:initial or self::s:scxml or self::s:history)]"/>
+	<param name="genHistoryTriggerDispatcherCurrentConfigurationAssignmentRHS"/>
+	<param name="genHistoryTriggerDispatcherInnerForEachStateReference"/>
+	<param name="genNonBasicTriggerDispatcherExitBlockIteratorExpression"/>
+
+	<!-- main variables -->
+	<variable name="allStates" 
+		select="//*[(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="states" select="//s:state"/>
 	<variable name="parallels" select="//s:parallel"/>
 	<variable name="finals" select="//s:final"/>
@@ -26,8 +30,10 @@
 	<variable name="defaultTransitions" select="//s:transition[not(@event)]"/>
 	<variable name="nonDefaultTransitions" select="//s:transition[@event]"/>
 	
-	<variable name="basicStates" select="$allStates[not(.//*[(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="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="basicStates" 
+		select="$allStates[not(.//*[(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="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="parallelRegions" select="$parallels/s:state"/>
 
 
@@ -377,7 +383,7 @@
 
 			do{
 				//take any available default transitions
-				microstep(<value-of select="$defaultEventLiteral"/>});
+				microstep(<value-of select="$defaultEventLiteral"/>);
 
 				if(!hasTakenDefaultTransition){
 					

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/StatePatternStatechartGenerator.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/StatePatternStatechartGenerator.xsl?rev=954057&r1=954056&r2=954057&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/StatePatternStatechartGenerator.xsl
(original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/StatePatternStatechartGenerator.xsl
Sat Jun 12 19:34:50 2010
@@ -11,13 +11,118 @@
 	<param name="defaultEventLiteral" select="'$default'"/>
 	<param name="currentConfigurationExpression" select="'currentConfiguration.slice()'"/>
 
-	<template name="genContextHooks"/>
-	<template name="genStateHooks"/>
-	<template name="genExternalTriggerDispatcher"/>
-	<template name="genParallelSubstateConfigurationSetString"/>
-	<template name="genNonParallelSubstateConfigurationSetString"/>
-	<template name="genInitialization"/>
-	<template name="genTriggerDispatcherContext"/>
+	<param name="genHistoryTriggerDispatcherCurrentConfigurationAssignmentRHS" select="'newConfiguration'"/>
+	<param name="genHistoryTriggerDispatcherInnerForEachStateReference" select="'state'"/>
+	<param name="genNonBasicTriggerDispatcherExitBlockIteratorExpression" select="'currentConfiguration'"/>
+
+	<template name="genStateHooks">
+		<param name="state"/>
+		<for-each select="$state/s:transition">
+			<call-template name="genStateTriggerDispatcher">
+				<with-param name="state" select="$state"/>
+				<with-param name="transition" select="."/>
+			</call-template>
+		</for-each>
+	</template>
+
+	<template name="genExternalTriggerDispatcher">
+		<param name="t"/>
+
+		this.<value-of select="$t/@event"/> = function(){
+			if(isInStableState){
+				runToCompletion("<value-of select="$t/@event"/>");
+			}else{
+				return undefined;
+			}
+		}
+	</template>
+
+	<template name="genParallelSubstateConfigurationSetString">
+		currentConfiguration.splice(currentConfiguration.indexOf(this),1,
+			<for-each select="$t/c:targets/c:target/c:targetState">
+				<value-of select="."/>
+				<if test="not(position() = last())">,</if>
+			</for-each> 
+		); 
+	</template>
+
+	<template name="genNonParallelSubstateConfigurationSetString">
+		<param name="t"/>
+		<param name="s"/>
+
+		currentConfiguration = [
+			<for-each select="$t/c:targets/c:target/c:targetState">
+				<value-of select="."/>
+				<if test="not(position() = last())">,</if>
+			</for-each>
+		]; 
+	</template>
+
+	<template name="genInitialization">
+
+		<variable name="initialStateName">
+			<value-of select="/s:scxml/s:initial/s:transition/c:targets/c:target/c:targetState"/>
+		</variable>
+ 
+		this.initialize = function(){
+			currentConfiguration = [<value-of select="$initialStateName"/>];
+			runToCompletion();
+			mainLoop();
+		}
+
+	</template>
+
+	<template name="genTriggerDispatcherContext">
+		<params name="s"/>
+		<params name="t"/>
+
+		<variable name="eventName">
+			<choose>
+				<when test="$t/@event">
+					<value-of select="$t/@event"/>
+				</when>	
+				<otherwise>
+					<value-of select="'$default'"/>
+				</otherwise>
+			</choose>
+		</variable>
+
+		this.<value-of select="$eventName"/> = function(){
+			<choose>
+				<when test="$s/@m:isHistory">
+					<call-template name="genHistoryTriggerDispatcher">
+						<with-param name="s" select="$s"/>
+						<with-param name="t" select="$t"/>
+					</call-template>
+				</when>
+				<otherwise>
+					<call-template name="genTriggerDispatcherContents">
+						<with-param name="s" select="$s"/>
+						<with-param name="t" select="$t"/>
+					</call-template>
+				</otherwise>
+			</choose>
+		}
+	</template>
+
+	<template name="genHistoryTriggerDispatcherHistoryStateReference">
+		<param name="s"/>
+
+		<text>this</text>
+	</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>
 



Mime
View raw message