Permalink
Browse files

Added support for send/@target='#_internal'

  • Loading branch information...
1 parent ab546a1 commit 14d4562ab41fa5c22ccc39fe64579d4935325e4d @jbeard4 committed Nov 2, 2012
Showing with 23 additions and 8 deletions.
  1. +3 −0 .gitmodules
  2. +1 −1 lib/core/scxml/SCXML.js
  3. +18 −7 lib/core/util/code-gen.js
  4. +1 −0 lib/external/sax-js
View
@@ -7,3 +7,6 @@
[submodule "lib/external/jsUri"]
path = lib/external/jsUri
url = git://github.com/jbeard4/jsUri.git
+[submodule "lib/external/sax-js"]
+ path = lib/external/sax-js
+ url = git://github.com/isaacs/sax-js.git
View
@@ -275,7 +275,7 @@ SCXMLInterpreter.prototype = {
/** @private */
_evaluateAction : function(actionRef, eventSet, datamodelForNextStep, eventsToAddToInnerQueue) {
function $raise(event){
- eventsToAddToInnerQueue.add({ name: event, data : {}});
+ eventsToAddToInnerQueue.add(event);
}
var n = this._getScriptingInterface(datamodelForNextStep, eventSet, true);
View
@@ -109,24 +109,35 @@ var actionTags = {
},
"raise" : function(action){
- return "$raise(" + JSON.stringify(pm.platform.dom.getAttribute(action,"event")) + ");";
+ return "$raise({ name:" + JSON.stringify(pm.platform.dom.getAttribute(action,"event")) + ", data : {}});";
},
"cancel" : function(action){
return "$cancel(" + JSON.stringify(pm.platform.dom.getAttribute(action,"sendid")) + ");";
},
"send" : function(action){
- return "$send({\n" +
- "target: " + (pm.platform.dom.hasAttribute(action,"targetexpr") ? pm.platform.dom.getAttribute(action,"targetexpr") : JSON.stringify(pm.platform.dom.getAttribute(action,"target"))) + ",\n" +
+ var target = (pm.platform.dom.hasAttribute(action,"targetexpr") ? pm.platform.dom.getAttribute(action,"targetexpr") : JSON.stringify(pm.platform.dom.getAttribute(action,"target")));
+ var event = "{\n" +
+ "target: " + target + ",\n" +
"name: " + (pm.platform.dom.hasAttribute(action,"eventexpr") ? pm.platform.dom.getAttribute(action,"eventexpr") : JSON.stringify(pm.platform.dom.getAttribute(action,"event"))) + ",\n" +
"type: " + (pm.platform.dom.hasAttribute(action,"typeexpr") ? pm.platform.dom.getAttribute(action,"typeexpr") : JSON.stringify(pm.platform.dom.getAttribute(action,"type"))) + ",\n" +
"data: " + constructSendEventData(action) + ",\n" +
"origin: $origin\n" +
- "}, {\n" +
- "delay: " + (pm.platform.dom.hasAttribute(action,"delayexpr") ? pm.platform.dom.getAttribute(action,"delayexpr") : getDelayInMs(pm.platform.dom.getAttribute(action,"delay"))) + ",\n" +
- "sendId: " + (pm.platform.dom.hasAttribute(action,"idlocation") ? pm.platform.dom.getAttribute(action,"idlocation") : JSON.stringify(pm.platform.dom.getAttribute(action,"id"))) + "\n" +
- "});";
+ "}";
+
+ var send =
+ "if(" + target + " === '#_internal'){\n" +
+ "console.log('here');\n" +
+ "$raise(" + event + ");\n" +
+ "}else{\n" +
+ "$send(" + event + ", {\n" +
+ "delay: " + (pm.platform.dom.hasAttribute(action,"delayexpr") ? pm.platform.dom.getAttribute(action,"delayexpr") : getDelayInMs(pm.platform.dom.getAttribute(action,"delay"))) + ",\n" +
+ "sendId: " + (pm.platform.dom.hasAttribute(action,"idlocation") ? pm.platform.dom.getAttribute(action,"idlocation") : JSON.stringify(pm.platform.dom.getAttribute(action,"id"))) + "\n" +
+ "});" +
+ "}";
+
+ return send;
},
"foreach" : function(action){
Submodule sax-js added at 3b2679

0 comments on commit 14d4562

Please sign in to comment.