24
24
25
25
#import " IOSArray.h"
26
26
27
+ #if __has_feature(nullability)
28
+ #pragma clang diagnostic push
29
+ #pragma GCC diagnostic ignored "-Wnullability-completeness"
30
+ #endif
31
+
27
32
@class IOSClass;
28
33
@class IOSObjectArray;
29
34
30
35
/* *
31
36
* An emulation class that represents a Java object array. Like a Java array,
32
37
* an IOSObjectArray is fixed-size but its elements are mutable.
33
38
*/
34
- @interface IOSObjectArray <__covariant ObjectType> : IOSArray<ObjectType> {
39
+ NS_ASSUME_NONNULL_BEGIN
40
+ @interface IOSObjectArray <__covariant ObjectType> : IOSArray <ObjectType> {
35
41
@public
36
42
/* *
37
43
* The type of elements in this array.
46
52
ObjectType __strong buffer_[0 ] __attribute__ ((aligned (__alignof__ (volatile_id))));
47
53
}
48
54
49
- @property (readonly ) IOSClass *elementType;
55
+ @property (readonly ) IOSClass *elementType;
50
56
51
57
/* * 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
53
59
count : (NSUInteger )count
54
60
type : (IOSClass *)type ;
55
61
56
62
/* * 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
58
64
count : (NSUInteger )count
59
65
type : (IOSClass *)type ;
60
66
101
107
* @throws IndexOutOfBoundsException
102
108
* if the specified length is greater than the array size.
103
109
*/
104
- - (void )getObjects : (NSObject ** )buffer length : (NSUInteger )length ;
110
+ - (void )getObjects : (NSObject *_Nonnull *_Nonnull )buffer length : (NSUInteger )length ;
105
111
106
112
@end
107
113
111
117
* if index is out of range
112
118
* @return the element at index.
113
119
*/
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) {
116
122
IOSArray_checkIndex (array->size_ , index);
117
123
return ALWAYS_RETAINED_AUTORELEASED_RETURN_VALUE (array->buffer_ [index]);
118
124
}
@@ -123,7 +129,8 @@ __attribute__((always_inline)) inline id IOSObjectArray_Get(
123
129
* if index is out of range
124
130
* @return the replacement object.
125
131
*/
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);
127
134
128
135
/* *
129
136
* 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,
132
139
* if index is out of range
133
140
* @return the replacement object.
134
141
*/
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);
137
146
138
147
// Internal only. Provides a pointer to an element with the array itself.
139
148
// Used for translating certain compound expressions.
140
149
typedef struct JreArrayRef {
141
- __unsafe_unretained IOSObjectArray *arr;
142
- __strong id * pValue;
150
+ __unsafe_unretained IOSObjectArray *_Nonnull arr;
151
+ __strong id _Nonnull *_Nullable pValue;
143
152
} JreArrayRef;
144
153
145
154
// Internal only functions.
146
155
__attribute__ ((always_inline)) inline JreArrayRef IOSObjectArray_GetRef(
147
- __unsafe_unretained IOSObjectArray *array, jint index) {
156
+ __unsafe_unretained IOSObjectArray *_Nonnull array, jint index) {
148
157
IOSArray_checkIndex (array->size_ , index);
149
- return (JreArrayRef){ .arr = array, .pValue = &array->buffer_ [index] };
158
+ return (JreArrayRef){.arr = array, .pValue = &array->buffer_ [index]};
150
159
}
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
152
167
153
- #endif // IOSObjectArray_H
168
+ #endif // IOSObjectArray_H
0 commit comments