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:27 UTC
[4/4] mac commit: @trivial avoid __weak - otherwise background blocks
might encounter empty objects
@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