ObjFW  Check-in [db131a629c]

Overview
Comment:Add intmax_t and uintmax_t to OFNumber.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: db131a629cf07607829762d31b0cd706d3ccfd28430d253dccfabe8155035c78
User & Date: js on 2009-02-14 20:15:47
Other Links: manifest | tags
Context
2009-02-15
16:40
Get rid of OFComparable and make it part of OFObject. check-in: d9308adc2b user: js tags: trunk
2009-02-14
20:15
Add intmax_t and uintmax_t to OFNumber. check-in: db131a629c user: js tags: trunk
19:04
Let OFString's setTo: use const char* instead of OFString*.
This is far more useful.
check-in: cc2e866e55 user: js tags: trunk
Changes

Modified src/OFNumber.h from [5ac8772568] to [6453b5d17a].

28
29
30
31
32
33
34


35
36
37
38
39
40
41
	OF_NUMBER_INT64,
	OF_NUMBER_UINT8,
	OF_NUMBER_UINT16,
	OF_NUMBER_UINT32,
	OF_NUMBER_UINT64,
	OF_NUMBER_SIZE,
	OF_NUMBER_SSIZE,


	OF_NUMBER_PTRDIFF,
	OF_NUMBER_INTPTR,
	OF_NUMBER_FLOAT,
	OF_NUMBER_DOUBLE,
	OF_NUMBER_LONG_DOUBLE
};








>
>







28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
	OF_NUMBER_INT64,
	OF_NUMBER_UINT8,
	OF_NUMBER_UINT16,
	OF_NUMBER_UINT32,
	OF_NUMBER_UINT64,
	OF_NUMBER_SIZE,
	OF_NUMBER_SSIZE,
	OF_NUMBER_INTMAX,
	OF_NUMBER_UINTMAX,
	OF_NUMBER_PTRDIFF,
	OF_NUMBER_INTPTR,
	OF_NUMBER_FLOAT,
	OF_NUMBER_DOUBLE,
	OF_NUMBER_LONG_DOUBLE
};

60
61
62
63
64
65
66


67
68
69
70
71
72
73
		int64_t	       int64;
		uint8_t	       uint8;
		uint16_t       uint16;
		uint32_t       uint32;
		uint64_t       uint64;
		size_t	       size;
		ssize_t	       ssize;


		ptrdiff_t      ptrdiff;
		intptr_t       intptr;
		float	       float_;
		double	       double_;
		long double    longdouble;
	} value;
	enum of_number_type type;







>
>







62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
		int64_t	       int64;
		uint8_t	       uint8;
		uint16_t       uint16;
		uint32_t       uint32;
		uint64_t       uint64;
		size_t	       size;
		ssize_t	       ssize;
		intmax_t       intmax;
		uintmax_t      uintmax;
		ptrdiff_t      ptrdiff;
		intptr_t       intptr;
		float	       float_;
		double	       double_;
		long double    longdouble;
	} value;
	enum of_number_type type;
87
88
89
90
91
92
93


94
95
96
97
98
99
100
+ numberWithInt64: (int64_t)int64;
+ numberWithUInt8: (uint8_t)uint8;
+ numberWithUInt16: (uint16_t)uint16;
+ numberWithUInt32: (uint32_t)uint32;
+ numberWithUInt64: (uint64_t)uint64;
+ numberWithSize: (size_t)size;
+ numberWithSSize: (ssize_t)ssize;


+ numberWithPtrDiff: (ptrdiff_t)ptrdiff;
+ numberWithIntPtr: (intptr_t)intptr;
+ numberWithFloat: (float)float_;
+ numberWithDouble: (double)double_;
+ numberWithLongDouble: (long double)longdouble;

- initWithChar: (char)char_;







>
>







91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
+ numberWithInt64: (int64_t)int64;
+ numberWithUInt8: (uint8_t)uint8;
+ numberWithUInt16: (uint16_t)uint16;
+ numberWithUInt32: (uint32_t)uint32;
+ numberWithUInt64: (uint64_t)uint64;
+ numberWithSize: (size_t)size;
+ numberWithSSize: (ssize_t)ssize;
+ numberWithIntMax: (intmax_t)intmax;
+ numberWithUIntMax: (uintmax_t)uintmax;
+ numberWithPtrDiff: (ptrdiff_t)ptrdiff;
+ numberWithIntPtr: (intptr_t)intptr;
+ numberWithFloat: (float)float_;
+ numberWithDouble: (double)double_;
+ numberWithLongDouble: (long double)longdouble;

- initWithChar: (char)char_;
111
112
113
114
115
116
117


118
119
120
121
122
123
124
- initWithInt64: (int64_t)int64;
- initWithUInt8: (uint8_t)uint8;
- initWithUInt16: (uint16_t)uint16;
- initWithUInt32: (uint32_t)uint32;
- initWithUInt64: (uint64_t)uint64;
- initWithSize: (size_t)size;
- initWithSSize: (ssize_t)ssize;


- initWithPtrDiff: (ptrdiff_t)ptrdiff;
- initWithIntPtr: (intptr_t)intptr;
- initWithFloat: (float)float_;
- initWithDouble: (double)double_;
- initWithLongDouble: (long double)longdouble;

- (enum of_number_type)type;







>
>







117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
- initWithInt64: (int64_t)int64;
- initWithUInt8: (uint8_t)uint8;
- initWithUInt16: (uint16_t)uint16;
- initWithUInt32: (uint32_t)uint32;
- initWithUInt64: (uint64_t)uint64;
- initWithSize: (size_t)size;
- initWithSSize: (ssize_t)ssize;
- initWithIntMax: (intmax_t)intmax;
- initWithUIntMax: (uintmax_t)uintmax;
- initWithPtrDiff: (ptrdiff_t)ptrdiff;
- initWithIntPtr: (intptr_t)intptr;
- initWithFloat: (float)float_;
- initWithDouble: (double)double_;
- initWithLongDouble: (long double)longdouble;

- (enum of_number_type)type;
137
138
139
140
141
142
143


144
145
146
147
148
149
- (int64_t)asInt64;
- (uint8_t)asUInt8;
- (uint16_t)asUInt16;
- (uint32_t)asUInt32;
- (uint64_t)asUInt64;
- (size_t)asSize;
- (ssize_t)asSSize;


- (ptrdiff_t)asPtrDiff;
- (intptr_t)asIntPtr;
- (float)asFloat;
- (double)asDouble;
- (long double)asLongDouble;
@end







>
>






145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
- (int64_t)asInt64;
- (uint8_t)asUInt8;
- (uint16_t)asUInt16;
- (uint32_t)asUInt32;
- (uint64_t)asUInt64;
- (size_t)asSize;
- (ssize_t)asSSize;
- (intmax_t)asIntMax;
- (uintmax_t)asUIntMax;
- (ptrdiff_t)asPtrDiff;
- (intptr_t)asIntPtr;
- (float)asFloat;
- (double)asDouble;
- (long double)asLongDouble;
@end

Modified src/OFNumber.m from [5618431ef2] to [5e2a173a69].

46
47
48
49
50
51
52




53
54
55
56
57
58
59
		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_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:						      \







>
>
>
>







46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
		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:						      \
153
154
155
156
157
158
159










160
161
162
163
164
165
166
	return [[[OFNumber alloc] initWithSize: size] autorelease];
}

+ numberWithSSize: (ssize_t)ssize
{
	return [[[OFNumber alloc] initWithSSize: ssize] autorelease];
}











+ numberWithPtrDiff: (ptrdiff_t)ptrdiff
{
	return [[[OFNumber alloc] initWithPtrDiff: ptrdiff] autorelease];
}

+ numberWithIntPtr: (intptr_t)intptr







>
>
>
>
>
>
>
>
>
>







157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
	return [[[OFNumber alloc] initWithSize: size] autorelease];
}

+ numberWithSSize: (ssize_t)ssize
{
	return [[[OFNumber alloc] initWithSSize: ssize] autorelease];
}

+ numberWithIntMax: (intmax_t)intmax
{
	return [[[OFNumber alloc] initWithIntMax: intmax] autorelease];
}

+ numberWithUIntMax: (uintmax_t)uintmax
{
	return [[[OFNumber alloc] initWithIntMax: uintmax] autorelease];
}

+ numberWithPtrDiff: (ptrdiff_t)ptrdiff
{
	return [[[OFNumber alloc] initWithPtrDiff: ptrdiff] autorelease];
}

+ numberWithIntPtr: (intptr_t)intptr
358
359
360
361
362
363
364




















365
366
367
368
369
370
371
	if ((self = [super init])) {
		value.ssize = ssize;
		type = OF_NUMBER_SSIZE;
	}

	return self;
}





















- initWithPtrDiff: (ptrdiff_t)ptrdiff
{
	if ((self = [super init])) {
		value.ptrdiff = ptrdiff;
		type = OF_NUMBER_PTRDIFF;
	}







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







372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
	if ((self = [super init])) {
		value.ssize = ssize;
		type = OF_NUMBER_SSIZE;
	}

	return self;
}

- initWithIntMax: (intmax_t)intmax
{
	if ((self = [super init])) {
		value.intmax = intmax;
		type = OF_NUMBER_INTMAX;
	}

	return self;
}

- initWithUIntMax: (uintmax_t)uintmax
{
	if ((self = [super init])) {
		value.uintmax = uintmax;
		type = OF_NUMBER_UINTMAX;
	}

	return self;
}

- initWithPtrDiff: (ptrdiff_t)ptrdiff
{
	if ((self = [super init])) {
		value.ptrdiff = ptrdiff;
		type = OF_NUMBER_PTRDIFF;
	}
503
504
505
506
507
508
509










510
511
512
513
514
515
516
	RETURN_AS(size_t)
}

- (ssize_t)asSSize
{
	RETURN_AS(ssize_t)
}











- (ptrdiff_t)asPtrDiff
{
	RETURN_AS(ptrdiff_t)
}

- (intptr_t)asIntPtr







>
>
>
>
>
>
>
>
>
>







537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
	RETURN_AS(size_t)
}

- (ssize_t)asSSize
{
	RETURN_AS(ssize_t)
}

- (intmax_t)asIntMax
{
	RETURN_AS(intmax_t)
}

- (uintmax_t)asUIntMax
{
	RETURN_AS(uintmax_t)
}

- (ptrdiff_t)asPtrDiff
{
	RETURN_AS(ptrdiff_t)
}

- (intptr_t)asIntPtr