Author: jbeard
Date: Sun Jun 27 00:32:26 2010
New Revision: 958300

URL: http://svn.apache.org/viewvc?rev=958300&view=rev
Log:
Test passes for state pattern.

Modified:
    
commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-140/src/xslt/backends/js/AbstractEnumeratedStatechartGenerator.xsl
    
commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-140/src/xslt/backends/js/AbstractStatechartGenerator.xsl
    
commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-140/src/xslt/backends/js/StatePatternStatechartGenerator.xsl
    
commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-140/test/in_predicate/scripts/unitTest.js

Modified: 
commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-140/src/xslt/backends/js/AbstractEnumeratedStatechartGenerator.xsl
URL: 
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-140/src/xslt/backends/js/AbstractEnumeratedStatechartGenerator.xsl?rev=958300&r1=958299&r2=958300&view=diff
==============================================================================
--- 
commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-140/src/xslt/backends/js/AbstractEnumeratedStatechartGenerator.xsl
 (original)
+++ 
commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-140/src/xslt/backends/js/AbstractEnumeratedStatechartGenerator.xsl
 Sun Jun 27 00:32:26 2010
@@ -216,17 +216,6 @@
        <template name="genEnumeratedHooks"/>
        <template name="genTriggerIntEnum"/>
 
-       <variable name="genInPredicateFunction">
-               function In(state){
-                       state = typeof state == "string" ? self._states[state] 
: state;
-                               
-                       return state.isBasic ? 
-                               currentConfiguration.indexOf(state.id) != -1 : 
-                                       currentConfiguration.some(function(s){
-                                               return 
s.ancestors.indexOf(state.id) != -1;
-                                       });
-               }
-       </variable>
 </stylesheet>
 
 

Modified: 
commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-140/src/xslt/backends/js/AbstractStatechartGenerator.xsl
URL: 
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-140/src/xslt/backends/js/AbstractStatechartGenerator.xsl?rev=958300&r1=958299&r2=958300&view=diff
==============================================================================
--- 
commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-140/src/xslt/backends/js/AbstractStatechartGenerator.xsl
 (original)
+++ 
commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-140/src/xslt/backends/js/AbstractStatechartGenerator.xsl
 Sun Jun 27 00:32:26 2010
@@ -178,6 +178,31 @@
 
                                this.historyState = null;
 
+                               //these variables facilitate fast In predicate
+                               this.isBasic = 
+                               <choose>
+                                       <when test="$state/@c:isBasic">
+                                               true;
+                                       </when>
+                                       <otherwise>
+                                               false;
+                                       </otherwise>
+                               </choose>
+
+                               <!-- only basic states need this property -->
+                               <if test="$state/@c:isBasic">
+                                       this.ancestors = [
+                                               <for-each 
select="$state/ancestor::*">
+                                                       <value-of select="@id"/>
+                                                       <if test="position() != 
last()">
+                                                               ,
+                                                       </if>   
+                                               </for-each>
+                                       ];
+                               </if>
+
+
+
                                <if test="$state/self::s:history">
                                        this.parent.historyState = this; //init 
parent's pointer to history state
                                </if>
@@ -731,7 +756,17 @@
        <template name="genInitialization"/>
        <template name="genTriggerDispatcherContext"/>
 
-       <variable name="genInPredicateFunction"/>
+       <variable name="genInPredicateFunction">
+               function In(state){
+                       state = typeof state == "string" ? self._states[state] 
: state;
+                               
+                       return state.isBasic ? 
+                               currentConfiguration.indexOf(state) != -1 : 
+                                       currentConfiguration.some(function(s){
+                                               return 
s.ancestors.indexOf(state) != -1;
+                                       });
+               }
+       </variable>
 
 </stylesheet>
 

Modified: 
commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-140/src/xslt/backends/js/StatePatternStatechartGenerator.xsl
URL: 
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-140/src/xslt/backends/js/StatePatternStatechartGenerator.xsl?rev=958300&r1=958299&r2=958300&view=diff
==============================================================================
--- 
commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-140/src/xslt/backends/js/StatePatternStatechartGenerator.xsl
 (original)
+++ 
commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-140/src/xslt/backends/js/StatePatternStatechartGenerator.xsl
 Sun Jun 27 00:32:26 2010
@@ -162,16 +162,4 @@
                </choose>
        </template>
 
-       <variable name="genInPredicateFunction">
-               function In(state){
-                       state = typeof state == "string" ? self._states[state] 
: state;
-                               
-                       return state.isBasic ? 
-                               currentConfiguration.indexOf(state) != -1 : 
-                                       currentConfiguration.some(function(s){
-                                               return 
s.ancestors.indexOf(state) != -1;
-                                       });
-               }
-       </variable>
-
 </stylesheet>

Modified: 
commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-140/test/in_predicate/scripts/unitTest.js
URL: 
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-140/test/in_predicate/scripts/unitTest.js?rev=958300&r1=958299&r2=958300&view=diff
==============================================================================
--- 
commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-140/test/in_predicate/scripts/unitTest.js
 (original)
+++ 
commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-140/test/in_predicate/scripts/unitTest.js
 Sun Jun 27 00:32:26 2010
@@ -77,7 +77,7 @@ require.def( "test/in_predicate/scripts/
 
                                                console.info("sending event t6")
                                                sc.t6()
-                                               var conf5 = 
sc.getCurrentConfiguration();
+                                               var conf6 = 
sc.getCurrentConfiguration();
                                                console.log($(conf6));
                                                
doh.assertTrue(setwiseEqual(conf6,[sc._states.g1,sc._states.b2]));
 
@@ -101,7 +101,7 @@ require.def( "test/in_predicate/scripts/
 
                                                console.info("sending event 
t10")
                                                sc.t10()
-                                               var conf9 = 
sc.getCurrentConfiguration();
+                                               var conf10 = 
sc.getCurrentConfiguration();
                                                console.log($(conf10));
                                                
doh.assertTrue(setwiseEqual(conf10,[sc._states.k1,sc._states.e2]));
                                        },


Reply via email to