Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
enumclass.qh
Go to the documentation of this file.
1#pragma once
2
3#include "oo.qh"
4
5// purpose: prevent transposed parameter passing
6
7#if NDEBUG
8
9// zero overhead mode, use this for releases
10
11#define ENUMCLASS(id) USING(id, int); enum { CASE(id, Null)
12#define CASE(class, id) class##_##id,
13#define ENUMCLASS_END(id) };
14#define ORDINAL(it) (it)
15#define ENUMCAST(T, it) (it)
16
17#else
18
19// edict overhead mode, use this for type checking
20
22#define ENUMCLASS(id) CLASS(id, Object) int id##_count; const noref entity id##_Null = nil; CASE(id, Null__)
23#define CASE(class, id) class class##_##id; STATIC_INIT(class##_##id) { entity e = class##_##id = NEW(class); e.enum_ordinal = class##_count++; }
24#define ENUMCLASS_END(id) ENDCLASS(id)
25#define ORDINAL(it) ((it).enum_ordinal)
26#define ENUMCAST(T, it) ftoe(etof(T##_Null__) + (it))
27
28#endif
int enum_ordinal
Definition enumclass.qh:21