X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Flib%2Flinkedlist.qh;h=6afc862ed0a6306b97e2ad5ca02702b3a79a4817;hb=301702fff6cd39f10c89eef9880cd9a85fe5c53e;hp=3f57fdbc7214872dfad24b4de2fb0d10480185a0;hpb=f203a8239ab58e776da8df7bce46be73d2d655a4;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/lib/linkedlist.qh b/qcsrc/lib/linkedlist.qh index 3f57fdbc7..6afc862ed 100644 --- a/qcsrc/lib/linkedlist.qh +++ b/qcsrc/lib/linkedlist.qh @@ -1,5 +1,4 @@ -#ifndef LINKEDLIST_H -#define LINKEDLIST_H +#pragma once CLASS(LinkedListNode, Object) ATTRIB(LinkedListNode, ll_data, entity, NULL) @@ -45,10 +44,11 @@ entity LL_POP(LinkedList this) return e; } -#define LL_CLEAR(...) EVAL(OVERLOAD(LL_CLEAR, __VA_ARGS__)) +#define LL_CLEAR(...) EVAL_LL_CLEAR(OVERLOAD(LL_CLEAR, __VA_ARGS__)) +#define EVAL_LL_CLEAR(...) __VA_ARGS__ #define LL_CLEAR_1(this) LL_CLEAR_2(this, LAMBDA()) #define LL_CLEAR_2(this, dtor) \ - do \ + MACRO_BEGIN \ { \ LinkedList _ll = this; \ assert(_ll); \ @@ -59,30 +59,26 @@ entity LL_POP(LinkedList this) dtor \ remove(it); \ } \ - } \ - while (0) + } MACRO_END -#define LL_DELETE(...) EVAL(OVERLOAD(LL_DELETE, __VA_ARGS__)) +#define LL_DELETE(...) EVAL_LL_DELETE(OVERLOAD(LL_DELETE, __VA_ARGS__)) +#define EVAL_LL_DELETE(...) __VA_ARGS__ #define LL_DELETE_1(this) LL_DELETE_2(this, LAMBDA()) #define LL_DELETE_2(this, dtor) \ - do \ + MACRO_BEGIN \ { \ - LL_CLEAR(this, dtor); \ + LL_CLEAR_2(this, dtor); \ remove(this); \ this = NULL; \ - } \ - while (0) + } MACRO_END #define LL_EACH(list, cond, body) \ - do \ + MACRO_BEGIN \ { \ noref int i = 0; \ for (entity _it = list.ll_head; _it; (_it = _it.ll_next, ++i)) \ { \ - noref entity it = _it.ll_data; \ + ITER_CONST noref entity it = _it.ll_data; \ if (cond) { body } \ } \ - } \ - while (0) - -#endif + } MACRO_END