Skip to content
50 changes: 29 additions & 21 deletions Headers/Foundation/NSArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,22 @@ enum
typedef NSUInteger NSBinarySearchingOptions;
#endif

NS_ASSUME_NONNULL_BEGIN

GS_EXPORT_CLASS
@interface GS_GENERIC_CLASS(NSArray, __covariant ElementT) : NSObject
<NSCoding, NSCopying, NSMutableCopying, NSFastEnumeration>

+ (instancetype) array;
+ (instancetype) arrayWithArray: (GS_GENERIC_CLASS(NSArray, ElementT) *)array;
+ (instancetype) arrayWithContentsOfFile: (NSString*)file;
+ (instancetype _Nullable) arrayWithContentsOfFile: (NSString*)file;
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
+ (instancetype) arrayWithContentsOfURL: (NSURL*)aURL;
+ (instancetype _Nullable) arrayWithContentsOfURL: (NSURL*)aURL;
#endif
+ (instancetype) arrayWithObject: (id)anObject;
+ (instancetype) arrayWithObjects: (id)firstObject, ...;
+ (instancetype) arrayWithObjects: (const id[])objects count: (NSUInteger)count;
+ (instancetype) arrayWithObjects: (const id _Nonnull [])objects
count: (NSUInteger)count;

- (GS_GENERIC_CLASS(NSArray, ElementT) *) arrayByAddingObject:
(GS_GENERIC_TYPE(ElementT))anObject;
Expand All @@ -80,8 +83,10 @@ GS_EXPORT_CLASS
* Returns the number of elements contained in the receiver.
*/
- (NSUInteger) count;
- (void) getObjects: (__unsafe_unretained GS_GENERIC_TYPE(ElementT)[])aBuffer;
- (void) getObjects: (__unsafe_unretained GS_GENERIC_TYPE(ElementT)[])aBuffer
- (void) getObjects:
(__unsafe_unretained GS_GENERIC_TYPE(ElementT) _Nonnull [])aBuffer;
- (void) getObjects:
(__unsafe_unretained GS_GENERIC_TYPE(ElementT) _Nonnull [])aBuffer
range: (NSRange)aRange;
- (NSUInteger) indexOfObject: (GS_GENERIC_TYPE(ElementT))anObject;
- (NSUInteger) indexOfObject: (GS_GENERIC_TYPE(ElementT))anObject
Expand All @@ -95,9 +100,9 @@ GS_EXPORT_CLASS
- (instancetype) initWithArray: (GS_GENERIC_CLASS(NSArray, ElementT)*)array
copyItems: (BOOL)shouldCopy;
#endif
- (instancetype) initWithContentsOfFile: (NSString*)file;
- (instancetype _Nullable) initWithContentsOfFile: (NSString*)file;
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
- (instancetype) initWithContentsOfURL: (NSURL*)aURL;
- (instancetype _Nullable) initWithContentsOfURL: (NSURL*)aURL;
#endif
- (instancetype) initWithObjects: (GS_GENERIC_TYPE(ElementT)) firstObject, ...;

Expand All @@ -108,11 +113,12 @@ GS_EXPORT_CLASS
* and needs to be re-implemented in subclasses in order to have all
* other initialisers work.
*/
- (instancetype) initWithObjects: (const GS_GENERIC_TYPE(ElementT)[])objects
- (instancetype) initWithObjects:
(const GS_GENERIC_TYPE(ElementT) _Nonnull [])objects
count: (NSUInteger)count;
- (GS_GENERIC_TYPE(ElementT)) lastObject;
- (GS_GENERIC_TYPE(ElementT) _Nullable) lastObject;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
- (GS_GENERIC_TYPE(ElementT)) firstObject;
- (GS_GENERIC_TYPE(ElementT) _Nullable) firstObject;
#endif

/** <override-subclass />
Expand All @@ -129,27 +135,27 @@ GS_EXPORT_CLASS
(NSIndexSet *)indexes;
#endif

- (GS_GENERIC_TYPE(ElementT)) firstObjectCommonWithArray:
- (GS_GENERIC_TYPE(ElementT) _Nullable) firstObjectCommonWithArray:
(GS_GENERIC_CLASS(NSArray, ElementT) *)otherArray;
- (BOOL) isEqualToArray: (NSArray*)otherArray;

#if OS_API_VERSION(GS_API_OPENSTEP, GS_API_MACOSX)
- (void) makeObjectsPerform: (SEL)aSelector;
- (void) makeObjectsPerform: (SEL)aSelector withObject: (id)argument;
- (void) makeObjectsPerform: (SEL)aSelector withObject: (id _Nullable)argument;
#endif
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
- (void) makeObjectsPerformSelector: (SEL)aSelector;
- (void) makeObjectsPerformSelector: (SEL)aSelector withObject: (id)arg;
- (void) makeObjectsPerformSelector: (SEL)aSelector withObject: (id _Nullable)arg;
#endif

- (NSData*) sortedArrayHint;
- (NSData *_Nullable) sortedArrayHint;
- (GS_GENERIC_CLASS(NSArray, ElementT)*) sortedArrayUsingFunction:
(NSComparisonResult (*)(id, id, void*))comparator
context: (void*)context;
context: (void *_Nullable)context;
- (GS_GENERIC_CLASS(NSArray, ElementT)*) sortedArrayUsingFunction:
(NSComparisonResult (*)(id, id, void*))comparator
context: (void*)context
hint: (NSData*)hint;
context: (void *_Nullable)context
hint: (NSData *_Nullable)hint;
- (GS_GENERIC_CLASS(NSArray, ElementT)*) sortedArrayUsingSelector:
(SEL)comparator;
- (GS_GENERIC_CLASS(NSArray, ElementT)*) subarrayWithRange: (NSRange)aRange;
Expand All @@ -162,15 +168,15 @@ GS_EXPORT_CLASS
- (GS_GENERIC_CLASS(NSEnumerator, ElementT)*) reverseObjectEnumerator;

- (NSString*) description;
- (NSString*) descriptionWithLocale: (id)locale;
- (NSString*) descriptionWithLocale: (id)locale
- (NSString*) descriptionWithLocale: (id _Nullable)locale;
- (NSString*) descriptionWithLocale: (id _Nullable)locale
indent: (NSUInteger)level;

- (BOOL) writeToFile: (NSString*)path atomically: (BOOL)useAuxiliaryFile;
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
- (BOOL) writeToURL: (NSURL*)url atomically: (BOOL)useAuxiliaryFile;
- (id) valueForKey: (NSString*)key;
- (void) setValue: (id)value forKey: (NSString*)key;
- (void) setValue: (id _Nullable)value forKey: (NSString*)key;
#endif

#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
Expand Down Expand Up @@ -389,7 +395,7 @@ GS_EXPORT_CLASS
- (void) sortUsingFunction:
(NSComparisonResult (*)(GS_GENERIC_TYPE(ElementT),
GS_GENERIC_TYPE(ElementT),void*))compare
context: (void*)context;
context: (void *_Nullable)context;
- (void) sortUsingSelector: (SEL)comparator;


Expand All @@ -415,6 +421,8 @@ atIndexedSubscript: (NSUInteger)anIndex;
#endif
@end

NS_ASSUME_NONNULL_END

#if defined(__cplusplus)
}
#endif
Expand Down
70 changes: 37 additions & 33 deletions Headers/Foundation/NSData.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,37 +98,39 @@ enum {
DEFINE_BLOCK_TYPE(GSDataDeallocatorBlock, void, void*, NSUInteger);
#endif

NS_ASSUME_NONNULL_BEGIN

GS_EXPORT_CLASS
@interface NSData : NSObject <NSCoding, NSCopying, NSMutableCopying>

// Allocating and Initializing a Data Object

+ (instancetype) data;
+ (instancetype) dataWithBytes: (const void*)bytes
length: (NSUInteger)length;
+ (instancetype) dataWithBytesNoCopy: (void*)bytes
+ (nonnull instancetype) dataWithBytes: (const void *_Nullable)bytes
length: (NSUInteger)length;
+ (instancetype) dataWithBytesNoCopy: (void *_Nullable)bytes
length: (NSUInteger)length;
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
+ (instancetype) dataWithBytesNoCopy: (void*)aBuffer
+ (instancetype) dataWithBytesNoCopy: (void *_Nullable)aBuffer
length: (NSUInteger)bufferSize
freeWhenDone: (BOOL)shouldFree;
#endif
+ (instancetype) dataWithContentsOfFile: (NSString *)path
options: (NSDataReadingOptions)readOptionsMask
error: (NSError **)errorPtr;
+ (instancetype) dataWithContentsOfFile: (NSString*)path;
+ (instancetype) dataWithContentsOfMappedFile: (NSString*)path;
+ (instancetype _Nullable) dataWithContentsOfFile: (NSString *)path
options: (NSDataReadingOptions)readOptionsMask
error: (NSError *_Nullable *_Nullable)errorPtr;
+ (instancetype _Nullable) dataWithContentsOfFile: (NSString*)path;
+ (instancetype _Nullable) dataWithContentsOfMappedFile: (NSString*)path;
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
+ (instancetype) dataWithContentsOfURL: (NSURL *)url
options: (NSDataReadingOptions)readOptionsMask
error: (NSError **)errorPtr;
+ (instancetype) dataWithContentsOfURL: (NSURL*)url;
+ (instancetype _Nullable) dataWithContentsOfURL: (NSURL *)url
options: (NSDataReadingOptions)readOptionsMask
error: (NSError *_Nullable *_Nullable)errorPtr;
+ (instancetype _Nullable) dataWithContentsOfURL: (NSURL*)url;
#endif
+ (instancetype) dataWithData: (NSData*)data;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_9,GS_API_LATEST)
- (instancetype) initWithBase64EncodedData: (NSData*)base64Data
- (instancetype _Nullable) initWithBase64EncodedData: (NSData*)base64Data
options: (NSDataBase64DecodingOptions)options;
- (instancetype) initWithBase64EncodedString: (NSString*)base64String
- (instancetype _Nullable) initWithBase64EncodedString: (NSString*)base64String
options: (NSDataBase64DecodingOptions)options;
/**
* <override-subclass/>
Expand All @@ -141,31 +143,31 @@ GS_EXPORT_CLASS
length: (NSUInteger)length
deallocator: (GSDataDeallocatorBlock)deallocBlock;
#endif
- (instancetype) initWithBytes: (const void*)aBuffer
length: (NSUInteger)bufferSize;
- (instancetype) initWithBytesNoCopy: (void*)aBuffer
- (nonnull instancetype) initWithBytes: (const void *_Nullable)aBuffer
length: (NSUInteger)bufferSize;
- (instancetype) initWithBytesNoCopy: (void *_Nullable)aBuffer
length: (NSUInteger)bufferSize;
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
- (instancetype) initWithBytesNoCopy: (void*)aBuffer
- (instancetype) initWithBytesNoCopy: (void *_Nullable)aBuffer
length: (NSUInteger)bufferSize
freeWhenDone: (BOOL)shouldFree;
#endif
- (instancetype) initWithContentsOfFile: (NSString*)path;
- (instancetype) initWithContentsOfFile: (NSString *) path
options: (NSDataReadingOptions) readOptionsMask
error: (NSError **) errorPtr;
- (instancetype) initWithContentsOfMappedFile: (NSString*)path;
- (instancetype _Nullable) initWithContentsOfFile: (NSString*)path;
- (instancetype _Nullable) initWithContentsOfFile: (NSString *) path
options: (NSDataReadingOptions) readOptionsMask
error: (NSError *_Nullable *_Nullable) errorPtr;
- (instancetype _Nullable) initWithContentsOfMappedFile: (NSString*)path;
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
- (instancetype) initWithContentsOfURL: (NSURL*)url;
- (instancetype) initWithContentsOfURL: (NSURL *)url
options: (NSDataReadingOptions)readOptionsMask
error: (NSError **)errorPtr;
- (instancetype _Nullable) initWithContentsOfURL: (NSURL*)url;
- (instancetype _Nullable) initWithContentsOfURL: (NSURL *)url
options: (NSDataReadingOptions)readOptionsMask
error: (NSError *_Nullable *_Nullable)errorPtr;
#endif
- (instancetype) initWithData: (NSData*)data;

// Accessing Data

- (const void*) bytes;
- (const void *_Nullable) bytes;
- (NSString*) description;
- (void) getBytes: (void*)buffer;
- (void) getBytes: (void*)buffer
Expand Down Expand Up @@ -355,21 +357,21 @@ GS_EXPORT_CLASS

- (void) increaseLengthBy: (NSUInteger)extraLength;
- (void) setLength: (NSUInteger)size;
- (void*) mutableBytes;
- (void *_Nullable) mutableBytes;

// Appending Data

- (void) appendBytes: (const void*)aBuffer
- (void) appendBytes: (const void *_Nullable)aBuffer
length: (NSUInteger)bufferSize;
- (void) appendData: (NSData*)other;

// Modifying Data

- (void) replaceBytesInRange: (NSRange)aRange
withBytes: (const void*)bytes;
withBytes: (const void *_Nullable)bytes;
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
- (void) replaceBytesInRange: (NSRange)aRange
withBytes: (const void*)bytes
withBytes: (const void *_Nullable)bytes
length: (NSUInteger)length;
#endif
- (void) resetBytesInRange: (NSRange)aRange;
Expand All @@ -392,6 +394,8 @@ GS_EXPORT_CLASS

@end

NS_ASSUME_NONNULL_END

#if OS_API_VERSION(GS_API_NONE, GS_API_NONE)

@interface NSMutableData (GNUstepExtensions)
Expand Down
Loading
Loading