File: GSFastEnumeration.h

package info (click to toggle)
gnustep-gui 0.25.0-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 13,088 kB
  • ctags: 3,417
  • sloc: objc: 153,800; ansic: 18,239; cpp: 579; yacc: 462; makefile: 143; sh: 5
file content (38 lines) | stat: -rw-r--r-- 1,124 bytes parent folder | download | duplicates (12)
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

#ifdef __clang__
#define FOR_IN(type, var, collection) \
	for (type var in collection)\
	{
#define END_FOR_IN(collection) }
#else
void objc_enumerationMutation(id);
#define FOR_IN(type, var, c) \
do\
{\
	type var;\
	NSFastEnumerationState gs_##c##_enumState = { 0 };\
	id gs_##c##_items[16];\
	unsigned long gs_##c##_limit = \
		[c countByEnumeratingWithState: &gs_##c##_enumState \
		                       objects: gs_##c##_items \
		                         count: 16];\
	if (gs_##c##_limit)\
	{\
		unsigned long gs_startMutations = *gs_##c##_enumState.mutationsPtr;\
		do {\
			unsigned long gs_##c##counter = 0;\
			do {\
				if (gs_startMutations != *gs_##c##_enumState.mutationsPtr)\
				{\
					objc_enumerationMutation(c);\
				}\
				var = gs_##c##_enumState.itemsPtr[gs_##c##counter++];\

#define END_FOR_IN(c) \
			} while (gs_##c##counter < gs_##c##_limit);\
		} while ((gs_##c##_limit = [c countByEnumeratingWithState: &gs_##c##_enumState\
		                                                  objects: gs_##c##_items\
		                                                    count: 16]));\
	}\
} while(0);
#endif