ObjFW  Diff

Differences From Artifact [8e480899d7]:

To Artifact [1e5b23cc34]:


60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
		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_







<
<







60
61
62
63
64
65
66


67
68
69
70
71
72
73
		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_;				\


	default:							\
		@throw [OFInvalidFormatException newWithClass: isa];	\
		return 0;	/* Make gcc happy */			\
	}

@implementation OFNumber
+ numberWithChar: (char)char_
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
}

+ numberWithDouble: (double)double_
{
	return [[[OFNumber alloc] initWithDouble: double_] autorelease];
}

+ numberWithLongDouble: (long double)longdouble
{
	return [[[OFNumber alloc] initWithLongDouble: longdouble] autorelease];
}

- initWithChar: (char)char_
{
	if ((self = [super init])) {
		value.char_ = char_;
		type = OF_NUMBER_CHAR;
	}








<
<
<
<
<







186
187
188
189
190
191
192





193
194
195
196
197
198
199
}

+ numberWithDouble: (double)double_
{
	return [[[OFNumber alloc] initWithDouble: double_] autorelease];
}






- initWithChar: (char)char_
{
	if ((self = [super init])) {
		value.char_ = char_;
		type = OF_NUMBER_CHAR;
	}

433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
		value.double_ = double_;
		type = OF_NUMBER_DOUBLE;
	}

	return self;
}

- initWithLongDouble: (long double)longdouble
{
	if ((self = [super init])) {
		value.longdouble = longdouble;
		type = OF_NUMBER_LONG_DOUBLE;
	}

	return self;
}

- (enum of_number_type)type
{
	return type;
}

- (char)asChar
{







<
<
<
<
<
<
<
<
<
<







426
427
428
429
430
431
432










433
434
435
436
437
438
439
		value.double_ = double_;
		type = OF_NUMBER_DOUBLE;
	}

	return self;
}











- (enum of_number_type)type
{
	return type;
}

- (char)asChar
{
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
	case OF_NUMBER_UINT64:
	case OF_NUMBER_SIZE:
	case OF_NUMBER_UINTMAX:
	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







<
|











588
589
590
591
592
593
594

595
596
597
598
599
600
601
602
603
604
605
606
	case OF_NUMBER_UINT64:
	case OF_NUMBER_SIZE:
	case OF_NUMBER_UINTMAX:
	case OF_NUMBER_INTPTR:
		return ([obj asUIntMax] == [self asUIntMax] ? YES : NO);
	case OF_NUMBER_FLOAT:
	case OF_NUMBER_DOUBLE:

		return ([obj asDouble] == [self asDouble] ? YES : NO);
	default:
		@throw [OFInvalidArgumentException newWithClass: isa
						    andSelector: _cmd];
	}
}

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