mirror of
https://github.com/zeldaret/oot.git
synced 2025-08-12 18:01:16 +00:00
Update ZAPD (#1569)
* git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "094e79734" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "094e79734" git-subrepo: version: "0.4.6" origin: "https://github.com/ingydotnet/git-subrepo" commit: "110b9eb" * Add EnumData.xml where some names are now externalized * Remove legacy typedefs for zapd, no longer needed!
This commit is contained in:
parent
503f6d86d5
commit
4e55168eaa
97 changed files with 4225 additions and 2328 deletions
|
@ -4,61 +4,79 @@
|
|||
#include "Utils/StringHelper.h"
|
||||
|
||||
Declaration::Declaration(offset_t nAddress, DeclarationAlignment nAlignment, size_t nSize,
|
||||
const std::string& nText)
|
||||
const std::string& nBody)
|
||||
{
|
||||
address = nAddress;
|
||||
alignment = nAlignment;
|
||||
size = nSize;
|
||||
text = nText;
|
||||
declBody = nBody;
|
||||
}
|
||||
|
||||
Declaration::Declaration(offset_t nAddress, DeclarationAlignment nAlignment, size_t nSize,
|
||||
const std::string& nVarType, const std::string& nVarName, bool nIsArray,
|
||||
const std::string& nText)
|
||||
: Declaration(nAddress, nAlignment, nSize, nText)
|
||||
Declaration* Declaration::Create(offset_t declAddr, DeclarationAlignment declAlign, size_t declSize,
|
||||
const std::string& declType, const std::string& declName,
|
||||
const std::string& declBody)
|
||||
{
|
||||
varType = nVarType;
|
||||
varName = nVarName;
|
||||
isArray = nIsArray;
|
||||
Declaration* decl = new Declaration(declAddr, declAlign, declSize, declBody);
|
||||
|
||||
decl->declType = declType;
|
||||
decl->declName = declName;
|
||||
decl->declBody = declBody;
|
||||
|
||||
return decl;
|
||||
}
|
||||
|
||||
Declaration::Declaration(offset_t nAddress, DeclarationAlignment nAlignment, size_t nSize,
|
||||
const std::string& nVarType, const std::string& nVarName, bool nIsArray,
|
||||
size_t nArrayItemCnt, const std::string& nText)
|
||||
: Declaration(nAddress, nAlignment, nSize, nText)
|
||||
Declaration* Declaration::CreateArray(offset_t declAddr, DeclarationAlignment declAlign,
|
||||
size_t declSize, const std::string& declType,
|
||||
const std::string& declName, const std::string& declBody,
|
||||
size_t declArrayItemCnt, bool isDeclExternal)
|
||||
{
|
||||
varType = nVarType;
|
||||
varName = nVarName;
|
||||
isArray = nIsArray;
|
||||
arrayItemCnt = nArrayItemCnt;
|
||||
Declaration* decl = new Declaration(declAddr, declAlign, declSize, declBody);
|
||||
|
||||
decl->declName = declName;
|
||||
decl->declType = declType;
|
||||
decl->arrayItemCnt = declArrayItemCnt;
|
||||
decl->isExternal = isDeclExternal;
|
||||
decl->isArray = true;
|
||||
|
||||
return decl;
|
||||
}
|
||||
|
||||
Declaration::Declaration(offset_t nAddress, DeclarationAlignment nAlignment, size_t nSize,
|
||||
const std::string& nVarType, const std::string& nVarName, bool nIsArray,
|
||||
const std::string& nArrayItemCntStr, const std::string& nText)
|
||||
: Declaration(nAddress, nAlignment, nSize, nText)
|
||||
Declaration* Declaration::CreateArray(offset_t declAddr, DeclarationAlignment declAlign,
|
||||
size_t declSize, const std::string& declType,
|
||||
const std::string& declName, const std::string& declBody,
|
||||
const std::string& declArrayItemCntStr, bool isDeclExternal)
|
||||
{
|
||||
varType = nVarType;
|
||||
varName = nVarName;
|
||||
isArray = nIsArray;
|
||||
arrayItemCntStr = nArrayItemCntStr;
|
||||
Declaration* decl = new Declaration(declAddr, declAlign, declSize, declBody);
|
||||
|
||||
decl->declName = declName;
|
||||
decl->declType = declType;
|
||||
decl->arrayItemCntStr = declArrayItemCntStr;
|
||||
decl->isExternal = isDeclExternal;
|
||||
decl->isArray = true;
|
||||
|
||||
return decl;
|
||||
}
|
||||
|
||||
Declaration::Declaration(offset_t nAddress, DeclarationAlignment nAlignment, size_t nSize,
|
||||
const std::string& nVarType, const std::string& nVarName, bool nIsArray,
|
||||
size_t nArrayItemCnt, const std::string& nText, bool nIsExternal)
|
||||
: Declaration(nAddress, nAlignment, nSize, nVarType, nVarName, nIsArray, nArrayItemCnt, nText)
|
||||
Declaration* Declaration::CreateInclude(offset_t declAddr, const std::string& includePath,
|
||||
size_t declSize, const std::string& declType,
|
||||
const std::string& declName, const std::string& defines)
|
||||
{
|
||||
isExternal = nIsExternal;
|
||||
Declaration* decl = new Declaration(declAddr, DeclarationAlignment::Align4, declSize, "");
|
||||
decl->includePath = includePath;
|
||||
decl->declType = declType;
|
||||
decl->declName = declName;
|
||||
decl->defines = defines;
|
||||
|
||||
return decl;
|
||||
}
|
||||
|
||||
Declaration::Declaration(offset_t nAddress, const std::string& nIncludePath, size_t nSize,
|
||||
const std::string& nVarType, const std::string& nVarName)
|
||||
: Declaration(nAddress, DeclarationAlignment::Align4, nSize, "")
|
||||
Declaration* Declaration::CreatePlaceholder(offset_t declAddr, const std::string& declName)
|
||||
{
|
||||
includePath = nIncludePath;
|
||||
varType = nVarType;
|
||||
varName = nVarName;
|
||||
Declaration* decl = new Declaration(declAddr, DeclarationAlignment::Align4, 0, "");
|
||||
decl->declName = declName;
|
||||
decl->isPlaceholder = true;
|
||||
|
||||
return decl;
|
||||
}
|
||||
|
||||
bool Declaration::IsStatic() const
|
||||
|
@ -82,9 +100,6 @@ std::string Declaration::GetNormalDeclarationStr() const
|
|||
{
|
||||
std::string output;
|
||||
|
||||
if (preText != "")
|
||||
output += preText + "\n";
|
||||
|
||||
if (IsStatic())
|
||||
{
|
||||
output += "static ";
|
||||
|
@ -92,27 +107,28 @@ std::string Declaration::GetNormalDeclarationStr() const
|
|||
|
||||
if (isArray)
|
||||
{
|
||||
if (arrayItemCntStr != "" && (IsStatic() || forceArrayCnt))
|
||||
bool includeArraySize = (IsStatic() || forceArrayCnt);
|
||||
|
||||
if (includeArraySize)
|
||||
{
|
||||
output += StringHelper::Sprintf("%s %s[%s];\n", varType.c_str(), varName.c_str(),
|
||||
arrayItemCntStr.c_str());
|
||||
}
|
||||
else if (arrayItemCnt != 0 && (IsStatic() || forceArrayCnt))
|
||||
{
|
||||
output += StringHelper::Sprintf("%s %s[%i] = {\n", varType.c_str(), varName.c_str(),
|
||||
arrayItemCnt);
|
||||
if (arrayItemCntStr != "")
|
||||
output += StringHelper::Sprintf("%s %s[%s];\n", declType.c_str(), declName.c_str(),
|
||||
arrayItemCntStr.c_str());
|
||||
else
|
||||
output += StringHelper::Sprintf("%s %s[%i] = {\n", declType.c_str(),
|
||||
declName.c_str(), arrayItemCnt);
|
||||
}
|
||||
else
|
||||
{
|
||||
output += StringHelper::Sprintf("%s %s[] = {\n", varType.c_str(), varName.c_str());
|
||||
output += StringHelper::Sprintf("%s %s[] = {\n", declType.c_str(), declName.c_str());
|
||||
}
|
||||
|
||||
output += text + "\n";
|
||||
output += declBody + "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
output += StringHelper::Sprintf("%s %s = { ", varType.c_str(), varName.c_str());
|
||||
output += text;
|
||||
output += StringHelper::Sprintf("%s %s = { ", declType.c_str(), declName.c_str());
|
||||
output += declBody;
|
||||
}
|
||||
|
||||
if (output.back() == '\n')
|
||||
|
@ -120,14 +136,8 @@ std::string Declaration::GetNormalDeclarationStr() const
|
|||
else
|
||||
output += " };";
|
||||
|
||||
if (rightText != "")
|
||||
output += " " + rightText + "";
|
||||
|
||||
output += "\n";
|
||||
|
||||
if (postText != "")
|
||||
output += postText + "\n";
|
||||
|
||||
output += "\n";
|
||||
|
||||
return output;
|
||||
|
@ -137,41 +147,34 @@ std::string Declaration::GetExternalDeclarationStr() const
|
|||
{
|
||||
std::string output;
|
||||
|
||||
if (preText != "")
|
||||
output += preText + "\n";
|
||||
|
||||
if (IsStatic())
|
||||
{
|
||||
output += "static ";
|
||||
|
||||
bool includeArraySize = (IsStatic() || forceArrayCnt);
|
||||
|
||||
if (includeArraySize)
|
||||
{
|
||||
if (arrayItemCntStr != "")
|
||||
output += StringHelper::Sprintf("%s %s[%s] = ", declType.c_str(), declName.c_str(),
|
||||
arrayItemCntStr.c_str());
|
||||
else
|
||||
output += StringHelper::Sprintf("%s %s[%i] = ", declType.c_str(), declName.c_str(),
|
||||
arrayItemCnt);
|
||||
}
|
||||
else
|
||||
{
|
||||
output += StringHelper::Sprintf("%s %s[] = ", declType.c_str(), declName.c_str());
|
||||
}
|
||||
|
||||
if (arrayItemCntStr != "" && (IsStatic() || forceArrayCnt))
|
||||
output += StringHelper::Sprintf("%s %s[%s] = ", varType.c_str(), varName.c_str(),
|
||||
arrayItemCntStr.c_str());
|
||||
else if (arrayItemCnt != 0 && (IsStatic() || forceArrayCnt))
|
||||
output +=
|
||||
StringHelper::Sprintf("%s %s[%i] = ", varType.c_str(), varName.c_str(), arrayItemCnt);
|
||||
else
|
||||
output += StringHelper::Sprintf("%s %s[] = ", varType.c_str(), varName.c_str());
|
||||
|
||||
output += StringHelper::Sprintf("{\n#include \"%s\"\n};", includePath.c_str());
|
||||
|
||||
if (rightText != "")
|
||||
output += " " + rightText + "";
|
||||
|
||||
output += "\n";
|
||||
|
||||
if (postText != "")
|
||||
output += postText + "\n";
|
||||
|
||||
output += "\n";
|
||||
output += "\n\n";
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
std::string Declaration::GetExternStr() const
|
||||
{
|
||||
if (IsStatic() || varType == "" || isUnaccounted)
|
||||
if (IsStatic() || declType == "" || isUnaccounted)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
@ -180,19 +183,28 @@ std::string Declaration::GetExternStr() const
|
|||
{
|
||||
if (arrayItemCntStr != "" && (IsStatic() || forceArrayCnt))
|
||||
{
|
||||
return StringHelper::Sprintf("extern %s %s[%s];\n", varType.c_str(), varName.c_str(),
|
||||
return StringHelper::Sprintf("extern %s %s[%s];\n", declType.c_str(), declName.c_str(),
|
||||
arrayItemCntStr.c_str());
|
||||
}
|
||||
else if (arrayItemCnt != 0 && (IsStatic() || forceArrayCnt))
|
||||
{
|
||||
return StringHelper::Sprintf("extern %s %s[%i];\n", varType.c_str(), varName.c_str(),
|
||||
return StringHelper::Sprintf("extern %s %s[%i];\n", declType.c_str(), declName.c_str(),
|
||||
arrayItemCnt);
|
||||
}
|
||||
else
|
||||
return StringHelper::Sprintf("extern %s %s[];\n", varType.c_str(), varName.c_str());
|
||||
return StringHelper::Sprintf("extern %s %s[];\n", declType.c_str(), declName.c_str());
|
||||
}
|
||||
|
||||
return StringHelper::Sprintf("extern %s %s;\n", varType.c_str(), varName.c_str());
|
||||
return StringHelper::Sprintf("extern %s %s;\n", declType.c_str(), declName.c_str());
|
||||
}
|
||||
|
||||
std::string Declaration::GetDefinesStr() const
|
||||
{
|
||||
if (IsStatic() || (declType == ""))
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return StringHelper::Sprintf("%s", defines.c_str());
|
||||
}
|
||||
|
||||
std::string Declaration::GetStaticForwardDeclarationStr() const
|
||||
|
@ -210,15 +222,15 @@ std::string Declaration::GetStaticForwardDeclarationStr() const
|
|||
|
||||
if (arrayItemCntStr != "")
|
||||
{
|
||||
return StringHelper::Sprintf("static %s %s[%s];\n", varType.c_str(), varName.c_str(),
|
||||
return StringHelper::Sprintf("static %s %s[%s];\n", declType.c_str(), declName.c_str(),
|
||||
arrayItemCntStr.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
return StringHelper::Sprintf("static %s %s[%i];\n", varType.c_str(), varName.c_str(),
|
||||
return StringHelper::Sprintf("static %s %s[%i];\n", declType.c_str(), declName.c_str(),
|
||||
arrayItemCnt);
|
||||
}
|
||||
}
|
||||
|
||||
return StringHelper::Sprintf("static %s %s;\n", varType.c_str(), varName.c_str());
|
||||
return StringHelper::Sprintf("static %s %s;\n", declType.c_str(), declName.c_str());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue