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:
Richard Frith-MacDonald 2011-02-20 07:58:11 +00:00
parent 474a12b708
commit c7eeb1bb08
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>
* Source/NSBundle.m:

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -44,18 +44,12 @@
#import "Foundation/NSString.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 "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.
IMP get_imp(Class, SEL);