mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-05-07 13:04:58 +00:00
Merge pull request #423 from Laupetin/refactor/asset-struct-for-zcg
refactor: asset struct for zcg
This commit is contained in:
commit
f4870de1a7
@ -13,12 +13,22 @@
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
bool IsStringizeParameterForwardLookup(const std::string& value, size_t pos)
|
constexpr auto DEFINE_DIRECTIVE = "define";
|
||||||
|
constexpr auto UNDEF_DIRECTIVE = "undef";
|
||||||
|
constexpr auto IF_DIRECTIVE = "if";
|
||||||
|
constexpr auto ELIF_DIRECTIVE = "elif";
|
||||||
|
constexpr auto IFDEF_DIRECTIVE = "ifdef";
|
||||||
|
constexpr auto IFNDEF_DIRECTIVE = "ifndef";
|
||||||
|
constexpr auto ELSE_DIRECTIVE = "else";
|
||||||
|
constexpr auto ENDIF_DIRECTIVE = "endif";
|
||||||
|
constexpr auto DEFINED_KEYWORD = "defined";
|
||||||
|
|
||||||
|
bool IsStringizeParameterForwardLookup(const std::string& value, const size_t pos)
|
||||||
{
|
{
|
||||||
return pos + 1 && (isalpha(value[pos + 1]) || value[pos + 1] == '_');
|
return pos + 1 && (isalpha(value[pos + 1]) || value[pos + 1] == '_');
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsTokenPastingOperatorForwardLookup(const std::string& value, size_t pos)
|
bool IsTokenPastingOperatorForwardLookup(const std::string& value, const size_t pos)
|
||||||
{
|
{
|
||||||
return pos + 1 < value.size() && value[pos + 1] == '#';
|
return pos + 1 < value.size() && value[pos + 1] == '#';
|
||||||
}
|
}
|
||||||
@ -31,7 +41,7 @@ DefinesStreamProxy::DefineParameterPosition::DefineParameterPosition()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
DefinesStreamProxy::DefineParameterPosition::DefineParameterPosition(const unsigned index, const size_t position, const bool stringize)
|
DefinesStreamProxy::DefineParameterPosition::DefineParameterPosition(const unsigned index, const unsigned position, const bool stringize)
|
||||||
: m_parameter_index(index),
|
: m_parameter_index(index),
|
||||||
m_parameter_position(position),
|
m_parameter_position(position),
|
||||||
m_stringize(stringize)
|
m_stringize(stringize)
|
||||||
@ -591,7 +601,6 @@ bool DefinesStreamProxy::FindNextMacro(const std::string& input, unsigned& input
|
|||||||
{
|
{
|
||||||
const auto inputSize = input.size();
|
const auto inputSize = input.size();
|
||||||
auto wordStart = 0u;
|
auto wordStart = 0u;
|
||||||
auto lastWordEnd = 0u;
|
|
||||||
auto inWord = false;
|
auto inWord = false;
|
||||||
auto inString = false;
|
auto inString = false;
|
||||||
auto stringEscape = false;
|
auto stringEscape = false;
|
||||||
@ -763,8 +772,7 @@ namespace
|
|||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void DefinesStreamProxy::ProcessTokenPastingOperators(
|
void DefinesStreamProxy::ProcessTokenPastingOperators(const ParserLine& line, const unsigned& linePos, std::string& input)
|
||||||
const ParserLine& line, const unsigned& linePos, std::vector<const Define*>& callstack, std::string& input, unsigned& inputPos)
|
|
||||||
{
|
{
|
||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
|
|
||||||
@ -853,18 +861,17 @@ void DefinesStreamProxy::ExpandMacro(ParserLine& line,
|
|||||||
unsigned& linePos,
|
unsigned& linePos,
|
||||||
std::ostringstream& out,
|
std::ostringstream& out,
|
||||||
std::vector<const Define*>& callstack,
|
std::vector<const Define*>& callstack,
|
||||||
const DefinesStreamProxy::Define* macro,
|
const Define* macro,
|
||||||
const std::vector<std::string>& parameterValues)
|
const std::vector<std::string>& parameterValues)
|
||||||
{
|
{
|
||||||
std::ostringstream rawOutput;
|
std::ostringstream rawOutput;
|
||||||
InsertMacroParameters(rawOutput, macro, parameterValues);
|
InsertMacroParameters(rawOutput, macro, parameterValues);
|
||||||
|
|
||||||
std::string str = rawOutput.str();
|
std::string str = rawOutput.str();
|
||||||
unsigned nestedPos = 0;
|
ProcessNestedMacros(line, linePos, callstack, str);
|
||||||
ProcessNestedMacros(line, linePos, callstack, str, nestedPos);
|
|
||||||
|
|
||||||
if (macro->m_contains_token_pasting_operators)
|
if (macro->m_contains_token_pasting_operators)
|
||||||
ProcessTokenPastingOperators(line, linePos, callstack, str, nestedPos);
|
ProcessTokenPastingOperators(line, linePos, str);
|
||||||
|
|
||||||
out << str;
|
out << str;
|
||||||
}
|
}
|
||||||
@ -966,7 +973,7 @@ void DefinesStreamProxy::ContinueMultiLineMacro(ParserLine& line)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefinesStreamProxy::ProcessNestedMacros(ParserLine& line, unsigned& linePos, std::vector<const Define*>& callstack, std::string& input, unsigned& inputPos)
|
void DefinesStreamProxy::ProcessNestedMacros(ParserLine& line, unsigned& linePos, std::vector<const Define*>& callstack, std::string& input)
|
||||||
{
|
{
|
||||||
bool usesDefines = false;
|
bool usesDefines = false;
|
||||||
|
|
||||||
@ -1021,7 +1028,7 @@ void DefinesStreamProxy::ProcessMacrosSingleLine(ParserLine& line)
|
|||||||
{
|
{
|
||||||
unsigned pos = 0;
|
unsigned pos = 0;
|
||||||
std::vector<const Define*> callstack;
|
std::vector<const Define*> callstack;
|
||||||
ProcessNestedMacros(line, pos, callstack, line.m_line, pos);
|
ProcessNestedMacros(line, pos, callstack, line.m_line);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefinesStreamProxy::ProcessMacrosMultiLine(ParserLine& line)
|
void DefinesStreamProxy::ProcessMacrosMultiLine(ParserLine& line)
|
||||||
|
@ -13,42 +13,30 @@
|
|||||||
|
|
||||||
class DefinesStreamProxy final : public AbstractDirectiveStreamProxy
|
class DefinesStreamProxy final : public AbstractDirectiveStreamProxy
|
||||||
{
|
{
|
||||||
static constexpr const char* DEFINE_DIRECTIVE = "define";
|
|
||||||
static constexpr const char* UNDEF_DIRECTIVE = "undef";
|
|
||||||
static constexpr const char* IF_DIRECTIVE = "if";
|
|
||||||
static constexpr const char* ELIF_DIRECTIVE = "elif";
|
|
||||||
static constexpr const char* IFDEF_DIRECTIVE = "ifdef";
|
|
||||||
static constexpr const char* IFNDEF_DIRECTIVE = "ifndef";
|
|
||||||
static constexpr const char* ELSE_DIRECTIVE = "else";
|
|
||||||
static constexpr const char* ENDIF_DIRECTIVE = "endif";
|
|
||||||
static constexpr const char* DEFINED_KEYWORD = "defined";
|
|
||||||
|
|
||||||
static constexpr auto MAX_DEFINE_ITERATIONS = 128u;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
class DefineParameterPosition
|
class DefineParameterPosition
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
unsigned m_parameter_index;
|
|
||||||
size_t m_parameter_position;
|
|
||||||
bool m_stringize;
|
|
||||||
|
|
||||||
DefineParameterPosition();
|
DefineParameterPosition();
|
||||||
DefineParameterPosition(unsigned index, size_t position, bool stringize);
|
DefineParameterPosition(unsigned index, unsigned position, bool stringize);
|
||||||
|
|
||||||
|
unsigned m_parameter_index;
|
||||||
|
unsigned m_parameter_position;
|
||||||
|
bool m_stringize;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Define
|
class Define
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Define();
|
||||||
|
Define(std::string name, std::string value);
|
||||||
|
void IdentifyParameters(const std::vector<std::string>& parameterNames);
|
||||||
|
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
std::string m_value;
|
std::string m_value;
|
||||||
std::vector<DefineParameterPosition> m_parameter_positions;
|
std::vector<DefineParameterPosition> m_parameter_positions;
|
||||||
bool m_contains_token_pasting_operators;
|
bool m_contains_token_pasting_operators;
|
||||||
|
|
||||||
Define();
|
|
||||||
Define(std::string name, std::string value);
|
|
||||||
void IdentifyParameters(const std::vector<std::string>& parameterNames);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void IdentifyTokenPasteOperatorOnly();
|
void IdentifyTokenPasteOperatorOnly();
|
||||||
};
|
};
|
||||||
@ -64,14 +52,27 @@ public:
|
|||||||
class MacroParameterState
|
class MacroParameterState
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
MacroParameterState();
|
||||||
|
|
||||||
ParameterState m_parameter_state;
|
ParameterState m_parameter_state;
|
||||||
std::ostringstream m_current_parameter;
|
std::ostringstream m_current_parameter;
|
||||||
std::vector<std::string> m_parameters;
|
std::vector<std::string> m_parameters;
|
||||||
std::stack<char> m_bracket_depth;
|
std::stack<char> m_bracket_depth;
|
||||||
|
|
||||||
MacroParameterState();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
explicit DefinesStreamProxy(IParserLineStream* stream, bool skipDirectiveLines = false);
|
||||||
|
|
||||||
|
void AddDefine(Define define);
|
||||||
|
void Undefine(const std::string& name);
|
||||||
|
|
||||||
|
[[nodiscard]] std::unique_ptr<ISimpleExpression> ParseExpression(std::shared_ptr<std::string> fileName, int lineNumber, std::string expressionString);
|
||||||
|
|
||||||
|
ParserLine NextLine() override;
|
||||||
|
bool IncludeFile(const std::string& filename) override;
|
||||||
|
void PopCurrentFile() override;
|
||||||
|
[[nodiscard]] bool IsOpen() const override;
|
||||||
|
[[nodiscard]] bool Eof() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum class BlockMode : uint8_t
|
enum class BlockMode : uint8_t
|
||||||
|
|
||||||
@ -81,6 +82,45 @@ private:
|
|||||||
BLOCK_BLOCKED
|
BLOCK_BLOCKED
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int GetLineEndEscapePos(const ParserLine& line);
|
||||||
|
void MatchDefineParameters(const ParserLine& line, size_t& currentPos);
|
||||||
|
void ContinueDefine(const ParserLine& line, size_t currentPos);
|
||||||
|
void ContinueParameters(const ParserLine& line, size_t& currentPos);
|
||||||
|
[[nodiscard]] bool MatchDefineDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition);
|
||||||
|
[[nodiscard]] bool MatchUndefDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition);
|
||||||
|
[[nodiscard]] bool MatchIfDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition);
|
||||||
|
[[nodiscard]] bool MatchElIfDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition);
|
||||||
|
[[nodiscard]] bool MatchIfdefDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition);
|
||||||
|
[[nodiscard]] bool MatchElseDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition);
|
||||||
|
[[nodiscard]] bool MatchEndifDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition);
|
||||||
|
[[nodiscard]] bool MatchDirectives(const ParserLine& line);
|
||||||
|
|
||||||
|
static void ExtractParametersFromMacroUsage(
|
||||||
|
const ParserLine& line, const unsigned& linePos, MacroParameterState& state, const std::string& input, unsigned& inputPos);
|
||||||
|
bool FindMacroForIdentifier(const std::string& input, unsigned identifierStart, unsigned identifierEnd, const Define*& value) const;
|
||||||
|
|
||||||
|
static bool MatchDefinedExpression(const ParserLine& line, size_t& pos, std::string& definitionName);
|
||||||
|
void ExpandDefinedExpressions(ParserLine& line) const;
|
||||||
|
|
||||||
|
bool FindNextMacro(const std::string& input, unsigned& inputPos, unsigned& defineStart, const DefinesStreamProxy::Define*& define) const;
|
||||||
|
|
||||||
|
static void ProcessTokenPastingOperators(const ParserLine& line, const unsigned& linePos, std::string& input);
|
||||||
|
static void InsertMacroParameters(std::ostringstream& out, const DefinesStreamProxy::Define* macro, const std::vector<std::string>& parameterValues);
|
||||||
|
void ExpandMacro(ParserLine& line,
|
||||||
|
unsigned& linePos,
|
||||||
|
std::ostringstream& out,
|
||||||
|
std::vector<const Define*>& callstack,
|
||||||
|
const DefinesStreamProxy::Define* macro,
|
||||||
|
const std::vector<std::string>& parameterValues);
|
||||||
|
|
||||||
|
static void
|
||||||
|
ContinueMacroParameters(const ParserLine& line, const unsigned& linePos, MacroParameterState& state, const std::string& input, unsigned& inputPos);
|
||||||
|
void ContinueMultiLineMacro(ParserLine& line);
|
||||||
|
|
||||||
|
void ProcessNestedMacros(ParserLine& line, unsigned& linePos, std::vector<const Define*>& callstack, std::string& input);
|
||||||
|
void ProcessMacrosSingleLine(ParserLine& line);
|
||||||
|
void ProcessMacrosMultiLine(ParserLine& line);
|
||||||
|
|
||||||
IParserLineStream* const m_stream;
|
IParserLineStream* const m_stream;
|
||||||
const bool m_skip_directive_lines;
|
const bool m_skip_directive_lines;
|
||||||
std::map<std::string, Define> m_defines;
|
std::map<std::string, Define> m_defines;
|
||||||
@ -95,58 +135,4 @@ private:
|
|||||||
|
|
||||||
const Define* m_current_macro;
|
const Define* m_current_macro;
|
||||||
MacroParameterState m_multi_line_macro_parameters;
|
MacroParameterState m_multi_line_macro_parameters;
|
||||||
|
|
||||||
static int GetLineEndEscapePos(const ParserLine& line);
|
|
||||||
void MatchDefineParameters(const ParserLine& line, size_t& currentPos);
|
|
||||||
void ContinueDefine(const ParserLine& line, size_t currentPos);
|
|
||||||
void ContinueParameters(const ParserLine& line, size_t& currentPos);
|
|
||||||
_NODISCARD bool MatchDefineDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition);
|
|
||||||
_NODISCARD bool MatchUndefDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition);
|
|
||||||
_NODISCARD bool MatchIfDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition);
|
|
||||||
_NODISCARD bool MatchElIfDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition);
|
|
||||||
_NODISCARD bool MatchIfdefDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition);
|
|
||||||
_NODISCARD bool MatchElseDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition);
|
|
||||||
_NODISCARD bool MatchEndifDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition);
|
|
||||||
_NODISCARD bool MatchDirectives(const ParserLine& line);
|
|
||||||
|
|
||||||
static void ExtractParametersFromMacroUsage(
|
|
||||||
const ParserLine& line, const unsigned& linePos, MacroParameterState& state, const std::string& input, unsigned& inputPos);
|
|
||||||
bool FindMacroForIdentifier(const std::string& input, unsigned identifierStart, unsigned identifierEnd, const Define*& value) const;
|
|
||||||
|
|
||||||
static bool MatchDefinedExpression(const ParserLine& line, size_t& pos, std::string& definitionName);
|
|
||||||
void ExpandDefinedExpressions(ParserLine& line) const;
|
|
||||||
|
|
||||||
bool FindNextMacro(const std::string& input, unsigned& inputPos, unsigned& defineStart, const DefinesStreamProxy::Define*& define) const;
|
|
||||||
|
|
||||||
static void ProcessTokenPastingOperators(
|
|
||||||
const ParserLine& line, const unsigned& linePos, std::vector<const Define*>& callstack, std::string& input, unsigned& inputPos);
|
|
||||||
static void InsertMacroParameters(std::ostringstream& out, const DefinesStreamProxy::Define* macro, const std::vector<std::string>& parameterValues);
|
|
||||||
void ExpandMacro(ParserLine& line,
|
|
||||||
unsigned& linePos,
|
|
||||||
std::ostringstream& out,
|
|
||||||
std::vector<const Define*>& callstack,
|
|
||||||
const DefinesStreamProxy::Define* macro,
|
|
||||||
const std::vector<std::string>& parameterValues);
|
|
||||||
|
|
||||||
static void
|
|
||||||
ContinueMacroParameters(const ParserLine& line, const unsigned& linePos, MacroParameterState& state, const std::string& input, unsigned& inputPos);
|
|
||||||
void ContinueMultiLineMacro(ParserLine& line);
|
|
||||||
|
|
||||||
void ProcessNestedMacros(ParserLine& line, unsigned& linePos, std::vector<const Define*>& callstack, std::string& input, unsigned& inputPos);
|
|
||||||
void ProcessMacrosSingleLine(ParserLine& line);
|
|
||||||
void ProcessMacrosMultiLine(ParserLine& line);
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit DefinesStreamProxy(IParserLineStream* stream, bool skipDirectiveLines = false);
|
|
||||||
|
|
||||||
void AddDefine(Define define);
|
|
||||||
void Undefine(const std::string& name);
|
|
||||||
|
|
||||||
_NODISCARD std::unique_ptr<ISimpleExpression> ParseExpression(std::shared_ptr<std::string> fileName, int lineNumber, std::string expressionString);
|
|
||||||
|
|
||||||
ParserLine NextLine() override;
|
|
||||||
bool IncludeFile(const std::string& filename) override;
|
|
||||||
void PopCurrentFile() override;
|
|
||||||
_NODISCARD bool IsOpen() const override;
|
|
||||||
_NODISCARD bool Eof() const override;
|
|
||||||
};
|
};
|
||||||
|
@ -80,7 +80,7 @@ public:
|
|||||||
result.m_fabricated_tokens.push_back(m_transform_func(tokens));
|
result.m_fabricated_tokens.push_back(m_transform_func(tokens));
|
||||||
|
|
||||||
result.m_matched_tokens.clear();
|
result.m_matched_tokens.clear();
|
||||||
result.m_matched_tokens.emplace_back(result.m_fabricated_tokens.size() - 1, true);
|
result.m_matched_tokens.emplace_back(static_cast<unsigned>(result.m_fabricated_tokens.size()) - 1u, true);
|
||||||
}
|
}
|
||||||
else if (result.m_matched_tokens.empty())
|
else if (result.m_matched_tokens.empty())
|
||||||
{
|
{
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
template<typename TokenType> class MatcherFactoryWrapper
|
template<typename TokenType> class MatcherFactoryWrapper
|
||||||
{
|
{
|
||||||
// TokenType must inherit IParserValue
|
// TokenType must inherit IParserValue
|
||||||
static_assert(std::is_base_of<IParserValue, TokenType>::value);
|
static_assert(std::is_base_of_v<IParserValue, TokenType>);
|
||||||
|
|
||||||
std::unique_ptr<AbstractMatcher<TokenType>> m_matcher;
|
std::unique_ptr<AbstractMatcher<TokenType>> m_matcher;
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ public:
|
|||||||
template<typename TokenType> class AbstractMatcherFactory
|
template<typename TokenType> class AbstractMatcherFactory
|
||||||
{
|
{
|
||||||
// TokenType must inherit IParserValue
|
// TokenType must inherit IParserValue
|
||||||
static_assert(std::is_base_of<IParserValue, TokenType>::value);
|
static_assert(std::is_base_of_v<IParserValue, TokenType>);
|
||||||
|
|
||||||
const IMatcherForLabelSupplier<TokenType>* m_label_supplier;
|
const IMatcherForLabelSupplier<TokenType>* m_label_supplier;
|
||||||
|
|
||||||
@ -85,52 +85,52 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
_NODISCARD MatcherFactoryWrapper<TokenType> False() const
|
[[nodiscard]] MatcherFactoryWrapper<TokenType> False() const
|
||||||
{
|
{
|
||||||
return MatcherFactoryWrapper<TokenType>(std::make_unique<MatcherFalse<TokenType>>());
|
return MatcherFactoryWrapper<TokenType>(std::make_unique<MatcherFalse<TokenType>>());
|
||||||
}
|
}
|
||||||
|
|
||||||
_NODISCARD MatcherFactoryWrapper<TokenType> True() const
|
[[nodiscard]] MatcherFactoryWrapper<TokenType> True() const
|
||||||
{
|
{
|
||||||
return MatcherFactoryWrapper<TokenType>(std::make_unique<MatcherTrue<TokenType>>());
|
return MatcherFactoryWrapper<TokenType>(std::make_unique<MatcherTrue<TokenType>>());
|
||||||
}
|
}
|
||||||
|
|
||||||
_NODISCARD MatcherFactoryWrapper<TokenType> And(std::initializer_list<Movable<std::unique_ptr<AbstractMatcher<TokenType>>>> matchers) const
|
[[nodiscard]] MatcherFactoryWrapper<TokenType> And(std::initializer_list<Movable<std::unique_ptr<AbstractMatcher<TokenType>>>> matchers) const
|
||||||
{
|
{
|
||||||
return MatcherFactoryWrapper<TokenType>(std::make_unique<MatcherAnd<TokenType>>(matchers));
|
return MatcherFactoryWrapper<TokenType>(std::make_unique<MatcherAnd<TokenType>>(matchers));
|
||||||
}
|
}
|
||||||
|
|
||||||
_NODISCARD MatcherFactoryWrapper<TokenType> And(std::vector<std::unique_ptr<AbstractMatcher<TokenType>>> matchers) const
|
[[nodiscard]] MatcherFactoryWrapper<TokenType> And(std::vector<std::unique_ptr<AbstractMatcher<TokenType>>> matchers) const
|
||||||
{
|
{
|
||||||
return MatcherFactoryWrapper<TokenType>(std::make_unique<MatcherAnd<TokenType>>(std::move(matchers)));
|
return MatcherFactoryWrapper<TokenType>(std::make_unique<MatcherAnd<TokenType>>(std::move(matchers)));
|
||||||
}
|
}
|
||||||
|
|
||||||
_NODISCARD MatcherFactoryWrapper<TokenType> Or(std::initializer_list<Movable<std::unique_ptr<AbstractMatcher<TokenType>>>> matchers) const
|
[[nodiscard]] MatcherFactoryWrapper<TokenType> Or(std::initializer_list<Movable<std::unique_ptr<AbstractMatcher<TokenType>>>> matchers) const
|
||||||
{
|
{
|
||||||
return MatcherFactoryWrapper<TokenType>(std::make_unique<MatcherOr<TokenType>>(matchers));
|
return MatcherFactoryWrapper<TokenType>(std::make_unique<MatcherOr<TokenType>>(matchers));
|
||||||
}
|
}
|
||||||
|
|
||||||
_NODISCARD MatcherFactoryWrapper<TokenType> Or(std::vector<std::unique_ptr<AbstractMatcher<TokenType>>> matchers) const
|
[[nodiscard]] MatcherFactoryWrapper<TokenType> Or(std::vector<std::unique_ptr<AbstractMatcher<TokenType>>> matchers) const
|
||||||
{
|
{
|
||||||
return MatcherFactoryWrapper<TokenType>(std::make_unique<MatcherOr<TokenType>>(std::move(matchers)));
|
return MatcherFactoryWrapper<TokenType>(std::make_unique<MatcherOr<TokenType>>(std::move(matchers)));
|
||||||
}
|
}
|
||||||
|
|
||||||
_NODISCARD MatcherFactoryWrapper<TokenType> Loop(std::unique_ptr<AbstractMatcher<TokenType>> matcher) const
|
[[nodiscard]] MatcherFactoryWrapper<TokenType> Loop(std::unique_ptr<AbstractMatcher<TokenType>> matcher) const
|
||||||
{
|
{
|
||||||
return MatcherFactoryWrapper<TokenType>(std::make_unique<MatcherLoop<TokenType>>(std::move(matcher)));
|
return MatcherFactoryWrapper<TokenType>(std::make_unique<MatcherLoop<TokenType>>(std::move(matcher)));
|
||||||
}
|
}
|
||||||
|
|
||||||
_NODISCARD MatcherFactoryWrapper<TokenType> OptionalLoop(std::unique_ptr<AbstractMatcher<TokenType>> matcher) const
|
[[nodiscard]] MatcherFactoryWrapper<TokenType> OptionalLoop(std::unique_ptr<AbstractMatcher<TokenType>> matcher) const
|
||||||
{
|
{
|
||||||
return MatcherFactoryWrapper<TokenType>(std::make_unique<MatcherOptional<TokenType>>(std::make_unique<MatcherLoop<TokenType>>(std::move(matcher))));
|
return MatcherFactoryWrapper<TokenType>(std::make_unique<MatcherOptional<TokenType>>(std::make_unique<MatcherLoop<TokenType>>(std::move(matcher))));
|
||||||
}
|
}
|
||||||
|
|
||||||
_NODISCARD MatcherFactoryWrapper<TokenType> Optional(std::unique_ptr<AbstractMatcher<TokenType>> matcher) const
|
[[nodiscard]] MatcherFactoryWrapper<TokenType> Optional(std::unique_ptr<AbstractMatcher<TokenType>> matcher) const
|
||||||
{
|
{
|
||||||
return MatcherFactoryWrapper<TokenType>(std::make_unique<MatcherOptional<TokenType>>(std::move(matcher)));
|
return MatcherFactoryWrapper<TokenType>(std::make_unique<MatcherOptional<TokenType>>(std::move(matcher)));
|
||||||
}
|
}
|
||||||
|
|
||||||
_NODISCARD MatcherFactoryWrapper<TokenType> Label(const int label) const
|
[[nodiscard]] MatcherFactoryWrapper<TokenType> Label(const int label) const
|
||||||
{
|
{
|
||||||
return MatcherFactoryWrapper<TokenType>(std::make_unique<MatcherLabel<TokenType>>(m_label_supplier, label));
|
return MatcherFactoryWrapper<TokenType>(std::make_unique<MatcherLabel<TokenType>>(m_label_supplier, label));
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,11 @@
|
|||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
// The highest bit is the fabricated flag
|
// The highest bit is the fabricated flag
|
||||||
constexpr size_t FABRICATED_FLAG_MASK = 1uz << (sizeof(size_t) * 8uz - 1uz);
|
constexpr unsigned FABRICATED_FLAG_MASK = 1u << (sizeof(unsigned) * 8u - 1u);
|
||||||
constexpr size_t TOKEN_INDEX_MASK = ~FABRICATED_FLAG_MASK;
|
constexpr unsigned TOKEN_INDEX_MASK = ~FABRICATED_FLAG_MASK;
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
MatcherResultTokenIndex::MatcherResultTokenIndex(const size_t index, const bool isFabricated)
|
MatcherResultTokenIndex::MatcherResultTokenIndex(const unsigned index, const bool isFabricated)
|
||||||
{
|
{
|
||||||
m_token_index = index & TOKEN_INDEX_MASK;
|
m_token_index = index & TOKEN_INDEX_MASK;
|
||||||
if (isFabricated)
|
if (isFabricated)
|
||||||
@ -19,7 +19,7 @@ bool MatcherResultTokenIndex::IsFabricated() const
|
|||||||
return m_token_index & FABRICATED_FLAG_MASK;
|
return m_token_index & FABRICATED_FLAG_MASK;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t MatcherResultTokenIndex::GetTokenIndex() const
|
unsigned MatcherResultTokenIndex::GetTokenIndex() const
|
||||||
{
|
{
|
||||||
return m_token_index & TOKEN_INDEX_MASK;
|
return m_token_index & TOKEN_INDEX_MASK;
|
||||||
}
|
}
|
||||||
|
@ -10,12 +10,12 @@
|
|||||||
class MatcherResultTokenIndex
|
class MatcherResultTokenIndex
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MatcherResultTokenIndex(size_t index, bool isFabricated);
|
MatcherResultTokenIndex(unsigned index, bool isFabricated);
|
||||||
[[nodiscard]] bool IsFabricated() const;
|
[[nodiscard]] bool IsFabricated() const;
|
||||||
[[nodiscard]] size_t GetTokenIndex() const;
|
[[nodiscard]] unsigned GetTokenIndex() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
size_t m_token_index;
|
unsigned m_token_index;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MatcherResultCapture
|
class MatcherResultCapture
|
||||||
@ -54,8 +54,9 @@ public:
|
|||||||
for (const auto& capture : other.m_captures)
|
for (const auto& capture : other.m_captures)
|
||||||
{
|
{
|
||||||
if (capture.m_token_index.IsFabricated())
|
if (capture.m_token_index.IsFabricated())
|
||||||
m_captures.emplace_back(capture.GetCaptureId(),
|
m_captures.emplace_back(
|
||||||
MatcherResultTokenIndex(m_fabricated_tokens.size() + capture.m_token_index.GetTokenIndex(), true));
|
capture.GetCaptureId(),
|
||||||
|
MatcherResultTokenIndex(static_cast<unsigned>(m_fabricated_tokens.size()) + capture.m_token_index.GetTokenIndex(), true));
|
||||||
else
|
else
|
||||||
m_captures.emplace_back(capture.GetCaptureId(), capture.m_token_index);
|
m_captures.emplace_back(capture.GetCaptureId(), capture.m_token_index);
|
||||||
}
|
}
|
||||||
@ -63,7 +64,7 @@ public:
|
|||||||
for (const auto& token : other.m_matched_tokens)
|
for (const auto& token : other.m_matched_tokens)
|
||||||
{
|
{
|
||||||
if (token.IsFabricated())
|
if (token.IsFabricated())
|
||||||
m_matched_tokens.emplace_back(m_fabricated_tokens.size() + token.GetTokenIndex(), true);
|
m_matched_tokens.emplace_back(static_cast<unsigned>(m_fabricated_tokens.size()) + token.GetTokenIndex(), true);
|
||||||
else
|
else
|
||||||
m_matched_tokens.emplace_back(token.GetTokenIndex(), false);
|
m_matched_tokens.emplace_back(token.GetTokenIndex(), false);
|
||||||
}
|
}
|
||||||
|
@ -191,7 +191,7 @@ std::unique_ptr<ISimpleExpression> SimpleExpressionMatchers::ProcessExpression(S
|
|||||||
if (operationIndex < 0 || operationIndex >= static_cast<int>(SimpleBinaryOperationId::COUNT))
|
if (operationIndex < 0 || operationIndex >= static_cast<int>(SimpleBinaryOperationId::COUNT))
|
||||||
throw ParsingException(TokenPos(), "Invalid binary operation id @ Expression");
|
throw ParsingException(TokenPos(), "Invalid binary operation id @ Expression");
|
||||||
|
|
||||||
operators.emplace_back(operators.size(), SimpleExpressionBinaryOperationType::ALL_OPERATION_TYPES[operationIndex]);
|
operators.emplace_back(static_cast<unsigned>(operators.size()), SimpleExpressionBinaryOperationType::ALL_OPERATION_TYPES[operationIndex]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
@ -10,17 +10,17 @@ class SimpleMatcherFactory : public AbstractMatcherFactory<SimpleParserValue>
|
|||||||
public:
|
public:
|
||||||
explicit SimpleMatcherFactory(const IMatcherForLabelSupplier<SimpleParserValue>* labelSupplier);
|
explicit SimpleMatcherFactory(const IMatcherForLabelSupplier<SimpleParserValue>* labelSupplier);
|
||||||
|
|
||||||
_NODISCARD MatcherFactoryWrapper<SimpleParserValue> Type(SimpleParserValueType type) const;
|
[[nodiscard]] MatcherFactoryWrapper<SimpleParserValue> Type(SimpleParserValueType type) const;
|
||||||
_NODISCARD MatcherFactoryWrapper<SimpleParserValue> Keyword(std::string value) const;
|
[[nodiscard]] MatcherFactoryWrapper<SimpleParserValue> Keyword(std::string value) const;
|
||||||
_NODISCARD MatcherFactoryWrapper<SimpleParserValue> KeywordIgnoreCase(std::string value) const;
|
[[nodiscard]] MatcherFactoryWrapper<SimpleParserValue> KeywordIgnoreCase(std::string value) const;
|
||||||
_NODISCARD MatcherFactoryWrapper<SimpleParserValue> KeywordPrefix(std::string value) const;
|
[[nodiscard]] MatcherFactoryWrapper<SimpleParserValue> KeywordPrefix(std::string value) const;
|
||||||
_NODISCARD MatcherFactoryWrapper<SimpleParserValue> Identifier() const;
|
[[nodiscard]] MatcherFactoryWrapper<SimpleParserValue> Identifier() const;
|
||||||
_NODISCARD MatcherFactoryWrapper<SimpleParserValue> String() const;
|
[[nodiscard]] MatcherFactoryWrapper<SimpleParserValue> String() const;
|
||||||
_NODISCARD MatcherFactoryWrapper<SimpleParserValue> Integer() const;
|
[[nodiscard]] MatcherFactoryWrapper<SimpleParserValue> Integer() const;
|
||||||
_NODISCARD MatcherFactoryWrapper<SimpleParserValue> IntegerWithSign() const;
|
[[nodiscard]] MatcherFactoryWrapper<SimpleParserValue> IntegerWithSign() const;
|
||||||
_NODISCARD MatcherFactoryWrapper<SimpleParserValue> FloatingPoint() const;
|
[[nodiscard]] MatcherFactoryWrapper<SimpleParserValue> FloatingPoint() const;
|
||||||
_NODISCARD MatcherFactoryWrapper<SimpleParserValue> FloatingPointWithSign() const;
|
[[nodiscard]] MatcherFactoryWrapper<SimpleParserValue> FloatingPointWithSign() const;
|
||||||
_NODISCARD MatcherFactoryWrapper<SimpleParserValue> Char(char c) const;
|
[[nodiscard]] MatcherFactoryWrapper<SimpleParserValue> Char(char c) const;
|
||||||
_NODISCARD MatcherFactoryWrapper<SimpleParserValue> MultiChar(int multiCharacterSequenceId) const;
|
[[nodiscard]] MatcherFactoryWrapper<SimpleParserValue> MultiChar(int multiCharacterSequenceId) const;
|
||||||
_NODISCARD MatcherFactoryWrapper<SimpleParserValue> AnyCharBesides(std::vector<char> chars) const;
|
[[nodiscard]] MatcherFactoryWrapper<SimpleParserValue> AnyCharBesides(std::vector<char> chars) const;
|
||||||
};
|
};
|
||||||
|
@ -79,7 +79,7 @@ bool SimpleLexer::ReadMultiCharacterToken(const MultiCharacterTokenLookupEntry*
|
|||||||
linePos++;
|
linePos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_current_line_offset = m_current_line_offset - 1 + multiTokenLookup->m_value.size();
|
m_current_line_offset = m_current_line_offset - 1 + static_cast<unsigned>(multiTokenLookup->m_value.size());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ bool ArgumentParser::ParseArguments(std::vector<std::string>& args)
|
|||||||
m_matched_options[matchedOption] = std::vector<std::string>();
|
m_matched_options[matchedOption] = std::vector<std::string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto parameterCount = matchedOption->m_parameters.size();
|
const auto parameterCount = static_cast<unsigned>(matchedOption->m_parameters.size());
|
||||||
if (argIndex + parameterCount >= argCount)
|
if (argIndex + parameterCount >= argCount)
|
||||||
{
|
{
|
||||||
std::cout << std::format("Not enough parameters for option '{}'.\n", arg);
|
std::cout << std::format("Not enough parameters for option '{}'.\n", arg);
|
||||||
|
@ -3,31 +3,31 @@ game IW3;
|
|||||||
architecture x86;
|
architecture x86;
|
||||||
|
|
||||||
// Game Assets
|
// Game Assets
|
||||||
asset PhysPreset ASSET_TYPE_PHYSPRESET;
|
asset PhysPreset AssetPhysPreset;
|
||||||
asset XAnimParts ASSET_TYPE_XANIMPARTS;
|
asset XAnimParts AssetXAnim;
|
||||||
asset XModel ASSET_TYPE_XMODEL;
|
asset XModel AssetXModel;
|
||||||
asset Material ASSET_TYPE_MATERIAL;
|
asset Material AssetMaterial;
|
||||||
asset MaterialTechniqueSet ASSET_TYPE_TECHNIQUE_SET;
|
asset MaterialTechniqueSet AssetTechniqueSet;
|
||||||
asset GfxImage ASSET_TYPE_IMAGE;
|
asset GfxImage AssetImage;
|
||||||
asset snd_alias_list_t ASSET_TYPE_SOUND;
|
asset snd_alias_list_t AssetSound;
|
||||||
asset SndCurve ASSET_TYPE_SOUND_CURVE;
|
asset SndCurve AssetSoundCurve;
|
||||||
asset LoadedSound ASSET_TYPE_LOADED_SOUND;
|
asset LoadedSound AssetLoadedSound;
|
||||||
asset clipMap_t ASSET_TYPE_CLIPMAP_PVS;
|
asset clipMap_t AssetClipMapPvs;
|
||||||
asset ComWorld ASSET_TYPE_COMWORLD;
|
asset ComWorld AssetComWorld;
|
||||||
asset GameWorldSp ASSET_TYPE_GAMEWORLD_SP;
|
asset GameWorldSp AssetGameWorldSp;
|
||||||
asset GameWorldMp ASSET_TYPE_GAMEWORLD_MP;
|
asset GameWorldMp AssetGameWorldMp;
|
||||||
asset MapEnts ASSET_TYPE_MAP_ENTS;
|
asset MapEnts AssetMapEnts;
|
||||||
asset GfxWorld ASSET_TYPE_GFXWORLD;
|
asset GfxWorld AssetGfxWorld;
|
||||||
asset GfxLightDef ASSET_TYPE_LIGHT_DEF;
|
asset GfxLightDef AssetLightDef;
|
||||||
asset Font_s ASSET_TYPE_FONT;
|
asset Font_s AssetFont;
|
||||||
asset MenuList ASSET_TYPE_MENULIST;
|
asset MenuList AssetMenuList;
|
||||||
asset menuDef_t ASSET_TYPE_MENU;
|
asset menuDef_t AssetMenu;
|
||||||
asset LocalizeEntry ASSET_TYPE_LOCALIZE_ENTRY;
|
asset LocalizeEntry AssetLocalize;
|
||||||
asset WeaponDef ASSET_TYPE_WEAPON;
|
asset WeaponDef AssetWeapon;
|
||||||
asset FxEffectDef ASSET_TYPE_FX;
|
asset FxEffectDef AssetFx;
|
||||||
asset FxImpactTable ASSET_TYPE_IMPACT_FX;
|
asset FxImpactTable AssetImpactFx;
|
||||||
asset RawFile ASSET_TYPE_RAWFILE;
|
asset RawFile AssetRawFile;
|
||||||
asset StringTable ASSET_TYPE_STRINGTABLE;
|
asset StringTable AssetStringTable;
|
||||||
|
|
||||||
// Setup blocks
|
// Setup blocks
|
||||||
block temp XFILE_BLOCK_TEMP default;
|
block temp XFILE_BLOCK_TEMP default;
|
||||||
@ -66,4 +66,3 @@ block normal XFILE_BLOCK_INDEX;
|
|||||||
#include "XAssets/RawFile.txt"
|
#include "XAssets/RawFile.txt"
|
||||||
#include "XAssets/StringTable.txt"
|
#include "XAssets/StringTable.txt"
|
||||||
|
|
||||||
// EOF
|
|
@ -3,41 +3,41 @@ game IW4;
|
|||||||
architecture x86;
|
architecture x86;
|
||||||
|
|
||||||
// Game Assets
|
// Game Assets
|
||||||
asset PhysPreset ASSET_TYPE_PHYSPRESET;
|
asset PhysPreset AssetPhysPreset;
|
||||||
asset PhysCollmap ASSET_TYPE_PHYSCOLLMAP;
|
asset PhysCollmap AssetPhysCollMap;
|
||||||
asset XAnimParts ASSET_TYPE_XANIMPARTS;
|
asset XAnimParts AssetXAnim;
|
||||||
asset XModel ASSET_TYPE_XMODEL;
|
asset XModel AssetXModel;
|
||||||
asset Material ASSET_TYPE_MATERIAL;
|
asset Material AssetMaterial;
|
||||||
asset MaterialPixelShader ASSET_TYPE_PIXELSHADER;
|
asset MaterialPixelShader AssetPixelShader;
|
||||||
asset MaterialVertexShader ASSET_TYPE_VERTEXSHADER;
|
asset MaterialVertexShader AssetVertexShader;
|
||||||
asset MaterialVertexDeclaration ASSET_TYPE_VERTEXDECL;
|
asset MaterialVertexDeclaration AssetVertexDecl;
|
||||||
asset MaterialTechniqueSet ASSET_TYPE_TECHNIQUE_SET;
|
asset MaterialTechniqueSet AssetTechniqueSet;
|
||||||
asset GfxImage ASSET_TYPE_IMAGE;
|
asset GfxImage AssetImage;
|
||||||
asset snd_alias_list_t ASSET_TYPE_SOUND;
|
asset snd_alias_list_t AssetSound;
|
||||||
asset SndCurve ASSET_TYPE_SOUND_CURVE;
|
asset SndCurve AssetSoundCurve;
|
||||||
asset LoadedSound ASSET_TYPE_LOADED_SOUND;
|
asset LoadedSound AssetLoadedSound;
|
||||||
asset clipMap_t ASSET_TYPE_CLIPMAP_MP;
|
asset clipMap_t AssetClipMapMp;
|
||||||
asset ComWorld ASSET_TYPE_COMWORLD;
|
asset ComWorld AssetComWorld;
|
||||||
asset GameWorldSp ASSET_TYPE_GAMEWORLD_SP;
|
asset GameWorldSp AssetGameWorldSp;
|
||||||
asset GameWorldMp ASSET_TYPE_GAMEWORLD_MP;
|
asset GameWorldMp AssetGameWorldMp;
|
||||||
asset MapEnts ASSET_TYPE_MAP_ENTS;
|
asset MapEnts AssetMapEnts;
|
||||||
asset FxWorld ASSET_TYPE_FXWORLD;
|
asset FxWorld AssetFxWorld;
|
||||||
asset GfxWorld ASSET_TYPE_GFXWORLD;
|
asset GfxWorld AssetGfxWorld;
|
||||||
asset GfxLightDef ASSET_TYPE_LIGHT_DEF;
|
asset GfxLightDef AssetLightDef;
|
||||||
asset Font_s ASSET_TYPE_FONT;
|
asset Font_s AssetFont;
|
||||||
asset MenuList ASSET_TYPE_MENULIST;
|
asset MenuList AssetMenuList;
|
||||||
asset menuDef_t ASSET_TYPE_MENU;
|
asset menuDef_t AssetMenu;
|
||||||
asset LocalizeEntry ASSET_TYPE_LOCALIZE_ENTRY;
|
asset LocalizeEntry AssetLocalize;
|
||||||
asset WeaponCompleteDef ASSET_TYPE_WEAPON;
|
asset WeaponCompleteDef AssetWeapon;
|
||||||
asset FxEffectDef ASSET_TYPE_FX;
|
asset FxEffectDef AssetFx;
|
||||||
asset FxImpactTable ASSET_TYPE_IMPACT_FX;
|
asset FxImpactTable AssetImpactFx;
|
||||||
asset RawFile ASSET_TYPE_RAWFILE;
|
asset RawFile AssetRawFile;
|
||||||
asset StringTable ASSET_TYPE_STRINGTABLE;
|
asset StringTable AssetStringTable;
|
||||||
asset LeaderboardDef ASSET_TYPE_LEADERBOARD;
|
asset LeaderboardDef AssetLeaderboard;
|
||||||
asset StructuredDataDefSet ASSET_TYPE_STRUCTURED_DATA_DEF;
|
asset StructuredDataDefSet AssetStructuredDataDef;
|
||||||
asset TracerDef ASSET_TYPE_TRACER;
|
asset TracerDef AssetTracer;
|
||||||
asset VehicleDef ASSET_TYPE_VEHICLE;
|
asset VehicleDef AssetVehicle;
|
||||||
asset AddonMapEnts ASSET_TYPE_ADDON_MAP_ENTS;
|
asset AddonMapEnts AssetAddonMapEnts;
|
||||||
|
|
||||||
// Setup blocks
|
// Setup blocks
|
||||||
block temp XFILE_BLOCK_TEMP default;
|
block temp XFILE_BLOCK_TEMP default;
|
||||||
@ -85,4 +85,3 @@ block normal XFILE_BLOCK_INDEX;
|
|||||||
#include "XAssets/VehicleDef.txt"
|
#include "XAssets/VehicleDef.txt"
|
||||||
#include "XAssets/AddonMapEnts.txt"
|
#include "XAssets/AddonMapEnts.txt"
|
||||||
|
|
||||||
// EOF
|
|
@ -3,46 +3,46 @@ game IW5;
|
|||||||
architecture x86;
|
architecture x86;
|
||||||
|
|
||||||
// Game Assets
|
// Game Assets
|
||||||
asset PhysPreset ASSET_TYPE_PHYSPRESET;
|
asset PhysPreset AssetPhysPreset;
|
||||||
asset PhysCollmap ASSET_TYPE_PHYSCOLLMAP;
|
asset PhysCollmap AssetPhysCollMap;
|
||||||
asset XAnimParts ASSET_TYPE_XANIMPARTS;
|
asset XAnimParts AssetXAnim;
|
||||||
asset XModelSurfs ASSET_TYPE_XMODEL_SURFS;
|
asset XModelSurfs AssetXModelSurfs;
|
||||||
asset XModel ASSET_TYPE_XMODEL;
|
asset XModel AssetXModel;
|
||||||
asset Material ASSET_TYPE_MATERIAL;
|
asset Material AssetMaterial;
|
||||||
asset MaterialPixelShader ASSET_TYPE_PIXELSHADER;
|
asset MaterialPixelShader AssetPixelShader;
|
||||||
asset MaterialVertexShader ASSET_TYPE_VERTEXSHADER;
|
asset MaterialVertexShader AssetVertexShader;
|
||||||
asset MaterialVertexDeclaration ASSET_TYPE_VERTEXDECL;
|
asset MaterialVertexDeclaration AssetVertexDecl;
|
||||||
asset MaterialTechniqueSet ASSET_TYPE_TECHNIQUE_SET;
|
asset MaterialTechniqueSet AssetTechniqueSet;
|
||||||
asset GfxImage ASSET_TYPE_IMAGE;
|
asset GfxImage AssetImage;
|
||||||
asset snd_alias_list_t ASSET_TYPE_SOUND;
|
asset snd_alias_list_t AssetSound;
|
||||||
asset SndCurve ASSET_TYPE_SOUND_CURVE;
|
asset SndCurve AssetSoundCurve;
|
||||||
asset LoadedSound ASSET_TYPE_LOADED_SOUND;
|
asset LoadedSound AssetLoadedSound;
|
||||||
asset clipMap_t ASSET_TYPE_CLIPMAP;
|
asset clipMap_t AssetClipMap;
|
||||||
asset ComWorld ASSET_TYPE_COMWORLD;
|
asset ComWorld AssetComWorld;
|
||||||
asset GlassWorld ASSET_TYPE_GLASSWORLD;
|
asset GlassWorld AssetGlassWorld;
|
||||||
asset PathData ASSET_TYPE_PATHDATA;
|
asset PathData AssetPathData;
|
||||||
asset VehicleTrack ASSET_TYPE_VEHICLE_TRACK;
|
asset VehicleTrack AssetVehicleTrack;
|
||||||
asset MapEnts ASSET_TYPE_MAP_ENTS;
|
asset MapEnts AssetMapEnts;
|
||||||
asset FxWorld ASSET_TYPE_FXWORLD;
|
asset FxWorld AssetFxWorld;
|
||||||
asset GfxWorld ASSET_TYPE_GFXWORLD;
|
asset GfxWorld AssetGfxWorld;
|
||||||
asset GfxLightDef ASSET_TYPE_LIGHT_DEF;
|
asset GfxLightDef AssetLightDef;
|
||||||
asset Font_s ASSET_TYPE_FONT;
|
asset Font_s AssetFont;
|
||||||
asset MenuList ASSET_TYPE_MENULIST;
|
asset MenuList AssetMenuList;
|
||||||
asset menuDef_t ASSET_TYPE_MENU;
|
asset menuDef_t AssetMenu;
|
||||||
asset LocalizeEntry ASSET_TYPE_LOCALIZE_ENTRY;
|
asset LocalizeEntry AssetLocalize;
|
||||||
asset WeaponAttachment ASSET_TYPE_ATTACHMENT;
|
asset WeaponAttachment AssetAttachment;
|
||||||
asset WeaponCompleteDef ASSET_TYPE_WEAPON;
|
asset WeaponCompleteDef AssetWeapon;
|
||||||
asset FxEffectDef ASSET_TYPE_FX;
|
asset FxEffectDef AssetFx;
|
||||||
asset FxImpactTable ASSET_TYPE_IMPACT_FX;
|
asset FxImpactTable AssetImpactFx;
|
||||||
asset SurfaceFxTable ASSET_TYPE_SURFACE_FX;
|
asset SurfaceFxTable AssetSurfaceFx;
|
||||||
asset RawFile ASSET_TYPE_RAWFILE;
|
asset RawFile AssetRawFile;
|
||||||
asset ScriptFile ASSET_TYPE_SCRIPTFILE;
|
asset ScriptFile AssetScript;
|
||||||
asset StringTable ASSET_TYPE_STRINGTABLE;
|
asset StringTable AssetStringTable;
|
||||||
asset LeaderboardDef ASSET_TYPE_LEADERBOARD;
|
asset LeaderboardDef AssetLeaderboard;
|
||||||
asset StructuredDataDefSet ASSET_TYPE_STRUCTURED_DATA_DEF;
|
asset StructuredDataDefSet AssetStructuredDataDef;
|
||||||
asset TracerDef ASSET_TYPE_TRACER;
|
asset TracerDef AssetTracer;
|
||||||
asset VehicleDef ASSET_TYPE_VEHICLE;
|
asset VehicleDef AssetVehicle;
|
||||||
asset AddonMapEnts ASSET_TYPE_ADDON_MAP_ENTS;
|
asset AddonMapEnts AssetAddonMapEnts;
|
||||||
|
|
||||||
// Setup blocks
|
// Setup blocks
|
||||||
block temp XFILE_BLOCK_TEMP default;
|
block temp XFILE_BLOCK_TEMP default;
|
||||||
@ -96,4 +96,3 @@ block normal XFILE_BLOCK_SCRIPT;
|
|||||||
#include "XAssets/VehicleDef.txt"
|
#include "XAssets/VehicleDef.txt"
|
||||||
#include "XAssets/AddonMapEnts.txt"
|
#include "XAssets/AddonMapEnts.txt"
|
||||||
|
|
||||||
// EOF
|
|
@ -3,38 +3,38 @@ game T5;
|
|||||||
architecture x86;
|
architecture x86;
|
||||||
|
|
||||||
// Game Assets
|
// Game Assets
|
||||||
asset PhysPreset ASSET_TYPE_PHYSPRESET;
|
asset PhysPreset AssetPhysPreset;
|
||||||
asset PhysConstraints ASSET_TYPE_PHYSCONSTRAINTS;
|
asset PhysConstraints AssetPhysConstraints;
|
||||||
asset DestructibleDef ASSET_TYPE_DESTRUCTIBLEDEF;
|
asset DestructibleDef AssetDestructibleDef;
|
||||||
asset XAnimParts ASSET_TYPE_XANIMPARTS;
|
asset XAnimParts AssetXAnim;
|
||||||
asset XModel ASSET_TYPE_XMODEL;
|
asset XModel AssetXModel;
|
||||||
asset Material ASSET_TYPE_MATERIAL;
|
asset Material AssetMaterial;
|
||||||
asset MaterialTechniqueSet ASSET_TYPE_TECHNIQUE_SET;
|
asset MaterialTechniqueSet AssetTechniqueSet;
|
||||||
asset GfxImage ASSET_TYPE_IMAGE;
|
asset GfxImage AssetImage;
|
||||||
asset SndBank ASSET_TYPE_SOUND;
|
asset SndBank AssetSoundBank;
|
||||||
asset SndPatch ASSET_TYPE_SOUND_PATCH;
|
asset SndPatch AssetSoundPatch;
|
||||||
asset clipMap_t ASSET_TYPE_CLIPMAP_PVS;
|
asset clipMap_t AssetClipMapPvs;
|
||||||
asset ComWorld ASSET_TYPE_COMWORLD;
|
asset ComWorld AssetComWorld;
|
||||||
asset GameWorldSp ASSET_TYPE_GAMEWORLD_SP;
|
asset GameWorldSp AssetGameWorldSp;
|
||||||
asset GameWorldMp ASSET_TYPE_GAMEWORLD_MP;
|
asset GameWorldMp AssetGameWorldMp;
|
||||||
asset MapEnts ASSET_TYPE_MAP_ENTS;
|
asset MapEnts AssetMapEnts;
|
||||||
asset GfxWorld ASSET_TYPE_GFXWORLD;
|
asset GfxWorld AssetGfxWorld;
|
||||||
asset GfxLightDef ASSET_TYPE_LIGHT_DEF;
|
asset GfxLightDef AssetLightDef;
|
||||||
asset Font_s ASSET_TYPE_FONT;
|
asset Font_s AssetFont;
|
||||||
asset MenuList ASSET_TYPE_MENULIST;
|
asset MenuList AssetMenuList;
|
||||||
asset menuDef_t ASSET_TYPE_MENU;
|
asset menuDef_t AssetMenu;
|
||||||
asset LocalizeEntry ASSET_TYPE_LOCALIZE_ENTRY;
|
asset LocalizeEntry AssetLocalize;
|
||||||
asset WeaponVariantDef ASSET_TYPE_WEAPON;
|
asset WeaponVariantDef AssetWeapon;
|
||||||
asset SndDriverGlobals ASSET_TYPE_SNDDRIVER_GLOBALS;
|
asset SndDriverGlobals AssetSoundDriverGlobals;
|
||||||
asset FxEffectDef ASSET_TYPE_FX;
|
asset FxEffectDef AssetFx;
|
||||||
asset FxImpactTable ASSET_TYPE_IMPACT_FX;
|
asset FxImpactTable AssetImpactFx;
|
||||||
asset RawFile ASSET_TYPE_RAWFILE;
|
asset RawFile AssetRawFile;
|
||||||
asset StringTable ASSET_TYPE_STRINGTABLE;
|
asset StringTable AssetStringTable;
|
||||||
asset PackIndex ASSET_TYPE_PACK_INDEX;
|
asset PackIndex AssetPackIndex;
|
||||||
asset XGlobals ASSET_TYPE_XGLOBALS;
|
asset XGlobals AssetXGlobals;
|
||||||
asset ddlRoot_t ASSET_TYPE_DDL;
|
asset ddlRoot_t AssetDDL;
|
||||||
asset Glasses ASSET_TYPE_GLASSES;
|
asset Glasses AssetGlasses;
|
||||||
asset EmblemSet ASSET_TYPE_EMBLEMSET;
|
asset EmblemSet AssetEmblemSet;
|
||||||
|
|
||||||
// Setup blocks
|
// Setup blocks
|
||||||
block temp XFILE_BLOCK_TEMP default;
|
block temp XFILE_BLOCK_TEMP default;
|
||||||
@ -79,4 +79,3 @@ block normal XFILE_BLOCK_PHYSICAL;
|
|||||||
#include "XAssets/Glasses.txt"
|
#include "XAssets/Glasses.txt"
|
||||||
#include "XAssets/EmblemSet.txt"
|
#include "XAssets/EmblemSet.txt"
|
||||||
|
|
||||||
// EOF
|
|
@ -3,54 +3,54 @@ game T6;
|
|||||||
architecture x86;
|
architecture x86;
|
||||||
|
|
||||||
// Game Assets
|
// Game Assets
|
||||||
asset PhysPreset ASSET_TYPE_PHYSPRESET;
|
asset PhysPreset AssetPhysPreset;
|
||||||
asset PhysConstraints ASSET_TYPE_PHYSCONSTRAINTS;
|
asset PhysConstraints AssetPhysConstraints;
|
||||||
asset DestructibleDef ASSET_TYPE_DESTRUCTIBLEDEF;
|
asset DestructibleDef AssetDestructibleDef;
|
||||||
asset XAnimParts ASSET_TYPE_XANIMPARTS;
|
asset XAnimParts AssetXAnim;
|
||||||
asset XModel ASSET_TYPE_XMODEL;
|
asset XModel AssetXModel;
|
||||||
asset Material ASSET_TYPE_MATERIAL;
|
asset Material AssetMaterial;
|
||||||
asset MaterialTechniqueSet ASSET_TYPE_TECHNIQUE_SET;
|
asset MaterialTechniqueSet AssetTechniqueSet;
|
||||||
asset GfxImage ASSET_TYPE_IMAGE;
|
asset GfxImage AssetImage;
|
||||||
asset SndBank ASSET_TYPE_SOUND;
|
asset SndBank AssetSoundBank;
|
||||||
asset SndPatch ASSET_TYPE_SOUND_PATCH;
|
asset SndPatch AssetSoundPatch;
|
||||||
asset clipMap_t ASSET_TYPE_CLIPMAP_PVS;
|
asset clipMap_t AssetClipMapPvs;
|
||||||
asset ComWorld ASSET_TYPE_COMWORLD;
|
asset ComWorld AssetComWorld;
|
||||||
asset GameWorldSp ASSET_TYPE_GAMEWORLD_SP;
|
asset GameWorldSp AssetGameWorldSp;
|
||||||
asset GameWorldMp ASSET_TYPE_GAMEWORLD_MP;
|
asset GameWorldMp AssetGameWorldMp;
|
||||||
asset MapEnts ASSET_TYPE_MAP_ENTS;
|
asset MapEnts AssetMapEnts;
|
||||||
asset GfxWorld ASSET_TYPE_GFXWORLD;
|
asset GfxWorld AssetGfxWorld;
|
||||||
asset GfxLightDef ASSET_TYPE_LIGHT_DEF;
|
asset GfxLightDef AssetLightDef;
|
||||||
asset Font_s ASSET_TYPE_FONT;
|
asset Font_s AssetFont;
|
||||||
asset FontIcon ASSET_TYPE_FONTICON;
|
asset FontIcon AssetFontIcon;
|
||||||
asset MenuList ASSET_TYPE_MENULIST;
|
asset MenuList AssetMenuList;
|
||||||
asset menuDef_t ASSET_TYPE_MENU;
|
asset menuDef_t AssetMenu;
|
||||||
asset LocalizeEntry ASSET_TYPE_LOCALIZE_ENTRY;
|
asset LocalizeEntry AssetLocalize;
|
||||||
asset WeaponVariantDef ASSET_TYPE_WEAPON;
|
asset WeaponVariantDef AssetWeapon;
|
||||||
asset WeaponAttachment ASSET_TYPE_ATTACHMENT;
|
asset WeaponAttachment AssetAttachment;
|
||||||
asset WeaponAttachmentUnique ASSET_TYPE_ATTACHMENT_UNIQUE;
|
asset WeaponAttachmentUnique AssetAttachmentUnique;
|
||||||
asset WeaponCamo ASSET_TYPE_WEAPON_CAMO;
|
asset WeaponCamo AssetWeaponCamo;
|
||||||
asset SndDriverGlobals ASSET_TYPE_SNDDRIVER_GLOBALS;
|
asset SndDriverGlobals AssetSoundDriverGlobals;
|
||||||
asset FxEffectDef ASSET_TYPE_FX;
|
asset FxEffectDef AssetFx;
|
||||||
asset FxImpactTable ASSET_TYPE_IMPACT_FX;
|
asset FxImpactTable AssetImpactFx;
|
||||||
asset RawFile ASSET_TYPE_RAWFILE;
|
asset RawFile AssetRawFile;
|
||||||
asset StringTable ASSET_TYPE_STRINGTABLE;
|
asset StringTable AssetStringTable;
|
||||||
asset LeaderboardDef ASSET_TYPE_LEADERBOARD;
|
asset LeaderboardDef AssetLeaderboard;
|
||||||
asset XGlobals ASSET_TYPE_XGLOBALS;
|
asset XGlobals AssetXGlobals;
|
||||||
asset ddlRoot_t ASSET_TYPE_DDL;
|
asset ddlRoot_t AssetDDL;
|
||||||
asset Glasses ASSET_TYPE_GLASSES;
|
asset Glasses AssetGlasses;
|
||||||
asset EmblemSet ASSET_TYPE_EMBLEMSET;
|
asset EmblemSet AssetEmblemSet;
|
||||||
asset ScriptParseTree ASSET_TYPE_SCRIPTPARSETREE;
|
asset ScriptParseTree AssetScript;
|
||||||
asset KeyValuePairs ASSET_TYPE_KEYVALUEPAIRS;
|
asset KeyValuePairs AssetKeyValuePairs;
|
||||||
asset VehicleDef ASSET_TYPE_VEHICLEDEF;
|
asset VehicleDef AssetVehicle;
|
||||||
asset MemoryBlock ASSET_TYPE_MEMORYBLOCK;
|
asset MemoryBlock AssetMemoryBlock;
|
||||||
asset AddonMapEnts ASSET_TYPE_ADDON_MAP_ENTS;
|
asset AddonMapEnts AssetAddonMapEnts;
|
||||||
asset TracerDef ASSET_TYPE_TRACER;
|
asset TracerDef AssetTracer;
|
||||||
asset SkinnedVertsDef ASSET_TYPE_SKINNEDVERTS;
|
asset SkinnedVertsDef AssetSkinnedVerts;
|
||||||
asset Qdb ASSET_TYPE_QDB;
|
asset Qdb AssetQdb;
|
||||||
asset Slug ASSET_TYPE_SLUG;
|
asset Slug AssetSlug;
|
||||||
asset FootstepTableDef ASSET_TYPE_FOOTSTEP_TABLE;
|
asset FootstepTableDef AssetFootstepTable;
|
||||||
asset FootstepFXTableDef ASSET_TYPE_FOOTSTEPFX_TABLE;
|
asset FootstepFXTableDef AssetFootstepFxTable;
|
||||||
asset ZBarrierDef ASSET_TYPE_ZBARRIER;
|
asset ZBarrierDef AssetZBarrier;
|
||||||
|
|
||||||
// Setup blocks
|
// Setup blocks
|
||||||
block temp XFILE_BLOCK_TEMP default;
|
block temp XFILE_BLOCK_TEMP default;
|
||||||
@ -112,4 +112,3 @@ block normal XFILE_BLOCK_STREAMER_RESERVE;
|
|||||||
#include "XAssets/FootstepFXTableDef.txt"
|
#include "XAssets/FootstepFXTableDef.txt"
|
||||||
#include "XAssets/ZBarrierDef.txt"
|
#include "XAssets/ZBarrierDef.txt"
|
||||||
|
|
||||||
// EOF
|
|
@ -12,7 +12,7 @@ StructureComputations::StructureComputations(const StructureInformation* structu
|
|||||||
|
|
||||||
bool StructureComputations::IsAsset() const
|
bool StructureComputations::IsAsset() const
|
||||||
{
|
{
|
||||||
return m_info->m_asset_enum_entry != nullptr;
|
return !m_info->m_asset_name.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
MemberInformation* StructureComputations::GetDynamicMember() const
|
MemberInformation* StructureComputations::GetDynamicMember() const
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
StructureInformation::StructureInformation(DefinitionWithMembers* definition)
|
StructureInformation::StructureInformation(DefinitionWithMembers* definition)
|
||||||
: m_definition(definition),
|
: m_definition(definition),
|
||||||
m_asset_enum_entry(nullptr),
|
|
||||||
m_is_leaf(false),
|
m_is_leaf(false),
|
||||||
m_requires_marking(false),
|
m_requires_marking(false),
|
||||||
m_has_matching_cross_platform_structure(false),
|
m_has_matching_cross_platform_structure(false),
|
||||||
|
@ -16,8 +16,8 @@ class StructureInformation
|
|||||||
public:
|
public:
|
||||||
explicit StructureInformation(DefinitionWithMembers* definition);
|
explicit StructureInformation(DefinitionWithMembers* definition);
|
||||||
|
|
||||||
DefinitionWithMembers* const m_definition;
|
DefinitionWithMembers* m_definition;
|
||||||
EnumMember* m_asset_enum_entry;
|
std::string m_asset_name;
|
||||||
|
|
||||||
std::vector<StructureInformation*> m_usages;
|
std::vector<StructureInformation*> m_usages;
|
||||||
std::vector<std::unique_ptr<MemberInformation>> m_ordered_members;
|
std::vector<std::unique_ptr<MemberInformation>> m_ordered_members;
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "Templates/ZoneWriteTemplate.h"
|
#include "Templates/ZoneWriteTemplate.h"
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
#include <format>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@ -41,7 +42,7 @@ bool CodeGenerator::GenerateCodeForTemplate(RenderingContext* context, ICodeTemp
|
|||||||
|
|
||||||
if (!stream.is_open())
|
if (!stream.is_open())
|
||||||
{
|
{
|
||||||
std::cout << "Failed to open file '" << p.string() << "'\n";
|
std::cerr << std::format("Failed to open file '{}'\n", p.string());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,21 +59,21 @@ bool CodeGenerator::GetAssetWithName(IDataRepository* repository, const std::str
|
|||||||
auto* def = repository->GetDataDefinitionByName(name);
|
auto* def = repository->GetDataDefinitionByName(name);
|
||||||
if (def == nullptr)
|
if (def == nullptr)
|
||||||
{
|
{
|
||||||
std::cout << "Could not find type with name '" << name << "'\n";
|
std::cerr << std::format("Could not find type with name '{}'\n", name);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* defWithMembers = dynamic_cast<DefinitionWithMembers*>(def);
|
auto* defWithMembers = dynamic_cast<DefinitionWithMembers*>(def);
|
||||||
auto* info = defWithMembers != nullptr ? repository->GetInformationFor(defWithMembers) : nullptr;
|
asset = defWithMembers != nullptr ? repository->GetInformationFor(defWithMembers) : nullptr;
|
||||||
if (info == nullptr)
|
if (asset == nullptr)
|
||||||
{
|
{
|
||||||
std::cout << "Could not find type with name '" << name << "'\n";
|
std::cerr << std::format("Could not find type with name '{}'\n", name);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!StructureComputations(info).IsAsset())
|
if (!StructureComputations(asset).IsAsset())
|
||||||
{
|
{
|
||||||
std::cout << "Type is not an asset '" << name << "'\n";
|
std::cerr << std::format("Type is not an asset '{}'\n", name);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +101,7 @@ bool CodeGenerator::GenerateCode(IDataRepository* repository)
|
|||||||
const auto foundTemplate = m_template_mapping.find(templateName);
|
const auto foundTemplate = m_template_mapping.find(templateName);
|
||||||
if (foundTemplate == m_template_mapping.end())
|
if (foundTemplate == m_template_mapping.end())
|
||||||
{
|
{
|
||||||
std::cout << "Unknown template '" << generationTask.m_template_name << "'.\n";
|
std::cerr << std::format("Unknown template '{}'.\n", generationTask.m_template_name);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,13 +112,13 @@ bool CodeGenerator::GenerateCode(IDataRepository* repository)
|
|||||||
auto context = RenderingContext::BuildContext(repository, asset);
|
auto context = RenderingContext::BuildContext(repository, asset);
|
||||||
if (!GenerateCodeForTemplate(context.get(), foundTemplate->second.get()))
|
if (!GenerateCodeForTemplate(context.get(), foundTemplate->second.get()))
|
||||||
{
|
{
|
||||||
std::cout << "Failed to generate code for asset '" << asset->m_definition->GetFullName() << "' with preset '" << foundTemplate->first
|
std::cerr << std::format(
|
||||||
<< "'\n";
|
"Failed to generate code for asset '{}' with preset '{}'\n", asset->m_definition->GetFullName(), foundTemplate->first);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "Successfully generated code for asset '" << asset->m_definition->GetFullName() << "' with preset '" << foundTemplate->first
|
std::cout << std::format(
|
||||||
<< "'\n";
|
"Successfully generated code for asset '{}' with preset '{}'\n", asset->m_definition->GetFullName(), foundTemplate->first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -133,9 +134,7 @@ bool CodeGenerator::GenerateCode(IDataRepository* repository)
|
|||||||
}
|
}
|
||||||
const auto end = std::chrono::steady_clock::now();
|
const auto end = std::chrono::steady_clock::now();
|
||||||
if (m_args->m_verbose)
|
if (m_args->m_verbose)
|
||||||
{
|
std::cout << std::format("Generating code took {}ms\n", std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count());
|
||||||
std::cout << "Generating code took " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,5 @@ private:
|
|||||||
static bool GetAssetWithName(IDataRepository* repository, const std::string& name, StructureInformation*& asset);
|
static bool GetAssetWithName(IDataRepository* repository, const std::string& name, StructureInformation*& asset);
|
||||||
|
|
||||||
const ZoneCodeGeneratorArguments* m_args;
|
const ZoneCodeGeneratorArguments* m_args;
|
||||||
|
|
||||||
std::unordered_map<std::string, std::unique_ptr<ICodeTemplate>> m_template_mapping;
|
std::unordered_map<std::string, std::unique_ptr<ICodeTemplate>> m_template_mapping;
|
||||||
};
|
};
|
||||||
|
@ -9,14 +9,14 @@
|
|||||||
class CodeTemplateFile
|
class CodeTemplateFile
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::string m_file_name;
|
|
||||||
int m_tag;
|
|
||||||
|
|
||||||
CodeTemplateFile(std::string fileName, const int tag)
|
CodeTemplateFile(std::string fileName, const int tag)
|
||||||
: m_file_name(std::move(fileName)),
|
: m_file_name(std::move(fileName)),
|
||||||
m_tag(tag)
|
m_tag(tag)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string m_file_name;
|
||||||
|
int m_tag;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ICodeTemplate
|
class ICodeTemplate
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include "Domain/Computations/MemberComputations.h"
|
#include "Domain/Computations/MemberComputations.h"
|
||||||
#include "Domain/Computations/StructureComputations.h"
|
#include "Domain/Computations/StructureComputations.h"
|
||||||
#include "Internal/BaseTemplate.h"
|
#include "Internal/BaseTemplate.h"
|
||||||
|
#include "Utils/StringUtils.h"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -261,7 +262,7 @@ namespace
|
|||||||
LINEF("{0}::{0}(Zone* zone, IZoneInputStream* stream)", LoaderClassName(m_env.m_asset))
|
LINEF("{0}::{0}(Zone* zone, IZoneInputStream* stream)", LoaderClassName(m_env.m_asset))
|
||||||
|
|
||||||
m_intendation++;
|
m_intendation++;
|
||||||
LINE_STARTF(": AssetLoader({0}, zone, stream)", m_env.m_asset->m_asset_enum_entry->m_name)
|
LINE_STARTF(": AssetLoader({0}::EnumEntry, zone, stream)", m_env.m_asset->m_asset_name)
|
||||||
if (m_env.m_has_actions)
|
if (m_env.m_has_actions)
|
||||||
{
|
{
|
||||||
LINE_MIDDLE(", m_actions(zone)")
|
LINE_MIDDLE(", m_actions(zone)")
|
||||||
@ -1349,8 +1350,7 @@ std::vector<CodeTemplateFile> ZoneLoadTemplate::GetFilesToRender(RenderingContex
|
|||||||
std::vector<CodeTemplateFile> files;
|
std::vector<CodeTemplateFile> files;
|
||||||
|
|
||||||
auto assetName = context->m_asset->m_definition->m_name;
|
auto assetName = context->m_asset->m_definition->m_name;
|
||||||
for (auto& c : assetName)
|
utils::MakeStringLowerCase(assetName);
|
||||||
c = static_cast<char>(tolower(c));
|
|
||||||
|
|
||||||
files.emplace_back(std::format("{0}/{0}_load_db.h", assetName), TAG_HEADER);
|
files.emplace_back(std::format("{0}/{0}_load_db.h", assetName), TAG_HEADER);
|
||||||
files.emplace_back(std::format("{0}/{0}_load_db.cpp", assetName), TAG_SOURCE);
|
files.emplace_back(std::format("{0}/{0}_load_db.cpp", assetName), TAG_SOURCE);
|
||||||
|
@ -245,7 +245,7 @@ namespace
|
|||||||
LINEF("{0}::{0}(Zone* zone)", MarkerClassName(m_env.m_asset))
|
LINEF("{0}::{0}(Zone* zone)", MarkerClassName(m_env.m_asset))
|
||||||
|
|
||||||
m_intendation++;
|
m_intendation++;
|
||||||
LINEF(": AssetMarker({0}, zone)", m_env.m_asset->m_asset_enum_entry->m_name)
|
LINEF(": AssetMarker({0}::EnumEntry, zone)", m_env.m_asset->m_asset_name)
|
||||||
m_intendation--;
|
m_intendation--;
|
||||||
|
|
||||||
LINE("{")
|
LINE("{")
|
||||||
|
@ -97,7 +97,6 @@ namespace
|
|||||||
m_intendation++;
|
m_intendation++;
|
||||||
PrintHeaderConstructor();
|
PrintHeaderConstructor();
|
||||||
PrintHeaderMainWriteMethodDeclaration(m_env.m_asset);
|
PrintHeaderMainWriteMethodDeclaration(m_env.m_asset);
|
||||||
PrintHeaderGetNameMethodDeclaration(m_env.m_asset);
|
|
||||||
|
|
||||||
m_intendation--;
|
m_intendation--;
|
||||||
LINE("};")
|
LINE("};")
|
||||||
@ -160,8 +159,6 @@ namespace
|
|||||||
PrintWritePtrMethod(m_env.m_asset);
|
PrintWritePtrMethod(m_env.m_asset);
|
||||||
LINE("")
|
LINE("")
|
||||||
PrintMainWriteMethod();
|
PrintMainWriteMethod();
|
||||||
LINE("")
|
|
||||||
PrintGetNameMethod();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -220,11 +217,6 @@ namespace
|
|||||||
LINEF("void WritePtr_{0}(bool atStreamStart);", MakeSafeTypeName(info->m_definition))
|
LINEF("void WritePtr_{0}(bool atStreamStart);", MakeSafeTypeName(info->m_definition))
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintHeaderGetNameMethodDeclaration(const StructureInformation* info) const
|
|
||||||
{
|
|
||||||
LINEF("static std::string GetAssetName({0}* pAsset);", info->m_definition->GetFullName())
|
|
||||||
}
|
|
||||||
|
|
||||||
void PrintHeaderMainWriteMethodDeclaration(const StructureInformation* info) const
|
void PrintHeaderMainWriteMethodDeclaration(const StructureInformation* info) const
|
||||||
{
|
{
|
||||||
LINEF("void Write({0}** pAsset);", info->m_definition->GetFullName())
|
LINEF("void Write({0}** pAsset);", info->m_definition->GetFullName())
|
||||||
@ -261,7 +253,8 @@ namespace
|
|||||||
"{0}::{0}({1}* asset, const Zone& zone, IZoneOutputStream& stream)", WriterClassName(m_env.m_asset), m_env.m_asset->m_definition->GetFullName())
|
"{0}::{0}({1}* asset, const Zone& zone, IZoneOutputStream& stream)", WriterClassName(m_env.m_asset), m_env.m_asset->m_definition->GetFullName())
|
||||||
|
|
||||||
m_intendation++;
|
m_intendation++;
|
||||||
LINEF(": AssetWriter(zone.m_pools->GetAssetOrAssetReference({0}, GetAssetName(asset)), zone, stream)", m_env.m_asset->m_asset_enum_entry->m_name)
|
LINEF(": AssetWriter(zone.m_pools->GetAssetOrAssetReference({0}::EnumEntry, AssetNameAccessor<{0}>()(*asset)), zone, stream)",
|
||||||
|
m_env.m_asset->m_asset_name)
|
||||||
m_intendation--;
|
m_intendation--;
|
||||||
|
|
||||||
LINE("{")
|
LINE("{")
|
||||||
@ -1102,40 +1095,6 @@ namespace
|
|||||||
LINE("}")
|
LINE("}")
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintGetNameMethod()
|
|
||||||
{
|
|
||||||
LINEF("std::string {0}::GetAssetName({1}* pAsset)", WriterClassName(m_env.m_asset), m_env.m_asset->m_definition->GetFullName())
|
|
||||||
LINE("{")
|
|
||||||
m_intendation++;
|
|
||||||
|
|
||||||
if (!m_env.m_asset->m_name_chain.empty())
|
|
||||||
{
|
|
||||||
LINE_START("return pAsset")
|
|
||||||
|
|
||||||
auto first = true;
|
|
||||||
for (const auto* member : m_env.m_asset->m_name_chain)
|
|
||||||
{
|
|
||||||
if (first)
|
|
||||||
{
|
|
||||||
first = false;
|
|
||||||
LINE_MIDDLEF("->{0}", member->m_member->m_name)
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LINE_MIDDLEF(".{0}", member->m_member->m_name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
LINE_END(";")
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LINEF("return \"{0}\";", m_env.m_asset->m_definition->m_name)
|
|
||||||
}
|
|
||||||
|
|
||||||
m_intendation--;
|
|
||||||
LINE("}")
|
|
||||||
}
|
|
||||||
|
|
||||||
void PrintWritePtrArrayMethod_Loading(const DataDefinition* def, const StructureInformation* info, const bool reusable) const
|
void PrintWritePtrArrayMethod_Loading(const DataDefinition* def, const StructureInformation* info, const bool reusable) const
|
||||||
{
|
{
|
||||||
LINEF("m_stream->Align({0});", def->GetAlignment())
|
LINEF("m_stream->Align({0});", def->GetAlignment())
|
||||||
|
@ -130,7 +130,7 @@ bool CommandsParserState::GetTypenameAndMembersFromTypename(const std::string& t
|
|||||||
|
|
||||||
if (foundDefinition == nullptr)
|
if (foundDefinition == nullptr)
|
||||||
{
|
{
|
||||||
currentSeparatorPos = typeNameValue.size();
|
currentSeparatorPos = static_cast<unsigned>(typeNameValue.size());
|
||||||
foundDefinition = m_repository->GetDataDefinitionByName(typeNameValue);
|
foundDefinition = m_repository->GetDataDefinitionByName(typeNameValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,7 +376,7 @@ std::unique_ptr<IEvaluation>
|
|||||||
operands.emplace_back(std::move(firstStatementPart));
|
operands.emplace_back(std::move(firstStatementPart));
|
||||||
|
|
||||||
if (result.PeekAndRemoveIfTag(TAG_EVALUATION_OPERATION) == TAG_EVALUATION_OPERATION)
|
if (result.PeekAndRemoveIfTag(TAG_EVALUATION_OPERATION) == TAG_EVALUATION_OPERATION)
|
||||||
operators.emplace_back(operators.size(), result.NextCapture(CAPTURE_BINARY_OPERATION_TYPE).OpTypeValue());
|
operators.emplace_back(static_cast<unsigned>(operators.size()), result.NextCapture(CAPTURE_BINARY_OPERATION_TYPE).OpTypeValue());
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
static constexpr auto CAPTURE_TYPE = 1;
|
static constexpr auto CAPTURE_TYPE = 1;
|
||||||
static constexpr auto CAPTURE_ENUM_ENTRY = 2;
|
static constexpr auto CAPTURE_ASSET_NAME = 2;
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
SequenceAsset::SequenceAsset()
|
SequenceAsset::SequenceAsset()
|
||||||
@ -17,7 +17,7 @@ SequenceAsset::SequenceAsset()
|
|||||||
AddMatchers({
|
AddMatchers({
|
||||||
create.Keyword("asset"),
|
create.Keyword("asset"),
|
||||||
create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE),
|
create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE),
|
||||||
create.Identifier().Capture(CAPTURE_ENUM_ENTRY),
|
create.Identifier().Capture(CAPTURE_ASSET_NAME),
|
||||||
create.Char(';'),
|
create.Char(';'),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -25,7 +25,7 @@ SequenceAsset::SequenceAsset()
|
|||||||
void SequenceAsset::ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const
|
void SequenceAsset::ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const
|
||||||
{
|
{
|
||||||
const auto& typeNameToken = result.NextCapture(CAPTURE_TYPE);
|
const auto& typeNameToken = result.NextCapture(CAPTURE_TYPE);
|
||||||
const auto& enumEntryToken = result.NextCapture(CAPTURE_ENUM_ENTRY);
|
const auto& assetNameToken = result.NextCapture(CAPTURE_ASSET_NAME);
|
||||||
|
|
||||||
auto* definition = state->GetRepository()->GetDataDefinitionByName(typeNameToken.TypeNameValue());
|
auto* definition = state->GetRepository()->GetDataDefinitionByName(typeNameToken.TypeNameValue());
|
||||||
if (definition == nullptr)
|
if (definition == nullptr)
|
||||||
@ -39,9 +39,7 @@ void SequenceAsset::ProcessMatch(CommandsParserState* state, SequenceResult<Comm
|
|||||||
if (information == nullptr)
|
if (information == nullptr)
|
||||||
throw ParsingException(typeNameToken.GetPos(), "No information for definition");
|
throw ParsingException(typeNameToken.GetPos(), "No information for definition");
|
||||||
|
|
||||||
auto* enumMember = state->GetRepository()->GetEnumMemberByName(enumEntryToken.IdentifierValue());
|
information->m_asset_name = assetNameToken.IdentifierValue();
|
||||||
if (enumMember == nullptr)
|
if (information->m_asset_name.empty())
|
||||||
throw ParsingException(enumEntryToken.GetPos(), "Unknown enum entry");
|
throw ParsingException(assetNameToken.GetPos(), "Asset name is empty");
|
||||||
|
|
||||||
information->m_asset_enum_entry = enumMember;
|
|
||||||
}
|
}
|
||||||
|
@ -10,12 +10,12 @@ namespace
|
|||||||
{
|
{
|
||||||
bool CalculateRequiresMarking(std::unordered_set<const void*>& visitedStructures, StructureInformation* info)
|
bool CalculateRequiresMarking(std::unordered_set<const void*>& visitedStructures, StructureInformation* info)
|
||||||
{
|
{
|
||||||
if (visitedStructures.find(info) != visitedStructures.end())
|
if (visitedStructures.contains(info))
|
||||||
return info->m_requires_marking;
|
return info->m_requires_marking;
|
||||||
|
|
||||||
visitedStructures.emplace(info);
|
visitedStructures.emplace(info);
|
||||||
|
|
||||||
if (info->m_asset_enum_entry)
|
if (StructureComputations(info).IsAsset())
|
||||||
{
|
{
|
||||||
info->m_requires_marking = true;
|
info->m_requires_marking = true;
|
||||||
return true;
|
return true;
|
||||||
@ -47,7 +47,7 @@ namespace
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Any script strings, asset refs and assets need to be processed.
|
// Any script strings, asset refs and assets need to be processed.
|
||||||
if (member->m_is_script_string || member->m_asset_ref || member->m_type && member->m_type->m_asset_enum_entry)
|
if (member->m_is_script_string || member->m_asset_ref || member->m_type && StructureComputations(member->m_type).IsAsset())
|
||||||
{
|
{
|
||||||
info->m_requires_marking = true;
|
info->m_requires_marking = true;
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user