Author: jbeard
Date: Thu Mar 17 16:17:22 2011
New Revision: 1082556
URL: http://svn.apache.org/viewvc?rev=1082556&view=rev
Log:
Added support for static reactions (targetless transitions in SCXML spec).
Added unit test for this. Passes state pattern, but not enumerated patterns.
The reason for this is a bug in the implementation of the flattening algorithm,
and I think extends beyond the task of implementing support for static
reactions. Next commit will fix this bug.
Also, added support for disabling tasks related to code generation when running
tests in Ant. Created a properties file to facilitate this.
Added:
commons/sandbox/gsoc/2010/scxml-js/trunk/run-tests-without-generating-code.properties
(with props)
commons/sandbox/gsoc/2010/scxml-js/trunk/test/targetless-transition/
commons/sandbox/gsoc/2010/scxml-js/trunk/test/targetless-transition/TestTargetlessTransition.xml
(with props)
commons/sandbox/gsoc/2010/scxml-js/trunk/test/targetless-transition/scripts/
commons/sandbox/gsoc/2010/scxml-js/trunk/test/targetless-transition/scripts/unitTest.js
(with props)
Modified:
commons/sandbox/gsoc/2010/scxml-js/trunk/build-common.xml
commons/sandbox/gsoc/2010/scxml-js/trunk/mvn-ant-build.xml
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractStatechartGenerator.xsl
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/addBasicDescendantsToTransitions.xsl
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/appendTransitionInformation.xsl
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/computeLCA.xsl
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/splitTransitionTargets.xsl
Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/build-common.xml
URL:
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/build-common.xml?rev=1082556&r1=1082555&r2=1082556&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/build-common.xml (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/build-common.xml Thu Mar 17
16:17:22 2011
@@ -82,6 +82,7 @@
<property name="path_to_dojo" value="${path_to_dojo_base}/dojo.js"/>
<path id="scxml_tests_xml">
+ <!--
<pathelement location="test/kitchen_sink/KitchenSink.xml"/>
<pathelement
location="test/kitchen_sink/KitchenSink_dataModule.xml"/>
<pathelement
location="test/kitchen_sink/KitchenSink_performance.xml"/>
@@ -91,6 +92,8 @@
<pathelement
location="test/event_system_properties/TestEventSystemProperties.xml"/>
<pathelement
location="test/prefix_events/TestPrefixEvents.xml"/>
<pathelement location="test/parallel/TestParallel.xml"/>
+ -->
+ <pathelement
location="test/targetless-transition/TestTargetlessTransition.xml"/>
</path>
<property name="drawing-tool-lib" value="demo/drawing-tool/lib"/>
@@ -286,7 +289,6 @@
<arg value="src/javascript/scxml/cgf/main"/>
<arg value="--backend=@{backend}"/>
- <arg value="--beautify"/>
<arg value="--ie"/>
<arg value="@{test-path}"/>
</java>
@@ -312,7 +314,6 @@
<arg value="src/javascript/scxml/cgf/main"/>
<arg value="--backend=@{backend}"/>
- <arg value="--beautify"/>
<arg value="@{test-path}"/>
</java>
</sequential>
@@ -549,7 +550,7 @@
</sequential>
</macrodef>
- <target name="preprocess-stylesheets"
unless="${skip-preprocessing-xsl}">
+ <target name="preprocess-stylesheets" unless="skip-preprocessing-xsl">
<xslt
classpathref="maven.plugin.classpath"
style="${src}/xslt/util/preprocess_import.xsl"
@@ -566,7 +567,7 @@
</xslt>
</target>
- <target name="build-dependency-lists" depends="setup-antcontrib">
+ <target name="build-dependency-lists" depends="setup-antcontrib"
unless="skip-building-dependency-lists">
<for list="${xslt-dep-sources}" param="xslt-dep-source">
<sequential>
@@ -593,7 +594,7 @@
</for>
</target>
- <target name="build-language-frontend-modules"
depends="build-dependency-lists" unless="${skip-generating-modules}">
+ <target name="build-language-frontend-modules"
depends="build-dependency-lists" unless="skip-generating-modules">
<path id="build-xsl-dep-list-path">
<fileset dir="${build-xsl-dep-list}" includes="*.xml"/>
Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/mvn-ant-build.xml
URL:
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/mvn-ant-build.xml?rev=1082556&r1=1082555&r2=1082556&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/mvn-ant-build.xml (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/mvn-ant-build.xml Thu Mar 17
16:17:22 2011
@@ -73,7 +73,7 @@
<!-- unit test stuff -->
- <target name="generate-javascript-mvn" depends="setup-properties">
+ <target name="generate-javascript-mvn" depends="setup-properties"
unless="skip-javascript-generation">
<mkdir dir="${build}/generate-javascript"/>
<for list="${for-ie}" param="for-ie">
Added:
commons/sandbox/gsoc/2010/scxml-js/trunk/run-tests-without-generating-code.properties
URL:
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/run-tests-without-generating-code.properties?rev=1082556&view=auto
==============================================================================
---
commons/sandbox/gsoc/2010/scxml-js/trunk/run-tests-without-generating-code.properties
(added)
+++
commons/sandbox/gsoc/2010/scxml-js/trunk/run-tests-without-generating-code.properties
Thu Mar 17 16:17:22 2011
@@ -0,0 +1,4 @@
+skip-javascript-generation=true
+skip-preprocessing-xsl=true
+skip-generating-modules=true
+skip-building-dependency-lists=true
Propchange:
commons/sandbox/gsoc/2010/scxml-js/trunk/run-tests-without-generating-code.properties
------------------------------------------------------------------------------
svn:eol-style = native
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=1082556&r1=1082555&r2=1082556&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
Thu Mar 17 16:17:22 2011
@@ -1116,25 +1116,28 @@
hasTakenDefaultTransition = true;
</if>
- <variable name="precomputeExit"
- select="local-name($s) = 'initial' or
local-name($s) = 'history' or
- ( $s/@c:isBasic and
- (
not($s/@c:isParallelSubstate) or
-
($s/@c:isParallelSubstate and not($t/@c:exitsParallelRegion))))"/>
-
- //exit states
- <choose>
- <when test="$precomputeExit">
- <for-each
select="$t/c:exitpath/c:state">
- <value-of
select="."/>.exitAction();
- </for-each>
- </when>
- <otherwise>
- <call-template
name="genNonBasicTriggerDispatcherExitBlock">
- <with-param name="t"
select="$t"/>
- </call-template>
- </otherwise>
- </choose>
+ <!-- if he's not a static reaction -->
+ <if test="$t/@target">
+ <variable name="precomputeExit"
+ select="local-name($s) =
'initial' or local-name($s) = 'history' or
+ ( $s/@c:isBasic
and
+ (
not($s/@c:isParallelSubstate) or
+
($s/@c:isParallelSubstate and not($t/@c:exitsParallelRegion))))"/>
+
+ //exit states
+ <choose>
+ <when test="$precomputeExit">
+ <for-each
select="$t/c:exitpath/c:state">
+ <value-of
select="."/>.exitAction();
+ </for-each>
+ </when>
+ <otherwise>
+ <call-template
name="genNonBasicTriggerDispatcherExitBlock">
+ <with-param
name="t" select="$t"/>
+ </call-template>
+ </otherwise>
+ </choose>
+ </if>
//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:assign or
self::s:validate ]"/>
@@ -1155,34 +1158,37 @@
</call-template>
</if>
- //enter states
- <for-each
select="$t/c:targets/c:target/c:enterpath/c:state">
- <!-- iterate in reverse order -->
- <sort select="position()"
data-type="number" order="descending"/>
- <value-of select="."/>.enterAction();
- </for-each>
-
- //update configuration
- <choose>
- <when test="$s/@c:isParallelSubstate
and not($t/@c:exitsParallelRegion) and not($s/@c:isBasic)">
- <call-template
name="genParallelSubstateAndCompositeConfigurationSetString">
- <with-param name="s"
select="$s"/>
- <with-param name="t"
select="$t"/>
- </call-template>
- </when>
- <when test="$s/@c:isParallelSubstate
and not($t/@c:exitsParallelRegion) and $s/@c:isBasic">
- <call-template
name="genParallelSubstateConfigurationSetString">
- <with-param name="s"
select="$s"/>
- <with-param name="t"
select="$t"/>
- </call-template>
- </when>
- <otherwise>
- <call-template
name="genNonParallelSubstateConfigurationSetString">
- <with-param name="s"
select="$s"/>
- <with-param name="t"
select="$t"/>
- </call-template>
- </otherwise>
- </choose>
+ <!-- if he's not a static reaction -->
+ <if test="$t/@target">
+ //enter states
+ <for-each
select="$t/c:targets/c:target/c:enterpath/c:state">
+ <!-- iterate in reverse order
-->
+ <sort select="position()"
data-type="number" order="descending"/>
+ <value-of
select="."/>.enterAction();
+ </for-each>
+
+ //update configuration
+ <choose>
+ <when
test="$s/@c:isParallelSubstate and not($t/@c:exitsParallelRegion) and
not($s/@c:isBasic)">
+ <call-template
name="genParallelSubstateAndCompositeConfigurationSetString">
+ <with-param
name="s" select="$s"/>
+ <with-param
name="t" select="$t"/>
+ </call-template>
+ </when>
+ <when
test="$s/@c:isParallelSubstate and not($t/@c:exitsParallelRegion) and
$s/@c:isBasic">
+ <call-template
name="genParallelSubstateConfigurationSetString">
+ <with-param
name="s" select="$s"/>
+ <with-param
name="t" select="$t"/>
+ </call-template>
+ </when>
+ <otherwise>
+ <call-template
name="genNonParallelSubstateConfigurationSetString">
+ <with-param
name="s" select="$s"/>
+ <with-param
name="t" select="$t"/>
+ </call-template>
+ </otherwise>
+ </choose>
+ </if>
}
}
Modified:
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/addBasicDescendantsToTransitions.xsl
URL:
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/addBasicDescendantsToTransitions.xsl?rev=1082556&r1=1082555&r2=1082556&view=diff
==============================================================================
---
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/addBasicDescendantsToTransitions.xsl
(original)
+++
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/addBasicDescendantsToTransitions.xsl
Thu Mar 17 16:17:22 2011
@@ -37,7 +37,7 @@
</xsl:template>
- <xsl:template match="s:transition">
+ <xsl:template match="s:transition[@target]">
<xsl:variable name="lca-id" select="c:lca/text()"/>
<xsl:variable name="lca-descendant-basic-states"
select="$states[@id=$lca-id]//s:state[@c:isBasic='true']"/>
<!--
Modified:
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/appendTransitionInformation.xsl
URL:
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/appendTransitionInformation.xsl?rev=1082556&r1=1082555&r2=1082556&view=diff
==============================================================================
---
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/appendTransitionInformation.xsl
(original)
+++
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/appendTransitionInformation.xsl
Thu Mar 17 16:17:22 2011
@@ -50,7 +50,7 @@ region (a child of <parallel>), and the
<xsl:variable name="parallelRegions" select="$parallels/s:state"/>
- <xsl:template match="s:transition">
+ <xsl:template match="s:transition[@target]">
<xsl:variable name="sourceState" select="parent::*"/>
<xsl:variable name="targetId"
select="c:targets/c:target/c:targetState[1]"/>
Modified:
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/computeLCA.xsl
URL:
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/computeLCA.xsl?rev=1082556&r1=1082555&r2=1082556&view=diff
==============================================================================
---
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/computeLCA.xsl
(original)
+++
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/computeLCA.xsl
Thu Mar 17 16:17:22 2011
@@ -125,7 +125,7 @@ to the input document as children in the
</xsl:copy>
</xsl:template>
- <xsl:template match="s:transition">
+ <xsl:template match="s:transition[@target]">
<xsl:variable name="srcState" select="parent::*"/>
Modified:
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/splitTransitionTargets.xsl
URL:
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/splitTransitionTargets.xsl?rev=1082556&r1=1082555&r2=1082556&view=diff
==============================================================================
---
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/splitTransitionTargets.xsl
(original)
+++
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/splitTransitionTargets.xsl
Thu Mar 17 16:17:22 2011
@@ -47,7 +47,7 @@
</xsl:template>
- <xsl:template match="s:transition">
+ <xsl:template match="s:transition[@target]">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
<c:targets>
Added:
commons/sandbox/gsoc/2010/scxml-js/trunk/test/targetless-transition/TestTargetlessTransition.xml
URL:
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/test/targetless-transition/TestTargetlessTransition.xml?rev=1082556&view=auto
==============================================================================
---
commons/sandbox/gsoc/2010/scxml-js/trunk/test/targetless-transition/TestTargetlessTransition.xml
(added)
+++
commons/sandbox/gsoc/2010/scxml-js/trunk/test/targetless-transition/TestTargetlessTransition.xml
Thu Mar 17 16:17:22 2011
@@ -0,0 +1,85 @@
+<?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.
+-->
+<!--
+This is to test the user of targetless transitions.
+-->
+<scxml
+ xmlns="http://www.w3.org/2005/07/scxml"
+ version="1.0"
+ profile="ecmascript">
+
+ <initial>
+ <transition target="a"/>
+ </initial>
+
+ <datamodel>
+ <data id="x" expr="0"/>
+ </datamodel>
+
+ <state id="a">
+ <transition event="t1">
+ <assign location="x" expr="x+1"/>
+ </transition>
+ <transition event="t1" target="should_not_be_here1"/>
+
+ <transition event="t2" target="b" cond="x==1"/>
+ </state>
+
+ <state id="should_not_be_here1"/>
+
+ <state id="b">
+ <transition event="t3" target="c" cond="x==1"/>
+ <transition event="t3">
+ <assign location="x" expr="x+1"/>
+ </transition>
+ </state>
+
+ <state id="c" initial="c1">
+ <transition event="t4">
+ <assign location="x" expr="x+1"/>
+ </transition>
+
+ <state id="c1">
+ <transition event="t4" target="d" cond="x==1"/>
+ </state>
+ </state>
+
+ <state id="d" initial="d1">
+ <transition event="t5">
+ <assign location="x" expr="x+1"/>
+ </transition>
+
+ <transition event="t6" target="e" cond="x==2"/>
+
+ <state id="d1">
+ <transition event="t5" cond="x==1">
+ <assign location="x" expr="x+1"/>
+ </transition>
+ <transition event="t5" target="should_not_be_here2"/>
+ </state>
+
+ </state>
+
+ <state id="should_not_be_here2"/>
+
+ <state id="e"/>
+
+</scxml>
+
+
+
Propchange:
commons/sandbox/gsoc/2010/scxml-js/trunk/test/targetless-transition/TestTargetlessTransition.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added:
commons/sandbox/gsoc/2010/scxml-js/trunk/test/targetless-transition/scripts/unitTest.js
URL:
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/test/targetless-transition/scripts/unitTest.js?rev=1082556&view=auto
==============================================================================
---
commons/sandbox/gsoc/2010/scxml-js/trunk/test/targetless-transition/scripts/unitTest.js
(added)
+++
commons/sandbox/gsoc/2010/scxml-js/trunk/test/targetless-transition/scripts/unitTest.js
Thu Mar 17 16:17:22 2011
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+
+require.def( "test/targetless-transition/scripts/unitTest",
+{
+
+ scxmlTest : "test/targetless-transition/TestTargetlessTransition.xml",
+
+ register:function(scConstructor){
+
+ //TODO: can load this using RequireJS, so we don't need to use
the dojo module system?
+ dojo.require("doh.runner");
+ var sc;
+ doh.register("testTargetlessTransitions",[
+ {
+ name:"testAll",
+ //timeout:5000,
+ setUp:function(){
+ sc = new scConstructor()
+ sc.initialize();
+ },
+ runTest:function(){
+ var $ = function(conf){
+ var toReturn = [];
+ for(var i=0;
i<conf.length;i++){
+ var s = conf[i];
+
toReturn.push(s.toString())
+ }
+ return toReturn;
+ };
+
+ var conf0 =
sc.getCurrentConfiguration();
+ console.log($(conf0));
+
doh.assertEqual(sc._states.a,conf0[0]);
+
+ console.info("sending event t1")
+ sc.t1()
+ var conf1 =
sc.getCurrentConfiguration();
+ console.log($(conf1));
+
doh.assertEqual(sc._states.a,conf1[0]);
+
+ console.info("sending event t2")
+ sc.t2()
+ var conf2 =
sc.getCurrentConfiguration();
+ console.log($(conf2));
+
doh.assertEqual(sc._states.b,conf2[0]);
+
+ console.info("sending event t3")
+ sc.t3()
+ var conf3 =
sc.getCurrentConfiguration();
+ console.log($(conf3));
+
doh.assertEqual(sc._states.c1,conf3[0]);
+
+ console.info("sending event t4")
+ sc.t4()
+ var conf4 =
sc.getCurrentConfiguration();
+ console.log($(conf4));
+
doh.assertEqual(sc._states.d1,conf4[0]);
+
+ console.info("sending event t5")
+ sc.t5()
+ var conf5 =
sc.getCurrentConfiguration();
+ console.log($(conf5));
+
doh.assertEqual(sc._states.d1,conf5[0]);
+
+ console.info("sending event t6")
+ sc.t6()
+ var conf6 =
sc.getCurrentConfiguration();
+ console.log($(conf6));
+
doh.assertEqual(sc._states.e,conf6[0]);
+ },
+ tearDown:function(){
+ sc.destroy();
+ }
+ }
+ ]);
+ }
+})
+
+
Propchange:
commons/sandbox/gsoc/2010/scxml-js/trunk/test/targetless-transition/scripts/unitTest.js
------------------------------------------------------------------------------
svn:eol-style = native