ObjFW  Check-in [5e267364ae]

Overview
Comment:runtime: Add objc_enumerationMutation()

This was provided by OFObject before, but should actually be provided by
the runtime, as the compiler can generate code calling into it.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 5e267364aeae1c70acaf3e5c0b580577a04bf194d32769a9b08132c132b33899
User & Date: js on 2016-07-03 12:01:43
Other Links: manifest | tags
Context
2016-07-03
12:19
Add forwardingTargetForSelector: for x86_64/Mach-O check-in: d9c9a3d0bc user: js tags: trunk
12:01
runtime: Add objc_enumerationMutation() check-in: 5e267364ae user: js tags: trunk
11:24
runtime: Add class_addMethod() check-in: d4cae4c963 user: js tags: trunk
Changes

Modified src/OFObject.m from [8d3755fc71] to [d472a9075a].

138
139
140
141
142
143
144
145

146
147
148
149
150
151
152
138
139
140
141
142
143
144

145
146
147
148
149
150
151
152







-
+








void OF_NO_RETURN_FUNC
of_method_not_found_stret(void *st, id obj, SEL sel)
{
	of_method_not_found(obj, sel);
}

#ifndef HAVE_OBJC_ENUMERATIONMUTATION
#if !defined(OF_OBJFW_RUNTIME) && !defined(HAVE_OBJC_ENUMERATIONMUTATION)
void
objc_enumerationMutation(id object)
{
	enumerationMutationHandler(object);
}
#endif

224
225
226
227
228
229
230
231

232
233
234
235
236
237
238
224
225
226
227
228
229
230

231
232
233
234
235
236
237
238







-
+








#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

#ifdef HAVE_OBJC_ENUMERATIONMUTATION
#if defined(OF_OBJFW_RUNTIME) || defined(HAVE_OBJC_ENUMERATIONMUTATION)
	objc_setEnumerationMutationHandler(enumerationMutationHandler);
#endif

	of_hash_seed = 0;
	while (of_hash_seed == 0) {
#if defined(HAVE_ARC4RANDOM)
		of_hash_seed = arc4random();

Modified src/runtime/Makefile from [f63ebab534] to [44d89a0e24].

9
10
11
12
13
14
15

16
17
18
19
20
21
22
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23







+







       category.m		\
       class.m			\
       dtable.m			\
       exception.m		\
       hashtable.m		\
       init.m			\
       lookup.m			\
       misc.m			\
       property.m		\
       protocol.m		\
       selector.m		\
       sparsearray.m		\
       static-instances.m	\
       synchronized.m		\
       ${USE_SRCS_THREADS}

Added src/runtime/misc.m version [7fc7897853].









































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/*
 * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016
 *   Jonathan Schleifer <js@heap.zone>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#include <stdio.h>
#include <stdlib.h>

#include "runtime.h"
#include "runtime-private.h"

static void (*enumeration_mutation_handler)(id) = NULL;

void
objc_enumerationMutation(id obj)
{
	if (enumeration_mutation_handler != NULL)
		enumeration_mutation_handler(obj);
	else
		OBJC_ERROR("Object was mutated during enumeration!");
}

void
objc_setEnumerationMutationHandler(void (*handler)(id))
{
	enumeration_mutation_handler = handler;
}

Modified src/runtime/runtime.h from [ee48ca9342] to [3f8b6a0471].

235
236
237
238
239
240
241


242
243
244
245
246
247
248
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250







+
+







extern id _objc_rootAutorelease(id);
extern void objc_zero_weak_references(id);
/* Used by the compiler, but can be called manually. */
extern IMP objc_msg_lookup(id, SEL);
extern IMP objc_msg_lookup_stret(id, SEL);
extern IMP objc_msg_lookup_super(struct objc_super*, SEL);
extern IMP objc_msg_lookup_super_stret(struct objc_super*, SEL);
extern void objc_enumerationMutation(id);
extern void objc_setEnumerationMutationHandler(void (*handler)(id));
#ifdef __cplusplus
}
#endif

#undef OBJC_UNSAFE_UNRETAINED
#undef OBJC_ROOT_CLASS