- use constexpr for translation utilities

This commit is contained in:
Christoph Oelckers 2020-08-15 10:22:07 +02:00
parent c3ddde02b2
commit a690f44fc8
1 changed files with 9 additions and 6 deletions

View File

@ -59,19 +59,22 @@ private:
}; };
#define TRANSLATION_SHIFT 16 enum
#define TRANSLATION_MASK ((1<<TRANSLATION_SHIFT)-1) {
#define TRANSLATIONTYPE_MASK (255<<TRANSLATION_SHIFT) TRANSLATION_SHIFT = 16,
TRANSLATION_MASK = ((1 << TRANSLATION_SHIFT) - 1),
TRANSLATIONTYPE_MASK = (255 << TRANSLATION_SHIFT)
};
inline uint32_t TRANSLATION(uint8_t a, uint32_t b) inline constexpr uint32_t TRANSLATION(uint8_t a, uint32_t b)
{ {
return (a << TRANSLATION_SHIFT) | b; return (a << TRANSLATION_SHIFT) | b;
} }
inline int GetTranslationType(uint32_t trans) inline constexpr int GetTranslationType(uint32_t trans)
{ {
return (trans & TRANSLATIONTYPE_MASK) >> TRANSLATION_SHIFT; return (trans & TRANSLATIONTYPE_MASK) >> TRANSLATION_SHIFT;
} }
inline int GetTranslationIndex(uint32_t trans) inline constexpr int GetTranslationIndex(uint32_t trans)
{ {
return (trans & TRANSLATION_MASK); return (trans & TRANSLATION_MASK);
} }