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/05/21 19:49:10 UTC

svn commit: r947090 [2/4] - in /commons/sandbox/gsoc/2010/scxml-js/trunk: ./ lib/ lib/java/ lib/js/ lib/test-java/ lib/test-js/ src/ src/scxml/ src/scxml/cgf/ src/scxml/cgf/js/ src/scxml/cgf/util/ test/ test/kitchen_sink/ test/kitchen_sink/doc/ test/ki...

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/SCXMLCompiler.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/SCXMLCompiler.js?rev=947090&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/SCXMLCompiler.js (added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/SCXMLCompiler.js Fri May 21 17:49:09 2010
@@ -0,0 +1,342 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+SCXMLCompiler is a singleton object which serves as a a backend-agnostic 
+entry-point to the compiler for both command-line and browser environments
+(although right now it only works in the command-line environment).
+It takes as input a map of compiler options, extracts information out of
+the SCXML input documents, and passes this configuration into the 
+chosen backend, then returns a string or string array of compiled
+code.  
+*/ 
+
+require.def("src/scxml/cgf/SCXMLCompiler",
+	["src/scxml/cgf/util",
+	"src/scxml/cgf/js/SwitchyardStatechartGenerator",
+	"src/scxml/cgf/js/StateTableStatechartGenerator",
+	"src/scxml/cgf/js/StatePatternStatechartGenerator",
+	"lib/js/beautify.js"],
+	function(util,
+		SwitchyardStatechartGenerator,
+		StateTableStatechartGenerator,
+		StatePatternStatechartGenerator){
+
+		//set the default xml namespace
+		msdlNs = "http://msdl.cs.mcgill.ca/";
+		msdl = new Namespace(msdlNs);
+
+		//default xml namespace = "http://www.w3.org/2005/07/scxml"
+
+		function parseSCXML(scxmlString){
+			return new XML(scxmlString.replace(/^<\?xml\s+version\s*=\s*(["'])[^\1]+\1[^?]*\?>/, "").replace(/^\s+|\s+$/g,"")); // bug 336551
+		}
+
+		function makeLegalLValue(name){
+			return name.toString().replace(/[\.:]/g,"_");
+		}
+
+		function getOuterNodes(node){
+			/*
+				Returns a list representing the containment hierarchy of
+				node.  node is always the first element, and its outermost
+				parent is the last.
+			*/
+			var toReturn = [node];
+			var currentNode = node;
+			while(currentNode = currentNode.parent()){
+				toReturn.push(currentNode);
+			}
+
+			return toReturn;
+		}
+
+
+		function getTransitionPath(allStates,startnode,endnode){
+			/*
+			Computes the states that must be exited and entered if the
+			system is to make a transition from 'startnode' to 'endnode'.
+			These ordered lists are returned in a tuple, (exitedNodes,
+			enteredNodes).
+			*/
+
+			//first get the ancestors of each node
+			var startAncestors=getOuterNodes(startnode);
+			var endAncestors=getOuterNodes(endnode);
+
+			//now find the scope of the transition (lowest common proper ancestor)
+			var LCA=null;
+			while(!(startAncestors[startAncestors.length-1] === startnode ||
+					  endAncestors[endAncestors.length-1] === endnode ||
+					  startAncestors[startAncestors.length-1] !=
+						endAncestors[endAncestors.length-1])){
+				LCA=startAncestors.pop()
+				endAncestors.pop()
+			}
+
+			/*
+			the states to be exited are all proper descendants of the scope
+			in which currentState resides the states to be entered are all
+			the proper descendants of the scope in which the final basic
+			state resides
+			*/
+			var enterpath, exitpath;
+			if(LCA){
+				// last element (LCA) is not included in slice
+				var currentnode;
+				exitpath = [startnode];
+				currentnode = startnode;
+				while((currentnode = currentnode.parent())!=LCA){
+					exitpath.push(currentnode);
+				}
+
+				enterpath = [endnode];
+				currentnode = endnode;
+
+				while((currentnode = currentnode.parent())!=LCA){
+					enterpath.push(currentnode);
+				}
+
+				enterpath.reverse();
+			}
+
+			return [enterpath,exitpath,LCA];
+		}
+
+		/*
+		    supported options:
+				backend	{switch | table | state}
+				ie
+				noForEach	
+				noIndexOf
+				noMap	
+				beautify	
+				log
+				verbose
+		*/
+		function compile(options){
+
+			if(!options.inFiles) return false;
+
+			var toReturn = options.inFiles.map(function(xmlFile){
+
+				if(options.ie){
+					options.noForEach = options.noIndexOf = true;
+					options.noMap = true;
+				}
+
+				var scxmlRoot = parseSCXML(readFile(xmlFile));
+
+				//do a bit of verification and normalization transformations
+
+				//make all names we will use for variables legal
+				scxmlRoot..transition.(@event.length() && (@event = makeLegalLValue(@event)));
+
+				//make sure root has an id
+				scxmlRoot.@id = "Root"
+
+				//normalize initial states
+				util.foreach(scxmlRoot..*.(@initial.length() > 0),function(s){
+					s.initial.transition.@target = s.@initial.toString();
+					delete s.@initial;
+				});
+
+				//make sure all transitions have id's
+				//var transitionid = 0;
+				//scxml..transition.(!@id.length() && (@id = "transition_" + transitionid++));
+
+				//we use both a dictionary and an array so that we can use both forEach and "in", which makes the code pretty
+				var stateTagsArray = ["state", "parallel" , "final" , "initial" , "scxml" , "history" ];
+				var stateTagsHash = {}
+				stateTagsArray.forEach(function(s){stateTagsHash[s] = true});
+
+				//precompute some stuff which we will need later
+				var conf = {
+					scxml : scxmlRoot,
+					allStates : scxmlRoot + scxmlRoot..*.(localName() in stateTagsHash),
+					states : scxmlRoot..state, 
+					parallels : scxmlRoot..parallel,
+					finals  : scxmlRoot.descendants("final"), 
+					initials : scxmlRoot..initial, 
+					transitions : scxmlRoot..transition,
+					defaultTransitions : scxmlRoot..transition.(@event.length() == 0),
+					nonDefaultTransitions : scxmlRoot..transition.(@event.length() > 0),
+					name : scxmlRoot.@name,
+					noForEach : options.noForEach,
+					noIndexOf : options.noIndexOf,
+					noMap : options.noMap,
+					log : options.log
+				}
+
+				conf.basicStates = conf.allStates.(stateTagsArray.every(
+							function(s){
+								return descendants(s).length() == 0
+							}));
+
+				conf.compositeStates = conf.allStates.(stateTagsArray.some(
+							function(s){
+								return descendants(s).length() > 0
+							}));
+
+				conf.parallelRegions = conf.parallels.state;
+
+				conf.basicParallelStates = conf.parallelRegions..*.(localName() in stateTagsHash).(stateTagsArray.every(
+							function(s){
+								return descendants(s).length() == 0
+							}));
+
+				conf.parallelsAndDescendantStates = conf.parallels + conf.parallels..*.(localName() in stateTagsHash);
+
+				/*
+				//then we need to know basic states that are descendants of parallel regions, vs. basic states that are not.
+				//might be best to try to formulate this as one query, as we cannot search ancestors.
+				//need to think about this in terms of finding parents first
+				conf.basicNonParallelStates = foreach(conf.basicStates,function(s){
+					if(conf.parallels.descendants().contains(s)){
+						return s;
+					}
+					else{
+						return <></>;
+					}
+				});
+				*/
+
+				//make sure all states have id's
+				var idNum = 0;
+				util.foreach(conf.allStates.(@id.length() == 0),function(s){
+					while(true){
+						//we want initial states to be named by a slightly different convention
+						var newId  = s.localName() == "initial" ? 
+										s.parent().@id + "_Initial" + idNum++ :
+										s.localName() + idNum++;
+						if(!conf.allStates.(@id == newId).length()){
+							//he is unique
+							s.@id = newId;
+							break;
+						}
+					}
+				});
+
+				//very important transformation to allow the use of ortho regions: 
+				//we take transition target attribute, which can contain multiple space-delimited targets
+				//and split it up into multiple elements stored as children under the transition under our
+				//namespace.
+				//This allows us to treat transition targets generally and uniformly in our compiler.
+				util.foreach(conf.transitions,function(t){
+					var targetIds = t.@target.toString().split(" ");
+
+					targetIds.forEach(function(targetId){
+						t.msdl::targets.msdl::target += <target xmlns={msdlNs}><targetState>{targetId}</targetState></target>;
+					});
+				});
+
+
+				//change transitions that point to non-basic states to point instead to the initial states
+				//note that we only change the transitions stored in our custom-namespaced elements, so this
+				//is still legal SCXML
+				util.foreach(conf.transitions,function(t){
+						util.foreach(t.msdl::targets.msdl::target,function(targetNode){
+							var target = conf.allStates.(@id == targetNode.msdl::targetState.text());
+							
+							//if he is a composite, update the transition to point to his initial state
+							if(conf.compositeStates.contains(target)){
+								targetNode.msdl::targetState.setChildren(target.initial.@id.toString());
+							}
+						});
+				});
+				
+
+				//augment our AST to allow easy retrieval of enter and exit states from transitions
+				util.foreach(conf.transitions,function(t){
+
+					var startnode = t.parent();
+					var exitpath, lca;
+
+					util.foreach(t.msdl::targets.msdl::target,function(targetNode){
+
+						var endnode = conf.allStates.(@id == targetNode.msdl::targetState.text());
+
+						var enterpath;
+						[enterpath, exitpath, lca] = getTransitionPath(conf.allStates,startnode,endnode);
+
+						if(enterpath){
+							enterpath.forEach(function(state){
+								targetNode.msdl::enterpath.msdl::state += state.@id;
+							});
+						}
+						
+					});
+
+					if(exitpath){
+						exitpath.forEach(function(state){
+							t.msdl::exitpath.msdl::state += state.@id;
+						});
+					}
+
+					if(lca){
+						t.msdl::lca = lca.@id;
+					}
+
+				});
+
+
+				//we do lazy loading here. I mean, why not?
+				var generatorConstructor;
+				switch(options.backend){
+					case "switch":
+						generatorConstructor = SwitchyardStatechartGenerator;
+						break;
+					case "table":
+						generatorConstructor = StateTableStatechartGenerator;
+						break;
+					case "state":
+						generatorConstructor = StatePatternStatechartGenerator;
+						break;
+					default:
+						print("Unknown backend specified: " + options.backend);
+				}
+
+				var scg = new generatorConstructor(conf);
+				var sc = scg.genStatechart(conf);
+
+				if(options.beautify){
+					sc = js_beautify(sc.toString().replace(/^\s+/, ''),{});
+				}
+
+				//print(scxml);
+				if(options.verbose) print(sc);
+
+				//TODO: write to specified file
+
+				//return generated statechart as a string
+				return sc;
+			});
+			
+			if(toReturn.length == 1){
+				return toReturn[0];
+			}else{
+				return toReturn;
+			}
+		};
+
+		return {
+			compile : compile
+		}
+
+	}
+);
+

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/SCXMLCompiler.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/js/AbstractEnumeratedStatechartGenerator.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/js/AbstractEnumeratedStatechartGenerator.js?rev=947090&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/js/AbstractEnumeratedStatechartGenerator.js (added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/js/AbstractEnumeratedStatechartGenerator.js Fri May 21 17:49:09 2010
@@ -0,0 +1,270 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+require.def("src/scxml/cgf/js/AbstractEnumeratedStatechartGenerator",
+		["src/scxml/cgf/util",
+			"src/scxml/cgf/js/AbstractStatechartGenerator"],
+		function(util,AbstractStatechartGenerator){
+			return function(conf){
+				var self = this;
+
+				//augment the AST so that we know what each transtion will be called
+				util.foreach(conf.transitions,function(t){
+					var tName = t.parent().@id.toString() + "_" + (t.@event.length() == 0 ? "$default" : t.@event.toString());
+					t.@msdl::tName = tName;
+				});
+
+
+				//flatten transitions
+				//FIXME: I wish there was some way to express this more elegantly, without all of these util.foreach statements.
+				//I think this is probably really expensive
+				util.foreach(conf.transitions,function(t){
+					var origin = t.parent();
+					if(!conf.basicStates.contains(origin)){
+						//for each basic state, if the state does not have a transition with the same event, copy the transition into him
+						util.foreach(origin..state,function(d){
+							if(conf.basicStates.contains(d) && !d.transition.@event.contains(t.@event)){
+								d.transition += t.copy();
+							}
+						});
+
+						//delete the transition off of the composite state
+						delete origin.children()[t.childIndex()];
+					}
+				});
+
+				//recompute the transitions
+				conf.transitions = conf.scxml..transition;
+				conf.defaultTransitions = conf.transitions.(@event.length() == 0);
+				conf.nonDefaultTransitions = conf.transitions.(@event.length() > 0);
+
+				//number the basic states
+				var stateNum = 0;
+				self.stateIdMap = {};
+				util.foreach(conf.basicStates,function(s){
+					var stateName = s.@id.toString();
+					if (!(stateName  in self.stateIdMap )){
+						self.stateIdMap[stateName]=stateNum++;
+					}
+					s.msdl::enumId = stateName + "_id"; 
+				});
+				//util.foreach(conf.basicStates,function(s){s.@msdl::sNum = stateNum++})
+
+				//number the events
+				var tNum = 1;	//start at 1. 0 is default state
+				self.eventIdMap = {};
+				self.eventIdList = ["$default"];
+				self.eventIdMap["$default"] = 0;
+				util.foreach(conf.transitions,function(t){
+					var ev = t.@event.toString()
+					if (ev.length && !(ev in self.eventIdMap)){
+						self.eventIdMap[ev]=tNum;
+						self.eventIdList[tNum] = ev;
+						tNum++;
+					}
+				});
+
+				conf.defaultEventLiteral = '$default';
+				conf.currentConfigurationExpression = "currentConfiguration.map(function(s){return STATE_INT_ID_TO_OBJECT_MAP[s]})"
+
+				AbstractStatechartGenerator.apply(this,[conf]);
+
+				self.genContextHooks = function(){
+					return <>
+						//enumeration of states int id's
+						{util.foreach(conf.basicStates,function(s){
+							return "var " + s.msdl::enumId + "=" + self.stateIdMap[s.@id.toString()] +";";
+						})}
+
+						//map from states int id's to objects
+						var STATE_INT_ID_TO_OBJECT_MAP = [{util.foreach(conf.basicStates,function(state){
+							return state.@id + ","
+						}).slice(0,-1)}];
+
+						//tag each state object with an int id to map from object to id
+						//only needed for history
+						{util.foreach(conf.basicStates,function(state){
+							return state.@id + ".id = " + self.stateIdMap[state.@id.toString()] + ";"
+						})}
+
+						//enumeration of triggers
+						{self.eventIdList.map(function(ev){
+							return "var " + ev + "=" + self.eventIdMap[ev] +";";
+						}).join("\n")}
+
+						//expose them as a convenient interface as part of the API
+						{self.genTriggerExternalObject()}
+
+						//needed for debugging
+						{self.genTriggerIdToNameMap()}
+
+						//transition functions
+						{util.foreach(conf.transitions,function(transition){return self.genStateTriggerDispatcher(transition.parent(),transition)})}
+
+						{self.genEnumeratedHooks()}
+
+					</>
+				}
+
+				//this should be overrridden by subclasses
+				self.genEnumeratedHooks = function(){
+					return "";
+				}
+
+				//@override
+				self.genTriggerDispatcherContext = function (params,s,t){
+					return <>
+						var {t.@msdl::tName} = function()&#x7B;
+							{params.isHistory ? 
+								self.genHistoryTriggerDispatcher(params,s,t) : 
+								self.genTriggerDispatcherContents(params,s,t) }
+						&#x7D;
+					</>
+				}
+
+
+				//enumeration of triggers
+				self.genTriggerIntEnum = function(){
+					return "";
+				}
+
+				//expose them as a convenient interface as part of the API
+				self.genTriggerExternalObject = function(){
+					return <>
+						this.TRIGGERS = &#x7B; {self.eventIdList.map(function(ev){
+							return ev + ":" + ev ;
+						}).join(",")}
+						&#x7D;;
+					</>
+
+				}
+
+				//needed for debugging
+				self.genTriggerIdToNameMap = function(){
+					return <>
+						var TRIGGER_ID_TO_NAME_MAP = [
+														{self.eventIdList.map(function(ev){
+														return '"' + ev + '"';
+														}).join(",")}
+													];
+					</>;
+				}
+
+				self.genStateTransitionTable = function(){
+					return 'var STATE_TRANSITION_TABLE = [' + self.transitionTable.map(function(row){
+						return '[' +row.map(function(action){
+							if(action){
+								return action.toString();
+							}
+							else return "$nt";
+						}).join(',') +']\n';
+					}).join(',') + ']';
+				}
+
+				self.genExternalTriggerDispatcher = function(t){
+					return <>
+						this.{t.@event} = function()&#x7B;
+							if(isInStableState)&#x7B;
+								runToCompletion({t.@event});
+							&#x7D;else&#x7B;
+								return undefined;
+							&#x7D;
+						&#x7D;
+					</>;
+				}
+
+				self.genNonParallelSubstateConfigurationSetString = function(s,t){
+					return <>
+								currentConfiguration = [{util.foreach(t.msdl::targets
+																.msdl::target
+																.msdl::targetState,function(s){
+																	return conf.allStates.(@id == s.toString()).msdl::enumId.toString() + ","}).slice(0,-1)}]; 
+					</>
+				}
+
+				self.genParallelSubstateConfigurationSetString = function(s,t){
+					return <>
+								currentConfiguration.splice(currentConfiguration.indexOf({s.msdl::enumId.toString()}),1,
+										{util.foreach(t.msdl::targets
+													.msdl::target
+													.msdl::targetState,function(s){
+														return conf.allStates.(@id == s.toString()).msdl::enumId.toString() + ","}).slice(0,-1)}); 
+					</>
+				}
+
+
+				self.genInitialization = function(){
+					//we just need to know what the initial state is
+					var initialStateName = conf.allStates.(@id == conf.
+											scxml.
+											initial.
+											transition.
+											msdl::targets.
+											msdl::target.
+											msdl::targetState.
+											toString()).msdl::enumId.toString();
+
+					return <>
+						this.initialize = function()&#x7B;
+							currentConfiguration = [{initialStateName}];
+							runToCompletion();
+							mainLoop();
+						&#x7D;
+					</>;
+				}
+
+
+				self.genSend = function(send){
+					var toReturn="";
+
+					if(send.length()){
+						var sendEvent = send.@event.toString();
+						var sendDelay = parseInt(send.@delay.toString());	//fixme: not sure what the units are
+
+						if(sendDelay){
+							//set timeout
+							toReturn =  <>
+							window.setTimeout(function()&#x7B;
+								self.GEN({sendEvent});
+							&#x7D;,{sendDelay*1000});
+								</>
+						}else{
+							//just add the event to the outer queue
+							toReturn = <>
+								innerEventQueue.push({sendEvent});
+								</>
+						}
+					}
+
+					return toReturn;
+				}
+
+				self.genHistoryTriggerDispatcherCurrentConfigurationAssignmentRHS = function(){
+					return "newConfiguration.map(function(sObj){return sObj.id})";
+				}
+
+				self.genHistoryTriggerDispatcherHistoryStateReference = function(s){
+					return s.@id
+				}
+
+				self.genHistoryTriggerDispatcherInnerForEachStateReference = function(){
+					return "STATE_INT_ID_TO_OBJECT_MAP[state]";
+				}
+
+			}
+		}
+);

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/js/AbstractEnumeratedStatechartGenerator.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/js/AbstractStatechartGenerator.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/js/AbstractStatechartGenerator.js?rev=947090&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/js/AbstractStatechartGenerator.js (added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/js/AbstractStatechartGenerator.js Fri May 21 17:49:09 2010
@@ -0,0 +1,523 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+require.def("src/scxml/cgf/js/AbstractStatechartGenerator",
+		["src/scxml/cgf/util"],
+		function(util){
+			return function(conf){
+				var self = this;
+
+				self.genStatechart = function(){
+					return self.genContext();
+				}
+
+				self.genContext = function(){
+					return <>
+
+						{conf.noIndexOf ? self.genNoIndexOfArrayPrototypeExtension() : ""}
+					
+						{conf.noMap ? self.genNoMapArrayPrototypeExtension() : ""}
+
+						function {conf.name}StatechartExecutionContext()&#x7B;
+
+							var self = this;	//used in the rare occasions we call public functions from inside this class
+
+							//abstract state
+							{self.genAbstractState(conf.nonDefaultTransitions.@event)}
+
+							//states
+							{util.foreach(conf.allStates, self.genState)}
+
+							//states enum for glass-box unit testing
+							{self.genStatesEnum(conf.basicStates)}
+
+							//trigger methods for synchronous interaction
+							{util.foreach(conf.nonDefaultTransitions,self.genExternalTriggerDispatcher)}
+
+							{self.genContextHooks()}
+
+							//initialization method
+							{self.genInitialization()}
+
+							//internal runtime functions
+							{self.genInternalRuntimeFunctions()}
+
+							//start static boilerplate code
+							{self.genBoilerplateDispatchCode(conf.dispatchInvocation)}
+
+						&#x7D;
+					</>
+				}
+
+				//abstract methods that we expect to be refined in subclasses
+				self.genContextHooks = function(){
+					return "";
+				}
+
+				self.genStateHooks = function(state){
+					return ""
+				}
+
+				self.genExternalTriggerDispatcher = function(t){
+					return "";
+				}
+
+
+				self.genParallelSubstateConfigurationSetString = function(s,t){
+					return "";
+				}
+
+				self.genNonParallelSubstateConfigurationSetString = function(s,t){
+					return "";
+				};
+
+				self.genInitialization = function(){
+					return "";
+				}
+
+				self.genSend = function(send){
+					return "";
+				}
+
+				self.genInternalRuntimeFunctions = function(){
+					return "";
+				}
+
+				//this is the context for the trigger handlers
+				self.genTriggerDispatcherContext = function (params,s,t){
+					return "";
+				}
+
+				//the rest of this is stuff we will likely not need to mess with too much
+				self.genBoilerplateDispatchCode = function(dispatchInvocation){
+					return <>
+
+							//static private member variables
+							var currentConfiguration = []; //current configuration
+							var innerEventQueue = []; //inner event queue
+							var outerEventQueue = []; //outer event queue
+							var isInStableState = true;
+							var isPreempted = false;
+							var hasTakenDefaultTransition = false;
+							var destroyed = false;
+							var mainLoopCallback = null;
+
+							//static private member functions
+							function mainLoop() &#x7B;
+
+								if(!destroyed)&#x7B;
+									//take an event from the current outer event queue
+									if (outerEventQueue.length &amp;&amp; isInStableState) &#x7B;
+										runToCompletion(outerEventQueue.shift());
+									&#x7D;
+									//call back
+									mainLoopCallback = window.setTimeout(function() &#x7B;
+										mainLoop(); //FIXME: note that when calling mainloop this way, we won't have access to the "this" object. 
+										//I don't think we ever use it though. Everything we need is private in function scope.
+									&#x7D;,
+									100);
+								&#x7D;
+							&#x7D;
+
+							function runToCompletion(e)&#x7B;
+								isInStableState = false;
+
+								if(e)&#x7B;
+									innerEventQueue.push(e);
+								&#x7D;
+
+								do&#x7B;
+									//take any available default transitions
+									microstep({conf.defaultEventLiteral});
+
+									if(!hasTakenDefaultTransition)&#x7B;
+										
+										if(!innerEventQueue.length)&#x7B;
+											//we have no more generated events, and no default transitions fired, so
+											//we are done, and have run to completion
+											break;
+										&#x7D;else&#x7B;
+											//microstep, then dequeue next event sending in event
+											microstep(innerEventQueue.shift());
+										&#x7D;
+									&#x7D;else&#x7B;
+										//he has taken a default transition, so reset the global variable to false and loop again
+										hasTakenDefaultTransition = false;
+									&#x7D;
+
+								&#x7D;while(true)
+
+								isInStableState = true;
+							&#x7D;
+
+							function microstep(e)&#x7B;
+								{self.genForEach("currentConfiguration",
+												 "state",
+												 "if(!isPreempted) " + dispatchInvocation)}
+
+								//reset the isPreempted flag
+								isPreempted = false;
+							&#x7D;
+
+
+							this.destroy = function()&#x7B;
+								//right now, this only disables timer and sets global destroyed variable to prevent future callbacks
+								window.clearTimeout(mainLoopCallback);
+								mainLoopCallback = null;
+								destroyed = true;
+							&#x7D;
+
+
+							//this is for async communication
+							this.GEN = function(e)&#x7B;
+								outerEventQueue.push(e);
+							&#x7D;
+
+							//this may or may not be something we want to expose, but for right now, we at least need it for testing
+							this.getCurrentConfiguration = function()&#x7B;
+								//slice it to return a copy of the configuration rather than the conf itself
+								//this saves us all kinds of confusion involving references and stuff
+								return {conf.currentConfigurationExpression};
+							&#x7D;
+
+							//end static boilerplate code
+					</>
+				}
+
+
+				self.genState = function(state){
+					var stateName = state.@id;
+					var parentName = state.parent() ? state.parent().@id : "AbstractState";
+					var historyState = state.history;
+					var hasHistoryState = historyState.length() > 0;
+					var constructorFunctionName = stateName + "Constructor";
+					return <>
+						var {stateName} = (function()&#x7B;
+
+							function {constructorFunctionName}()&#x7B;
+								this.parent = {parentName};
+
+								this.initial = null;
+
+								this.depth = {self.computeDepth(state)};
+
+								this.historyState = null;
+
+								{state.localName() == "history" ?
+									"this.parent.historyState = this; //init parent's pointer to history state" :
+									""}
+
+								{state.localName() == "initial" ?
+									"this.parent.initial = this; //init parent's pointer to initial state" :
+									""}
+
+								this.toString = function()&#x7B;
+									return "{stateName}"
+								&#x7D;
+
+								this.enterAction = function()&#x7B;
+									{conf.log ? 
+										'console.log("entering ' + stateName + '");' : 
+										"" }
+									{self.genSend(state.onentry.send)}	
+								&#x7D;
+
+								this.exitAction = function()&#x7B;
+									{conf.log ? 
+										'console.log("exiting ' + stateName + '");' : 
+										"" }
+
+									{hasHistoryState ? 
+										"this.historyState.lastConfiguration = currentConfiguration.slice();" :
+										 ""}
+								&#x7D;
+
+								{self.genStateHooks(state)}
+
+							&#x7D;
+							{constructorFunctionName}.prototype = {parentName};
+							return new {constructorFunctionName}();
+						&#x7D;)();
+					</>;
+				}
+
+
+				self.genAbstractStateTriggerDispatcher = function(t){
+					return <>
+						this.{t} = function()&#x7B;&#x7D;
+					</>
+				}
+
+				self.genAbstractState = function(events){
+					return <>
+						var AbstractState = new function()&#x7B;
+							//triggers are methods
+							{util.foreach(events, this.genAbstractStateTriggerDispatcher)}
+							this.$default = function()&#x7B;&#x7D;
+						&#x7D;
+					</>;
+				};
+
+				function TransitionParams(isBasic,isHistory,isParallelSubstate,isDefaultTransition){
+					this.isBasic = isBasic;
+					this.isHistory = isHistory;
+					this.isParallelSubstate = isParallelSubstate;
+					this.isDefaultTransition = isDefaultTransition;
+				}
+
+				//FIXME: how do we apply multiply arguments?
+				self.genStateTriggerDispatcher = function(state,transition){
+					//so, this will vary depending on whether he is a basic state in a non-parallel region, a non-basic state, or a history state. 
+					//so, we do a check, and then delegate to the proper method
+					
+					//we also need to know the lca here.
+					var toReturn;
+					var targetId = transition.msdl::targets.msdl::target.msdl::targetState[0].toString();
+					var transitionTarget = conf.allStates.(@id == targetId);
+					var isDefaultTransition = transition.@event.length() == 0;
+					//generate exit action
+					var transitionParams;
+					if(state.localName() == "history"){
+						transitionParams = new TransitionParams(true,true,false,isDefaultTransition);
+					}else if(conf.basicParallelStates.contains(state) && conf.basicParallelStates.contains(transitionTarget)){
+						//is basic, and not a descendant of a parallel state
+						transitionParams = new TransitionParams(true,false,true,isDefaultTransition);
+					}
+					else if(conf.basicStates.contains(state)){
+						//is basic, and not a descendant of a parallel state
+						transitionParams = new TransitionParams(true,false,false,isDefaultTransition);
+					}	
+					else{
+						//is some kind of compound 
+						transitionParams = new TransitionParams(false,false,false,isDefaultTransition);
+					}
+
+					//set whether he is preempted
+					transitionParams.isPreempted = 
+						conf.parallelsAndDescendantStates.contains(state) && 
+							!conf.parallelsAndDescendantStates.contains(transitionTarget);
+
+
+					toReturn = self.genTriggerDispatcherContext(transitionParams,state,transition);
+
+					return toReturn;
+				}
+
+				self.deepHistoryEnterAction = <>
+								var topState;
+								while(topState = statesEntered.pop())&#x7B;
+									topState.enterAction();
+								&#x7D;
+					</>
+
+				self.shallowHistoryEnterAction = <>
+								var topState = statesEntered.pop();
+
+								topState.enterAction();
+
+								newConfiguration.push(topState.initial ? topState.initial : topState );	
+					</>
+
+				self.genHistoryTriggerDispatcher = function(params,s,t){
+					var isDeep = s.@type == "deep";
+					return <>
+						//history state semantics
+						if({self.genHistoryTriggerDispatcherHistoryStateReference(s)}.lastConfiguration)&#x7B;
+
+							//transition action
+							{conf.log ? 
+								(isDeep ? 
+									'console.log("return to last deep configuration");' :
+									'console.log("return to last shallow configuration");')	:
+									""}
+							{self.genSend(t.send)}	
+
+							var historyState = {self.genHistoryTriggerDispatcherHistoryStateReference(s)};
+
+							{!isDeep ?  "var newConfiguration = [];": ''}
+
+							{this.genForEach(self.genHistoryTriggerDispatcherHistoryStateReference(s) + ".lastConfiguration",
+											"state",
+											self.genHistoryTriggerDispatcherInnerForEach(isDeep))}
+
+							{isDeep ? 
+								"currentConfiguration = " + self.genHistoryTriggerDispatcherHistoryStateReference(s) + ".lastConfiguration.slice();" :
+								"currentConfiguration = " + self.genHistoryTriggerDispatcherCurrentConfigurationAssignmentRHS() + ";"}
+							
+						&#x7D;else&#x7B;
+							{self.genTriggerDispatcherContents(new TransitionParams(params.isBasic,true,false,true),s,t)}
+						&#x7D;
+					</>
+
+				}
+
+				//these get overridden
+				self.genHistoryTriggerDispatcherCurrentConfigurationAssignmentRHS = function(){
+					return "";
+				}
+
+				self.genHistoryTriggerDispatcherHistoryStateReference = function(s){
+					return ""
+				}
+
+				self.genHistoryTriggerDispatcherInnerForEachStateReference = function(){
+					return "";
+				}
+
+				self.genHistoryTriggerDispatcherInnerForEach  = function(isDeep){
+					return <>
+								var statesEntered = [{self.genHistoryTriggerDispatcherInnerForEachStateReference()}]; 
+
+								for(var parent = {self.genHistoryTriggerDispatcherInnerForEachStateReference()}.parent; 
+									parent != historyState.parent &amp;&amp; parent != null; 
+									parent = parent.parent)&#x7B;
+									statesEntered.push(parent);
+								&#x7D;
+
+								{isDeep ? 
+									self.deepHistoryEnterAction :
+									self.shallowHistoryEnterAction}
+					</>
+				}
+
+				self.genNonBasicTriggerDispatcherExitBlock = function(t){
+					return <>
+							var statesExited = [];
+							var lca = {t.msdl::lca.text()};
+							{self.genForEach("currentConfiguration",
+											"state",	
+											self.genNonBasicTriggerDispatcherExitBlockInnerForEach())}
+
+							//sort by depth
+							statesExited.sort(sortByDepthDeepToShallow);
+
+							//execute actions for each of these states
+							{self.genForEach("statesExited",
+											"state",	
+											"state.exitAction();")}
+					</>
+				}
+
+				self.genNonBasicTriggerDispatcherExitBlockInnerForEach = function(){
+					return <>
+							&#x7B;
+								do&#x7B;
+									statesExited.push(state);
+								&#x7D;while((state = state.parent) &amp;&amp;
+									state != lca &amp;&amp; 
+									statesExited.indexOf(state) == -1)
+							&#x7D;
+					</>
+				}
+
+				self.genTriggerDispatcherContents = function(params,s,t){
+					return <>
+							{params.isDefaultTransition ? 
+								"hasTakenDefaultTransition = true;" :
+								"" }
+
+							//exit states
+							{params.isBasic ?
+								util.foreach(t.msdl::exitpath
+											.msdl::state,function(stateToExit){return stateToExit + ".exitAction();"}) :
+								self.genNonBasicTriggerDispatcherExitBlock(t) }
+
+							//transition action
+							{self.genSend(t.send)}	
+
+							//enter states
+							{util.foreach(t.msdl::targets
+										.msdl::target
+										.msdl::enterpath
+										.msdl::state,function(stateToExit){return stateToExit + ".enterAction();"})}
+
+							//update configuration
+							{params.isParallelSubstate ?
+								self.genParallelSubstateConfigurationSetString(s,t) : 
+								self.genNonParallelSubstateConfigurationSetString(s,t) }
+
+
+							//set whether preempted
+							{params.isPreempted ?  "isPreempted = true;" : "" }
+					</>
+				}
+
+
+				self.genStatesEnum = function(states){
+					return <>
+						this._states = &#x7B;
+							{util.foreach(states,
+									function(state){return state.@id + ":" + state.@id + ","}).slice(0,-1)}
+						&#x7D;
+					</>;
+				}
+
+				//private and not changable by subclasses
+				self.computeDepth = function(state){
+					var depthToReturn = 0;
+					var currentNode = state;
+					while(currentNode = currentNode.parent()){
+						depthToReturn++;
+					}
+					return depthToReturn;
+				}
+
+				self.genForEach = function(arrName,itemName,body){
+					return conf.noForEach ?  <>
+							for(var $i=0; $i &lt; {arrName}.length; $i++) &#x7B;
+								{itemName} = {arrName}[$i];
+								{body}
+							&#x7D;
+						</> : <>
+							{arrName}.forEach(function({itemName})&#x7B;
+								{body}
+							&#x7D;);
+						</>;
+				}
+
+				self.genNoIndexOfArrayPrototypeExtension = function(){
+					return <>
+						if(!Array.indexOf)&#x7B;
+							Array.prototype.indexOf = function(obj)&#x7B;
+								for(var i=0; i &lt; this.length; i++)&#x7B;
+									if(this[i]==obj)&#x7B;
+										return i;
+									&#x7D;
+								&#x7D;
+								return -1;
+							&#x7D;
+						&#x7D;
+					</>
+				}
+
+				self.genNoMapArrayPrototypeExtension = function(){
+					return <>
+						if(!Array.map)&#x7B;
+							Array.prototype.map = function(fn)&#x7B;
+								var toReturn = [];
+								for(var i=0; i &lt; this.length; i++)&#x7B;
+									toReturn[i]=fn(this[i]);
+								&#x7D;
+								return toReturn;
+							&#x7D;
+						&#x7D;
+					</>
+				}
+		}
+	}
+);

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/js/AbstractStatechartGenerator.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/js/StatePatternStatechartGenerator.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/js/StatePatternStatechartGenerator.js?rev=947090&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/js/StatePatternStatechartGenerator.js (added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/js/StatePatternStatechartGenerator.js Fri May 21 17:49:09 2010
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+require.def("src/scxml/cgf/js/StatePatternStatechartGenerator",
+		["src/scxml/cgf/util",
+			"src/scxml/cgf/js/AbstractStatechartGenerator"],
+		function(util,AbstractStatechartGenerator){ 
+			return function(conf){
+				var self = this;
+
+				conf.dispatchInvocation = "state[e]();";
+				conf.defaultEventLiteral = '"$default"';
+				conf.currentConfigurationExpression = "currentConfiguration.slice()"
+
+				AbstractStatechartGenerator.apply(this,[conf]);
+
+				self.genInternalRuntimeFunctions = function(){
+					return <>
+						function sortByDepthDeepToShallow(a,b)&#x7B;
+							return b.depth - a.depth;
+						&#x7D;
+					</>
+				}
+
+				self.genStateHooks = function(state){
+					return <>
+						//triggers are methods
+						{util.foreach(state.transition,
+								function(transition){return self.genStateTriggerDispatcher(state,transition)})}
+					</>
+				}
+
+				self.genTriggerDispatcherContext = function (params,s,t){
+					return <>
+						this.{params.isDefaultTransition ? "$default" : t.@event} = function()&#x7B;
+							{params.isHistory ? 
+								self.genHistoryTriggerDispatcher(params,s,t) : 
+								self.genTriggerDispatcherContents(params,s,t) }
+						&#x7D;
+					</>
+				}
+
+				self.genExternalTriggerDispatcher = function(t){
+					return <>
+						this.{t.@event} = function()&#x7B;
+							if(isInStableState)&#x7B;
+								runToCompletion("{t.@event}");
+							&#x7D;else&#x7B;
+								return undefined;
+							&#x7D;
+						&#x7D;
+					</>;
+				}
+
+				self.genNonParallelSubstateConfigurationSetString = function(s,t){
+					return <>
+								currentConfiguration = [{util.foreach(t.msdl::targets
+														.msdl::target
+														.msdl::targetState,function(s){return s + ","}).slice(0,-1)}]; 
+					</>
+				}
+
+				self.genParallelSubstateConfigurationSetString = function(s,t){
+					return <>
+								currentConfiguration.splice(currentConfiguration.indexOf(this),1,
+										{util.foreach(t.msdl::targets
+													.msdl::target
+													.msdl::targetState,function(s){return s + ","}).slice(0,-1)}); 
+					</>
+				}
+
+				self.genInitialization = function(){
+					//we just need to know what the initial state is
+					var initialStateName = conf.scxml.initial.transition.msdl::targets.msdl::target.msdl::targetState.text();
+
+					return <>
+						this.initialize = function()&#x7B;
+							currentConfiguration = [{initialStateName}];
+							runToCompletion();
+							mainLoop();
+						&#x7D;
+					</>;
+				}
+
+
+				self.genSend = function(send){
+					var toReturn="";
+
+					if(send.length()){
+						var sendEvent = send.@event.toString();
+						var sendDelay = parseInt(send.@delay.toString());	//fixme: not sure what the units are
+
+						if(sendDelay){
+							//set timeout
+							toReturn =  <>
+							window.setTimeout(function()&#x7B;
+								self.GEN("{sendEvent}");
+							&#x7D;,{sendDelay*1000});
+								</>
+						}else{
+							//just add the event to the outer queue
+							toReturn = <>
+								innerEventQueue.push("{sendEvent}");
+								</>
+						}
+					}
+
+					return toReturn;
+				}
+
+				self.genHistoryTriggerDispatcherCurrentConfigurationAssignmentRHS = function(){
+					return "newConfiguration";
+				}
+
+				self.genHistoryTriggerDispatcherHistoryStateReference = function(s){
+					return "this"
+				}
+
+				self.genHistoryTriggerDispatcherInnerForEachStateReference = function(){
+					return "state";
+				}
+			}
+
+		}
+);

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/js/StatePatternStatechartGenerator.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/js/StateTableStatechartGenerator.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/js/StateTableStatechartGenerator.js?rev=947090&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/js/StateTableStatechartGenerator.js (added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/js/StateTableStatechartGenerator.js Fri May 21 17:49:09 2010
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+require.def("src/scxml/cgf/js/StateTableStatechartGenerator",
+		["src/scxml/cgf/util",
+			"src/scxml/cgf/js/AbstractEnumeratedStatechartGenerator"],
+		function(util,AbstractEnumeratedStatechartGenerator){
+
+			return function(conf){
+				var self = this;
+
+				conf.dispatchInvocation = "STATE_TRANSITION_TABLE[state][e]();";
+
+				AbstractEnumeratedStatechartGenerator.apply(this,[conf]);
+
+				//compute transition table data structure
+				//we do code gen with it later on
+				self.transitionTable = [[null for each (ev in self.eventIdMap)] for each (state in self.stateIdMap)];	//initialize everything to null
+				util.foreach(conf.transitions,function(t){
+					var stateName=t.parent().@id;
+					var ev = t.@event;
+					var stateId = self.stateIdMap[stateName];
+					var evId = ev.length() ? self.eventIdMap[ev] : 0;
+					self.transitionTable[stateId][evId] = t.@msdl::tName;
+				});
+
+
+
+				self.genEnumeratedHooks = function(){
+					return <>
+						var $nt = function()&#x7B;&#x7D;;	//null transition
+
+						//state transition table
+						{self.genStateTransitionTable()}
+					</>;
+				}
+
+				self.genStateTransitionTable = function(){
+					return 'var STATE_TRANSITION_TABLE = [' + self.transitionTable.map(function(row){
+						return '[' +row.map(function(action){
+							if(action){
+								return action.toString();
+							}
+							else return "$nt";
+						}).join(',') +']\n';
+					}).join(',') + ']';
+				}
+
+			}
+
+		}
+);
+

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/js/StateTableStatechartGenerator.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/js/SwitchyardStatechartGenerator.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/js/SwitchyardStatechartGenerator.js?rev=947090&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/js/SwitchyardStatechartGenerator.js (added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/js/SwitchyardStatechartGenerator.js Fri May 21 17:49:09 2010
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+require.def("src/scxml/cgf/js/SwitchyardStatechartGenerator",
+		["src/scxml/cgf/util",
+			"src/scxml/cgf/js/AbstractEnumeratedStatechartGenerator"],
+		function(util,AbstractEnumeratedStatechartGenerator){
+
+			return function(conf){
+				var self = this;
+
+				conf.dispatchInvocation = "dispatch(state,e)";
+
+				AbstractEnumeratedStatechartGenerator.apply(this,[conf]);
+
+				self.genEnumeratedHooks = function(){
+					return <>
+						//state transition table
+						{self.genSwitchyard(conf.basicStates)}
+					</>;
+				}
+
+
+				self.genSwitchyard = function(basicStates){
+					return <>
+						function dispatch(state,e)&#x7B;
+							switch(state) &#x7B;
+								{util.foreach(basicStates,genStateCase)}
+							&#x7D;
+						&#x7D;
+					</>;
+				}
+
+				function genStateCase(s){
+					return <>
+						case {s.msdl::enumId.toString()}:
+							switch(e) &#x7B;
+								{util.foreach(s.transition,genEventCase)}
+							&#x7D;
+							break;
+					</>;
+				}
+
+				function genEventCase(t){
+					var e = t.@event;
+					return <>
+					case {e.length() ? t.@event : "$default"} :
+						{t.@msdl::tName.toString()}();
+						break;
+					</>;
+				}
+			}
+
+
+		}
+);
+
+

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/js/SwitchyardStatechartGenerator.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/main.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/main.js?rev=947090&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/main.js (added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/main.js Fri May 21 17:49:09 2010
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+/**
+This file serves as an entry-point to SCXMLCompiler when running under Rhino.
+It accepts command-line arguments, and converts them to an options hash that it then passes into SCXMLCompiler.compile.
+*/
+
+/*
+    supported options:
+		backend	{switch | table | state}
+		ie
+		noForEach	
+		noIndexOf
+		noMap	
+		beautify	
+		log
+		verbose
+ */
+
+require.def("src/scxml/cgf/main",
+	["src/scxml/cgf/SCXMLCompiler",
+		"src/scxml/cgf/util/commandLine"],
+	function(SCXMLCompiler,cmdLineUtil){
+
+		return function(args){
+
+			var optionsMap = {
+				backend	: { argName : "backendValue" },
+				ie : true,
+				noForEach : true,
+				noIndexOf : true,
+				noMap : true,
+				beautify : true,
+				log : true,
+				verbose :  true
+			}
+
+			var parsedOptionsMap = cmdLineUtil.parseCommandLine(optionsMap,args);
+			parsedOptionsMap.inFiles = parsedOptionsMap.args;
+			delete parsedOptionsMap.args;
+
+			var scArr = SCXMLCompiler.compile(parsedOptionsMap);
+
+			if(parsedOptionsMap.inFiles.length > 1){
+				scArr.forEach(function(sc){print(sc)});
+			}else{
+				print(scArr);
+			}
+		}
+
+});

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/main.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/util.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/util.js?rev=947090&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/util.js (added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/util.js Fri May 21 17:49:09 2010
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+This module contains basic utilities.
+*/
+
+require.def("src/scxml/cgf/util",
+	{
+
+		//source: https://developer.mozilla.org/En/E4X_for_templating
+		/* 
+		The first two arguments are optional: (h is a handler with an explicit argument v only, or beginning with k, v)
+		lev is optional argument to note recursive depth (if part of recursion)
+		*/
+		foreach : function(min, max, arr, h, lev) {
+		    var k, ret=<></>, it = 1;
+		    lev = lev || 0;
+		    if (typeof min === 'number') {
+			if (typeof max !== 'number') {
+			    lev = h;
+			    h = arr;
+			    arr = max;
+			    max = min;
+			    min = 1;
+			}
+		    }
+		    else {
+			lev = arr;
+			h = max;
+			arr = min;
+			max = Number.POSITIVE_INFINITY;
+			min = 1;
+		    }
+		    if (h.length === 1) {
+			for (k in arr) {
+			    if (it < min) {
+				++it;
+				continue;
+			    }
+			    if (it > max) {
+				break;
+			    }
+			    ret+=h(arr[k], it, lev); // Need to get it or lev via arguments[] since our length detection implies no explicit additional params; otherwise define with more than one param (see below)
+			    ++it;
+			}
+		    }
+		    else {
+			for (k in arr) {
+			    if (it < min) {
+				++it;
+				continue;
+			    }
+			    if (it > max) {
+				break;
+			    }
+			    ret+=h(k, arr[k], it, lev);
+			    ++it;
+			}
+		    }
+		    return ret;
+		},
+
+		toJsArray : function (args){
+			var toReturn = [];
+
+			for(var i = 0; i < args.length; i++){
+				toReturn.push(args[i]);
+			}
+
+			return toReturn;
+		}
+	}
+);
+
+

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/util.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/util/commandLine.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/util/commandLine.js?rev=947090&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/util/commandLine.js (added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/util/commandLine.js Fri May 21 17:49:09 2010
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+This module contains utilities for parsing command-line arguments
+using the Apache Commons CLI library, and for converting these
+native Java objects back to JavaScript objects. 
+*/
+
+require.def(
+	"src/scxml/cgf/util/commandLine",
+	["src/scxml/cgf/util"],
+	function(util){
+
+		return {
+			parseCommandLine: function(optionsMap,args){
+			
+				var Options = Packages.org.apache.commons.cli.Options;
+				var OptionBuilder = Packages.org.apache.commons.cli.OptionBuilder;
+				var PosixParser = Packages.org.apache.commons.cli.PosixParser;
+
+				var lineMap;
+				
+				var options = new Options();
+				for( var optionName in optionsMap){
+					var optionVal = optionsMap[optionName];
+					options.addOption(
+						typeof optionVal == "boolean" ? 
+							OptionBuilder.create( optionName ) : 
+							OptionBuilder.withArgName(optionVal.argName).hasArg().create( optionName )
+					);	
+				}
+
+				var parser = new PosixParser();
+
+				try {
+					// parse the command line arguments
+					line = parser.parse( options, args );
+
+					lineMap = this.lineToJsMap(line);
+					lineMap.args = util.toJsArray(line.getArgs());
+
+					/*
+					for (var optName in lineMap){
+						print(optName);
+						print(lineMap[optName]);
+						print("--------------");
+					}
+
+					lineMap.args.forEach(function(f){print(f)});
+					*/
+				}
+				catch( exp ) {
+					// oops, something went wrong
+					print( "Parsing failed.  Reason: " + exp.getMessage() );
+				}
+			
+				return lineMap;
+			},
+
+			lineToJsMap : function(line){
+				var toReturn = {};
+
+				var processedOptions = line.getOptions();
+				processedOptions.forEach(function(pOpt){
+
+					var pval = pOpt.getValue();
+
+					if(pval){
+						//if pval is defined, copy him so that we have a native, primitive js string
+						//otherwise, switch statement won't work in rhino
+						toReturn[pOpt.getOpt()] = pval.slice();
+					}else{
+						toReturn[pOpt.getOpt()] = true; 
+					}
+					
+				}) 
+				
+				return toReturn;
+			}
+
+		}
+	}
+);
+

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/util/commandLine.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/util/file.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/util/file.js?rev=947090&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/util/file.js (added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/util/file.js Fri May 21 17:49:09 2010
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+This module contains functions to simplify File operations when
+running under Rhino.
+*/
+
+require.def("src/scxml/cgf/util/file",
+		[],
+		function(){
+			var File = java.io.File;
+			var FileWriter = java.io.FileWriter;
+			var FileReader = java.io.FileReader;
+
+			return {
+				deleteDir : function (dir) {
+				    if (dir.isDirectory()) {
+					children = dir.list();
+					for (var i=0; i<children.length; i++) {
+					    var success = deleteDir(new File(dir, children[i]));
+					    if (!success) {
+						return false;
+					    }
+					}
+				    }
+
+				    // The directory is now empty so delete it
+				    return dir["delete"]();
+				},
+
+				writeFile : function (str,pathStr){
+					var out = new FileWriter(pathStr);
+					out.write(str);
+					out.flush();
+				    out.close();
+				},
+
+				//not currently used.
+				copyFile : function (from,to){
+				    var fr = new FileReader(from);
+				    var fw = new FileWriter(to);
+				    var c;
+
+				    while ((c = fr.read()) != -1){
+				      fw.write(c);
+				    }
+
+				    fr.close();
+				    fw.close();
+				}
+			}
+
+		}
+);

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/util/file.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/test/kitchen_sink/KitchenSink.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/test/kitchen_sink/KitchenSink.xml?rev=947090&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/test/kitchen_sink/KitchenSink.xml (added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/test/kitchen_sink/KitchenSink.xml Fri May 21 17:49:09 2010
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scxml 
+	xmlns="http://www.w3.org/2005/07/scxml"
+	version="1.0"
+	profile="ecmascript">
+
+	<!--
+	 * Licensed to the Apache Software Foundation (ASF) under one or more
+	 * contributor license agreements.  See the NOTICE file distributed with
+	 * this work for additional information regarding copyright ownership.
+	 * The ASF licenses this file to You under the Apache License, Version 2.0
+	 * (the "License"); you may not use this file except in compliance with
+	 * the License.  You may obtain a copy of the License at
+	 *
+	 *     http://www.apache.org/licenses/LICENSE-2.0
+	 *
+	 * Unless required by applicable law or agreed to in writing, software
+	 * distributed under the License is distributed on an "AS IS" BASIS,
+	 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	 * See the License for the specific language governing permissions and
+	 * limitations under the License.
+	-->
+
+	<!-- its initial state is Test1 -->
+	<initial>
+		<transition target="Compound1"/>
+	</initial>
+
+	<!-- Really simple state showing the basic syntax. -->
+	<state id="Compound1">
+		<initial>
+			<transition target="ShallowHistory"/>
+		</initial>
+
+		<history id="ShallowHistory" type="shallow">
+			<transition target="Basic1"/>
+		</history>
+
+		<state id="Basic1">
+			<transition event="t1" target="Basic2"/> 
+		</state>
+
+		<state id="Basic2">
+			<transition event="t5" target="Basic1"/> 
+			<transition event="t2_7" target="Parallel1"/> 
+		</state>
+
+		<state id="Basic3">
+			<onentry>
+				<send event="t_after" delay="1"/>
+			</onentry>
+			<transition event="t_after" target="FinalState"/>
+		</state>
+
+		<transition event="t2_7" target="DeepHistory"/> 
+	</state>
+
+	<final id="FinalState"/>
+
+	<parallel id="Parallel1">
+
+		<initial>
+			<transition target="DeepHistory"/>
+		</initial>
+
+		<history id="DeepHistory" type="deep">
+			<transition target="ParallelRegion1 ParallelRegion2"/>
+		</history>
+
+		<state id="ParallelRegion1" initial="Basic4">
+
+			<state id="Basic4">
+				<transition event="t3" target="Basic5">
+					<send event="tgen"/>
+				</transition>
+			</state>
+
+			<state id="Basic5">
+				<transition event="t8" target="Basic4"/>
+				<transition event="t4_9" target="Compound1"/>
+			</state>
+
+		</state>
+
+		<state id="ParallelRegion2" initial="Basic6">
+
+			<state id="Basic6">
+				<transition event="tgen" target="Basic7"/>
+			</state>
+
+			<state id="Basic7"/>
+			
+		</state>
+
+		<transition event="t4_9" target="Basic3"/>
+	</parallel>
+
+</scxml>
+

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/test/kitchen_sink/KitchenSink.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/test/kitchen_sink/KitchenSink_performance.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/test/kitchen_sink/KitchenSink_performance.xml?rev=947090&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/test/kitchen_sink/KitchenSink_performance.xml (added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/test/kitchen_sink/KitchenSink_performance.xml Fri May 21 17:49:09 2010
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scxml 
+	xmlns="http://www.w3.org/2005/07/scxml"
+	version="1.0"
+	profile="ecmascript">
+
+	<!--
+	 * Licensed to the Apache Software Foundation (ASF) under one or more
+	 * contributor license agreements.  See the NOTICE file distributed with
+	 * this work for additional information regarding copyright ownership.
+	 * The ASF licenses this file to You under the Apache License, Version 2.0
+	 * (the "License"); you may not use this file except in compliance with
+	 * the License.  You may obtain a copy of the License at
+	 *
+	 *     http://www.apache.org/licenses/LICENSE-2.0
+	 *
+	 * Unless required by applicable law or agreed to in writing, software
+	 * distributed under the License is distributed on an "AS IS" BASIS,
+	 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	 * See the License for the specific language governing permissions and
+	 * limitations under the License.
+	-->
+
+	<!-- its initial state is Test1 -->
+	<initial>
+		<transition target="Compound1"/>
+	</initial>
+
+	<!-- Really simple state showing the basic syntax. -->
+	<state id="Compound1">
+		<initial>
+			<transition target="ShallowHistory"/>
+		</initial>
+
+		<history id="ShallowHistory" type="shallow">
+			<transition target="Basic1"/>
+		</history>
+
+		<state id="Basic1">
+			<transition event="t1" target="Basic2"/> 
+		</state>
+
+		<state id="Basic2">
+			<transition event="t5" target="Basic1"/> 
+			<transition event="t2_7" target="Parallel1"/> 
+		</state>
+
+		<state id="Basic3">
+			<transition event="t10" target="Basic1"/>
+		</state>
+
+		<transition event="t2_7" target="DeepHistory"/> 
+	</state>
+
+	<final id="FinalState"/>
+
+	<parallel id="Parallel1">
+
+		<initial>
+			<transition target="DeepHistory"/>
+		</initial>
+
+		<history id="DeepHistory" type="deep">
+			<transition target="ParallelRegion1 ParallelRegion2"/>
+		</history>
+
+		<state id="ParallelRegion1" initial="Basic4">
+
+			<state id="Basic4">
+				<transition event="t3" target="Basic5">
+					<send event="tgen"/>
+				</transition>
+			</state>
+
+			<state id="Basic5">
+				<transition event="t8" target="Basic4"/>
+				<transition event="t4_9" target="Compound1"/>
+			</state>
+
+		</state>
+
+		<state id="ParallelRegion2" initial="Basic6">
+
+			<state id="Basic6">
+				<transition event="tgen" target="Basic7"/>
+			</state>
+
+			<state id="Basic7"/>
+			
+		</state>
+
+		<transition event="t4_9" target="Basic3"/>
+	</parallel>
+
+</scxml>
+

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/test/kitchen_sink/KitchenSink_performance.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/test/kitchen_sink/doc/KitchenSink.dot
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/test/kitchen_sink/doc/KitchenSink.dot?rev=947090&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/test/kitchen_sink/doc/KitchenSink.dot (added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/test/kitchen_sink/doc/KitchenSink.dot Fri May 21 17:49:09 2010
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+digraph Root {
+
+	compound=true;
+
+	subgraph cluster_Root {
+		label="Root";
+
+		Root_initial[shape=point];
+
+		FinalState[label="final"];
+
+		subgraph cluster_Compound1 {
+			label = "Compound 1";
+
+			Compound1_initial[shape=point];
+			ShallowHistory[label="H"];
+			Basic1;
+			Basic2; 
+			Basic3;
+			
+
+			Compound1_initial -> ShallowHistory;
+			ShallowHistory  -> Basic1;
+			Basic1 -> Basic2 [label="t1"];
+			Basic2 -> Basic1 [label="t5"];
+		}
+
+		subgraph cluster_Parallel1{
+			label="Parallel1";
+
+			Parallel1_initial[shape=point];
+			DeepHistory[label="H*"];
+
+			subgraph cluster_ParallelRegion1{
+				label="ParallelRegion1";
+				style="dashed";
+
+				ParallelRegion1_initial[shape=point];
+				Basic4;
+				Basic5;
+
+				ParallelRegion1_initial -> Basic4;
+				Basic4 -> Basic5 [label="t3/GEN(tgen)"];
+				Basic5->Basic4[label="t8"];
+			}
+
+			subgraph cluster_ParallelRegion2{
+				label="ParallelRegion2";
+				style="dashed";
+
+				ParallelRegion2_initial[shape=point];
+				Basic6;
+				Basic7;
+
+				ParallelRegion2_initial->Basic6;
+				Basic6 -> Basic7 [label="tgen"];
+			}
+
+			Parallel1_initial->DeepHistory;
+			DeepHistory->ParallelRegion1_initial[lhead="cluster_ParallelRegion1"];
+			DeepHistory->ParallelRegion2_initial[lhead="cluster_ParallelRegion2"];
+		}
+
+		Root_initial -> Compound1_initial[lhead="cluster_Compound1"];
+		Basic3->FinalState[label="AFTER(1)"];
+
+		Basic2->Parallel1_initial[label="t2_7",lhead="cluster_Parallel1"];
+		Compound1_initial->DeepHistory[label="t2_7",ltail="cluster_Compound1"];
+
+		Basic5->Compound1_initial[label="t4_9",lhead="cluster_Compound1"];
+		Parallel1_initial->Basic3[label="t4_9",ltail="cluster_Parallel1"];
+	}
+}

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/test/kitchen_sink/doc/KitchenSink.dot
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/test/kitchen_sink/doc/KitchenSink.svg
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/test/kitchen_sink/doc/KitchenSink.svg?rev=947090&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/test/kitchen_sink/doc/KitchenSink.svg (added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/test/kitchen_sink/doc/KitchenSink.svg Fri May 21 17:49:09 2010
@@ -0,0 +1,219 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<!-- Generated by graphviz version 2.24.0 (20090616.2323)
+ -->
+<!-- Title: Root Pages: 1 -->
+<svg width="489pt" height="624pt"
+ viewBox="0.00 0.00 489.00 624.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<g id="graph1" class="graph" transform="scale(1 1) rotate(0) translate(4 620)">
+<title>Root</title>
+<polygon fill="white" stroke="white" points="-4,5 -4,-620 486,-620 486,5 -4,5"/>
+<g id="graph2" class="cluster"><title>cluster_Root</title>
+<polygon fill="none" stroke="black" points="8,-8 8,-608 473,-608 473,-8 8,-8"/>
+<text text-anchor="middle" x="240.5" y="-591.4" font-family="Times New Roman,serif" font-size="14.00">Root</text>
+</g>
+<g id="graph3" class="cluster"><title>cluster_Compound1</title>
+<polygon fill="none" stroke="black" points="78,-112 78,-506 188,-506 188,-112 78,-112"/>
+<text text-anchor="middle" x="133" y="-489.4" font-family="Times New Roman,serif" font-size="14.00">Compound 1</text>
+</g>
+<g id="graph4" class="cluster"><title>cluster_Parallel1</title>
+<polygon fill="none" stroke="black" points="196,-16 196,-490 465,-490 465,-16 196,-16"/>
+<text text-anchor="middle" x="330.5" y="-473.4" font-family="Times New Roman,serif" font-size="14.00">Parallel1</text>
+</g>
+<g id="graph5" class="cluster"><title>cluster_ParallelRegion1</title>
+<polygon fill="none" stroke="black" stroke-dasharray="5,2" points="204,-24 204,-284 347,-284 347,-24 204,-24"/>
+<text text-anchor="middle" x="275.5" y="-267.4" font-family="Times New Roman,serif" font-size="14.00">ParallelRegion1</text>
+</g>
+<g id="graph6" class="cluster"><title>cluster_ParallelRegion2</title>
+<polygon fill="none" stroke="black" stroke-dasharray="5,2" points="355,-24 355,-284 457,-284 457,-24 355,-24"/>
+<text text-anchor="middle" x="406" y="-267.4" font-family="Times New Roman,serif" font-size="14.00">ParallelRegion2</text>
+</g>
+<!-- Root_initial -->
+<g id="node2" class="node"><title>Root_initial</title>
+<ellipse fill="black" stroke="black" cx="207" cy="-550" rx="1.8" ry="1.8"/>
+</g>
+<!-- Compound1_initial -->
+<g id="node5" class="node"><title>Compound1_initial</title>
+<ellipse fill="black" stroke="black" cx="178" cy="-432" rx="1.8" ry="1.8"/>
+</g>
+<!-- Root_initial&#45;&gt;Compound1_initial -->
+<g id="edge31" class="edge"><title>Root_initial&#45;&gt;Compound1_initial</title>
+<path fill="none" stroke="black" d="M207.194,-548.206C207.702,-542.686 208.612,-525.629 202,-514 200.022,-510.521 197.332,-510.391 193.364,-505.939"/>
+<polygon fill="black" stroke="black" points="196.105,-503.744 187.611,-497.412 190.302,-507.659 196.105,-503.744"/>
+</g>
+<!-- FinalState -->
+<g id="node3" class="node"><title>FinalState</title>
+<ellipse fill="none" stroke="black" cx="43" cy="-344" rx="27" ry="18"/>
+<text text-anchor="middle" x="43" y="-339.4" font-family="Times New Roman,serif" font-size="14.00">final</text>
+</g>
+<!-- ShallowHistory -->
+<g id="node6" class="node"><title>ShallowHistory</title>
+<ellipse fill="none" stroke="black" cx="140" cy="-344" rx="27" ry="18"/>
+<text text-anchor="middle" x="140" y="-339.4" font-family="Times New Roman,serif" font-size="14.00">H</text>
+</g>
+<!-- Compound1_initial&#45;&gt;ShallowHistory -->
+<g id="edge4" class="edge"><title>Compound1_initial&#45;&gt;ShallowHistory</title>
+<path fill="none" stroke="black" d="M177.147,-430.181C175.497,-426.776 171.62,-419.301 167,-414 158.7,-404.476 150.951,-407.144 145,-396 141.198,-388.88 139.435,-380.425 138.753,-372.425"/>
+<polygon fill="black" stroke="black" points="142.247,-372.191 138.399,-362.32 135.252,-372.436 142.247,-372.191"/>
+</g>
+<!-- DeepHistory -->
+<g id="node16" class="node"><title>DeepHistory</title>
+<ellipse fill="none" stroke="black" cx="244" cy="-344" rx="27" ry="18"/>
+<text text-anchor="middle" x="244" y="-339.4" font-family="Times New Roman,serif" font-size="14.00">H*</text>
+</g>
+<!-- Compound1_initial&#45;&gt;DeepHistory -->
+<g id="edge37" class="edge"><title>Compound1_initial&#45;&gt;DeepHistory</title>
+<path fill="none" stroke="black" d="M187.805,-403.548C191.291,-395.515 195.695,-387.05 201,-380 205.508,-374.01 211.194,-368.366 216.942,-363.403"/>
+<polygon fill="black" stroke="black" points="219.16,-366.11 224.713,-357.087 214.746,-360.677 219.16,-366.11"/>
+<text text-anchor="middle" x="213.5" y="-383.4" font-family="Times New Roman,serif" font-size="14.00">t2_7</text>
+</g>
+<!-- Basic1 -->
+<g id="node7" class="node"><title>Basic1</title>
+<ellipse fill="none" stroke="black" cx="140" cy="-226" rx="36.2243" ry="18"/>
+<text text-anchor="middle" x="140" y="-221.4" font-family="Times New Roman,serif" font-size="14.00">Basic1</text>
+</g>
+<!-- ShallowHistory&#45;&gt;Basic1 -->
+<g id="edge6" class="edge"><title>ShallowHistory&#45;&gt;Basic1</title>
+<path fill="none" stroke="black" d="M140,-325.821C140,-306.709 140,-276.389 140,-254.175"/>
+<polygon fill="black" stroke="black" points="143.5,-254.006 140,-244.006 136.5,-254.006 143.5,-254.006"/>
+</g>
+<!-- Basic2 -->
+<g id="node8" class="node"><title>Basic2</title>
+<ellipse fill="none" stroke="black" cx="144" cy="-138" rx="36.2243" ry="18"/>
+<text text-anchor="middle" x="144" y="-133.4" font-family="Times New Roman,serif" font-size="14.00">Basic2</text>
+</g>
+<!-- Basic1&#45;&gt;Basic2 -->
+<g id="edge8" class="edge"><title>Basic1&#45;&gt;Basic2</title>
+<path fill="none" stroke="black" d="M129.503,-208.303C124.844,-198.298 121.015,-185.521 124,-174 124.843,-170.747 126.05,-167.475 127.46,-164.301"/>
+<polygon fill="black" stroke="black" points="130.685,-165.683 132.135,-155.187 124.457,-162.488 130.685,-165.683"/>
+<text text-anchor="middle" x="129.5" y="-177.4" font-family="Times New Roman,serif" font-size="14.00">t1</text>
+</g>
+<!-- Basic2&#45;&gt;Basic1 -->
+<g id="edge10" class="edge"><title>Basic2&#45;&gt;Basic1</title>
+<path fill="none" stroke="black" d="M143.172,-156.21C142.631,-168.122 141.912,-183.932 141.296,-197.492"/>
+<polygon fill="black" stroke="black" points="137.787,-197.618 140.829,-207.766 144.779,-197.936 137.787,-197.618"/>
+<text text-anchor="middle" x="148.5" y="-177.4" font-family="Times New Roman,serif" font-size="14.00">t5</text>
+</g>
+<!-- Parallel1_initial -->
+<g id="node15" class="node"><title>Parallel1_initial</title>
+<ellipse fill="black" stroke="black" cx="220" cy="-432" rx="1.8" ry="1.8"/>
+</g>
+<!-- Basic2&#45;&gt;Parallel1_initial -->
+<g id="edge35" class="edge"><title>Basic2&#45;&gt;Parallel1_initial</title>
+<path fill="none" stroke="black" d="M156.416,-154.925C165.787,-168.567 178.161,-188.608 185,-208 188.828,-218.855 192.048,-235.748 194.843,-254.718"/>
+<polygon fill="black" stroke="black" points="191.403,-255.394 196.266,-264.807 198.335,-254.416 191.403,-255.394"/>
+<text text-anchor="middle" x="214.5" y="-295.4" font-family="Times New Roman,serif" font-size="14.00">t2_7</text>
+</g>
+<!-- Basic3 -->
+<g id="node9" class="node"><title>Basic3</title>
+<ellipse fill="none" stroke="black" cx="122" cy="-432" rx="36.2243" ry="18"/>
+<text text-anchor="middle" x="122" y="-427.4" font-family="Times New Roman,serif" font-size="14.00">Basic3</text>
+</g>
+<!-- Basic3&#45;&gt;FinalState -->
+<g id="edge33" class="edge"><title>Basic3&#45;&gt;FinalState</title>
+<path fill="none" stroke="black" d="M87.2205,-427.046C68.3774,-422.395 46.6274,-413.395 35,-396 30.1112,-388.686 30.0333,-379.516 31.8383,-370.92"/>
+<polygon fill="black" stroke="black" points="35.2217,-371.819 34.6468,-361.24 28.4989,-369.869 35.2217,-371.819"/>
+<text text-anchor="middle" x="65.5" y="-383.4" font-family="Times New Roman,serif" font-size="14.00">AFTER(1)</text>
+</g>
+<!-- Parallel1_initial&#45;&gt;Basic3 -->
+<g id="edge41" class="edge"><title>Parallel1_initial&#45;&gt;Basic3</title>
+<path fill="none" stroke="black" d="M206.494,-489.837C202.777,-496.173 198.039,-501.828 192,-506 167.791,-522.724 145.482,-486.45 132.829,-459.005"/>
+<polygon fill="black" stroke="black" points="135.996,-457.513 128.769,-449.766 129.588,-460.329 135.996,-457.513"/>
+<text text-anchor="middle" x="188" y="-517.4" font-family="Times New Roman,serif" font-size="14.00">t4_9</text>
+</g>
+<!-- Parallel1_initial&#45;&gt;DeepHistory -->
+<g id="edge25" class="edge"><title>Parallel1_initial&#45;&gt;DeepHistory</title>
+<path fill="none" stroke="black" d="M220.501,-430.162C222.544,-422.671 230.423,-393.782 236.501,-371.498"/>
+<polygon fill="black" stroke="black" points="239.884,-372.393 239.139,-361.825 233.131,-370.551 239.884,-372.393"/>
+</g>
+<!-- ParallelRegion1_initial -->
+<g id="node18" class="node"><title>ParallelRegion1_initial</title>
+<ellipse fill="black" stroke="black" cx="245" cy="-226" rx="1.8" ry="1.8"/>
+</g>
+<!-- DeepHistory&#45;&gt;ParallelRegion1_initial -->
+<g id="edge27" class="edge"><title>DeepHistory&#45;&gt;ParallelRegion1_initial</title>
+<path fill="none" stroke="black" d="M244.154,-325.821C244.23,-316.888 244.326,-305.505 244.427,-293.646"/>
+<polygon fill="black" stroke="black" points="247.927,-293.645 244.512,-283.615 240.927,-293.585 247.927,-293.645"/>
+</g>
+<!-- ParallelRegion2_initial -->
+<g id="node25" class="node"><title>ParallelRegion2_initial</title>
+<ellipse fill="black" stroke="black" cx="382" cy="-226" rx="1.8" ry="1.8"/>
+</g>
+<!-- DeepHistory&#45;&gt;ParallelRegion2_initial -->
+<g id="edge29" class="edge"><title>DeepHistory&#45;&gt;ParallelRegion2_initial</title>
+<path fill="none" stroke="black" d="M267.793,-335.283C289.294,-326.515 321.081,-311.263 347.792,-286.577"/>
+<polygon fill="black" stroke="black" points="350.471,-288.853 355.179,-279.362 345.579,-283.846 350.471,-288.853"/>
+</g>
+<!-- Basic4 -->
+<g id="node19" class="node"><title>Basic4</title>
+<ellipse fill="none" stroke="black" cx="248" cy="-138" rx="36.2243" ry="18"/>
+<text text-anchor="middle" x="248" y="-133.4" font-family="Times New Roman,serif" font-size="14.00">Basic4</text>
+</g>
+<!-- ParallelRegion1_initial&#45;&gt;Basic4 -->
+<g id="edge14" class="edge"><title>ParallelRegion1_initial&#45;&gt;Basic4</title>
+<path fill="none" stroke="black" d="M245.063,-224.162C245.314,-216.781 246.274,-188.625 247.029,-166.483"/>
+<polygon fill="black" stroke="black" points="250.536,-166.327 247.379,-156.214 243.54,-166.089 250.536,-166.327"/>
+</g>
+<!-- Basic5 -->
+<g id="node20" class="node"><title>Basic5</title>
+<ellipse fill="none" stroke="black" cx="248" cy="-50" rx="36.2243" ry="18"/>
+<text text-anchor="middle" x="248" y="-45.4" font-family="Times New Roman,serif" font-size="14.00">Basic5</text>
+</g>
+<!-- Basic4&#45;&gt;Basic5 -->
+<g id="edge16" class="edge"><title>Basic4&#45;&gt;Basic5</title>
+<path fill="none" stroke="black" d="M237.901,-120.613C235.091,-114.877 232.422,-108.34 231,-102 229.138,-93.6981 230.661,-84.8392 233.428,-76.8296"/>
+<polygon fill="black" stroke="black" points="236.668,-78.1528 237.275,-67.5754 230.204,-75.4655 236.668,-78.1528"/>
+<text text-anchor="middle" x="268.5" y="-89.4" font-family="Times New Roman,serif" font-size="14.00">t3/GEN(tgen)</text>
+</g>
+<!-- Basic5&#45;&gt;Compound1_initial -->
+<g id="edge39" class="edge"><title>Basic5&#45;&gt;Compound1_initial</title>
+<path fill="none" stroke="black" d="M213.537,-55.5865C182.387,-62.2714 136.876,-76.3099 106.405,-104.519"/>
+<polygon fill="black" stroke="black" points="103.547,-102.431 99,-112 108.522,-107.355 103.547,-102.431"/>
+<text text-anchor="middle" x="82.5" y="-221.4" font-family="Times New Roman,serif" font-size="14.00">t4_9</text>
+</g>
+<!-- Basic5&#45;&gt;Basic4 -->
+<g id="edge18" class="edge"><title>Basic5&#45;&gt;Basic4</title>
+<path fill="none" stroke="black" d="M276.633,-61.1855C295.659,-70.4569 315.533,-84.8634 306,-102 301.388,-110.29 293.99,-116.916 285.998,-122.107"/>
+<polygon fill="black" stroke="black" points="284.108,-119.157 277.198,-127.188 287.608,-125.219 284.108,-119.157"/>
+<text text-anchor="middle" x="314.5" y="-89.4" font-family="Times New Roman,serif" font-size="14.00">t8</text>
+</g>
+<!-- Basic6 -->
+<g id="node26" class="node"><title>Basic6</title>
+<ellipse fill="none" stroke="black" cx="399" cy="-138" rx="36.2243" ry="18"/>
+<text text-anchor="middle" x="399" y="-133.4" font-family="Times New Roman,serif" font-size="14.00">Basic6</text>
+</g>
+<!-- ParallelRegion2_initial&#45;&gt;Basic6 -->
+<g id="edge21" class="edge"><title>ParallelRegion2_initial&#45;&gt;Basic6</title>
+<path fill="none" stroke="black" d="M382.355,-224.162C383.788,-216.747 389.27,-188.369 393.556,-166.182"/>
+<polygon fill="black" stroke="black" points="397.021,-166.696 395.481,-156.214 390.148,-165.368 397.021,-166.696"/>
+</g>
+<!-- Basic7 -->
+<g id="node27" class="node"><title>Basic7</title>
+<ellipse fill="none" stroke="black" cx="399" cy="-50" rx="36.2243" ry="18"/>
+<text text-anchor="middle" x="399" y="-45.4" font-family="Times New Roman,serif" font-size="14.00">Basic7</text>
+</g>
+<!-- Basic6&#45;&gt;Basic7 -->
+<g id="edge23" class="edge"><title>Basic6&#45;&gt;Basic7</title>
+<path fill="none" stroke="black" d="M399,-119.766C399,-107.849 399,-92.0384 399,-78.4817"/>
+<polygon fill="black" stroke="black" points="402.5,-78.2103 399,-68.2103 395.5,-78.2103 402.5,-78.2103"/>
+<text text-anchor="middle" x="410.5" y="-89.4" font-family="Times New Roman,serif" font-size="14.00">tgen</text>
+</g>
+</g>
+</svg>

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/test/kitchen_sink/doc/KitchenSink.svg
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/test/kitchen_sink/doc_performance/KitchenSink.dot
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/test/kitchen_sink/doc_performance/KitchenSink.dot?rev=947090&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/test/kitchen_sink/doc_performance/KitchenSink.dot (added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/test/kitchen_sink/doc_performance/KitchenSink.dot Fri May 21 17:49:09 2010
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+digraph Root {
+
+	compound=true;
+
+	subgraph cluster_Root {
+		label="Root";
+
+		Root_initial[shape=point];
+
+		FinalState[label="final"];
+
+		subgraph cluster_Compound1 {
+			label = "Compound 1";
+
+			Compound1_initial[shape=point];
+			ShallowHistory[label="H"];
+			Basic1;
+			Basic2; 
+			Basic3;
+			
+
+			Compound1_initial -> ShallowHistory;
+			ShallowHistory  -> Basic1;
+			Basic1 -> Basic2 [label="t1"];
+			Basic2 -> Basic1 [label="t5"];
+		}
+
+		subgraph cluster_Parallel1{
+			label="Parallel1";
+
+			Parallel1_initial[shape=point];
+			DeepHistory[label="H*"];
+
+			subgraph cluster_ParallelRegion1{
+				label="ParallelRegion1";
+				style="dashed";
+
+				ParallelRegion1_initial[shape=point];
+				Basic4;
+				Basic5;
+
+				ParallelRegion1_initial -> Basic4;
+				Basic4 -> Basic5 [label="t3/GEN(tgen)"];
+				Basic5->Basic4[label="t8"];
+			}
+
+			subgraph cluster_ParallelRegion2{
+				label="ParallelRegion2";
+				style="dashed";
+
+				ParallelRegion2_initial[shape=point];
+				Basic6;
+				Basic7;
+
+				ParallelRegion2_initial->Basic6;
+				Basic6 -> Basic7 [label="tgen"];
+			}
+
+			Parallel1_initial->DeepHistory;
+			DeepHistory->ParallelRegion1_initial[lhead="cluster_ParallelRegion1"];
+			DeepHistory->ParallelRegion2_initial[lhead="cluster_ParallelRegion2"];
+		}
+
+		Root_initial -> Compound1_initial[lhead="cluster_Compound1"];
+		Basic3->FinalState[label="AFTER(1)"];
+
+		Basic2->Parallel1_initial[label="t2_7",lhead="cluster_Parallel1"];
+		Compound1_initial->DeepHistory[label="t2_7",ltail="cluster_Compound1"];
+
+		Basic5->Compound1_initial[label="t4_9",lhead="cluster_Compound1"];
+		Parallel1_initial->Basic3[label="t4_9",ltail="cluster_Parallel1"];
+	}
+}

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/test/kitchen_sink/doc_performance/KitchenSink.dot
------------------------------------------------------------------------------
    svn:eol-style = native