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; \
40 #define STRING_ITERATOR_SET(this, s, i) \
46 #define STRING_ITERATOR_GET(this) str2chr(this##_s, this##_i++)
48 #define FOREACH_CHAR(s, cond, body) \
51 STRING_ITERATOR(iter, s, 0); \
53 while ((it = STRING_ITERATOR_GET(iter)) > 0) \
55 if (cond) { LAMBDA(body) } \
60 entity(.string fld, string match, .entity tofield) _findchainstring_tofield = #402;
61 entity(.entity fld, entity match, .entity tofield) findchainentity_tofield = #403;
62 entity(.float fld, float match, .entity tofield) _findchainflags_tofield = #450;
64 entity(.string fld, string match, .entity tofield) _findchainstring_tofield = #402;
65 entity(.entity fld, entity match, .entity tofield) findchainentity_tofield = #403;
66 entity(.float fld, float match, .entity tofield) _findchainflags_tofield = #450;
68 entity(.string fld, string match, .entity tofield) _findchainstring_tofield = #26;
69 entity(.entity fld, entity match, .entity tofield) findchainentity_tofield = #27;
70 entity(.float fld, float match, .entity tofield) _findchainflags_tofield = #88;
73 .entity _FOREACH_ENTITY_fld;
74 .entity _FOREACH_ENTITY_next;
76 #define FOREACH_ENTITY_UNORDERED(cond, body) \
79 for (entity it = findchainentity_tofield(_FOREACH_ENTITY_fld, NULL, _FOREACH_ENTITY_next); it; (it = it._FOREACH_ENTITY_next, ++i)) \
81 if (cond) { LAMBDA(body) } \
85 #define FOREACH_ENTITY_ORDERED(cond, body) \
88 for (entity it = NULL; (it = nextent(it)); ++i) \
90 if (cond) { LAMBDA(body) } \
94 #define FOREACH_ENTITY_FLAGS(fld, flags, body) \
97 for (entity it = _findchainflags_tofield(fld, flags, _FOREACH_ENTITY_next); it; (it = it._FOREACH_ENTITY_next, ++i)) \
103 #define FOREACH_ENTITY_CLASS(class, cond, body) \
106 for (entity it = _findchainstring_tofield(classname, class, _FOREACH_ENTITY_next); it; (it = it._FOREACH_ENTITY_next, ++i)) \
108 if (cond) { LAMBDA(body) } \
112 #define FOREACH_ENTITY(cond, body) FOREACH_ENTITY_UNORDERED(cond, body)
114 #define FOREACH(list, cond, body) FOREACH_LIST(list, enemy, cond, body)