diff options
author | DINH Viet Hoa <hoa@sprw.me> | 2013-02-01 20:47:53 -0800 |
---|---|---|
committer | DINH Viet Hoa <hoa@sprw.me> | 2013-02-01 20:50:27 -0800 |
commit | aa32ffa7b46496ed639057b30d4f49ea53df7ec9 (patch) | |
tree | d4875288c416a93c7b9b340b447e7309d8386ed8 | |
parent | 3129f582e76fad6e664d80e1c3350c72378bf075 (diff) |
Implemented conversion methods from Objective-C objects to MailCore basetypes
-rw-r--r-- | build-mac/mailcore2.xcodeproj/project.pbxproj | 26 | ||||
-rw-r--r-- | src/objc/MCObjC.h | 5 | ||||
-rw-r--r-- | src/objc/utils/MCOObjectWrapper.h | 6 | ||||
-rw-r--r-- | src/objc/utils/MCOObjectWrapper.mm | 1 | ||||
-rw-r--r-- | src/objc/utils/NSArray+MCO.h | 23 | ||||
-rw-r--r-- | src/objc/utils/NSArray+MCO.mm | 26 | ||||
-rw-r--r-- | src/objc/utils/NSData+MCO.h | 6 | ||||
-rw-r--r-- | src/objc/utils/NSData+MCO.mm | 2 | ||||
-rw-r--r-- | src/objc/utils/NSDictionary+MCO.h | 23 | ||||
-rw-r--r-- | src/objc/utils/NSDictionary+MCO.mm | 27 | ||||
-rw-r--r-- | src/objc/utils/NSObject+MCO.h | 23 | ||||
-rw-r--r-- | src/objc/utils/NSObject+MCO.mm | 42 | ||||
-rw-r--r-- | src/objc/utils/NSString+MCO.h | 7 | ||||
-rw-r--r-- | src/objc/utils/NSString+MCO.mm | 2 |
14 files changed, 215 insertions, 4 deletions
diff --git a/build-mac/mailcore2.xcodeproj/project.pbxproj b/build-mac/mailcore2.xcodeproj/project.pbxproj index 30940696..9c797b14 100644 --- a/build-mac/mailcore2.xcodeproj/project.pbxproj +++ b/build-mac/mailcore2.xcodeproj/project.pbxproj @@ -176,6 +176,12 @@ C6EB30DE16B5B8050091F4F1 /* MCObjC.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6EB30DC16B5B7770091F4F1 /* MCObjC.h */; }; F87F190C16BB62B00012652F /* MCOFetchFoldersOperation.mm in Sources */ = {isa = PBXBuildFile; fileRef = F87F190B16BB62B00012652F /* MCOFetchFoldersOperation.mm */; }; F8EA941716BB1C9D0011AC6F /* MCOIMAPSession.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = F8EA941416BAED6E0011AC6F /* MCOIMAPSession.h */; }; + C6EB30F716B8C9480091F4F1 /* NSDictionary+MCO.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6EB30F616B8C9480091F4F1 /* NSDictionary+MCO.mm */; }; + C6EB30F816B8DED30091F4F1 /* NSDictionary+MCO.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6EB30F516B8C9480091F4F1 /* NSDictionary+MCO.h */; }; + C6EB30FE16B8E50F0091F4F1 /* NSArray+MCO.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6EB30FC16B8E50F0091F4F1 /* NSArray+MCO.mm */; }; + C6EB310116B8E6E60091F4F1 /* NSObject+MCO.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6EB310016B8E6E50091F4F1 /* NSObject+MCO.mm */; }; + C6EB310216B8E7D60091F4F1 /* NSObject+MCO.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6EB30FF16B8E6E50091F4F1 /* NSObject+MCO.h */; }; + C6EB310316B8E7D80091F4F1 /* NSArray+MCO.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6EB30FD16B8E50F0091F4F1 /* NSArray+MCO.h */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -197,7 +203,10 @@ files = ( C62C6EE016A696AB00737497 /* MCAsyncIMAP.h in CopyFiles */, C6EB30DE16B5B8050091F4F1 /* MCObjC.h in CopyFiles */, + C6EB310216B8E7D60091F4F1 /* NSObject+MCO.h in CopyFiles */, + C6EB310316B8E7D80091F4F1 /* NSArray+MCO.h in CopyFiles */, C64FF39316B3C25200F8C162 /* MCOObjectWrapper.h in CopyFiles */, + C6EB30F816B8DED30091F4F1 /* NSDictionary+MCO.h in CopyFiles */, C64EA74E169E859600778456 /* MCAbstract.h in CopyFiles */, C6D42C2A16AE0507002BB4F9 /* NSData+MCO.h in CopyFiles */, C62C6F0016A7E32800737497 /* MCPOPFetchHeaderOperation.h in CopyFiles */, @@ -481,6 +490,12 @@ F87F190816BB62690012652F /* MCOFetchFoldersOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCOFetchFoldersOperation.h; sourceTree = "<group>"; }; F87F190B16BB62B00012652F /* MCOFetchFoldersOperation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MCOFetchFoldersOperation.mm; sourceTree = "<group>"; }; F8EA941416BAED6E0011AC6F /* MCOIMAPSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCOIMAPSession.h; sourceTree = "<group>"; }; + C6EB30F516B8C9480091F4F1 /* NSDictionary+MCO.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDictionary+MCO.h"; sourceTree = "<group>"; }; + C6EB30F616B8C9480091F4F1 /* NSDictionary+MCO.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "NSDictionary+MCO.mm"; sourceTree = "<group>"; }; + C6EB30FC16B8E50F0091F4F1 /* NSArray+MCO.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "NSArray+MCO.mm"; sourceTree = "<group>"; }; + C6EB30FD16B8E50F0091F4F1 /* NSArray+MCO.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+MCO.h"; sourceTree = "<group>"; }; + C6EB30FF16B8E6E50091F4F1 /* NSObject+MCO.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSObject+MCO.h"; sourceTree = "<group>"; }; + C6EB310016B8E6E50091F4F1 /* NSObject+MCO.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "NSObject+MCO.mm"; sourceTree = "<group>"; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -819,6 +834,12 @@ C64FF39016B3C13000F8C162 /* MCOObjectWrapper.mm */, C07AD44B013BB42A240B4F04 /* NSError+MCO.h */, C07ADFE43E22B38EFF23ADB5 /* NSError+MCO.mm */, + C6EB30F516B8C9480091F4F1 /* NSDictionary+MCO.h */, + C6EB30F616B8C9480091F4F1 /* NSDictionary+MCO.mm */, + C6EB30FD16B8E50F0091F4F1 /* NSArray+MCO.h */, + C6EB30FC16B8E50F0091F4F1 /* NSArray+MCO.mm */, + C6EB30FF16B8E6E50091F4F1 /* NSObject+MCO.h */, + C6EB310016B8E6E50091F4F1 /* NSObject+MCO.mm */, ); path = utils; sourceTree = "<group>"; @@ -1003,6 +1024,9 @@ C07ADA0FE807DC9D166BBF37 /* MCOCheckAccountOperation.mm in Sources */, C07AD99B2E2054C684DB8FF6 /* NSError+MCO.mm in Sources */, F87F190C16BB62B00012652F /* MCOFetchFoldersOperation.mm in Sources */, + C6EB30F716B8C9480091F4F1 /* NSDictionary+MCO.mm in Sources */, + C6EB30FE16B8E50F0091F4F1 /* NSArray+MCO.mm in Sources */, + C6EB310116B8E6E60091F4F1 /* NSObject+MCO.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1099,6 +1123,7 @@ C64EA53C169E772200778456 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_CXX_LIBRARY = "libstdc++"; EXECUTABLE_PREFIX = lib; PRODUCT_NAME = mailcore2; }; @@ -1107,6 +1132,7 @@ C64EA53D169E772200778456 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_CXX_LIBRARY = "libstdc++"; EXECUTABLE_PREFIX = lib; PRODUCT_NAME = mailcore2; }; diff --git a/src/objc/MCObjC.h b/src/objc/MCObjC.h index 364d5692..f579af1c 100644 --- a/src/objc/MCObjC.h +++ b/src/objc/MCObjC.h @@ -14,12 +14,15 @@ #import <mailcore/MCOObjectWrapper.h> #import <mailcore/NSData+MCO.h> #import <mailcore/NSString+MCO.h> +#import <mailcore/NSDictionary+MCO.h> +#import <mailcore/NSArray+MCO.h> +#import <mailcore/NSObject+MCO.h> +#import <mailcore/MCOObjectWrapper.h> #import <mailcore/NSError+MCO.h> #import <mailcore/MCOIMAPSession.h> #import <mailcore/MCOOperation.h> #import <mailcore/MCOCheckAccountOperation.h> - #endif #endif diff --git a/src/objc/utils/MCOObjectWrapper.h b/src/objc/utils/MCOObjectWrapper.h index eac1a457..6827bde9 100644 --- a/src/objc/utils/MCOObjectWrapper.h +++ b/src/objc/utils/MCOObjectWrapper.h @@ -8,7 +8,11 @@ #import <Foundation/Foundation.h> -#include <mailcore/MCObject.h> +#ifdef __cplusplus +namespace mailcore { + class Object; +} +#endif @interface MCOObjectWrapper : NSObject diff --git a/src/objc/utils/MCOObjectWrapper.mm b/src/objc/utils/MCOObjectWrapper.mm index 74a2afe7..e4fda2ae 100644 --- a/src/objc/utils/MCOObjectWrapper.mm +++ b/src/objc/utils/MCOObjectWrapper.mm @@ -9,6 +9,7 @@ #import "MCOObjectWrapper.h" #include "MCUtils.h" +#include "MCObject.h" @implementation MCOObjectWrapper { mailcore::Object * mObject; diff --git a/src/objc/utils/NSArray+MCO.h b/src/objc/utils/NSArray+MCO.h new file mode 100644 index 00000000..8d95acbc --- /dev/null +++ b/src/objc/utils/NSArray+MCO.h @@ -0,0 +1,23 @@ +// +// NSArray+MCO.h +// mailcore2 +// +// Created by DINH Viêt Hoà on 1/29/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#import <Foundation/Foundation.h> + +#ifdef __cplusplus +namespace mailcore { + class Array; +} +#endif + +@interface NSArray (MCO) + +#ifdef __cplusplus +- (mailcore::Array *) mco_mcArray; +#endif + +@end diff --git a/src/objc/utils/NSArray+MCO.mm b/src/objc/utils/NSArray+MCO.mm new file mode 100644 index 00000000..1c4ef3e6 --- /dev/null +++ b/src/objc/utils/NSArray+MCO.mm @@ -0,0 +1,26 @@ +// +// NSArray+MCO.cpp +// mailcore2 +// +// Created by DINH Viêt Hoà on 1/29/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#import "NSArray+MCO.h" + +#include "MCBaseTypes.h" + +#import "NSObject+MCO.h" + +@implementation NSArray (MCO) + +- (mailcore::Array *) mco_mcArray +{ + mailcore::Array * result = mailcore::Array::array(); + for(NSObject * value in self) { + [value mco_mcObject]; + } + return result; +} + +@end diff --git a/src/objc/utils/NSData+MCO.h b/src/objc/utils/NSData+MCO.h index 105fd325..9a0b39cc 100644 --- a/src/objc/utils/NSData+MCO.h +++ b/src/objc/utils/NSData+MCO.h @@ -8,7 +8,11 @@ #import <Foundation/Foundation.h> -#include <mailcore/MCData.h> +#ifdef __cplusplus +namespace mailcore { + class Data; +} +#endif @interface NSData (MCO) diff --git a/src/objc/utils/NSData+MCO.mm b/src/objc/utils/NSData+MCO.mm index 70838280..dd279554 100644 --- a/src/objc/utils/NSData+MCO.mm +++ b/src/objc/utils/NSData+MCO.mm @@ -8,6 +8,8 @@ #import "NSData+MCO.h" +#include "MCData.h" + @implementation NSData (MCO) + (NSData *) mco_dataWithMCData:(mailcore::Data *)cppData diff --git a/src/objc/utils/NSDictionary+MCO.h b/src/objc/utils/NSDictionary+MCO.h new file mode 100644 index 00000000..71812a46 --- /dev/null +++ b/src/objc/utils/NSDictionary+MCO.h @@ -0,0 +1,23 @@ +// +// NSDictionary+MCO.h +// mailcore2 +// +// Created by DINH Viêt Hoà on 1/29/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#import <Foundation/Foundation.h> + +#ifdef __cplusplus +namespace mailcore { + class HashMap; +} +#endif + +@interface NSDictionary (MCO) + +#ifdef __cplusplus +- (mailcore::HashMap *) mco_mcHashMap; +#endif + +@end diff --git a/src/objc/utils/NSDictionary+MCO.mm b/src/objc/utils/NSDictionary+MCO.mm new file mode 100644 index 00000000..a751f85b --- /dev/null +++ b/src/objc/utils/NSDictionary+MCO.mm @@ -0,0 +1,27 @@ +// +// NSDictionary+MCO.m +// mailcore2 +// +// Created by DINH Viêt Hoà on 1/29/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#import "NSDictionary+MCO.h" + +#include "MCBaseTypes.h" + +#import "NSObject+MCO.h" + +@implementation NSDictionary (MCO) + +- (mailcore::HashMap *) mco_mcHashMap +{ + mailcore::HashMap * result = mailcore::HashMap::hashMap(); + for(NSObject * key in self) { + NSObject * value = [self objectForKey:key]; + result->setObjectForKey([key mco_mcObject], [value mco_mcObject]); + } + return result; +} + +@end diff --git a/src/objc/utils/NSObject+MCO.h b/src/objc/utils/NSObject+MCO.h new file mode 100644 index 00000000..349bd27a --- /dev/null +++ b/src/objc/utils/NSObject+MCO.h @@ -0,0 +1,23 @@ +// +// NSObject+MCO.h +// mailcore2 +// +// Created by DINH Viêt Hoà on 1/29/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#import <Foundation/Foundation.h> + +#ifdef __cplusplus +namespace mailcore { + class Object; +} +#endif + +@interface NSObject (MCO) + +#ifdef __cplusplus +- (mailcore::Object *) mco_mcObject; +#endif + +@end diff --git a/src/objc/utils/NSObject+MCO.mm b/src/objc/utils/NSObject+MCO.mm new file mode 100644 index 00000000..e25db319 --- /dev/null +++ b/src/objc/utils/NSObject+MCO.mm @@ -0,0 +1,42 @@ +// +// NSObject+MCO.m +// mailcore2 +// +// Created by DINH Viêt Hoà on 1/29/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#import "NSObject+MCO.h" + +#import "NSData+MCO.h" +#import "NSString+MCO.h" +#import "NSDictionary+MCO.h" +#import "NSArray+MCO.h" + +#include "MCBaseTypes.h" +#include "MCUtils.h" + +@implementation NSObject (MCO) + +- (mailcore::Object *) mco_mcObject +{ + if ([self isKindOfClass:[NSData class]]) { + return [(NSData *) self mco_mcData]; + } + else if ([self isKindOfClass:[NSString class]]) { + return [(NSString *) self mco_mcString]; + } + else if ([self isKindOfClass:[NSArray class]]) { + return [(NSArray *) self mco_mcArray]; + } + else if ([self isKindOfClass:[NSDictionary class]]) { + return [(NSDictionary *) self mco_mcHashMap]; + } + else { + MCAssert(0); + return nil; + } + +} + +@end diff --git a/src/objc/utils/NSString+MCO.h b/src/objc/utils/NSString+MCO.h index e7057116..33cc0b67 100644 --- a/src/objc/utils/NSString+MCO.h +++ b/src/objc/utils/NSString+MCO.h @@ -8,7 +8,12 @@ #import <Foundation/Foundation.h> -#include <mailcore/MCString.h> +#ifdef __cplusplus +namespace mailcore { + class String; + class Object; +} +#endif @interface NSString (MCO) diff --git a/src/objc/utils/NSString+MCO.mm b/src/objc/utils/NSString+MCO.mm index 803e9f24..3d692b76 100644 --- a/src/objc/utils/NSString+MCO.mm +++ b/src/objc/utils/NSString+MCO.mm @@ -8,6 +8,8 @@ #import "NSString+MCO.h" +#include "MCString.h" + @implementation NSString (MCO) + (NSString *) mco_stringWithMCString:(mailcore::String *)cppString |