Fix some warnings on AppleClang

This commit is contained in:
Alexander Bock
2021-03-29 14:58:19 +02:00
parent e88650f22c
commit 797ddf7daf
3 changed files with 244 additions and 71 deletions

View File

@@ -45,17 +45,27 @@ template <typename T>
TestResult TemplateVerifier<T>::operator()(const ghoul::Dictionary& dict,
const std::string& key) const
{
TestResult res;
if (dict.hasValue<Type>(key)) {
return { true, {}, {} };
res.success = true;
}
else {
res.success = false;
if (dict.hasKey(key)) {
return { false, { { key, TestResult::Offense::Reason::WrongType } }, {} };
TestResult::Offense o;
o.offender = key;
o.reason = TestResult::Offense::Reason::WrongType;
res.offenses.push_back(o);
}
else {
return { false, { { key, TestResult::Offense::Reason::MissingKey } }, {} };
TestResult::Offense o;
o.offender = key;
o.reason = TestResult::Offense::Reason::MissingKey;
res.offenses.push_back(o);
}
}
return res;
}
template <typename T>
@@ -143,7 +153,13 @@ TestResult OperatorVerifier<T, Operator>::operator()(const ghoul::Dictionary& di
val = static_cast<int>(d);
}
else {
return { false, { { key, TestResult::Offense::Reason::WrongType } }, {} };
TestResult r;
r.success = false;
TestResult::Offense o;
o.offender = key;
o.reason = TestResult::Offense::Reason::WrongType;
r.offenses.push_back(o);
return r;
}
}
else {
@@ -153,7 +169,13 @@ TestResult OperatorVerifier<T, Operator>::operator()(const ghoul::Dictionary& di
return { true, {}, {} };
}
else {
return { false, { { key, TestResult::Offense::Reason::Verification } }, {} };
TestResult r;
r.success = false;
TestResult::Offense o;
o.offender = key;
o.reason = TestResult::Offense::Reason::Verification;
r.offenses.push_back(o);
return r;
}
}
else {
@@ -210,7 +232,13 @@ TestResult InListVerifier<T>::operator()(const ghoul::Dictionary& dict,
return { true, {}, {} };
}
else {
return { false, { { key, TestResult::Offense::Reason::Verification } }, {} };
TestResult r;
r.success = false;
TestResult::Offense o;
o.offender = key;
o.reason = TestResult::Offense::Reason::Verification;
r.offenses.push_back(o);
return r;
}
}
else {
@@ -256,7 +284,13 @@ TestResult NotInListVerifier<T>::operator()(const ghoul::Dictionary& dict,
return { true, {}, {} };
}
else {
return { false, { { key, TestResult::Offense::Reason::Verification } }, {} };
TestResult r;
r.success = false;
TestResult::Offense o;
o.offender = key;
o.reason = TestResult::Offense::Reason::Verification;
r.offenses.push_back(o);
return r;
}
}
else {
@@ -306,7 +340,13 @@ TestResult InRangeVerifier<T>::operator()(const ghoul::Dictionary& dict,
val = static_cast<int>(d);
}
else {
return { false, { { key, TestResult::Offense::Reason::WrongType } }, {} };
TestResult r;
r.success = false;
TestResult::Offense o;
o.offender = key;
o.reason = TestResult::Offense::Reason::WrongType;
r.offenses.push_back(o);
return r;
}
}
else {
@@ -317,7 +357,13 @@ TestResult InRangeVerifier<T>::operator()(const ghoul::Dictionary& dict,
return { true, {}, {} };
}
else {
return { false, { { key, TestResult::Offense::Reason::Verification } }, {} };
TestResult r;
r.success = false;
TestResult::Offense o;
o.offender = key;
o.reason = TestResult::Offense::Reason::Verification;
r.offenses.push_back(o);
return r;
}
}
else {
@@ -353,7 +399,13 @@ TestResult NotInRangeVerifier<T>::operator()(const ghoul::Dictionary& dict,
val = static_cast<int>(d);
}
else {
return { false, { { key, TestResult::Offense::Reason::WrongType } }, {} };
TestResult r;
r.success = false;
TestResult::Offense o;
o.offender = key;
o.reason = TestResult::Offense::Reason::WrongType;
r.offenses.push_back(o);
return r;
}
}
else {
@@ -361,7 +413,13 @@ TestResult NotInRangeVerifier<T>::operator()(const ghoul::Dictionary& dict,
}
if (val >= lower && val <= upper) {
return { false, { { key, TestResult::Offense::Reason::Verification } }, {} };
TestResult r;
r.success = false;
TestResult::Offense o;
o.offender = key;
o.reason = TestResult::Offense::Reason::Verification;
r.offenses.push_back(o);
return r;
}
else {
return { true, {}, {} };
@@ -396,9 +454,10 @@ TestResult DeprecatedVerifier<T>::operator()(const ghoul::Dictionary& dict,
const std::string& key) const
{
TestResult res = T::operator()(dict, key);
res.warnings.push_back(
TestResult::Warning{ key, TestResult::Warning::Reason::Deprecated }
);
TestResult::Warning w;
w.offender = key;
w.reason = TestResult::Warning::Reason::Deprecated;
res.warnings.push_back(w);
return res;
}

View File

@@ -154,10 +154,10 @@ UrlSynchronization::UrlSynchronization(const ghoul::Dictionary& dict,
else {
documentation::TestResult res;
res.success = false;
res.offenses.push_back({
std::string(KeyIdentifier) + "|" + KeyUseHash,
documentation::TestResult::Offense::Reason::MissingKey
});
documentation::TestResult::Offense o;
o.offender = std::string(KeyIdentifier) + "|" + KeyUseHash;
o.reason = documentation::TestResult::Offense::Reason::MissingKey;
res.offenses.push_back(o);
throw documentation::SpecificationError(std::move(res), "UrlSynchronization");
}
}

View File

@@ -139,7 +139,9 @@ TestResult IntVerifier::operator()(const ghoul::Dictionary& dict,
{
if (dict.hasValue<int>(key)) {
// We have a key and the value is int, we are done
return { true, {}, {} };
TestResult res;
res.success = true;
return res;
}
else {
if (dict.hasKey(key)) {
@@ -149,19 +151,29 @@ TestResult IntVerifier::operator()(const ghoul::Dictionary& dict,
double intPart;
bool isInt = modf(value, &intPart) == 0.0;
if (isInt) {
return { true, {}, {} };
TestResult res;
res.success = true;
return res;
}
else {
return {
false,
{ { key, TestResult::Offense::Reason::WrongType } },
{}
};
TestResult res;
res.success = false;
TestResult::Offense o;
o.offender = key;
o.reason = TestResult::Offense::Reason::WrongType;
res.offenses.push_back(o);
return res;
}
}
else {
// If we don't have a double value, we cannot have an int value
return { false, {{ key, TestResult::Offense::Reason::WrongType }}, {} };
TestResult res;
res.success = false;
TestResult::Offense o;
o.offender = key;
o.reason = TestResult::Offense::Reason::WrongType;
res.offenses.push_back(o);
return res;
}
}
else {
@@ -264,17 +276,26 @@ TestResult Color3Verifier::operator()(const ghoul::Dictionary& dictionary,
glm::dvec3 values = dictionary.value<glm::dvec3>(key);
if (values.x < 0.0 || values.x > 1.0) {
res.success = false;
res.offenses.push_back({ key + ".x", TestResult::Offense::Reason::Verification });
TestResult::Offense o;
o.offender = key + ".x";
o.reason = TestResult::Offense::Reason::Verification;
res.offenses.push_back(o);
}
if (values.y < 0.0 || values.y > 1.0) {
res.success = false;
res.offenses.push_back({ key + ".y", TestResult::Offense::Reason::Verification });
TestResult::Offense o;
o.offender = key + ".y";
o.reason = TestResult::Offense::Reason::Verification;
res.offenses.push_back(o);
}
if (values.z < 0.0 || values.z > 1.0) {
res.success = false;
res.offenses.push_back({ key + ".z", TestResult::Offense::Reason::Verification });
TestResult::Offense o;
o.offender = key + ".z";
o.reason = TestResult::Offense::Reason::Verification;
res.offenses.push_back(o);
}
return res;
@@ -295,22 +316,34 @@ TestResult Color4Verifier::operator()(const ghoul::Dictionary& dictionary,
glm::dvec4 values = dictionary.value<glm::dvec4>(key);
if (values.x < 0.0 || values.x > 1.0) {
res.success = false;
res.offenses.push_back({ key + ".x", TestResult::Offense::Reason::Verification });
TestResult::Offense o;
o.offender = key + ".x";
o.reason = TestResult::Offense::Reason::Verification;
res.offenses.push_back(o);
}
if (values.y < 0.0 || values.y > 1.0) {
res.success = false;
res.offenses.push_back({ key + ".y", TestResult::Offense::Reason::Verification });
TestResult::Offense o;
o.offender = key + ".y";
o.reason = TestResult::Offense::Reason::Verification;
res.offenses.push_back(o);
}
if (values.z < 0.0 || values.z > 1.0) {
res.success = false;
res.offenses.push_back({ key + ".z", TestResult::Offense::Reason::Verification });
TestResult::Offense o;
o.offender = key + ".z";
o.reason = TestResult::Offense::Reason::Verification;
res.offenses.push_back(o);
}
if (values.w < 0.0 || values.w > 1.0) {
res.success = false;
res.offenses.push_back({ key + ".a", TestResult::Offense::Reason::Verification });
TestResult::Offense o;
o.offender = key + ".a";
o.reason = TestResult::Offense::Reason::Verification;
res.offenses.push_back(o);
}
return res;
@@ -325,7 +358,9 @@ TestResult TemplateVerifier<glm::ivec2>::operator()(const ghoul::Dictionary& dic
const std::string& key) const
{
if (dict.hasValue<glm::ivec2>(key)) {
return { true, {}, {} };
TestResult res;
res.success = true;
return res;
}
else {
if (dict.hasKey(key)) {
@@ -337,22 +372,38 @@ TestResult TemplateVerifier<glm::ivec2>::operator()(const ghoul::Dictionary& dic
modf(value.y, &intPart.y) == 0.0
};
if (isInt.x && isInt.y) {
return { true, {}, {} };
TestResult res;
res.success = true;
return res;
}
else {
return {
false,
{{ key, TestResult::Offense::Reason::WrongType }},
{}
};
TestResult res;
res.success = false;
TestResult::Offense o;
o.offender = key;
o.reason = TestResult::Offense::Reason::WrongType;
res.offenses.push_back(o);
return res;
}
}
else {
return { false, {{ key, TestResult::Offense::Reason::WrongType }}, {} };
TestResult res;
res.success = false;
TestResult::Offense o;
o.offender = key;
o.reason = TestResult::Offense::Reason::WrongType;
res.offenses.push_back(o);
return res;
}
}
else {
return { false, {{ key, TestResult::Offense::Reason::MissingKey }}, {} };
TestResult res;
res.success = false;
TestResult::Offense o;
o.offender = key;
o.reason = TestResult::Offense::Reason::MissingKey;
res.offenses.push_back(o);
return res;
}
}
}
@@ -362,7 +413,9 @@ TestResult TemplateVerifier<glm::ivec3>::operator()(const ghoul::Dictionary& dic
const std::string& key) const
{
if (dict.hasValue<glm::ivec3>(key)) {
return { true, {}, {} };
TestResult res;
res.success = true;
return res;
}
else {
if (dict.hasKey(key)) {
@@ -375,22 +428,38 @@ TestResult TemplateVerifier<glm::ivec3>::operator()(const ghoul::Dictionary& dic
modf(value.z, &intPart.z) == 0.0
};
if (isInt.x && isInt.y && isInt.z) {
return { true, {}, {} };
TestResult res;
res.success = true;
return res;
}
else {
return {
false,
{{ key, TestResult::Offense::Reason::WrongType }},
{}
};
TestResult res;
res.success = false;
TestResult::Offense o;
o.offender = key;
o.reason = TestResult::Offense::Reason::WrongType;
res.offenses.push_back(o);
return res;
}
}
else {
return { false, {{ key, TestResult::Offense::Reason::WrongType }}, {} };
TestResult res;
res.success = false;
TestResult::Offense o;
o.offender = key;
o.reason = TestResult::Offense::Reason::WrongType;
res.offenses.push_back(o);
return res;
}
}
else {
return { false, {{ key, TestResult::Offense::Reason::MissingKey }}, {} };
TestResult res;
res.success = false;
TestResult::Offense o;
o.offender = key;
o.reason = TestResult::Offense::Reason::MissingKey;
res.offenses.push_back(o);
return res;
}
}
}
@@ -400,7 +469,9 @@ TestResult TemplateVerifier<glm::ivec4>::operator()(const ghoul::Dictionary& dic
const std::string& key) const
{
if (dict.hasValue<glm::ivec4>(key)) {
return { true, {}, {} };
TestResult res;
res.success = true;
return res;
}
else {
if (dict.hasKey(key)) {
@@ -414,22 +485,38 @@ TestResult TemplateVerifier<glm::ivec4>::operator()(const ghoul::Dictionary& dic
modf(value.w, &intPart.w) == 0.0
};
if (isInt.x && isInt.y && isInt.z && isInt.w) {
return { true, {}, {} };
TestResult res;
res.success = true;
return res;
}
else {
return {
false,
{{ key, TestResult::Offense::Reason::WrongType }},
{}
};
TestResult res;
res.success = false;
TestResult::Offense o;
o.offender = key;
o.reason = TestResult::Offense::Reason::WrongType;
res.offenses.push_back(o);
return res;
}
}
else {
return { false, {{ key, TestResult::Offense::Reason::WrongType }}, {} };
TestResult res;
res.success = false;
TestResult::Offense o;
o.offender = key;
o.reason = TestResult::Offense::Reason::WrongType;
res.offenses.push_back(o);
return res;
}
}
else {
return { false, {{ key, TestResult::Offense::Reason::MissingKey }}, {} };
TestResult res;
res.success = false;
TestResult::Offense o;
o.offender = key;
o.reason = TestResult::Offense::Reason::MissingKey;
res.offenses.push_back(o);
return res;
}
}
}
@@ -459,11 +546,22 @@ TestResult TableVerifier::operator()(const ghoul::Dictionary& dictionary,
}
else {
if (dictionary.hasKey(key)) {
return { false, { { key, TestResult::Offense::Reason::WrongType } }, {} };
TestResult res;
res.success = false;
TestResult::Offense o;
o.offender = key;
o.reason = TestResult::Offense::Reason::WrongType;
res.offenses.push_back(o);
return res;
}
else {
return { false, { { key, TestResult::Offense::Reason::MissingKey } }, {} };
TestResult res;
res.success = false;
TestResult::Offense o;
o.offender = key;
o.reason = TestResult::Offense::Reason::MissingKey;
res.offenses.push_back(o);
return res;
}
}
}
@@ -512,11 +610,11 @@ TestResult ReferencingVerifier::operator()(const ghoul::Dictionary& dictionary,
);
if (it == docs.end()) {
res.offenses.push_back({
key,
TestResult::Offense::Reason::UnknownIdentifier
});
res.success = false;
TestResult::Offense o;
o.offender = key;
o.reason = TestResult::Offense::Reason::UnknownIdentifier;
res.offenses.push_back(o);
return res;
}
@@ -576,10 +674,18 @@ TestResult AndVerifier::operator()(const ghoul::Dictionary& dictionary,
);
if (success) {
return { true, {}, {} };
TestResult res;
res.success = true;
return res;
}
else {
return { false, { { key, TestResult::Offense::Reason::Verification } }, {} };
TestResult res;
res.success = false;
TestResult::Offense o;
o.offender = key;
o.reason = TestResult::Offense::Reason::Verification;
res.offenses.push_back(o);
return res;
}
}
@@ -645,10 +751,18 @@ TestResult OrVerifier::operator()(const ghoul::Dictionary& dictionary,
);
if (success) {
return { true, {}, {} };
TestResult res;
res.success = true;
return res;
}
else {
return { false, { { key, TestResult::Offense::Reason::Verification } }, {} };
TestResult res;
res.success = false;
TestResult::Offense o;
o.offender = key;
o.reason = TestResult::Offense::Reason::Verification;
res.offenses.push_back(o);
return res;
}
}