Author: rfm
Date: Wed Feb 24 08:41:20 2016
New Revision: 39411

URL: http://svn.gna.org/viewcvs/gnustep?rev=39411&view=rev
Log:
Apply patch by Patrick Laurent and tidy a bit.

Modified:
    libs/base/trunk/ChangeLog
    libs/base/trunk/Headers/Foundation/NSArray.h
    libs/base/trunk/Headers/Foundation/NSDictionary.h
    libs/base/trunk/Source/NSArray.m

Modified: libs/base/trunk/ChangeLog
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/ChangeLog?rev=39411&r1=39410&r2=39411&view=diff
==============================================================================
--- libs/base/trunk/ChangeLog   (original)
+++ libs/base/trunk/ChangeLog   Wed Feb 24 08:41:20 2016
@@ -1,29 +1,39 @@
+2016-02-24  Richard Frith-Macdonald <[email protected]>
+
+       * Headers/Foundation/NSArray.h:
+       * Source/NSArray.m:
+       Correct argument types in ([-objectAtIndexedSubscript:]) and
+       ([setObject:atIndexedSubscript:]) to match OSX.
+       Apply patch by Patrick Laurent <[email protected]> to fix bug setting
+       an object at the end of the array.
+
 2016-02-22     Niels Grewe <[email protected]>
        * 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.
-
-2016-02-18  Richard Frith-Macdonald <[email protected]>
+       NSDiscardableContent, while the API documentation seems to suggest
+       that cost and count based eviction without NSDiscardableContent is
+       also possible.
+
+016-02-18  Richard Frith-Macdonald <[email protected]>
 
        * Source/Additions/GSMime.m:
        Fold using tabs between key=value tokens in structured headers

Modified: libs/base/trunk/Headers/Foundation/NSArray.h
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Headers/Foundation/NSArray.h?rev=39411&r1=39410&r2=39411&view=diff
==============================================================================
--- libs/base/trunk/Headers/Foundation/NSArray.h        (original)
+++ libs/base/trunk/Headers/Foundation/NSArray.h        Wed Feb 24 08:41:20 2016
@@ -71,9 +71,9 @@
 + (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 @@
 - (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 @@
     (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 @@
 
 #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 @@
  * 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 @@
 #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 @@
 - (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)

Modified: libs/base/trunk/Headers/Foundation/NSDictionary.h
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Headers/Foundation/NSDictionary.h?rev=39411&r1=39410&r2=39411&view=diff
==============================================================================
--- libs/base/trunk/Headers/Foundation/NSDictionary.h   (original)
+++ libs/base/trunk/Headers/Foundation/NSDictionary.h   Wed Feb 24 08:41:20 2016
@@ -38,8 +38,8 @@
 @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 @@
 #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 @@
 
 #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 @@
 #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 @@
 - (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 @@
 - (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 @@
  * 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 @@
 
 - (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

Modified: libs/base/trunk/Source/NSArray.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/NSArray.m?rev=39411&r1=39410&r2=39411&view=diff
==============================================================================
--- libs/base/trunk/Source/NSArray.m    (original)
+++ libs/base/trunk/Source/NSArray.m    Wed Feb 24 08:41:20 2016
@@ -914,9 +914,9 @@
   return nil;
 }
 
-- (id) objectAtIndexedSubscript: (size_t)anIndex
-{
-  return [self objectAtIndex: (NSUInteger)anIndex];
+- (id) objectAtIndexedSubscript: (NSUInteger)anIndex
+{
+  return [self objectAtIndex: anIndex];
 }
 
 - (NSArray *) objectsAtIndexes: (NSIndexSet *)indexes
@@ -2055,9 +2055,16 @@
   [self subclassResponsibility: _cmd];
 }
 
-- (void) setObject: (id)anObject atIndexedSubscript: (size_t)anIndex
-{
-  [self replaceObjectAtIndex: (NSUInteger)anIndex withObject: anObject];
+- (void) setObject: (id)anObject atIndexedSubscript: (NSUInteger)anIndex
+{
+  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


_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs

Reply via email to