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/12 21:41:26 UTC

svn commit: r954111 - in /commons/sandbox/gsoc/2010/scxml-js/trunk: ./ src/scxml/cgf/ test/xslt/

Author: jbeard
Date: Sat Jun 12 19:41:25 2010
New Revision: 954111

URL: http://svn.apache.org/viewvc?rev=954111&view=rev
Log:
Fixed some bugs with the code generation for State Table pattern. Still broken.

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

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=954111&r1=954110&r2=954111&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/build.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/build.js Sat Jun 12 19:41:25 2010
@@ -55,8 +55,8 @@ require.def("build",
 			//we keep backward links of these
 			var backends = {
 				//"switch" : true,
-				//"table" : true,
-				"state" : true
+				"table" : true,
+				//"state" : true
 			}
 
 			var browsers = {

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=954111&r1=954110&r2=954111&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:41:25 2010
@@ -26,11 +26,10 @@ code.  
 */ 
 
 require.def("src/scxml/cgf/SCXMLCompiler",
-	["src/scxml/cgf/xsltIRFilters",
-		"src/scxml/cgf/util/file",
+	[ "src/scxml/cgf/util/file",
 		"lib/js/beautify.js"],
 	
-	function(xsltIRFilters,fileUtil){
+	function(fileUtil){
 
 		//import packages
 		importPackage(javax.xml.transform.dom);
@@ -59,23 +58,52 @@ require.def("src/scxml/cgf/SCXMLCompiler
 		function compile(options){
 			if(!options.inFiles) return false;
 
-			//do transforms
-			var tFactory = TransformerFactory.newInstance();
 
-			var filterList = xsltIRFilters.map(function(xsltDoc){
-				return tFactory.newTransformerHandler(new StreamSource(new StringReader(xsltDoc)));
-			});
+			var baseIRFilters = ["test/xslt/enumerateEvents",
+						"test/xslt/normalizeInitialStates",
+						"test/xslt/generateUniqueStateIds",
+						"test/xslt/splitTransitionTargets",
+						"test/xslt/changeTransitionsPointingToCompoundStatesToPointToInitialStates",
+						"test/xslt/computeLCA",
+						"test/xslt/transformIf",
+						"test/xslt/appendStateInformation",
+						"test/xslt/appendBasicStateInformation",
+						"test/xslt/appendTransitionInformation"];
+
+			var enumeratedIRFilters = baseIRFilters.concat([ "test/xslt/nameTransitions",
+										"test/xslt/flattenTransitions",
+										"test/xslt/numberStatesAndTransitions" ]);
 
+			
+			var irFiltersXsl, codeGeneratorXsl;
 
-			//we do this one separately from the others, because he has external dependencies, 
-			//and thus needs to be given the path to the file, rather than just the file's string representation
-			//FIXME: I think require.nameToUrl is not supposed to be a public API, even though it should be...
-			var statePatternStatechartGeneratorXslPath = require.nameToUrl("test/xslt/StatePatternStatechartGenerator",".xsl","_");
+			switch(options.backend){
+				case "switch":
+					irFiltersXsl = enumeratedIRFilters; 
+					codeGeneratorXsl = "test/xslt/SwitchyardStatechartGenerator";
+					break;
+				case "table":
+					irFiltersXsl = enumeratedIRFilters; 
+					codeGeneratorXsl = "test/xslt/StateTableStatechartGenerator";
+					break;
+				case "state":
+					irFiltersXsl = baseIRFilters; 
+					codeGeneratorXsl = "test/xslt/StatePatternStatechartGenerator";
+					break;
+			}
+			
+			var allFilters = irFiltersXsl.concat(codeGeneratorXsl); 
+
+			//do transforms
+			var tFactory = TransformerFactory.newInstance();
 
-			var generatorFilter = tFactory.newTransformerHandler(new StreamSource(statePatternStatechartGeneratorXslPath));
+			//FIXME: I think require.nameToUrl is not supposed to be a public API, even though it should be...
+			var filterList = allFilters.map(function(modulePathToXsl){
+				return tFactory.newTransformerHandler(
+					new StreamSource(
+						require.nameToUrl(modulePathToXsl,".xsl","_")));
+			});
 
-			filterList = filterList.concat(generatorFilter);
-		
 			var reader = XMLReaderFactory.createXMLReader();
 
 			for(var i = 1; i < filterList.length; i++){

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/AbstractEnumeratedStatechartGenerator.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/AbstractEnumeratedStatechartGenerator.xsl?rev=954111&r1=954110&r2=954111&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/AbstractEnumeratedStatechartGenerator.xsl (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/AbstractEnumeratedStatechartGenerator.xsl Sat Jun 12 19:41:25 2010
@@ -26,10 +26,10 @@
 		</for-each>
 
 		//map from states int id's to objects
-		var STATE_INT_ID_TO_OBJECT_MAP = 
+		var STATE_INT_ID_TO_OBJECT_MAP = [
 		<for-each select="$basicStates">
 			<value-of select="@id"/> <if test="not(position() = last())"> , </if>
-		</for-each>;
+		</for-each> ];
 
 		//tag each state object with an int id to map from object to id
 		//only needed for history
@@ -62,7 +62,7 @@
 	<template name="genTriggerExternalObject"> 
 			this.TRIGGERS = { 
 				<for-each select="$eventsEnum">
-					<value-of select="c:name"/> : + <value-of select="c:name"/>
+					<value-of select="c:name"/> : <value-of select="c:name"/>
 					<if test="not(position() = last())"> , </if>
 				</for-each>
 			};
@@ -103,9 +103,9 @@
 	<template name="genExternalTriggerDispatcher">
 		<param name="event"/>
 
-		this.<value-of select="$event"/> = function(){
+		this.<value-of select="$event/c:name"/> = function(){
 			if(isInStableState){
-				runToCompletion(<value-of select="$event"/>);
+				runToCompletion(<value-of select="$event/c:name"/>);
 			}else{
 				return undefined;
 			}

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=954111&r1=954110&r2=954111&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:41:25 2010
@@ -363,7 +363,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=954111&r1=954110&r2=954111&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:41:25 2010
@@ -8,7 +8,7 @@
 
 	<!-- these params get overridden by subclasses -->
 	<param name="dispatchInvocation" select="'state[e]();'"/>
-	<param name="defaultEventLiteral" select="'$default'"/>
+	<param name="defaultEventLiteral" select="'&quot;$default&quot;'"/>
 	<param name="currentConfigurationExpression" select="'currentConfiguration.slice()'"/>
 
 	<param name="genHistoryTriggerDispatcherCurrentConfigurationAssignmentRHS" select="'newConfiguration'"/>

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/enumerateEvents.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/enumerateEvents.xsl?rev=954111&r1=954110&r2=954111&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/enumerateEvents.xsl (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/enumerateEvents.xsl Sat Jun 12 19:41:25 2010
@@ -21,9 +21,20 @@
 		<xsl:variable name="uniqueEvents" select="//s:transition[generate-id(.)=generate-id(key('events',@event)[1])]/@event"/>
 
 		<xsl:copy>
-			<xsl:apply-templates match="@*|node()"/>
+			<xsl:apply-templates select="@*|node()"/>
 	
 			<c:eventsEnum>
+				<!-- start with default event -->
+				<!-- FIXME: this may be a bit implementation-specfic, 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>