]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/lib/unsafe.qh
etof: avoid tempstring
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / unsafe.qh
1 #ifndef UNSAFE_H
2 #define UNSAFE_H
3
4 #define reinterpret_cast(T, it) _unsafe_cast_##T(0, it)
5 #define X(T) T _unsafe_cast_##T(int dummy, ...) { return ...(0, T); }
6 X(bool)
7 X(int)
8 X(float)
9 X(entity)
10 X(string)
11 typedef float(...) rawfunc;
12 X(rawfunc)
13 #undef X
14
15 #define strid(s) ITOF(reinterpret_cast(int, s))
16
17 .int _unsafe_fld1, _unsafe_fld2;
18 int INTEGER_ONE;
19
20 #define FTOI(f) ((f) * INTEGER_ONE)
21 #define ITOF(i) ((i) / INTEGER_ONE)
22
23 STATIC_INIT(INTEGER_ONE)
24 {
25     INTEGER_ONE = reinterpret_cast(int, _unsafe_fld2) - reinterpret_cast(int, _unsafe_fld1);
26 }
27
28 #endif