ObjFW  Diff

Differences From Artifact [75df3d0578]:

To Artifact [60c8cd9af5]:


16
17
18
19
20
21
22

23
24
25
26
27
28
29
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30







+








#include "config.h"

#include "assert.h"

#import "OFList.h"
#import "OFString.h"
#import "OFXMLElement.h"
#import "OFAutoreleasePool.h"

#import "OFEnumerationMutationException.h"

#import "macros.h"

@implementation OFList
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
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







-
+

-

+


-
-
+
+

-

+
+


-
-
+
-
-
-


-
-
-



-
-
-
-
-
-
-
+






-
+





-
+



-
+


-
-
+
+







	 * to be OFString*, so it can't be modified anyway. But not swizzling it
	 * would create a real copy each time -[copy] is called.
	 */
	ret->isa = [OFString class];
	return ret;
}

- (OFString*)stringBySerializing
- (OFXMLElement*)XMLElementBySerializing
{
	OFMutableString *ret;
	OFAutoreleasePool *pool;
	OFXMLElement *element;
	of_list_object_t *iter;

	if (count == 0)
		return @"(list,mutable)[]";
	element = [OFXMLElement elementWithName: @"object"
				      namespace: OF_SERIALIZATION_NS];

	ret = [OFMutableString stringWithString: @"(list,mutable)[\n"];
	pool = [[OFAutoreleasePool alloc] init];
	[element addAttributeWithName: @"class"
			  stringValue: [self className]];

	for (iter = firstListObject; iter != NULL; iter = iter->next) {
		[ret appendString: [iter->object stringBySerializing]];

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

		[pool releaseObjects];
	}
	[ret replaceOccurrencesOfString: @"\n"
			     withString: @"\n\t"];
	[ret appendString: @"\n]"];

	[pool release];

	/*
	 * Class swizzle the string to be immutable. We declared the return type
	 * to be OFString*, so it can't be modified anyway. But not swizzling it
	 * would create a real copy each time -[copy] is called.
	 */
	ret->isa = [OFString class];
	return ret;
	return element;
}

- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state
			   objects: (id*)objects
			     count: (int)count_
{
	of_list_object_t **list_obj = (of_list_object_t**)state->extra;
	of_list_object_t **listObject = (of_list_object_t**)state->extra;

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

	if (state->state == 0) {
		*list_obj = firstListObject;
		*listObject = firstListObject;
		state->state = 1;
	}

	if (*list_obj == NULL)
	if (*listObject == NULL)
		return 0;

	objects[0] = (*list_obj)->object;
	*list_obj = (*list_obj)->next;
	objects[0] = (*listObject)->object;
	*listObject = (*listObject)->next;
	return 1;
}

- (OFEnumerator*)objectEnumerator
{
	return [[[OFListEnumerator alloc]
	        initWithList: self