ObjFW  Diff

Differences From Artifact [bbacfd711b]:

To Artifact [7df4d449e0]:


36
37
38
39
40
41
42







43
44
45
46
47
48
49

+ dictionaryWithKey: (OFObject <OFCopying>*)key
	  andObject: (OFObject*)obj
{
	return [[[self alloc] initWithKey: key
				andObject: obj] autorelease];
}








+ dictionaryWithKeysAndObjects: (OFObject <OFCopying>*)first, ...
{
	id ret;
	va_list args;

	va_start(args, first);







>
>
>
>
>
>
>







36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56

+ dictionaryWithKey: (OFObject <OFCopying>*)key
	  andObject: (OFObject*)obj
{
	return [[[self alloc] initWithKey: key
				andObject: obj] autorelease];
}

+ dictionaryWithKeys: (OFArray*)keys
	  andObjects: (OFArray*)objs
{
	return [[[self alloc] initWithKeys: keys
				andObjects: objs] autorelease];
}

+ dictionaryWithKeysAndObjects: (OFObject <OFCopying>*)first, ...
{
	id ret;
	va_list args;

	va_start(args, first);
141
142
143
144
145
146
147


























































148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164

165
166
167
168
169
170
171
172
173
174
175
176
177
		@throw e;
	} @finally {
		[key release];
	}

	return self;
}



























































- initWithKeysAndObjects: (OFObject <OFCopying>*)first, ...
{
	id ret;
	va_list args;

	va_start(args, first);
	ret = [self initWithKey: first
		     andArgList: args];
	va_end(args);

	return ret;
}

- initWithKey: (OFObject <OFCopying>*)first
   andArgList: (va_list)args
{

	id key, obj;
	Class c;
	uint32_t hash;

	self = [self init];
	obj = va_arg(args, id);

	if (first == nil || obj == nil) {
		c = isa;
		[self dealloc];
		@throw [OFInvalidArgumentException newWithClass: isa
						    andSelector: _cmd];
	}







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

















>
|




|







148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
		@throw e;
	} @finally {
		[key release];
	}

	return self;
}

- initWithKeys: (OFArray*)keys
    andObjects: (OFArray*)objs
{
	Class c;
	OFObject <OFCopying> **keys_data;
	OFObject **objs_data;
	size_t count, i;

	self = [self init];
	count = [keys count];

	if (keys == nil || objs == nil || count != [objs count]) {
		c = isa;
		[self dealloc];
		@throw [OFInvalidArgumentException newWithClass: isa
						    andSelector: _cmd];
	}

	keys_data = [keys data];
	objs_data = [objs data];

	for (i = 0; i < count; i++) {
		uint32_t hash;
		OFObject <OFCopying> *key;

		if (keys_data[i] == nil || objs_data[i] == nil) {
			c = isa;
			[self dealloc];
			@throw [OFInvalidArgumentException newWithClass: isa
							    andSelector: _cmd];
		}

		hash = [keys_data[i] hash] & (size - 1);

		@try {
			key = [keys_data[i] copy];
		} @catch (OFException *e) {
			[self dealloc];
			@throw e;
		}

		@try {
			if (data[hash] == nil)
				data[hash] = [[OFList alloc] init];

			[data[hash] append: key];
			[data[hash] append: objs_data[i]];
		} @catch (OFException *e) {
			[self dealloc];
			@throw e;
		} @finally {
			[key release];
		}
	}

	return self;
}

- initWithKeysAndObjects: (OFObject <OFCopying>*)first, ...
{
	id ret;
	va_list args;

	va_start(args, first);
	ret = [self initWithKey: first
		     andArgList: args];
	va_end(args);

	return ret;
}

- initWithKey: (OFObject <OFCopying>*)first
   andArgList: (va_list)args
{
	OFObject <OFCopying> *key;
	OFObject *obj;
	Class c;
	uint32_t hash;

	self = [self init];
	obj = va_arg(args, OFObject*);

	if (first == nil || obj == nil) {
		c = isa;
		[self dealloc];
		@throw [OFInvalidArgumentException newWithClass: isa
						    andSelector: _cmd];
	}
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
	} @catch (OFException *e) {
		[self dealloc];
		@throw e;
	} @finally {
		[key release];
	}

	while ((key = va_arg(args, id)) != nil) {
		if ((obj = va_arg(args, id)) == nil) {
			c = isa;
			[self dealloc];
			@throw [OFInvalidArgumentException newWithClass: isa
							    andSelector: _cmd];
		}

		hash = [key hash] & (size - 1);







|
|







260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
	} @catch (OFException *e) {
		[self dealloc];
		@throw e;
	} @finally {
		[key release];
	}

	while ((key = va_arg(args, OFObject <OFCopying>*)) != nil) {
		if ((obj = va_arg(args, OFObject*)) == nil) {
			c = isa;
			[self dealloc];
			@throw [OFInvalidArgumentException newWithClass: isa
							    andSelector: _cmd];
		}

		hash = [key hash] & (size - 1);