ObjFW  Diff

Differences From Artifact [a2a40a09cb]:

To Artifact [efb4532301]:

  • File src/OFObject.m — part of check-in [c70fd7d7f3] at 2016-10-08 15:57:45 on branch trunk — Never override CoreFoundations's forward handler

    If an application links ObjFW and (Core)Foundation, overriding
    CoreFoundation's forward handler breaks things.

    Before this commit, this only worked depending on the load order: If
    ObjFW was loaded first, everything was fine, as CoreFoundation would
    just override ObjFW's forward handler. However, if CoreFoundation would
    be loaded first, ObjFW would override CoreFoundation's forward handler
    and break CoreFoundation. (user: js, size: 25049) [annotate] [blame] [check-ins using]


54
55
56
57
58
59
60




61
62
63
64
65
66
67

#import "instance.h"
#if defined(OF_HAVE_ATOMIC_OPS)
# import "atomic.h"
#elif defined(OF_HAVE_THREADS)
# import "threading.h"
#endif





#if defined(OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR)
extern id of_forward(id, SEL, ...);
extern struct stret of_forward_stret(id, SEL, ...);
#else
# define of_forward of_method_not_found
# define of_forward_stret of_method_not_found_stret







>
>
>
>







54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71

#import "instance.h"
#if defined(OF_HAVE_ATOMIC_OPS)
# import "atomic.h"
#elif defined(OF_HAVE_THREADS)
# import "threading.h"
#endif

#ifdef OF_APPLE_RUNTIME
extern void* CFRetain(void*) __attribute__((__weak__));
#endif

#if defined(OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR)
extern id of_forward(id, SEL, ...);
extern struct stret of_forward_stret(id, SEL, ...);
#else
# define of_forward of_method_not_found
# define of_forward_stret of_method_not_found_stret
211
212
213
214
215
216
217









218

219
220
221
222
223
224
225
+ (void)load
{
#if !defined(OF_APPLE_RUNTIME) || defined(__OBJC2__)
	objc_setUncaughtExceptionHandler(uncaughtExceptionHandler);
#endif

#if defined(OF_APPLE_RUNTIME)









	objc_setForwardHandler((void*)&of_forward, (void*)&of_forward_stret);

#else
	objc_setForwardHandler((IMP)&of_forward, (IMP)&of_forward_stret);
#endif

	objc_setEnumerationMutationHandler(enumerationMutationHandler);

	of_hash_seed = 0;







>
>
>
>
>
>
>
>
>
|
>







215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
+ (void)load
{
#if !defined(OF_APPLE_RUNTIME) || defined(__OBJC2__)
	objc_setUncaughtExceptionHandler(uncaughtExceptionHandler);
#endif

#if defined(OF_APPLE_RUNTIME)
	/*
	 * If the CFRetain symbol is defined, we are linked against
	 * CoreFoundation. Since CoreFoundation sets its own forward handler
	 * on load, we should not set ours, as this will break CoreFoundation.
	 *
	 * Unfortunately, there is no way to check if a forward handler has
	 * already been set, so this is the best we can do.
	 */
	if (&CFRetain == NULL)
		objc_setForwardHandler((void*)&of_forward,
		    (void*)&of_forward_stret);
#else
	objc_setForwardHandler((IMP)&of_forward, (IMP)&of_forward_stret);
#endif

	objc_setEnumerationMutationHandler(enumerationMutationHandler);

	of_hash_seed = 0;