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 04:50:41 UTC
svn commit: r958444 - in
/commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148: build.js
src/xslt/backends/js/AbstractStatechartGenerator.xsl
test/kitchen_sink/KitchenSink_dataModule.xml
test/kitchen_sink/scripts/unitTest_dataModel.js
Author: jbeard
Date: Mon Jun 28 02:50:41 2010
New Revision: 958444
URL: http://svn.apache.org/viewvc?rev=958444&view=rev
Log:
Added code for datamodel, data, and assign elements to AbstractStatechartGenerator.xsl. New unit test passes.
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/AbstractStatechartGenerator.xsl
commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/test/kitchen_sink/KitchenSink_dataModule.xml
commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/test/kitchen_sink/scripts/unitTest_dataModel.js
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=958444&r1=958443&r2=958444&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 02:50:41 2010
@@ -56,8 +56,8 @@ require.def("build",
//enums
//we keep backward links of these
var backends = {
- "switch" : true,
- "table" : true,
+ //"switch" : true,
+ //"table" : true,
"state" : true
}
@@ -73,11 +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 :"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
@@ -104,10 +105,11 @@ 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"*/
]
//gets populated at run-time
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=958444&r1=958443&r2=958444&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 02:50:41 2010
@@ -86,8 +86,13 @@
var self = this; //used in the rare occasions we call public functions from inside this class
- //abstract state
+ //system variable declarations
+ var _event, _name, _sessionid, _x;
+
+ //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 +135,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 +377,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>
@@ -538,7 +566,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 +712,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">
Modified: commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/test/kitchen_sink/KitchenSink_dataModule.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/test/kitchen_sink/KitchenSink_dataModule.xml?rev=958444&r1=958443&r2=958444&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/test/kitchen_sink/KitchenSink_dataModule.xml (original)
+++ commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/test/kitchen_sink/KitchenSink_dataModule.xml Mon Jun 28 02:50:41 2010
@@ -1,29 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
<scxml
xmlns="http://www.w3.org/2005/07/scxml"
version="1.0"
profile="ecmascript">
- <!--
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- -->
-
<datamodel>
- <data name="x" expr="0"/>
- <data name="y" expr="0"/>
+ <data id="x" expr="0"/>
+ <data id="y" expr="0"/>
</datamodel>
<log label="x" expr="x"/>
@@ -52,7 +51,7 @@
</history>
<state id="Basic1">
- <transition event="t1" target="Basic2" cond="x==0 && y==0">
+ <transition event="t1" target="Basic2" cond="x==0 && y==0">
<assign location="x" expr="x+1"/>
<log label="x" expr="x"/>
<log label="y" expr="y"/>
@@ -60,15 +59,15 @@
</state>
<state id="Basic2">
- <transition event="t5" target="Basic1" cond="x==3 && y==3"/>
- <transition event="t2_7" target="Parallel1" cond="x==1 && y==0"/>
+ <transition event="t5" target="Basic1" cond="x==3 && y==3"/>
+ <transition event="t2_7" target="Parallel1" cond="x==1 && y==0"/>
</state>
<state id="Basic3">
- <transition event="t10" target="FinalState" cond="x==9 && y==9"/>
+ <transition event="t10" target="FinalState" cond="x==9 && y==9"/>
</state>
- <transition event="t2_7" target="DeepHistory" cond="x==81 && y==3"/>
+ <transition event="t2_7" target="DeepHistory"/>
</state>
<final id="FinalState"/>
@@ -103,14 +102,14 @@
</onentry>
<state id="Basic4">
- <transition event="t3" target="Basic5" cond="x==9 && y==0">
+ <transition event="t3" target="Basic5" cond="x==9 && y==0">
<send event="tgen"/>
</transition>
</state>
<state id="Basic5">
- <transition event="t8" target="Basic4"/>
- <transition event="t4_9" target="Compound1" cond="x==9 && y==1"/>
+ <transition event="t8" target="Basic4" cond="x==81 && y==3"/>
+ <transition event="t4_9" target="Compound1" cond="x==9 && y==1"/>
</state>
</state>
Modified: commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/test/kitchen_sink/scripts/unitTest_dataModel.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/test/kitchen_sink/scripts/unitTest_dataModel.js?rev=958444&r1=958443&r2=958444&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/test/kitchen_sink/scripts/unitTest_dataModel.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/test/kitchen_sink/scripts/unitTest_dataModel.js Mon Jun 28 02:50:41 2010
@@ -17,7 +17,7 @@
require.def( "test/kitchen_sink/scripts/unitTest_dataModel",
{
- scxmlTest:"test/kitchen_sink/KitchenSink_dataModel.xml",
+ scxmlTest:"test/kitchen_sink/KitchenSink_dataModule.xml",
register:function(scConstructor){
@@ -44,6 +44,7 @@ require.def( "test/kitchen_sink/scripts/
console.log(conf1);
doh.assertTrue(setwiseEqual(conf1,[sc._states.Basic2]));
+debugger;
console.info("sending event t2_7")
sc.t2_7()
var conf2 = sc.getCurrentConfiguration();
@@ -68,6 +69,7 @@ require.def( "test/kitchen_sink/scripts/
console.log(conf5);
doh.assertTrue(setwiseEqual(conf5,[sc._states.Basic1]));
+debugger;
console.info("sending event t2_7")
sc.t2_7()
var conf6 = sc.getCurrentConfiguration();