Overview
Comment: | bridge: Add bridging for {OF,NS}Enumerator |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
7080ad2ebf33e16a63ca487ff0f7c2fb |
User & Date: | js on 2019-06-18 01:54:23 |
Other Links: | manifest | tags |
Context
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 | |
01:42 | bridge: Fix missing deallocs check-in: d2886a005f user: js tags: trunk | |
Changes
Modified src/bridge/Makefile from [f31f6bb273] to [e674b06e1c].
︙ | ︙ | |||
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | INCLUDES := ${SRCS:.m=.h} \ NSBridging.h \ OFBridging.h \ ObjFWBridge.h SRCS += NSOFArray.m \ NSOFDictionary.m \ OFNSArray.m \ OFNSDictionary.m \ includesubdir = ObjFWBridge include ../../buildsys.mk CPPFLAGS += -I. -I.. -I../.. -I../exceptions -DOF_BRIDGE_LOCAL_INCLUDES LD = ${OBJC} | > > | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | INCLUDES := ${SRCS:.m=.h} \ NSBridging.h \ OFBridging.h \ ObjFWBridge.h SRCS += NSOFArray.m \ NSOFDictionary.m \ NSOFEnumerator.m \ OFNSArray.m \ OFNSDictionary.m \ OFNSEnumerator.m includesubdir = ObjFWBridge include ../../buildsys.mk CPPFLAGS += -I. -I.. -I../.. -I../exceptions -DOF_BRIDGE_LOCAL_INCLUDES LD = ${OBJC} |
︙ | ︙ |
Modified src/bridge/NSOFDictionary.m from [08a371f09a] to [6b0e3be066].
︙ | ︙ | |||
12 13 14 15 16 17 18 19 20 21 22 23 24 25 | * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "NSOFDictionary.h" #import "OFDictionary.h" #import "NSBridging.h" #import "OFBridging.h" #import "OFOutOfRangeException.h" | > | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "NSOFDictionary.h" #import "NSOFEnumerator.h" #import "OFDictionary.h" #import "NSBridging.h" #import "OFBridging.h" #import "OFOutOfRangeException.h" |
︙ | ︙ | |||
59 60 61 62 63 64 65 66 | size_t count = _dictionary.count; if (count > NSUIntegerMax) @throw [OFOutOfRangeException exception]; return (NSUInteger)count; } @end | > > > > > > | 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | size_t count = _dictionary.count; if (count > NSUIntegerMax) @throw [OFOutOfRangeException exception]; return (NSUInteger)count; } - (NSEnumerator *)keyEnumerator { return [[[NSOFEnumerator alloc] initWithOFEnumerator: [_dictionary keyEnumerator]] autorelease]; } @end |
Added src/bridge/NSOFEnumerator.h version [ceab83fad6].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | /* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, * 2018, 2019 * Jonathan Schleifer <js@heap.zone> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import <Foundation/NSEnumerator.h> #import "macros.h" @class OFEnumerator; OF_ASSUME_NONNULL_BEGIN @interface NSOFEnumerator: NSEnumerator { OFEnumerator *_enumerator; } - (instancetype)initWithOFEnumerator: (OFEnumerator *)enumerator; @end OF_ASSUME_NONNULL_END |
Added src/bridge/NSOFEnumerator.m version [1bfad925c7].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | /* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, * 2018, 2019 * Jonathan Schleifer <js@heap.zone> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "NSOFEnumerator.h" #import "OFEnumerator.h" #import "NSBridging.h" #import "OFBridging.h" @implementation NSOFEnumerator - (instancetype)initWithOFEnumerator: (OFEnumerator *)enumerator { if ((self = [super init]) != nil) _enumerator = [enumerator retain]; return self; } - (void)dealloc { [_enumerator release]; [super dealloc]; } - (id)nextObject { id object = [_enumerator nextObject]; if ([(OFObject *)object conformsToProtocol: @protocol(OFBridging)]) return [object NSObject]; return object; } @end |
Modified src/bridge/OFNSArray.m from [265432c593] to [1c099082bd].
︙ | ︙ | |||
16 17 18 19 20 21 22 | */ #import <Foundation/NSArray.h> #import "OFNSArray.h" #import "NSBridging.h" | | | < | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | */ #import <Foundation/NSArray.h> #import "OFNSArray.h" #import "NSBridging.h" #import "OFInvalidArgumentException.h" #import "OFOutOfRangeException.h" @implementation OFNSArray - (instancetype)initWithNSArray: (NSArray *)array { self = [super init]; @try { if (array == nil) @throw [OFInvalidArgumentException exception]; _array = [array retain]; } @catch (id e) { [self release]; @throw e; } |
︙ | ︙ |
Modified src/bridge/OFNSDictionary.m from [3e5d86d339] to [d1ad9f6edf].
︙ | ︙ | |||
14 15 16 17 18 19 20 21 22 23 24 | * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import <Foundation/NSDictionary.h> #import "OFNSDictionary.h" #import "NSBridging.h" #import "OFBridging.h" | > | | < | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import <Foundation/NSDictionary.h> #import "OFNSDictionary.h" #import "OFNSEnumerator.h" #import "NSBridging.h" #import "OFBridging.h" #import "OFInvalidArgumentException.h" @implementation OFNSDictionary - (instancetype)initWithNSDictionary: (NSDictionary *)dictionary { self = [super init]; @try { if (dictionary == nil) @throw [OFInvalidArgumentException exception]; _dictionary = [dictionary retain]; } @catch (id e) { [self release]; @throw e; } |
︙ | ︙ | |||
65 66 67 68 69 70 71 72 | return object; } - (size_t)count { return _dictionary.count; } @end | > > > > > > | 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | return object; } - (size_t)count { return _dictionary.count; } - (OFEnumerator *)keyEnumerator { return [[[OFNSEnumerator alloc] initWithNSEnumerator: [_dictionary keyEnumerator]] autorelease]; } @end |
Added src/bridge/OFNSEnumerator.h version [eef282bd93].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | /* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, * 2018, 2019 * Jonathan Schleifer <js@heap.zone> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #ifdef OF_BRIDGE_LOCAL_INCLUDES # import "OFEnumerator.h" #else # if defined(__has_feature) && __has_feature(modules) @import ObjFW; # else # import <ObjFW/OFEnumerator.h> # endif #endif OF_ASSUME_NONNULL_BEGIN @class NSEnumerator; @interface OFNSEnumerator: OFEnumerator { NSEnumerator *_enumerator; } - (instancetype)initWithNSEnumerator: (NSEnumerator *)enumerator; @end OF_ASSUME_NONNULL_END |
Added src/bridge/OFNSEnumerator.m version [f46fa6b701].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 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 57 58 59 60 61 | /* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, * 2018, 2019 * Jonathan Schleifer <js@heap.zone> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import <Foundation/NSEnumerator.h> #import "OFNSEnumerator.h" #import "NSBridging.h" #import "OFBridging.h" #import "OFInvalidArgumentException.h" @implementation OFNSEnumerator - (instancetype)initWithNSEnumerator: (NSEnumerator *)enumerator { self = [super init]; @try { if (enumerator == nil) @throw [OFInvalidArgumentException exception]; _enumerator = [enumerator retain]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_enumerator release]; [super dealloc]; } - (id)nextObject { id object = [_enumerator nextObject]; if ([(NSObject *)object conformsToProtocol: @protocol(NSBridging)]) return [object OFObject]; return object; } @end |