Fix IO Port code again

This commit is contained in:
Jaby
2023-01-08 13:56:26 +01:00
committed by Jaby
parent 2e4106436d
commit a1c8b3aea6
3 changed files with 26 additions and 19 deletions

View File

@@ -9,27 +9,26 @@ namespace JabyEngine {
T value;
public:
//For easy access
constexpr T read() const {
return const_cast<volatile IOPort<T>*>(this)->value;
return const_cast<const volatile decltype(this)>(this)->value;
}
constexpr void write(T value) {
const_cast<volatile IOPort<T>*>(this)->value = value;
template<typename...ARGS>
constexpr void write_combined(const ARGS&... value) {
IOPort::write(T::with(value...));
}
constexpr volatile T& ref() {
return const_cast<volatile IOPort<T>*>(this)->value;
template<typename S>
constexpr void write(const BitRangeValue<S>& value) {
IOPort::write(T::with(value));
}
constexpr const volatile T& ref() const {
return const_cast<volatile IOPort<T>*>(this)->value;
constexpr void write(const T& value) {
const_cast<volatile decltype(this)>(this)->value = value;
}
constexpr IOPort<T>& operator=(T value) {
IOPort::write(value);
return *this;
}
// We keep this a POD so we will not add assignment operators anymore
// We also removed ref() to be more percise
};
struct __no_align ubus32_t {