Use GSObjCRuntime functions for selector types until/unless we can get

a standard runtime API that handles them.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32240 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2011-02-20 07:58:11 +00:00
parent ca854a4b3c
commit 050f3f7190
7 changed files with 29 additions and 71 deletions

View file

@ -1,3 +1,14 @@
2011-02-20 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSDistributedNotificationCenter.m:
* Source/GSFFCallInvocation.m:
* Source/GSFFIInvocation.m:
* Source/common.h:
* Source/NSConnection.m:
* Source/NSData.m:
Use GSObjCRuntime functions for selector types until/unless we can get
a standard runtime API that handles them.
2011-02-19 Richard Frith-Macdonald <rfm@gnu.org> 2011-02-19 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSBundle.m: * Source/NSBundle.m:

View file

@ -922,7 +922,7 @@ GSInvocationCallback (void *callback_data, va_alist args)
selector = sel_getType_np(runtimeName, receiverTypes); selector = sel_getType_np(runtimeName, receiverTypes);
if (selector == 0) if (selector == 0)
{ {
selector = sel_registerTypedName_np(runtimeName, receiverTypes); selector = GSSelectorFromNameAndTypes(runtimeName, receiverTypes);
} }
if (runtimeTypes != 0) if (runtimeTypes != 0)
{ {

View file

@ -100,11 +100,7 @@ gs_method_for_receiver_and_selector (id receiver, SEL sel)
static INLINE SEL static INLINE SEL
gs_find_best_typed_sel (SEL sel) gs_find_best_typed_sel (SEL sel)
{ {
#ifdef __GNU_LIBOBJC__ if (!GSTypesFromSelector(sel))
if (!sel_getTypeEncoding(sel))
#else
if (!sel_getType_np(sel))
#endif
{ {
const char *name = sel_getName(sel); const char *name = sel_getName(sel);
@ -164,11 +160,7 @@ static IMP gs_objc_msg_forward2 (id receiver, SEL sel)
in the callback, but only under limited circumstances. in the callback, but only under limited circumstances.
*/ */
sel = gs_find_best_typed_sel(sel); sel = gs_find_best_typed_sel(sel);
#ifdef __GNU_LIBOBJC__ sel_type = GSTypesFromSelector(sel);
sel_type = sel_getTypeEncoding(sel);
#else
sel_type = sel_getType_np(sel);
#endif
if (sel_type) if (sel_type)
{ {
sig = [NSMethodSignature signatureWithObjCTypes: sel_type]; sig = [NSMethodSignature signatureWithObjCTypes: sel_type];
@ -557,17 +549,11 @@ GSFFIInvocationCallback(ffi_cif *cif, void *retp, void **args, void *user)
} }
sig = nil; sig = nil;
#ifdef __GNU_LIBOBJC__ if (gs_protocol_selector(GSTypesFromSelector(selector)) == YES)
if (gs_protocol_selector(sel_getTypeEncoding(selector)) == YES)
{ {
sig = [NSMethodSignature signatureWithObjCTypes: sel_getTypeEncoding(selector)]; sig = [NSMethodSignature signatureWithObjCTypes:
GSTypesFromSelector(selector)];
} }
#else
if (gs_protocol_selector(sel_getType_np(selector)) == YES)
{
sig = [NSMethodSignature signatureWithObjCTypes: sel_getType_np(selector)];
}
#endif
if (sig == nil) if (sig == nil)
{ {
sig = [obj methodSignatureForSelector: selector]; sig = [obj methodSignatureForSelector: selector];
@ -580,21 +566,13 @@ GSFFIInvocationCallback(ffi_cif *cif, void *retp, void **args, void *user)
if (sig != nil) if (sig != nil)
{ {
const char *receiverTypes = [sig methodType]; const char *receiverTypes = [sig methodType];
#ifdef __GNU_LIBOBJC__ const char *runtimeTypes = GSTypesFromSelector(selector);
const char *runtimeTypes = sel_getTypeEncoding(selector);
#else
const char *runtimeTypes = sel_getType_np(selector);
#endif
if (runtimeTypes == 0 || strcmp(receiverTypes, runtimeTypes) != 0) if (runtimeTypes == 0 || strcmp(receiverTypes, runtimeTypes) != 0)
{ {
const char *runtimeName = sel_getName(selector); const char *runtimeName = sel_getName(selector);
#ifdef __GNU_LIBOBJC__ selector = GSSelectorFromNameAndTypes(runtimeName, receiverTypes);
selector = sel_registerTypedName(runtimeName, receiverTypes);
#else
selector = sel_registerTypedName_np(runtimeName, receiverTypes);
#endif
if (runtimeTypes != 0) if (runtimeTypes != 0)
{ {
/* /*
@ -616,19 +594,11 @@ GSFFIInvocationCallback(ffi_cif *cif, void *retp, void **args, void *user)
{ {
selector = gs_find_best_typed_sel (selector); selector = gs_find_best_typed_sel (selector);
#ifdef __GNU_LIBOBJC__ if (GSTypesFromSelector(selector) != 0)
if (sel_getTypeEncoding(selector) != 0)
{ {
sig = [NSMethodSignature signatureWithObjCTypes: sig = [NSMethodSignature signatureWithObjCTypes:
sel_getTypeEncoding(selector)]; GSTypesFromSelector(selector)];
} }
#else
if (sel_getType_np(selector) != 0)
{
sig = [NSMethodSignature signatureWithObjCTypes:
sel_getType_np(selector)];
}
#endif
} }
if (sig == nil) if (sig == nil)

View file

@ -1991,11 +1991,7 @@ static NSLock *cached_proxies_gate = nil;
type = [[object methodSignatureForSelector: [inv selector]] methodType]; type = [[object methodSignatureForSelector: [inv selector]] methodType];
if (type) if (type)
{ {
#ifdef __GNU_LIBOBJC__ GSSelectorFromNameAndTypes(sel_getName([inv selector]), type);
sel_registerTypedName(sel_getName([inv selector]), type);
#else
sel_registerTypedName_np(sel_getName([inv selector]), type);
#endif
} }
} }
NSParameterAssert(type); NSParameterAssert(type);

View file

@ -1160,11 +1160,7 @@ failure:
if (lt) if (lt)
{ {
#ifdef __GNU_LIBOBJC__ sel = GSSelectorFromNameAndTypes(name, types);
sel = sel_registerTypedName(name, types);
#else
sel = sel_registerTypedName_np(name, types);
#endif
} }
else else
{ {
@ -2807,11 +2803,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
if (lt) if (lt)
{ {
#ifdef __GNU_LIBOBJC__ sel = GSSelectorFromNameAndTypes(name, types);
sel = sel_registerTypedName(name, types);
#else
sel = sel_registerTypedName_np(name, types);
#endif
} }
else else
{ {

View file

@ -811,13 +811,8 @@ static NSDistributedNotificationCenter *netCenter = nil;
notification = [NSNotification notificationWithName: name notification = [NSNotification notificationWithName: name
object: object object: object
userInfo: userInfo]; userInfo: userInfo];
#ifdef __GNU_LIBOBJC__ [recipient performSelector: GSSelectorFromNameAndTypes([aSelector cString], 0)
[recipient performSelector: sel_registerTypedName([aSelector cString], 0)
withObject: notification]; withObject: notification];
#else
[recipient performSelector: sel_registerTypedName_np([aSelector cString], 0)
withObject: notification];
#endif
} }
@end @end

View file

@ -44,18 +44,12 @@
#import "Foundation/NSString.h" #import "Foundation/NSString.h"
#import "Foundation/NSDebug.h" #import "Foundation/NSDebug.h"
/* These headers needed for string localisation ... hopefully we will
* localise all the exceptions and debug/error messages in all the source
* some day, so localisation needs ot be in the common header for all code.
*/
#import "Foundation/NSBundle.h" #import "Foundation/NSBundle.h"
#import "GNUstepBase/NSBundle+GNUstepBase.h" #import "GNUstepBase/NSBundle+GNUstepBase.h"
#include <string.h>
#include <ctype.h>
#if defined(__GNUSTEP_RUNTIME__) || defined(NeXT_RUNTIME)
#define objc_malloc(x) malloc(x)
#define objc_realloc(p, s) realloc(p, s)
#define objc_free(x) free(x)
#endif
// Semi-private GNU[step] runtime function. // Semi-private GNU[step] runtime function.
IMP get_imp(Class, SEL); IMP get_imp(Class, SEL);