3 /* { dg-skip-if "No NeXT fast enum. pre-Darwin9" { *-*-darwin[5-8]* } { "-fnext-runtime" } { "" } } */
4 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
5 /* { dg-additional-sources "../objc-obj-c++-shared/nsconstantstring-class-impl.m" } */
6 /* { dg-additional-options "-mno-constant-cfstrings" { target *-*-darwin* } } */
7 /* { dg-additional-options "-Wno-objc-root-class" } */
9 #import "../objc-obj-c++-shared/TestsuiteObject.m"
10 #ifndef __NEXT_RUNTIME__
11 #include <objc/NXConstStr.h>
13 #include "../objc-obj-c++-shared/nsconstantstring-class.h"
16 extern int printf (const char *, ...);
19 /* A mini-array implementation that can be used to test fast
20 enumeration. You create the array with some objects; you can
21 mutate the array, and you can fast-enumerate it.
23 @interface MyArray : TestsuiteObject
27 unsigned long mutated;
29 - (id) initWithLength: (unsigned int)l objects: (id *)o;
31 - (unsigned long)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state
32 objects:(id *)stackbuf
33 count:(unsigned long)len;
36 @implementation MyArray : TestsuiteObject
37 - (id) initWithLength: (unsigned int)l
49 - (unsigned long)countByEnumeratingWithState: (struct __objcFastEnumerationState*)state
50 objects: (id*)stackbuf
51 count: (unsigned long)len
53 unsigned long i, batch_size;
55 /* We keep how many objects we served in the state->state counter. So the next batch
56 will contain up to length - state->state objects. */
57 batch_size = length - state->state;
59 /* Make obvious adjustments. */
66 /* Copy the objects. */
67 for (i = 0; i < batch_size; i++)
68 stackbuf[i] = objects[i];
70 state->state += batch_size;
71 state->itemsPtr = stackbuf;
72 state->mutationsPtr = &mutated;
83 id *objects = malloc (sizeof (id) * 2);
87 MyArray *array = [[MyArray alloc] initWithLength: 2 objects: objects];
90 for (id object in array) {