summaryrefslogtreecommitdiff
path: root/ZAPD/ZArray.cpp
diff options
context:
space:
mode:
authorEllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com>2021-11-27 20:06:29 +0000
committerGitHub <noreply@github.com>2021-11-27 15:06:29 -0500
commit0966109a1402ac4a070345f9e151b93064d09fc9 (patch)
tree58043fa7bd894bb57a61d843bca9e99492387df4 /ZAPD/ZArray.cpp
parent6948306d97a8d87c5ecae23c409894383badfe67 (diff)
Warning system (#189)
* first draft * take vt.h from mm repo * Colors * Fix argument types * Add argument parser to errorhandler * Rename ErrorHandler to WarningHandler * Add -Wno- and more warning types * header and body in warnings * Small cleanup * Replace a bunch of warnings with the new system Co-authored-by: EllipticEllipsis <EllipticEllipsis@users.noreply.github.com> * Move stuff around * Move stuff to header * Make some more VT macros, new Warning_Build function + macro, ZBackground * Add remaining warnings * Add ZResource* param to Warning_Resource * Add warning help message * Simplify help message a bit * Refactor warnings into lots of helper functions * Fix HANG_INDT in the wild * Builds now * Update macros to use bold * Fix body printing and error colour * Add -Werror= * Add warningType to HANDLE_ERROR * Change some throws into HANDLE_ERROR * Create init and main maps and write new help printer * Changed ZTextureAnimation to new w/e * Typo * Delete build warnings list file * Use ERROR in ZResource and ZPath * Remove extra structs * Move ifdef into the InitMap, add descriptions * Actually move into initMap and add descriptions... * Remove Everything from the WarningType enum * Make more of the handler arguments const for compatibility * Fix warning * Document macros a bit * Add ImageBackend ERRRORs * Note on Weverything, rename InvalidData to InvalidExtractedData * add texture and mesh warnings/errors * InvalidExtractedData * Add description for InvalidPNG * print which warnings are enabled by using debug verbosity * Fix everything * Fix some newlines * Move help to the end, start some documentation * Remove unnecessary `WarningHandler::`s * Remove commented code * Some more documentation * Make first letters consistenty lowercase, more docs * Consistently use lowercase, more docs * Format consistently, more detail in documentation * Simplify enabled warnings checks * Rename HANDLE_WARNING_BUILD and add HANDLE_ERROR_PROCESS * Delete BuildInfo.cpp * Use PROCESS where possible, bit more documentation * Add documenation to README, sort when printing help * Add an example, escalate the rest of the invalids by default * Format warning names in table * format readme * Remove old flags info * Remove obsolete variables * Format * assert.h -> cassert * Replace some asserts in ZTexture * Remove test file * Minor cleanup * Bit more in the help * Fix header includes * Format * One character in readme * Update README.md Co-authored-by: Anghelo Carvajal <angheloalf95@gmail.com> * Some Morita inspiration * Convert new errors * Static warnings/errors * Merge remote-tracking branch 'upstream/master' into errorlib * Add explanation for switch control flow * format * whooops * Fix segment warning that doesn't apply now we assume no segment means use VRAM * Comment out MM in Jenkinsfile Co-authored-by: Angie <angheloalf95@gmail.com> Co-authored-by: EllipticEllipsis <EllipticEllipsis@users.noreply.github.com>
Diffstat (limited to 'ZAPD/ZArray.cpp')
-rw-r--r--ZAPD/ZArray.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/ZAPD/ZArray.cpp b/ZAPD/ZArray.cpp
index b1ba3a6..ebfb13e 100644
--- a/ZAPD/ZArray.cpp
+++ b/ZAPD/ZArray.cpp
@@ -4,6 +4,7 @@
#include "Globals.h"
#include "Utils/StringHelper.h"
+#include "WarningHandler.h"
#include "ZFile.h"
REGISTER_ZFILENODE(Array, ZArray);
@@ -25,13 +26,18 @@ void ZArray::ParseXML(tinyxml2::XMLElement* reader)
ZResource::ParseXML(reader);
arrayCnt = reader->IntAttribute("Count", 0);
- // TODO: do a better check.
- assert(arrayCnt > 0);
+ if (arrayCnt <= 0)
+ {
+ HANDLE_ERROR_RESOURCE(WarningType::InvalidAttributeValue, parent, this, rawDataIndex,
+ "invalid value found for 'Count' attribute", "");
+ }
tinyxml2::XMLElement* child = reader->FirstChildElement();
if (child == nullptr)
- throw std::runtime_error(
- StringHelper::Sprintf("Error! Array needs at least one sub-element.\n"));
+ {
+ HANDLE_ERROR_RESOURCE(WarningType::InvalidXML, parent, this, rawDataIndex,
+ "<Array> needs one sub-element", "");
+ }
childName = child->Name();
@@ -42,9 +48,10 @@ void ZArray::ParseXML(tinyxml2::XMLElement* reader)
ZResource* res = nodeMap->at(childName)(parent);
if (!res->DoesSupportArray())
{
- throw std::runtime_error(StringHelper::Sprintf(
- "Error! Resource %s does not support being wrapped in an array!\n",
- childName.c_str()));
+ std::string errorHeader = StringHelper::Sprintf(
+ "resource <%s> does not support being wrapped in an <Array>", childName.c_str());
+ HANDLE_ERROR_RESOURCE(WarningType::InvalidXML, parent, this, rawDataIndex, errorHeader,
+ "");
}
res->parent = parent;
res->SetInnerNode(true);
@@ -87,7 +94,7 @@ Declaration* ZArray::DeclareVar(const std::string& prefix, const std::string& bo
std::string ZArray::GetBodySourceCode() const
{
- std::string output;
+ std::string output = "";
for (size_t i = 0; i < arrayCnt; i++)
{