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) _findchainfloat_tofield = #403;
63 entity(.float fld, float match, .entity tofield) _findchainflags_tofield = #450;
65 entity(.string fld, string match, .entity tofield) _findchainstring_tofield = #402;
66 entity(.entity fld, entity match, .entity tofield) findchainentity_tofield = #403;
67 entity(.float fld, float match, .entity tofield) _findchainfloat_tofield = #403;
68 entity(.float fld, float match, .entity tofield) _findchainflags_tofield = #450;
70 entity(.string fld, string match, .entity tofield) _findchainstring_tofield = #26;
71 entity(.entity fld, entity match, .entity tofield) findchainentity_tofield = #27;
72 entity(.float fld, float match, .entity tofield) _findchainfloat_tofield = #27;
73 entity(.float fld, float match, .entity tofield) _findchainflags_tofield = #88;
76 .entity _FOREACH_ENTITY_fld;
77 .entity _FOREACH_ENTITY_next;
79 #define FOREACH_ENTITY_UNORDERED(cond, body) \
82 for (entity it = findchainentity_tofield(_FOREACH_ENTITY_fld, NULL, _FOREACH_ENTITY_next); it; (it = it._FOREACH_ENTITY_next, ++i)) \
84 if (cond) { LAMBDA(body) } \
88 #define FOREACH_ENTITY_ORDERED(cond, body) \
91 for (entity it = NULL; (it = nextent(it)); ++i) \
93 if (cond) { LAMBDA(body) } \
97 #define FOREACH_ENTITY_FLOAT(fld, match, body) \
100 for (entity it = _findchainfloat_tofield(fld, match, _FOREACH_ENTITY_next); it; (it = it._FOREACH_ENTITY_next, ++i)) \
106 #define FOREACH_ENTITY_FLAGS(fld, match, body) \
109 for (entity it = _findchainflags_tofield(fld, match, _FOREACH_ENTITY_next); it; (it = it._FOREACH_ENTITY_next, ++i)) \
115 #define FOREACH_ENTITY_CLASS(class, cond, body) \
118 for (entity it = _findchainstring_tofield(classname, class, _FOREACH_ENTITY_next); it; (it = it._FOREACH_ENTITY_next, ++i)) \
120 if (cond) { LAMBDA(body) } \
124 #define FOREACH_ENTITY_ENT(fld, match, body) \
127 for (entity it = findchainentity_tofield(fld, match, _FOREACH_ENTITY_next); it; (it = it._FOREACH_ENTITY_next, ++i)) \
134 #define FOREACH_ENTITY(cond, body) FOREACH_ENTITY_UNORDERED(cond, body)
136 #define FOREACH(list, cond, body) FOREACH_LIST(list, enemy, cond, body)