Differences From Artifact [5681aa0f6b]:
- File
src/OFNumber.m
— part of check-in
[44f45c2e35]
at
2017-01-09 17:36:36
on branch trunk
— Update copyright
Forgot to add 2017, even though I already did quite some changes in
2017. (user: js, size: 23780) [annotate] [blame] [check-ins using]
To Artifact [97313fd44a]:
- File
src/OFNumber.m
— part of check-in
[4af49a13c3]
at
2017-05-07 20:10:13
on branch trunk
— Small code style change
Casts are now written like types in variable declarations. (user: js, size: 23791) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
88 89 90 91 92 93 94 | case OF_NUMBER_TYPE_DOUBLE: \ return (t)_value.double_; \ default: \ @throw [OFInvalidFormatException exception]; \ } @interface OFNumber () | | | | 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | case OF_NUMBER_TYPE_DOUBLE: \ return (t)_value.double_; \ default: \ @throw [OFInvalidFormatException exception]; \ } @interface OFNumber () - (OFString *)OF_JSONRepresentationWithOptions: (int)options depth: (size_t)depth; @end @implementation OFNumber @synthesize type = _type; + (instancetype)numberWithBool: (bool)bool_ { |
︙ | ︙ | |||
520 521 522 523 524 525 526 | _value.double_ = double_; _type = OF_NUMBER_TYPE_DOUBLE; return self; } | | | 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 | _value.double_ = double_; _type = OF_NUMBER_TYPE_DOUBLE; return self; } - initWithSerialization: (OFXMLElement *)element { self = [super init]; @try { void *pool = objc_autoreleasePoolPush(); OFString *typeString; |
︙ | ︙ | |||
761 762 763 764 765 766 767 | - (of_comparison_result_t)compare: (id <OFComparing>)object { OFNumber *number; if (![object isKindOfClass: [OFNumber class]]) @throw [OFInvalidArgumentException exception]; | | | 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 | - (of_comparison_result_t)compare: (id <OFComparing>)object { OFNumber *number; if (![object isKindOfClass: [OFNumber class]]) @throw [OFInvalidArgumentException exception]; number = (OFNumber *)object; if (_type & OF_NUMBER_TYPE_FLOAT || number->_type & OF_NUMBER_TYPE_FLOAT) { double double1 = [self doubleValue]; double double2 = [number doubleValue]; if (double1 > double2) |
︙ | ︙ | |||
865 866 867 868 869 870 871 | } - copy { return [self retain]; } | | | 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 | } - copy { return [self retain]; } - (OFString *)description { OFMutableString *ret; switch (_type) { case OF_NUMBER_TYPE_BOOL: return (_value.bool_ ? @"true" : @"false"); case OF_NUMBER_TYPE_UCHAR: |
︙ | ︙ | |||
922 923 924 925 926 927 928 | return ret; default: @throw [OFInvalidFormatException exception]; } } | | | 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 | return ret; default: @throw [OFInvalidFormatException exception]; } } - (OFXMLElement *)XMLElementBySerializing { void *pool = objc_autoreleasePoolPush(); OFXMLElement *element; element = [OFXMLElement elementWithName: [self className] namespace: OF_SERIALIZATION_NS stringValue: [self description]]; |
︙ | ︙ | |||
1006 1007 1008 1009 1010 1011 1012 | [element retain]; objc_autoreleasePoolPop(pool); return [element autorelease]; } | | | | | | | 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 | [element retain]; objc_autoreleasePoolPop(pool); return [element autorelease]; } - (OFString *)JSONRepresentation { return [self OF_JSONRepresentationWithOptions: 0 depth: 0]; } - (OFString *)JSONRepresentationWithOptions: (int)options { return [self OF_JSONRepresentationWithOptions: options depth: 0]; } - (OFString *)OF_JSONRepresentationWithOptions: (int)options depth: (size_t)depth { double doubleValue; if (_type == OF_NUMBER_TYPE_BOOL) return (_value.bool_ ? @"true" : @"false"); doubleValue = [self doubleValue]; if (isinf(doubleValue)) { if (options & OF_JSON_REPRESENTATION_JSON5) { if (doubleValue > 0) return @"Infinity"; else return @"-Infinity"; } else @throw [OFInvalidArgumentException exception]; } return [self description]; } - (OFDataArray *)messagePackRepresentation { OFDataArray *data; if (_type == OF_NUMBER_TYPE_BOOL) { uint8_t type; data = [OFDataArray dataArrayWithItemSize: 1 |
︙ | ︙ |