diff --git a/GNUmakefile b/GNUmakefile index 1fa631b..b54575e 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -31,6 +31,25 @@ libobjc_C_FILES = \ selector.c\ sendmsg.c\ thr.c +libobjc_HEADER_FILES_DIR = objc +libobjc_HEADER_FILES_INSTALL_DIR = objc +libobjc_HEADER_FILES = \ + Availability.h\ + NXConstStr.h\ + Object.h\ + Protocol.h\ + blocks_runtime.h\ + encoding.h\ + hash.h\ + objc-api.h\ + objc-decls.h\ + objc-list.h\ + objc.h\ + runtime-legacy.h\ + runtime.h\ + sarray.h\ + thr.h\ + typedstream.h # Deprecated functions are only deprecated for external use, not for us because # we are special, precious, little flowers. diff --git a/blocks_runtime.m b/blocks_runtime.m index 6c61606..45c0e27 100644 --- a/blocks_runtime.m +++ b/blocks_runtime.m @@ -198,7 +198,6 @@ struct StackBlockClass { // Copy a block to the heap if it's still on the stack or increments its retain count. -// The block is considered on the stack if self->descriptor->reserved == 0. void *_Block_copy(void *src) { struct StackBlockClass *self = src; diff --git a/objc/runtime.h b/objc/runtime.h index 77d0583..a3e0c24 100644 --- a/objc/runtime.h +++ b/objc/runtime.h @@ -4,6 +4,7 @@ // If __LEGACY_GNU_MODE__ is defined then we include the old GNU runtime header // instead of this one #ifndef __OBJC_LEGACY_GNU_MODE__ +#define __GNUSTEP_RUNTIME__ #include #include @@ -255,6 +256,10 @@ objc_property_t protocol_getProperty(Protocol *p, const char *name, BOOL protocol_isEqual(Protocol *p, Protocol *other); +#else +#include "runtime-legacy.h" +#endif // __LEGACY_GNU_MODE__ + /** * The objc_slot structure is used to permit safe IMP caching. It is returned * by the new lookup APIs. When you cache an IMP, you should store a copy of @@ -298,7 +303,8 @@ struct objc_slot * New ABI lookup function. Receiver may be modified during lookup or proxy * forwarding and the sender may affect how lookup occurs. */ -struct objc_slot *objc_msg_lookup_sender(id *receiver, SEL selector, id sender) OBJC_NONPORTABLE; +struct objc_slot *objc_msg_lookup_sender(id *receiver, SEL selector, id sender) + OBJC_NONPORTABLE; /** * Hook provided to allow libraries to support fast proxies. */ @@ -322,8 +328,4 @@ static const id self = nil; #define objc_msgSendSuper(super, op, ...) objc_msg_lookup_super(super, op)(super->receiver, op, ## __VA_ARGS__) -#else -#include "runtime-legacy.h" -#endif // __LEGACY_GNU_MODE__ - #endif // __LIBOBJC_RUNTIME_H_INCLUDED__ diff --git a/sendmsg.c b/sendmsg.c index 161979f..82ef435 100644 --- a/sendmsg.c +++ b/sendmsg.c @@ -208,6 +208,7 @@ __objc_responds_to (id object, SEL sel) return (res != 0); } +extern id (*objc_proxy_lookup)(id receiver, SEL op); /* This is the lookup function. All entries in the table are either a valid method *or* zero. If zero then either the dispatch table needs to be installed or it doesn't exist and forwarding is attempted. */ @@ -243,6 +244,16 @@ objc_msg_lookup (id receiver, SEL op) (sidx)op->sel_id); if (result == 0) { + /* Try again after giving the code a chance to install new + * methods. This lookup mechanism doesn't support forwarding + * to other objects, so only call the lookup recursively if + * the receiver is not changed. + */ + id newReceiver = objc_proxy_lookup (receiver, op); + if (newReceiver == receiver) + { + return objc_msg_lookup(receiver, op); + } /* If the method still just doesn't exist for the class, attempt to forward the method. */ result = __objc_get_forward_imp (receiver, op);