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:48:01 UTC

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

Updated Branches:
  refs/heads/master deabeeb6f -> dfe407aad


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


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

Branch: refs/heads/master
Commit: dfe407aad9c0ee053529f3cf53a3bc79d94622a9
Parents: deabeeb
Author: Michal Mocny <mm...@gmail.com>
Authored: Thu Jan 10 16:15:01 2013 -0500
Committer: Michal Mocny <mm...@gmail.com>
Committed: Thu Jan 10 16:46:53 2013 -0500

----------------------------------------------------------------------
 CordovaLib/Classes/CDVInvokedUrlCommand.m |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/dfe407aa/CordovaLib/Classes/CDVInvokedUrlCommand.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVInvokedUrlCommand.m b/CordovaLib/Classes/CDVInvokedUrlCommand.m
index 833baad..7a0bf84 100644
--- a/CordovaLib/Classes/CDVInvokedUrlCommand.m
+++ b/CordovaLib/Classes/CDVInvokedUrlCommand.m
@@ -19,6 +19,7 @@
 
 #import "CDVInvokedUrlCommand.h"
 #import "JSONKit.h"
+#import "NSData+Base64.h"
 
 @implementation CDVInvokedUrlCommand
 
@@ -58,9 +59,30 @@
         _className = className;
         _methodName = methodName;
     }
+    [self massageArguments];
     return self;
 }
 
+- (void)massageArguments
+{
+    for (NSUInteger i = 0, count = [_arguments count]; i < count; ++i) {
+        id arg = [_arguments objectAtIndex:i];
+        if (![arg isKindOfClass:[NSDictionary class]]) {
+            continue;
+        }
+        NSDictionary* dict = arg;
+        NSString* type = [dict objectForKey:@"CDVType"];
+        if (!type || ![type isEqualToString:@"ArrayBuffer"]) {
+            continue;
+        }
+        NSString* data = [dict objectForKey:@"data"];
+        if (!data) {
+            continue;
+        }
+        [(NSMutableArray*) _arguments replaceObjectAtIndex:i withObject:[NSData dataFromBase64String:data]];
+    }
+}
+
 - (void)legacyArguments:(NSMutableArray**)legacyArguments andDict:(NSMutableDictionary**)legacyDict
 {
     NSMutableArray* newArguments = [NSMutableArray arrayWithArray:_arguments];