diff options
| author | louist103 <35883445+louist103@users.noreply.github.com> | 2021-04-24 16:42:52 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-24 16:42:52 -0400 |
| commit | 6d27dbaab3b32ccebb076895fac3cc6aa3240d6c (patch) | |
| tree | 601c6ab5bef2f93b6d6ef4ba5506eb04dfb59c9f /ZAPD/ZFile.cpp | |
| parent | ee8bdea252db4c764f4a2567c32754118fdce10b (diff) | |
Fix most -Wall warnings (#115)
* started on basic type errors
* Done. For now
* remove libgfxd binary
* Most warnings fixed
* Fix conflicts and new warnings
* Makefile
* Sig
* Clang format
* destructor
* Add a bunch of destructors
* clear the scalars vector after freeing the elements
* PR fixes (Anghelo Alf)
* Fix most clang -Wall warnings
Diffstat (limited to 'ZAPD/ZFile.cpp')
| -rw-r--r-- | ZAPD/ZFile.cpp | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/ZAPD/ZFile.cpp b/ZAPD/ZFile.cpp index 79a0a4d..c8e6b71 100644 --- a/ZAPD/ZFile.cpp +++ b/ZAPD/ZFile.cpp @@ -66,7 +66,13 @@ ZFile::ZFile(ZFileMode mode, XMLElement* reader, string nBasePath, string nOutPa ZFile::~ZFile() { for (ZResource* res : resources) + { delete res; + } + + for(auto d : declarations) { + delete d.second; + } } void ZFile::ParseXML(ZFileMode mode, XMLElement* reader, std::string filename, bool placeholderMode) @@ -76,7 +82,7 @@ void ZFile::ParseXML(ZFileMode mode, XMLElement* reader, std::string filename, b else name = filename; - int segment = -1; + int32_t segment = -1; // TODO: This should be a variable on the ZFile, but it is a large change in order to force all // ZResource types to have a parent ZFile. @@ -111,7 +117,6 @@ void ZFile::ParseXML(ZFileMode mode, XMLElement* reader, std::string filename, b if (segment != -1) { - // printf("Adding Segment %i\n", segment); Globals::Instance->AddSegment(segment); } @@ -131,7 +136,7 @@ void ZFile::ParseXML(ZFileMode mode, XMLElement* reader, std::string filename, b std::unordered_set<std::string> offsetSet; auto nodeMap = *GetNodeMap(); - int rawDataIndex = 0; + uint32_t rawDataIndex = 0; for (XMLElement* child = reader->FirstChildElement(); child != NULL; child = child->NextSiblingElement()) @@ -185,8 +190,6 @@ void ZFile::ParseXML(ZFileMode mode, XMLElement* reader, std::string filename, b if (mode == ZFileMode::Extract) nRes->ExtractFromXML(child, rawData, rawDataIndex, folderName); - // else - // nRes->ExtractFromFile(); // TODO: See if we can make this part of the ZRoom code... if (nRes->GetResourceType() == ZResourceType::Room) @@ -237,9 +240,9 @@ void ZFile::BuildSourceFile(string outputDir) GenerateSourceFiles(outputDir); } -std::string ZFile::GetVarName(int address) +std::string ZFile::GetVarName(uint32_t address) { - for (pair<int32_t, Declaration*> pair : declarations) + for (pair<uint32_t, Declaration*> pair : declarations) { if (pair.first == address) return pair.second->varName; @@ -257,9 +260,6 @@ void ZFile::ExtractResources(string outputDir) { string folderName = Path::GetFileNameWithoutExtension(outputPath); - // printf("DIR CHECK: %s\n", folderName.c_str()); - // printf("OUT CHECK: %s\n", outputDir.c_str()); - if (!Directory::Exists(outputPath)) Directory::CreateDirectory(outputPath); @@ -314,13 +314,13 @@ std::vector<ZResource*> ZFile::GetResourcesOfType(ZResourceType resType) return resList; } -Declaration* ZFile::AddDeclaration(uint32_t address, DeclarationAlignment alignment, uint32_t size, +Declaration* ZFile::AddDeclaration(uint32_t address, DeclarationAlignment alignment, size_t size, std::string varType, std::string varName, std::string body) { #if _DEBUG if (declarations.find(address) != declarations.end()) { - int bp = 0; + int32_t bp = 0; } #endif @@ -332,13 +332,13 @@ Declaration* ZFile::AddDeclaration(uint32_t address, DeclarationAlignment alignm } Declaration* ZFile::AddDeclaration(uint32_t address, DeclarationAlignment alignment, - DeclarationPadding padding, uint32_t size, string varType, + DeclarationPadding padding, size_t size, string varType, string varName, std::string body) { #if _DEBUG if (declarations.find(address) != declarations.end()) { - int bp = 0; + int32_t bp = 0; } #endif @@ -350,13 +350,13 @@ Declaration* ZFile::AddDeclaration(uint32_t address, DeclarationAlignment alignm } Declaration* ZFile::AddDeclarationArray(uint32_t address, DeclarationAlignment alignment, - uint32_t size, std::string varType, std::string varName, - int arrayItemCnt, std::string body) + size_t size, std::string varType, std::string varName, + size_t arrayItemCnt, std::string body) { #if _DEBUG if (declarations.find(address) != declarations.end()) { - int bp = 0; + int32_t bp = 0; } #endif @@ -368,13 +368,13 @@ Declaration* ZFile::AddDeclarationArray(uint32_t address, DeclarationAlignment a } Declaration* ZFile::AddDeclarationArray(uint32_t address, DeclarationAlignment alignment, - uint32_t size, std::string varType, std::string varName, - int arrayItemCnt, std::string body, bool isExternal) + size_t size, std::string varType, std::string varName, + size_t arrayItemCnt, std::string body, bool isExternal) { #if _DEBUG if (declarations.find(address) != declarations.end()) { - int bp = 0; + int32_t bp = 0; } #endif @@ -386,13 +386,13 @@ Declaration* ZFile::AddDeclarationArray(uint32_t address, DeclarationAlignment a } Declaration* ZFile::AddDeclarationArray(uint32_t address, DeclarationAlignment alignment, - DeclarationPadding padding, uint32_t size, string varType, - string varName, int arrayItemCnt, std::string body) + DeclarationPadding padding, size_t size, string varType, + string varName, size_t arrayItemCnt, std::string body) { #if _DEBUG if (declarations.find(address) != declarations.end()) { - int bp = 0; + int32_t bp = 0; } #endif @@ -424,7 +424,7 @@ Declaration* ZFile::AddDeclarationPlaceholder(uint32_t address, string varName) return declarations[address]; } -Declaration* ZFile::AddDeclarationInclude(uint32_t address, string includePath, uint32_t size, +Declaration* ZFile::AddDeclarationInclude(uint32_t address, string includePath, size_t size, string varType, string varName) { AddDeclarationDebugChecks(address); @@ -436,18 +436,18 @@ Declaration* ZFile::AddDeclarationInclude(uint32_t address, string includePath, } Declaration* ZFile::AddDeclarationIncludeArray(uint32_t address, std::string includePath, - uint32_t size, std::string varType, - std::string varName, int arrayItemCnt) + size_t size, std::string varType, + std::string varName, size_t arrayItemCnt) { #if _DEBUG if (declarations.find(address) != declarations.end()) { - int bp = 0; + int32_t bp = 0; } if (address == 0) { - int bp = 0; + int32_t bp = 0; } #endif @@ -488,7 +488,7 @@ void ZFile::AddDeclarationDebugChecks(uint32_t address) #ifdef _DEBUG if (address == 0x0000) { - int bp = 0; + int32_t bp = 0; } #endif } @@ -701,7 +701,7 @@ string ZFile::ProcessDeclarations() pair<int32_t, Declaration*> lastItem = declarationKeys[0]; - for (int i = 1; i < declarationKeys.size(); i++) + for (size_t i = 1; i < declarationKeys.size(); i++) { pair<int32_t, Declaration*> curItem = declarationKeys[i]; @@ -712,7 +712,7 @@ string ZFile::ProcessDeclarations() // TEST: For now just do Vtx declarations... if (lastItem.second->varType == "static Vtx") { - int sizeDiff = curItem.first - (lastItem.first + lastItem.second->size); + int32_t sizeDiff = curItem.first - (lastItem.first + lastItem.second->size); // Make sure there isn't an unaccounted inbetween these two if (sizeDiff == 0) @@ -744,8 +744,8 @@ string ZFile::ProcessDeclarations() { if (item.second->alignment == DeclarationAlignment::Align16) { - // int lastAddrSizeTest = declarations[lastAddr]->size; - int curPtr = lastAddr + declarations[lastAddr]->size; + // int32_t lastAddrSizeTest = declarations[lastAddr]->size; + int32_t curPtr = lastAddr + declarations[lastAddr]->size; while (curPtr % 4 != 0) { @@ -767,7 +767,7 @@ string ZFile::ProcessDeclarations() } else if (item.second->alignment == DeclarationAlignment::Align8) { - int curPtr = lastAddr + declarations[lastAddr]->size; + int32_t curPtr = lastAddr + declarations[lastAddr]->size; while (curPtr % 4 != 0) { @@ -792,7 +792,7 @@ string ZFile::ProcessDeclarations() if (item.second->padding == DeclarationPadding::Pad16) { - int curPtr = item.first + item.second->size; + int32_t curPtr = item.first + item.second->size; while (curPtr % 4 != 0) { @@ -922,7 +922,7 @@ string ZFile::ProcessDeclarations() // Go through include declarations // First, handle the prototypes (static only for now) - int protoCnt = 0; + int32_t protoCnt = 0; for (pair<uint32_t, Declaration*> item : declarations) { if (StringHelper::StartsWith(item.second->varType, "static ") && @@ -1093,8 +1093,8 @@ void ZFile::ProcessDeclarationText(Declaration* decl) { if (refDecl->arrayItemCnt != 0) { - int itemSize = refDecl->size / refDecl->arrayItemCnt; - int itemIndex = (decl->references[refIndex] - refDeclAddr) / itemSize; + int32_t itemSize = refDecl->size / refDecl->arrayItemCnt; + int32_t itemIndex = (decl->references[refIndex] - refDeclAddr) / itemSize; decl->text.replace(i, 2, StringHelper::Sprintf( |
