ObjFW  Diff

Differences From Artifact [f02c7b62f7]:

To Artifact [4267d7d56d]:

  • File src/OFArray.h — part of check-in [b7097a67b6] at 2015-06-14 10:45:10 on branch trunk — Add OF_NONNULL / OF_NULLABLE and use that instead

    Using __nonnull directly doesn't work on systems using glibc, as glibc
    defines __nonnull as a parameterized define. While this does not fix the
    problem of Clang introducing __nonnull even though it conflicts with
    glibc, this at least means it's possible again to compile things with
    versions of Clang that don't support __nonnull on systems with glibc. (user: js, size: 14354) [annotate] [blame] [check-ins using]


65
66
67
68
69
70
71
72

73
74
75
76
77
78
79
80
81

82
83
84
85
86
87
88
65
66
67
68
69
70
71

72
73
74
75
76
77
78
79
80

81
82
83
84
85
86
87
88







-
+








-
+







/*!
 * @brief A block for mapping objects to objects in an OFArray.
 *
 * @param object The object to map
 * @param index The index of the object to map
 * @return The object to map to
 */
typedef __nonnull id (^of_array_map_block_t)(id object, size_t index);
typedef id OF_NONNULL (^of_array_map_block_t)(id object, size_t index);

/*!
 * @brief A block for folding an OFArray.
 *
 * @param left The object to which the object has been folded so far
 * @param right The object that should be added to the left object
 * @return The left and right side folded into one object
 */
typedef __nullable id (^of_array_fold_block_t)(__nullable id left, id right);
typedef id OF_NULLABLE (^of_array_fold_block_t)(id OF_NULLABLE left, id right);
#endif

/*!
 * @class OFArray OFArray.h ObjFW/OFArray.h
 *
 * @brief An abstract class for storing objects in an array.
 */
135
136
137
138
139
140
141
142
143



144
145
146
147
148
149
150
135
136
137
138
139
140
141


142
143
144
145
146
147
148
149
150
151







-
-
+
+
+







 * @brief Creates a new OFArray with the objects from the specified C array of
 *	  the specified length.
 *
 * @param objects A C array of objects
 * @param count The length of the C array
 * @return A new autoreleased OFArray
 */
+ (instancetype)arrayWithObjects: (__nonnull ObjectType const *__nonnull)objects
			   count: (size_t)count;
+ (instancetype)
    arrayWithObjects: (ObjectType const OF_NONNULL *OF_NONNULL)objects
	       count: (size_t)count;

/*!
 * @brief Initializes an OFArray with the specified object.
 *
 * @param object An object
 * @return An initialized OFArray
 */
180
181
182
183
184
185
186
187

188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208


209
210
211
212
213
214
215
216

217
218
219
220
221
222
223
181
182
183
184
185
186
187

188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208

209
210
211
212
213
214
215
216
217

218
219
220
221
222
223
224
225







-
+




















-
+
+







-
+







 * @brief Initializes an OFArray with the objects from the specified C array of
 *	  the specified length.
 *
 * @param objects A C array of objects
 * @param count The length of the C array
 * @return An initialized OFArray
 */
- initWithObjects: (__nonnull ObjectType const *__nonnull)objects
- initWithObjects: (ObjectType const OF_NONNULL *OF_NONNULL)objects
	    count: (size_t)count;

/*!
 * @brief Returns the object at the specified index in the array.
 *
 * @warning The returned object is *not* retained and autoreleased for
 *	    performance reasons!
 *
 * @param index The index of the object to return
 * @return The object at the specified index in the array
 */
- (ObjectType)objectAtIndex: (size_t)index;
- (ObjectType)objectAtIndexedSubscript: (size_t)index;

/*!
 * @brief Copies the objects at the specified range to the specified buffer.
 *
 * @param buffer The buffer to copy the objects to
 * @param range The range to copy
 */
- (void)getObjects: (__unsafe_unretained __nonnull ObjectType *__nonnull)buffer
- (void)getObjects: (ObjectType __unsafe_unretained OF_NONNULL *OF_NONNULL)
			buffer
	   inRange: (of_range_t)range;

/*!
 * @brief Returns the objects of the array as a C array.
 *
 * @return The objects of the array as a C array
 */
- (__nonnull ObjectType const *__nonnull)objects;
- (ObjectType const __unsafe_unretained OF_NONNULL *OF_NONNULL)objects;

/*!
 * @brief Returns the index of the first object that is equivalent to the
 *	  specified object or `OF_NOT_FOUND` if it was not found.
 *
 * @param object The object whose index is returned
 * @return The index of the first object equivalent to the specified object
465
466
467
468
469
470
471
472

473
474
475
476
477
478
479
480
481
482
467
468
469
470
471
472
473

474
475
476
477
478
479
480
481
482
483
484







-
+










	size_t	      _count;
	unsigned long _mutations;
	unsigned long *_mutationsPtr;
	size_t	      _position;
}

- initWithArray: (OFArray*)data
   mutationsPtr: (__nullable unsigned long*)mutationsPtr;
   mutationsPtr: (unsigned long *OF_NULLABLE)mutationsPtr;
@end

OF_ASSUME_NONNULL_END

#import "OFMutableArray.h"

#ifndef NSINTEGER_DEFINED
/* Required for array literals to work */
@compatibility_alias NSArray OFArray;
#endif