cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaz...@apache.org
Subject [4/5] ios commit: CB-8270 Rename category methods for JSON handling with a prefix (close #124)
Date Tue, 20 Jan 2015 21:02:06 GMT
CB-8270 Rename category methods for JSON handling with a prefix (close #124)


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

Branch: refs/heads/wkwebview
Commit: a98144b8ad63fe714c9f6d274bc9fd98b62575e7
Parents: c707a01
Author: Ruoyu Fu <ryfu@thoughtworks.com>
Authored: Thu Jan 8 12:08:37 2015 +0800
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Mon Jan 19 11:59:18 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, 21 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/a98144b8/CordovaLib/Classes/CDVCommandQueue.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCommandQueue.m b/CordovaLib/Classes/CDVCommandQueue.m
index 1eddfe3..0b15fff 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 JSONObject]];
+            [commandBatchHolder addObject:[batchJSON cdv_JSONObject]];
         } else {
             dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
^() {
-                    NSMutableArray* result = [batchJSON JSONObject];
+                    NSMutableArray* result = [batchJSON cdv_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 JSONString];
+                            NSString* commandJson = [jsonEntry cdv_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/a98144b8/CordovaLib/Classes/CDVJSON.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVJSON.h b/CordovaLib/Classes/CDVJSON.h
index 8ad85da..a81d549 100644
--- a/CordovaLib/Classes/CDVJSON.h
+++ b/CordovaLib/Classes/CDVJSON.h
@@ -18,14 +18,14 @@
  */
 
 @interface NSArray (CDVJSONSerializing)
-- (NSString*)JSONString;
+- (NSString*)cdv_JSONString;
 @end
 
 @interface NSDictionary (CDVJSONSerializing)
-- (NSString*)JSONString;
+- (NSString*)cdv_JSONString;
 @end
 
 @interface NSString (CDVJSONSerializing)
-- (id)JSONObject;
-- (id)JSONFragment;
+- (id)cdv_JSONObject;
+- (id)cdv_JSONFragment;
 @end

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/a98144b8/CordovaLib/Classes/CDVJSON.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVJSON.m b/CordovaLib/Classes/CDVJSON.m
index 4698bfe..9aa07f8 100644
--- a/CordovaLib/Classes/CDVJSON.m
+++ b/CordovaLib/Classes/CDVJSON.m
@@ -22,7 +22,7 @@
 
 @implementation NSArray (CDVJSONSerializing)
 
-- (NSString*)JSONString
+- (NSString*)cdv_JSONString
 {
     NSError* error = nil;
     NSData* jsonData = [NSJSONSerialization dataWithJSONObject:self
@@ -41,7 +41,7 @@
 
 @implementation NSDictionary (CDVJSONSerializing)
 
-- (NSString*)JSONString
+- (NSString*)cdv_JSONString
 {
     NSError* error = nil;
     NSData* jsonData = [NSJSONSerialization dataWithJSONObject:self
@@ -60,7 +60,7 @@
 
 @implementation NSString (CDVJSONSerializing)
 
-- (id)JSONObject
+- (id)cdv_JSONObject
 {
     NSError* error = nil;
     id object = [NSJSONSerialization JSONObjectWithData:[self dataUsingEncoding:NSUTF8StringEncoding]
@@ -74,7 +74,7 @@
     return object;
 }
 
-- (id)JSONFragment
+- (id)cdv_JSONFragment
 {
     NSError* error = nil;
     id object = [NSJSONSerialization JSONObjectWithData:[self dataUsingEncoding:NSUTF8StringEncoding]
@@ -89,3 +89,4 @@
 }
 
 @end
+

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/a98144b8/CordovaLib/Classes/CDVPluginResult.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVPluginResult.m b/CordovaLib/Classes/CDVPluginResult.m
index 2eb46cd..b8b69ed 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 JSONString];
+    NSString* argumentsJSON = [argumentsWrappedInArray cdv_JSONString];
 
     argumentsJSON = [argumentsJSON substringWithRange:NSMakeRange(1, [argumentsJSON length]
- 2)];
 

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/a98144b8/tests/CordovaLibTests/CDVPluginResultJSONSerializationTests.m
----------------------------------------------------------------------
diff --git a/tests/CordovaLibTests/CDVPluginResultJSONSerializationTests.m b/tests/CordovaLibTests/CDVPluginResultJSONSerializationTests.m
index e87f52d..83ed4d4 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] JSONFragment]]);
+    XCTAssertTrue([[NSNumber numberWithInt:val] isEqual:[[result argumentsAsJSON] cdv_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] JSONFragment]]);
+    XCTAssertTrue([[NSNumber numberWithDouble:val] isEqual:[[result argumentsAsJSON] cdv_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] JSONFragment]]);
+    XCTAssertTrue([[NSNumber numberWithBool:val] isEqual:[[result argumentsAsJSON] cdv_JSONFragment]]);
 }
 
 - (void)testSerializingMessageAsArray
@@ -63,7 +63,7 @@
         nil];
 
     CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:testValues];
-    NSArray* arr = [[result argumentsAsJSON] JSONObject];
+    NSArray* arr = [[result argumentsAsJSON] cdv_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] JSONObject];
+    NSDictionary* dic = [[result argumentsAsJSON] cdv_JSONObject];
 
     [self __testDictionary:testValues withDictionary:dic];
 }
@@ -122,7 +122,7 @@
 
     CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageToErrorObject:1];
 
-    [self __testDictionary:testValues withDictionary:[[result argumentsAsJSON] JSONObject]];
+    [self __testDictionary:testValues withDictionary:[[result argumentsAsJSON] cdv_JSONObject]];
 }
 
 - (void)testSerializingMessageAsStringContainingQuotes
@@ -130,7 +130,7 @@
     NSString* quotedString = @"\"quoted\"";
     CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:quotedString];
 
-    XCTAssertTrue([quotedString isEqualToString:[[result argumentsAsJSON] JSONFragment]]);
+    XCTAssertTrue([quotedString isEqualToString:[[result argumentsAsJSON] cdv_JSONFragment]]);
 }
 
 - (void)testSerializingMessageAsStringThatIsNil
@@ -138,7 +138,7 @@
     NSString* nilString = nil;
     CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:nilString];
 
-    XCTAssertTrue([[NSNull null] isEqual:[[result argumentsAsJSON] JSONFragment]]);
+    XCTAssertTrue([[NSNull null] isEqual:[[result argumentsAsJSON] cdv_JSONFragment]]);
 }
 
 @end


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message