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/06/27 04:11:45 UTC
svn commit: r958312 - in /commons/sandbox/gsoc/2010/scxml-js/trunk: ./
src/javascript/scxml/cgf/ src/javascript/scxml/cgf/util/
src/xslt/backends/js/ test/in_predicate/ test/in_predicate/scripts/
Author: jbeard
Date: Sun Jun 27 02:11:45 2010
New Revision: 958312
URL: http://svn.apache.org/viewvc?rev=958312&view=rev
Log:
Merged branch SCXML-140 back into trunk.
Added:
commons/sandbox/gsoc/2010/scxml-js/trunk/test/in_predicate/
- copied from r958311, commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-140/test/in_predicate/
commons/sandbox/gsoc/2010/scxml-js/trunk/test/in_predicate/TestInPredicate.xml
- copied unchanged from r958311, commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-140/test/in_predicate/TestInPredicate.xml
commons/sandbox/gsoc/2010/scxml-js/trunk/test/in_predicate/scripts/
- copied from r958311, commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-140/test/in_predicate/scripts/
commons/sandbox/gsoc/2010/scxml-js/trunk/test/in_predicate/scripts/unitTest.js
- copied unchanged from r958311, commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-140/test/in_predicate/scripts/unitTest.js
Modified:
commons/sandbox/gsoc/2010/scxml-js/trunk/ (props changed)
commons/sandbox/gsoc/2010/scxml-js/trunk/build.js
commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/SCXMLCompiler.js
commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/util/base.js
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractEnumeratedStatechartGenerator.xsl
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractStatechartGenerator.xsl
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StatePatternStatechartGenerator.xsl
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StateTableStatechartGenerator.xsl
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/SwitchyardStatechartGenerator.xsl
Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Jun 27 02:11:45 2010
@@ -1,3 +1,4 @@
/commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-138-139:958222
+/commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-140:958231-958311
/commons/sandbox/gsoc/2010/scxml-js/branches/browser-tests.1.ie:954350-956951
/commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137:957703-958221
Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/build.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/build.js?rev=958312&r1=958311&r2=958312&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/build.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/build.js Sun Jun 27 02:11:45 2010
@@ -77,7 +77,7 @@ require.def("build",
KitchenSink_performance :"test/kitchen_sink/KitchenSink_performance.xml",
KitchenSink_executableContent :"test/kitchen_sink/KitchenSink_executableContent.xml",
ConditionalTransition :"test/conditional_transition/TestConditionalTransition.xml",
- ConditionalTransition_executableContent :"test/conditional_transition/TestConditionalTransition_executableContent.xml"
+ InPredicate :"test/in_predicate/TestInPredicate.xml"
}
//FIXME: this violates Don't Repeat Yourself; these paths are written here and in the module
@@ -107,7 +107,7 @@ require.def("build",
"test/kitchen_sink/scripts/unitTest",
"test/kitchen_sink/scripts/unitTest_executableContent",
"test/conditional_transition/scripts/unitTest",
- "test/conditional_transition/scripts/unitTest"
+ "test/in_predicate/scripts/unitTest"
]
//gets populated at run-time
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=958312&r1=958311&r2=958312&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 Sun Jun 27 02:11:45 2010
@@ -54,7 +54,7 @@ require.def("src/javascript/scxml/cgf/SC
if(!options.inFiles) return false;
if(options.ie){
- options.noMap = options.noForEach = options.noIndexOf = true;
+ options.noMap = options.noForEach = options.noIndexOf = options.noSome = true;
}
var backendModuleToImport =
Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/util/base.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/util/base.js?rev=958312&r1=958311&r2=958312&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/util/base.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/util/base.js Sun Jun 27 02:11:45 2010
@@ -31,5 +31,14 @@ function(){
return undefined;
}
}
+
+ if(!Array.some){
+ Array.prototype.some = function(fn){
+ for(var i=0; i < this.length; i++){
+ if(fn(this[i])) return true;
+ }
+ return false;
+ }
+ }
});
Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractEnumeratedStatechartGenerator.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractEnumeratedStatechartGenerator.xsl?rev=958312&r1=958311&r2=958312&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractEnumeratedStatechartGenerator.xsl (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractEnumeratedStatechartGenerator.xsl Sun Jun 27 02:11:45 2010
@@ -22,15 +22,18 @@
<import href="AbstractStatechartGenerator.xsl"/>
- <param name="defaultEventLiteral" select="'$default'"/>
- <param name="currentConfigurationExpression"
+ <variable name="defaultEventLiteral" select="'$default'"/>
+ <variable name="currentConfigurationExpression"
select="'currentConfiguration.map(function(s){return STATE_INT_ID_TO_OBJECT_MAP[s]})'"/>
+ <variable name="inPredicateFunctionStateReference" select="'state.id'"/>
+ <variable name="inPredicateFunctionStateIdReference" select="'STATE_INT_ID_TO_OBJECT_MAP[s]'"/>
+
- <param name="genHistoryTriggerDispatcherCurrentConfigurationAssignmentRHS"
+ <variable name="genHistoryTriggerDispatcherCurrentConfigurationAssignmentRHS"
select="'newConfiguration.map(function(sObj){return sObj.id})'"/>
- <param name="genHistoryTriggerDispatcherInnerForEachStateReference"
+ <variable name="genHistoryTriggerDispatcherInnerForEachStateReference"
select="'STATE_INT_ID_TO_OBJECT_MAP[state]'"/>
- <param name="genNonBasicTriggerDispatcherExitBlockIteratorExpression"
+ <variable name="genNonBasicTriggerDispatcherExitBlockIteratorExpression"
select="'currentConfiguration.map(function(state){return STATE_INT_ID_TO_OBJECT_MAP[state]})'"/>
@@ -215,6 +218,7 @@
<template name="genStateHooks"/>
<template name="genEnumeratedHooks"/>
<template name="genTriggerIntEnum"/>
+
</stylesheet>
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=958312&r1=958311&r2=958312&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 Sun Jun 27 02:11:45 2010
@@ -25,16 +25,19 @@
<param name="noIndexOf" select="false()"/>
<param name="noMap" select="false()"/>
<param name="noForEach" select="false()"/>
+ <param name="noSome" select="false()"/>
<param name="name"/>
- <!-- these params get overridden by subclasses -->
- <param name="dispatchInvocation"/>
- <param name="currentConfigurationExpression"/>
- <param name="defaultEventLiteral"/>
+ <!-- these variables get overridden by subclasses -->
+ <variable name="dispatchInvocation"/>
+ <variable name="currentConfigurationExpression"/>
+ <variable name="defaultEventLiteral"/>
+ <variable name="inPredicateFunctionStateReference"/>
+ <variable name="inPredicateFunctionStateIdReference"/>
<!-- TODO: refactor these names-->
- <param name="genHistoryTriggerDispatcherCurrentConfigurationAssignmentRHS"/>
- <param name="genHistoryTriggerDispatcherInnerForEachStateReference"/>
- <param name="genNonBasicTriggerDispatcherExitBlockIteratorExpression"/>
+ <variable name="genHistoryTriggerDispatcherCurrentConfigurationAssignmentRHS"/>
+ <variable name="genHistoryTriggerDispatcherInnerForEachStateReference"/>
+ <variable name="genNonBasicTriggerDispatcherExitBlockIteratorExpression"/>
<!-- main variables -->
<variable name="allStates"
@@ -75,6 +78,10 @@
<call-template name="genNoForEachArrayPrototypeExtension"/>
</if>
+ <if test="$noSome">
+ <call-template name="genNoSomeArrayPrototypeExtension"/>
+ </if>
+
function <value-of select="$name"/>StatechartExecutionContext(){
var self = this; //used in the rare occasions we call public functions from inside this class
@@ -119,6 +126,7 @@
//start static boilerplate code
<call-template name="genBoilerplateDispatchCode"/>
+ <value-of select="$genInPredicateFunction"/>
}
</template>
@@ -177,6 +185,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>
@@ -438,6 +471,11 @@
return <value-of select="$currentConfigurationExpression"/>;
}
+ //public API for In predicate
+ this.$in = function(state){
+ return In(state);
+ }
+
//end static boilerplate code
</template>
@@ -716,6 +754,28 @@
}
</template>
+ <template name="genNoSomeArrayPrototypeExtension">
+ if(!Array.some){
+ Array.prototype.some = function(fn){
+ for(var i=0; i < this.length; i++){
+ if(fn(this[i])) return true;
+ }
+ return false;
+ }
+ }
+ </template>
+
+ <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;
+ });
+ }
+ </variable>
<template name="genContextHooks"/>
<template name="genStateHooks"/>
@@ -725,5 +785,6 @@
<template name="genInitialization"/>
<template name="genTriggerDispatcherContext"/>
+
</stylesheet>
Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StatePatternStatechartGenerator.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StatePatternStatechartGenerator.xsl?rev=958312&r1=958311&r2=958312&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StatePatternStatechartGenerator.xsl (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StatePatternStatechartGenerator.xsl Sun Jun 27 02:11:45 2010
@@ -22,14 +22,15 @@
<import href="AbstractStatechartGenerator.xsl"/>
- <!-- these params get overridden by subclasses -->
- <param name="dispatchInvocation" select="'state[e]();'"/>
- <param name="defaultEventLiteral" select="'"$default"'"/>
- <param name="currentConfigurationExpression" select="'currentConfiguration.slice()'"/>
-
- <param name="genHistoryTriggerDispatcherCurrentConfigurationAssignmentRHS" select="'newConfiguration'"/>
- <param name="genHistoryTriggerDispatcherInnerForEachStateReference" select="'state'"/>
- <param name="genNonBasicTriggerDispatcherExitBlockIteratorExpression" select="'currentConfiguration'"/>
+ <variable name="dispatchInvocation" select="'state[e]();'"/>
+ <variable name="defaultEventLiteral" select="'"$default"'"/>
+ <variable name="currentConfigurationExpression" select="'currentConfiguration.slice()'"/>
+ <variable name="inPredicateFunctionStateReference" select="'state'"/>
+ <variable name="inPredicateFunctionStateIdReference" select="'s'"/>
+
+ <variable name="genHistoryTriggerDispatcherCurrentConfigurationAssignmentRHS" select="'newConfiguration'"/>
+ <variable name="genHistoryTriggerDispatcherInnerForEachStateReference" select="'state'"/>
+ <variable name="genNonBasicTriggerDispatcherExitBlockIteratorExpression" select="'currentConfiguration'"/>
<template name="genStateHooks">
<param name="state"/>
Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StateTableStatechartGenerator.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StateTableStatechartGenerator.xsl?rev=958312&r1=958311&r2=958312&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StateTableStatechartGenerator.xsl (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StateTableStatechartGenerator.xsl Sun Jun 27 02:11:45 2010
@@ -22,7 +22,7 @@
<import href="AbstractEnumeratedStatechartGenerator.xsl"/>
- <param name="dispatchInvocation" select="'STATE_TRANSITION_TABLE[state][e]();'"/>
+ <variable name="dispatchInvocation" select="'STATE_TRANSITION_TABLE[state][e]();'"/>
<variable name="nullTransitionFunctionName" select="'$nt'"/>
Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/SwitchyardStatechartGenerator.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/SwitchyardStatechartGenerator.xsl?rev=958312&r1=958311&r2=958312&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/SwitchyardStatechartGenerator.xsl (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/SwitchyardStatechartGenerator.xsl Sun Jun 27 02:11:45 2010
@@ -22,7 +22,7 @@
<import href="AbstractEnumeratedStatechartGenerator.xsl"/>
- <param name="dispatchInvocation" select="'dispatch(state,e)'"/>
+ <variable name="dispatchInvocation" select="'dispatch(state,e)'"/>
<template name="genEnumeratedHooks">
//state transition table