Overview
Comment: | OFDictionary: Add default -[objectEnumerator] |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
e2d0c876b44672a4edfdcb437d55d290 |
User & Date: | js on 2019-06-18 02:05:56 |
Other Links: | manifest | tags |
Context
2019-06-19
| ||
00:36 | OFDictionary: Add default for fast enumeration check-in: eeec8af349 user: js tags: trunk | |
2019-06-18
| ||
02:05 | OFDictionary: Add default -[objectEnumerator] check-in: e2d0c876b4 user: js tags: trunk | |
01:54 | bridge: Add bridging for {OF,NS}Enumerator check-in: 7080ad2ebf user: js tags: trunk | |
Changes
Modified src/OFDictionary.m from [bc54a55dea] to [b0c221b8b7].
︙ | ︙ | |||
21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #include <assert.h> #import "OFDictionary.h" #import "OFArray.h" #import "OFCharacterSet.h" #import "OFData.h" #import "OFMapTableDictionary.h" #import "OFString.h" #import "OFXMLElement.h" #import "OFInvalidArgumentException.h" #import "OFOutOfRangeException.h" #import "OFUndefinedKeyException.h" | > | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #include <assert.h> #import "OFDictionary.h" #import "OFArray.h" #import "OFCharacterSet.h" #import "OFData.h" #import "OFEnumerator.h" #import "OFMapTableDictionary.h" #import "OFString.h" #import "OFXMLElement.h" #import "OFInvalidArgumentException.h" #import "OFOutOfRangeException.h" #import "OFUndefinedKeyException.h" |
︙ | ︙ | |||
42 43 44 45 46 47 48 49 50 51 52 53 54 55 | @interface OFDictionary () - (OFString *)of_JSONRepresentationWithOptions: (int)options depth: (size_t)depth; @end @interface OFDictionaryPlaceholder: OFDictionary @end @interface OFURLQueryPartAllowedCharacterSet: OFCharacterSet + (OFCharacterSet *)URLQueryPartAllowedCharacterSet; @end @implementation OFDictionaryPlaceholder - (instancetype)init | > > > > > > > > > | 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | @interface OFDictionary () - (OFString *)of_JSONRepresentationWithOptions: (int)options depth: (size_t)depth; @end @interface OFDictionaryPlaceholder: OFDictionary @end @interface OFDictionaryObjectEnumerator: OFEnumerator { OFDictionary *_dictionary; OFEnumerator *_keyEnumerator; } - (instancetype)initWithDictionary: (OFDictionary *)dictionary; @end @interface OFURLQueryPartAllowedCharacterSet: OFCharacterSet + (OFCharacterSet *)URLQueryPartAllowedCharacterSet; @end @implementation OFDictionaryPlaceholder - (instancetype)init |
︙ | ︙ | |||
500 501 502 503 504 505 506 | - (OFEnumerator *)keyEnumerator { OF_UNRECOGNIZED_SELECTOR } - (OFEnumerator *)objectEnumerator { | | > | 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 | - (OFEnumerator *)keyEnumerator { OF_UNRECOGNIZED_SELECTOR } - (OFEnumerator *)objectEnumerator { return [[[OFDictionaryObjectEnumerator alloc] initWithDictionary: self] autorelease]; } - (int)countByEnumeratingWithState: (of_fast_enumeration_state_t *)state objects: (id *)objects count: (int)count { OF_UNRECOGNIZED_SELECTOR |
︙ | ︙ | |||
849 850 851 852 853 854 855 | [data makeImmutable]; objc_autoreleasePoolPop(pool); return data; } @end | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | [data makeImmutable]; objc_autoreleasePoolPop(pool); return data; } @end @implementation OFDictionaryObjectEnumerator - (instancetype)initWithDictionary: (OFDictionary *)dictionary { self = [super init]; @try { void *pool = objc_autoreleasePoolPush(); _dictionary = [dictionary retain]; _keyEnumerator = [[_dictionary keyEnumerator] retain]; objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_dictionary release]; [_keyEnumerator release]; [super dealloc]; } - (id)nextObject { id key = [_keyEnumerator nextObject]; id object; if (key == nil) return nil; if ((object = [_dictionary objectForKey: key]) == nil) @throw [OFInvalidArgumentException exception]; return object; } @end |