Author: jbeard
Date: Fri Jun 25 16:16:52 2010
New Revision: 958019

URL: http://svn.apache.org/viewvc?rev=958019&view=rev
Log:
Guard conditions now working for table and switch techniques as well.

Modified:
    commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/build.js
    
commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/xslt/backends/js/AbstractEnumeratedStatechartGenerator.xsl
    
commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/xslt/backends/js/AbstractStatechartGenerator.xsl
    
commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/xslt/backends/js/StatePatternStatechartGenerator.xsl
    
commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/xslt/backends/js/StateTableStatechartGenerator.xsl
    
commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/xslt/ir-compiler/flattenTransitions.xsl
    
commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/test/conditional_transition/scripts/unitTest.js
    
commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/test/test_with_xsltproc.sh

Modified: 
commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/build.js
URL: 
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/build.js?rev=958019&r1=958018&r2=958019&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/build.js 
(original)
+++ commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/build.js 
Fri Jun 25 16:16:52 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
                        }
 

Modified: 
commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/xslt/backends/js/AbstractEnumeratedStatechartGenerator.xsl
URL: 
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/xslt/backends/js/AbstractEnumeratedStatechartGenerator.xsl?rev=958019&r1=958018&r2=958019&view=diff
==============================================================================
--- 
commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/xslt/backends/js/AbstractEnumeratedStatechartGenerator.xsl
 (original)
+++ 
commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/xslt/backends/js/AbstractEnumeratedStatechartGenerator.xsl
 Fri Jun 25 16:16:52 2010
@@ -65,12 +65,7 @@
                <call-template name="genTriggerIdToNameMap"/>
 
                //transition functions
-               <for-each select="$transitions">
-                       <call-template name="genTriggerDispatcherContext">
-                               <with-param name="s" select=".."/>
-                               <with-param name="t" select="."/>
-                       </call-template>
-               </for-each>
+               <call-template name="genTriggerHandlerFunctions"/>
 
                <call-template name="genEnumeratedHooks"/>
        </template>
@@ -94,25 +89,52 @@
                ];
        </template>
 
+       <template name="genTriggerHandlerFunctions">
+
+               <for-each select="$basicStates">
+
+                       <variable name="state" select="."/>
+
+                       <for-each select="$eventsEnum/c:name">
+                               <variable name="eventName">
+                                       <value-of select="."/>
+                               </variable>
+
+                               <variable name="transitionsForEvent" 
select="$state/s:transiti...@event = $eventName]"/>
+
+                               <if test="$transitionsForEvent">
+                                       <call-template 
name="genTriggerDispatcherContext">
+                                               <with-param name="s" 
select="$state"/>
+                                               <with-param name="transitions" 
select="$transitionsForEvent"/>
+                                               <with-param name="eventName" 
select="$eventName"/>
+                                       </call-template>
+                               </if>
+                       </for-each>
+
+                       <!-- now do default transitions -->
+                       <variable name="defaultTransitionsForState" 
select="$state/s:transition[not(@event)]"/>
+                       <if test="$defaultTransitionsForState">
+                               <call-template 
name="genTriggerDispatcherContext">
+                                       <with-param name="s" select="$state"/>
+                                       <with-param name="transitions" 
select="$defaultTransitionsForState"/>
+                                       <with-param name="eventName" 
select="'$default'"/>
+                               </call-template>
+                       </if>
+
+               </for-each>
+       </template>
+
        <template name="genTriggerDispatcherContext">
                <param name="s"/>
-               <param name="t"/>
+               <param name="transitions"/>
+               <param name="eventName"/>
 
-               var <value-of select="$t/@c:tName"/> = function(){
-                       <choose>
-                               <when test="$s/@c:isHistory">
-                                       <call-template 
name="genHistoryTriggerDispatcher">
-                                               <with-param name="s" 
select="$s"/>
-                                               <with-param name="t" 
select="$t"/>
-                                       </call-template>
-                               </when>
-                               <otherwise>
-                                       <call-template 
name="genTriggerDispatcherContents">
-                                               <with-param name="s" 
select="$s"/>
-                                               <with-param name="t" 
select="$t"/>
-                                       </call-template>
-                               </otherwise>
-                       </choose>
+               var <value-of select="$transitions[1]/@c:tName"/> = function(){
+                       <call-template name="genTriggerDispatcherContents">
+                               <with-param name="s" select="$s"/>
+                               <with-param name="transitions" 
select="$transitions"/>
+                               <with-param name="eventName" 
select="$eventName"/>
+                       </call-template>
                }
        </template>
 

Modified: 
commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/xslt/backends/js/AbstractStatechartGenerator.xsl
URL: 
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/xslt/backends/js/AbstractStatechartGenerator.xsl?rev=958019&r1=958018&r2=958019&view=diff
==============================================================================
--- 
commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/xslt/backends/js/AbstractStatechartGenerator.xsl
 (original)
+++ 
commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/xslt/backends/js/AbstractStatechartGenerator.xsl
 Fri Jun 25 16:16:52 2010
@@ -574,7 +574,30 @@
                });
        </template>
 
-       <template name="genTriggerDispatcherContents"> 
+       <template name="genTriggerDispatcherContents">
+               <param name="s"/>
+               <param name="transitions"/>
+               <param name="eventName"/>
+
+               <choose>
+                       <when test="$s/@c:isHistory">
+                               <call-template 
name="genHistoryTriggerDispatcher">
+                                       <with-param name="s" select="$s"/>
+                                       <with-param name="t" 
select="$transitions[1]"/>
+                               </call-template>
+                       </when>
+                       <otherwise>
+                               <for-each select="$transitions">
+                                       <call-template 
name="genTriggerDispatcherGuardConditionBlockContents">
+                                               <with-param name="s" 
select="$s"/>
+                                               <with-param name="t" 
select="."/>
+                                       </call-template>
+                               </for-each>
+                       </otherwise>
+               </choose>
+       </template>
+
+       <template name="genTriggerDispatcherGuardConditionBlockContents"> 
                <param name="s"/>
                <param name="t"/>
 

Modified: 
commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/xslt/backends/js/StatePatternStatechartGenerator.xsl
URL: 
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/xslt/backends/js/StatePatternStatechartGenerator.xsl?rev=958019&r1=958018&r2=958019&view=diff
==============================================================================
--- 
commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/xslt/backends/js/StatePatternStatechartGenerator.xsl
 (original)
+++ 
commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/xslt/backends/js/StatePatternStatechartGenerator.xsl
 Fri Jun 25 16:16:52 2010
@@ -118,22 +118,12 @@
                <param name="eventName"/>
 
                this.<value-of select="$eventName"/> = function(){
-                       <choose>
-                               <when test="local-name($s) = 'history'">
-                                       <call-template 
name="genHistoryTriggerDispatcher">
-                                               <with-param name="s" 
select="$s"/>
-                                               <with-param name="t" 
select="$transitions[1]"/>
-                                       </call-template>
-                               </when>
-                               <otherwise>
-                                       <for-each select="$transitions">
-                                               <call-template 
name="genTriggerDispatcherContents">
-                                                       <with-param name="s" 
select="$s"/>
-                                                       <with-param name="t" 
select="."/>
-                                               </call-template>
-                                       </for-each>
-                               </otherwise>
-                       </choose>
+
+                       <call-template name="genTriggerDispatcherContents">
+                               <with-param name="s" select="$s"/>
+                               <with-param name="transitions" 
select="$transitions"/>
+                               <with-param name="eventName" 
select="$eventName"/>
+                       </call-template>
 
                        <!-- if by this point he hasn't returned, then none of 
the transitions passed, 
                                and we need to pass the transition up the 
hierarchy chain -->

Modified: 
commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/xslt/backends/js/StateTableStatechartGenerator.xsl
URL: 
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/xslt/backends/js/StateTableStatechartGenerator.xsl?rev=958019&r1=958018&r2=958019&view=diff
==============================================================================
--- 
commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/xslt/backends/js/StateTableStatechartGenerator.xsl
 (original)
+++ 
commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/xslt/backends/js/StateTableStatechartGenerator.xsl
 Fri Jun 25 16:16:52 2010
@@ -76,9 +76,7 @@
 
                                                <choose>
                                                        <when 
test="$correspondingTransitions">
-                                                               <for-each 
select="$correspondingTransitions">
-                                                                       
<value-of select="@c:tName"/>
-                                                               </for-each>
+                                                               <value-of 
select="$correspondingTransitions[1]/@c:tName"/>
                                                        </when>
                                                        <otherwise>
                                                                <value-of 
select="$nullTransitionFunctionName"/>

Modified: 
commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/xslt/ir-compiler/flattenTransitions.xsl
URL: 
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/xslt/ir-compiler/flattenTransitions.xsl?rev=958019&r1=958018&r2=958019&view=diff
==============================================================================
--- 
commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/xslt/ir-compiler/flattenTransitions.xsl
 (original)
+++ 
commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/xslt/ir-compiler/flattenTransitions.xsl
 Fri Jun 25 16:16:52 2010
@@ -59,10 +59,11 @@ collision. 
 
                <xsl:variable name="currentTransitions" select="s:transition"/>
 
-               <!-- get active transitions -->
-               <xsl:variable name="filteredParentTransitions" 
select="$parentTransitions[not(@event = $currentTransitions/@event)]"/>
+               <!-- we used to filter the parent transitions here to avoid 
transitions with duplicate events,
+                       but this is no longer necessary, as parent transitions 
will have lower priority
+                       as they are appended in a deeper document order -->
 
-               <xsl:variable name="activeTransitions" 
select="$filteredParentTransitions | $currentTransitions"/>
+               <xsl:variable name="activeTransitions" 
select="$currentTransitions | $parentTransitions"/>
 
                <!--
                <xsl:message>
@@ -98,10 +99,11 @@ collision. 
 
                <xsl:variable name="currentTransitions" select="s:transition"/>
 
-               <!-- get active transitions -->
-               <xsl:variable name="filteredParentTransitions" 
select="$parentTransitions[not(@event = $currentTransitions/@event)]"/>
+               <!-- we used to filter the parent transitions here to avoid 
transitions with duplicate events,
+                       but this is no longer necessary, as parent transitions 
will have lower priority
+                       as they are appended in a deeper document order -->
 
-               <xsl:variable name="activeTransitions" 
select="$filteredParentTransitions | $currentTransitions"/>
+               <xsl:variable name="activeTransitions" 
select="$currentTransitions | $parentTransitions"/>
 
                <!--
                <xsl:message>

Modified: 
commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/test/conditional_transition/scripts/unitTest.js
URL: 
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/test/conditional_transition/scripts/unitTest.js?rev=958019&r1=958018&r2=958019&view=diff
==============================================================================
--- 
commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/test/conditional_transition/scripts/unitTest.js
 (original)
+++ 
commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/test/conditional_transition/scripts/unitTest.js
 Fri Jun 25 16:16:52 2010
@@ -51,7 +51,6 @@ dojo.require("doh.runner");
                                        console.log($(conf2));
                                        
doh.assertTrue(setwiseEqual(conf2,[sc._states.e1]));
 
-debugger;
                                        console.info("sending event t3")
                                        sc.t3()
                                        var conf3 = 
sc.getCurrentConfiguration();

Modified: 
commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/test/test_with_xsltproc.sh
URL: 
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/test/test_with_xsltproc.sh?rev=958019&r1=958018&r2=958019&view=diff
==============================================================================
--- 
commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/test/test_with_xsltproc.sh
 (original)
+++ 
commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/test/test_with_xsltproc.sh
 Fri Jun 25 16:16:52 2010
@@ -17,7 +17,7 @@ xsltproc ../src/xslt/ir-compiler/numberS
 xmlindent > tmp_IR.xml;
 
 #uncomment to compile IR to js
-xsltproc ../src/xslt/backends/js/StatePatternStatechartGenerator_combined.xsl 
tmp_IR.xml > out.js
+xsltproc ../build/StatePatternStatechartGenerator_combined.xsl tmp_IR.xml > 
out.js
 
 #uncomment to prettify js. need to have beautify.js, beautify-cl.js and 
beautify-html.js in this directory
 #java -cp ../lib/java/js.jar org.mozilla.javascript.tools.shell.Main -debug 
beautify-cl.js -i 4 out.js > out_pretty.js


Reply via email to