You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by mm...@apache.org on 2013/01/10 22:53:41 UTC

js commit: [ios]CB-2189: support ArrayBuffer over exec bridge

Updated Branches:
  refs/heads/master 9d1676804 -> 334b19779


[ios]CB-2189: support ArrayBuffer over exec bridge


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

Branch: refs/heads/master
Commit: 334b19779c48c9dd79137bf04821fb86ae7efc47
Parents: 9d16768
Author: Michal Mocny <mm...@gmail.com>
Authored: Thu Jan 10 13:26:26 2013 -0500
Committer: Michal Mocny <mm...@gmail.com>
Committed: Thu Jan 10 16:52:31 2013 -0500

----------------------------------------------------------------------
 lib/ios/exec.js |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/334b1977/lib/ios/exec.js
----------------------------------------------------------------------
diff --git a/lib/ios/exec.js b/lib/ios/exec.js
index 1c2c1f2..08cdc15 100644
--- a/lib/ios/exec.js
+++ b/lib/ios/exec.js
@@ -103,6 +103,27 @@ function iOSExec() {
             {success:successCallback, fail:failCallback};
     }
 
+    // Binary!
+    var encodeArrayBufferAsBase64 = function(ab) {
+        var arr = new Uint8Array(ab);
+        var binary = '';
+        var len = arr.length;
+        for (var i = 0; i < len; i++) {
+            binary += String.fromCharCode(arr[i]);
+        }
+        return window.btoa(binary);
+    };
+    actionArgs.forEach(function(arg, i) {
+        if (Object.prototype.toString.call(arg) != Object.prototype.toString.call(new ArrayBuffer())) {
+            return;
+        }
+        actionArgs[i] = {
+            'CDVType': 'ArrayBuffer',
+            'data': encodeArrayBufferAsBase64(arg)
+        };
+    });
+
+    console.log(actionArgs);
     var command = [callbackId, service, action, actionArgs];
 
     // Stringify and queue the command. We stringify to command now to