ObjFW  Diff

Differences From Artifact [b19ce3cb16]:

To Artifact [8e480899d7]:


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
 */

#import "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_;					      \
	case OF_NUMBER_INT:						      \
		return (t)value.int_;					      \
	case OF_NUMBER_LONG:						      \
		return (t)value.long_;					      \
	case OF_NUMBER_UCHAR:						      \
		return (t)value.uchar;					      \
	case OF_NUMBER_USHORT:						      \
		return (t)value.ushort;					      \
	case OF_NUMBER_UINT:						      \
		return (t)value.uint;					      \
	case OF_NUMBER_ULONG:						      \
		return (t)value.ulong;					      \
	case OF_NUMBER_INT8:						      \
		return (t)value.int8;					      \
	case OF_NUMBER_INT16:						      \
		return (t)value.int16;					      \
	case OF_NUMBER_INT32:						      \
		return (t)value.int32;					      \
	case OF_NUMBER_INT64:						      \
		return (t)value.int64;					      \
	case OF_NUMBER_UINT8:						      \
		return (t)value.uint8;					      \
	case OF_NUMBER_UINT16:						      \
		return (t)value.uint16;					      \
	case OF_NUMBER_UINT32:						      \
		return (t)value.uint32;					      \
	case OF_NUMBER_UINT64:						      \
		return (t)value.uint64;					      \
	case OF_NUMBER_SIZE:						      \
		return (t)value.size;					      \
	case OF_NUMBER_SSIZE:						      \
		return (t)value.ssize;					      \
	case OF_NUMBER_INTMAX:						      \
		return (t)value.intmax;					      \
	case OF_NUMBER_UINTMAX:						      \
		return (t)value.uintmax;				      \
	case OF_NUMBER_PTRDIFF:						      \
		return (t)value.ptrdiff;				      \
	case OF_NUMBER_INTPTR:						      \
		return (t)value.intptr;					      \
	case OF_NUMBER_FLOAT:						      \
		return (t)value.float_;					      \
	case OF_NUMBER_DOUBLE:						      \
		return (t)value.double_;				      \
	case OF_NUMBER_LONG_DOUBLE:					      \
		return (t)value.longdouble;				      \
	default:							      \
		@throw [OFInvalidFormatException newWithClass: [self class]]; \
									      \
		/* Make gcc happy */					      \
		return 0;						      \
	}

@implementation OFNumber
+ numberWithChar: (char)char_
{
	return [[[OFNumber alloc] initWithChar: char_] autorelease];
}







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







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70

71

72
73
74
75
76
77
78
 */

#import "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_;					\
	case OF_NUMBER_INT:						\
		return (t)value.int_;					\
	case OF_NUMBER_LONG:						\
		return (t)value.long_;					\
	case OF_NUMBER_UCHAR:						\
		return (t)value.uchar;					\
	case OF_NUMBER_USHORT:						\
		return (t)value.ushort;					\
	case OF_NUMBER_UINT:						\
		return (t)value.uint;					\
	case OF_NUMBER_ULONG:						\
		return (t)value.ulong;					\
	case OF_NUMBER_INT8:						\
		return (t)value.int8;					\
	case OF_NUMBER_INT16:						\
		return (t)value.int16;					\
	case OF_NUMBER_INT32:						\
		return (t)value.int32;					\
	case OF_NUMBER_INT64:						\
		return (t)value.int64;					\
	case OF_NUMBER_UINT8:						\
		return (t)value.uint8;					\
	case OF_NUMBER_UINT16:						\
		return (t)value.uint16;					\
	case OF_NUMBER_UINT32:						\
		return (t)value.uint32;					\
	case OF_NUMBER_UINT64:						\
		return (t)value.uint64;					\
	case OF_NUMBER_SIZE:						\
		return (t)value.size;					\
	case OF_NUMBER_SSIZE:						\
		return (t)value.ssize;					\
	case OF_NUMBER_INTMAX:						\
		return (t)value.intmax;					\
	case OF_NUMBER_UINTMAX:						\
		return (t)value.uintmax;				\
	case OF_NUMBER_PTRDIFF:						\
		return (t)value.ptrdiff;				\
	case OF_NUMBER_INTPTR:						\
		return (t)value.intptr;					\
	case OF_NUMBER_FLOAT:						\
		return (t)value.float_;					\
	case OF_NUMBER_DOUBLE:						\
		return (t)value.double_;				\
	case OF_NUMBER_LONG_DOUBLE:					\
		return (t)value.longdouble;				\
	default:							\
		@throw [OFInvalidFormatException newWithClass: isa];	\

		return 0;	/* Make gcc happy */			\

	}

@implementation OFNumber
+ numberWithChar: (char)char_
{
	return [[[OFNumber alloc] initWithChar: char_] autorelease];
}
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
	case OF_NUMBER_INTPTR:
		return ([obj asUIntMax] == [self asUIntMax] ? YES : NO);
	case OF_NUMBER_FLOAT:
	case OF_NUMBER_DOUBLE:
	case OF_NUMBER_LONG_DOUBLE:
		return ([obj asLongDouble] == [self asLongDouble] ? YES : NO);
	default:
		@throw [OFInvalidArgumentException newWithClass: [self class]
						    andSelector: _cmd];
	}
}

- (uint32_t)hash
{
	return [self asUInt32];
}
@end







|









608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
	case OF_NUMBER_INTPTR:
		return ([obj asUIntMax] == [self asUIntMax] ? YES : NO);
	case OF_NUMBER_FLOAT:
	case OF_NUMBER_DOUBLE:
	case OF_NUMBER_LONG_DOUBLE:
		return ([obj asLongDouble] == [self asLongDouble] ? YES : NO);
	default:
		@throw [OFInvalidArgumentException newWithClass: isa
						    andSelector: _cmd];
	}
}

- (uint32_t)hash
{
	return [self asUInt32];
}
@end