ObjFW  Diff

Differences From Artifact [4db74b4fc5]:

To Artifact [afb39b7429]:


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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103

104
105
106
107

108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
	OF_NUMBER_UCHAR		= 0x02,
	/*! unsigned short */
	OF_NUMBER_USHORT	= 0x03,
	/*! unsigned int */
	OF_NUMBER_UINT		= 0x04,
	/*! unsigned long */
	OF_NUMBER_ULONG		= 0x05,


	/*! size_t */
	OF_NUMBER_SIZE		= 0x06,
	/*! uint8_t */
	OF_NUMBER_UINT8		= 0x07,
	/*! uint16_t */
	OF_NUMBER_UINT16	= 0x08,
	/*! uint32_t */
	OF_NUMBER_UINT32	= 0x09,
	/*! uint64_t */
	OF_NUMBER_UINT64	= 0x0A,
	/*! uintptr_t */
	OF_NUMBER_UINTPTR	= 0x0B,
	/*! uintmax_t */
	OF_NUMBER_UINTMAX	= 0x0C,
	OF_NUMBER_SIGNED	= 0x10,
	/*! signed char */
	OF_NUMBER_CHAR		= OF_NUMBER_UCHAR | OF_NUMBER_SIGNED,
	/*! signed short */
	OF_NUMBER_SHORT		= OF_NUMBER_USHORT | OF_NUMBER_SIGNED,
	/*! signed int */
	OF_NUMBER_INT		= OF_NUMBER_UINT | OF_NUMBER_SIGNED,
	/*! signed long */
	OF_NUMBER_LONG		= OF_NUMBER_ULONG | OF_NUMBER_SIGNED,


	/*! int8_t */
	OF_NUMBER_INT8		= OF_NUMBER_UINT8 | OF_NUMBER_SIGNED,
	/*! int16_t */
	OF_NUMBER_INT16		= OF_NUMBER_UINT16 | OF_NUMBER_SIGNED,
	/*! int32_t */
	OF_NUMBER_INT32		= OF_NUMBER_UINT32 | OF_NUMBER_SIGNED,
	/*! int64_t */
	OF_NUMBER_INT64		= OF_NUMBER_UINT64 | OF_NUMBER_SIGNED,
	/*! ssize_t */
	OF_NUMBER_SSIZE		= OF_NUMBER_SIZE | OF_NUMBER_SIGNED,
	/*! intmax_t */
	OF_NUMBER_INTMAX	= OF_NUMBER_UINTMAX | OF_NUMBER_SIGNED,
	/*! ptrdiff_t */
	OF_NUMBER_PTRDIFF	= 0x0D | OF_NUMBER_SIGNED,
	/*! intptr_t */
	OF_NUMBER_INTPTR	= 0x0E | OF_NUMBER_SIGNED,
	/*! float */
	OF_NUMBER_FLOAT		= 0x20,
	/*! double */
	OF_NUMBER_DOUBLE	= 0x40 | OF_NUMBER_FLOAT,
} of_number_type_t;

/*!
 * @brief Provides a way to store a number in an object.
 */
@interface OFNumber: OFObject <OFCopying, OFComparing, OFSerialization,
    OFJSONRepresentation, OFBinaryPackRepresentation>
{
	union of_number_value {
		BOOL	       bool_;
		signed char    schar;
		signed short   sshort;
		signed int     sint;
		signed long    slong;

		unsigned char  uchar;
		unsigned short ushort;
		unsigned int   uint;
		unsigned long  ulong;

		int8_t	       int8;
		int16_t	       int16;
		int32_t	       int32;
		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;
		uintptr_t      uintptr;
		float	       float_;
		double	       double_;
	} _value;
	of_number_type_t _type;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly) of_number_type_t type;
#endif







>
>

|

|

|

|

|

|

|









>
>













|

|













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







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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
	OF_NUMBER_UCHAR		= 0x02,
	/*! unsigned short */
	OF_NUMBER_USHORT	= 0x03,
	/*! unsigned int */
	OF_NUMBER_UINT		= 0x04,
	/*! unsigned long */
	OF_NUMBER_ULONG		= 0x05,
	/*! unsigned long long */
	OF_NUMBER_ULONGLONG	= 0x06,
	/*! size_t */
	OF_NUMBER_SIZE		= 0x07,
	/*! uint8_t */
	OF_NUMBER_UINT8		= 0x08,
	/*! uint16_t */
	OF_NUMBER_UINT16	= 0x09,
	/*! uint32_t */
	OF_NUMBER_UINT32	= 0x0A,
	/*! uint64_t */
	OF_NUMBER_UINT64	= 0x0B,
	/*! uintptr_t */
	OF_NUMBER_UINTPTR	= 0x0C,
	/*! uintmax_t */
	OF_NUMBER_UINTMAX	= 0x0D,
	OF_NUMBER_SIGNED	= 0x10,
	/*! signed char */
	OF_NUMBER_CHAR		= OF_NUMBER_UCHAR | OF_NUMBER_SIGNED,
	/*! signed short */
	OF_NUMBER_SHORT		= OF_NUMBER_USHORT | OF_NUMBER_SIGNED,
	/*! signed int */
	OF_NUMBER_INT		= OF_NUMBER_UINT | OF_NUMBER_SIGNED,
	/*! signed long */
	OF_NUMBER_LONG		= OF_NUMBER_ULONG | OF_NUMBER_SIGNED,
	/*! signed long long */
	OF_NUMBER_LONGLONG	= OF_NUMBER_ULONGLONG | OF_NUMBER_SIGNED,
	/*! int8_t */
	OF_NUMBER_INT8		= OF_NUMBER_UINT8 | OF_NUMBER_SIGNED,
	/*! int16_t */
	OF_NUMBER_INT16		= OF_NUMBER_UINT16 | OF_NUMBER_SIGNED,
	/*! int32_t */
	OF_NUMBER_INT32		= OF_NUMBER_UINT32 | OF_NUMBER_SIGNED,
	/*! int64_t */
	OF_NUMBER_INT64		= OF_NUMBER_UINT64 | OF_NUMBER_SIGNED,
	/*! ssize_t */
	OF_NUMBER_SSIZE		= OF_NUMBER_SIZE | OF_NUMBER_SIGNED,
	/*! intmax_t */
	OF_NUMBER_INTMAX	= OF_NUMBER_UINTMAX | OF_NUMBER_SIGNED,
	/*! ptrdiff_t */
	OF_NUMBER_PTRDIFF	= 0x0E | OF_NUMBER_SIGNED,
	/*! intptr_t */
	OF_NUMBER_INTPTR	= 0x0F | OF_NUMBER_SIGNED,
	/*! float */
	OF_NUMBER_FLOAT		= 0x20,
	/*! double */
	OF_NUMBER_DOUBLE	= 0x40 | OF_NUMBER_FLOAT,
} of_number_type_t;

/*!
 * @brief Provides a way to store a number in an object.
 */
@interface OFNumber: OFObject <OFCopying, OFComparing, OFSerialization,
    OFJSONRepresentation, OFBinaryPackRepresentation>
{
	union of_number_value {
		BOOL		   bool_;
		signed char	   schar;
		signed short	   sshort;
		signed int	   sint;
		signed long	   slong;
		signed long long   slonglong;
		unsigned char	   uchar;
		unsigned short	   ushort;
		unsigned int	   uint;
		unsigned long	   ulong;
		unsigned long long ulonglong;
		int8_t		   int8;
		int16_t		   int16;
		int32_t		   int32;
		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;
		uintptr_t	   uintptr;
		float		   float_;
		double		   double_;
	} _value;
	of_number_type_t _type;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly) of_number_type_t type;
#endif
166
167
168
169
170
171
172








173
174
175
176
177
178
179
 * @brief Creates a new OFNumber with the specified signed long.
 *
 * @param slong A signed long which the OFNumber should contain
 * @return A new autoreleased OFNumber
 */
+ (instancetype)numberWithLong: (signed long)slong;









/*!
 * @brief Creates a new OFNumber with the specified unsigned char.
 *
 * @param uchar An unsigned char which the OFNumber should contain
 * @return A new autoreleased OFNumber
 */
+ (instancetype)numberWithUnsignedChar: (unsigned char)uchar;







>
>
>
>
>
>
>
>







172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
 * @brief Creates a new OFNumber with the specified signed long.
 *
 * @param slong A signed long which the OFNumber should contain
 * @return A new autoreleased OFNumber
 */
+ (instancetype)numberWithLong: (signed long)slong;

/*!
 * @brief Creates a new OFNumber with the specified signed long long.
 *
 * @param slonglong A signed long long which the OFNumber should contain
 * @return A new autoreleased OFNumber
 */
+ (instancetype)numberWithLongLong: (signed long long)slonglong;

/*!
 * @brief Creates a new OFNumber with the specified unsigned char.
 *
 * @param uchar An unsigned char which the OFNumber should contain
 * @return A new autoreleased OFNumber
 */
+ (instancetype)numberWithUnsignedChar: (unsigned char)uchar;
198
199
200
201
202
203
204








205
206
207
208
209
210
211
 * @brief Creates a new OFNumber with the specified unsigned long.
 *
 * @param ulong An unsigned long which the OFNumber should contain
 * @return A new autoreleased OFNumber
 */
+ (instancetype)numberWithUnsignedLong: (unsigned long)ulong;









/*!
 * @brief Creates a new OFNumber with the specified int8_t.
 *
 * @param int8 An int8_t which the OFNumber should contain
 * @return A new autoreleased OFNumber
 */
+ (instancetype)numberWithInt8: (int8_t)int8;







>
>
>
>
>
>
>
>







212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
 * @brief Creates a new OFNumber with the specified unsigned long.
 *
 * @param ulong An unsigned long which the OFNumber should contain
 * @return A new autoreleased OFNumber
 */
+ (instancetype)numberWithUnsignedLong: (unsigned long)ulong;

/*!
 * @brief Creates a new OFNumber with the specified unsigned long long.
 *
 * @param ulonglong An unsigned long long which the OFNumber should contain
 * @return A new autoreleased OFNumber
 */
+ (instancetype)numberWithUnsignedLongLong: (unsigned long long)ulonglong;

/*!
 * @brief Creates a new OFNumber with the specified int8_t.
 *
 * @param int8 An int8_t which the OFNumber should contain
 * @return A new autoreleased OFNumber
 */
+ (instancetype)numberWithInt8: (int8_t)int8;
378
379
380
381
382
383
384









385
386
387
388
389
390
391
 *	  long.
 *
 * @param slong A signed long which the OFNumber should contain
 * @return An initialized OFNumber
 */
- initWithLong: (signed long)slong;










/*!
 * @brief Initializes an already allocated OFNumber with the specified unsigned
 *	  char.
 *
 * @param uchar An unsigned char which the OFNumber should contain
 * @return An initialized OFNumber
 */







>
>
>
>
>
>
>
>
>







400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
 *	  long.
 *
 * @param slong A signed long which the OFNumber should contain
 * @return An initialized OFNumber
 */
- initWithLong: (signed long)slong;

/*!
 * @brief Initializes an already allocated OFNumber with the specified signed
 *	  long long.
 *
 * @param slonglong A signed long long which the OFNumber should contain
 * @return An initialized OFNumber
 */
- initWithLongLong: (signed long long)slonglong;

/*!
 * @brief Initializes an already allocated OFNumber with the specified unsigned
 *	  char.
 *
 * @param uchar An unsigned char which the OFNumber should contain
 * @return An initialized OFNumber
 */
414
415
416
417
418
419
420









421
422
423
424
425
426
427
 *	  long.
 *
 * @param ulong An unsigned long which the OFNumber should contain
 * @return An initialized OFNumber
 */
- initWithUnsignedLong: (unsigned long)ulong;










/*!
 * @brief Initializes an already allocated OFNumber with the specified int8_t.
 *
 * @param int8 An int8_t which the OFNumber should contain
 * @return An initialized OFNumber
 */
- initWithInt8: (int8_t)int8;







>
>
>
>
>
>
>
>
>







445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
 *	  long.
 *
 * @param ulong An unsigned long which the OFNumber should contain
 * @return An initialized OFNumber
 */
- initWithUnsignedLong: (unsigned long)ulong;

/*!
 * @brief Initializes an already allocated OFNumber with the specified unsigned
 *	  long long.
 *
 * @param ulonglong An unsigned long long which the OFNumber should contain
 * @return An initialized OFNumber
 */
- initWithUnsignedLongLong: (unsigned long long)ulonglong;

/*!
 * @brief Initializes an already allocated OFNumber with the specified int8_t.
 *
 * @param int8 An int8_t which the OFNumber should contain
 * @return An initialized OFNumber
 */
- initWithInt8: (int8_t)int8;
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601







602
603
604
605
606
607
608
 * @return The OFNumber as a signed char
 */
- (signed char)charValue;

/*!
 * @brief Returns the OFNumber as a signed short.
 *
 * @return The OFNumber as a short
 */
- (signed short)shortValue;

/*!
 * @brief Returns the OFNumber as a signed int.
 *
 * @return The OFNumber as an int
 */
- (signed int)intValue;

/*!
 * @brief Returns the OFNumber as a signed long.
 *
 * @return The OFNumber as a long
 */
- (signed long)longValue;








/*!
 * @brief Returns the OFNumber as an unsigned char.
 *
 * @return The OFNumber as an unsigned char
 */
- (unsigned char)unsignedCharValue;








|






|






|



>
>
>
>
>
>
>







617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
 * @return The OFNumber as a signed char
 */
- (signed char)charValue;

/*!
 * @brief Returns the OFNumber as a signed short.
 *
 * @return The OFNumber as a signed short
 */
- (signed short)shortValue;

/*!
 * @brief Returns the OFNumber as a signed int.
 *
 * @return The OFNumber as a signed int
 */
- (signed int)intValue;

/*!
 * @brief Returns the OFNumber as a signed long.
 *
 * @return The OFNumber as a signed long
 */
- (signed long)longValue;

/*!
 * @brief Returns the OFNumber as a signed long long.
 *
 * @return The OFNumber as a signed long long
 */
- (signed long long)longLongValue;

/*!
 * @brief Returns the OFNumber as an unsigned char.
 *
 * @return The OFNumber as an unsigned char
 */
- (unsigned char)unsignedCharValue;

623
624
625
626
627
628
629







630
631
632
633
634
635
636
/*!
 * @brief Returns the OFNumber as an unsigned long.
 *
 * @return The OFNumber as an unsigned long
 */
- (unsigned long)unsignedLongValue;








/*!
 * @brief Returns the OFNumber as an int8_t.
 *
 * @return The OFNumber as an int8_t
 */
- (int8_t)int8Value;








>
>
>
>
>
>
>







670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
/*!
 * @brief Returns the OFNumber as an unsigned long.
 *
 * @return The OFNumber as an unsigned long
 */
- (unsigned long)unsignedLongValue;

/*!
 * @brief Returns the OFNumber as an unsigned long long.
 *
 * @return The OFNumber as an unsigned long long
 */
- (unsigned long long)unsignedLongLongValue;

/*!
 * @brief Returns the OFNumber as an int8_t.
 *
 * @return The OFNumber as an int8_t
 */
- (int8_t)int8Value;