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/03/06 23:27:35 UTC
[03/31] ios commit: Revert "CB-8270 Rename category methods for JSON
handling with a prefix (close #124)"
Revert "CB-8270 Rename category methods for JSON handling with a prefix (close #124)"
This reverts commit a98144b8ad63fe714c9f6d274bc9fd98b62575e7.
To be un-reverted in 4.0.x branch.
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/3543c9e4
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/3543c9e4
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/3543c9e4
Branch: refs/heads/wkwebview
Commit: 3543c9e43749c7c7b1b736ddca2a92608e979081
Parents: 60f8c58
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Jan 22 12:49:51 2015 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Jan 22 12:49:51 2015 -0500
----------------------------------------------------------------------
CordovaLib/Classes/CDVCommandQueue.m | 6 +++---
CordovaLib/Classes/CDVJSON.h | 8 ++++----
CordovaLib/Classes/CDVJSON.m | 9 ++++-----
CordovaLib/Classes/CDVPluginResult.m | 2 +-
.../CDVPluginResultJSONSerializationTests.m | 16 ++++++++--------
5 files changed, 20 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/3543c9e4/CordovaLib/Classes/CDVCommandQueue.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCommandQueue.m b/CordovaLib/Classes/CDVCommandQueue.m
index 0b15fff..1eddfe3 100644
--- a/CordovaLib/Classes/CDVCommandQueue.m
+++ b/CordovaLib/Classes/CDVCommandQueue.m
@@ -70,10 +70,10 @@ static const double MAX_EXECUTION_TIME = .008; // Half of a 60fps frame.
NSMutableArray* commandBatchHolder = [[NSMutableArray alloc] init];
[_queue addObject:commandBatchHolder];
if ([batchJSON length] < JSON_SIZE_FOR_MAIN_THREAD) {
- [commandBatchHolder addObject:[batchJSON cdv_JSONObject]];
+ [commandBatchHolder addObject:[batchJSON JSONObject]];
} else {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^() {
- NSMutableArray* result = [batchJSON cdv_JSONObject];
+ NSMutableArray* result = [batchJSON JSONObject];
@synchronized(commandBatchHolder) {
[commandBatchHolder addObject:result];
}
@@ -149,7 +149,7 @@ static const double MAX_EXECUTION_TIME = .008; // Half of a 60fps frame.
if (![self execute:command]) {
#ifdef DEBUG
- NSString* commandJson = [jsonEntry cdv_JSONString];
+ NSString* commandJson = [jsonEntry JSONString];
static NSUInteger maxLogLength = 1024;
NSString* commandString = ([commandJson length] > maxLogLength) ?
[NSString stringWithFormat:@"%@[...]", [commandJson substringToIndex:maxLogLength]] :
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/3543c9e4/CordovaLib/Classes/CDVJSON.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVJSON.h b/CordovaLib/Classes/CDVJSON.h
index a81d549..8ad85da 100644
--- a/CordovaLib/Classes/CDVJSON.h
+++ b/CordovaLib/Classes/CDVJSON.h
@@ -18,14 +18,14 @@
*/
@interface NSArray (CDVJSONSerializing)
-- (NSString*)cdv_JSONString;
+- (NSString*)JSONString;
@end
@interface NSDictionary (CDVJSONSerializing)
-- (NSString*)cdv_JSONString;
+- (NSString*)JSONString;
@end
@interface NSString (CDVJSONSerializing)
-- (id)cdv_JSONObject;
-- (id)cdv_JSONFragment;
+- (id)JSONObject;
+- (id)JSONFragment;
@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/3543c9e4/CordovaLib/Classes/CDVJSON.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVJSON.m b/CordovaLib/Classes/CDVJSON.m
index 9aa07f8..4698bfe 100644
--- a/CordovaLib/Classes/CDVJSON.m
+++ b/CordovaLib/Classes/CDVJSON.m
@@ -22,7 +22,7 @@
@implementation NSArray (CDVJSONSerializing)
-- (NSString*)cdv_JSONString
+- (NSString*)JSONString
{
NSError* error = nil;
NSData* jsonData = [NSJSONSerialization dataWithJSONObject:self
@@ -41,7 +41,7 @@
@implementation NSDictionary (CDVJSONSerializing)
-- (NSString*)cdv_JSONString
+- (NSString*)JSONString
{
NSError* error = nil;
NSData* jsonData = [NSJSONSerialization dataWithJSONObject:self
@@ -60,7 +60,7 @@
@implementation NSString (CDVJSONSerializing)
-- (id)cdv_JSONObject
+- (id)JSONObject
{
NSError* error = nil;
id object = [NSJSONSerialization JSONObjectWithData:[self dataUsingEncoding:NSUTF8StringEncoding]
@@ -74,7 +74,7 @@
return object;
}
-- (id)cdv_JSONFragment
+- (id)JSONFragment
{
NSError* error = nil;
id object = [NSJSONSerialization JSONObjectWithData:[self dataUsingEncoding:NSUTF8StringEncoding]
@@ -89,4 +89,3 @@
}
@end
-
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/3543c9e4/CordovaLib/Classes/CDVPluginResult.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVPluginResult.m b/CordovaLib/Classes/CDVPluginResult.m
index b8b69ed..2eb46cd 100644
--- a/CordovaLib/Classes/CDVPluginResult.m
+++ b/CordovaLib/Classes/CDVPluginResult.m
@@ -156,7 +156,7 @@ id messageFromMultipart(NSArray* theMessages)
id arguments = (self.message == nil ? [NSNull null] : self.message);
NSArray* argumentsWrappedInArray = [NSArray arrayWithObject:arguments];
- NSString* argumentsJSON = [argumentsWrappedInArray cdv_JSONString];
+ NSString* argumentsJSON = [argumentsWrappedInArray JSONString];
argumentsJSON = [argumentsJSON substringWithRange:NSMakeRange(1, [argumentsJSON length] - 2)];
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/3543c9e4/tests/CordovaLibTests/CDVPluginResultJSONSerializationTests.m
----------------------------------------------------------------------
diff --git a/tests/CordovaLibTests/CDVPluginResultJSONSerializationTests.m b/tests/CordovaLibTests/CDVPluginResultJSONSerializationTests.m
index 83ed4d4..e87f52d 100644
--- a/tests/CordovaLibTests/CDVPluginResultJSONSerializationTests.m
+++ b/tests/CordovaLibTests/CDVPluginResultJSONSerializationTests.m
@@ -33,7 +33,7 @@
int val = 5;
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:val];
- XCTAssertTrue([[NSNumber numberWithInt:val] isEqual:[[result argumentsAsJSON] cdv_JSONFragment]]);
+ XCTAssertTrue([[NSNumber numberWithInt:val] isEqual:[[result argumentsAsJSON] JSONFragment]]);
}
- (void)testSerializingMessageAsDouble
@@ -41,7 +41,7 @@
double val = 5.5;
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDouble:val];
- XCTAssertTrue([[NSNumber numberWithDouble:val] isEqual:[[result argumentsAsJSON] cdv_JSONFragment]]);
+ XCTAssertTrue([[NSNumber numberWithDouble:val] isEqual:[[result argumentsAsJSON] JSONFragment]]);
}
- (void)testSerializingMessageAsBool
@@ -49,7 +49,7 @@
BOOL val = YES;
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:val];
- XCTAssertTrue([[NSNumber numberWithBool:val] isEqual:[[result argumentsAsJSON] cdv_JSONFragment]]);
+ XCTAssertTrue([[NSNumber numberWithBool:val] isEqual:[[result argumentsAsJSON] JSONFragment]]);
}
- (void)testSerializingMessageAsArray
@@ -63,7 +63,7 @@
nil];
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:testValues];
- NSArray* arr = [[result argumentsAsJSON] cdv_JSONObject];
+ NSArray* arr = [[result argumentsAsJSON] JSONObject];
XCTAssertTrue([arr isKindOfClass:[NSArray class]]);
XCTAssertTrue([testValues count] == [arr count]);
@@ -109,7 +109,7 @@
[testValues setValue:nestedDict forKey:@"nestedDict"];
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:testValues];
- NSDictionary* dic = [[result argumentsAsJSON] cdv_JSONObject];
+ NSDictionary* dic = [[result argumentsAsJSON] JSONObject];
[self __testDictionary:testValues withDictionary:dic];
}
@@ -122,7 +122,7 @@
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageToErrorObject:1];
- [self __testDictionary:testValues withDictionary:[[result argumentsAsJSON] cdv_JSONObject]];
+ [self __testDictionary:testValues withDictionary:[[result argumentsAsJSON] JSONObject]];
}
- (void)testSerializingMessageAsStringContainingQuotes
@@ -130,7 +130,7 @@
NSString* quotedString = @"\"quoted\"";
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:quotedString];
- XCTAssertTrue([quotedString isEqualToString:[[result argumentsAsJSON] cdv_JSONFragment]]);
+ XCTAssertTrue([quotedString isEqualToString:[[result argumentsAsJSON] JSONFragment]]);
}
- (void)testSerializingMessageAsStringThatIsNil
@@ -138,7 +138,7 @@
NSString* nilString = nil;
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:nilString];
- XCTAssertTrue([[NSNull null] isEqual:[[result argumentsAsJSON] cdv_JSONFragment]]);
+ XCTAssertTrue([[NSNull null] isEqual:[[result argumentsAsJSON] JSONFragment]]);
}
@end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org