You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by fi...@apache.org on 2012/03/15 20:36:25 UTC

[19/21] git commit: reverting change to exec

reverting change to exec


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/commit/a725bde6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/a725bde6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/a725bde6

Branch: refs/heads/master
Commit: a725bde68cb3ed42480775a69fad1e0ede6ec076
Parents: 62d9ee6
Author: Fil Maj <ma...@gmail.com>
Authored: Tue Mar 13 08:30:44 2012 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Thu Mar 15 10:14:41 2012 -0700

----------------------------------------------------------------------
 lib/exec/ios.js |   52 +++++++++++++++++++++++++++++++++++++------------
 1 files changed, 39 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/a725bde6/lib/exec/ios.js
----------------------------------------------------------------------
diff --git a/lib/exec/ios.js b/lib/exec/ios.js
index 4291946..6df98dd 100644
--- a/lib/exec/ios.js
+++ b/lib/exec/ios.js
@@ -24,32 +24,56 @@ module.exports = function() {
     }
 
     var successCallback, failCallback, service, action, actionArgs;
-    successCallback = arguments[0];
-    failCallback = arguments[1];
-    service = arguments[2];
-    action = arguments[3];
-    actionArgs = arguments[4];
+    var callbackId = null;
+    if (typeof arguments[0] !== "string") {
+        // FORMAT ONE
+        successCallback = arguments[0];
+        failCallback = arguments[1];
+        service = arguments[2];
+        action = arguments[3];
+        actionArgs = arguments[4];
 
-    var callbackId = service + cordova.callbackId++;
-
-    // Since we need to maintain backwards compatibility, we have to pass
-    // an invalid callbackId even if no callback was provided since plugins
-    // will be expecting it. The cordova.exec() implementation allocates
-    // an invalid callbackId and passes it even if no callbacks were given.
+        // Since we need to maintain backwards compatibility, we have to pass
+        // an invalid callbackId even if no callback was provided since plugins
+        // will be expecting it. The Cordova.exec() implementation allocates
+        // an invalid callbackId and passes it even if no callbacks were given.
+        callbackId = 'INVALID';
+    } else {
+        // FORMAT TWO
+        splitCommand = arguments[0].split(".");
+        action = splitCommand.pop();
+        service = splitCommand.join(".");
+        actionArgs = Array.prototype.splice.call(arguments, 1);
+    }
     
     // Start building the command object.
     var command = {
         className: service,
         methodName: action,
-        arguments: [callbackId].concat(actionArgs)
+        arguments: []
     };
 
     // Register the callbacks and add the callbackId to the positional
     // arguments if given.
     if (successCallback || failCallback) {
+        callbackId = service + cordova.callbackId++;
         cordova.callbacks[callbackId] = 
             {success:successCallback, fail:failCallback};
     }
+    if (callbackId != null) {
+        command.arguments.push(callbackId);
+    }
+
+    for (var i = 0; i < actionArgs.length; ++i) {
+        var arg = actionArgs[i];
+        if (arg == undefined || arg == null) { // nulls are pushed to the args now (becomes NSNull)
+            command.arguments.push(arg);
+        } else if (typeof(arg) == 'object') {
+            command.options = arg;
+        } else {
+            command.arguments.push(arg);
+        }
+    }
 
     // Stringify and queue the command. We stringify to command now to
     // effectively clone the command arguments in case they are mutated before
@@ -64,7 +88,9 @@ module.exports = function() {
         if (!gapBridge) {
             createGapBridge();
         }
-
         gapBridge.src = "gap://ready";
     }
 };
+
+module.exports = exec = function() { 
+}