ObjFW  Diff

Differences From Artifact [69df15df8e]:

To Artifact [af933f0dd2]:


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

struct of_dictionary_bucket of_dictionary_deleted_bucket = {};

#define BUCKET struct of_dictionary_bucket
#define DELETED &of_dictionary_deleted_bucket

@implementation OFDictionary
+ dictionary;
{
	return [[[self alloc] init] autorelease];
}

+ dictionaryWithDictionary: (OFDictionary*)dict
{
	return [[[self alloc] initWithDictionary: dict] autorelease];







|







32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

struct of_dictionary_bucket of_dictionary_deleted_bucket = {};

#define BUCKET struct of_dictionary_bucket
#define DELETED &of_dictionary_deleted_bucket

@implementation OFDictionary
+ dictionary
{
	return [[[self alloc] init] autorelease];
}

+ dictionaryWithDictionary: (OFDictionary*)dict
{
	return [[[self alloc] initWithDictionary: dict] autorelease];
144
145
146
147
148
149
150




151
152
153
154
155
156
157
	  forKey: (id <OFCopying>)key
{
	self = [super init];

	@try {
		uint32_t i;
		BUCKET *b;





		data = [self allocMemoryForNItems: 2
					 withSize: sizeof(BUCKET*)];

		size = 2;
		for (i = 0; i < size; i++)
			data[i] = NULL;







>
>
>
>







144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
	  forKey: (id <OFCopying>)key
{
	self = [super init];

	@try {
		uint32_t i;
		BUCKET *b;

		if (key == nil || obj == nil)
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];

		data = [self allocMemoryForNItems: 2
					 withSize: sizeof(BUCKET*)];

		size = 2;
		for (i = 0; i < size; i++)
			data[i] = NULL;
451
452
453
454
455
456
457

458
459
460
461
462
463
464
				[data[j]->object release];
			} @catch (id e) {
				[obj release];
				@throw e;
			}

			data[j]->object = obj;

		}
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;







>







455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
				[data[j]->object release];
			} @catch (id e) {
				[obj release];
				@throw e;
			}

			data[j]->object = obj;
			count--;
		}
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
701
702
703
704
705
706
707
708
709
710

711
712
713








714
715
716

717
718
719
720
721
722
723
724
725
726
727
	OF_HASH_FINALIZE(hash);

	return hash;
}

- (OFString*)description
{
	OFMutableString *ret = [OFMutableString stringWithString: @"{\n"];
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init], *pool2;
	OFEnumerator *enumerator = [self keyEnumerator];

	id key;
	size_t i;









	i = 0;
	pool2 = [[OFAutoreleasePool alloc] init];


	while ((key = [enumerator nextObject]) != nil) {
		[ret appendString: [key description]];
		[ret appendString: @" = "];
		[ret appendString: [[self objectForKey: key] description]];

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

		[pool2 releaseObjects];
	}
	[ret replaceOccurrencesOfString: @"\n"







|
|
|
>
|


>
>
>
>
>
>
>
>



>
|


|







706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
	OF_HASH_FINALIZE(hash);

	return hash;
}

- (OFString*)description
{
	OFMutableString *ret;
	OFAutoreleasePool *pool, *pool2;
	OFEnumerator *keyEnumerator;
	OFEnumerator *objectEnumerator;
	id key, object;
	size_t i;

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

	ret = [OFMutableString stringWithString: @"{\n"];
	pool = [[OFAutoreleasePool alloc] init];
	keyEnumerator = [self keyEnumerator];
	objectEnumerator = [self objectEnumerator];

	i = 0;
	pool2 = [[OFAutoreleasePool alloc] init];

	while ((key = [keyEnumerator nextObject]) != nil &&
	    (object = [objectEnumerator nextObject]) != nil) {
		[ret appendString: [key description]];
		[ret appendString: @" = "];
		[ret appendString: [object description]];

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

		[pool2 releaseObjects];
	}
	[ret replaceOccurrencesOfString: @"\n"