ObjFW  Diff

Differences From Artifact [27e6d4b43c]:

To Artifact [a3dd281791]:


56
57
58
59
60
61
62
63

64
65
66
67
68
69
70

71
72
73
74
75
76
77
78
56
57
58
59
60
61
62

63

64
65
66
67
68

69

70
71
72
73
74
75
76







-
+
-





-
+
-







	ret = [[OFMapTableSet alloc] initWithObject: firstObject
					  arguments: arguments];
	va_end(arguments);

	return ret;
}

- (instancetype)initWithObjects: (id const *)objects
- (instancetype)initWithObjects: (id const *)objects count: (size_t)count
			  count: (size_t)count
{
	return (id)[[OFMapTableSet alloc] initWithObjects: objects
						    count: count];
}

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

- (instancetype)initWithSerialization: (OFXMLElement *)element
{
138
139
140
141
142
143
144
145

146
147
148
149
150
151
152
153
136
137
138
139
140
141
142

143

144
145
146
147
148
149
150







-
+
-







	ret = [[[self alloc] initWithObject: firstObject
				  arguments: arguments] autorelease];
	va_end(arguments);

	return ret;
}

+ (instancetype)setWithObjects: (id const *)objects
+ (instancetype)setWithObjects: (id const *)objects count: (size_t)count
			 count: (size_t)count
{
	return [[[self alloc] initWithObjects: objects
					count: count] autorelease];
}

- (instancetype)init
{
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
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







-
+
-










-
+
-





-
+
-







}

- (instancetype)initWithArray: (OFArray *)array
{
	OF_INVALID_INIT_METHOD
}

- (instancetype)initWithObjects: (id const *)objects
- (instancetype)initWithObjects: (id const *)objects count: (size_t)count
			  count: (size_t)count
{
	OF_INVALID_INIT_METHOD
}

- (instancetype)initWithObjects: (id)firstObject, ...
{
	id ret;
	va_list arguments;

	va_start(arguments, firstObject);
	ret = [self initWithObject: firstObject
	ret = [self initWithObject: firstObject arguments: arguments];
			 arguments: arguments];
	va_end(arguments);

	return ret;
}

- (instancetype)initWithObject: (id)firstObject
- (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments
		     arguments: (va_list)arguments
{
	OF_INVALID_INIT_METHOD
}

- (instancetype)initWithSerialization: (OFXMLElement *)element
{
	OF_INVALID_INIT_METHOD
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
259
221
222
223
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







-
+
-


-
+
-












-
+







	}

	[ret makeImmutable];

	return ret;
}

- (void)setValue: (id)value
- (void)setValue: (id)value forKey: (OFString *)key
	  forKey: (OFString *)key
{
	for (id object in self)
		[object setValue: value
		[object setValue: value forKey: key];
			  forKey: key];
}

- (bool)containsObject: (id)object
{
	OF_UNRECOGNIZED_SELECTOR
}

- (OFEnumerator *)objectEnumerator
{
	OF_UNRECOGNIZED_SELECTOR
}

- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t *)state
- (int)countByEnumeratingWithState: (OFFastEnumerationState *)state
			   objects: (id *)objects
			     count: (int)count
{
	OFEnumerator *enumerator;
	int i;

	memcpy(&enumerator, state->extra, sizeof(enumerator));
329
330
331
332
333
334
335
336

337
338
339
340
341
342
343
344
345
346
321
322
323
324
325
326
327

328

329

330
331
332
333
334
335
336







-
+
-

-







		[ret appendString: [object description]];

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

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

	[ret makeImmutable];

	objc_autoreleasePoolPop(pool);

	return ret;
}

375
376
377
378
379
380
381
382

383
384
385

386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406

407
408
409
410
411
412
413
414
415
416
417
418

419
420
421
422
423
424
425
426
427
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
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
398
399



400
401

402

403
404
405
406
407



408
409

410

411
412
413
414
415
416
417
418

419
420
421
422
423
424
425
426

427
428
429
430

431
432
433
434
435
436
437
438
439
440
441
442

443
444
445
446
447
448
449
450







-
+


-
+



-

-












-
-
-
+

-

-





-
-
-
+

-

-





-
-
-
+

-

-








-








-




-
+











-
+







- (OFXMLElement *)XMLElementBySerializing
{
	void *pool = objc_autoreleasePoolPush();
	OFXMLElement *element;

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

	for (id <OFSerialization> object in self) {
		void *pool2 = objc_autoreleasePoolPush();

		[element addChild: object.XMLElementBySerializing];

		objc_autoreleasePoolPop(pool2);
	}

	[element retain];

	objc_autoreleasePoolPop(pool);

	return [element autorelease];
}

- (OFSet *)setBySubtractingSet: (OFSet *)set
{
	OFMutableSet *new;

	new = [[self mutableCopy] autorelease];
	OFMutableSet *new = [[self mutableCopy] autorelease];
	[new minusSet: set];

	[new makeImmutable];

	return new;
}

- (OFSet *)setByIntersectingWithSet: (OFSet *)set
{
	OFMutableSet *new;

	new = [[self mutableCopy] autorelease];
	OFMutableSet *new = [[self mutableCopy] autorelease];
	[new intersectSet: set];

	[new makeImmutable];

	return new;
}

- (OFSet *)setByAddingSet: (OFSet *)set
{
	OFMutableSet *new;

	new = [[self mutableCopy] autorelease];
	OFMutableSet *new = [[self mutableCopy] autorelease];
	[new unionSet: set];

	[new makeImmutable];

	return new;
}

- (OFArray *)allObjects
{
	void *pool = objc_autoreleasePoolPush();
	OFArray *ret = [[[self objectEnumerator] allObjects] retain];
	objc_autoreleasePoolPop(pool);

	return [ret autorelease];
}

- (id)anyObject
{
	void *pool = objc_autoreleasePoolPush();
	id ret = [[[self objectEnumerator] nextObject] retain];
	objc_autoreleasePoolPop(pool);

	return [ret autorelease];
}

#ifdef OF_HAVE_BLOCKS
- (void)enumerateObjectsUsingBlock: (of_set_enumeration_block_t)block
- (void)enumerateObjectsUsingBlock: (OFSetEnumerationBlock)block
{
	bool stop = false;

	for (id object in self) {
		block(object, &stop);

		if (stop)
			break;
	}
}

- (OFSet *)filteredSetUsingBlock: (of_set_filter_block_t)block
- (OFSet *)filteredSetUsingBlock: (OFSetFilterBlock)block
{
	OFMutableSet *ret = [OFMutableSet set];

	[self enumerateObjectsUsingBlock: ^ (id object, bool *stop) {
		if (block(object))
			[ret addObject: object];
	}];