Only use specialized Objective-C collection types when Foundation supports them.

Rely on Foundation to provide NS_ARRAY/NS_DICTIONARY/NS_SET macros
that expand to either an unspecialized type (e.g., NSArray *) or a
specialized one (e.g., NSArray<T> *) as appropriate for the definition
of NSArray. Use these macros in the Objective-C printer.

The actual names and form of these macros is still to be debated, but
it's important to be able to handle both Clangs and Foundations with
and without parameterized NSArray/NSDictionary/NSSet.

Swift SVN r24198
This commit is contained in:
Doug Gregor
2015-01-06 00:16:43 +00:00
parent 83d4c3783d
commit d3d4c8b8fb
4 changed files with 58 additions and 26 deletions

View File

@@ -19,6 +19,7 @@ typedef double NSTimeInterval;
@class NSString, NSArray, NSDictionary, NSSet, NSEnumerator;
#define NS_ARRAY(...) NSArray<__VA_ARGS__> *
@interface NSArray<ObjectType> : NSObject
- (ObjectType)objectAtIndexedSubscript:(NSUInteger)idx;
- description;
@@ -41,6 +42,7 @@ typedef double NSTimeInterval;
- (id)copyWithZone:(NSZone *)zone;
@end
#define NS_DICTIONARY(...) NSDictionary<__VA_ARGS__> *
@interface NSDictionary<KeyType : id<NSCopying>, ObjectType> : NSObject /*<NSCopying, NSMutableCopying, NSSecureCoding, NSFastEnumeration>*/
@property (readonly) NSUInteger count;
- (ObjectType)objectForKey:(KeyType)aKey;
@@ -63,6 +65,7 @@ typedef double NSTimeInterval;
- (void)setObject:(ObjectType)obj forKeyedSubscript:(KeyType)key;
@end
#define NS_SET(...) NSSet<__VA_ARGS__> *
@interface NSSet<KeyType> : NSObject
- (instancetype)init;
- (NSUInteger)count;