mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-12-04 15:22:26 -05:00
d4c1c40c1d
* hacks to align strings for clang... wow just wow
* start work to getting built with clang
* fix issues with struct constructors, all builds, doesn't link still
* fix some narrowing issues that clang complains about
* fix compliation of zapd
* fix null deref in VersionInfo
* builds with clang
* make stringbuilding use StringHelper instead of addition
* fix linking
* add CLANG SHIP overlay on clang built versions
* doesn't need to be volatile
* mark unknown strings as extern
* rename some stuff
* can't align extern
* hopefully fix compilation for everythign
* expandtab
* allow setting LD
* Revert "allow setting LD"
This reverts commit 711aba6db2
.
maybe to use lld it should be a LDFLAG?
* -Wno-deprecated-declarations is required for newer versions of clang
on macOS 13 beta sdk, the version of apple clang requires this
* Add jenkins support for clang
* Forward CXX flags to stormlib compilation
* Move GCC only flags to check
* use exports to set multiarch setup
* Fix Jenkins forever
* use make instead of cmake --build
add some flags to build with clang-11 as well
* address review coments
- rework extraction to allow multi thread
- misc readability cleanup
* update makefile to add WARN on linux+clang
Co-authored-by: David Chavez <david@dcvz.io>
99 lines
2.4 KiB
C++
99 lines
2.4 KiB
C++
#include "ZSymbol.h"
|
|
|
|
#include "Utils/StringHelper.h"
|
|
#include "WarningHandler.h"
|
|
#include "ZFile.h"
|
|
|
|
REGISTER_ZFILENODE(Symbol, ZSymbol);
|
|
|
|
ZSymbol::ZSymbol(ZFile* nParent) : ZResource(nParent)
|
|
{
|
|
RegisterOptionalAttribute("Type");
|
|
RegisterOptionalAttribute("TypeSize");
|
|
RegisterOptionalAttribute("Count");
|
|
}
|
|
|
|
void ZSymbol::ParseXML(tinyxml2::XMLElement* reader)
|
|
{
|
|
ZResource::ParseXML(reader);
|
|
|
|
std::string typeXml = registeredAttributes.at("Type").value;
|
|
|
|
if (typeXml == "")
|
|
{
|
|
HANDLE_WARNING_RESOURCE(WarningType::MissingAttribute, parent, this, rawDataIndex,
|
|
"missing 'Type' attribute in <Symbol>", "Defaulting to 'void*'.");
|
|
type = "void*";
|
|
}
|
|
else
|
|
{
|
|
type = typeXml;
|
|
}
|
|
|
|
std::string typeSizeXml = registeredAttributes.at("TypeSize").value;
|
|
if (typeSizeXml == "")
|
|
{
|
|
HANDLE_WARNING_RESOURCE(WarningType::MissingAttribute, parent, this, rawDataIndex,
|
|
"missing 'TypeSize' attribute in <Symbol>", "Defaulting to '4'.");
|
|
typeSize = 4; // Size of a word.
|
|
}
|
|
else
|
|
{
|
|
typeSize = StringHelper::StrToL(typeSizeXml, 0);
|
|
}
|
|
|
|
if (registeredAttributes.at("Count").wasSet)
|
|
{
|
|
isArray = true;
|
|
|
|
std::string countXml = registeredAttributes.at("Count").value;
|
|
if (countXml != "")
|
|
count = StringHelper::StrToL(countXml, 0);
|
|
}
|
|
|
|
if (registeredAttributes.at("Static").value == "On")
|
|
{
|
|
HANDLE_WARNING_RESOURCE(WarningType::InvalidAttributeValue, parent, this, rawDataIndex,
|
|
"a <Symbol> cannot be marked as static",
|
|
"Disabling static for this resource.");
|
|
}
|
|
staticConf = StaticConfig::Off;
|
|
}
|
|
|
|
Declaration* ZSymbol::DeclareVar([[maybe_unused]] const std::string& prefix,
|
|
[[maybe_unused]] const std::string& bodyStr)
|
|
{
|
|
return nullptr;
|
|
}
|
|
|
|
size_t ZSymbol::GetRawDataSize() const
|
|
{
|
|
if (isArray)
|
|
return count * typeSize;
|
|
|
|
return typeSize;
|
|
}
|
|
|
|
std::string ZSymbol::GetSourceOutputHeader([[maybe_unused]] const std::string& prefix, std::set<std::string> *nameSet)
|
|
{
|
|
if (isArray)
|
|
{
|
|
if (count == 0)
|
|
return StringHelper::Sprintf("extern %s %s[];\n", type.c_str(), name.c_str());
|
|
else
|
|
return StringHelper::Sprintf("extern %s %s[%i];\n", type.c_str(), name.c_str(), count);
|
|
}
|
|
|
|
return StringHelper::Sprintf("extern %s %s;\n", type.c_str(), name.c_str());
|
|
}
|
|
|
|
std::string ZSymbol::GetSourceTypeName() const
|
|
{
|
|
return type;
|
|
}
|
|
|
|
ZResourceType ZSymbol::GetResourceType() const
|
|
{
|
|
return ZResourceType::Symbol;
|
|
}
|