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/16 07:42:28 UTC

svn commit: r985795 - in /commons/sandbox/gsoc/2010/scxml-js/trunk/src: javascript/scxml/cgf/SCXMLCompiler.js javascript/scxml/cgf/main.js xslt/backends/js/AbstractStatechartGenerator.xsl

Author: jbeard
Date: Mon Aug 16 05:42:28 2010
New Revision: 985795

URL: http://svn.apache.org/viewvc?rev=985795&view=rev
Log:
Previous change made generated code use Array.filter method, which broke IE. Added new compatibility code. All ahead-of-time, in-browser unit tests pass, as well as tests with rhino.

Modified:
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/SCXMLCompiler.js
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/main.js
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractStatechartGenerator.xsl

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/SCXMLCompiler.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/SCXMLCompiler.js?rev=985795&r1=985794&r2=985795&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/SCXMLCompiler.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/SCXMLCompiler.js Mon Aug 16 05:42:28 2010
@@ -51,7 +51,7 @@ require.def("src/javascript/scxml/cgf/SC
 			if(!options.inFiles) return false;
 
 			if(options.ie){
-				options.noMap = options.noForEach = options.noIndexOf = options.noSome = true;
+				options.noMap = options.noForEach = options.noIndexOf = options.noSome = options.noFilter = true;
 			}
 
 			var backendModuleToImport = 

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/main.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/main.js?rev=985795&r1=985794&r2=985795&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/main.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/main.js Mon Aug 16 05:42:28 2010
@@ -48,6 +48,7 @@ require.def("src/javascript/scxml/cgf/ma
 				noForEach : true,
 				noIndexOf : true,
 				noMap : true,
+				noFilter : true,
 				beautify : true,
 				log : true,
 				verbose :  true,

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=985795&r1=985794&r2=985795&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 Mon Aug 16 05:42:28 2010
@@ -27,6 +27,7 @@
 	<param name="noMap" select="false()"/>
 	<param name="noForEach" select="false()"/>
 	<param name="noSome" select="false()"/>
+	<param name="noFilter" select="false()"/>
 
 	<!-- these variables get overridden by subclasses -->
 	<variable name="enumeratedEventDispatchInvocation"/>
@@ -98,6 +99,10 @@
 			<call-template name="genNoSomeArrayPrototypeExtension"/>
 		</if>
 
+		<if test="$noFilter">
+			<call-template name="genNoFilterArrayPrototypeExtension"/>
+		</if>
+
 		function <value-of select="@name"/>StatechartExecutionContext(){
 
 				var self = this;	//used in the rare occasions we call public functions from inside this class
@@ -979,6 +984,18 @@
 		}
 	</template>
 
+	<template name="genNoFilterArrayPrototypeExtension">
+		if(!Array.filter){
+			Array.prototype.filter = function(fn){
+				var toReturn = [];
+				for(var i=0; i &lt; this.length; i++){
+					if(fn(this[i])) toReturn.push(this[i]);
+				}
+				return toReturn;
+			}
+		}
+	</template>
+
 	<variable name="genInPredicateFunction">
 		function In(state){
 			state = typeof state == "string" ? self._states[state] : state;