commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbe...@apache.org
Subject svn commit: r986384 - /commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractStatechartGenerator.xsl
Date Tue, 17 Aug 2010 16:45:33 GMT
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>



Mime
View raw message