You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by tr...@apache.org on 2016/01/08 23:05:46 UTC
[1/3] mac commit: Support for multi-dimensional js array/objects
Repository: cordova-osx
Updated Branches:
refs/heads/master 6370c1e13 -> 4b1b68e36
Support for multi-dimensional js array/objects
Previous implementation was not parsing multi-dimensional JS array > object properly. Replacing it with webkit javascriptCore implementation solved it. (From OSX 10.5)
Project: http://git-wip-us.apache.org/repos/asf/cordova-osx/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-osx/commit/5ca3a7c8
Tree: http://git-wip-us.apache.org/repos/asf/cordova-osx/tree/5ca3a7c8
Diff: http://git-wip-us.apache.org/repos/asf/cordova-osx/diff/5ca3a7c8
Branch: refs/heads/master
Commit: 5ca3a7c8b023e47112d7731155e6d72777c78618
Parents: 6370c1e
Author: Sahil Bhardwaj <sa...@gmail.com>
Authored: Tue Dec 22 12:21:09 2015 +0530
Committer: Tobias Bocanegra <tr...@adobe.com>
Committed: Fri Jan 8 13:05:09 2016 -0800
----------------------------------------------------------------------
CordovaLib/CordovaLib/Classes/CDVBridge.m | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/5ca3a7c8/CordovaLib/CordovaLib/Classes/CDVBridge.m
----------------------------------------------------------------------
diff --git a/CordovaLib/CordovaLib/Classes/CDVBridge.m b/CordovaLib/CordovaLib/Classes/CDVBridge.m
index d9c3466..aafb541 100644
--- a/CordovaLib/CordovaLib/Classes/CDVBridge.m
+++ b/CordovaLib/CordovaLib/Classes/CDVBridge.m
@@ -18,6 +18,7 @@
*/
#import <WebKit/WebKit.h>
+#import <JavascriptCore/JavascriptCore.h>
#include <objc/message.h>
#import "CDVBridge.h"
@@ -112,7 +113,7 @@
// between iOS and OS X. Also we are going async as well.
// we're just going to assume the webScriptObject passed in is an NSArray
- NSArray* arguments = [self convertWebScriptObjectToNSArray:webScriptObject];
+ NSArray* arguments = [[webScriptObject JSValue] toArray];
CDVInvokedUrlCommand* command = [[CDVInvokedUrlCommand alloc] initWithArguments:arguments callbackId:callbackId className:service methodName:action];
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[2/3] mac commit: Update CDVBridge.m
Posted by tr...@apache.org.
Update CDVBridge.m
We don't need them anymore.. This closes #29
Project: http://git-wip-us.apache.org/repos/asf/cordova-osx/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-osx/commit/dd620c9b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-osx/tree/dd620c9b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-osx/diff/dd620c9b
Branch: refs/heads/master
Commit: dd620c9b913ec3cc909e4d41369a10c9fcf9b260
Parents: 5ca3a7c
Author: Sahil Bhardwaj <sa...@gmail.com>
Authored: Tue Dec 22 12:35:02 2015 +0530
Committer: Tobias Bocanegra <tr...@adobe.com>
Committed: Fri Jan 8 13:05:10 2016 -0800
----------------------------------------------------------------------
CordovaLib/CordovaLib/Classes/CDVBridge.m | 42 --------------------------
1 file changed, 42 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/dd620c9b/CordovaLib/CordovaLib/Classes/CDVBridge.m
----------------------------------------------------------------------
diff --git a/CordovaLib/CordovaLib/Classes/CDVBridge.m b/CordovaLib/CordovaLib/Classes/CDVBridge.m
index aafb541..5a67d24 100644
--- a/CordovaLib/CordovaLib/Classes/CDVBridge.m
+++ b/CordovaLib/CordovaLib/Classes/CDVBridge.m
@@ -41,48 +41,6 @@
return [result boolValue];
}
-- (NSDictionary*) convertWebScriptObjectToNSDictionary:(WebScriptObject*) webScriptObject {
- // Assumption: webScriptObject has already been tested using isDictionary:
-
- id win = [self.webView windowScriptObject];
-
- WebScriptObject* util = [win valueForKey:@"CordovaBridgeUtil"];
- WebScriptObject* keysObject = [util callWebScriptMethod:@"getDictionaryKeys" withArguments:@[webScriptObject]];
- NSArray* keys = [self convertWebScriptObjectToNSArray:keysObject];
- NSMutableDictionary* dict = [NSMutableDictionary dictionaryWithCapacity:[keys count]];
-
- NSEnumerator* enumerator = [keys objectEnumerator];
- id key;
- while ((key = enumerator.nextObject)) {
- dict[key] = [webScriptObject valueForKey:key];
- }
-
- return dict;
-}
-
-- (NSArray*) convertWebScriptObjectToNSArray:(WebScriptObject*) webScriptObject {
- // Assumption: webScriptObject has already been tested using isArray:
-
- NSUInteger count = [[webScriptObject valueForKey:@"length"] unsignedIntegerValue];
- NSMutableArray* a = [NSMutableArray array];
- for (unsigned i = 0; i < count; i++) {
- id item = [webScriptObject webScriptValueAtIndex:i];
- if (!item) {
- [a addObject:[NSNull null]];
- } else if ([item isKindOfClass:[WebScriptObject class]]) {
- if ([self isArray:item]) {
- [a addObject:[self convertWebScriptObjectToNSArray:item]];
- } else if ([self isDictionary:item]) {
- [a addObject:[self convertWebScriptObjectToNSDictionary:item]];
- };
- } else {
- [a addObject:item];
- }
- }
-
- return a;
-}
-
- (void) registerJavaScriptHelpers {
NSString* cordovaBridgeUtil = @"var CordovaBridgeUtil = {};";
NSString* isArray = [NSString stringWithFormat:@"CordovaBridgeUtil.isArray = function(obj) { return obj.constructor == Array; };"];
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[3/3] mac commit: CB-10308 Unable to parse multi dimensional arrays
with more than 2 levels
Posted by tr...@apache.org.
CB-10308 Unable to parse multi dimensional arrays with more than 2 levels
- enabling tests
- remove unused code
Project: http://git-wip-us.apache.org/repos/asf/cordova-osx/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-osx/commit/4b1b68e3
Tree: http://git-wip-us.apache.org/repos/asf/cordova-osx/tree/4b1b68e3
Diff: http://git-wip-us.apache.org/repos/asf/cordova-osx/diff/4b1b68e3
Branch: refs/heads/master
Commit: 4b1b68e3644d7c4786f77ae83b5f17e16479567a
Parents: dd620c9
Author: Tobias Bocanegra <tr...@adobe.com>
Authored: Fri Jan 8 14:05:19 2016 -0800
Committer: Tobias Bocanegra <tr...@adobe.com>
Committed: Fri Jan 8 14:05:19 2016 -0800
----------------------------------------------------------------------
CordovaLib/CordovaLib/Classes/CDVBridge.m | 19 -------------------
tests/CordovaLibTests/CordovaLibApp/www/tests.js | 4 ++--
2 files changed, 2 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/4b1b68e3/CordovaLib/CordovaLib/Classes/CDVBridge.m
----------------------------------------------------------------------
diff --git a/CordovaLib/CordovaLib/Classes/CDVBridge.m b/CordovaLib/CordovaLib/Classes/CDVBridge.m
index 5a67d24..4eeb056 100644
--- a/CordovaLib/CordovaLib/Classes/CDVBridge.m
+++ b/CordovaLib/CordovaLib/Classes/CDVBridge.m
@@ -26,31 +26,12 @@
@implementation CDVBridge
-- (BOOL) isArray:(id) item {
- id win = [self.webView windowScriptObject];
- WebScriptObject* bridgeUtil = [win evaluateWebScript:@"CordovaBridgeUtil"];
- NSNumber* result = [bridgeUtil callWebScriptMethod:@"isArray" withArguments:@[item]];
-
- return [result boolValue];
-}
-
-- (BOOL) isDictionary:(id) item {
- id win = [self.webView windowScriptObject];
- WebScriptObject* bridgeUtil = [win evaluateWebScript:@"CordovaBridgeUtil"];
- NSNumber* result = [bridgeUtil callWebScriptMethod:@"isObject" withArguments:@[item]];
- return [result boolValue];
-}
-
- (void) registerJavaScriptHelpers {
NSString* cordovaBridgeUtil = @"var CordovaBridgeUtil = {};";
- NSString* isArray = [NSString stringWithFormat:@"CordovaBridgeUtil.isArray = function(obj) { return obj.constructor == Array; };"];
- NSString* isObject = [NSString stringWithFormat:@"CordovaBridgeUtil.isObject = function(obj) { return obj.constructor == Object; };"];
NSString* dictionaryKeys = [NSString stringWithFormat:@"CordovaBridgeUtil.getDictionaryKeys = function(obj) { return Object.keys(obj);};"];
id win = [self.webView windowScriptObject];
[win evaluateWebScript:cordovaBridgeUtil];
- [win evaluateWebScript:isArray];
- [win evaluateWebScript:isObject];
[win evaluateWebScript:dictionaryKeys];
}
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/4b1b68e3/tests/CordovaLibTests/CordovaLibApp/www/tests.js
----------------------------------------------------------------------
diff --git a/tests/CordovaLibTests/CordovaLibApp/www/tests.js b/tests/CordovaLibTests/CordovaLibApp/www/tests.js
index 2f65b7b..57db1bf 100644
--- a/tests/CordovaLibTests/CordovaLibApp/www/tests.js
+++ b/tests/CordovaLibTests/CordovaLibApp/www/tests.js
@@ -29,8 +29,8 @@ function echoTests() {
'double': 3.141,
'array': ['a','b','c'],
'nested-array': ['a','b','c', [1,2,3]],
- 'object': {a:'a', b:'b'}
- // 'nested-object': {a:'a', b:'b', c:{d:'d'}} (does not work yet, CB-10308)
+ 'object': {a:'a', b:'b'},
+ 'nested-object': {a:'a', b:'b', c:{d:'d'}}
};
var tests = [];
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org