2424
2525#import " IOSArray.h"
2626
27+ #if __has_feature(nullability)
28+ #pragma clang diagnostic push
29+ #pragma GCC diagnostic ignored "-Wnullability-completeness"
30+ #endif
31+
2732@class IOSClass;
2833@class IOSObjectArray;
2934
3035/* *
3136 * An emulation class that represents a Java object array. Like a Java array,
3237 * an IOSObjectArray is fixed-size but its elements are mutable.
3338 */
34- @interface IOSObjectArray <__covariant ObjectType> : IOSArray<ObjectType> {
39+ NS_ASSUME_NONNULL_BEGIN
40+ @interface IOSObjectArray <__covariant ObjectType> : IOSArray <ObjectType> {
3541 @public
3642 /* *
3743 * The type of elements in this array.
4652 ObjectType __strong buffer_[0 ] __attribute__ ((aligned (__alignof__ (volatile_id))));
4753}
4854
49- @property (readonly ) IOSClass *elementType;
55+ @property (readonly ) IOSClass *elementType;
5056
5157/* * Create an array from a C object array, length, and type. */
52- + (instancetype )newArrayWithObjects : (const ObjectType *)objects
58+ + (instancetype )newArrayWithObjects : (const _Nonnull ObjectType *_Nonnull )objects
5359 count : (NSUInteger )count
5460 type : (IOSClass *)type ;
5561
5662/* * Create an autoreleased array from a C object array, length, and type. */
57- + (instancetype )arrayWithObjects : (const ObjectType *)objects
63+ + (instancetype )arrayWithObjects : (const _Nonnull ObjectType *_Nonnull )objects
5864 count : (NSUInteger )count
5965 type : (IOSClass *)type ;
6066
101107 * @throws IndexOutOfBoundsException
102108 * if the specified length is greater than the array size.
103109 */
104- - (void )getObjects : (NSObject ** )buffer length : (NSUInteger )length ;
110+ - (void )getObjects : (NSObject *_Nonnull *_Nonnull )buffer length : (NSUInteger )length ;
105111
106112@end
107113
111117 * if index is out of range
112118 * @return the element at index.
113119 */
114- __attribute__ ((always_inline)) inline id IOSObjectArray_Get(
115- __unsafe_unretained IOSObjectArray *array, jint index) {
120+ __attribute__ ((always_inline)) inline id _Nullable IOSObjectArray_Get(
121+ __unsafe_unretained IOSObjectArray *_Nonnull array, jint index) {
116122 IOSArray_checkIndex (array->size_ , index);
117123 return ALWAYS_RETAINED_AUTORELEASED_RETURN_VALUE (array->buffer_ [index]);
118124}
@@ -123,7 +129,8 @@ __attribute__((always_inline)) inline id IOSObjectArray_Get(
123129 * if index is out of range
124130 * @return the replacement object.
125131 */
126- FOUNDATION_EXPORT id IOSObjectArray_Set (IOSObjectArray *array, NSUInteger index, id value);
132+ FOUNDATION_EXPORT id _Nullable IOSObjectArray_Set (IOSObjectArray *_Nonnull array, NSUInteger index,
133+ id _Nullable value);
127134
128135/* *
129136 * Sets element at a specified index, same as IOSObjectArray_Set(), but this function
@@ -132,22 +139,30 @@ FOUNDATION_EXPORT id IOSObjectArray_Set(IOSObjectArray *array, NSUInteger index,
132139 * if index is out of range
133140 * @return the replacement object.
134141 */
135- FOUNDATION_EXPORT id IOSObjectArray_SetAndConsume (IOSObjectArray *array, NSUInteger index,
136- id __attribute__ ((ns_consumed)) value);
142+ FOUNDATION_EXPORT id _Nullable IOSObjectArray_SetAndConsume (IOSObjectArray *_Nonnull array,
143+ NSUInteger index,
144+ id _Nullable
145+ __attribute__ ((ns_consumed)) value);
137146
138147// Internal only. Provides a pointer to an element with the array itself.
139148// Used for translating certain compound expressions.
140149typedef struct JreArrayRef {
141- __unsafe_unretained IOSObjectArray *arr;
142- __strong id * pValue;
150+ __unsafe_unretained IOSObjectArray *_Nonnull arr;
151+ __strong id _Nonnull *_Nullable pValue;
143152} JreArrayRef;
144153
145154// Internal only functions.
146155__attribute__ ((always_inline)) inline JreArrayRef IOSObjectArray_GetRef(
147- __unsafe_unretained IOSObjectArray *array, jint index) {
156+ __unsafe_unretained IOSObjectArray *_Nonnull array, jint index) {
148157 IOSArray_checkIndex (array->size_ , index);
149- return (JreArrayRef){ .arr = array, .pValue = &array->buffer_ [index] };
158+ return (JreArrayRef){.arr = array, .pValue = &array->buffer_ [index]};
150159}
151- FOUNDATION_EXPORT id IOSObjectArray_SetRef (JreArrayRef ref, id value);
160+ FOUNDATION_EXPORT id _Nullable IOSObjectArray_SetRef (JreArrayRef ref, id _Nullable value);
161+
162+ NS_ASSUME_NONNULL_END
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