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/19 16:59:06 UTC

svn commit: r965516 - in /commons/sandbox/gsoc/2010/scxml-js/trunk: ./ demo/drag-and-drop/ src/javascript/scxml/cgf/ src/xslt/backends/js/ test/event_system_properties/ test/event_system_properties/scripts/ test/kitchen_sink/ test/kitchen_sink/scripts/...

Author: jbeard
Date: Mon Jul 19 14:59:06 2010
New Revision: 965516

URL: http://svn.apache.org/viewvc?rev=965516&view=rev
Log:
Merged SCXML-141-148 back into trunk.

Added:
    commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drag-and-drop/
      - copied from r965514, commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/demo/drag-and-drop/
    commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drag-and-drop/drag-and-drop.xhtml
      - copied unchanged from r965514, commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/demo/drag-and-drop/drag-and-drop.xhtml
    commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drag-and-drop/drag-and-drop2.xhtml
      - copied unchanged from r965514, commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/demo/drag-and-drop/drag-and-drop2.xhtml
    commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drag-and-drop/drag-and-drop2.xml
      - copied unchanged from r965514, commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/demo/drag-and-drop/drag-and-drop2.xml
    commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drag-and-drop/drag-and-drop3.js
      - copied unchanged from r965514, commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/demo/drag-and-drop/drag-and-drop3.js
    commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drag-and-drop/drag-and-drop3.svg
      - copied unchanged from r965514, commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/demo/drag-and-drop/drag-and-drop3.svg
    commons/sandbox/gsoc/2010/scxml-js/trunk/test/event_system_properties/
      - copied from r965514, commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/test/event_system_properties/
    commons/sandbox/gsoc/2010/scxml-js/trunk/test/event_system_properties/TestEventSystemProperties.xml
      - copied unchanged from r965514, commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/test/event_system_properties/TestEventSystemProperties.xml
    commons/sandbox/gsoc/2010/scxml-js/trunk/test/event_system_properties/scripts/
      - copied from r965514, commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/test/event_system_properties/scripts/
    commons/sandbox/gsoc/2010/scxml-js/trunk/test/event_system_properties/scripts/unitTest.js
      - copied unchanged from r965514, commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/test/event_system_properties/scripts/unitTest.js
    commons/sandbox/gsoc/2010/scxml-js/trunk/test/kitchen_sink/KitchenSink_dataModule.xml
      - copied unchanged from r965514, commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/test/kitchen_sink/KitchenSink_dataModule.xml
    commons/sandbox/gsoc/2010/scxml-js/trunk/test/kitchen_sink/scripts/unitTest_dataModel.js
      - copied unchanged from r965514, commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/test/kitchen_sink/scripts/unitTest_dataModel.js
    commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/xslt_js/
      - copied from r965514, commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/test/xslt/xslt_js/
    commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/xslt_js/test.html
      - copied unchanged from r965514, commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/test/xslt/xslt_js/test.html
    commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/xslt_js/test.xml
      - copied unchanged from r965514, commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/test/xslt/xslt_js/test.xml
    commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/xslt_js/test.xsl
      - copied unchanged from r965514, commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/test/xslt/xslt_js/test.xsl
Modified:
    commons/sandbox/gsoc/2010/scxml-js/trunk/   (props changed)
    commons/sandbox/gsoc/2010/scxml-js/trunk/build.js
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/SCXMLCompiler.js
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/Transformer.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

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Mon Jul 19 14:59:06 2010
@@ -2,3 +2,4 @@
 target
 build_dbg.sh
 build
+Session.vim

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jul 19 14:59:06 2010
@@ -1,4 +1,5 @@
 /commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-138-139:958222
 /commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-140:958231-958311
+/commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148:958433-965514
 /commons/sandbox/gsoc/2010/scxml-js/branches/browser-tests.1.ie:954350-956951
 /commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137:957703-958221

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=965516&r1=965515&r2=965516&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/build.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/build.js Mon Jul 19 14:59:06 2010
@@ -73,11 +73,13 @@ 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 :"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",
+				EventSystemProperties :"test/event_system_properties/TestEventSystemProperties.xml",
 			}
 
 			//FIXME: this violates Don't Repeat Yourself; these paths are written here and in the module
@@ -104,10 +106,12 @@ require.def("build",
 
 
 			var unitTestScripts = [
+					"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",
+					"test/event_system_properties/scripts/unitTest"
 			]
 
 			//gets populated at run-time

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/SCXMLCompiler.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/SCXMLCompiler.js?rev=965516&r1=965515&r2=965516&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/SCXMLCompiler.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/SCXMLCompiler.js Mon Jul 19 14:59:06 2010
@@ -68,8 +68,8 @@ require.def("src/javascript/scxml/cgf/SC
 
 				var toReturn = options.inFiles.map(function(xmlFile){
 
-					var ir = Transformer(xmlFile,backend.transformations,null,"xml");
-					var transformedJs = Transformer(ir,backend.code,options,"text");
+					var ir = Transformer(xmlFile,backend.transformations,null,"xml",options.debug);
+					var transformedJs = Transformer(ir,backend.code,options,"text",options.debug);
 
 					//optionally beautify it
 					if(options.beautify){

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/Transformer.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/Transformer.js?rev=965516&r1=965515&r2=965516&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/Transformer.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/Transformer.js Mon Jul 19 14:59:06 2010
@@ -113,7 +113,7 @@ function(xmlUtil){
 					return toReturn;	//string or node
 				}			:
 				//everything else
-				function(sourceDocument,transformList,params,output){
+				function(sourceDocument,transformList,params,output,debug){
 					transformList = transformList && !transformList.length	? 
 								[transformList]			:
 								transformList;
@@ -147,14 +147,17 @@ function(xmlUtil){
 					//set parameters
 					processors.forEach(function(p){
 						for(paramName in params){
-							 p.setParameter(null,paramName,params[paramName]);
+							 var paramValue = params[paramName];
+							 if (typeof paramValue == "string") p.setParameter(null,paramName,paramValue);
 						}
 					});
 
 					var docToTransform  = sourceDocument;
 					processors.forEach(function(p){
+						if(debug) console.dirxml(docToTransform); 
 						docToTransform = p.transformToDocument(docToTransform);
 					});
+					if(debug) console.dirxml(docToTransform); 
 		
 
 					var toReturn;

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=965516&r1=965515&r2=965516&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 Mon Jul 19 14:59:06 2010
@@ -36,7 +36,7 @@
 	<variable name="genNonBasicTriggerDispatcherExitBlockIteratorExpression"
 		select="'currentConfiguration.map(function(state){return STATE_INT_ID_TO_OBJECT_MAP[state]})'"/>
 
-
+	<variable name="eventToNameMap" select="'TRIGGER_ID_TO_NAME_MAP[e]'"/>
 
 	<template name="genContextHooks">
 		//enumeration of states int id's
@@ -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"/>
 
@@ -215,6 +203,12 @@
 		<value-of select="$s/@id"/>
 	</template>
 
+	<template name="genExternalTriggerDispatcherRunToCompletionEventValue">
+		<param name="eventName"/>
+
+		<value-of select="$eventName"/>
+	</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=965516&r1=965515&r2=965516&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 Mon Jul 19 14:59:06 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,25 @@
 			<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
 
-				//abstract state
+				//system variable declarations
+				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"/>
 
+				//abstract state
 				<call-template name="genAbstractState">
 					<with-param name="events" select="$eventsEnum"/>
 				</call-template>
@@ -130,6 +142,27 @@
 			}
 
 	</template>
+
+	<template match="s:datamodel">
+		var <for-each select="s:data">
+			<value-of select="@id"/> 
+			<choose>
+				<when test="@expr">
+					= <value-of select="@expr"/>
+				</when>
+				<when test="@src">
+					= xhrGET(<value-of select="@src"/>)
+				</when>
+				<!-- if this inline content is JSON, we're good,  
+					otherwise, we need to parse the xml DOM at runtime 	
+					(using the DOMParser object) -->
+				<when test="*">
+					= <value-of select="*"/>
+				</when>
+			</choose>
+			<if test="position() != last()">, </if>
+		</for-each>;
+	</template>
 	
 	<template name="genAbstractState">
 		<param name="events"/>
@@ -351,23 +384,25 @@
 
 	<!-- data module -->
 
-	<template match="s:datamodel">
-	<!--TODO-->
-	</template>
-
-	<template match="s:data">
-	<!--TODO-->
-	</template>
-
 	<template match="s:assign">
-	<!--TODO-->
-	</template>
+		<variable name="rhs">
+			<choose>
+				<when test="@expr">
+					<value-of select="@expr"/>
+				</when>
+				<!-- if this inline content is JSON, we're good,  
+					otherwise, we need to parse the xml DOM at runtime 	
+					(using the DOMParser object) -->
+				<when test="*">
+					<value-of select="*"/>
+				</when>
+			</choose>
+		</variable>
 
-	<template match="s:validate">
-	<!--TODO-->
+		<value-of select="@location"/> = <value-of select="$rhs"/>;
 	</template>
 
-	<template match="s:param">
+	<template match="s:validate">
 	<!--TODO-->
 	</template>
 
@@ -380,6 +415,21 @@
 		}
 	</template>
 
+	<template name="genExternalTriggerDispatcher">
+		<param name="event"/>
+
+		this.<value-of select="$event/c:name"/> = function(data){
+			if(isInStableState){
+				runToCompletion(
+					<call-template name="genExternalTriggerDispatcherRunToCompletionEventValue">
+						<with-param name="eventName" select="$event/c:name"/>
+					</call-template>
+				,data);
+			}else{
+				return undefined;
+			}
+		}
+	</template>
 
 	<template name="genBoilerplateDispatchCode">
 		//static private member variables
@@ -398,7 +448,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() {
@@ -409,11 +459,11 @@
 			}
 		}
 
-		function runToCompletion(e){
+		function runToCompletion(e,data){
 			isInStableState = false;
 
 			if(e){
-				innerEventQueue.push(e);
+				innerEventQueue.push(e,data);
 			}
 
 			do{
@@ -428,7 +478,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
@@ -440,10 +490,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=<value-of select="$eventToNameMap"/>;
+						_event.data=data;
+					}
 					<value-of select="$dispatchInvocation"/>
+				}
 			});
 
 			//reset the isPreempted flag
@@ -460,8 +517,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
@@ -538,7 +595,7 @@
 					
 				
 			<!--gen executable content for t-->
-			<apply-templates select="$t/*[self::s:if or self::s:raise or self::s:log or self::s:script or self::s:send or self::s:cancel or self::s:invoke or self::s:finalize or self::s:datamodel or self::s:data or self::s:assign or self::s:validate or self::s:param]"/>
+			<apply-templates select="$t/*[self::s:if or self::s:raise or self::s:log or self::s:script or self::s:send or self::s:cancel or self::s:invoke or self::s:finalize or self::s:assign or self::s:validate ]"/>
 
 
 
@@ -684,7 +741,7 @@
 		</choose>
 
 		//transition action
-		<apply-templates select="$t/*[self::s:if or self::s:raise or self::s:log or self::s:script or self::s:send or self::s:cancel or self::s:invoke or self::s:finalize or self::s:datamodel or self::s:data or self::s:assign or self::s:validate or self::s:param]"/>
+		<apply-templates select="$t/*[self::s:if or self::s:raise or self::s:log or self::s:script or self::s:send or self::s:cancel or self::s:invoke or self::s:finalize or self::s:assign or self::s:validate ]"/>
 
 		//enter states
 		<for-each select="$t/c:targets/c:target/c:enterpath/c:state"> 
@@ -779,11 +836,11 @@
 
 	<template name="genContextHooks"/>
 	<template name="genStateHooks"/>
-	<template name="genExternalTriggerDispatcher"/>
 	<template name="genParallelSubstateConfigurationSetString"/>
 	<template name="genNonParallelSubstateConfigurationSetString"/>
 	<template name="genInitialization"/>
 	<template name="genTriggerDispatcherContext"/>
+	<template name="genExternalTriggerDispatcherRunToCompletionEventValue"/>
 
 
 </stylesheet>

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=965516&r1=965515&r2=965516&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 Mon Jul 19 14:59:06 2010
@@ -32,6 +32,8 @@
 	<variable name="genHistoryTriggerDispatcherInnerForEachStateReference" select="'state'"/>
 	<variable name="genNonBasicTriggerDispatcherExitBlockIteratorExpression" select="'currentConfiguration'"/>
 
+	<variable name="eventToNameMap" select="'e'"/>
+
 	<template name="genStateHooks">
 		<param name="state"/>
 
@@ -63,18 +65,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"/>
@@ -150,6 +140,12 @@
 		<text>this</text>
 	</template> 
 
+	<template name="genExternalTriggerDispatcherRunToCompletionEventValue">
+		<param name="eventName"/>
+
+		"<value-of select="$eventName"/>"
+	</template>
+
 	<template match="s:send">
 		<choose>
 			<when test="@delay">