]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/util-post.qh
Remove more useless tooltips
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / util-post.qh
index 6b43f34bf2aefedfdc40aa65012a09d2f8befe54..f796b6ebda6109c169700f78dae37989464819d6 100644 (file)
@@ -1,6 +1,47 @@
 #ifndef UTIL_POST_H
 #define UTIL_POST_H
 
+[[alias("self")]] entity __self;
+
+// Can't wrap with do-while as block may contain continue or break
+#define WITH(type, name, value, block) { \
+    type __with_save = (name); \
+    name = (value); \
+    LAMBDA(block) \
+    name = __with_save; \
+} do { } while (0)
+
+// Transition from global 'self' to local 'this'
+
+// Step 1: auto oldself
+#if 1
+#define SELFPARAM() noref entity this = __self
+#define setself(s) (__self = s)
+#define self __self
+#endif
+
+// Step 2: check SELFPARAM() is present for functions that use self
+#if 0
+#define SELFPARAM() [[alias("__self")]] noref entity this = __self
+#define setself(s) (__self = s)
+#define self this
+#endif
+
+// Step 3: const self
+#if 0
+#define SELFPARAM() noref const entity this = __self
+entity setself(entity e) { return self = e; }
+entity getself() { return self; }
+#define self getself()
+#endif
+
+// Step 4: enable when possible
+// TODO: Remove SELFPARAM in favor of a parameter
+#if 0
+#define SELFPARAM() noref const entity this = __self
+#define self this
+#endif
+
 #define spawn() new(entity)
 
 #endif