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
[14/21] git commit: simplifying / cleaning up exec for ios
simplifying / cleaning up exec for ios
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/7a27bef6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/7a27bef6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/7a27bef6
Branch: refs/heads/master
Commit: 7a27bef6fe9947ea02fd19ecd8aaaacaf3c1e194
Parents: a8063f3
Author: Fil Maj <ma...@gmail.com>
Authored: Sat Mar 10 11:52:56 2012 -0800
Committer: Fil Maj <ma...@gmail.com>
Committed: Thu Mar 15 10:14:41 2012 -0700
----------------------------------------------------------------------
lib/exec/ios.js | 47 +++++++++++------------------------------------
1 files changed, 11 insertions(+), 36 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/7a27bef6/lib/exec/ios.js
----------------------------------------------------------------------
diff --git a/lib/exec/ios.js b/lib/exec/ios.js
index 5c972ca..2d6f057 100644
--- a/lib/exec/ios.js
+++ b/lib/exec/ios.js
@@ -24,56 +24,31 @@ module.exports = function() {
}
var successCallback, failCallback, service, action, actionArgs;
- 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++;
+ successCallback = arguments[0];
+ failCallback = arguments[1];
+ service = arguments[2];
+ action = arguments[3];
+ actionArgs = arguments[4];
- // 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);
- }
+ // 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.
// Start building the command object.
var command = {
className: service,
methodName: action,
- arguments: []
+ arguments: [callbackId].concat(actionArgs)
};
// 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) {
- continue;
- } 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