Apply patch by Patrick Laurent and tidy a bit.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@39411 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2016-02-24 07:41:20 +00:00
parent 28c824a78a
commit a51249a65d
4 changed files with 67 additions and 47 deletions

View file

@ -1,29 +1,39 @@
2016-02-24 Richard Frith-Macdonald <rfm@gnu.org>
* Headers/Foundation/NSArray.h:
* Source/NSArray.m:
Correct argument types in ([-objectAtIndexedSubscript:]) and
([setObject:atIndexedSubscript:]) to match OSX.
Apply patch by Patrick Laurent <plaurent@me.com> to fix bug setting
an object at the end of the array.
2016-02-22 Niels Grewe <niels.grewe@halbordnung.de>
* Headers/Foundation/NSObjCRuntime.h: Add macros for backwards-
compatible generics annotations. Also define instancetype if necessary.
* Headers/Foundation/NSArray.h
* Headers/Foundation/NSCache.h
* Headers/Foundation/NSDictionary.h
* Headers/Foundation/NSEnumerator.h
* Headers/Foundation/NSArray.h:
* Headers/Foundation/NSCache.h:
* Headers/Foundation/NSDictionary.h:
* Headers/Foundation/NSEnumerator.h:
* Headers/Foundation/NSSet.h: Update interfaces for instancetype and
generics.
* Source/NSCache.m: Use NSMapTable instead of NSMutableDictionary.
The API contract for NSCache stipulates that keys are not copied, so
using a dictionary wasn't apropriate.
* Source/NSConnection.m
* Source/NSConnection.m:
* Source/NSData.m: Small type safety improvements (mostly to keep the
compiler happy).
* Source/NSDictionary.m: Change id to id<NSCopying> in a few places to
avoid compiler warnings.
* Tests/base/NSCache
* Tests/base/NSCache/TestInfo
* Tests/base/NSCache/basic.m
* Tests/base/NSCache:
* Tests/base/NSCache/TestInfo:
* Tests/base/NSCache/basic.m:
* Tests/base/NSCache/cache.m:
Test cases eviction from NSCache. Turns out we currently only evict
NSDiscardableContent, while the API documentation seems to suggest that cost
and count based eviction without NSDiscardableContent is also possible.
NSDiscardableContent, while the API documentation seems to suggest
that cost and count based eviction without NSDiscardableContent is
also possible.
2016-02-18 Richard Frith-Macdonald <rfm@gnu.org>
016-02-18 Richard Frith-Macdonald <rfm@gnu.org>
* Source/Additions/GSMime.m:
Fold using tabs between key=value tokens in structured headers

View file

@ -71,9 +71,9 @@ typedef NSUInteger NSBinarySearchingOptions;
+ (instancetype) arrayWithObjects: (const id[])objects count: (NSUInteger)count;
- (GS_GENERIC_CLASS(NSArray, ElementT) *) arrayByAddingObject:
(GS_GENERIC_TYPE(ElementT))anObject;
(GS_GENERIC_TYPE(ElementT))anObject;
- (GS_GENERIC_CLASS(NSArray, ElementT) *) arrayByAddingObjectsFromArray:
(GS_GENERIC_CLASS(NSArray, ElementT)*)anotherArray;
(GS_GENERIC_CLASS(NSArray, ElementT)*)anotherArray;
- (BOOL) containsObject: (GS_GENERIC_TYPE(ElementT))anObject;
/** <override-subclass />
@ -122,7 +122,8 @@ typedef NSUInteger NSBinarySearchingOptions;
- (GS_GENERIC_TYPE(ElementT)) objectAtIndex: (NSUInteger)index;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
- (GS_GENERIC_CLASS(NSArray, ElementT) *) objectsAtIndexes: (NSIndexSet *)indexes;
- (GS_GENERIC_CLASS(NSArray, ElementT) *) objectsAtIndexes:
(NSIndexSet *)indexes;
#endif
- (GS_GENERIC_TYPE(ElementT)) firstObjectCommonWithArray:
@ -146,7 +147,8 @@ typedef NSUInteger NSBinarySearchingOptions;
(NSComparisonResult (*)(id, id, void*))comparator
context: (void*)context
hint: (NSData*)hint;
- (GS_GENERIC_CLASS(NSArray, ElementT)*) sortedArrayUsingSelector: (SEL)comparator;
- (GS_GENERIC_CLASS(NSArray, ElementT)*) sortedArrayUsingSelector:
(SEL)comparator;
- (GS_GENERIC_CLASS(NSArray, ElementT)*) subarrayWithRange: (NSRange)aRange;
- (NSString*) componentsJoinedByString: (NSString*)separator;
@ -170,8 +172,10 @@ typedef NSUInteger NSBinarySearchingOptions;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
DEFINE_BLOCK_TYPE(GSEnumeratorBlock, void, GS_GENERIC_TYPE(ElementT), NSUInteger, BOOL*);
DEFINE_BLOCK_TYPE(GSPredicateBlock, BOOL, GS_GENERIC_TYPE(ElementT), NSUInteger, BOOL*);
DEFINE_BLOCK_TYPE(GSEnumeratorBlock, void, GS_GENERIC_TYPE(ElementT),
NSUInteger, BOOL*);
DEFINE_BLOCK_TYPE(GSPredicateBlock, BOOL, GS_GENERIC_TYPE(ElementT),
NSUInteger, BOOL*);
/**
* Enumerate over the collection using the given block. The first argument is
* the object and the second is the index in the array. The final argument is
@ -295,7 +299,7 @@ DEFINE_BLOCK_TYPE(GSPredicateBlock, BOOL, GS_GENERIC_TYPE(ElementT), NSUInteger,
* Accessor for subscripting. This is called by the compiler when you write
* code like anArray[12]. It should not be called directly.
*/
- (GS_GENERIC_TYPE(ElementT)) objectAtIndexedSubscript: (size_t)anIndex;
- (GS_GENERIC_TYPE(ElementT)) objectAtIndexedSubscript: (NSUInteger)anIndex;
@end
@ -359,11 +363,11 @@ DEFINE_BLOCK_TYPE(GSPredicateBlock, BOOL, GS_GENERIC_TYPE(ElementT), NSUInteger,
#endif
- (void) replaceObjectsInRange: (NSRange)aRange
withObjectsFromArray: (GS_GENERIC_CLASS(NSArray, ElementT)*)anArray;
withObjectsFromArray: (GS_GENERIC_CLASS(NSArray, ElementT)*)anArray;
- (void) replaceObjectsInRange: (NSRange)aRange
withObjectsFromArray: (GS_GENERIC_CLASS(NSArray, ElementT)*)anArray
range: (NSRange)anotherRange;
withObjectsFromArray: (GS_GENERIC_CLASS(NSArray, ElementT)*)anArray
range: (NSRange)anotherRange;
- (void) setArray: (GS_GENERIC_CLASS(NSArray, ElementT) *)otherArray;
@ -399,11 +403,13 @@ DEFINE_BLOCK_TYPE(GSPredicateBlock, BOOL, GS_GENERIC_TYPE(ElementT), NSUInteger,
- (void) sortWithOptions: (NSSortOptions)options
usingComparator: (NSComparator)comparator;
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_8, GS_API_LATEST)
/**
* Set method called by the compiler with array subscripting.
*/
- (void) setObject: (GS_GENERIC_TYPE(ElementT))anObject
atIndexedSubscript: (size_t)anIndex;
atIndexedSubscript: (NSUInteger)anIndex;
#endif
@end
#if defined(__cplusplus)

View file

@ -38,8 +38,8 @@ extern "C" {
@class NSString, NSURL;
@interface GS_GENERIC_CLASS(NSDictionary,
__covariant KeyT:id<NSCopying>, __covariant ValT)
: NSObject <NSCoding, NSCopying, NSMutableCopying, NSFastEnumeration>
__covariant KeyT:id<NSCopying>, __covariant ValT)
: NSObject <NSCoding, NSCopying, NSMutableCopying, NSFastEnumeration>
+ (instancetype) dictionary;
+ (instancetype) dictionaryWithContentsOfFile: (NSString*)path;
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
@ -47,19 +47,17 @@ extern "C" {
#endif
+ (instancetype) dictionaryWithDictionary: (NSDictionary*)otherDictionary;
+ (instancetype) dictionaryWithObject: (GS_GENERIC_TYPE(ValT))object
forKey:
(GS_GENERIC_TYPE(KeyT))key;
forKey: (GS_GENERIC_TYPE(KeyT))key;
+ (instancetype) dictionaryWithObjects: (GS_GENERIC_CLASS(NSArray,ValT)*)objects
forKeys: (GS_GENERIC_CLASS(NSArray,KeyT)*)keys;
+ (instancetype) dictionaryWithObjects: (const GS_GENERIC_TYPE(ValT)[])objects
forKeys:
(const GS_GENERIC_TYPE_F(KeyT,id<NSCopying>)[])keys
count: (NSUInteger)count;
forKeys: (const GS_GENERIC_TYPE_F(KeyT,id<NSCopying>)[])keys
count: (NSUInteger)count;
+ (instancetype) dictionaryWithObjectsAndKeys: (id)firstObject, ...;
- (GS_GENERIC_CLASS(NSArray,KeyT)*) allKeys;
- (GS_GENERIC_CLASS(NSArray,KeyT)*) allKeysForObject:
(GS_GENERIC_TYPE(ValT))anObject;
(GS_GENERIC_TYPE(ValT))anObject;
- (GS_GENERIC_CLASS(NSArray,ValT)*) allValues;
- (NSUInteger) count; // Primitive
- (NSString*) description;
@ -70,7 +68,7 @@ extern "C" {
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
DEFINE_BLOCK_TYPE(GSKeysAndObjectsEnumeratorBlock, void,
GS_GENERIC_TYPE_F(KeyT,id<NSCopying>), GS_GENERIC_TYPE(ValT), BOOL*);
GS_GENERIC_TYPE_F(KeyT,id<NSCopying>), GS_GENERIC_TYPE(ValT), BOOL*);
- (void) enumerateKeysAndObjectsUsingBlock:
(GSKeysAndObjectsEnumeratorBlock)aBlock;
- (void) enumerateKeysAndObjectsWithOptions: (NSEnumerationOptions)opts
@ -78,8 +76,7 @@ DEFINE_BLOCK_TYPE(GSKeysAndObjectsEnumeratorBlock, void,
#endif
- (void) getObjects: (__unsafe_unretained GS_GENERIC_TYPE(ValT)[])objects
andKeys:
(__unsafe_unretained GS_GENERIC_TYPE_F(KeyT,id<NSCopying>)[])keys;
andKeys: (__unsafe_unretained GS_GENERIC_TYPE_F(KeyT,id<NSCopying>)[])keys;
- (instancetype) init;
- (instancetype) initWithContentsOfFile: (NSString*)path;
@ -96,10 +93,10 @@ DEFINE_BLOCK_TYPE(GSKeysAndObjectsEnumeratorBlock, void,
- (id) initWithObjectsAndKeys: (GS_GENERIC_TYPE(ValT))firstObject, ...;
- (id) initWithObjects: (const GS_GENERIC_TYPE(ValT)[])objects
forKeys: (const GS_GENERIC_TYPE_F(KeyT,id<NSCopying>)[])keys
count: (NSUInteger)count; // Primitive
count: (NSUInteger)count; // Primitive
- (BOOL) isEqualToDictionary: (GS_GENERIC_CLASS(NSDictionary,KeyT, ValT)*)other;
- (GS_GENERIC_CLASS(NSEnumerator,KeyT)*) keyEnumerator; // Primitive
- (GS_GENERIC_CLASS(NSEnumerator,KeyT)*) keyEnumerator; // Primitive
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
DEFINE_BLOCK_TYPE(GSKeysAndObjectsPredicateBlock, BOOL,
@ -107,17 +104,17 @@ DEFINE_BLOCK_TYPE(GSKeysAndObjectsPredicateBlock, BOOL,
- (GS_GENERIC_CLASS(NSSet,KeyT)*) keysOfEntriesPassingTest:
(GSKeysAndObjectsPredicateBlock)aPredicate;
- (GS_GENERIC_CLASS(NSSet,KeyT)*) keysOfEntriesWithOptions:
(NSEnumerationOptions)opts
passingTest: (GSKeysAndObjectsPredicateBlock)aPredicate;
(NSEnumerationOptions)opts
passingTest: (GSKeysAndObjectsPredicateBlock)aPredicate;
#endif
- (GS_GENERIC_CLASS(NSArray,ValT)*) keysSortedByValueUsingSelector: (SEL)comp;
- (GS_GENERIC_CLASS(NSEnumerator,ValT)*) objectEnumerator; // Primitive
- (GS_GENERIC_CLASS(NSEnumerator,ValT)*) objectEnumerator; // Primitive
- (GS_GENERIC_TYPE(ValT)) objectForKey:
(GS_GENERIC_TYPE(KeyT))aKey; // Primitive
(GS_GENERIC_TYPE(KeyT))aKey; // Primitive
- (GS_GENERIC_CLASS(NSArray,ValT)*) objectsForKeys:
(GS_GENERIC_CLASS(NSArray,KeyT)*)keys
notFoundMarker: (GS_GENERIC_TYPE(ValT))marker;
(GS_GENERIC_CLASS(NSArray,KeyT)*)keys
notFoundMarker: (GS_GENERIC_TYPE(ValT))marker;
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
- (GS_GENERIC_TYPE(ValT)) valueForKey: (NSString*)key;
@ -132,7 +129,7 @@ DEFINE_BLOCK_TYPE(GSKeysAndObjectsPredicateBlock, BOOL,
* Method called by array subscripting.
*/
- (GS_GENERIC_TYPE(ValT)) objectForKeyedSubscript:
(GS_GENERIC_TYPE(KeyT))aKey;
(GS_GENERIC_TYPE(KeyT))aKey;
@end
@interface GS_GENERIC_CLASS(NSMutableDictionary, KeyT:id<NSCopying>, ValT) :
@ -142,7 +139,7 @@ DEFINE_BLOCK_TYPE(GSKeysAndObjectsPredicateBlock, BOOL,
- (void) addEntriesFromDictionary:
(GS_GENERIC_CLASS(NSDictionary, KeyT, ValT)*)otherDictionary;
- (instancetype) initWithCapacity: (NSUInteger)numItems; // Primitive
- (instancetype) initWithCapacity: (NSUInteger)numItems; // Primitive
- (void) removeAllObjects;
/**
* Removes the object with the specified key from the receiver. This method

View file

@ -914,9 +914,9 @@ static SEL rlSel;
return nil;
}
- (id) objectAtIndexedSubscript: (size_t)anIndex
- (id) objectAtIndexedSubscript: (NSUInteger)anIndex
{
return [self objectAtIndex: (NSUInteger)anIndex];
return [self objectAtIndex: anIndex];
}
- (NSArray *) objectsAtIndexes: (NSIndexSet *)indexes
@ -2055,9 +2055,16 @@ compare(id elem1, id elem2, void* context)
[self subclassResponsibility: _cmd];
}
- (void) setObject: (id)anObject atIndexedSubscript: (size_t)anIndex
- (void) setObject: (id)anObject atIndexedSubscript: (NSUInteger)anIndex
{
[self replaceObjectAtIndex: (NSUInteger)anIndex withObject: anObject];
if ([self count] == anIndex)
{
[self addObject: anObject];
}
else
{
[self replaceObjectAtIndex: anIndex withObject: anObject];
}
}
/** Replaces the values in the receiver at the locations given by the