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/06/28 17:32:51 UTC

svn commit: r958605 - in /commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148: ./ src/xslt/backends/js/

Author: jbeard
Date: Mon Jun 28 15:32:51 2010
New Revision: 958605

URL: http://svn.apache.org/viewvc?rev=958605&view=rev
Log:
Added code to support the setting of _event.name and _event.data system properties. Next step will be to write a test and a demo for this.

Modified:
    commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/build.js
    commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/src/xslt/backends/js/AbstractEnumeratedStatechartGenerator.xsl
    commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/src/xslt/backends/js/AbstractStatechartGenerator.xsl
    commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/src/xslt/backends/js/StatePatternStatechartGenerator.xsl

Modified: commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/build.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/build.js?rev=958605&r1=958604&r2=958605&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/build.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/build.js Mon Jun 28 15:32:51 2010
@@ -73,12 +73,12 @@ require.def("build",
 
 			//paths to all of the SCXML files we want to compile
 			var scxmlTests = {
-				KitchenSink_dataModule :"test/kitchen_sink/KitchenSink_dataModule.xml"/*,
+				KitchenSink_dataModule :"test/kitchen_sink/KitchenSink_dataModule.xml",
 				KitchenSink :"test/kitchen_sink/KitchenSink.xml",
 				KitchenSink_performance :"test/kitchen_sink/KitchenSink_performance.xml",
 				KitchenSink_executableContent :"test/kitchen_sink/KitchenSink_executableContent.xml",
 				ConditionalTransition :"test/conditional_transition/TestConditionalTransition.xml",
-				InPredicate :"test/in_predicate/TestInPredicate.xml",*/
+				InPredicate :"test/in_predicate/TestInPredicate.xml",
 			}
 
 			//FIXME: this violates Don't Repeat Yourself; these paths are written here and in the module
@@ -105,11 +105,11 @@ require.def("build",
 
 
 			var unitTestScripts = [
-					"test/kitchen_sink/scripts/unitTest_dataModel"/*,
+					"test/kitchen_sink/scripts/unitTest_dataModel",
 					"test/kitchen_sink/scripts/unitTest",
 					"test/kitchen_sink/scripts/unitTest_executableContent",
 					"test/conditional_transition/scripts/unitTest",
-					"test/in_predicate/scripts/unitTest"*/
+					"test/in_predicate/scripts/unitTest"
 			]
 
 			//gets populated at run-time

Modified: commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/src/xslt/backends/js/AbstractEnumeratedStatechartGenerator.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/src/xslt/backends/js/AbstractEnumeratedStatechartGenerator.xsl?rev=958605&r1=958604&r2=958605&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/src/xslt/backends/js/AbstractEnumeratedStatechartGenerator.xsl (original)
+++ commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/src/xslt/backends/js/AbstractEnumeratedStatechartGenerator.xsl Mon Jun 28 15:32:51 2010
@@ -141,18 +141,6 @@
 		}
 	</template>
 
-	<template name="genExternalTriggerDispatcher">
-		<param name="event"/>
-
-		this.<value-of select="$event/c:name"/> = function(){
-			if(isInStableState){
-				runToCompletion(<value-of select="$event/c:name"/>);
-			}else{
-				return undefined;
-			}
-		}
-	</template>
-
 	<template name="genNonParallelSubstateConfigurationSetString">
 		<param name="t"/>
 

Modified: commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/src/xslt/backends/js/AbstractStatechartGenerator.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/src/xslt/backends/js/AbstractStatechartGenerator.xsl?rev=958605&r1=958604&r2=958605&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/src/xslt/backends/js/AbstractStatechartGenerator.xsl (original)
+++ commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/src/xslt/backends/js/AbstractStatechartGenerator.xsl Mon Jun 28 15:32:51 2010
@@ -26,7 +26,6 @@
 	<param name="noMap" select="false()"/>
 	<param name="noForEach" select="false()"/>
 	<param name="noSome" select="false()"/>
-	<param name="name"/>
 
 	<!-- these variables get overridden by subclasses -->
 	<variable name="dispatchInvocation"/>
@@ -82,12 +81,20 @@
 			<call-template name="genNoSomeArrayPrototypeExtension"/>
 		</if>
 
-		function <value-of select="$name"/>StatechartExecutionContext(){
+		function <value-of select="@name"/>StatechartExecutionContext(){
 
 				var self = this;	//used in the rare occasions we call public functions from inside this class
 
 				//system variable declarations
-				var _event, _name, _sessionid, _x;
+				var _event = { name : undefined, data : undefined }, 
+					_name = "<value-of select="@name"/>", 
+					_sessionid; 
+
+				var _x = {
+					_event : _event,
+					_name : _name,
+					_sessionid : _sessionid 
+				};
 
 				//variable declarations relating to data model
 				<apply-templates select=".//s:datamodel"/>
@@ -408,6 +415,17 @@
 		}
 	</template>
 
+	<template name="genExternalTriggerDispatcher">
+		<param name="event"/>
+
+		this.<value-of select="$event/c:name"/> = function(data){
+			if(isInStableState){
+				runToCompletion("<value-of select="$event/c:name"/>",data);
+			}else{
+				return undefined;
+			}
+		}
+	</template>
 
 	<template name="genBoilerplateDispatchCode">
 		//static private member variables
@@ -426,7 +444,7 @@
 			if(!destroyed){
 				//take an event from the current outer event queue
 				if (outerEventQueue.length &amp;&amp; isInStableState) {
-					runToCompletion(outerEventQueue.shift());
+					runToCompletion(outerEventQueue.shift(),outerEventQueue.shift());
 				}
 				//call back
 				mainLoopCallback = window.setTimeout(function() {
@@ -437,11 +455,11 @@
 			}
 		}
 
-		function runToCompletion(e){
+		function runToCompletion(e,data){
 			isInStableState = false;
 
 			if(e){
-				innerEventQueue.push(e);
+				innerEventQueue.push(e,data);
 			}
 
 			do{
@@ -456,7 +474,7 @@
 						break;
 					}else{
 						//microstep, then dequeue next event sending in event
-						microstep(innerEventQueue.shift());
+						microstep(innerEventQueue.shift(),innerEventQueue.shift());
 					}
 				}else{
 					//he has taken a default transition, so reset the global variable to false and loop again
@@ -468,10 +486,17 @@
 			isInStableState = true;
 		}
 
-		function microstep(e){
+		function microstep(e,data){
 			currentConfiguration.forEach(function(state){
-				if(!isPreempted) 
+				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=e;
+						_event.data=data;
+					}
 					<value-of select="$dispatchInvocation"/>
+				}
 			});
 
 			//reset the isPreempted flag
@@ -488,8 +513,8 @@
 
 
 		//this is for async communication
-		this.GEN = function(e){
-			outerEventQueue.push(e);
+		this.GEN = function(e,data){
+			outerEventQueue.push(e,data);
 		}
 
 		//this may or may not be something we want to expose, but for right now, we at least need it for testing
@@ -807,7 +832,6 @@
 
 	<template name="genContextHooks"/>
 	<template name="genStateHooks"/>
-	<template name="genExternalTriggerDispatcher"/>
 	<template name="genParallelSubstateConfigurationSetString"/>
 	<template name="genNonParallelSubstateConfigurationSetString"/>
 	<template name="genInitialization"/>

Modified: commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/src/xslt/backends/js/StatePatternStatechartGenerator.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/src/xslt/backends/js/StatePatternStatechartGenerator.xsl?rev=958605&r1=958604&r2=958605&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/src/xslt/backends/js/StatePatternStatechartGenerator.xsl (original)
+++ commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/src/xslt/backends/js/StatePatternStatechartGenerator.xsl Mon Jun 28 15:32:51 2010
@@ -63,18 +63,6 @@
 		</if>
 	</template>
 
-	<template name="genExternalTriggerDispatcher">
-		<param name="event"/>
-
-		this.<value-of select="$event/c:name"/> = function(){
-			if(isInStableState){
-				runToCompletion("<value-of select="$event/c:name"/>");
-			}else{
-				return undefined;
-			}
-		}
-	</template>
-
 	<template name="genParallelSubstateConfigurationSetString">
 		<param name="s"/>
 		<param name="t"/>