Differences From Artifact [687e9eb918]:
- File src/OFNumber.m — part of check-in [ef02147e8b] at 2011-09-17 18:58:01 on branch trunk — Better format for serialization of floating point OFNumbers. (user: js, size: 27967) [annotate] [blame] [check-ins using]
To Artifact [37c360709c]:
- File
src/OFNumber.m
— part of check-in
[e1e7ffa903]
at
2011-09-22 23:25:42
on branch trunk
— Exceptions are now autoreleased.
This is safe as an "exception loop" can't happen, since if allocating
an exception fails, it throws an OFAllocFailedException which is
preallocated and can always be thrown.So, the worst case would be that an autorelease of an exception fails,
triggering an OFOutOfMemoryException for which there is no memory,
resulting in an OFAllocFailedException to be thrown. (user: js, size: 28115) [annotate] [blame] [check-ins using]
︙ | |||
80 81 82 83 84 85 86 | 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | - + + | case OF_NUMBER_UINTPTR: \ return (t)value.uintptr; \ case OF_NUMBER_FLOAT: \ return (t)value.float_; \ case OF_NUMBER_DOUBLE: \ return (t)value.double_; \ default: \ |
︙ | |||
163 164 165 166 167 168 169 | 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | - + + | case OF_NUMBER_FLOAT: \ return [OFNumber numberWithFloat: \ value.float_ o [n floatValue]]; \ case OF_NUMBER_DOUBLE: \ return [OFNumber numberWithDouble: \ value.double_ o [n doubleValue]]; \ default: \ |
︙ | |||
241 242 243 244 245 246 247 | 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | - - + + + - + + | return [OFNumber numberWithIntPtr: \ value.intptr o [n intPtrValue]]; \ case OF_NUMBER_UINTPTR: \ return [OFNumber numberWithUIntPtr: \ value.uintptr o [n uIntPtrValue]]; \ case OF_NUMBER_FLOAT: \ case OF_NUMBER_DOUBLE: \ |
︙ | |||
304 305 306 307 308 309 310 | 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | - + + | case OF_NUMBER_UINTPTR: \ return [OFNumber numberWithUIntPtr: value.uintptr o]; \ case OF_NUMBER_FLOAT: \ return [OFNumber numberWithFloat: value.float_ o]; \ case OF_NUMBER_DOUBLE: \ return [OFNumber numberWithDouble: value.double_ o]; \ default: \ |
︙ | |||
440 441 442 443 444 445 446 | 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 | - - + + | + numberWithDouble: (double)double_ { return [[[self alloc] initWithDouble: double_] autorelease]; } - init { |
︙ | |||
714 715 716 717 718 719 720 | 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 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 766 767 768 769 | - - + + + - - + + - - + + + | @try { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFString *typeString; if (![[element name] isEqual: [self className]] || ![[element namespace] isEqual: OF_SERIALIZATION_NS]) |
︙ | |||
1114 1115 1116 1117 1118 1119 1120 | 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 | - + | case OF_NUMBER_FLOAT: return [OFNumber numberWithFloat: fmodf(value.float_, [number floatValue])]; case OF_NUMBER_DOUBLE: return [OFNumber numberWithDouble: fmod(value.double_, [number doubleValue])]; default: |
︙ | |||
1158 1159 1160 1161 1162 1163 1164 | 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 | - + | case OF_NUMBER_INTPTR: return [OFString stringWithFormat: @"%jd", [self intMaxValue]]; case OF_NUMBER_FLOAT: return [OFString stringWithFormat: @"%g", value.float_]; case OF_NUMBER_DOUBLE: return [OFString stringWithFormat: @"%lg", value.double_]; default: |
︙ | |||
1220 1221 1222 1223 1224 1225 1226 | 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 | - + | [element addAttributeWithName: @"type" stringValue: @"double"]; [element setStringValue: [OFString stringWithFormat: @"%la", value.double_]]; break; default: |