aboutsummaryrefslogtreecommitdiff
path: root/buildtools/codegen/CodegenLookupTable.h
blob: 02c0c7a523052dbaf981915cb798f9954fb22d00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#pragma once

#define LUT_DECL_VAR(name, aType, aCount, bType, bCount) \
	int name##A2B[aCount];                               \
	int name##B2A[bCount];                               \
	using name##AType = aType;                           \
	using name##BType = bType;                           \
	void InitializeLookupTable_##name()

#define LUT_MAP_FOR(name)           \
	int* lutMappingA2B = name##A2B; \
	int* lutMappingB2A = name##B2A
#define LUT_MAP(from, to)     \
	lutMappingA2B[from] = to; \
	lutMappingB2A[to] = from

#define LUT_INIT(name) InitializeLookupTable_##name()
#define LUT_LOOKUP(name, from) (name##BType)(name##A2B[from])
#define LUT_REV_LOOKUP(name, to) (name##AType)(name##B2A[to])