commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbe...@apache.org
Subject svn commit: r1032237 - in /commons/sandbox/gsoc/2010/scxml-js/trunk: ./ src/python/ src/python/scxml/ src/python/scxml/cgf/ src/python/scxml/cgf/backends/ src/python/scxml/cgf/backends/js/ src/python/scxml/cgf/tests/
Date Sun, 07 Nov 2010 09:34:08 GMT
Author: jbeard
Date: Sun Nov  7 09:34:08 2010
New Revision: 1032237

URL: http://svn.apache.org/viewvc?rev=1032237&view=rev
Log:
Preliminary check-in of python front-end. Untested, although most seems syntactically correct.

Added:
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/__init__.py   (with props)
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/SCXMLCompiler.py   (with
props)
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/__init__.py   (with props)
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/__init__.py   (with
props)
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/AbstractEnumeatedStatechartGenerator.py
  (with props)
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/AbstractEnumeratedStatechartGenerator.py
  (with props)
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/AbstractStatechartGenerator.py
  (with props)
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/StatePatternStatechartGenerator.py
  (with props)
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/StateTableStatechartGenerator.py
  (with props)
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/SwitchyardGenerator.py
  (with props)
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/__init__.py
  (with props)
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/tests/
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/tests/__init__.py   (with
props)
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/tests/test.xml   (with props)
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/tests/testpkgresource.py
  (with props)
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/xslt   (with props)
Modified:
    commons/sandbox/gsoc/2010/scxml-js/trunk/.gitignore

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/.gitignore
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/.gitignore?rev=1032237&r1=1032236&r2=1032237&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/.gitignore (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/.gitignore Sun Nov  7 09:34:08 2010
@@ -20,3 +20,4 @@ demo/drawing-tool/lib/*
 test/rhino-jsc/*/*.class
 test/rhino-jsc/*/*-built.js
 doc/*.pdf
+*.pyc

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/__init__.py
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/__init__.py?rev=1032237&view=auto
==============================================================================
    (empty)

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/__init__.py
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/SCXMLCompiler.py
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/SCXMLCompiler.py?rev=1032237&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/SCXMLCompiler.py (added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/SCXMLCompiler.py Sun Nov
 7 09:34:08 2010
@@ -0,0 +1,43 @@
+import sys
+import pkg_resources
+from lxml import etree
+
+def compile(pathsToSCXML=[],backend="state",options={}):
+	#open it
+	sourceDocuments = map(lambda p : etree.parse(p), pathsToSCXML)
+
+	#do some transforms
+	if backend == "state":
+		from scxml.cgf.backends.js.StatePatternStatechartGenerator import config
+	elif backend == "table":
+		from scxml.cgf.backends.js.StateTableStatechartGenerator import config
+	elif backend == "switch":
+		from scxml.cgf.backends.js.SwitchyardGenerator import config
+	else:
+		print "Backend not recognized!"
+
+	results = []
+	
+	for doc in sourceDocuments:
+		ir = transformDocument(doc,config["transformations"])
+		transformedJs = transformDocument(sourceDocument,[config["code"]],options,"text")
+		results.push(transformedJs) 
+
+	return results
+
+def transformDocument(sourceDocument=None,transformList=[],params={},output="xml"):
+
+	templateStreams = map(lambda t : pkg_resources.resource_stream(__name__,t), transformList)
+	templateDocs = map(lambda t : etree.parse(t), templateStreams)
+	compiledTemplates = map(lambda t : etree.XSLT(t), transformList)
+
+	outputDocument = reduce(lambda docToTransform,transform: transform(docToTransform), compiledTemplates,
sourceDocument)
+
+	if output == "xml":
+		return outputDocument 	
+	else:
+		#assume "text"
+		return outputDocument.root.getText() 
+
+if __name__ == "__main__":
+	pass #TODO: parse command-line args

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/SCXMLCompiler.py
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/__init__.py
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/__init__.py?rev=1032237&view=auto
==============================================================================
    (empty)

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/__init__.py
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/__init__.py
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/__init__.py?rev=1032237&view=auto
==============================================================================
    (empty)

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/__init__.py
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/AbstractEnumeatedStatechartGenerator.py
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/AbstractEnumeatedStatechartGenerator.py?rev=1032237&view=auto
==============================================================================
    (empty)

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/AbstractEnumeatedStatechartGenerator.py
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/AbstractEnumeratedStatechartGenerator.py
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/AbstractEnumeratedStatechartGenerator.py?rev=1032237&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/AbstractEnumeratedStatechartGenerator.py
(added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/AbstractEnumeratedStatechartGenerator.py
Sun Nov  7 09:34:08 2010
@@ -0,0 +1,16 @@
+from scxml.cgf.backends.js.AbstractStatechartGenerator import config as AbstractStatechartGeneratorConfig

+
+
+config =  {
+	"transformations": AbstractStatechartGeneratorConfig["transformations"] +
+				["xslt/ir-compiler/flattenTransitions.xsl",
+					"xslt/ir-compiler/appendTransitionInformation.xsl",
+					"xslt/ir-compiler/nameTransitions.xsl",
+					"xslt/ir-compiler/copyEnumeratedEventTransitions.xsl",
+					"xslt/ir-compiler/enumerateEvents.xsl",
+					"xslt/ir-compiler/addEventRegularExpressions.xsl",
+					"xslt/ir-compiler/expandStarEvent.xsl",
+					"xslt/ir-compiler/numberStatesAndTransitions.xsl", 
+					"xslt/layout/addTransitionTargetIds.xsl" ]
+}
+

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/AbstractEnumeratedStatechartGenerator.py
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/AbstractStatechartGenerator.py
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/AbstractStatechartGenerator.py?rev=1032237&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/AbstractStatechartGenerator.py
(added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/AbstractStatechartGenerator.py
Sun Nov  7 09:34:08 2010
@@ -0,0 +1,12 @@
+config = {
+	"transformations" : ["xslt/ir-compiler/normalizeInitialStates.xsl",
+				"xslt/ir-compiler/generateUniqueStateIds.xsl",
+				"xslt/ir-compiler/generateUniqueInitialStateIds.xsl",
+				"xslt/ir-compiler/splitTransitionTargets.xsl",
+				"xslt/ir-compiler/changeTransitionsPointingToCompoundStatesToPointToInitialStates.xsl",
+				"xslt/ir-compiler/computeLCA.xsl",
+				"xslt/ir-compiler/transformIf.xsl",
+				"xslt/ir-compiler/appendStateInformation.xsl",
+				"xslt/ir-compiler/appendBasicStateInformation.xsl"],
+	"code" : None
+}

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/AbstractStatechartGenerator.py
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/StatePatternStatechartGenerator.py
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/StatePatternStatechartGenerator.py?rev=1032237&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/StatePatternStatechartGenerator.py
(added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/StatePatternStatechartGenerator.py
Sun Nov  7 09:34:08 2010
@@ -0,0 +1,12 @@
+from scxml.cgf.backends.js.AbstractStatechartGenerator import config as AbstractStatechartGeneratorConfig

+
+config =  {
+	"transformations": AbstractStatechartGeneratorConfig["transformations"] +
+				 [ "xslt/ir-compiler/appendTransitionInformation.xsl",
+					"xslt/ir-compiler/copyEnumeratedEventTransitions.xsl",
+					"xslt/ir-compiler/enumerateEvents.xsl",
+					"xslt/ir-compiler/addEventRegularExpressions.xsl",
+					"xslt/ir-compiler/expandStarEvent.xsl",
+					"xslt/layout/addTransitionTargetIds.xsl" ],
+	"code" : "xslt/backends/js/StatePatternStatechartGenerator.xsl"	 #preprocessed stylesheet
instead? 
+}

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/StatePatternStatechartGenerator.py
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/StateTableStatechartGenerator.py
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/StateTableStatechartGenerator.py?rev=1032237&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/StateTableStatechartGenerator.py
(added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/StateTableStatechartGenerator.py
Sun Nov  7 09:34:08 2010
@@ -0,0 +1,7 @@
+from scxml.cgf.backends.js.AbstractEnumeratedStatechartGenerator import config as AbstractEnumeratedStatechartGeneratorConfig

+
+config =  {
+	"transformations": AbstractEnumeratedStatechartGeneratorConfig["transformations"], 
+	"code" : "xslt/backends/js/StateTableStatechartGenerator.xsl"	 #preprocessed stylesheet
instead? 
+}
+

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/StateTableStatechartGenerator.py
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/SwitchyardGenerator.py
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/SwitchyardGenerator.py?rev=1032237&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/SwitchyardGenerator.py
(added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/SwitchyardGenerator.py
Sun Nov  7 09:34:08 2010
@@ -0,0 +1,6 @@
+from scxml.cgf.backends.js.AbstractEnumeratedStatechartGenerator import config as AbstractEnumeratedStatechartGeneratorConfig

+
+config =  {
+	"transformations": AbstractEnumeratedStatechartGeneratorConfig["transformations"], 
+	"code" : "xslt/backends/js/SwitchyardStatechartGenerator.xsl"	 #preprocessed stylesheet
instead? 
+}

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/SwitchyardGenerator.py
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/__init__.py
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/__init__.py?rev=1032237&view=auto
==============================================================================
    (empty)

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/backends/js/__init__.py
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/tests/__init__.py
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/tests/__init__.py?rev=1032237&view=auto
==============================================================================
    (empty)

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/tests/__init__.py
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/tests/test.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/tests/test.xml?rev=1032237&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/tests/test.xml (added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/tests/test.xml Sun Nov 
7 09:34:08 2010
@@ -0,0 +1,3 @@
+<hello>
+	<world/>
+</hello>

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/tests/test.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/tests/testpkgresource.py
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/tests/testpkgresource.py?rev=1032237&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/tests/testpkgresource.py
(added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/tests/testpkgresource.py
Sun Nov  7 09:34:08 2010
@@ -0,0 +1,15 @@
+import pkg_resources
+from lxml import etree
+
+#get some basic data
+my_data = pkg_resources.resource_string("scxml.cgf.tests.testpkgresource", "test.xml")
+
+print my_data
+
+#see if we can parse the stream into an xml tree
+my_stream = pkg_resources.resource_stream("scxml.cgf.tests.testpkgresource", "test.xml")
+tree = etree.parse(my_stream)
+print tree 
+print etree.tostring(tree,pretty_print=True)
+
+#result: works great!

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/tests/testpkgresource.py
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/xslt
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/xslt?rev=1032237&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/xslt (added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/xslt Sun Nov  7 09:34:08
2010
@@ -0,0 +1 @@
+link ../../../xslt/
\ No newline at end of file

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/xslt
------------------------------------------------------------------------------
    svn:special = *



Mime
View raw message