ObjFW  Diff

Differences From Artifact [4b8b632d36]:

To Artifact [59f7a05c14]:


118
119
120
121
122
123
124
125

126
127
128
129
130
131
132
118
119
120
121
122
123
124

125
126
127
128
129
130
131
132







-
+







			@throw e;
		}

		return self;
	}

	@try {
		count = [dictionary count];
		count = dictionary.count;
	} @catch (id e) {
		[self release];
		@throw e;
	}

	self = [self initWithCapacity: count];

252
253
254
255
256
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
252
253
254
255
256
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







-
+





-
+








-
-
-
-
+
+
+
+




-
-
+
+







		OFXMLElement *keyElement, *objectElement;

		keys = [element elementsForName: @"key"
				      namespace: OF_SERIALIZATION_NS];
		objects = [element elementsForName: @"object"
					 namespace: OF_SERIALIZATION_NS];

		if ([keys count] != [objects count])
		if (keys.count != objects.count)
			@throw [OFInvalidFormatException exception];

		_mapTable = [[OFMapTable alloc]
		    initWithKeyFunctions: keyFunctions
			 objectFunctions: objectFunctions
				capacity: [keys count]];
				capacity: keys.count];

		keyEnumerator = [keys objectEnumerator];
		objectEnumerator = [objects objectEnumerator];
		while ((keyElement = [keyEnumerator nextObject]) != nil &&
		    (objectElement = [objectEnumerator nextObject]) != nil) {
			void *pool2 = objc_autoreleasePoolPush();
			OFXMLElement *key, *object;

			key = [[keyElement elementsForNamespace:
			    OF_SERIALIZATION_NS] firstObject];
			object = [[objectElement elementsForNamespace:
			    OF_SERIALIZATION_NS] firstObject];
			key = [keyElement elementsForNamespace:
			    OF_SERIALIZATION_NS].firstObject;
			object = [objectElement elementsForNamespace:
			    OF_SERIALIZATION_NS].firstObject;

			if (key == nil || object == nil)
				@throw [OFInvalidFormatException exception];

			[_mapTable setObject: [object objectByDeserializing]
				      forKey: [key objectByDeserializing]];
			[_mapTable setObject: object.objectByDeserializing
				      forKey: key.objectByDeserializing];

			objc_autoreleasePoolPop(pool2);
		}

		objc_autoreleasePoolPop(pool);
	} @catch (id e) {
		[self release];
304
305
306
307
308
309
310
311

312
313
314
315
316
317
318
304
305
306
307
308
309
310

311
312
313
314
315
316
317
318







-
+







- (id)objectForKey: (id)key
{
	return [_mapTable objectForKey: key];
}

- (size_t)count
{
	return [_mapTable count];
	return _mapTable.count;
}

- (bool)isEqual: (id)object
{
	OFDictionary_hashtable *dictionary;

	if (object == self)
339
340
341
342
343
344
345
346

347
348
349
350
351
352
353
339
340
341
342
343
344
345

346
347
348
349
350
351
352
353







-
+








- (OFArray *)allKeys
{
	OFArray *ret;
	id *keys;
	size_t count;

	count = [_mapTable count];
	count = _mapTable.count;
	keys = [self allocMemoryWithSize: sizeof(*keys)
				   count: count];

	@try {
		void *pool = objc_autoreleasePoolPush();
		OFMapTableEnumerator *enumerator;
		void **keyPtr;
374
375
376
377
378
379
380
381

382
383
384
385
386
387
388
374
375
376
377
378
379
380

381
382
383
384
385
386
387
388







-
+








- (OFArray *)allObjects
{
	OFArray *ret;
	id *objects;
	size_t count;

	count = [_mapTable count];
	count = _mapTable.count;
	objects = [self allocMemoryWithSize: sizeof(*objects)
				      count: count];

	@try {
		void *pool = objc_autoreleasePoolPush();
		OFMapTableEnumerator *enumerator;
		void **objectPtr;
444
445
446
447
448
449
450
451

452
453
444
445
446
447
448
449
450

451
452
453







-
+


		    exceptionWithObject: self];
	}
}
#endif

- (uint32_t)hash
{
	return [_mapTable hash];
	return _mapTable.hash;
}
@end