ObjFW  Check-in [be8b442546]

Overview
Comment:OFNumber: Remove ssize_t

It's a non-standard type that should only be used for matching POSIX
APIs.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: be8b4425461b6f7bd839d42c252673c6f5f2a15be885942d0388ccd511d3111e
User & Date: js on 2020-08-16 18:28:17
Other Links: manifest | tags
Context
2020-08-22
18:39
OFNumber: Don't always use the smallest type check-in: 9746cff094 user: js tags: trunk
2020-08-16
18:28
OFNumber: Remove ssize_t check-in: be8b442546 user: js tags: trunk
2020-08-13
23:13
Make GCC happy again check-in: 3be13d358f user: js tags: trunk
Changes

Modified src/OFNumber.h from [66f566bece] to [833a3447d8].

157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
157
158
159
160
161
162
163





164
165
166
167
168
169
170







-
-
-
-
-







@property (readonly, nonatomic) uint64_t uInt64Value;

/*!
 * @brief The OFNumber as a `size_t`.
 */
@property (readonly, nonatomic) size_t sizeValue;

/*!
 * @brief The OFNumber as an `ssize_t`.
 */
@property (readonly, nonatomic) ssize_t sSizeValue;

/*!
 * @brief The OFNumber as a `ptrdiff_t`.
 */
@property (readonly, nonatomic) ptrdiff_t ptrDiffValue;

/*!
 * @brief The OFNumber as an `intptr_t`.
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
358
359
360
361
362
363
364








365
366
367
368
369
370
371







-
-
-
-
-
-
-
-







 * @brief Creates a new OFNumber with the specified `size_t`.
 *
 * @param value The `size_t` value which the OFNumber should contain
 * @return A new autoreleased OFNumber
 */
+ (instancetype)numberWithSize: (size_t)value;

/*!
 * @brief Creates a new OFNumber with the specified `ssize_t`.
 *
 * @param value The `ssize_t` value which the OFNumber should contain
 * @return A new autoreleased OFNumber
 */
+ (instancetype)numberWithSSize: (ssize_t)value;

/*!
 * @brief Creates a new OFNumber with the specified `ptrdiff_t`.
 *
 * @param value The `ptrdiff_t` value which the OFNumber should contain
 * @return A new autoreleased OFNumber
 */
+ (instancetype)numberWithPtrDiff: (ptrdiff_t)value;
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
584
585
586
587
588
589
590









591
592
593
594
595
596
597







-
-
-
-
-
-
-
-
-







 * @brief Initializes an already allocated OFNumber with the specified `size_t`.
 *
 * @param value The `size_t` value which the OFNumber should contain
 * @return An initialized OFNumber
 */
- (instancetype)initWithSize: (size_t)value;

/*!
 * @brief Initializes an already allocated OFNumber with the specified
 *	  `ssize_t`.
 *
 * @param value The `ssize_t` value which the OFNumber should contain
 * @return An initialized OFNumber
 */
- (instancetype)initWithSSize: (ssize_t)value;

/*!
 * @brief Initializes an already allocated OFNumber with the specified
 *	  `ptrdiff_t`.
 *
 * @param value The `ptrdiff_t` value which the OFNumber should contain
 * @return An initialized OFNumber
 */

Modified src/OFNumber.m from [a978c1217d] to [c26097a3d6].

268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
268
269
270
271
272
273
274










275
276
277
278
279
280
281







-
-
-
-
-
-
-
-
-
-







{
	if (value <= ULONG_MAX)
		return [self initWithUnsignedLong: (unsigned long)value];

	return (id)[[OFNumber of_alloc] initWithSize: value];
}

- (instancetype)initWithSSize: (ssize_t)value
{
	if (value >= 0)
		return [self initWithSize: value];
	if (value <= LONG_MIN)
		return [self initWithLong: (long)value];

	return (id)[[OFNumber of_alloc] initWithSSize: value];
}

#ifdef __clang__
/*
 * This warning should probably not exist at all, as it prevents checking
 * whether one type fits into another in a portable way.
 */
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wtautological-constant-out-of-range-compare"
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
479
480
481
482
483
484
485





486
487
488
489
490
491
492







-
-
-
-
-







}

+ (instancetype)numberWithSize: (size_t)value
{
	return [[[self alloc] initWithSize: value] autorelease];
}

+ (instancetype)numberWithSSize: (ssize_t)value
{
	return [[[self alloc] initWithSSize: value] autorelease];
}

+ (instancetype)numberWithPtrDiff: (ptrdiff_t)value
{
	return [[[self alloc] initWithPtrDiff: value] autorelease];
}

+ (instancetype)numberWithIntPtr: (intptr_t)value
{
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
726
727
728
729
730
731
732











733
734
735
736
737
738
739







-
-
-
-
-
-
-
-
-
-
-







{
	self = [super init];

	_value.unsigned_ = value;
	_type = OF_NUMBER_TYPE_UNSIGNED;
	_typeEncoding = @encode(size_t);

	return self;
}

- (instancetype)initWithSSize: (ssize_t)value
{
	self = [super init];

	_value.signed_ = value;
	_type = OF_NUMBER_TYPE_SIGNED;
	_typeEncoding = @encode(ssize_t);

	return self;
}

- (instancetype)initWithPtrDiff: (ptrdiff_t)value
{
	self = [super init];

1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
981
982
983
984
985
986
987





988
989
990
991
992
993
994







-
-
-
-
-







}

- (size_t)sizeValue
{
	RETURN_AS(size_t)
}

- (ssize_t)sSizeValue
{
	RETURN_AS(ssize_t)
}

- (ptrdiff_t)ptrDiffValue
{
	RETURN_AS(ptrdiff_t)
}

- (intptr_t)intPtrValue
{