mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-22 09:05:44 +00:00
wip: use std::format for zcg templates
This commit is contained in:
parent
02b2c93e30
commit
6bbc3fa37e
@ -56,8 +56,8 @@ namespace
|
||||
void CreateFromString(const std::string& templateString)
|
||||
{
|
||||
const auto templateStringLength = templateString.size();
|
||||
auto partStart = 0u;
|
||||
for (auto i = 0u; i < templateStringLength; i++)
|
||||
auto partStart = 0uz;
|
||||
for (auto i = 0uz; i < templateStringLength; i++)
|
||||
{
|
||||
if (templateString[i] != '?')
|
||||
continue;
|
||||
|
@ -245,7 +245,7 @@ void UnlinkerArgs::AddSpecifiedAssetType(std::string value)
|
||||
|
||||
void UnlinkerArgs::ParseCommaSeparatedAssetTypeString(const std::string& input)
|
||||
{
|
||||
auto currentPos = 0u;
|
||||
auto currentPos = 0uz;
|
||||
size_t endPos;
|
||||
|
||||
std::string lowerInput(input);
|
||||
|
@ -74,7 +74,7 @@ void BaseTemplate::MakeTypeWrittenPtrVarNameInternal(const DataDefinition* def,
|
||||
|
||||
void BaseTemplate::MakeArrayIndicesInternal(const DeclarationModifierComputations& modifierComputations, std::ostringstream& str)
|
||||
{
|
||||
for (auto index : modifierComputations.GetArrayIndices())
|
||||
for (const auto index : modifierComputations.GetArrayIndices())
|
||||
{
|
||||
str << "[" << index << "]";
|
||||
}
|
||||
@ -115,7 +115,7 @@ std::string BaseTemplate::MakeSafeTypeName(const DataDefinition* def)
|
||||
return str.str();
|
||||
}
|
||||
|
||||
std::string BaseTemplate::MakeMemberAccess(StructureInformation* info, MemberInformation* member, const DeclarationModifierComputations& modifier)
|
||||
std::string BaseTemplate::MakeMemberAccess(const StructureInformation* info, const MemberInformation* member, const DeclarationModifierComputations& modifier)
|
||||
{
|
||||
std::ostringstream str;
|
||||
MakeTypeVarNameInternal(info->m_definition, str);
|
||||
@ -125,7 +125,8 @@ std::string BaseTemplate::MakeMemberAccess(StructureInformation* info, MemberInf
|
||||
return str.str();
|
||||
}
|
||||
|
||||
std::string BaseTemplate::MakeWrittenMemberAccess(StructureInformation* info, MemberInformation* member, const DeclarationModifierComputations& modifier)
|
||||
std::string
|
||||
BaseTemplate::MakeWrittenMemberAccess(const StructureInformation* info, const MemberInformation* member, const DeclarationModifierComputations& modifier)
|
||||
{
|
||||
std::ostringstream str;
|
||||
MakeTypeWrittenVarNameInternal(info->m_definition, str);
|
||||
@ -137,7 +138,7 @@ std::string BaseTemplate::MakeWrittenMemberAccess(StructureInformation* info, Me
|
||||
|
||||
std::string BaseTemplate::MakeMemberAccess(const std::string& variableName,
|
||||
StructureInformation* info,
|
||||
MemberInformation* member,
|
||||
const MemberInformation* member,
|
||||
const DeclarationModifierComputations& modifier)
|
||||
{
|
||||
std::ostringstream str;
|
||||
@ -185,13 +186,13 @@ std::string BaseTemplate::MakeArrayIndices(const DeclarationModifierComputations
|
||||
return str.str();
|
||||
}
|
||||
|
||||
std::string BaseTemplate::MakeCustomActionCall(CustomAction* action)
|
||||
std::string BaseTemplate::MakeCustomActionCall(const CustomAction* action)
|
||||
{
|
||||
std::ostringstream str;
|
||||
str << "m_actions." << action->m_action_name << "(";
|
||||
|
||||
auto first = true;
|
||||
for (auto* def : action->m_parameter_types)
|
||||
for (const auto* def : action->m_parameter_types)
|
||||
{
|
||||
if (first)
|
||||
{
|
||||
|
@ -7,13 +7,13 @@
|
||||
#include "Domain/Evaluation/Operation.h"
|
||||
#include "Generating/RenderingContext.h"
|
||||
|
||||
#include <format>
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
|
||||
class BaseTemplate
|
||||
{
|
||||
protected:
|
||||
static constexpr const char* INTENDATION = " ";
|
||||
static constexpr auto INTENDATION = " ";
|
||||
|
||||
BaseTemplate(std::ostream& stream, RenderingContext* context);
|
||||
|
||||
@ -26,16 +26,17 @@ protected:
|
||||
static std::string MakeTypePtrVarName(const DataDefinition* def);
|
||||
static std::string MakeTypeWrittenPtrVarName(const DataDefinition* def);
|
||||
static std::string MakeSafeTypeName(const DataDefinition* def);
|
||||
static std::string MakeMemberAccess(StructureInformation* info, MemberInformation* member, const DeclarationModifierComputations& modifier);
|
||||
static std::string MakeWrittenMemberAccess(StructureInformation* info, MemberInformation* member, const DeclarationModifierComputations& modifier);
|
||||
static std::string MakeMemberAccess(const StructureInformation* info, const MemberInformation* member, const DeclarationModifierComputations& modifier);
|
||||
static std::string
|
||||
MakeWrittenMemberAccess(const StructureInformation* info, const MemberInformation* member, const DeclarationModifierComputations& modifier);
|
||||
static std::string MakeMemberAccess(const std::string& variableName,
|
||||
StructureInformation* info,
|
||||
MemberInformation* member,
|
||||
const MemberInformation* member,
|
||||
const DeclarationModifierComputations& modifier);
|
||||
static std::string MakeTypeDecl(const TypeDeclaration* decl);
|
||||
static std::string MakeFollowingReferences(const std::vector<DeclarationModifier*>& modifiers);
|
||||
static std::string MakeArrayIndices(const DeclarationModifierComputations& modifierComputations);
|
||||
static std::string MakeCustomActionCall(CustomAction* action);
|
||||
static std::string MakeCustomActionCall(const CustomAction* action);
|
||||
static std::string MakeArrayCount(const ArrayDeclarationModifier* arrayModifier);
|
||||
static std::string MakeEvaluation(const IEvaluation* evaluation);
|
||||
|
||||
@ -61,16 +62,34 @@ private:
|
||||
DoIntendation(); \
|
||||
m_out << x << "\n"; \
|
||||
}
|
||||
#define LINEF(...) \
|
||||
{ \
|
||||
DoIntendation(); \
|
||||
m_out << std::format(__VA_ARGS__) << "\n"; \
|
||||
}
|
||||
#define LINE_START(x) \
|
||||
{ \
|
||||
DoIntendation(); \
|
||||
m_out << x; \
|
||||
}
|
||||
#define LINE_STARTF(...) \
|
||||
{ \
|
||||
DoIntendation(); \
|
||||
m_out << std::format(__VA_ARGS__); \
|
||||
}
|
||||
#define LINE_MIDDLE(x) \
|
||||
{ \
|
||||
m_out << x; \
|
||||
}
|
||||
#define LINE_MIDDLEF(...) \
|
||||
{ \
|
||||
m_out << std::format(__VA_ARGS__); \
|
||||
}
|
||||
#define LINE_END(x) \
|
||||
{ \
|
||||
m_out << x << "\n"; \
|
||||
}
|
||||
#define LINE_ENDF(...) \
|
||||
{ \
|
||||
m_out << std::format(__VA_ARGS__) << "\n"; \
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "Loading/ContentLoaderBase.h"
|
||||
#include "Loading/IContentLoadingEntryPoint.h"
|
||||
@ -7,17 +8,18 @@ namespace IW4
|
||||
{
|
||||
class ContentLoader final : public ContentLoaderBase, public IContentLoadingEntryPoint
|
||||
{
|
||||
XAsset* varXAsset;
|
||||
ScriptStringList* varScriptStringList;
|
||||
public:
|
||||
ContentLoader();
|
||||
|
||||
void Load(Zone* zone, IZoneInputStream* stream) override;
|
||||
|
||||
private:
|
||||
void LoadScriptStringList(bool atStreamStart);
|
||||
|
||||
void LoadXAsset(bool atStreamStart) const;
|
||||
void LoadXAssetArray(bool atStreamStart, size_t count);
|
||||
|
||||
public:
|
||||
ContentLoader();
|
||||
|
||||
void Load(Zone* zone, IZoneInputStream* stream) override;
|
||||
XAsset* varXAsset;
|
||||
ScriptStringList* varScriptStringList;
|
||||
};
|
||||
} // namespace IW4
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
LoadDataInBlock(const_cast<void*>(reinterpret_cast<const void*>(dst)), sizeof(T));
|
||||
}
|
||||
|
||||
template<typename T> void Load(T* dst, const uint32_t count)
|
||||
template<typename T> void Load(T* dst, const size_t count)
|
||||
{
|
||||
LoadDataInBlock(const_cast<void*>(reinterpret_cast<const void*>(dst)), count * sizeof(T));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user