From b29e4570e7e3832a9923226c04ba43d630e91bd1 Mon Sep 17 00:00:00 2001 From: theraven Date: Sat, 5 Sep 2009 17:43:13 +0000 Subject: [PATCH] Added enumeration mutation function, called by code automatically inserted by the compiler when a collection mutates during fast enumeration. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@28610 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 4 ++++ Source/NSEnumerator.m | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/ChangeLog b/ChangeLog index 38e53478c..e167bfd3e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-09-05 David Chisnall + + * Source/NSEnumberation.m: Added enumeration mutation callback. + 2009-09-03 Richard Frith-Macdonald * Source/NSLock.m: Fix a few variable declarations to work with older diff --git a/Source/NSEnumerator.m b/Source/NSEnumerator.m index 2893d4141..afe068d68 100644 --- a/Source/NSEnumerator.m +++ b/Source/NSEnumerator.m @@ -29,6 +29,8 @@ #import "GNUstepBase/preface.h" #import "Foundation/NSArray.h" #import "Foundation/NSEnumerator.h" +#include "Foundation/NSException.h" + /** * Simple class for iterating over a collection of objects, usually returned @@ -96,3 +98,14 @@ return len; } @end + +/** + * objc_enumerationMutation() is called whenever a collection mutates in the + * middle of fast enumeration. + */ +void objc_enumerationMutation(id obj) +{ + [NSException raise: NSGenericException + format: @"Collection %@ was mutated while being enumerated", + obj]; +}