ObjFW  Diff

Differences From Artifact [9847bb6afe]:

To Artifact [63d31ab23c]:


37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
	OF_NUMBER_PTRDIFF,
	OF_NUMBER_INTPTR,
	OF_NUMBER_FLOAT,
	OF_NUMBER_DOUBLE,
};

/**
 * The OFNumber class provides a way to store a number in an object and
 * manipulate it.
 */
@interface OFNumber: OFObject
{
	union {
		char	       char_;
		short	       short_;







|







37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
	OF_NUMBER_PTRDIFF,
	OF_NUMBER_INTPTR,
	OF_NUMBER_FLOAT,
	OF_NUMBER_DOUBLE,
};

/**
 * The OFNumber class provides a way to store a number in an object and to
 * manipulate it.
 */
@interface OFNumber: OFObject
{
	union {
		char	       char_;
		short	       short_;
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




138




139




140




141




142




143




144




145




146




147




148




149




150




151




152




153
154





155






156






157






158




159




160
161
		intptr_t       intptr;
		float	       float_;
		double	       double_;
	} value;
	enum of_number_type type;
}





+ numberWithChar: (char)char_;





+ numberWithShort: (short)short_;





+ numberWithInt: (int)int_;





+ numberWithLong: (long)long_;





+ numberWithUChar: (unsigned char)uchar;





+ numberWithUShort: (unsigned short)ushort;





+ numberWithUInt: (unsigned int)uint;





+ numberWithULong: (unsigned long)ulong;





+ numberWithInt8: (int8_t)int8;





+ numberWithInt16: (int16_t)int16;





+ numberWithInt32: (int32_t)int32;





+ 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_;







- initWithChar: (char)char_;







- initWithShort: (short)short_;







- initWithInt: (int)int_;







- initWithLong: (long)long_;







- initWithUChar: (unsigned char)uchar;







- initWithUShort: (unsigned short)ushort;







- initWithUInt: (unsigned int)uint;







- initWithULong: (unsigned long)ulong;







- initWithInt8: (int8_t)int8;







- initWithInt16: (int16_t)int16;







- initWithInt32: (int32_t)int32;







- 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_;





- (enum of_number_type)type;




- (char)asChar;




- (short)asShort;




- (int)asInt;




- (long)asLong;




- (unsigned char)asUChar;




- (unsigned short)asUShort;




- (unsigned int)asUInt;




- (unsigned long)asULong;




- (int8_t)asInt8;




- (int16_t)asInt16;




- (int32_t)asInt32;




- (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;






- add: (OFNumber*)num;






- subtract: (OFNumber*)num;






- multiplyWith: (OFNumber*)num;






- divideBy: (OFNumber*)num;




- increase;




- decrease;
@end







>
>
>
>

>
>
>
>
>

>
>
>
>
>

>
>
>
>
>

>
>
>
>
>

>
>
>
>
>

>
>
>
>
>

>
>
>
>
>

>
>
>
>
>

>
>
>
>
>

>
>
>
>
>

>
>
>
>
>

>
>
>
>
>

>
>
>
>
>

>
>
>
>
>

>
>
>
>
>

>
>
>
>
>

>
>
>
>
>

>
>
>
>
>

>
>
>
>
>

>
>
>
>
>

>
>
>
>
>

>
>
>
>
>

>
>
>
>
>


>
>
>
>
>
>

>
>
>
>
>
>
>

>
>
>
>
>
>
>

>
>
>
>
>
>
>

>
>
>
>
>
>
>

>
>
>
>
>
>
>

>
>
>
>
>
>
>

>
>
>
>
>
>
>

>
>
>
>
>
>
>

>
>
>
>
>
>
>

>
>
>
>
>
>
>

>
>
>
>
>
>
>

>
>
>
>
>
>
>

>
>
>
>
>
>
>

>
>
>
>
>
>
>

>
>
>
>
>
>
>

>
>
>
>
>
>
>

>
>
>
>
>
>
>

>
>
>
>
>
>
>

>
>
>
>
>
>
>

>
>
>
>
>
>
>

>
>
>
>
>
>
>

>
>
>
>
>
>
>

>
>
>
>
>
>
>


>
>
>
>


>
>
>

>
>
>
>

>
>
>
>

>
>
>
>

>
>
>
>

>
>
>
>

>
>
>
>

>
>
>
>

>
>
>
>

>
>
>
>

>
>
>
>

>
>
>
>

>
>
>
>

>
>
>
>

>
>
>
>

>
>
>
>

>
>
>
>

>
>
>
>

>
>
>
>

>
>
>
>

>
>
>
>

>
>
>
>

>
>
>
>

>
>
>
>


>
>
>
>
>

>
>
>
>
>
>

>
>
>
>
>
>

>
>
>
>
>
>

>
>
>
>

>
>
>
>


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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
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
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
		intptr_t       intptr;
		float	       float_;
		double	       double_;
	} value;
	enum of_number_type type;
}

/**
 * \param char_ A char which the OFNumber should contain
 * \return A new autoreleased OFNumber
 */
+ numberWithChar: (char)char_;

/**
 * \param short_ A short which the OFNumber should contain
 * \return A new autoreleased OFNumber
 */
+ numberWithShort: (short)short_;

/**
 * \param int_ An int which the OFNumber should contain
 * \return A new autoreleased OFNumber
 */
+ numberWithInt: (int)int_;

/**
 * \param long_ A long which the OFNumber should contain
 * \return A new autoreleased OFNumber
 */
+ numberWithLong: (long)long_;

/**
 * \param uchar An unsigned char which the OFNumber should contain
 * \return A new autoreleased OFNumber
 */
+ numberWithUChar: (unsigned char)uchar;

/**
 * \param ushort An unsigned short which the OFNumber should contain
 * \return A new autoreleased OFNumber
 */
+ numberWithUShort: (unsigned short)ushort;

/**
 * \param uint An unsigned int which the OFNumber should contain
 * \return A new autoreleased OFNumber
 */
+ numberWithUInt: (unsigned int)uint;

/**
 * \param ulong An unsigned long which the OFNumber should contain
 * \return A new autoreleased OFNumber
 */
+ numberWithULong: (unsigned long)ulong;

/**
 * \param int8 An int8_t which the OFNumber should contain
 * \return A new autoreleased OFNumber
 */
+ numberWithInt8: (int8_t)int8;

/**
 * \param int16 An int16_t which the OFNumber should contain
 * \return A new autoreleased OFNumber
 */
+ numberWithInt16: (int16_t)int16;

/**
 * \param int32 An int32_t which the OFNumber should contain
 * \return A new autoreleased OFNumber
 */
+ numberWithInt32: (int32_t)int32;

/**
 * \param int64 An int64_t which the OFNumber should contain
 * \return A new autoreleased OFNumber
 */
+ numberWithInt64: (int64_t)int64;

/**
 * \param uint8 An uint8_t which the OFNumber should contain
 * \return A new autoreleased OFNumber
 */
+ numberWithUInt8: (uint8_t)uint8;

/**
 * \param uint16 An uint16_t which the OFNumber should contain
 * \return A new autoreleased OFNumber
 */
+ numberWithUInt16: (uint16_t)uint16;

/**
 * \param uint32 An uint32_t which the OFNumber should contain
 * \return A new autoreleased OFNumber
 */
+ numberWithUInt32: (uint32_t)uint32;

/**
 * \param uint64 An uint64_t which the OFNumber should contain
 * \return A new autoreleased OFNumber
 */
+ numberWithUInt64: (uint64_t)uint64;

/**
 * \param size A size_t which the OFNumber should contain
 * \return A new autoreleased OFNumber
 */
+ numberWithSize: (size_t)size;

/**
 * \param ssize An ssize_t which the OFNumber should contain
 * \return A new autoreleased OFNumber
 */
+ numberWithSSize: (ssize_t)ssize;

/**
 * \param intmax An intmax_t which the OFNumber should contain
 * \return A new autoreleased OFNumber
 */
+ numberWithIntMax: (intmax_t)intmax;

/**
 * \param uintmax An uintmax_t which the OFNumber should contain
 * \return A new autoreleased OFNumber
 */
+ numberWithUIntMax: (uintmax_t)uintmax;

/**
 * \param ptrdifff A ptrdiff_t which the OFNumber should contain
 * \return A new autoreleased OFNumber
 */
+ numberWithPtrDiff: (ptrdiff_t)ptrdiff;

/**
 * \param intptr An intptr_t which the OFNumber should contain
 * \return A new autoreleased OFNumber
 */
+ numberWithIntPtr: (intptr_t)intptr;

/**
 * \param float_ A float which the OFNumber should contain
 * \return A new autoreleased OFNumber
 */
+ numberWithFloat: (float)float_;

/**
 * \param double_ A double which the OFNumber should contain
 * \return A new autoreleased OFNumber
 */
+ numberWithDouble: (double)double_;

/**
 * Initializes an already allocated OFNumber with the specified char.
 *
 * \param char_ A char which the OFNumber should contain
 * \return An initialized OFNumber
 */
- initWithChar: (char)char_;

/**
 * Initializes an already allocated OFNumber with the specified short.
 *
 * \param short_ A short which the OFNumber should contain
 * \return An initialized OFNumber
 */
- initWithShort: (short)short_;

/**
 * Initializes an already allocated OFNumber with the specified int.
 *
 * \param int_ An int which the OFNumber should contain
 * \return An initialized OFNumber
 */
- initWithInt: (int)int_;

/**
 * Initializes an already allocated OFNumber with the specified long.
 *
 * \param long_ A long which the OFNumber should contain
 * \return An initialized OFNumber
 */
- initWithLong: (long)long_;

/**
 * Initializes an already allocated OFNumber with the specified unsigned char.
 *
 * \param uchar An unsigned char which the OFNumber should contain
 * \return An initialized OFNumber
 */
- initWithUChar: (unsigned char)uchar;

/**
 * Initializes an already allocated OFNumber with the specified unsigned short.
 *
 * \param ushort An unsigned short which the OFNumber should contain
 * \return An initialized OFNumber
 */
- initWithUShort: (unsigned short)ushort;

/**
 * Initializes an already allocated OFNumber with the specified unsigned int .
 *
 * \param uint An unsigned int which the OFNumber should contain
 * \return An initialized OFNumber
 */
- initWithUInt: (unsigned int)uint;

/**
 * Initializes an already allocated OFNumber with the specified unsigned long.
 *
 * \param ulong An unsigned long which the OFNumber should contain
 * \return An initialized OFNumber
 */
- initWithULong: (unsigned long)ulong;

/**
 * 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;

/**
 * Initializes an already allocated OFNumber with the specified int16_t.
 *
 * \param int16 An int16_t which the OFNumber should contain
 * \return An initialized OFNumber
 */
- initWithInt16: (int16_t)int16;

/**
 * Initializes an already allocated OFNumber with the specified int32_t.
 *
 * \param int32 An int32_t which the OFNumber should contain
 * \return An initialized OFNumber
 */
- initWithInt32: (int32_t)int32;

/**
 * Initializes an already allocated OFNumber with the specified int64_t.
 *
 * \param int64 An int64_t which the OFNumber should contain
 * \return An initialized OFNumber
 */
- initWithInt64: (int64_t)int64;

/**
 * Initializes an already allocated OFNumber with the specified uint8_t.
 *
 * \param uint8 An uint8_t which the OFNumber should contain
 * \return An initialized OFNumber
 */
- initWithUInt8: (uint8_t)uint8;

/**
 * Initializes an already allocated OFNumber with the specified uint16_t.
 *
 * \param uint16 An uint16_t which the OFNumber should contain
 * \return An initialized OFNumber
 */
- initWithUInt16: (uint16_t)uint16;

/**
 * Initializes an already allocated OFNumber with the specified uint32_t.
 *
 * \param uint32 An uint32_t which the OFNumber should contain
 * \return An initialized OFNumber
 */
- initWithUInt32: (uint32_t)uint32;

/**
 * Initializes an already allocated OFNumber with the specified uint64_t.
 *
 * \param uint64 An uint64_t which the OFNumber should contain
 * \return An initialized OFNumber
 */
- initWithUInt64: (uint64_t)uint64;

/**
 * Initializes an already allocated OFNumber with the specified size_t.
 *
 * \param size A size_t which the OFNumber should contain
 * \return An initialized OFNumber
 */
- initWithSize: (size_t)size;

/**
 * Initializes an already allocated OFNumber with the specified ssize_t.
 *
 * \param ssize An ssize_t which the OFNumber should contain
 * \return An initialized OFNumber
 */
- initWithSSize: (ssize_t)ssize;

/**
 * Initializes an already allocated OFNumber with the specified intmax_t.
 *
 * \param intmax An intmax_t which the OFNumber should contain
 * \return An initialized OFNumber
 */
- initWithIntMax: (intmax_t)intmax;

/**
 * Initializes an already allocated OFNumber with the specified uintmax_t.
 *
 * \param uintmax An uintmax_t which the OFNumber should contain
 * \return An initialized OFNumber
 */
- initWithUIntMax: (uintmax_t)uintmax;

/**
 * Initializes an already allocated OFNumber with the specified ptrdiff_t.
 *
 * \param ptrdiff A ptrdiff_t which the OFNumber should contain
 * \return An initialized OFNumber
 */
- initWithPtrDiff: (ptrdiff_t)ptrdiff;

/**
 * Initializes an already allocated OFNumber with the specified intptr_t.
 *
 * \param intptr An intptr_t which the OFNumber should contain
 * \return An initialized OFNumber
 */
- initWithIntPtr: (intptr_t)intptr;

/**
 * Initializes an already allocated OFNumber with the specified float.
 *
 * \param float_ A float which the OFNumber should contain
 * \return An initialized OFNumber
 */
- initWithFloat: (float)float_;

/**
 * Initializes an already allocated OFNumber with the specified double.
 *
 * \param double_ A double which the OFNumber should contain
 * \return An initialized OFNumber
 */
- initWithDouble: (double)double_;

/**
 * \return An enum of type of_number_type indicating the type of contained
 *	   number of the OFNumber
 */
- (enum of_number_type)type;

/**
 * \return The OFNumber as a char
 */
- (char)asChar;

/**
 * \return The OFNumber as a short
 */
- (short)asShort;

/**
 * \return The OFNumber as an int
 */
- (int)asInt;

/**
 * \return The OFNumber as a long
 */
- (long)asLong;

/**
 * \return The OFNumber as an unsigned char
 */
- (unsigned char)asUChar;

/**
 * \return The OFNumber as an unsigned short
 */
- (unsigned short)asUShort;

/**
 * \return The OFNumber as an unsigned int
 */
- (unsigned int)asUInt;

/**
 * \return The OFNumber as an unsigned long
 */
- (unsigned long)asULong;

/**
 * \return The OFNumber as an int8_t
 */
- (int8_t)asInt8;

/**
 * \return The OFNumber as an int16_t
 */
- (int16_t)asInt16;

/**
 * \return The OFNumber as an int32_t
 */
- (int32_t)asInt32;

/**
 * \return The OFNumber as an int64_t
 */
- (int64_t)asInt64;

/**
 * \return The OFNumber as an uint8_t
 */
- (uint8_t)asUInt8;

/**
 * \return The OFNumber as an uint16_t
 */
- (uint16_t)asUInt16;

/**
 * \return The OFNumber as an uint32_t
 */
- (uint32_t)asUInt32;

/**
 * \return The OFNumber as an uint64_t
 */
- (uint64_t)asUInt64;

/**
 * \return The OFNumber as a size_t
 */
- (size_t)asSize;

/**
 * \return The OFNumber as an ssize_t
 */
- (ssize_t)asSSize;

/**
 * \return The OFNumber as an intmax_t
 */
- (intmax_t)asIntMax;

/**
 * \return The OFNumber as an uintmax_t
 */
- (uintmax_t)asUIntMax;

/**
 * \return The OFNumber as a ptrdiff_t
 */
- (ptrdiff_t)asPtrDiff;

/**
 * \return The OFNumber as an intptr_t
 */
- (intptr_t)asIntPtr;

/**
 * \return The OFNumber as a float
 */
- (float)asFloat;

/**
 * \return The OFNumber as a double
 */
- (double)asDouble;

/**
 * Adds the specified OFNumber to the OFNumber.
 *
 * \param num The OFNumber to add
 */
- add: (OFNumber*)num;

/**
 * Subtracts the specified OFNumber from the OFNumber.
 *
 * \param num The OFNumber to substract
 */
- subtract: (OFNumber*)num;

/**
 * Multiplies the OFNumber with the specified OFNumber.
 *
 * \param num The OFNumber to multiply with
 */
- multiplyWith: (OFNumber*)num;

/**
 * Divides the OFNumber by the specified OFNumber.
 *
 * \param num The OFNumber to divide by
 */
- divideBy: (OFNumber*)num;

/**
 * Increases the OFNumber by 1.
 */
- increase;

/**
 * Decreases the OFNumber by 1.
 */
- decrease;
@end