]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/util-post.qh
Doxygen config
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / util-post.qh
1 #ifndef UTIL_POST_H
2 #define UTIL_POST_H
3
4 [[alias("self")]] entity __self;
5
6 // Can't wrap with do-while as block may contain continue or break
7 #define WITH(type, name, value, block) { \
8     type __with_save = (name); \
9     name = (value); \
10     LAMBDA(block) \
11     name = __with_save; \
12 } do { } while (0)
13
14 // Transition from global 'self' to local 'this'
15
16 // Step 1: auto oldself
17 #if 1
18 #define SELFPARAM() noref entity this = __self
19 #define setself(s) (__self = s)
20 #define self __self
21 #endif
22
23 // Step 2: check SELFPARAM() is present for functions that use self
24 #if 0
25 #define SELFPARAM() [[alias("__self")]] noref entity this = __self
26 #define setself(s) (__self = s)
27 #define self this
28 #endif
29
30 // Step 3: const self
31 #if 0
32 #define SELFPARAM() noref const entity this = __self
33 entity setself(entity e) { return self = e; }
34 entity getself() { return self; }
35 #define self getself()
36 #endif
37
38 // Step 4: enable when possible
39 // TODO: Remove SELFPARAM in favor of a parameter
40 #if 0
41 #define SELFPARAM() noref const entity this = __self
42 #define self this
43 #endif
44
45 #define spawn() new(entity)
46
47 #endif