ObjFW  Diff

Differences From Artifact [b75900fe79]:

To Artifact [f345fceab0]:


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

- (void)insertObjectsFromArray: (OFArray*)array_
		       atIndex: (size_t)index
{
	id *objects = [array_ objects];
	size_t i, count = [array_ count];

	[array insertItemsFromCArray: objects
			     atIndex: index
			       count: count];

	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
		    exceptionWithClass: [self class]];

	objects = [array cArray];
	count = [array count];

	for (i = 0; i < count; i++) {
		if ([objects[i] isEqual: oldObject]) {
			[newObject retain];
			[objects[i] release];
			objects[i] = newObject;







|
|
|

















|







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

- (void)insertObjectsFromArray: (OFArray*)array_
		       atIndex: (size_t)index
{
	id *objects = [array_ objects];
	size_t i, count = [array_ count];

	[array insertItems: objects
		   atIndex: index
		     count: count];

	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
		    exceptionWithClass: [self class]];

	objects = [array items];
	count = [array count];

	for (i = 0; i < count; i++) {
		if ([objects[i] isEqual: oldObject]) {
			[newObject retain];
			[objects[i] release];
			objects[i] = newObject;
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
	id *objects;
	id oldObject;

	if (object == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	objects = [array cArray];

	if (index >= [array count])
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	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
		    exceptionWithClass: [self class]];

	objects = [array cArray];
	count = [array count];

	for (i = 0; i < count; i++) {
		if (objects[i] == oldObject) {
			[newObject retain];
			[objects[i] release];
			objects[i] = newObject;







|



















|







105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
	id *objects;
	id oldObject;

	if (object == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	objects = [array items];

	if (index >= [array count])
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	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
		    exceptionWithClass: [self class]];

	objects = [array items];
	count = [array count];

	for (i = 0; i < count; i++) {
		if (objects[i] == oldObject) {
			[newObject retain];
			[objects[i] release];
			objects[i] = newObject;
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
	id *objects;
	size_t i, count;

	if (object == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	objects = [array cArray];
	count = [array count];

	for (i = 0; i < count; i++) {
		if ([objects[i] isEqual: object]) {
			object = objects[i];

			[array removeItemAtIndex: i];







|







148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
	id *objects;
	size_t i, count;

	if (object == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	objects = [array items];
	count = [array count];

	for (i = 0; i < count; i++) {
		if ([objects[i] isEqual: object]) {
			object = objects[i];

			[array removeItemAtIndex: i];
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
	id *objects;
	size_t i, count;

	if (object == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	objects = [array cArray];
	count = [array count];

	for (i = 0; i < count; i++) {
		if (objects[i] == object) {
			[array removeItemAtIndex: i];
			mutations++;








|







174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
	id *objects;
	size_t i, count;

	if (object == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	objects = [array items];
	count = [array count];

	for (i = 0; i < count; i++) {
		if (objects[i] == object) {
			[array removeItemAtIndex: i];
			mutations++;

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
	[object release];

	mutations++;
}

- (void)removeAllObjects
{
	id *objects = [array cArray];
	size_t i, count = [array count];

	for (i = 0; i < count; i++)
		[objects[i] release];

	[array removeAllItems];
}

- (void)removeObjectsInRange: (of_range_t)range
{
	id *objects = [array cArray], *copy;
	size_t i, count = [array count];

	if (range.length > SIZE_MAX - range.location ||
	    range.length > count - range.location)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	copy = [self allocMemoryWithSize: sizeof(*copy)







|










|







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
	[object release];

	mutations++;
}

- (void)removeAllObjects
{
	id *objects = [array items];
	size_t i, count = [array count];

	for (i = 0; i < count; i++)
		[objects[i] release];

	[array removeAllItems];
}

- (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 exceptionWithClass: [self class]];

	copy = [self allocMemoryWithSize: sizeof(*copy)
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279

	mutations++;
}

- (void)exchangeObjectAtIndex: (size_t)index1
	    withObjectAtIndex: (size_t)index2
{
	id *objects = [array cArray];
	size_t count = [array count];
	id tmp;

	if (index1 >= count || index2 >= count)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	tmp = objects[index1];
	objects[index1] = objects[index2];
	objects[index2] = tmp;
}

- (void)reverse
{
	id *objects = [array cArray];
	size_t i, j, count = [array count];

	if (count == 0 || count == 1)
		return;

	for (i = 0, j = count - 1; i < j; i++, j--) {
		id tmp = objects[i];







|













|







251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279

	mutations++;
}

- (void)exchangeObjectAtIndex: (size_t)index1
	    withObjectAtIndex: (size_t)index2
{
	id *objects = [array items];
	size_t count = [array count];
	id tmp;

	if (index1 >= count || index2 >= count)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	tmp = objects[index1];
	objects[index1] = objects[index2];
	objects[index2] = tmp;
}

- (void)reverse
{
	id *objects = [array items];
	size_t i, j, count = [array count];

	if (count == 0 || count == 1)
		return;

	for (i = 0, j = count - 1; i < j; i++, j--) {
		id tmp = objects[i];
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
	    initWithArray: self
	     mutationsPtr: &mutations] autorelease];
}

#ifdef OF_HAVE_BLOCKS
- (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block
{
	id *objects = [array cArray];
	size_t i, count = [array count];
	BOOL stop = NO;
	unsigned long mutations_ = mutations;

	for (i = 0; i < count && !stop; i++) {
		if (mutations != mutations_)
			@throw [OFEnumerationMutationException
			    exceptionWithClass: [self class]
					object: self];

		block(objects[i], i, &stop);
	}
}

- (void)replaceObjectsUsingBlock: (of_array_replace_block_t)block
{
	id *objects = [array cArray];
	size_t i, count = [array count];
	BOOL stop = NO;
	unsigned long mutations_ = mutations;

	for (i = 0; i < count && !stop; i++) {
		id newObject;








|
















|







306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
	    initWithArray: self
	     mutationsPtr: &mutations] autorelease];
}

#ifdef OF_HAVE_BLOCKS
- (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block
{
	id *objects = [array items];
	size_t i, count = [array count];
	BOOL stop = NO;
	unsigned long mutations_ = mutations;

	for (i = 0; i < count && !stop; i++) {
		if (mutations != mutations_)
			@throw [OFEnumerationMutationException
			    exceptionWithClass: [self class]
					object: self];

		block(objects[i], i, &stop);
	}
}

- (void)replaceObjectsUsingBlock: (of_array_replace_block_t)block
{
	id *objects = [array items];
	size_t i, count = [array count];
	BOOL stop = NO;
	unsigned long mutations_ = mutations;

	for (i = 0; i < count && !stop; i++) {
		id newObject;