mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-05-02 08:29:36 +00:00
refactor: fix additional zcg x64 warnings
This commit is contained in:
@@ -80,7 +80,7 @@ public:
|
||||
result.m_fabricated_tokens.push_back(m_transform_func(tokens));
|
||||
|
||||
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())
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
template<typename TokenType> class MatcherFactoryWrapper
|
||||
{
|
||||
// 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;
|
||||
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
template<typename TokenType> class AbstractMatcherFactory
|
||||
{
|
||||
// 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;
|
||||
|
||||
@@ -85,52 +85,52 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
_NODISCARD MatcherFactoryWrapper<TokenType> False() const
|
||||
[[nodiscard]] MatcherFactoryWrapper<TokenType> False() const
|
||||
{
|
||||
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>>());
|
||||
}
|
||||
|
||||
_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));
|
||||
}
|
||||
|
||||
_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)));
|
||||
}
|
||||
|
||||
_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));
|
||||
}
|
||||
|
||||
_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)));
|
||||
}
|
||||
|
||||
_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)));
|
||||
}
|
||||
|
||||
_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))));
|
||||
}
|
||||
|
||||
_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)));
|
||||
}
|
||||
|
||||
_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));
|
||||
}
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
namespace
|
||||
{
|
||||
// The highest bit is the fabricated flag
|
||||
constexpr size_t FABRICATED_FLAG_MASK = 1uz << (sizeof(size_t) * 8uz - 1uz);
|
||||
constexpr size_t TOKEN_INDEX_MASK = ~FABRICATED_FLAG_MASK;
|
||||
constexpr unsigned FABRICATED_FLAG_MASK = 1u << (sizeof(unsigned) * 8u - 1u);
|
||||
constexpr unsigned TOKEN_INDEX_MASK = ~FABRICATED_FLAG_MASK;
|
||||
} // 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;
|
||||
if (isFabricated)
|
||||
@@ -19,7 +19,7 @@ bool MatcherResultTokenIndex::IsFabricated() const
|
||||
return m_token_index & FABRICATED_FLAG_MASK;
|
||||
}
|
||||
|
||||
size_t MatcherResultTokenIndex::GetTokenIndex() const
|
||||
unsigned MatcherResultTokenIndex::GetTokenIndex() const
|
||||
{
|
||||
return m_token_index & TOKEN_INDEX_MASK;
|
||||
}
|
||||
|
||||
@@ -10,12 +10,12 @@
|
||||
class MatcherResultTokenIndex
|
||||
{
|
||||
public:
|
||||
MatcherResultTokenIndex(size_t index, bool isFabricated);
|
||||
MatcherResultTokenIndex(unsigned index, bool isFabricated);
|
||||
[[nodiscard]] bool IsFabricated() const;
|
||||
[[nodiscard]] size_t GetTokenIndex() const;
|
||||
[[nodiscard]] unsigned GetTokenIndex() const;
|
||||
|
||||
private:
|
||||
size_t m_token_index;
|
||||
unsigned m_token_index;
|
||||
};
|
||||
|
||||
class MatcherResultCapture
|
||||
@@ -54,8 +54,9 @@ public:
|
||||
for (const auto& capture : other.m_captures)
|
||||
{
|
||||
if (capture.m_token_index.IsFabricated())
|
||||
m_captures.emplace_back(capture.GetCaptureId(),
|
||||
MatcherResultTokenIndex(m_fabricated_tokens.size() + capture.m_token_index.GetTokenIndex(), true));
|
||||
m_captures.emplace_back(
|
||||
capture.GetCaptureId(),
|
||||
MatcherResultTokenIndex(static_cast<unsigned>(m_fabricated_tokens.size()) + capture.m_token_index.GetTokenIndex(), true));
|
||||
else
|
||||
m_captures.emplace_back(capture.GetCaptureId(), capture.m_token_index);
|
||||
}
|
||||
@@ -63,7 +64,7 @@ public:
|
||||
for (const auto& token : other.m_matched_tokens)
|
||||
{
|
||||
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
|
||||
m_matched_tokens.emplace_back(token.GetTokenIndex(), false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user