]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/lib/linkedlist.qh
Merge branch 'master' into Mario/showspecs
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / linkedlist.qh
index 3f57fdbc7214872dfad24b4de2fb0d10480185a0..6afc862ed0a6306b97e2ad5ca02702b3a79a4817 100644 (file)
@@ -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