ObjFW  Diff

Differences From Artifact [b830cfbb1d]:

To Artifact [7ea4c5f34b]:


9
10
11
12
13
14
15

16
17
18
19
20
21
22
 * the packaging of this file.
 */

#include "config.h"

#import "OFNumber.h"
#import "OFExceptions.h"


#define RETURN_AS(t)							\
	switch (type) {							\
	case OF_NUMBER_CHAR:						\
		return (t)value.char_;					\
	case OF_NUMBER_SHORT:						\
		return (t)value.short_;					\







>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 * the packaging of this file.
 */

#include "config.h"

#import "OFNumber.h"
#import "OFExceptions.h"
#import "macros.h"

#define RETURN_AS(t)							\
	switch (type) {							\
	case OF_NUMBER_CHAR:						\
		return (t)value.char_;					\
	case OF_NUMBER_SHORT:						\
		return (t)value.short_;					\
754
755
756
757
758
759
760



















761

762
763
764
765
766
767
768
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
	}
}

- (uint32_t)hash
{



















	return [self asUInt32];

}

- add: (OFNumber*)num
{
	CALCULATE2(+=, num)
	return self;
}







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>







755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
	}
}

- (uint32_t)hash
{
	uint32_t hash;
	size_t i;

	switch (type) {
	case OF_NUMBER_FLOAT:
		OF_HASH_INIT(hash);
		for (i = 0; i < sizeof(float); i++)
			OF_HASH_ADD(hash, ((char*)&value.float_)[i]);
		OF_HASH_FINALIZE(hash);

		return hash;
	case OF_NUMBER_DOUBLE:
		OF_HASH_INIT(hash);
		for (i = 0; i < sizeof(double); i++)
			OF_HASH_ADD(hash, ((char*)&value.double_)[i]);
		OF_HASH_FINALIZE(hash);

		return hash;
	default:
		return [self asUInt32];
	}
}

- add: (OFNumber*)num
{
	CALCULATE2(+=, num)
	return self;
}