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 2012/05/04 00:32:53 UTC

ios commit: FIXED CB-513 - Remove cast functionality from CDVPluginResult, obsolete

Updated Branches:
  refs/heads/master 38e822362 -> 5e8d5235e


FIXED CB-513 - Remove cast functionality from CDVPluginResult, obsolete


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

Branch: refs/heads/master
Commit: 5e8d5235ece3b4556850c69b65ad9538e3f95c82
Parents: 38e8223
Author: Shazron Abdullah <sh...@apache.org>
Authored: Thu May 3 15:32:42 2012 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Thu May 3 15:32:42 2012 -0700

----------------------------------------------------------------------
 CordovaLib/Classes/CDVFile.m         |    4 --
 CordovaLib/Classes/CDVPluginResult.h |   12 +----
 CordovaLib/Classes/CDVPluginResult.m |   73 +++++++++--------------------
 3 files changed, 24 insertions(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/5e8d5235/CordovaLib/Classes/CDVFile.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVFile.m b/CordovaLib/Classes/CDVFile.m
index 6c8148e..1e5a15f 100644
--- a/CordovaLib/Classes/CDVFile.m
+++ b/CordovaLib/Classes/CDVFile.m
@@ -496,10 +496,6 @@
 	if (fileAttribs){
 		NSDate* modDate = [fileAttribs fileModificationDate];
 		if (modDate){
-			//NSNumber* msDate = [NSNumber numberWithDouble:[modDate timeIntervalSince1970]*1000];
-			//NSMutableDictionary* metadataDict = [NSMutableDictionary dictionaryWithCapacity:1];
-			//[metadataDict setObject:msDate forKey:@"modificationTime"];
-			//result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary: metadataDict cast: @"window.localFileSystem._castDate"];
             result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDouble: [modDate timeIntervalSince1970]*1000];
 			jsString = [result toSuccessCallbackString:callbackId];
 		}

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/5e8d5235/CordovaLib/Classes/CDVPluginResult.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVPluginResult.h b/CordovaLib/Classes/CDVPluginResult.h
index aeaf853..71df676 100644
--- a/CordovaLib/Classes/CDVPluginResult.h
+++ b/CordovaLib/Classes/CDVPluginResult.h
@@ -33,17 +33,12 @@ typedef enum {
 } CDVCommandStatus;
 	
 @interface CDVPluginResult : NSObject {
-	NSNumber* status;
-	id message;
-	NSNumber* keepCallback;
-	NSString* cast;
-	
+
 }
 
 @property (nonatomic, retain, readonly) NSNumber* status;
 @property (nonatomic, retain, readonly) id message;
 @property (nonatomic, retain)			NSNumber* keepCallback;
-@property (nonatomic, retain, readonly) NSString* cast;
 
 -(CDVPluginResult*) init;
 +(void) releaseStatus;
@@ -53,11 +48,6 @@ typedef enum {
 +(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageAsInt: (int) theMessage;
 +(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageAsDouble: (double) theMessage;
 +(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageAsDictionary: (NSDictionary*) theMessage;
-+(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageAsString: (NSString*) theMessage cast: (NSString*) theCast;
-+(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageAsArray: (NSArray*) theMessage cast: (NSString*) theCast;
-+(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageAsInt: (int) theMessage cast: (NSString*) theCast;
-+(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageAsDouble: (double) theMessage cast: (NSString*) theCast;
-+(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageAsDictionary: (NSDictionary*) theMessage cast: (NSString*) theCast;
 +(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageToErrorObject: (int) errorCode;
 
 

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/5e8d5235/CordovaLib/Classes/CDVPluginResult.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVPluginResult.m b/CordovaLib/Classes/CDVPluginResult.m
index 30704bc..98c4e6f 100644
--- a/CordovaLib/Classes/CDVPluginResult.m
+++ b/CordovaLib/Classes/CDVPluginResult.m
@@ -23,13 +23,13 @@
 
 @interface CDVPluginResult()
 
--(CDVPluginResult*) initWithStatus:(CDVCommandStatus)statusOrdinal message: (id) theMessage cast: (NSString*) theCast;
+-(CDVPluginResult*) initWithStatus:(CDVCommandStatus)statusOrdinal message: (id) theMessage;
 
 @end
 
 
 @implementation CDVPluginResult
-@synthesize status, message, keepCallback, cast;
+@synthesize status, message, keepCallback;
 
 static NSArray* org_apache_cordova_CommandStatusMsgs;
 
@@ -47,6 +47,7 @@ static NSArray* org_apache_cordova_CommandStatusMsgs;
 									  @"Error",
 									  nil];
 }
+
 +(void) releaseStatus
 {
 	if (org_apache_cordova_CommandStatusMsgs != nil){
@@ -57,14 +58,14 @@ static NSArray* org_apache_cordova_CommandStatusMsgs;
 		
 -(CDVPluginResult*) init
 {
-	return [self initWithStatus: CDVCommandStatus_NO_RESULT message: nil cast: nil];
+	return [self initWithStatus: CDVCommandStatus_NO_RESULT message: nil];
 }
--(CDVPluginResult*) initWithStatus:(CDVCommandStatus)statusOrdinal message: (id) theMessage cast: (NSString*) theCast{
+
+-(CDVPluginResult*) initWithStatus:(CDVCommandStatus)statusOrdinal message: (id) theMessage {
 	self = [super init];
 	if(self) {
 		status = [NSNumber numberWithInt: statusOrdinal];
 		message = theMessage;
-		cast = theCast;
 		keepCallback = [NSNumber numberWithBool: NO];
 	}
 	return self;
@@ -72,57 +73,40 @@ static NSArray* org_apache_cordova_CommandStatusMsgs;
 	
 +(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal
 {
-	return [[[self alloc] initWithStatus: statusOrdinal message: [org_apache_cordova_CommandStatusMsgs objectAtIndex: statusOrdinal] cast: nil] autorelease];
+	return [[[self alloc] initWithStatus: statusOrdinal message: [org_apache_cordova_CommandStatusMsgs objectAtIndex: statusOrdinal]] autorelease];
 }
+
 +(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageAsString: (NSString*) theMessage
 {
-	return [[[self alloc] initWithStatus: statusOrdinal message: theMessage cast:nil] autorelease];
+	return [[[self alloc] initWithStatus: statusOrdinal message: theMessage] autorelease];
 }
+
 +(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageAsArray: (NSArray*) theMessage
 {
-	return [[[self alloc] initWithStatus: statusOrdinal message: theMessage cast:nil] autorelease];
+	return [[[self alloc] initWithStatus: statusOrdinal message: theMessage] autorelease];
 }
+
 +(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageAsInt: (int) theMessage
 {
-	return [[[self alloc] initWithStatus: statusOrdinal message: [NSNumber numberWithInt: theMessage] cast:nil] autorelease];
+	return [[[self alloc] initWithStatus: statusOrdinal message: [NSNumber numberWithInt: theMessage]] autorelease];
 }
+
 +(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageAsDouble: (double) theMessage
 {
-	return [[[self alloc] initWithStatus: statusOrdinal message: [NSNumber numberWithDouble: theMessage] cast:nil] autorelease];
+	return [[[self alloc] initWithStatus: statusOrdinal message: [NSNumber numberWithDouble: theMessage]] autorelease];
 }
 
 +(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageAsDictionary: (NSDictionary*) theMessage
 {
-	return [[[self alloc] initWithStatus: statusOrdinal message: theMessage cast:nil] autorelease];
-}
-+(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageAsString: (NSString*) theMessage cast: (NSString*) theCast
-{
-	return [[[self alloc] initWithStatus: statusOrdinal message: theMessage cast:theCast] autorelease];
-}
-+(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageAsArray: (NSArray*) theMessage cast: (NSString*) theCast
-{
-	return [[[self alloc] initWithStatus: statusOrdinal message: theMessage cast:theCast] autorelease];
+	return [[[self alloc] initWithStatus: statusOrdinal message: theMessage] autorelease];
 }
 
-+(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageAsInt: (int) theMessage cast: (NSString*) theCast
-{
-	return [[[self alloc] initWithStatus: statusOrdinal message: [NSNumber numberWithInt: theMessage] cast:theCast] autorelease];
-}
-+(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageAsDouble: (double) theMessage cast: (NSString*) theCast
-{
-	return [[[self alloc] initWithStatus: statusOrdinal message: [NSNumber numberWithDouble: theMessage] cast:theCast] autorelease];
-}
-+(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageAsDictionary: (NSDictionary*) theMessage cast: (NSString*) theCast
-{
-	return [[[self alloc] initWithStatus: statusOrdinal message: theMessage cast:theCast] autorelease];
-}
 +(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageToErrorObject: (int) errorCode 
 {
     NSDictionary* errDict = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:errorCode] forKey:@"code"];
-	return [[[self alloc] initWithStatus: statusOrdinal message: errDict cast:nil] autorelease];
+	return [[[self alloc] initWithStatus: statusOrdinal message: errDict] autorelease];
 }
 
-
 -(void) setKeepCallbackAsBool:(BOOL)bKeepCallback
 {
 	[self setKeepCallback: [NSNumber numberWithBool:bKeepCallback]];
@@ -134,34 +118,24 @@ static NSArray* org_apache_cordova_CommandStatusMsgs;
                                self.message ? self.message : [NSNull null], @"message",
                                self.keepCallback, @"keepCallback",
                                nil] JSONString];
+    
 	DLog(@"PluginResult:toJSONString - %@", resultString);
 	return resultString;
 }
-// TODO: get rid of casting
+
 -(NSString*) toSuccessCallbackString: (NSString*) callbackId
 {
-	NSString* successCB;
+	NSString* successCB = [NSString stringWithFormat:@"cordova.callbackSuccess('%@',%@);", callbackId, [self toJSONString]];			
 	
-	if ([self cast] != nil) {
-		successCB = [NSString stringWithFormat: @"var temp = %@(%@);\ncordova.callbackSuccess('%@',temp);", self.cast, [self toJSONString], callbackId];
-	}
-	else {
-		successCB = [NSString stringWithFormat:@"cordova.callbackSuccess('%@',%@);", callbackId, [self toJSONString]];			
-	}
 	DLog(@"PluginResult toSuccessCallbackString: %@", successCB);
 	return successCB;
 }
-// TODO: get rid of casting
+
 -(NSString*) toErrorCallbackString: (NSString*) callbackId
 {
-	NSString* errorCB = nil;
+	NSString* errorCB = [NSString stringWithFormat:@"cordova.callbackError('%@',%@);", callbackId, [self toJSONString]];
 	
-	if ([self cast] != nil) {
-		errorCB = [NSString stringWithFormat: @"var temp = %@(%@);\ncordova.callbackError('%@',temp);", self.cast, [self toJSONString], callbackId];
-	}
-	else {
-		errorCB = [NSString stringWithFormat:@"cordova.callbackError('%@',%@);", callbackId, [self toJSONString]];
-	}
+
 	DLog(@"PluginResult toErrorCallbackString: %@", errorCB);
 	return errorCB;
 }	
@@ -171,7 +145,6 @@ static NSArray* org_apache_cordova_CommandStatusMsgs;
 	status = nil;
 	message = nil;
 	keepCallback = nil;
-	cast = nil;
 	
 	[super dealloc];
 }