patterns: Fixed various render issues

This commit is contained in:
WerWolv
2022-04-07 12:47:45 +02:00
parent 0462cc3d0c
commit 76f732dc53
8 changed files with 79 additions and 77 deletions

View File

@@ -77,7 +77,7 @@ namespace hex::pl {
[[nodiscard]] const std::optional<std::string> &getComment() const { return this->m_comment; }
void setComment(std::string comment) { this->m_comment = std::move(comment); }
[[nodiscard]] const std::string &getTypeName() const { return this->m_typeName; }
[[nodiscard]] virtual std::string getTypeName() const { return this->m_typeName; }
void setTypeName(std::string name) { this->m_typeName = std::move(name); }
[[nodiscard]] u32 getColor() const { return this->m_color; }

View File

@@ -39,7 +39,7 @@ namespace hex::pl {
return this->m_entries[0]->getTypeName() + "[" + std::to_string(this->m_entries.size()) + "]";
}
[[nodiscard]] std::string getTypeName() const {
[[nodiscard]] std::string getTypeName() const override {
return this->m_entries[0]->getTypeName();
}
@@ -58,7 +58,7 @@ namespace hex::pl {
return this->m_entries;
}
void forEachArrayEntry(const std::function<void(int, Pattern&)>& fn) {
void forEachArrayEntry(const std::function<void(u64, Pattern&)>& fn) {
for (u64 i = 0; i < this->m_entries.size(); i++)
fn(i, *this->m_entries[i]);
}

View File

@@ -19,9 +19,10 @@ namespace hex::pl {
return std::unique_ptr<Pattern>(new PatternArrayStatic(*this));
}
void forEachArrayEntry(const std::function<void(int, Pattern&)>& fn) {
void forEachArrayEntry(const std::function<void(u64, Pattern&)>& fn) {
auto entry = std::shared_ptr(this->m_template->clone());
for (u64 index = 0; index < this->m_entryCount; index++) {
entry->clearFormatCache();
entry->setVariableName(hex::format("[{0}]", index));
entry->setOffset(this->getOffset() + index * this->m_template->getSize());
fn(index, *entry);

View File

@@ -24,7 +24,7 @@ namespace hex::pl {
return "enum " + Pattern::getTypeName();
}
[[nodiscard]] std::string getTypeName() const {
[[nodiscard]] std::string getTypeName() const override {
return Pattern::getTypeName();
}

View File

@@ -67,10 +67,6 @@ namespace hex::pl {
return "union " + Pattern::getTypeName();
}
[[nodiscard]] std::string getTypeName() const {
return Pattern::getTypeName();
}
[[nodiscard]] const auto &getMembers() const {
return this->m_members;
}