Differences From Artifact [4bdaba029a]:
- File
src/OFMutableArray_adjacent.m
— part of check-in
[e8473b9db8]
at
2013-03-08 22:44:07
on branch trunk
— Document the block types.
This also removes "bool *stop" from some blocks where it does not make
sense. (user: js, size: 7794) [annotate] [blame] [check-ins using]
To Artifact [190fb95780]:
- File
src/OFMutableArray_adjacent.m
— part of check-in
[3d16a30f41]
at
2013-06-22 12:12:36
on branch trunk
— Rework exceptions.
This mostly removes the argument for the class in which the exception
occurred. As backtraces were recently added for all platforms, the
passed class does not give any extra information on where the exception
occurred anymore.This also removes a few other arguments which were not too helpful. In
the past, the idea was to pass as many arguments as possible so that it
is easier to find the origin of the exception. However, as backtraces
are a much better way to find the origin, those are not useful anymore
and just make the exception more cumbersome to use. The rule is now to
only pass arguments that might help in recovering from the exception or
provide information that is otherwise not easily accessible. (user: js, size: 7371) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
47 48 49 50 51 52 53 | return self; } - (void)addObject: (id)object { if (object == nil) | | < | < | | | < | 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | return self; } - (void)addObject: (id)object { if (object == nil) @throw [OFInvalidArgumentException exception]; [_array addItem: &object]; [object retain]; _mutations++; } - (void)insertObject: (id)object atIndex: (size_t)index { if (object == nil) @throw [OFInvalidArgumentException exception]; @try { [_array insertItem: &object atIndex: index]; } @catch (OFOutOfRangeException *e) { @throw [OFOutOfRangeException exception]; } [object retain]; _mutations++; } - (void)insertObjectsFromArray: (OFArray*)array atIndex: (size_t)index { id *objects = [array objects]; size_t i, count = [array count]; @try { [_array insertItems: objects atIndex: index count: count]; } @catch (OFOutOfRangeException *e) { @throw [OFOutOfRangeException exception]; } for (i = 0; i < count; i++) [objects[i] retain]; _mutations++; } - (void)replaceObject: (id)oldObject withObject: (id)newObject { id *objects; size_t i, count; if (oldObject == nil || newObject == nil) @throw [OFInvalidArgumentException exception]; objects = [_array items]; count = [_array count]; for (i = 0; i < count; i++) { if ([objects[i] isEqual: oldObject]) { [newObject retain]; |
︙ | ︙ | |||
125 126 127 128 129 130 131 | - (void)replaceObjectAtIndex: (size_t)index withObject: (id)object { id *objects; id oldObject; if (object == nil) | | < | | < | 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | - (void)replaceObjectAtIndex: (size_t)index withObject: (id)object { id *objects; id oldObject; if (object == nil) @throw [OFInvalidArgumentException exception]; objects = [_array items]; if (index >= [_array count]) @throw [OFOutOfRangeException exception]; oldObject = objects[index]; objects[index] = [object retain]; [oldObject release]; } - (void)replaceObjectIdenticalTo: (id)oldObject withObject: (id)newObject { id *objects; size_t i, count; if (oldObject == nil || newObject == nil) @throw [OFInvalidArgumentException exception]; objects = [_array items]; count = [_array count]; for (i = 0; i < count; i++) { if (objects[i] == oldObject) { [newObject retain]; |
︙ | ︙ | |||
168 169 170 171 172 173 174 | - (void)removeObject: (id)object { id *objects; size_t i, count; if (object == nil) | | < | 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | - (void)removeObject: (id)object { id *objects; size_t i, count; if (object == nil) @throw [OFInvalidArgumentException exception]; objects = [_array items]; count = [_array count]; for (i = 0; i < count; i++) { if ([objects[i] isEqual: object]) { object = objects[i]; |
︙ | ︙ | |||
194 195 196 197 198 199 200 | - (void)removeObjectIdenticalTo: (id)object { id *objects; size_t i, count; if (object == nil) | | < | 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | - (void)removeObjectIdenticalTo: (id)object { id *objects; size_t i, count; if (object == nil) @throw [OFInvalidArgumentException exception]; objects = [_array items]; count = [_array count]; for (i = 0; i < count; i++) { if (objects[i] == object) { [_array removeItemAtIndex: i]; |
︙ | ︙ | |||
239 240 241 242 243 244 245 | - (void)removeObjectsInRange: (of_range_t)range { id *objects = [_array items], *copy; size_t i, count = [_array count]; if (range.length > SIZE_MAX - range.location || range.length > count - range.location) | | | 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | - (void)removeObjectsInRange: (of_range_t)range { id *objects = [_array items], *copy; size_t i, count = [_array count]; if (range.length > SIZE_MAX - range.location || range.length > count - range.location) @throw [OFOutOfRangeException exception]; copy = [self allocMemoryWithSize: sizeof(*copy) count: range.length]; memcpy(copy, objects + range.location, range.length * sizeof(id)); @try { [_array removeItemsInRange: range]; |
︙ | ︙ | |||
279 280 281 282 283 284 285 | withObjectAtIndex: (size_t)index2 { id *objects = [_array items]; size_t count = [_array count]; id tmp; if (index1 >= count || index2 >= count) | | | 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | withObjectAtIndex: (size_t)index2 { id *objects = [_array items]; size_t count = [_array count]; id tmp; if (index1 >= count || index2 >= count) @throw [OFOutOfRangeException exception]; tmp = objects[index1]; objects[index1] = objects[index2]; objects[index2] = tmp; } - (void)reverse |
︙ | ︙ | |||
337 338 339 340 341 342 343 | size_t i, count = [_array count]; bool stop = false; unsigned long mutations = _mutations; for (i = 0; i < count && !stop; i++) { if (_mutations != mutations) @throw [OFEnumerationMutationException | < | < | | < < | 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 | size_t i, count = [_array count]; bool stop = false; unsigned long mutations = _mutations; for (i = 0; i < count && !stop; i++) { if (_mutations != mutations) @throw [OFEnumerationMutationException exceptionWithObject: self]; block(objects[i], i, &stop); } } - (void)replaceObjectsUsingBlock: (of_array_replace_block_t)block { id *objects = [_array items]; size_t i, count = [_array count]; unsigned long mutations = _mutations; for (i = 0; i < count; i++) { id new; if (_mutations != mutations) @throw [OFEnumerationMutationException exceptionWithObject: self]; new = block(objects[i], i); if (new == nil) @throw [OFInvalidArgumentException exception]; if (new != objects[i]) { [objects[i] release]; objects[i] = [new retain]; } } } |
︙ | ︙ |