ObjFW  Diff

Differences From Artifact [7c97ea2061]:

To Artifact [9be4537608]:


16
17
18
19
20
21
22
23
24
25


26
27
28
29
30
31
32
16
17
18
19
20
21
22

23
24
25
26
27
28
29
30
31
32
33







-


+
+








#include "config.h"

#import "OFSet.h"
#import "OFSet_hashtable.h"
#import "OFString.h"
#import "OFXMLElement.h"
#import "OFAutoreleasePool.h"

#import "OFNotImplementedException.h"

#import "autorelease.h"

static struct {
	Class isa;
} placeholder;

@interface OFSet_placeholder: OFSet
@end
257
258
259
260
261
262
263
264

265
266
267
268
269
270
271
272

273
274
275
276
277
278

279
280
281
282
283
284
285
286
287
288

289

290
291
292

293

294
295
296
297
298
299
300
301

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
393
394
395
258
259
260
261
262
263
264

265
266
267
268
269
270
271
272

273
274
275
276
277
278
279
280
281

282
283
284
285
286
287
288
289
290

291
292
293
294
295

296
297

298
299
300
301
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
393
394
395
396
397







-
+







-
+






+

-








+
-
+



+
-
+

-





-
+







-
+
















-
+





-
+




-
+






-
+





-
+




-
+






-
-
+













-

+
+


-
+



-
-
+
+

-
+







		return NO;

	return [otherSet isSubsetOfSet: self];
}

- (uint32_t)hash
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	void *pool = objc_autoreleasePoolPush();
	OFEnumerator *enumerator = [self objectEnumerator];
	id object;
	uint32_t hash = 0;

	while ((object = [enumerator nextObject]) != nil)
		hash += [object hash];

	[pool release];
	objc_autoreleasePoolPop(pool);

	return hash;
}

- (OFString*)description
{
	void *pool;
	OFMutableString *ret;
	OFAutoreleasePool *pool, *pool2;
	OFEnumerator *enumerator;
	size_t i, count = [self count];
	id object;

	if (count == 0)
		return @"{()}";

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

	pool = [[OFAutoreleasePool alloc] init];
	pool = objc_autoreleasePoolPush();
	enumerator = [self objectEnumerator];

	i = 0;
	while ((object = [enumerator nextObject]) != nil) {
	pool2 = [[OFAutoreleasePool alloc] init];
		void *pool2 = objc_autoreleasePoolPush();

	while ((object = [enumerator nextObject]) != nil) {
		[ret appendString: [object description]];

		if (++i < count)
			[ret appendString: @",\n"];

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

	[ret makeImmutable];

	[pool release];
	objc_autoreleasePoolPop(pool);

	return ret;
}

- copy
{
	return [self retain];
}

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

- (BOOL)isSubsetOfSet: (OFSet*)set
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	void *pool = objc_autoreleasePoolPush();
	OFEnumerator *enumerator = [self objectEnumerator];
	id object;

	while ((object = [enumerator nextObject]) != nil) {
		if (![set containsObject: object]) {
			[pool release];
			objc_autoreleasePoolPop(pool);
			return NO;
		}
	}

	[pool release];
	objc_autoreleasePoolPop(pool);

	return YES;
}

- (BOOL)intersectsSet: (OFSet*)set
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	void *pool = objc_autoreleasePoolPush();
	OFEnumerator *enumerator = [self objectEnumerator];
	id object;

	while ((object = [enumerator nextObject]) != nil) {
		if ([set containsObject: object]) {
			[pool release];
			objc_autoreleasePoolPop(pool);
			return YES;
		}
	}

	[pool release];
	objc_autoreleasePoolPop(pool);

	return NO;
}

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

	if ([self isKindOfClass: [OFMutableSet class]])
		element = [OFXMLElement elementWithName: @"OFMutableSet"
					      namespace: OF_SERIALIZATION_NS];
	else
		element = [OFXMLElement elementWithName: @"OFSet"
					      namespace: OF_SERIALIZATION_NS];

	enumerator = [self objectEnumerator];

	pool2 = [[OFAutoreleasePool alloc] init];
	while ((object = [enumerator nextObject]) != nil) {
		void *pool2 = objc_autoreleasePoolPush();

		[element addChild: [object XMLElementBySerializing]];

		[pool2 releaseObjects];
		objc_autoreleasePoolPop(pool2);
	}

	[element retain];
	[pool release];
	[element autorelease];

	objc_autoreleasePoolPop(pool);

	return element;
	return [element autorelease];
}

#if defined(OF_HAVE_BLOCKS) && defined(OF_HAVE_FAST_ENUMERATION)
- (void)enumerateObjectsUsingBlock: (of_set_enumeration_block_t)block
{
	BOOL stop = NO;