Comment: | Give the methods in OFNumber better names. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
2517f18272a108103af74d5f46e13e66 |
User & Date: | js on 2010-04-17 16:09:37 |
Other Links: | manifest | tags |
2010-04-17
| ||
16:55 | More consistency in names of file operations. check-in: 2eb2172a96 user: js tags: trunk | |
16:09 | Give the methods in OFNumber better names. check-in: 2517f18272 user: js tags: trunk | |
16:01 | Add class OFHash as a superclass for OFMD5Hash and OFSHA1Hash. check-in: d28c998082 user: js tags: trunk | |
Modified src/OFArray.m from [00e1708140] to [9a33d23f86].
︙ | ︙ | |||
182 183 184 185 186 187 188 | } - (id*)cArray { return [array cArray]; } | | | | 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | } - (id*)cArray { return [array cArray]; } - copy { return [self retain]; } - mutableCopy { OFArray *new = [[OFMutableArray alloc] init]; OFObject **objs; size_t count, i; objs = [array cArray]; count = [array count]; |
︙ | ︙ |
Modified src/OFDataArray.m from [36d514b98b] to [cb1099f8ad].
︙ | ︙ | |||
182 183 184 185 186 187 188 | withSize: itemsize]; } @catch (OFOutOfMemoryException *e) { /* We don't really care, as we only made it smaller */ [e dealloc]; } } | | | 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | withSize: itemsize]; } @catch (OFOutOfMemoryException *e) { /* We don't really care, as we only made it smaller */ [e dealloc]; } } - copy { OFDataArray *new = [[OFDataArray alloc] initWithItemSize: itemsize]; [new addNItems: count fromCArray: data]; return new; } |
︙ | ︙ | |||
352 353 354 355 356 357 358 | if (size != nsize) data = [self resizeMemory: data toSize: nsize]; size = nsize; } | | | 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 | if (size != nsize) data = [self resizeMemory: data toSize: nsize]; size = nsize; } - copy { OFDataArray *new = [[OFBigDataArray alloc] initWithItemSize: itemsize]; [new addNItems: count fromCArray: data]; return new; } @end |
Modified src/OFDictionary.m from [c58e028e47] to [469dcb5227].
︙ | ︙ | |||
568 569 570 571 572 573 574 | } - (size_t)count { return count; } | | | | 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 | } - (size_t)count { return count; } - copy { return [self retain]; } - mutableCopy { return [[OFMutableDictionary alloc] initWithDictionary: self]; } - (BOOL)isEqual: (OFDictionary*)dict { uint32_t i; |
︙ | ︙ |
Modified src/OFList.m from [3d67d61610] to [b9fb525575].
︙ | ︙ | |||
190 191 192 193 194 195 196 | /* One is bigger than the other although we checked the count */ assert(iter == NULL && iter2 == NULL); return YES; } | | | 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | /* One is bigger than the other although we checked the count */ assert(iter == NULL && iter2 == NULL); return YES; } - copy { OFList *new = [[OFList alloc] init]; of_list_object_t *iter, *o, *prev; o = NULL; prev = NULL; |
︙ | ︙ |
Modified src/OFMutableArray.m from [3a8b86073d] to [bad05b4309].
︙ | ︙ | |||
14 15 16 17 18 19 20 | #include <string.h> #import "OFMutableArray.h" #import "OFDataArray.h" #import "OFExceptions.h" @implementation OFMutableArray | | | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | #include <string.h> #import "OFMutableArray.h" #import "OFDataArray.h" #import "OFExceptions.h" @implementation OFMutableArray - copy { OFArray *new = [[OFArray alloc] init]; OFObject **objs; size_t count, i; objs = [array cArray]; count = [array count]; |
︙ | ︙ |
Modified src/OFMutableDictionary.m from [f5a5609e10] to [5339feda90].
︙ | ︙ | |||
223 224 225 226 227 228 229 | return [old autorelease]; } } return nil; } | | | 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | return [old autorelease]; } } return nil; } - copy { return [[OFDictionary alloc] initWithDictionary: self]; } - (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state objects: (id*)objects count: (int)count_ |
︙ | ︙ |
Modified src/OFMutableString.m from [276880c8d3] to [7172dc591d].
︙ | ︙ | |||
516 517 518 519 520 521 522 | toSize: length + 1]; } @catch (OFOutOfMemoryException *e) { /* We don't really care, as we only made it smaller */ [e dealloc]; } } | | | 516 517 518 519 520 521 522 523 524 525 526 527 | toSize: length + 1]; } @catch (OFOutOfMemoryException *e) { /* We don't really care, as we only made it smaller */ [e dealloc]; } } - copy { return [[OFString alloc] initWithString: self]; } @end |
Modified src/OFNumber.h from [35311fb8bd] to [c86cd5538d].
︙ | ︙ | |||
557 558 559 560 561 562 563 | */ - (double)asDouble; /** * \param num The OFNumber to add * \return A new autoreleased OFNumber added with the specified OFNumber */ | | | | | | | | | | | | | 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 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 609 610 611 612 613 614 615 616 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 | */ - (double)asDouble; /** * \param num The OFNumber to add * \return A new autoreleased OFNumber added with the specified OFNumber */ - (OFNumber*)numberByAdding: (OFNumber*)num; /** * \param num The OFNumber to substract * \return A new autoreleased OFNumber subtracted by the specified OFNumber */ - (OFNumber*)numberBySubtracting: (OFNumber*)num; /** * \param num The OFNumber to multiply with * \return A new autoreleased OFNumber multiplied with the specified OFNumber */ - (OFNumber*)numberByMultiplyingWith: (OFNumber*)num; /** * \param num The OFNumber to divide by * \return A new autoreleased OFNumber devided by the specified OFNumber */ - (OFNumber*)numberByDividingBy: (OFNumber*)num; /** * ANDs two OFNumbers, returning a new one. * * Does not work with floating point types! * * \param num The number to AND with. * \return A new autoreleased OFNumber ANDed with the specified OFNumber */ - (OFNumber*)numberByANDing: (OFNumber*)num; /** * ORs two OFNumbers, returning a new one. * * Does not work with floating point types! * * \param num The number to OR with. * \return A new autoreleased OFNumber ORed with the specified OFNumber */ - (OFNumber*)numberByORing: (OFNumber*)num; /** * XORs two OFNumbers, returning a new one. * * Does not work with floating point types! * * \param num The number to XOR with. * \return A new autoreleased OFNumber XORed with the specified OFNumber */ - (OFNumber*)numberByXORing: (OFNumber*)num; /** * Bitshifts the OFNumber to the left by the specified OFNumber, returning a new * one. * * Does not work with floating point types! * * \param num The number of bits to shift to the left * \return A new autoreleased OFNumber bitshifted to the left with the * specified OFNumber */ - (OFNumber*)numberByShiftingLeftBy: (OFNumber*)num; /** * Bitshifts the OFNumber to the right by the specified OFNumber, returning a * new one. * * Does not work with floating point types! * * \param num The number of bits to shift to the right * \return A new autoreleased OFNumber bitshifted to the right with the * specified OFNumber */ - (OFNumber*)numberByShiftingRightBy: (OFNumber*)num; /** * \return A new autoreleased OFNumber with the value increased by one. */ - (OFNumber*)numberByIncreasing; /** * \return A new autoreleased OFNumber with the value decreased by one. */ - (OFNumber*)numberByDecreasing; @end |
Modified src/OFNumber.m from [1856417314] to [1d85baa4c6].
︙ | ︙ | |||
860 861 862 863 864 865 866 | return hash; default: return [self asUInt32]; } } | | | | | | | | | | | | | 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 | return hash; default: return [self asUInt32]; } } - (OFNumber*)numberByAdding: (OFNumber*)num { CALCULATE(+, num) } - (OFNumber*)numberBySubtracting: (OFNumber*)num { CALCULATE(-, num) } - (OFNumber*)numberByMultiplyingWith: (OFNumber*)num { CALCULATE(*, num) } - (OFNumber*)numberByDividingBy: (OFNumber*)num { CALCULATE(/, num) } - (OFNumber*)numberByANDing: (OFNumber*)num { CALCULATE2(&, num) } - (OFNumber*)numberByORing: (OFNumber*)num { CALCULATE2(|, num) } - (OFNumber*)numberByXORing: (OFNumber*)num { CALCULATE2(^, num) } - (OFNumber*)numberByShiftingLeftBy: (OFNumber*)num { CALCULATE2(<<, num) } - (OFNumber*)numberByShiftingRightBy: (OFNumber*)num { CALCULATE2(>>, num) } - (OFNumber*)numberByIncreasing { CALCULATE3(+ 1) } - (OFNumber*)numberByDecreasing { CALCULATE3(- 1) } @end |
Modified src/OFObject.h from [c207812c2a] to [ed24092d00].
︙ | ︙ | |||
330 331 332 333 334 335 336 | /** * \brief A protocol for the creation of copies. */ @protocol OFCopying /** * \return A copy of the object */ | | | | 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 | /** * \brief A protocol for the creation of copies. */ @protocol OFCopying /** * \return A copy of the object */ - copy; @end /** * \brief A protocol for the creation of mutable copies. * * This protocol is implemented by objects that can be mutable and immutable * and allows returning a mutable copy. */ @protocol OFMutableCopying /** * \return A copy of the object */ - mutableCopy; @end extern size_t of_pagesize; |
Modified src/OFObject.m from [224d3accf3] to [7e95f15bf5].
︙ | ︙ | |||
618 619 620 621 622 623 624 | if (PRE_IVAR->memchunks != NULL) free(PRE_IVAR->memchunks); free((char*)self - PRE_IVAR_ALIGN); } /* Required to use properties with the Apple runtime */ | | | | 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 | if (PRE_IVAR->memchunks != NULL) free(PRE_IVAR->memchunks); free((char*)self - PRE_IVAR_ALIGN); } /* Required to use properties with the Apple runtime */ - copyWithZone: (void*)zone { if (zone != NULL) @throw [OFNotImplementedException newWithClass: isa selector: _cmd]; return [(id)self copy]; } - mutableCopyWithZone: (void*)zone { if (zone != NULL) @throw [OFNotImplementedException newWithClass: isa selector: _cmd]; return [(id)self mutableCopy]; } |
︙ | ︙ | |||
705 706 707 708 709 710 711 | + (void)dealloc { @throw [OFNotImplementedException newWithClass: self selector: _cmd]; } | | | | 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 | + (void)dealloc { @throw [OFNotImplementedException newWithClass: self selector: _cmd]; } + copyWithZone: (void*)zone { @throw [OFNotImplementedException newWithClass: self selector: _cmd]; } + mutableCopyWithZone: (void*)zone { @throw [OFNotImplementedException newWithClass: self selector: _cmd]; } @end |
Modified src/OFString.m from [228bd6589d] to [f0e2960871].
︙ | ︙ | |||
715 716 717 718 719 720 721 | return NO; if (strcmp(string, [(OFString*)obj cString])) return NO; return YES; } | | | | 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 | return NO; if (strcmp(string, [(OFString*)obj cString])) return NO; return YES; } - copy { return [self retain]; } - mutableCopy { return [[OFMutableString alloc] initWithString: self]; } - (of_comparison_result_t)compare: (OFString*)str { int cmp; |
︙ | ︙ |
Modified tests/OFNumberTests.m from [389ac325a5] to [6bab1566e0].
︙ | ︙ | |||
31 32 33 34 35 36 37 | TEST(@"-[isEqual:]", [num isEqual: [OFNumber numberWithUInt32: 123456789]]) TEST(@"-[hash]", [num hash] == 123456789) TEST(@"-[asDouble]", [num asDouble] == 123456789.L) | | > | | | > | | > | | > | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | TEST(@"-[isEqual:]", [num isEqual: [OFNumber numberWithUInt32: 123456789]]) TEST(@"-[hash]", [num hash] == 123456789) TEST(@"-[asDouble]", [num asDouble] == 123456789.L) TEST(@"-[numberByDecreasing]", [[num numberByDecreasing] isEqual: [OFNumber numberWithInt32: 123456788]]) TEST(@"-[numberByDividingBy:]", [[num numberByDividingBy: [OFNumber numberWithInt: 2]] asInt] == 61728394) TEST(@"-[numberByXORing:]", [[num numberByXORing: [OFNumber numberWithInt: 123456831]] asInt] == 42) TEST(@"-[numberByShiftingRightBy:]", [[num numberByShiftingRightBy: [OFNumber numberWithInt: 8]] asInt] == 482253) [pool drain]; } @end |