ObjFW  Diff

Differences From Artifact [99a256af1a]:

To Artifact [809ddd51dc]:


63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
	}

	return self;
}

- (void)dealloc
{
	of_list_object_t *iter;

	for (iter = _firstListObject; iter != NULL; iter = iter->next)
		[iter->object release];

	[super dealloc];
}

- (of_list_object_t*)appendObject: (id)object
{







|
<
|







63
64
65
66
67
68
69
70

71
72
73
74
75
76
77
78
	}

	return self;
}

- (void)dealloc
{
	for (of_list_object_t *iter = _firstListObject;

	    iter != NULL; iter = iter->next)
		[iter->object release];

	[super dealloc];
}

- (of_list_object_t*)appendObject: (id)object
{
225
226
227
228
229
230
231
232
233
234
235
236

237
238
239
240
241
242
243
244
245
246
247
248
249
250

251
252
253
254
255
256
257
258
	assert(iter == NULL && iter2 == NULL);

	return true;
}

- (bool)containsObject: (id)object
{
	of_list_object_t *iter;

	if (_count == 0)
		return false;


	for (iter = _firstListObject; iter != NULL; iter = iter->next)
		if ([iter->object isEqual: object])
			return true;

	return false;
}

- (bool)containsObjectIdenticalTo: (id)object
{
	of_list_object_t *iter;

	if (_count == 0)
		return false;


	for (iter = _firstListObject; iter != NULL; iter = iter->next)
		if (iter->object == object)
			return true;

	return false;
}

- (void)removeAllObjects







<
<



>
|








<
<



>
|







224
225
226
227
228
229
230


231
232
233
234
235
236
237
238
239
240
241
242
243


244
245
246
247
248
249
250
251
252
253
254
255
	assert(iter == NULL && iter2 == NULL);

	return true;
}

- (bool)containsObject: (id)object
{


	if (_count == 0)
		return false;

	for (of_list_object_t *iter = _firstListObject;
	    iter != NULL; iter = iter->next)
		if ([iter->object isEqual: object])
			return true;

	return false;
}

- (bool)containsObjectIdenticalTo: (id)object
{


	if (_count == 0)
		return false;

	for (of_list_object_t *iter = _firstListObject;
	    iter != NULL; iter = iter->next)
		if (iter->object == object)
			return true;

	return false;
}

- (void)removeAllObjects
270
271
272
273
274
275
276
277
278
279
280
281
282

283
284
285
286
287
288
289
290

	_firstListObject = _lastListObject = NULL;
}

- copy
{
	OFList *copy = [[[self class] alloc] init];
	of_list_object_t *iter, *listObject, *previous;

	listObject = NULL;
	previous = NULL;

	@try {

		for (iter = _firstListObject; iter != NULL; iter = iter->next) {
			listObject = [copy allocMemoryWithSize:
			    sizeof(of_list_object_t)];
			listObject->object = [iter->object retain];
			listObject->next = NULL;
			listObject->previous = previous;

			if (copy->_firstListObject == NULL)







|





>
|







267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288

	_firstListObject = _lastListObject = NULL;
}

- copy
{
	OFList *copy = [[[self class] alloc] init];
	of_list_object_t *listObject, *previous;

	listObject = NULL;
	previous = NULL;

	@try {
		for (of_list_object_t *iter = _firstListObject;
		    iter != NULL; iter = iter->next) {
			listObject = [copy allocMemoryWithSize:
			    sizeof(of_list_object_t)];
			listObject->object = [iter->object retain];
			listObject->next = NULL;
			listObject->previous = previous;

			if (copy->_firstListObject == NULL)
304
305
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
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
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
	copy->_lastListObject = listObject;

	return copy;
}

- (uint32_t)hash
{
	of_list_object_t *iter;
	uint32_t hash;

	OF_HASH_INIT(hash);


	for (iter = _firstListObject; iter != NULL; iter = iter->next)
		OF_HASH_ADD_HASH(hash, [iter->object hash]);

	OF_HASH_FINALIZE(hash);

	return hash;
}

- (OFString*)description
{
	OFMutableString *ret;
	of_list_object_t *iter;

	if (_count == 0)
		return @"[]";

	ret = [OFMutableString stringWithString: @"[\n"];


	for (iter = _firstListObject; iter != NULL; iter = iter->next) {
		void *pool = objc_autoreleasePoolPush();

		[ret appendString: [iter->object description]];

		if (iter->next != NULL)
			[ret appendString: @",\n"];

		objc_autoreleasePoolPop(pool);
	}
	[ret replaceOccurrencesOfString: @"\n"
			     withString: @"\n\t"];
	[ret appendString: @"\n]"];

	[ret makeImmutable];

	return ret;
}

- (OFXMLElement*)XMLElementBySerializing
{
	OFXMLElement *element;
	of_list_object_t *iter;

	element = [OFXMLElement elementWithName: [self className]
				      namespace: OF_SERIALIZATION_NS];


	for (iter = _firstListObject; iter != NULL; iter = iter->next) {
		void *pool = objc_autoreleasePoolPush();

		[element addChild: [iter->object XMLElementBySerializing]];

		objc_autoreleasePoolPop(pool);
	}

	return element;
}

- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state
			   objects: (id*)objects
			     count: (int)count
{
	of_list_object_t *listObject;
	int i;

	memcpy(&listObject, state->extra, sizeof(listObject));

	state->itemsPtr = objects;
	state->mutationsPtr = &_mutations;

	if (state->state == 0) {
		listObject = _firstListObject;
		state->state = 1;
	}

	for (i = 0; i < count; i++) {
		if (listObject == NULL)
			return i;

		objects[i] = listObject->object;
		listObject = listObject->next;
	}








<




>
|










<






>
|




















|
<
<
|
|

>
|















<











|







302
303
304
305
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
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
367
368
369
370
371
372
373

374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
	copy->_lastListObject = listObject;

	return copy;
}

- (uint32_t)hash
{

	uint32_t hash;

	OF_HASH_INIT(hash);

	for (of_list_object_t *iter = _firstListObject;
	    iter != NULL; iter = iter->next)
		OF_HASH_ADD_HASH(hash, [iter->object hash]);

	OF_HASH_FINALIZE(hash);

	return hash;
}

- (OFString*)description
{
	OFMutableString *ret;


	if (_count == 0)
		return @"[]";

	ret = [OFMutableString stringWithString: @"[\n"];

	for (of_list_object_t *iter = _firstListObject;
	    iter != NULL; iter = iter->next) {
		void *pool = objc_autoreleasePoolPush();

		[ret appendString: [iter->object description]];

		if (iter->next != NULL)
			[ret appendString: @",\n"];

		objc_autoreleasePoolPop(pool);
	}
	[ret replaceOccurrencesOfString: @"\n"
			     withString: @"\n\t"];
	[ret appendString: @"\n]"];

	[ret makeImmutable];

	return ret;
}

- (OFXMLElement*)XMLElementBySerializing
{
	OFXMLElement *element =


	    [OFXMLElement elementWithName: [self className]
				namespace: OF_SERIALIZATION_NS];

	for (of_list_object_t *iter = _firstListObject;
	    iter != NULL; iter = iter->next) {
		void *pool = objc_autoreleasePoolPush();

		[element addChild: [iter->object XMLElementBySerializing]];

		objc_autoreleasePoolPop(pool);
	}

	return element;
}

- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state
			   objects: (id*)objects
			     count: (int)count
{
	of_list_object_t *listObject;


	memcpy(&listObject, state->extra, sizeof(listObject));

	state->itemsPtr = objects;
	state->mutationsPtr = &_mutations;

	if (state->state == 0) {
		listObject = _firstListObject;
		state->state = 1;
	}

	for (int i = 0; i < count; i++) {
		if (listObject == NULL)
			return i;

		objects[i] = listObject->object;
		listObject = listObject->next;
	}