Differences From Artifact [4b4eff1419]:
- File
src/OFObject.m
— part of check-in
[d3a2e59414]
at
2012-11-14 15:39:10
on branch trunk
— Initial -[forwarindTargetForSelector:].
This only works with the ObjFW runtime so far. The Apple runtime will
require an assembly implementation for every architecture. (user: js, size: 25411) [annotate] [blame] [check-ins using]
To Artifact [43abec3b5d]:
- File
src/OFObject.m
— part of check-in
[2b20e164d7]
at
2012-11-16 21:16:06
on branch trunk
— Implement forwarding target for the Apple runtime.
Only on x86_64 so far, others to follow. (user: js, size: 25774) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
62 63 64 65 66 67 68 69 70 71 72 73 74 75 | #import "instance.h" #if defined(OF_ATOMIC_OPS) # import "atomic.h" #elif defined(OF_THREADS) # import "threading.h" #endif struct pre_ivar { int32_t retainCount; struct pre_mem *firstMem, *lastMem; #if !defined(OF_ATOMIC_OPS) && defined(OF_THREADS) of_spinlock_t retainCountSpinlock; #endif | > > > > > | 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | #import "instance.h" #if defined(OF_ATOMIC_OPS) # import "atomic.h" #elif defined(OF_THREADS) # import "threading.h" #endif #if defined(OF_APPLE_RUNTIME) && defined(__x86_64__) extern id of_forward(id, SEL, ...); extern struct stret of_forward_stret(id, SEL, ...); #endif struct pre_ivar { int32_t retainCount; struct pre_mem *firstMem, *lastMem; #if !defined(OF_ATOMIC_OPS) && defined(OF_THREADS) of_spinlock_t retainCountSpinlock; #endif |
︙ | ︙ | |||
109 110 111 112 113 114 115 | enumeration_mutation_handler(id object) { @throw [OFEnumerationMutationException exceptionWithClass: [object class] object: object]; } | < | | > < < | 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | enumeration_mutation_handler(id object) { @throw [OFEnumerationMutationException exceptionWithClass: [object class] object: object]; } void of_method_not_found(id obj, SEL sel) { fprintf(stderr, "Runtime error: Selector %s is not implemented in " "class %s!\n", sel_getName(sel), class_getName(object_getClass(obj))); abort(); } #ifdef OF_OBJFW_RUNTIME static IMP forward_handler(id obj, SEL sel) { /* Try resolveClassMethod:/resolveInstanceMethod: */ if (class_isMetaClass(object_getClass(obj))) { if ([obj respondsToSelector: @selector(resolveClassMethod:)] && [obj resolveClassMethod: sel]) { if (![obj respondsToSelector: sel]) { fprintf(stderr, "Runtime error: [%s " "resolveClassMethod: %s] returned YES " |
︙ | ︙ | |||
157 158 159 160 161 162 163 | } return objc_msg_lookup(obj, sel); } } /* Try forwardingTargetForSelector: */ | > > | | | | > | > | 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | } return objc_msg_lookup(obj, sel); } } /* Try forwardingTargetForSelector: */ if (class_respondsToSelector(object_getClass(obj), @selector(forwardingTargetForSelector:))) { id target = [obj forwardingTargetForSelector: sel]; if (target != obj && target != nil) return objc_msg_lookup(target, sel); } of_method_not_found(obj, sel); return NULL; } #endif #ifndef HAVE_OBJC_ENUMERATIONMUTATION void objc_enumerationMutation(id object) { |
︙ | ︙ | |||
244 245 246 247 248 249 250 | @implementation OFObject + (void)load { #if !defined(OF_APPLE_RUNTIME) || defined(__OBJC2__) objc_setUncaughtExceptionHandler(uncaught_exception_handler); #endif | | > > > > | 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | @implementation OFObject + (void)load { #if !defined(OF_APPLE_RUNTIME) || defined(__OBJC2__) objc_setUncaughtExceptionHandler(uncaught_exception_handler); #endif #if defined(OF_OBJFW_RUNTIME) objc_forward_handler = forward_handler; #elif defined(OF_APPLE_RUNTIME) # ifdef __x86_64__ objc_setForwardHandler(of_forward, of_forward_stret); # endif #endif #ifdef HAVE_OBJC_ENUMERATIONMUTATION objc_setEnumerationMutationHandler(enumeration_mutation_handler); #endif #if defined(_WIN32) |
︙ | ︙ |