Make IOPort constexpr
This commit is contained in:
parent
5fc4c2dc44
commit
47484a8056
|
@ -60,25 +60,31 @@ namespace JabyEngine {
|
|||
#define __declare_io_type(name, type, ...) \
|
||||
template<template<typename> typename T> \
|
||||
struct name##_io_base { \
|
||||
T<type>::Value raw_value; \
|
||||
T<type>::Value raw_value = 0; \
|
||||
\
|
||||
name##_io_base(type value) : raw_value(value) {} \
|
||||
constexpr name##_io_base() = default; \
|
||||
\
|
||||
constexpr name##_io_base(type value) : raw_value(value) {} \
|
||||
__VA_ARGS__ \
|
||||
\
|
||||
void set(IOBitSet bit) { \
|
||||
constexpr name##_io_base& set(IOBitSet bit) { \
|
||||
this->raw_value = bit::set(this->raw_value, bit.pos); \
|
||||
return *this; \
|
||||
} \
|
||||
\
|
||||
void set(IOBitUnset bit) { \
|
||||
constexpr name##_io_base& set(IOBitUnset bit) { \
|
||||
this->raw_value = bit::clear(this->raw_value, bit.pos); \
|
||||
return *this; \
|
||||
} \
|
||||
\
|
||||
void set(IOValueSet bits, type value) { \
|
||||
constexpr name##_io_base& set(IOValueSet bits, type value) { \
|
||||
this->raw_value = bit::value::set_normalized(this->raw_value, value, bits.pos, bits.length); \
|
||||
return *this; \
|
||||
} \
|
||||
\
|
||||
void set(const IOValueSet::IOValueSetPair<type>& value) { \
|
||||
constexpr name##_io_base& set(const IOValueSet::IOValueSetPair<type>& value) { \
|
||||
this->set(value.first, value.second); \
|
||||
return *this; \
|
||||
} \
|
||||
\
|
||||
type get(IOValueSet bits) const { \
|
||||
|
@ -86,8 +92,9 @@ namespace JabyEngine {
|
|||
} \
|
||||
\
|
||||
\
|
||||
void clear(IOBitSet bit) { \
|
||||
constexpr name##_io_base& clear(IOBitSet bit) { \
|
||||
this->raw_value = bit::clear(this->raw_value, bit.pos); \
|
||||
return *this; \
|
||||
} \
|
||||
\
|
||||
\
|
||||
|
|
Loading…
Reference in New Issue