Use C++-style casts (#1576)

This commit is contained in:
Sylvie
2024-12-09 21:56:54 -05:00
committed by GitHub
parent e66da4c8c7
commit b877c81c32
33 changed files with 197 additions and 173 deletions

View File

@@ -30,8 +30,8 @@ struct FileStackNode {
// Meaningless at the root level, but gets written to the object file anyway, so init it
uint32_t lineNo = 0;
// Set only if referenced: ID within the object file, -1 if not output yet
uint32_t ID = -1;
// Set only if referenced: ID within the object file, `UINT32_MAX` if not output yet
uint32_t ID = UINT32_MAX;
// REPT iteration counts since last named node, in reverse depth order
std::vector<uint32_t> &iters() { return data.get<std::vector<uint32_t>>(); }

View File

@@ -45,7 +45,7 @@ struct Symbol {
>
data;
uint32_t ID; // ID of the symbol in the object file (-1 if none)
uint32_t ID; // ID of the symbol in the object file (`UINT32_MAX` if none)
uint32_t defIndex; // Ordering of the symbol in the state file
bool isDefined() const { return type != SYM_REF; }
@@ -55,7 +55,7 @@ struct Symbol {
bool isConstant() const {
if (type == SYM_LABEL) {
Section const *sect = getSection();
return sect && sect->org != (uint32_t)-1;
return sect && sect->org != UINT32_MAX;
}
return type == SYM_EQU || type == SYM_VAR;
}

View File

@@ -43,11 +43,11 @@ private:
// Generic field accessors; for internal use only.
template<typename T>
auto &field() {
return pick((T *)nullptr);
return pick(static_cast<T *>(nullptr));
}
template<typename T>
auto const &field() const {
return pick((T *)nullptr);
return pick(static_cast<T *>(nullptr));
}
public:

View File

@@ -28,7 +28,7 @@ struct Rgba {
_5to8(cgbColor),
_5to8(cgbColor >> 5),
_5to8(cgbColor >> 10),
(uint8_t)(cgbColor & 0x8000 ? 0x00 : 0xFF),
static_cast<uint8_t>(cgbColor & 0x8000 ? 0x00 : 0xFF),
};
}

View File

@@ -18,7 +18,7 @@ class EnumSeq {
explicit Iterator(T value) : _value(value) {}
Iterator &operator++() {
_value = (T)(_value + 1);
_value = static_cast<T>(_value + 1);
return *this;
}
@@ -29,7 +29,7 @@ class EnumSeq {
};
public:
explicit EnumSeq(T stop) : _start((T)0), _stop(stop) {}
explicit EnumSeq(T stop) : _start(static_cast<T>(0)), _stop(stop) {}
explicit EnumSeq(T start, T stop) : _start(start), _stop(stop) {}
Iterator begin() { return Iterator(_start); }