2424
2525#import " IOSArray.h"
2626
27+ #if __has_feature(nullability)
28+ #pragma clang diagnostic push
29+ #pragma GCC diagnostic ignored "-Wnullability"
30+ #pragma GCC diagnostic ignored "-Wnullability-completeness"
31+ #endif
32+
2733@class IOSClass;
2834@class IOSObjectArray;
2935
3036/* *
3137 * An emulation class that represents a Java object array. Like a Java array,
3238 * an IOSObjectArray is fixed-size but its elements are mutable.
3339 */
34- @interface IOSObjectArray <__covariant ObjectType> : IOSArray<ObjectType> {
40+ NS_ASSUME_NONNULL_BEGIN
41+ @interface IOSObjectArray <__covariant ObjectType> : IOSArray <ObjectType> {
3542 @public
3643 /* *
3744 * The type of elements in this array.
4653 ObjectType __strong buffer_[0 ] __attribute__ ((aligned (__alignof__ (volatile_id))));
4754}
4855
49- @property (readonly ) IOSClass *elementType;
56+ @property (readonly ) IOSClass *elementType;
5057
5158/* * Create an array from a C object array, length, and type. */
52- + (instancetype )newArrayWithObjects : (const ObjectType *)objects
59+ + (instancetype )newArrayWithObjects : (const _Nonnull ObjectType *_Nonnull )objects
5360 count : (NSUInteger )count
5461 type : (IOSClass *)type ;
5562
5663/* * Create an autoreleased array from a C object array, length, and type. */
57- + (instancetype )arrayWithObjects : (const ObjectType *)objects
64+ + (instancetype )arrayWithObjects : (const _Nonnull ObjectType *_Nonnull )objects
5865 count : (NSUInteger )count
5966 type : (IOSClass *)type ;
6067
101108 * @throws IndexOutOfBoundsException
102109 * if the specified length is greater than the array size.
103110 */
104- - (void )getObjects : (NSObject ** )buffer length : (NSUInteger )length ;
111+ - (void )getObjects : (NSObject *_Nonnull *_Nonnull )buffer length : (NSUInteger )length ;
105112
106113@end
114+ NS_ASSUME_NONNULL_END
107115
108116/* *
109117 * Gets element at a specified index, functional equivalent to objectAtIndex:.
110118 * @throws IndexOutOfBoundsException
111119 * if index is out of range
112120 * @return the element at index.
113121 */
114- __attribute__ ((always_inline)) inline id IOSObjectArray_Get(
115- __unsafe_unretained IOSObjectArray *array, jint index) {
122+ __attribute__ ((always_inline)) inline id _Nullable IOSObjectArray_Get(
123+ __unsafe_unretained IOSObjectArray *_Nonnull array, jint index) {
116124 IOSArray_checkIndex (array->size_ , index);
117125 return ALWAYS_RETAINED_AUTORELEASED_RETURN_VALUE (array->buffer_ [index]);
118126}
@@ -123,7 +131,8 @@ __attribute__((always_inline)) inline id IOSObjectArray_Get(
123131 * if index is out of range
124132 * @return the replacement object.
125133 */
126- FOUNDATION_EXPORT id IOSObjectArray_Set (IOSObjectArray *array, NSUInteger index, id value);
134+ FOUNDATION_EXPORT id _Nullable IOSObjectArray_Set (IOSObjectArray *_Nonnull array, NSUInteger index,
135+ id _Nullable value);
127136
128137/* *
129138 * Sets element at a specified index, same as IOSObjectArray_Set(), but this function
@@ -132,22 +141,28 @@ FOUNDATION_EXPORT id IOSObjectArray_Set(IOSObjectArray *array, NSUInteger index,
132141 * if index is out of range
133142 * @return the replacement object.
134143 */
135- FOUNDATION_EXPORT id IOSObjectArray_SetAndConsume (IOSObjectArray *array, NSUInteger index,
136- id __attribute__ ((ns_consumed)) value);
144+ FOUNDATION_EXPORT id _Nullable IOSObjectArray_SetAndConsume (IOSObjectArray *_Nonnull array,
145+ NSUInteger index,
146+ id _Nullable
147+ __attribute__ ((ns_consumed)) value);
137148
138149// Internal only. Provides a pointer to an element with the array itself.
139150// Used for translating certain compound expressions.
140151typedef struct JreArrayRef {
141- __unsafe_unretained IOSObjectArray *arr;
142- __strong id * pValue;
152+ __unsafe_unretained IOSObjectArray *_Nonnull arr;
153+ __strong id _Nonnull *_Nullable pValue;
143154} JreArrayRef;
144155
145156// Internal only functions.
146157__attribute__ ((always_inline)) inline JreArrayRef IOSObjectArray_GetRef(
147- __unsafe_unretained IOSObjectArray *array, jint index) {
158+ __unsafe_unretained IOSObjectArray *_Nonnull array, jint index) {
148159 IOSArray_checkIndex (array->size_ , index);
149- return (JreArrayRef){ .arr = array, .pValue = &array->buffer_ [index] };
160+ return (JreArrayRef){.arr = array, .pValue = &array->buffer_ [index]};
150161}
151- FOUNDATION_EXPORT id IOSObjectArray_SetRef (JreArrayRef ref, id value);
162+ FOUNDATION_EXPORT id _Nullable IOSObjectArray_SetRef (JreArrayRef ref, id _Nullable value);
163+
164+ #if __has_feature(nullability)
165+ #pragma clang diagnostic pop
166+ #endif
152167
153- #endif // IOSObjectArray_H
168+ #endif // IOSObjectArray_H
0 commit comments