Add CharToLower and CharToUpper into util.s (#6126)

This commit adds replacement of `::tolower` and `::toupper`.
Added CharToLower and CharToUpper routines reduce the number of cast operators
that required for correct usage of standard C/C++ `::tolower/toupper` routines.
This commit is contained in:
Vladimir Glavnyy
2020-09-21 23:31:27 +07:00
committed by GitHub
parent 8c67b5b129
commit fb4e1c34f9
7 changed files with 27 additions and 28 deletions

View File

@@ -121,16 +121,16 @@ class DartGenerator : public BaseGenerator {
auto ret = sstream.str() + ns.components.back();
for (size_t i = 0; i < ret.size(); i++) {
auto lower = tolower(ret[i]);
auto lower = CharToLower(ret[i]);
if (lower != ret[i]) {
ret[i] = static_cast<char>(lower);
ret[i] = lower;
if (i != 0 && ret[i - 1] != '.') {
ret.insert(i, "_");
i++;
}
}
}
// std::transform(ret.begin(), ret.end(), ret.begin(), ::tolower);
// std::transform(ret.begin(), ret.end(), ret.begin(), CharToLower);
return ret;
}
@@ -487,11 +487,11 @@ class DartGenerator : public BaseGenerator {
for (size_t i = 0; i < part.length(); i++) {
if (i && !isdigit(part[i]) &&
part[i] == static_cast<char>(toupper(part[i]))) {
part[i] == CharToUpper(part[i])) {
ns += "_";
ns += static_cast<char>(tolower(part[i]));
ns += CharToLower(part[i]);
} else {
ns += static_cast<char>(tolower(part[i]));
ns += CharToLower(part[i]);
}
}
if (it != qualified_name_parts.end() - 1) { ns += "_"; }