commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbe...@apache.org
Subject svn commit: r954346 - in /commons/sandbox/gsoc/2010/scxml-js/trunk: src/xslt/ir-compiler/flattenTransitions.xsl test/SCXMLCompiler.js test/testBrowserTransform.html
Date Mon, 14 Jun 2010 02:19:19 GMT
Author: jbeard
Date: Mon Jun 14 02:19:19 2010
New Revision: 954346

URL: http://svn.apache.org/viewvc?rev=954346&view=rev
Log:
Started working on the browser front-end.

Added:
    commons/sandbox/gsoc/2010/scxml-js/trunk/test/SCXMLCompiler.js   (with props)
Modified:
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/flattenTransitions.xsl
    commons/sandbox/gsoc/2010/scxml-js/trunk/test/testBrowserTransform.html

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/flattenTransitions.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/flattenTransitions.xsl?rev=954346&r1=954345&r2=954346&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/flattenTransitions.xsl (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/flattenTransitions.xsl Mon
Jun 14 02:19:19 2010
@@ -94,7 +94,7 @@ collision. 
 		<!-- if no param passed in, then initialized to empty node-list -->
 		<xsl:param name="parentTransitions" select="/.."/>	
 
-		<!-- TODO: merge parent transitions with his own transitions -->
+		<!-- merge parent transitions with his own transitions -->
 
 		<xsl:variable name="currentTransitions" select="s:transition"/>
 

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/test/SCXMLCompiler.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/test/SCXMLCompiler.js?rev=954346&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/test/SCXMLCompiler.js (added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/test/SCXMLCompiler.js Mon Jun 14 02:19:19 2010
@@ -0,0 +1,127 @@
+require.def(
+	"test/SCXMLCompiler",
+	[
+		"xml!test/kitchen_sink/KitchenSink.xml",
+		"xml!src/xslt/ir-compiler/enumerateEvents.xsl",
+		"xml!src/xslt/ir-compiler/normalizeInitialStates.xsl",
+		"xml!src/xslt/ir-compiler/generateUniqueStateIds.xsl",
+		"xml!src/xslt/ir-compiler/generateUniqueInitialStateIds.xsl",
+		"xml!src/xslt/ir-compiler/splitTransitionTargets.xsl",
+		"xml!src/xslt/ir-compiler/changeTransitionsPointingToCompoundStatesToPointToInitialStates.xsl",
+		"xml!src/xslt/ir-compiler/computeLCA.xsl",
+		"xml!src/xslt/ir-compiler/transformIf.xsl",
+		"xml!src/xslt/ir-compiler/appendStateInformation.xsl",
+		"xml!src/xslt/ir-compiler/appendBasicStateInformation.xsl",
+		"xml!src/xslt/ir-compiler/flattenTransitions.xsl",
+		"xml!src/xslt/ir-compiler/nameTransitions.xsl",
+		"xml!src/xslt/ir-compiler/numberStatesAndTransitions.xsl",
+		"xml!src/xslt/ir-compiler/appendTransitionInformation.xsl",
+		"xml!src/xslt/backends/js/StatePatternStatechartGenerator.xsl",
+		"/lib/js/beautify.js"],
+	function(
+		KitchenSink,
+		enumerateEvents,
+		normalizeInitialStates,
+		generateUniqueStateIds,
+		generateUniqueInitialStateIds,
+		splitTransitionTargets,
+		changeTransitionsPointingToCompoundStatesToPointToInitialStates,
+		computeLCA,
+		transformIf,
+		appendStateInformation,
+		appendBasicStateInformation,
+		flattenTransitions,
+		nameTransitions,
+		numberStatesAndTransitions,
+		appendTransitionInformation,
+		StatePatternStatechartGenerator
+	){
+
+		var sourceDocument = KitchenSink;
+		var transforms = [ 	enumerateEvents,
+					normalizeInitialStates,
+					generateUniqueStateIds,
+					generateUniqueInitialStateIds,
+					splitTransitionTargets,
+					changeTransitionsPointingToCompoundStatesToPointToInitialStates,
+					computeLCA,
+					transformIf,
+					appendStateInformation,
+					appendBasicStateInformation,
+					/*
+					flattenTransitions,
+					nameTransitions,
+					numberStatesAndTransitions,
+					*/
+					appendTransitionInformation
+				];
+					//StatePatternStatechartGenerator
+		//TODO: generate code
+
+		function getProcessorFromStylesheetDocument(d){
+			var processor = new XSLTProcessor();  
+			processor.importStylesheet(d); 
+			return processor;
+		}
+
+		function xmlToString(d){
+			var s = new XMLSerializer();  
+			var str = s.serializeToString(d);  
+			return str;
+		}
+
+		function getResultTextFromDoc(d){
+			resultText = d.documentElement.firstChild.textContent;
+			return resultText;
+		}
+
+		return {	
+			compile : function(options){
+				var processors = transforms.map(getProcessorFromStylesheetDocument); 
+
+				//transform to IR
+				var docToTransform = sourceDocument;
+				processors.forEach(function(p){
+					docToTransform = p.transformToDocument(docToTransform);
+				});
+
+				//print IR
+				//console.log(xmlToString(docToTransform));  
+
+				//transform to js
+				var statePatternStatechartGeneratorProcessor =	
+					 getProcessorFromStylesheetDocument(StatePatternStatechartGenerator);
+	
+				//set parameters
+				for(optName in options){
+					 statePatternStatechartGeneratorProcessor.setParameter(null,optName,options[optName]);
+				}
+				
+
+				docToTransform = statePatternStatechartGeneratorProcessor.transformToDocument(docToTransform);
+			
+				//console.log(xmlToString(docToTransform));
+				//console.log(getResultTextFromDoc(docToTransform));
+
+				var transformedJs = getResultTextFromDoc(docToTransform);
+
+				//optionally beautify it
+				if(options.beautify){
+					transformedJs = js_beautify(transformedJs);
+				}
+
+				return transformedJs;
+
+				/*
+				
+				//eval
+				eval(resultText);
+				window.StatechartExecutionContext = StatechartExecutionContext;
+				dojo.require("doh.runner"); 
+				doh.run();
+				*/
+			}
+		}
+
+	}
+);

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/test/SCXMLCompiler.js
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/test/testBrowserTransform.html
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/test/testBrowserTransform.html?rev=954346&r1=954345&r2=954346&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/test/testBrowserTransform.html (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/test/testBrowserTransform.html Mon Jun 14 02:19:19
2010
@@ -1,5 +1,7 @@
 <html>
 <head>
+	<script src="../lib/js/requirejs/require.js" type="text/javascript">true;</script>
+	<script src="../lib/js/requirejs/require/xml.js" type="text/javascript">true;</script>
 	<script djConfig="isDebug:true" src="../lib/test-js/dojo-release-1.4.2-src/dojo/dojo.js"
type="text/javascript">true;</script>
 	<script src="testHelpers.js" type="text/javascript">true;</script>
 	<script src="kitchen_sink/scripts/unitTest_executableContent.js" type="text/javascript">true;</script>
@@ -18,24 +20,28 @@
 		//load xml
 		var resultText;
 
-		doXHR( "http://localhost:8081/test/xslt/StatePatternStatechartGenerator.xsl", function(statePatternStatechartGeneratorXSL){
-			doXHR( "http://localhost:8081/test/KitchenSink_executableContent_IR.xml", function(kitchenSinkXML){
-				//transform to js
-				var processor = new XSLTProcessor();  
-				processor.importStylesheet(statePatternStatechartGeneratorXSL); 
+		require(
+			{
+				"baseUrl":"/"
+			},
+			[ "test/SCXMLCompiler"],
+			function(compiler){
+				var compileLog = true;
+				var backend = "state";
 
-				var newDocument = processor.transformToDocument(kitchenSinkXML);  
+				var transformedJs = compiler.compile({
+					//inFiles:[pathToTest],
+					backend:backend,
+					beautify:true,
+					verbose:false,
+					log:compileLog,
+					ie:false
+				});
+
+				console.log(transformedJs);
+			}
+		);
 
-				resultText = newDocument.documentElement.firstChild.textContent;
-				console.log(resultText);
-				
-				//eval
-				eval(resultText);
-				window.StatechartExecutionContext = StatechartExecutionContext;
-				dojo.require("doh.runner"); 
-				doh.run();
-			});
-		});
 	</script>
 </head>
 <body>



Mime
View raw message