Add some simple pointer functions personality tests

This commit is contained in:
rfm 2024-07-16 12:07:32 +01:00
parent 4629a4e1f6
commit b677ea402a
4 changed files with 250 additions and 5 deletions

View file

@ -186,6 +186,13 @@ relinquishRetainedMemory(const void *item,
- (id) initWithOptions: (NSPointerFunctionsOptions)options
{
#define Unsupported(X) ({\
NSLog(@"*** An unsupported PointerFunctions configuration was requested,"\
@" probably for use by NSMapTable, NSHashTable, or NSPointerArray. %@",\
X);\
DESTROY(self);\
})
_x.options = options;
/* First we look at the memory management options to see which function
@ -252,10 +259,18 @@ relinquishRetainedMemory(const void *item,
}
else if (personalityType(options, NSPointerFunctionsIntegerPersonality))
{
_x.acquireFunction = acquireExistingMemory;
_x.descriptionFunction = describeInteger;
_x.hashFunction = hashDirect;
_x.isEqualFunction = equalDirect;
if (memoryType(options, NSPointerFunctionsOpaqueMemory))
{
_x.acquireFunction = acquireExistingMemory;
_x.descriptionFunction = describeInteger;
_x.hashFunction = hashDirect;
_x.isEqualFunction = equalDirect;
}
else
{
Unsupported(@"The requested configuration fails due to"
@" integer personality not using opaque memory.");
}
}
else /* objects */
{
@ -272,7 +287,6 @@ relinquishRetainedMemory(const void *item,
_x.isEqualFunction = equalObject;
}
return self;
}