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
[6/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/f97442a7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/f97442a7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/f97442a7
Branch: refs/heads/master
Commit: f97442a7ad2aa7e5c2bb20373269db515a8a3c49
Parents: f3cd87a
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:16:28 2012 -0700
----------------------------------------------------------------------
lib/exec/ios.js | 51 ++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 39 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f97442a7/lib/exec/ios.js
----------------------------------------------------------------------
diff --git a/lib/exec/ios.js b/lib/exec/ios.js
index aa9de81..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
@@ -67,3 +91,6 @@ module.exports = function() {
gapBridge.src = "gap://ready";
}
};
+
+module.exports = exec = function() {
+}