]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/util-post.qh
afec8ed20772da84a607311327d8b5345175ac0c
[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 // Step 1: auto oldself
7 #if 1
8 #define SELFPARAM() noref entity this = __self
9 #define self __self
10 #define SELFCALL(s, f) (__self = s, f)
11 #define SELFCALL_DONE() (__self = this)
12 #endif
13
14 // Step 2: check SELFPARAM() is present for functions that use self
15 #if 0
16 #define SELFPARAM() [[alias("__self")]] noref entity this = __self
17 #define self this
18 #define SELFCALL(s, f) (this = s, f)
19 #define SELFCALL_DONE() (this = this)
20 #endif
21
22 // Step 3: const self
23 #if 0
24 #define SELFPARAM() noref const entity this = __self
25 entity setself(entity e) { return self = e; }
26 entity getself() { return self; }
27 #define self getself()
28 #define SELFCALL(s, f) (__self = s, f)
29 #define SELFCALL_DONE() (__self = this)
30 #endif
31
32 // Step 4: enable when possible
33 #if 0
34 #define SELFPARAM() noref const entity this = __self
35 #define self this
36 #define SELFCALL(s, f) (__self = s, f)
37 #define SELFCALL_DONE() (__self = this)
38 #endif
39
40 #define spawn() new(entity)
41
42 #endif