You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2015/08/26 03:06:24 UTC
[1/4] mac commit: @trivial reformat code - clean whitespaces
Repository: cordova-osx
Updated Branches:
refs/heads/master 3722eac36 -> 05c4d55ef
@trivial reformat code - clean whitespaces
Project: http://git-wip-us.apache.org/repos/asf/cordova-osx/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-osx/commit/192b60ae
Tree: http://git-wip-us.apache.org/repos/asf/cordova-osx/tree/192b60ae
Diff: http://git-wip-us.apache.org/repos/asf/cordova-osx/diff/192b60ae
Branch: refs/heads/master
Commit: 192b60aea417825a09e98b5a1ad2bdadf186c5ef
Parents: 3722eac
Author: Tobias Bocanegra <tr...@adobe.com>
Authored: Tue Aug 25 17:07:57 2015 -0700
Committer: Tobias Bocanegra <tr...@adobe.com>
Committed: Tue Aug 25 17:07:57 2015 -0700
----------------------------------------------------------------------
CordovaLib/CordovaLib/Classes/CDVBridge.h | 20 ++--
CordovaLib/CordovaLib/Classes/CDVBridge.m | 115 ++++++++-----------
.../Classes/Commands/CDVConfigParser.m | 2 +-
3 files changed, 59 insertions(+), 78 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/192b60ae/CordovaLib/CordovaLib/Classes/CDVBridge.h
----------------------------------------------------------------------
diff --git a/CordovaLib/CordovaLib/Classes/CDVBridge.h b/CordovaLib/CordovaLib/Classes/CDVBridge.h
index 5d15064..62ef8cb 100644
--- a/CordovaLib/CordovaLib/Classes/CDVBridge.h
+++ b/CordovaLib/CordovaLib/Classes/CDVBridge.h
@@ -6,9 +6,9 @@
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
-
+
http://www.apache.org/licenses/LICENSE-2.0
-
+
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -18,25 +18,19 @@
*/
#import <Cocoa/Cocoa.h>
+
@class WebView;
@class CDVViewController;
@interface CDVBridge : NSObject {
-
}
-@property (nonatomic, weak) WebView* webView;
-@property (nonatomic,
-#ifdef __MAC_10_8
- weak
-#else
- assign
-#endif
- ) CDVViewController* viewController;
+@property(nonatomic, weak) WebView* webView;
+@property(nonatomic,assign) CDVViewController* viewController;
+- (id) initWithWebView:(WebView*) webView andViewController:(CDVViewController*) viewController;
-- (id) initWithWebView:(WebView*)webView andViewController:(CDVViewController*)viewController;
-- (void) exec:(NSString*)callbackId withService:(NSString*)service andAction:(NSString*)action andArguments:(NSArray*)arguments;
+- (void) exec:(NSString*) callbackId withService:(NSString*) service andAction:(NSString*) action andArguments:(NSArray*) arguments;
@end
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/192b60ae/CordovaLib/CordovaLib/Classes/CDVBridge.m
----------------------------------------------------------------------
diff --git a/CordovaLib/CordovaLib/Classes/CDVBridge.m b/CordovaLib/CordovaLib/Classes/CDVBridge.m
index 6e4d147..1610083 100644
--- a/CordovaLib/CordovaLib/Classes/CDVBridge.m
+++ b/CordovaLib/CordovaLib/Classes/CDVBridge.m
@@ -6,9 +6,9 @@
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
-
+
http://www.apache.org/licenses/LICENSE-2.0
-
+
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -18,8 +18,6 @@
*/
#import <WebKit/WebKit.h>
-#import <AppKit/AppKit.h>
-#import <Foundation/NSJSONSerialization.h>
#include <objc/message.h>
#import "CDVBridge.h"
@@ -27,8 +25,7 @@
@implementation CDVBridge
-- (BOOL) isArray:(id)item
-{
+- (BOOL) isArray:(id) item {
id win = [self.webView windowScriptObject];
WebScriptObject* bridgeUtil = [win evaluateWebScript:@"CordovaBridgeUtil"];
NSNumber* result = [bridgeUtil callWebScriptMethod:@"isArray" withArguments:[NSArray arrayWithObject:item]];
@@ -36,21 +33,19 @@
return [result boolValue];
}
-- (BOOL) isDictionary:(id)item
-{
+- (BOOL) isDictionary:(id) item {
id win = [self.webView windowScriptObject];
WebScriptObject* bridgeUtil = [win evaluateWebScript:@"CordovaBridgeUtil"];
NSNumber* result = [bridgeUtil callWebScriptMethod:@"isObject" withArguments:[NSArray arrayWithObject:item]];
return [result boolValue];
}
-- (NSDictionary*) convertWebScriptObjectToNSDictionary:(WebScriptObject*)webScriptObject
-{
+- (NSDictionary*) convertWebScriptObjectToNSDictionary:(WebScriptObject*) webScriptObject {
// Assumption: webScriptObject has already been tested using isDictionary:
id win = [self.webView windowScriptObject];
-
- WebScriptObject *util = [win valueForKey:@"CordovaBridgeUtil"];
+
+ WebScriptObject* util = [win valueForKey:@"CordovaBridgeUtil"];
WebScriptObject* keysObject = [util callWebScriptMethod:@"getDictionaryKeys" withArguments:[NSArray arrayWithObject:webScriptObject]];
NSArray* keys = [self convertWebScriptObjectToNSArray:keysObject];
NSMutableDictionary* dict = [NSMutableDictionary dictionaryWithCapacity:[keys count]];
@@ -60,16 +55,15 @@
while (key = [enumerator nextObject]) {
[dict setObject:[webScriptObject valueForKey:key] forKey:key];
}
-
+
return dict;
}
-- (NSArray*) convertWebScriptObjectToNSArray:(WebScriptObject*)webScriptObject
-{
+- (NSArray*) convertWebScriptObjectToNSArray:(WebScriptObject*) webScriptObject {
// Assumption: webScriptObject has already been tested using isArray:
-
+
NSUInteger count = [[webScriptObject valueForKey:@"length"] integerValue];
- NSMutableArray *a = [NSMutableArray array];
+ NSMutableArray* a = [NSMutableArray array];
for (unsigned i = 0; i < count; i++) {
id item = [webScriptObject webScriptValueAtIndex:i];
if ([item isKindOfClass:[WebScriptObject class]]) {
@@ -82,17 +76,16 @@
[a addObject:item];
}
}
-
+
return a;
}
-- (void) registerJavaScriptHelpers
-{
+- (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];
@@ -100,37 +93,35 @@
[win evaluateWebScript:dictionaryKeys];
}
-- (id) initWithWebView:(WebView *)webView andViewController:(CDVViewController*)viewController
-{
+- (id) initWithWebView:(WebView*) webView andViewController:(CDVViewController*) viewController {
if ((self = [super init]) != nil) {
self.webView = webView;
self.viewController = viewController;
[self registerJavaScriptHelpers];
}
-
+
return self;
}
-- (void) exec:(NSString*)callbackId withService:(NSString*)service andAction:(NSString*)action andArguments:(WebScriptObject*)webScriptObject
-{
+- (void) exec:(NSString*) callbackId withService:(NSString*) service andAction:(NSString*) action andArguments:(WebScriptObject*) webScriptObject {
// We are going with the iOS method of passing in a callbackId.
// Note that we can use the JavaScriptCore C API to pass in the JavaScript function references
// and context and call them directly, but this is done this way for possible plugin sharing
// 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];
-
+
CDVInvokedUrlCommand* command = [[CDVInvokedUrlCommand alloc] initWithArguments:arguments callbackId:callbackId className:service methodName:action];
-
+
if ((command.className == nil) || (command.methodName == nil)) {
NSLog(@"ERROR: Classname and/or methodName not found for command.");
return;
}
-
+
// Fetch an instance of this class
CDVPlugin* obj = [_viewController.commandDelegate getCommandInstance:command.className];
-
+
if (!([obj isKindOfClass:[CDVPlugin class]])) {
NSLog(@"ERROR: Plugin '%@' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.", command.className);
return;
@@ -151,45 +142,41 @@
#pragma mark WebScripting Protocol
/* checks whether a selector is acceptable to be called from JavaScript */
-+ (BOOL) isSelectorExcludedFromWebScript:(SEL)selector
-{
- BOOL result = YES;
-
- int i = 0;
- static SEL * acceptableList = NULL;
- SEL currentSelector;
-
- if (acceptableList == NULL && (acceptableList = calloc(256, sizeof(SEL)))) // up to 256 selectors
- {
- acceptableList[i++] = @selector(exec:withService:andAction:andArguments:);
- }
-
- i = 0;
- while (result == YES && (currentSelector = acceptableList[i++]))
- {
- //checking for exclusions
- result = !(selector == currentSelector);
- }
-
- return result;
++ (BOOL) isSelectorExcludedFromWebScript:(SEL) selector {
+ BOOL result = YES;
+
+ int i = 0;
+ static SEL* acceptableList = NULL;
+ SEL currentSelector;
+
+ if (acceptableList == NULL && (acceptableList = calloc(256, sizeof(SEL)))) // up to 256 selectors
+ {
+ acceptableList[i++] = @selector(exec:withService:andAction:andArguments:);
+ }
+
+ i = 0;
+ while (result == YES && (currentSelector = acceptableList[i++])) {
+ //checking for exclusions
+ result = !(selector == currentSelector);
+ }
+
+ return result;
}
/* helper function so we don't have to have underscores and stuff in js to refer to the right method */
-+ (NSString*) webScriptNameForSelector:(SEL)aSelector
-{
- id result = nil;
-
- if (aSelector == @selector(exec:withService:andAction:andArguments:)) {
- result = @"exec";
- }
-
- return result;
++ (NSString*) webScriptNameForSelector:(SEL) aSelector {
+ id result = nil;
+
+ if (aSelector == @selector(exec:withService:andAction:andArguments:)) {
+ result = @"exec";
+ }
+
+ return result;
}
// right now exclude all properties (eg keys)
-+ (BOOL) isKeyExcludedFromWebScript:(const char*)name
-{
- return YES;
++ (BOOL) isKeyExcludedFromWebScript:(const char*) name {
+ return YES;
}
@end
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/192b60ae/CordovaLib/CordovaLib/Classes/Commands/CDVConfigParser.m
----------------------------------------------------------------------
diff --git a/CordovaLib/CordovaLib/Classes/Commands/CDVConfigParser.m b/CordovaLib/CordovaLib/Classes/Commands/CDVConfigParser.m
index ba71066..a345cdc 100644
--- a/CordovaLib/CordovaLib/Classes/Commands/CDVConfigParser.m
+++ b/CordovaLib/CordovaLib/Classes/Commands/CDVConfigParser.m
@@ -100,7 +100,7 @@
- (void)parser:(NSXMLParser*)parser parseErrorOccurred:(NSError*)parseError
{
- NSAssert(NO, @"config.xml parse error line %d col %d", [parser lineNumber], [parser columnNumber]);
+ NSAssert(NO, @"config.xml parse error line %ld col %ld", [parser lineNumber], [parser columnNumber]);
}
@end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[3/4] mac commit: @trivial - avoid NPE when adding a nil object to
NSArray
Posted by sh...@apache.org.
@trivial - avoid NPE when adding a nil object to NSArray
Project: http://git-wip-us.apache.org/repos/asf/cordova-osx/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-osx/commit/de664c46
Tree: http://git-wip-us.apache.org/repos/asf/cordova-osx/tree/de664c46
Diff: http://git-wip-us.apache.org/repos/asf/cordova-osx/diff/de664c46
Branch: refs/heads/master
Commit: de664c46271647efda330acd481a8eb8e974f4d7
Parents: afae3f4
Author: Tobias Bocanegra <tr...@adobe.com>
Authored: Tue Aug 25 17:16:56 2015 -0700
Committer: Tobias Bocanegra <tr...@adobe.com>
Committed: Tue Aug 25 17:16:56 2015 -0700
----------------------------------------------------------------------
CordovaLib/CordovaLib/Classes/CDVBridge.m | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/de664c46/CordovaLib/CordovaLib/Classes/CDVBridge.m
----------------------------------------------------------------------
diff --git a/CordovaLib/CordovaLib/Classes/CDVBridge.m b/CordovaLib/CordovaLib/Classes/CDVBridge.m
index 65a403a..d9c3466 100644
--- a/CordovaLib/CordovaLib/Classes/CDVBridge.m
+++ b/CordovaLib/CordovaLib/Classes/CDVBridge.m
@@ -66,7 +66,9 @@
NSMutableArray* a = [NSMutableArray array];
for (unsigned i = 0; i < count; i++) {
id item = [webScriptObject webScriptValueAtIndex:i];
- if ([item isKindOfClass:[WebScriptObject class]]) {
+ 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]) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[4/4] mac commit: @trivial avoid __weak - otherwise background blocks
might encounter empty objects
Posted by sh...@apache.org.
@trivial avoid __weak - otherwise background blocks might encounter empty objects
Project: http://git-wip-us.apache.org/repos/asf/cordova-osx/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-osx/commit/05c4d55e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-osx/tree/05c4d55e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-osx/diff/05c4d55e
Branch: refs/heads/master
Commit: 05c4d55efe00e39acb4f2b1a8e9a1eb497ff49b3
Parents: de664c4
Author: Tobias Bocanegra <tr...@adobe.com>
Authored: Tue Aug 25 17:53:52 2015 -0700
Committer: Tobias Bocanegra <tr...@adobe.com>
Committed: Tue Aug 25 17:53:52 2015 -0700
----------------------------------------------------------------------
CordovaLib/CordovaLib.xcodeproj/project.pbxproj | 4 +-
.../Classes/Commands/CDVInvokedUrlCommand.h | 36 +++++-----
.../Classes/Commands/CDVInvokedUrlCommand.m | 70 ++++++--------------
3 files changed, 40 insertions(+), 70 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/05c4d55e/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
index bd6d943..a087a66 100644
--- a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
+++ b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
@@ -389,7 +389,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- MACOSX_DEPLOYMENT_TARGET = 10.8;
+ MACOSX_DEPLOYMENT_TARGET = 10.9;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_NAME = Cordova;
PUBLIC_HEADERS_FOLDER_PATH = include/Cordova;
@@ -424,7 +424,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- MACOSX_DEPLOYMENT_TARGET = 10.8;
+ MACOSX_DEPLOYMENT_TARGET = 10.9;
PRODUCT_NAME = Cordova;
PUBLIC_HEADERS_FOLDER_PATH = include/Cordova;
SDKROOT = macosx;
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/05c4d55e/CordovaLib/CordovaLib/Classes/Commands/CDVInvokedUrlCommand.h
----------------------------------------------------------------------
diff --git a/CordovaLib/CordovaLib/Classes/Commands/CDVInvokedUrlCommand.h b/CordovaLib/CordovaLib/Classes/Commands/CDVInvokedUrlCommand.h
index 5f7e204..a15ab3c 100644
--- a/CordovaLib/CordovaLib/Classes/Commands/CDVInvokedUrlCommand.h
+++ b/CordovaLib/CordovaLib/Classes/Commands/CDVInvokedUrlCommand.h
@@ -20,33 +20,35 @@
#import <Foundation/Foundation.h>
@interface CDVInvokedUrlCommand : NSObject {
- NSString* __weak _callbackId;
- NSString* __weak _className;
- NSString* __weak _methodName;
- NSArray* __weak _arguments;
+ NSString* _callbackId;
+ NSString* _className;
+ NSString* _methodName;
+ NSArray* _arguments;
}
-@property (weak, nonatomic, readonly) NSArray* arguments;
-@property (weak, nonatomic, readonly) NSString* callbackId;
-@property (weak, nonatomic, readonly) NSString* className;
-@property (weak, nonatomic, readonly) NSString* methodName;
+@property(nonatomic, readonly) NSArray* arguments;
+@property(nonatomic, readonly) NSString* callbackId;
+@property(nonatomic, readonly) NSString* className;
+@property(nonatomic, readonly) NSString* methodName;
-+ (CDVInvokedUrlCommand*)commandFromJson:(NSArray*)jsonEntry;
++ (CDVInvokedUrlCommand*) commandFromJson:(NSArray*) jsonEntry;
-- (id)initWithArguments:(NSArray*)arguments
- callbackId :(NSString*)callbackId
- className :(NSString*)className
- methodName :(NSString*)methodName;
+- (id) initWithArguments:(NSArray*) arguments
+ callbackId:(NSString*) callbackId
+ className:(NSString*) className
+ methodName:(NSString*) methodName;
-- (id)initFromJson:(NSArray*)jsonEntry;
+- (id) initFromJson:(NSArray*) jsonEntry;
// Returns the argument at the given index.
// If index >= the number of arguments, returns nil.
// If the argument at the given index is NSNull, returns nil.
-- (id)argumentAtIndex:(NSUInteger)index;
+- (id) argumentAtIndex:(NSUInteger) index;
+
// Same as above, but returns defaultValue instead of nil.
-- (id)argumentAtIndex:(NSUInteger)index withDefault:(id)defaultValue;
+- (id) argumentAtIndex:(NSUInteger) index withDefault:(id) defaultValue;
+
// Same as above, but returns defaultValue instead of nil, and if the argument is not of the expected class, returns defaultValue
-- (id)argumentAtIndex:(NSUInteger)index withDefault:(id)defaultValue andClass:(Class)aClass;
+- (id) argumentAtIndex:(NSUInteger) index withDefault:(id) defaultValue andClass:(Class) aClass;
@end
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/05c4d55e/CordovaLib/CordovaLib/Classes/Commands/CDVInvokedUrlCommand.m
----------------------------------------------------------------------
diff --git a/CordovaLib/CordovaLib/Classes/Commands/CDVInvokedUrlCommand.m b/CordovaLib/CordovaLib/Classes/Commands/CDVInvokedUrlCommand.m
index 6c7a856..6d73610 100644
--- a/CordovaLib/CordovaLib/Classes/Commands/CDVInvokedUrlCommand.m
+++ b/CordovaLib/CordovaLib/Classes/Commands/CDVInvokedUrlCommand.m
@@ -18,8 +18,6 @@
*/
#import "CDVInvokedUrlCommand.h"
-#import "CDVJSON.h"
-#import "NSData+Base64.h"
@implementation CDVInvokedUrlCommand
@@ -28,18 +26,16 @@
@synthesize className = _className;
@synthesize methodName = _methodName;
-+ (CDVInvokedUrlCommand*)commandFromJson:(NSArray*)jsonEntry
-{
++ (CDVInvokedUrlCommand*) commandFromJson:(NSArray*) jsonEntry {
return [[CDVInvokedUrlCommand alloc] initFromJson:jsonEntry];
}
-- (id)initFromJson:(NSArray*)jsonEntry
-{
- id tmp = [jsonEntry objectAtIndex:0];
+- (id) initFromJson:(NSArray*) jsonEntry {
+ id tmp = jsonEntry[0];
NSString* callbackId = tmp == [NSNull null] ? nil : tmp;
- NSString* className = [jsonEntry objectAtIndex:1];
- NSString* methodName = [jsonEntry objectAtIndex:2];
- NSMutableArray* arguments = [jsonEntry objectAtIndex:3];
+ NSString* className = jsonEntry[1];
+ NSString* methodName = jsonEntry[2];
+ NSMutableArray* arguments = jsonEntry[3];
return [self initWithArguments:arguments
callbackId:callbackId
@@ -47,11 +43,10 @@
methodName:methodName];
}
-- (id)initWithArguments:(NSArray*)arguments
- callbackId:(NSString*)callbackId
- className:(NSString*)className
- methodName:(NSString*)methodName
-{
+- (id) initWithArguments:(NSArray*) arguments
+ callbackId:(NSString*) callbackId
+ className:(NSString*) className
+ methodName:(NSString*) methodName {
self = [super init];
if (self != nil) {
_arguments = arguments;
@@ -63,21 +58,20 @@
return self;
}
-- (void)massageArguments
-{
+- (void) massageArguments {
NSMutableArray* newArgs = nil;
for (NSUInteger i = 0, count = [_arguments count]; i < count; ++i) {
- id arg = [_arguments objectAtIndex:i];
+ id arg = _arguments[i];
if (![arg isKindOfClass:[NSDictionary class]]) {
continue;
}
NSDictionary* dict = arg;
- NSString* type = [dict objectForKey:@"CDVType"];
+ NSString* type = dict[@"CDVType"];
if (!type || ![type isEqualToString:@"ArrayBuffer"]) {
continue;
}
- NSString* data = [dict objectForKey:@"data"];
+ NSString* data = dict[@"data"];
if (!data) {
continue;
}
@@ -85,49 +79,23 @@
newArgs = [NSMutableArray arrayWithArray:_arguments];
_arguments = newArgs;
}
- [newArgs replaceObjectAtIndex:i withObject:[NSData dataFromBase64String:data]];
+ newArgs[i] = [[NSData alloc] initWithBase64EncodedString:data options:0];
}
}
-- (void)legacyArguments:(NSMutableArray**)legacyArguments andDict:(NSMutableDictionary**)legacyDict
-{
- NSMutableArray* newArguments = [NSMutableArray arrayWithArray:_arguments];
-
- for (NSUInteger i = 0; i < [newArguments count]; ++i) {
- if ([[newArguments objectAtIndex:i] isKindOfClass:[NSDictionary class]]) {
- if (legacyDict != NULL) {
- *legacyDict = [newArguments objectAtIndex:i];
- }
- [newArguments removeObjectAtIndex:i];
- break;
- }
- }
-
- // Legacy (two versions back) has no callbackId.
- if (_callbackId != nil) {
- [newArguments insertObject:_callbackId atIndex:0];
- }
- if (legacyArguments != NULL) {
- *legacyArguments = newArguments;
- }
-}
-
-- (id)argumentAtIndex:(NSUInteger)index
-{
+- (id) argumentAtIndex:(NSUInteger) index {
return [self argumentAtIndex:index withDefault:nil];
}
-- (id)argumentAtIndex:(NSUInteger)index withDefault:(id)defaultValue
-{
+- (id) argumentAtIndex:(NSUInteger) index withDefault:(id) defaultValue {
return [self argumentAtIndex:index withDefault:defaultValue andClass:nil];
}
-- (id)argumentAtIndex:(NSUInteger)index withDefault:(id)defaultValue andClass:(Class)aClass
-{
+- (id) argumentAtIndex:(NSUInteger) index withDefault:(id) defaultValue andClass:(Class) aClass {
if (index >= [_arguments count]) {
return defaultValue;
}
- id ret = [_arguments objectAtIndex:index];
+ id ret = _arguments[index];
if (ret == [NSNull null]) {
ret = defaultValue;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[2/4] mac commit: @trivial - simplify with modern syntax
Posted by sh...@apache.org.
@trivial - simplify with modern syntax
Project: http://git-wip-us.apache.org/repos/asf/cordova-osx/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-osx/commit/afae3f46
Tree: http://git-wip-us.apache.org/repos/asf/cordova-osx/tree/afae3f46
Diff: http://git-wip-us.apache.org/repos/asf/cordova-osx/diff/afae3f46
Branch: refs/heads/master
Commit: afae3f46613b1c042bc80b5d05f8372e7cd58328
Parents: 192b60a
Author: Tobias Bocanegra <tr...@adobe.com>
Authored: Tue Aug 25 17:15:22 2015 -0700
Committer: Tobias Bocanegra <tr...@adobe.com>
Committed: Tue Aug 25 17:15:22 2015 -0700
----------------------------------------------------------------------
CordovaLib/CordovaLib/Classes/CDVBridge.m | 41 +++++++-------------------
1 file changed, 11 insertions(+), 30 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/afae3f46/CordovaLib/CordovaLib/Classes/CDVBridge.m
----------------------------------------------------------------------
diff --git a/CordovaLib/CordovaLib/Classes/CDVBridge.m b/CordovaLib/CordovaLib/Classes/CDVBridge.m
index 1610083..65a403a 100644
--- a/CordovaLib/CordovaLib/Classes/CDVBridge.m
+++ b/CordovaLib/CordovaLib/Classes/CDVBridge.m
@@ -28,7 +28,7 @@
- (BOOL) isArray:(id) item {
id win = [self.webView windowScriptObject];
WebScriptObject* bridgeUtil = [win evaluateWebScript:@"CordovaBridgeUtil"];
- NSNumber* result = [bridgeUtil callWebScriptMethod:@"isArray" withArguments:[NSArray arrayWithObject:item]];
+ NSNumber* result = [bridgeUtil callWebScriptMethod:@"isArray" withArguments:@[item]];
return [result boolValue];
}
@@ -36,7 +36,7 @@
- (BOOL) isDictionary:(id) item {
id win = [self.webView windowScriptObject];
WebScriptObject* bridgeUtil = [win evaluateWebScript:@"CordovaBridgeUtil"];
- NSNumber* result = [bridgeUtil callWebScriptMethod:@"isObject" withArguments:[NSArray arrayWithObject:item]];
+ NSNumber* result = [bridgeUtil callWebScriptMethod:@"isObject" withArguments:@[item]];
return [result boolValue];
}
@@ -46,14 +46,14 @@
id win = [self.webView windowScriptObject];
WebScriptObject* util = [win valueForKey:@"CordovaBridgeUtil"];
- WebScriptObject* keysObject = [util callWebScriptMethod:@"getDictionaryKeys" withArguments:[NSArray arrayWithObject:webScriptObject]];
+ 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 setObject:[webScriptObject valueForKey:key] forKey:key];
+ while ((key = enumerator.nextObject)) {
+ dict[key] = [webScriptObject valueForKey:key];
}
return dict;
@@ -62,7 +62,7 @@
- (NSArray*) convertWebScriptObjectToNSArray:(WebScriptObject*) webScriptObject {
// Assumption: webScriptObject has already been tested using isArray:
- NSUInteger count = [[webScriptObject valueForKey:@"length"] integerValue];
+ NSUInteger count = [[webScriptObject valueForKey:@"length"] unsignedIntegerValue];
NSMutableArray* a = [NSMutableArray array];
for (unsigned i = 0; i < count; i++) {
id item = [webScriptObject webScriptValueAtIndex:i];
@@ -142,36 +142,17 @@
#pragma mark WebScripting Protocol
/* checks whether a selector is acceptable to be called from JavaScript */
-+ (BOOL) isSelectorExcludedFromWebScript:(SEL) selector {
- BOOL result = YES;
-
- int i = 0;
- static SEL* acceptableList = NULL;
- SEL currentSelector;
-
- if (acceptableList == NULL && (acceptableList = calloc(256, sizeof(SEL)))) // up to 256 selectors
- {
- acceptableList[i++] = @selector(exec:withService:andAction:andArguments:);
- }
-
- i = 0;
- while (result == YES && (currentSelector = acceptableList[i++])) {
- //checking for exclusions
- result = !(selector == currentSelector);
- }
-
- return result;
++ (BOOL) isSelectorExcludedFromWebScript:(SEL) sel {
+ return sel != @selector(exec:withService:andAction:andArguments:);
}
/* helper function so we don't have to have underscores and stuff in js to refer to the right method */
+ (NSString*) webScriptNameForSelector:(SEL) aSelector {
- id result = nil;
-
if (aSelector == @selector(exec:withService:andAction:andArguments:)) {
- result = @"exec";
+ return @"exec";
+ } else {
+ return nil;
}
-
- return result;
}
// right now exclude all properties (eg keys)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org