ObjFW  Diff

Differences From Artifact [40c18091bb]:

To Artifact [7df94bcaeb]:


17
18
19
20
21
22
23

24
25
26
27
28
29
30
#include "config.h"

#include <stdarg.h>

#import "OFArray.h"
#import "OFDataArray.h"
#import "OFString.h"

#import "OFAutoreleasePool.h"

#import "OFEnumerationMutationException.h"
#import "OFOutOfRangeException.h"

#import "macros.h"








>







17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "config.h"

#include <stdarg.h>

#import "OFArray.h"
#import "OFDataArray.h"
#import "OFString.h"
#import "OFXMLElement.h"
#import "OFAutoreleasePool.h"

#import "OFEnumerationMutationException.h"
#import "OFOutOfRangeException.h"

#import "macros.h"

428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456


457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
	 * 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
{
	OFAutoreleasePool *pool;
	OFMutableString *ret;
	OFObject <OFSerialization> **cArray;
	size_t i, count;

	if ([array count] == 0) {
		if ([self isKindOfClass: [OFMutableArray class]])
			return @"(mutable,0)[]";
		else
			return @"(0)[]";
	}

	cArray = [array cArray];
	count = [array count];
	if ([self isKindOfClass: [OFMutableArray class]])
		ret = [OFMutableString stringWithFormat: @"(mutable,%zd)[\n",
							 count];
	else
		ret = [OFMutableString stringWithFormat: @"(%zd)[\n", count];
	pool = [[OFAutoreleasePool alloc] init];



	for (i = 0; i < count - 1; i++) {
		[ret appendString: [cArray[i] stringBySerializing]];
		[ret appendString: @",\n"];

		[pool releaseObjects];
	}
	[ret appendString: [cArray[i] stringBySerializing]];
	[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;
}

- (void)makeObjectsPerformSelector: (SEL)selector
{
	id *cArray = [array cArray];
	size_t i, count = [array count];








|


|
|
|

|
|
<
<
<
|
<
<
<
<
<
<
<
<

>
>

|
<
<
|


<
<
<
<



<
<
<
<
<
<
|







429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444



445








446
447
448
449
450


451
452
453




454
455
456






457
458
459
460
461
462
463
464
	 * 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;
}

- (OFXMLElement*)XMLElementBySerializing
{
	OFAutoreleasePool *pool;
	OFXMLElement *element;
	id <OFSerialization> *cArray = [array cArray];
	size_t i, count = [array count];

	element = [OFXMLElement elementWithName: @"object"
				      namespace: OF_SERIALIZATION_NS];












	pool = [[OFAutoreleasePool alloc] init];
	[element addAttributeWithName: @"class"
			  stringValue: [self className]];

	for (i = 0; i < count; i++) {


		[element addChild: [cArray[i] XMLElementBySerializing]];
		[pool releaseObjects];
	}





	[pool release];







	return element;
}

- (void)makeObjectsPerformSelector: (SEL)selector
{
	id *cArray = [array cArray];
	size_t i, count = [array count];