ObjFW  Diff

Differences From Artifact [564495dad9]:

To Artifact [931ec5d215]:


16
17
18
19
20
21
22

23
24
25
26
27
28
29

#include "config.h"

#import "OFCountedSet.h"
#import "OFCountedSet_hashtable.h"
#import "OFNumber.h"
#import "OFString.h"

#import "OFAutoreleasePool.h"

#import "OFNotImplementedException.h"

static struct {
	Class isa;
} placeholder;







>







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

#include "config.h"

#import "OFCountedSet.h"
#import "OFCountedSet_hashtable.h"
#import "OFNumber.h"
#import "OFString.h"
#import "OFXMLElement.h"
#import "OFAutoreleasePool.h"

#import "OFNotImplementedException.h"

static struct {
	Class isa;
} placeholder;
59
60
61
62
63
64
65





66
67
68
69
70
71
72

- initWithObject: (id)firstObject
       arguments: (va_list)arguments
{
	return [[OFCountedSet_hashtable alloc] initWithObject: firstObject
						    arguments: arguments];
}






- retain
{
	return self;
}

- autorelease







>
>
>
>
>







60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78

- initWithObject: (id)firstObject
       arguments: (va_list)arguments
{
	return [[OFCountedSet_hashtable alloc] initWithObject: firstObject
						    arguments: arguments];
}

- initWithSerialization: (OFXMLElement*)element
{
	return [[OFCountedSet_hashtable alloc] initWithSerialization: element];
}

- retain
{
	return self;
}

- autorelease
162
163
164
165
166
167
168











































169
170
171
172
173
174
175
	return [[OFCountedSet alloc] initWithSet: self];
}

- mutableCopy
{
	return [[OFCountedSet alloc] initWithSet: self];
}












































#ifdef OF_HAVE_BLOCKS
- (void)enumerateObjectsAndCountUsingBlock:
    (of_counted_set_enumeration_block_t)block
{
	[self enumerateObjectsUsingBlock: ^ (id object, BOOL *stop) {
		block(object, [self countForObject: object], stop);







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
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
	return [[OFCountedSet alloc] initWithSet: self];
}

- mutableCopy
{
	return [[OFCountedSet alloc] initWithSet: self];
}

- (OFXMLElement*)XMLElementBySerializing
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFAutoreleasePool *pool2;
	OFXMLElement *element;
	OFEnumerator *enumerator;
	id <OFSerialization> object;

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

	enumerator = [self objectEnumerator];

	pool2 = [[OFAutoreleasePool alloc] init];
	while ((object = [enumerator nextObject]) != nil) {
		OFXMLElement *objectElement;
		OFString *count;

		count =
		    [OFString stringWithFormat: @"%zu",
						[self countForObject: object]];

		objectElement = [OFXMLElement
		    elementWithName: @"object"
			  namespace: OF_SERIALIZATION_NS];
		[objectElement addAttributeWithName: @"count"
					stringValue: count];
		[objectElement addChild: [object XMLElementBySerializing]];
		[element addChild: objectElement];

		[pool2 releaseObjects];
	}

	[element retain];
	@try {
		[pool release];
	} @finally {
		[element autorelease];
	}

	return element;
}

#ifdef OF_HAVE_BLOCKS
- (void)enumerateObjectsAndCountUsingBlock:
    (of_counted_set_enumeration_block_t)block
{
	[self enumerateObjectsUsingBlock: ^ (id object, BOOL *stop) {
		block(object, [self countForObject: object], stop);