4 #define FOREACH_ARRAY(arr, start, end, cond, body) \
7 for (int i = start; i < end; ++i) \
9 const noref entity it = arr[i]; \
10 if (cond) { LAMBDA(body) } \
14 #define FOREACH_LIST(list, next, cond, body) \
18 for (entity it = list##_first; it; (it = it.next, ++i)) \
20 if (cond) { LAMBDA(body) } \
24 #define FOREACH_WORD(words, cond, body) \
27 string _words = words; \
29 for (string _it; (_it = car(_words)); (_words = cdr(_words), ++i)) \
31 const noref string it = _it; \
32 if (cond) { LAMBDA(body) } \
36 #define STRING_ITERATOR(this, s, i) \
37 string this##_s = s; \
41 #define STRING_ITERATOR_GET(this) str2chr(this##_s, this##_i++)
43 #define FOREACH_CHAR(s, cond, body) \
46 STRING_ITERATOR(iter, s, 0); \
48 while ((it = STRING_ITERATOR_GET(iter)) > 0) \
50 if (cond) { LAMBDA(body) } \
55 entity(.string fld, string match, .entity tofield) _findchainstring_tofield = #402;
56 entity(.entity fld, entity match, .entity tofield) findchainentity_tofield = #403;
57 entity(.float fld, float match, .entity tofield) _findchainflags_tofield = #450;
59 entity(.string fld, string match, .entity tofield) _findchainstring_tofield = #402;
60 entity(.entity fld, entity match, .entity tofield) findchainentity_tofield = #403;
61 entity(.float fld, float match, .entity tofield) _findchainflags_tofield = #450;
63 entity(.string fld, string match, .entity tofield) _findchainstring_tofield = #26;
64 entity(.entity fld, entity match, .entity tofield) findchainentity_tofield = #27;
65 entity(.float fld, float match, .entity tofield) _findchainflags_tofield = #88;
68 .entity _FOREACH_ENTITY_fld;
69 .entity _FOREACH_ENTITY_next;
71 #define FOREACH_ENTITY_UNORDERED(cond, body) \
74 for (entity it = findchainentity_tofield(_FOREACH_ENTITY_fld, NULL, _FOREACH_ENTITY_next); it; (it = it._FOREACH_ENTITY_next, ++i)) \
76 if (cond) { LAMBDA(body) } \
80 #define FOREACH_ENTITY_ORDERED(cond, body) \
83 for (entity it = NULL; (it = nextent(it)); ++i) \
85 if (cond) { LAMBDA(body) } \
89 #define FOREACH_ENTITY_FLAGS(fld, flags, body) \
92 for (entity it = _findchainflags_tofield(fld, flags, _FOREACH_ENTITY_next); it; (it = it._FOREACH_ENTITY_next, ++i)) \
98 #define FOREACH_ENTITY_CLASS(class, cond, body) \
101 for (entity it = _findchainstring_tofield(classname, class, _FOREACH_ENTITY_next); it; (it = it._FOREACH_ENTITY_next, ++i)) \
103 if (cond) { LAMBDA(body) } \
107 #define FOREACH_ENTITY(cond, body) FOREACH_ENTITY_UNORDERED(cond, body)
109 #define FOREACH(list, cond, body) FOREACH_LIST(list, enemy, cond, body)