mirror of
https://github.com/gbdev/rgbds.git
synced 2026-01-21 16:01:52 +00:00
Give clearer names to template parameters
This commit is contained in:
@@ -38,8 +38,8 @@ struct Charmap {
|
||||
};
|
||||
|
||||
// Traverse the trie depth-first to derive the character mappings in definition order
|
||||
template<typename F>
|
||||
bool forEachChar(Charmap const &charmap, F callback) {
|
||||
template<typename CallbackFnT>
|
||||
bool forEachChar(Charmap const &charmap, CallbackFnT callback) {
|
||||
// clang-format off: nested initializers
|
||||
for (std::stack<std::pair<size_t, std::string>> prefixes({{0, ""}}); !prefixes.empty();) {
|
||||
// clang-format on
|
||||
|
||||
@@ -816,8 +816,8 @@ static int nextChar() {
|
||||
return peek();
|
||||
}
|
||||
|
||||
template<typename P>
|
||||
static int skipChars(P predicate) {
|
||||
template<typename PredicateFnT>
|
||||
static int skipChars(PredicateFnT predicate) {
|
||||
int c = peek();
|
||||
while (predicate(c)) {
|
||||
c = nextChar();
|
||||
@@ -2281,8 +2281,8 @@ yy::parser::symbol_type yylex() {
|
||||
}
|
||||
}
|
||||
|
||||
template<typename F>
|
||||
static Capture makeCapture(char const *name, F callback) {
|
||||
template<typename CallbackFnT>
|
||||
static Capture makeCapture(char const *name, CallbackFnT callback) {
|
||||
// Due to parser internals, it reads the EOL after the expression before calling this.
|
||||
// Thus, we don't need to keep one in the buffer afterwards.
|
||||
// The following assumption checks that.
|
||||
|
||||
@@ -57,8 +57,10 @@
|
||||
|
||||
yy::parser::symbol_type yylex(); // Provided by lexer.cpp
|
||||
|
||||
template <typename N, typename S>
|
||||
static auto handleSymbolByType(std::string const &symName, N numCallback, S strCallback) {
|
||||
template<typename NumCallbackFnT, typename StrCallbackFnT>
|
||||
static auto handleSymbolByType(
|
||||
std::string const &symName, NumCallbackFnT numCallback, StrCallbackFnT strCallback
|
||||
) {
|
||||
if (Symbol *sym = sym_FindScopedSymbol(symName); sym && sym->type == SYM_EQUS) {
|
||||
return strCallback(*sym->getEqus());
|
||||
} else {
|
||||
|
||||
@@ -70,7 +70,7 @@ public:
|
||||
|
||||
private:
|
||||
// Template class for both const and non-const iterators over the non-empty `_assigned` slots
|
||||
template<typename I, template<typename> typename Constness>
|
||||
template<typename IteratorT, template<typename> typename Constness>
|
||||
class AssignedSetsIter {
|
||||
public:
|
||||
friend class AssignedSets;
|
||||
@@ -84,7 +84,7 @@ private:
|
||||
|
||||
private:
|
||||
Constness<decltype(_assigned)> *_array = nullptr;
|
||||
I _iter{};
|
||||
IteratorT _iter{};
|
||||
|
||||
AssignedSetsIter(decltype(_array) array, decltype(_iter) &&iter)
|
||||
: _array(array), _iter(iter) {}
|
||||
@@ -164,11 +164,11 @@ public:
|
||||
size_t nbColorSets() const { return std::distance(RANGE(*this)); }
|
||||
|
||||
private:
|
||||
template<typename I>
|
||||
template<typename IteratorT>
|
||||
static void addUniqueColors(
|
||||
std::unordered_set<uint16_t> &colors,
|
||||
I iter,
|
||||
I const &end,
|
||||
IteratorT iter,
|
||||
IteratorT const &end,
|
||||
std::vector<ColorSet> const &colorSets
|
||||
) {
|
||||
for (; iter != end; ++iter) {
|
||||
@@ -240,18 +240,20 @@ public:
|
||||
}
|
||||
|
||||
// Computes the "relative size" of a set of color sets on this palette
|
||||
template<typename I>
|
||||
size_t combinedVolume(I &&begin, I const &end, std::vector<ColorSet> const &colorSets) const {
|
||||
template<typename IteratorT>
|
||||
size_t combinedVolume(
|
||||
IteratorT &&begin, IteratorT const &end, std::vector<ColorSet> const &colorSets
|
||||
) const {
|
||||
std::unordered_set<uint16_t> &colors = uniqueColors();
|
||||
addUniqueColors(colors, std::forward<I>(begin), end, colorSets);
|
||||
addUniqueColors(colors, std::forward<IteratorT>(begin), end, colorSets);
|
||||
return colors.size();
|
||||
}
|
||||
|
||||
// Computes the "relative size" of a set of colors on this palette
|
||||
template<typename I>
|
||||
size_t combinedVolume(I &&begin, I &&end) const {
|
||||
template<typename IteratorT>
|
||||
size_t combinedVolume(IteratorT &&begin, IteratorT &&end) const {
|
||||
std::unordered_set<uint16_t> &colors = uniqueColors();
|
||||
colors.insert(std::forward<I>(begin), std::forward<I>(end));
|
||||
colors.insert(std::forward<IteratorT>(begin), std::forward<IteratorT>(end));
|
||||
return colors.size();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -210,15 +210,15 @@ static void warnExtraColors(
|
||||
}
|
||||
|
||||
// Parses the initial part of a string_view, advancing the "read index" as it does
|
||||
template<typename U> // Should be uint*_t
|
||||
static std::optional<U> parseDec(std::string const &str, size_t &n) {
|
||||
template<typename UintT> // Should be uint*_t
|
||||
static std::optional<UintT> parseDec(std::string const &str, size_t &n) {
|
||||
uintmax_t value = 0;
|
||||
auto result = std::from_chars(str.data() + n, str.data() + str.length(), value);
|
||||
if (static_cast<bool>(result.ec)) {
|
||||
return std::nullopt;
|
||||
}
|
||||
n = result.ptr - str.data();
|
||||
return std::optional<U>{value};
|
||||
return std::optional<UintT>{value};
|
||||
}
|
||||
|
||||
static std::optional<Rgba> parseColor(std::string const &str, size_t &n, uint16_t i) {
|
||||
|
||||
@@ -314,8 +314,8 @@ static bool compareSymbols(SortedSymbol const &sym1, SortedSymbol const &sym2) {
|
||||
< std::tie(sym2.addr, sym2_local, sym2.parentAddr, sym2_name);
|
||||
}
|
||||
|
||||
template<typename F>
|
||||
static void forEachSortedSection(SortedSections const &bankSections, F callback) {
|
||||
template<typename CallbackFnT>
|
||||
static void forEachSortedSection(SortedSections const &bankSections, CallbackFnT callback) {
|
||||
for (Section const *sect : bankSections.zeroLenSections) {
|
||||
for (Section const &piece : sect->pieces()) {
|
||||
callback(piece);
|
||||
@@ -415,8 +415,8 @@ static void writeSectionName(std::string const &name, FILE *file) {
|
||||
}
|
||||
}
|
||||
|
||||
template<typename F>
|
||||
uint16_t forEachSection(SortedSections const §List, F callback) {
|
||||
template<typename CallbackFnT>
|
||||
uint16_t forEachSection(SortedSections const §List, CallbackFnT callback) {
|
||||
uint16_t used = 0;
|
||||
auto section = sectList.sections.begin();
|
||||
auto zeroLenSection = sectList.zeroLenSections.begin();
|
||||
|
||||
Reference in New Issue
Block a user