Fully type method implementatyion pointers.

This commit is contained in:
Richard Frith-Macdonald 2020-04-15 10:31:55 +01:00
parent 4e98c82396
commit 09e9354f08
8 changed files with 35 additions and 31 deletions

View file

@ -115,7 +115,7 @@ static SEL objSel;
{
NSUInteger count = map.nodeCount;
SEL sel = @selector(encodeObject:);
IMP imp = [aCoder methodForSelector: sel];
id (*imp)(id,SEL,id) = [aCoder methodForSelector: sel];
GSIMapEnumerator_t enumerator = GSIMapEnumeratorForMap(&map);
GSIMapNode node = GSIMapEnumeratorNextNode(&enumerator);
@ -152,7 +152,7 @@ static SEL objSel;
id key;
id value;
SEL sel = @selector(decodeValueOfObjCType:at:);
IMP imp = [aCoder methodForSelector: sel];
void (*imp)(id,SEL,const char*,void*) = [aCoder methodForSelector: sel];
const char *type = @encode(id);
[aCoder decodeValueOfObjCType: @encode(NSUInteger)
@ -220,8 +220,8 @@ static SEL objSel;
if (c > 0)
{
NSEnumerator *e = [other keyEnumerator];
IMP nxtObj = [e methodForSelector: nxtSel];
IMP otherObj = [other methodForSelector: objSel];
id (*nxtObj)(id, SEL) = [e methodForSelector: nxtSel];
id (*otherObj)(id, SEL, id) = [other methodForSelector: objSel];
BOOL isProxy = [other isProxy];
NSUInteger i;
@ -293,7 +293,7 @@ static SEL objSel;
{
GSIMapEnumerator_t enumerator;
GSIMapNode node;
IMP otherObj = [other methodForSelector: objSel];
id (*otherObj)(id, SEL, id) = [other methodForSelector: objSel];
enumerator = GSIMapEnumeratorForMap(&map);
while ((node = GSIMapEnumeratorNextNode(&enumerator)) != 0)

View file

@ -132,6 +132,7 @@ static NSString *CteContentType = @"content-type";
static NSString *CteQuotedPrintable = @"quoted-printable";
static NSString *CteXuuencode = @"x-uuencode";
typedef id (*oaiIMP)(id, SEL, NSUInteger);
typedef BOOL (*boolIMP)(id, SEL, id);
static char *hex = "0123456789ABCDEF";
@ -6184,12 +6185,12 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold,
if (count > 0)
{
IMP imp1;
oaiIMP imp1;
boolIMP imp2;
name = [name lowercaseString];
imp1 = [headers methodForSelector: @selector(objectAtIndex:)];
imp1 = (oaiIMP)[headers methodForSelector: @selector(objectAtIndex:)];
imp2 = (boolIMP)[name methodForSelector: @selector(isEqualToString:)];
while (count-- > 0)
{
@ -6330,11 +6331,11 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold,
if (count > 0)
{
NSUInteger index;
IMP imp1;
oaiIMP imp1;
boolIMP imp2;
name = [headerClass makeToken: name preservingCase: NO];
imp1 = [headers methodForSelector: @selector(objectAtIndex:)];
imp1 = (oaiIMP)[headers methodForSelector: @selector(objectAtIndex:)];
imp2 = (boolIMP)[name methodForSelector: @selector(isEqualToString:)];
for (index = 0; index < count; index++)
{
@ -6364,10 +6365,10 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold,
{
NSUInteger index;
NSMutableArray *array;
IMP imp1;
oaiIMP imp1;
boolIMP imp2;
imp1 = [headers methodForSelector: @selector(objectAtIndex:)];
imp1 = (oaiIMP)[headers methodForSelector: @selector(objectAtIndex:)];
imp2 = (boolIMP)[name methodForSelector: @selector(isEqualToString:)];
array = [NSMutableArray array];
@ -7285,10 +7286,10 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold,
if (count > 0)
{
NSUInteger index;
IMP imp1;
oaiIMP imp1;
boolIMP imp2;
imp1 = [headers methodForSelector: @selector(objectAtIndex:)];
imp1 = (oaiIMP)[headers methodForSelector: @selector(objectAtIndex:)];
imp2 = (boolIMP)[name methodForSelector: @selector(isEqualToString:)];
for (index = 0; index < count; index++)
{
@ -7310,10 +7311,10 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold,
if (count > 0)
{
IMP imp1;
oaiIMP imp1;
boolIMP imp2;
imp1 = [headers methodForSelector: @selector(objectAtIndex:)];
imp1 = (oaiIMP)[headers methodForSelector: @selector(objectAtIndex:)];
imp2 = (boolIMP)[name methodForSelector: @selector(isEqualToString:)];
while (count-- > 0)
{

View file

@ -1983,7 +1983,7 @@ GSAutoreleasedBuffer(unsigned size)
static Class buffer_class = 0;
static Class autorelease_class;
static SEL autorelease_sel;
static IMP autorelease_imp;
static id (*autorelease_imp)(Class, SEL, id);
static int instance_size;
static int offset;
NSObject *o;
@ -1995,7 +1995,8 @@ GSAutoreleasedBuffer(unsigned size)
offset = instance_size % ALIGN;
autorelease_class = [NSAutoreleasePool class];
autorelease_sel = @selector(addObject:);
autorelease_imp = [autorelease_class methodForSelector: autorelease_sel];
autorelease_imp = (id (*)(Class, SEL, id))
[autorelease_class methodForSelector: autorelease_sel];
}
o = (NSObject*)NSAllocateObject(buffer_class,
size + offset, NSDefaultMallocZone());
@ -2065,7 +2066,9 @@ GSPrintf (FILE *fptr, NSString* format, ...)
# define AADD(c, o)
# define AREM(c, o)
# endif
#else
# define AADD(c, o)
# define AREM(c, o)
#endif /* defined(GNUSTEP_BASE_LIBRARY) */
void

View file

@ -104,7 +104,7 @@
*/
static Class NSString_class;
static Class treeClass;
static IMP usImp;
static id (*usImp)(id, SEL, const char*);
static SEL usSel;
static xmlExternalEntityLoader originalLoader = NULL;
@ -166,7 +166,8 @@ setupCache()
xmlDefaultSAXHandlerInit();
NSString_class = [NSString class];
usSel = @selector(stringWithUTF8String:);
usImp = [NSString_class methodForSelector: usSel];
usImp = (id (*)(id, SEL, const char*))
[NSString_class methodForSelector: usSel];
treeClass = [GSTreeSAXHandler class];
}
}

View file

@ -38,7 +38,7 @@
NSUInteger lower = 0;
NSUInteger index;
SEL oaiSel;
IMP oai;
id (*oai)(id,SEL,NSUInteger);
if (item == nil)
{
@ -52,7 +52,7 @@
}
oaiSel = @selector(objectAtIndex:);
oai = [self methodForSelector: oaiSel];
oai = (id(*)(id,SEL,NSUInteger))[self methodForSelector: oaiSel];
/*
* Binary search for an item equal to the one to be inserted.
*/
@ -95,7 +95,7 @@
NSUInteger index;
NSComparisonResult (*imp)(id, SEL, id);
SEL oaiSel;
IMP oai;
id (*oai)(id,SEL,NSUInteger);
if (item == nil)
{
@ -115,7 +115,7 @@
}
oaiSel = @selector(objectAtIndex:);
oai = [self methodForSelector: oaiSel];
oai = (id(*)(id,SEL,NSUInteger))[self methodForSelector: oaiSel];
/*
* Binary search for an item equal to the one to be inserted.
*/

View file

@ -27,6 +27,7 @@
#import "Foundation/NSException.h"
#import "Foundation/NSHashTable.h"
#import "Foundation/NSLock.h"
#import "GNUstepBase/GSObjCRuntime.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#import "GNUstepBase/NSDebug+GNUstepBase.h"
#import "GNUstepBase/NSThread+GNUstepBase.h"
@ -327,10 +328,6 @@ handleExit()
#else
#if __has_include(<objc/runtime.h>)
# include <objc/runtime.h>
#endif
@implementation NSObject (MemoryFootprint)
+ (NSUInteger) contentSizeOf: (NSObject*)obj
excluding: (NSHashTable*)exclude

View file

@ -39,7 +39,7 @@ static BOOL debugTemporarilyDisabled = NO;
BOOL GSDebugSet(NSString *level)
{
static IMP debugImp = 0;
static id (*debugImp)(id,SEL,id) = 0;
static SEL debugSel;
if (debugTemporarilyDisabled == YES)

View file

@ -415,7 +415,8 @@ OAppend(id obj, NSDictionary *loc, unsigned lev, unsigned step,
const char *iBaseString;
const char *iSizeString;
SEL objSel = @selector(objectForKey:);
IMP myObj = [obj methodForSelector: objSel];
id (*myObj)(id,SEL,id)
= (id(*)(id,SEL,id))[obj methodForSelector: objSel];
unsigned i;
NSArray *keyArray = [obj allKeys];
unsigned numKeys = [keyArray count];
@ -642,7 +643,8 @@ OAppend(id obj, NSDictionary *loc, unsigned lev, unsigned step,
OAppend(aPropertyList, loc, 0, step > 3 ? 3 : step, dest);
return dest;
}
return (*originalImp)(self, _cmd, aPropertyList, aFormat, anErrorString);
return (*(id(*)(id,SEL,id,id,id))originalImp)
(self, _cmd, aPropertyList, aFormat, anErrorString);
}
+ (void) load