ObjFW  Diff

Differences From Artifact [4b4eff1419]:

To Artifact [43abec3b5d]:


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
116
117
118
119
120
121
122
123
124
125

126
127
128
129
130
131
132
133
134
135
136
137
enumeration_mutation_handler(id object)
{
	@throw [OFEnumerationMutationException
	    exceptionWithClass: [object class]
			object: object];
}

#ifdef OF_OBJFW_RUNTIME
static id
method_not_found_handler(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();
}


static IMP
forward_handler(id obj, SEL sel)
{
	id target;

	/* 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 "







<
|
|







>



<
<







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


164
165
166
167
168

169

170
171
172
173
174
175
176
			}

			return objc_msg_lookup(obj, sel);
		}
	}

	/* Try forwardingTargetForSelector: */


	target = [obj forwardingTargetForSelector: sel];

	if (target != obj && target != nil)
		return objc_msg_lookup(target, sel);


	return method_not_found_handler;

}
#endif

#ifndef HAVE_OBJC_ENUMERATIONMUTATION
void
objc_enumerationMutation(id object)
{







>
>
|

|
|
|
>
|
>







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
251
252




253
254
255
256
257
258
259
@implementation OFObject
+ (void)load
{
#if !defined(OF_APPLE_RUNTIME) || defined(__OBJC2__)
	objc_setUncaughtExceptionHandler(uncaught_exception_handler);
#endif

#ifdef OF_OBJFW_RUNTIME
	objc_forward_handler = forward_handler;




#endif

#ifdef HAVE_OBJC_ENUMERATIONMUTATION
	objc_setEnumerationMutationHandler(enumeration_mutation_handler);
#endif

#if defined(_WIN32)







|

>
>
>
>







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)