From 28a6e6ebbd1af611adecebd6228b5a80ada61525 Mon Sep 17 00:00:00 2001 From: rfm Date: Thu, 25 Jul 2024 17:11:34 +0100 Subject: [PATCH] Final batch of GC cleanups (for the forseeable future). --- ChangeLog | 37 +++++++++++++++++++++++++++++ Headers/Foundation/NSHashTable.h | 8 ++----- Headers/Foundation/NSMapTable.h | 20 ---------------- Headers/Foundation/NSPointerArray.h | 2 +- Source/NSHashTable.m | 5 ++-- Source/NSMapTable.m | 24 +++++++++---------- Source/NSPointerArray.m | 8 +++++-- 7 files changed, 61 insertions(+), 43 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5158c8592..6337cc88c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,40 @@ +2024-07-25 Richard Frith-Macdonald + + * Headers/Foundation/NSHashTable.h: + * Headers/Foundation/NSMapTable.h: + * Headers/Foundation/NSPointerArray.h: + * Headers/Foundation/NSPointerFunctions.h: + * Headers/Foundation/NSZone.h: + * Headers/GNUstepBase/config.h.in: + * Source/GSSocketStream.m: + * Source/GSStream.m: + * Source/NSConcreteHashTable.m: + * Source/NSConcreteMapTable.m: + * Source/NSConcretePointerFunctions.h: + * Source/NSConcretePointerFunctions.m: + * Source/NSConnection.m: + * Source/NSHashTable.m: + * Source/NSKeyedArchiver.m: + * Source/NSKeyedUnarchiver.m: + * Source/NSKeyValueObserving.m: + * Source/NSMapTable.m: + * Source/NSPointerArray.m: + * Source/NSPort.m: + * Source/NSZone.m: + * Tests/base/NSHashTable/create.m: + * Tests/base/NSHashTable/weakObjects.m: + * Tests/base/NSIndexSet/enumerateRanges.m: + * Tests/base/NSMapTable/create.m: + * Tests/base/NSMapTable/weakObjects.m: + * Tests/base/NSPointerArray/weakObjects.m: + * Tests/base/NSPointerFunctions/basic.m: + * Tests/base/NSPointerFunctions/general.m: + * Tests/base/NSPointerFunctions/TestInfo: + General fixups for pointer functions, removing obsolete (non-working) + GC related internal code. There is probably still a little of that old + stuff lurking in the internals which should be removed when found, but + the vast majority is cleaned up. + 2024-07-15 Richard Frith-Macdonald * Headers/Foundation/NSPointerFunctions.h: deprecate GC methods. diff --git a/Headers/Foundation/NSHashTable.h b/Headers/Foundation/NSHashTable.h index 0359f06e3..1f0c75574 100644 --- a/Headers/Foundation/NSHashTable.h +++ b/Headers/Foundation/NSHashTable.h @@ -66,16 +66,12 @@ GS_EXPORT_CLASS + (instancetype) hashTableWithOptions: (NSPointerFunctionsOptions)options; -+ (instancetype) hashTableWithWeakObjects; -/** - * Creates a hash table that uses zeroing weak references (either using the - * automatic reference counting or garbage collection mechanism, depending on - * which mode this framework is compiled in) so that objects are removed when +/** Creates a hash table that uses weak references (using the automatic + * reference counting mechanism) so that objects are removed when * their last other reference disappears. */ + (instancetype) weakObjectsHashTable; - - (instancetype) initWithOptions: (NSPointerFunctionsOptions)options capacity: (NSUInteger)initialCapacity; diff --git a/Headers/Foundation/NSMapTable.h b/Headers/Foundation/NSMapTable.h index 11d95601a..abe4d7549 100644 --- a/Headers/Foundation/NSMapTable.h +++ b/Headers/Foundation/NSMapTable.h @@ -68,26 +68,6 @@ GS_EXPORT_CLASS + (instancetype) mapTableWithKeyOptions: (NSPointerFunctionsOptions)keyOptions valueOptions: (NSPointerFunctionsOptions)valueOptions; -/** Convenience method for creating a map table to store object values - * using object keys. - */ -+ (instancetype) mapTableWithStrongToStrongObjects; - -/** Convenience method for creating a map table to store non-retained - * object values with retained object keys. - */ -+ (instancetype) mapTableWithStrongToWeakObjects; - -/** Convenience method for creating a map table to store retained - * object values with non-retained object keys. - */ -+ (instancetype) mapTableWithWeakToStrongObjects; - -/** Convenience method for creating a map table to store non-retained - * object values with non-retained object keys. - */ -+ (instancetype) mapTableWithWeakToWeakObjects; - /** Convenience method for creating a map table to store object values * using object keys. The collection will retain both the key and the value. */ diff --git a/Headers/Foundation/NSPointerArray.h b/Headers/Foundation/NSPointerArray.h index 8b5be60a5..91aae1f35 100644 --- a/Headers/Foundation/NSPointerArray.h +++ b/Headers/Foundation/NSPointerArray.h @@ -59,7 +59,7 @@ GS_EXPORT_CLASS * objects. */ + (id) strongObjectsPointerArray; -/** Returns a new pointer array for storing zeroing weak references to objects. +/** Returns a new pointer array for storing weak references to objects. */ + (id) weakObjectsPointerArray; diff --git a/Source/NSHashTable.m b/Source/NSHashTable.m index 48aa430c9..908eed339 100644 --- a/Source/NSHashTable.m +++ b/Source/NSHashTable.m @@ -72,8 +72,9 @@ + (id) hashTableWithOptions: (NSPointerFunctionsOptions)options + (id) hashTableWithWeakObjects { - return [self hashTableWithOptions: - NSPointerFunctionsObjectPersonality | NSPointerFunctionsWeakMemory]; + GSOnceMLog(@"Garbage Collection no longer supported." + @" Using +weakObjectsHashTable"); + return [self weakObjectsHashTable]; } + (id) weakObjectsHashTable diff --git a/Source/NSMapTable.m b/Source/NSMapTable.m index 83428fe68..200a32a41 100644 --- a/Source/NSMapTable.m +++ b/Source/NSMapTable.m @@ -72,30 +72,30 @@ + (id) mapTableWithKeyOptions: (NSPointerFunctionsOptions)keyOptions + (id) mapTableWithStrongToStrongObjects { - return [self mapTableWithKeyOptions: NSPointerFunctionsObjectPersonality - valueOptions: NSPointerFunctionsObjectPersonality]; + GSOnceMLog(@"Garbage Collection no longer supported." + @" Using +strongToStrongObjectsMapTable"); + return [self strongToStrongObjectsMapTable]; } + (id) mapTableWithStrongToWeakObjects { - return [self mapTableWithKeyOptions: NSPointerFunctionsObjectPersonality - valueOptions: NSPointerFunctionsObjectPersonality - | NSPointerFunctionsWeakMemory]; + GSOnceMLog(@"Garbage Collection no longer supported." + @" Using +strongToWeakObjectsMapTable"); + return [self strongToWeakObjectsMapTable]; } + (id) mapTableWithWeakToStrongObjects { - return [self mapTableWithKeyOptions: NSPointerFunctionsObjectPersonality - | NSPointerFunctionsWeakMemory - valueOptions: NSPointerFunctionsObjectPersonality]; + GSOnceMLog(@"Garbage Collection no longer supported." + @" Using +weakToStringObjectsMapTable"); + return [self weakToStringObjectsMapTable]; } + (id) mapTableWithWeakToWeakObjects { - return [self mapTableWithKeyOptions: NSPointerFunctionsObjectPersonality - | NSPointerFunctionsWeakMemory - valueOptions: NSPointerFunctionsObjectPersonality - | NSPointerFunctionsWeakMemory]; + GSOnceMLog(@"Garbage Collection no longer supported." + @" Using +weakToWeakObjectsMapTable"); + return [self weakToWeakObjectsMapTable]; } + (id) strongToStrongObjectsMapTable diff --git a/Source/NSPointerArray.m b/Source/NSPointerArray.m index 32ade60e6..9a1d9a0f0 100644 --- a/Source/NSPointerArray.m +++ b/Source/NSPointerArray.m @@ -204,12 +204,16 @@ @implementation NSPointerArray (NSArrayConveniences) + (id) pointerArrayWithStrongObjects { - return [self pointerArrayWithOptions: NSPointerFunctionsStrongMemory]; + GSOnceMLog(@"Garbage Collection no longer supported." + @" Using +strongObjectsPointerArray"); + return [self strongObjectsPointerArray]; } + (id) pointerArrayWithWeakObjects { - return [self pointerArrayWithOptions: NSPointerFunctionsWeakMemory]; + GSOnceMLog(@"Garbage Collection no longer supported." + @" Using +weakObjectsPointerArray"); + return [self weakObjectsPointerArray]; } - (NSArray*) allObjects