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:33 UTC

svn commit: r986384 - /commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractStatechartGenerator.xsl

Author: jbeard
Date: Tue Aug 17 16:45:33 2010
New Revision: 986384

URL: http://svn.apache.org/viewvc?rev=986384&view=rev
Log:
Replaced functional filter expression.

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=986384&r1=986383&r2=986384&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:33 2010
@@ -93,6 +93,31 @@
 	
 	</template>
 
+	<template name="genFilter">
+		<param name="returnArrayVarName"/>
+
+		<param name="var"/>
+		<param name="in"/>
+		<param name="when"/>
+		<param name="iteratorVarName" select="$defaultIteratorVarName"/>
+		<param name="hoistVarName" select="$defaultHoistVarName"/>
+
+		var <value-of select="$returnArrayVarName"/> = [];
+
+		<call-template name="genForEach">
+			<with-param name="var" select="$var"/>
+			<with-param name="in" select="$in"/>
+			<with-param name="when" select="$when"/>
+			<with-param name="iteratorVarName" select="$iteratorVarName"/>
+			<with-param name="hoistVarName" select="$hoistVarName"/>
+
+			<with-param name="do">
+				<value-of select="$returnArrayVarName"/>.push(<value-of select="$var"/>);
+			</with-param>
+		</call-template>
+	
+	</template>
+
 	<!-- helper template to safely get a state's parent's name -->
 	<template name="getParentNameFromState">
 		<param name="s"/>
@@ -729,10 +754,17 @@
 					currentConfiguration =  <value-of select="$historyStateReference"/>.lastConfiguration.slice();
 				</when>
 				<otherwise>
-					newConfiguration = newConfiguration.concat(currentConfiguration.filter(function(state) {
-						return <value-of select="$genHistoryTriggerDispatcherInnerForEachStateReference"/>
-							.ancestors.indexOf(historyStateParent) == -1
-					}))
+					<call-template name="genFilter">
+						<with-param name="returnArrayVarName" select="'filteredConfiguration'"/>
+						<with-param name="var" select="'state'"/>
+						<with-param name="in" select="'currentConfiguration'"/>
+						<with-param name="when">
+							<value-of select="$genHistoryTriggerDispatcherInnerForEachStateReference"/>
+								.ancestors.indexOf(historyStateParent) == -1
+						</with-param>
+					</call-template>
+
+					newConfiguration = newConfiguration.concat(filteredConfiguration)
 
 					currentConfiguration = <value-of select="$genHistoryTriggerDispatcherCurrentConfigurationAssignmentRHS"/>;
 				</otherwise>