ObjFW  Check-in [871fcf6e0b]

Overview
Comment:Add OF_HASH_ADD_INT{16,32,64}.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 871fcf6e0bb43b66d824f93d205fc90395820ea70ca27f62db71644edee4fe17
User & Date: js on 2011-06-04 16:02:44
Other Links: manifest | tags
Context
2011-06-04
16:07
Add -[hash] to OFXMLElement and OFXMLAttribute. check-in: a698b98203 user: js tags: trunk
16:02
Add OF_HASH_ADD_INT{16,32,64}. check-in: 871fcf6e0b user: js tags: trunk
15:40
Add -[hash] to OFDate, as it is required if there's -[isEqual:]. check-in: eee0aa1848 user: js tags: trunk
Changes

Modified src/OFDate.m from [23de019f51] to [9790497193].

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

- (uint32_t)hash
{
	uint32_t hash;

	OF_HASH_INIT(hash);

	OF_HASH_ADD(hash, (seconds >> 56) & 0xFF);
	OF_HASH_ADD(hash, (seconds >> 48) & 0xFF);
	OF_HASH_ADD(hash, (seconds >> 40) & 0xFF);
	OF_HASH_ADD(hash, (seconds >> 32) & 0xFF);
	OF_HASH_ADD(hash, (seconds >> 24) & 0xFF);
	OF_HASH_ADD(hash, (seconds >> 16) & 0xFF);
	OF_HASH_ADD(hash, (seconds >> 8) & 0xFF);
	OF_HASH_ADD(hash, seconds & 0xFF);

	OF_HASH_ADD(hash, (microseconds >> 24) & 0xFF);
	OF_HASH_ADD(hash, (microseconds >> 16) & 0xFF);
	OF_HASH_ADD(hash, (microseconds >> 8) & 0xFF);
	OF_HASH_ADD(hash, microseconds & 0xFF);

	OF_HASH_FINALIZE(hash);

	return hash;
}

- copy







<
<
<
<
<
<
<
|
<
<
<
<
|







300
301
302
303
304
305
306







307




308
309
310
311
312
313
314
315

- (uint32_t)hash
{
	uint32_t hash;

	OF_HASH_INIT(hash);








	OF_HASH_ADD_INT64(hash, seconds);




	OF_HASH_ADD_INT32(hash, microseconds);

	OF_HASH_FINALIZE(hash);

	return hash;
}

- copy

Modified src/OFURL.m from [72e6419d11] to [7b484f195b].

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48

#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFOutOfMemoryException.h"

#import "macros.h"

#define ADD_STR_HASH(str)			\
	tmp = [str hash];			\
	OF_HASH_ADD(hash, tmp >> 24);		\
	OF_HASH_ADD(hash, (tmp >> 16) & 0xFF);	\
	OF_HASH_ADD(hash, (tmp >> 8) & 0xFF);	\
	OF_HASH_ADD(hash, tmp & 0xFF);

static OF_INLINE OFString*
resolve_relative_path(OFString *path)
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFMutableArray *array;
	OFString *ret;
	BOOL done = NO;







<
<
<
<
<
<
<







28
29
30
31
32
33
34







35
36
37
38
39
40
41

#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFOutOfMemoryException.h"

#import "macros.h"








static OF_INLINE OFString*
resolve_relative_path(OFString *path)
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFMutableArray *array;
	OFString *ret;
	BOOL done = NO;
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
		return NO;

	return YES;
}

- (uint32_t)hash
{
	uint32_t hash, tmp;

	OF_HASH_INIT(hash);

	ADD_STR_HASH(scheme);
	ADD_STR_HASH(host);

	OF_HASH_ADD(hash, (port >> 8) & 0xFF);
	OF_HASH_ADD(hash, port & 0xFF);

	ADD_STR_HASH(user);
	ADD_STR_HASH(password);
	ADD_STR_HASH(path);
	ADD_STR_HASH(parameters);
	ADD_STR_HASH(query);
	ADD_STR_HASH(fragment);

	OF_HASH_FINALIZE(hash);

	return hash;
}

- copy







|



<
<
|
|
|
|
<
|
|
|
|
|







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
		return NO;

	return YES;
}

- (uint32_t)hash
{
	uint32_t hash;

	OF_HASH_INIT(hash);



	OF_HASH_ADD_INT32(hash, [scheme hash]);
	OF_HASH_ADD_INT32(hash, [host hash]);
	OF_HASH_ADD_INT16(hash, port);
	OF_HASH_ADD_INT32(hash, [user hash]);

	OF_HASH_ADD_INT32(hash, [password hash]);
	OF_HASH_ADD_INT32(hash, [path hash]);
	OF_HASH_ADD_INT32(hash, [parameters hash]);
	OF_HASH_ADD_INT32(hash, [query hash]);
	OF_HASH_ADD_INT32(hash, [fragment hash]);

	OF_HASH_FINALIZE(hash);

	return hash;
}

- copy

Modified src/macros.h from [d5e29a8d9f] to [93351baa39].

246
247
248
249
250
251
252
253


























		hash ^= (hash >> 6);	\
	}
#define OF_HASH_FINALIZE(hash)		\
	{				\
		hash += (hash << 3);	\
		hash ^= (hash >> 11);	\
		hash += (hash << 15);	\
	}


































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
246
247
248
249
250
251
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
		hash ^= (hash >> 6);	\
	}
#define OF_HASH_FINALIZE(hash)		\
	{				\
		hash += (hash << 3);	\
		hash ^= (hash >> 11);	\
		hash += (hash << 15);	\
	}
#define OF_HASH_ADD_INT16(hash, int16)			\
	{						\
		uint16_t int16Copy = int16;		\
		OF_HASH_ADD(hash, int16Copy >> 8);	\
		OF_HASH_ADD(hash, int16Copy & 0xFF);	\
	}
#define OF_HASH_ADD_INT32(hash, int32)				\
	{							\
		uint32_t int32Copy = int32;			\
		OF_HASH_ADD(hash, (int32Copy >> 24) & 0xFF);	\
		OF_HASH_ADD(hash, (int32Copy >> 16) & 0xFF);	\
		OF_HASH_ADD(hash, (int32Copy >>  8) & 0xFF);	\
		OF_HASH_ADD(hash, int32Copy & 0xFF);		\
	}
#define OF_HASH_ADD_INT64(hash, int64)				\
	{							\
		uint64_t int64Copy = int64;			\
		OF_HASH_ADD(hash, (int64Copy >> 56) & 0xFF);	\
		OF_HASH_ADD(hash, (int64Copy >> 48) & 0xFF);	\
		OF_HASH_ADD(hash, (int64Copy >> 40) & 0xFF);	\
		OF_HASH_ADD(hash, (int64Copy >> 32) & 0xFF);	\
		OF_HASH_ADD(hash, (int64Copy >> 24) & 0xFF);	\
		OF_HASH_ADD(hash, (int64Copy >> 16) & 0xFF);	\
		OF_HASH_ADD(hash, (int64Copy >>  8) & 0xFF);	\
		OF_HASH_ADD(hash, int64Copy & 0xFF);		\
	}