@@ -1,7 +1,7 @@ /* - * Copyright (c) 2008-2022 Jonathan Schleifer + * Copyright (c) 2008-2024 Jonathan Schleifer * * 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 @@ -15,50 +15,50 @@ #include "config.h" #include -#import "OFMutableMapTableDictionary.h" +#import "OFConcreteMutableDictionary.h" #import "OFArray.h" #import "OFString.h" static struct { Class isa; } placeholder; -@interface OFMutableDictionaryPlaceholder: OFDictionary +@interface OFPlaceholderMutableDictionary: OFDictionary @end -@implementation OFMutableDictionaryPlaceholder +@implementation OFPlaceholderMutableDictionary - (instancetype)init { - return (id)[[OFMutableMapTableDictionary alloc] init]; + return (id)[[OFConcreteMutableDictionary alloc] init]; } - (instancetype)initWithDictionary: (OFDictionary *)dictionary { - return (id)[[OFMutableMapTableDictionary alloc] + return (id)[[OFConcreteMutableDictionary alloc] initWithDictionary: dictionary]; } - (instancetype)initWithObject: (id)object forKey: (id)key { - return (id)[[OFMutableMapTableDictionary alloc] initWithObject: object + return (id)[[OFConcreteMutableDictionary alloc] initWithObject: object forKey: key]; } - (instancetype)initWithObjects: (OFArray *)objects forKeys: (OFArray *)keys { - return (id)[[OFMutableMapTableDictionary alloc] initWithObjects: objects + return (id)[[OFConcreteMutableDictionary alloc] initWithObjects: objects forKeys: keys]; } - (instancetype)initWithObjects: (id const *)objects forKeys: (id const *)keys count: (size_t)count { - return (id)[[OFMutableMapTableDictionary alloc] initWithObjects: objects + return (id)[[OFConcreteMutableDictionary alloc] initWithObjects: objects forKeys: keys count: count]; } - (instancetype)initWithKeysAndObjects: (id)firstKey, ... @@ -65,60 +65,38 @@ { id ret; va_list arguments; va_start(arguments, firstKey); - ret = (id)[[OFMutableMapTableDictionary alloc] initWithKey: firstKey + ret = (id)[[OFConcreteMutableDictionary alloc] initWithKey: firstKey arguments: arguments]; va_end(arguments); return ret; } - (instancetype)initWithKey: (id)firstKey arguments: (va_list)arguments { - return (id)[[OFMutableMapTableDictionary alloc] initWithKey: firstKey + return (id)[[OFConcreteMutableDictionary alloc] initWithKey: firstKey arguments: arguments]; } -- (instancetype)initWithSerialization: (OFXMLElement *)element -{ - return (id)[[OFMutableMapTableDictionary alloc] - initWithSerialization: element]; -} - - (instancetype)initWithCapacity: (size_t)capacity { - return (id)[[OFMutableMapTableDictionary alloc] + return (id)[[OFConcreteMutableDictionary alloc] initWithCapacity: capacity]; } -- (instancetype)retain -{ - return self; -} - -- (instancetype)autorelease -{ - return self; -} - -- (void)release -{ -} - -- (void)dealloc -{ - OF_DEALLOC_UNSUPPORTED -} +OF_SINGLETON_METHODS @end @implementation OFMutableDictionary + (void)initialize { if (self == [OFMutableDictionary class]) - placeholder.isa = [OFMutableDictionaryPlaceholder class]; + object_setClass((id)&placeholder, + [OFPlaceholderMutableDictionary class]); } + (instancetype)alloc { if (self == [OFMutableDictionary class]) @@ -132,28 +110,33 @@ return [[[self alloc] initWithCapacity: capacity] autorelease]; } - (instancetype)init { - if ([self isMemberOfClass: [OFMutableDictionary class]]) { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); - } - return [super init]; } + +#ifdef __clang__ +/* We intentionally don't call into super, so silence the warning. */ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wunknown-pragmas" +# pragma clang diagnostic ignored "-Wobjc-designated-initializers" +#endif +- (instancetype)initWithObjects: (id const *)objects + forKeys: (id const *)keys + count: (size_t)count +{ + OF_INVALID_INIT_METHOD +} - (instancetype)initWithCapacity: (size_t)capacity { OF_INVALID_INIT_METHOD } +#ifdef __clang__ +# pragma clang diagnostic pop +#endif - (void)setObject: (id)object forKey: (id)key { OF_UNRECOGNIZED_SELECTOR }