From 797ddf7dafb3a03fb50d08f1822bd5e942d9da8b Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 29 Mar 2021 14:58:19 +0200 Subject: [PATCH] Fix some warnings on AppleClang --- include/openspace/documentation/verifier.inl | 87 ++++++-- modules/sync/syncs/urlsynchronization.cpp | 8 +- src/documentation/verifier.cpp | 220 ++++++++++++++----- 3 files changed, 244 insertions(+), 71 deletions(-) diff --git a/include/openspace/documentation/verifier.inl b/include/openspace/documentation/verifier.inl index d61169dd2c..7363b325ec 100644 --- a/include/openspace/documentation/verifier.inl +++ b/include/openspace/documentation/verifier.inl @@ -45,17 +45,27 @@ template TestResult TemplateVerifier::operator()(const ghoul::Dictionary& dict, const std::string& key) const { + TestResult res; if (dict.hasValue(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 @@ -143,7 +153,13 @@ TestResult OperatorVerifier::operator()(const ghoul::Dictionary& di val = static_cast(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::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::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::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::operator()(const ghoul::Dictionary& dict, val = static_cast(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::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::operator()(const ghoul::Dictionary& dict, val = static_cast(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::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::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; } diff --git a/modules/sync/syncs/urlsynchronization.cpp b/modules/sync/syncs/urlsynchronization.cpp index a8b7ee98fb..2d88784903 100644 --- a/modules/sync/syncs/urlsynchronization.cpp +++ b/modules/sync/syncs/urlsynchronization.cpp @@ -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"); } } diff --git a/src/documentation/verifier.cpp b/src/documentation/verifier.cpp index 223de8bd57..0b5779c5a9 100644 --- a/src/documentation/verifier.cpp +++ b/src/documentation/verifier.cpp @@ -139,7 +139,9 @@ TestResult IntVerifier::operator()(const ghoul::Dictionary& dict, { if (dict.hasValue(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(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(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::operator()(const ghoul::Dictionary& dic const std::string& key) const { if (dict.hasValue(key)) { - return { true, {}, {} }; + TestResult res; + res.success = true; + return res; } else { if (dict.hasKey(key)) { @@ -337,22 +372,38 @@ TestResult TemplateVerifier::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::operator()(const ghoul::Dictionary& dic const std::string& key) const { if (dict.hasValue(key)) { - return { true, {}, {} }; + TestResult res; + res.success = true; + return res; } else { if (dict.hasKey(key)) { @@ -375,22 +428,38 @@ TestResult TemplateVerifier::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::operator()(const ghoul::Dictionary& dic const std::string& key) const { if (dict.hasValue(key)) { - return { true, {}, {} }; + TestResult res; + res.success = true; + return res; } else { if (dict.hasKey(key)) { @@ -414,22 +485,38 @@ TestResult TemplateVerifier::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; } }