1 |
739 |
jeremybenn |
/* GNU Objective C Runtime 'fast enumeration' implementation
|
2 |
|
|
Copyright (C) 2010 Free Software Foundation, Inc.
|
3 |
|
|
Contributed by Nicola Pero <nicola.pero@meta-innovation.com>
|
4 |
|
|
|
5 |
|
|
This file is part of GCC.
|
6 |
|
|
|
7 |
|
|
GCC is free software; you can redistribute it and/or modify it under the
|
8 |
|
|
terms of the GNU General Public License as published by the Free Software
|
9 |
|
|
Foundation; either version 3, or (at your option) any later version.
|
10 |
|
|
|
11 |
|
|
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
12 |
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
13 |
|
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
14 |
|
|
details.
|
15 |
|
|
|
16 |
|
|
Under Section 7 of GPL version 3, you are granted additional
|
17 |
|
|
permissions described in the GCC Runtime Library Exception, version
|
18 |
|
|
3.1, as published by the Free Software Foundation.
|
19 |
|
|
|
20 |
|
|
You should have received a copy of the GNU General Public License and
|
21 |
|
|
a copy of the GCC Runtime Library Exception along with this program;
|
22 |
|
|
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
23 |
|
|
<http://www.gnu.org/licenses/>. */
|
24 |
|
|
|
25 |
|
|
/* This file implements objc_enumeration_mutation() and
|
26 |
|
|
objc_set_enumeration_mutation_handler(), the two functions required
|
27 |
|
|
to handle mutations during a fast enumeration. */
|
28 |
|
|
#include "objc-private/common.h"
|
29 |
|
|
#include "objc-private/error.h" /* For _objc_abort() */
|
30 |
|
|
#include "objc/runtime.h" /* For objc_enumerationMutation() and objc_set_enumeration_mutation_handler() */
|
31 |
|
|
|
32 |
|
|
/* The enumeration mutation handler currently in use. */
|
33 |
|
|
static void (*__objc_enumeration_mutation_handler)(id) = NULL;
|
34 |
|
|
|
35 |
|
|
void
|
36 |
|
|
objc_setEnumerationMutationHandler (void (*handler)(id))
|
37 |
|
|
{
|
38 |
|
|
__objc_enumeration_mutation_handler = handler;
|
39 |
|
|
}
|
40 |
|
|
|
41 |
|
|
void
|
42 |
|
|
objc_enumerationMutation (id collection)
|
43 |
|
|
{
|
44 |
|
|
if (__objc_enumeration_mutation_handler != NULL)
|
45 |
|
|
(*__objc_enumeration_mutation_handler) (collection);
|
46 |
|
|
|
47 |
|
|
/* We always abort if we get here; there is no point in going on as
|
48 |
|
|
the next iteration in the fast enumeration would probably go
|
49 |
|
|
deeply wrong. */
|
50 |
|
|
_objc_abort ("Collection %p mutated during fast enumeration", collection);
|
51 |
|
|
}
|