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/08/17 18:45:58 UTC
svn commit: r986386 -
/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractStatechartGenerator.xsl
Author: jbeard
Date: Tue Aug 17 16:45:58 2010
New Revision: 986386
URL: http://svn.apache.org/viewvc?rev=986386&view=rev
Log:
Removed reference to Array.some in favor of for loop.
Modified:
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractStatechartGenerator.xsl
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=986386&r1=986385&r2=986386&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 Tue Aug 17 16:45:58 2010
@@ -141,7 +141,30 @@
<value-of select="$returnArrayVarName"/>[<value-of select="$iteratorVarName"/>] = <value-of select="$expr"/>;
</with-param>
</call-template>
-
+ </template>
+
+ <template name="genSome">
+ <param name="returnVarName"/>
+
+ <param name="var"/>
+ <param name="in"/>
+ <param name="when" select="true"/>
+ <param name="iteratorVarName" select="$defaultIteratorVarName"/>
+ <param name="hoistVarName" select="$defaultHoistVarName"/>
+
+ var <value-of select="$returnVarName"/> = false;
+
+ for(var <value-of select="$iteratorVarName"/>=0,
+ <value-of select="$hoistVarName"/>=<value-of select="$in"/>.length;
+ <value-of select="$iteratorVarName"/> < <value-of select="$hoistVarName"/>;
+ <value-of select="$iteratorVarName"/>++){
+ <value-of select="$var"/> = <value-of select="$in"/>[<value-of select="$iteratorVarName"/>];
+
+ if(<value-of select="$when"/>){
+ <value-of select="$returnVarName"/> = true;
+ break;
+ }
+ }
</template>
<!-- helper template to safely get a state's parent's name -->
@@ -1056,12 +1079,24 @@
<variable name="genInPredicateFunction">
function In(state){
state = typeof state == "string" ? self._states[state] : state;
-
- return state.isBasic ?
- currentConfiguration.indexOf(<value-of select="$inPredicateFunctionStateReference"/>) != -1 :
- currentConfiguration.some(function(s){
- return <value-of select="$inPredicateFunctionStateIdReference"/>.ancestors.indexOf(state) != -1;
- });
+
+ var toReturn;
+
+ if(state.isBasic){
+ toReturn = currentConfiguration.indexOf(<value-of select="$inPredicateFunctionStateReference"/>) != -1;
+ }else{
+ <call-template name="genSome">
+ <with-param name="returnVarName" select="'toReturn'"/>
+ <with-param name="var" select="'s'"/>
+ <with-param name="in" select="'currentConfiguration'"/>
+ <with-param name="when">
+ <value-of select="$inPredicateFunctionStateIdReference"/>
+ .ancestors.indexOf(state) != -1
+ </with-param>
+ </call-template>
+ }
+
+ return toReturn;
}
</variable>