patterns: Updated to new API
This commit is contained in:
parent
7ae814f7fb
commit
6c122e5fbe
2
lib/external/libromfs
vendored
2
lib/external/libromfs
vendored
@ -1 +1 @@
|
||||
Subproject commit 40cd303e9213e544a3ff21562b16406140f254ec
|
||||
Subproject commit 80b9adea2003eb01fa4cf2ecb0d77f2d9c0dd32a
|
2
lib/external/pattern_language
vendored
2
lib/external/pattern_language
vendored
@ -1 +1 @@
|
||||
Subproject commit a918d6f3a76fd199af146e1045aafe637245361e
|
||||
Subproject commit 6fc5210840edf1b3eecd9b06c07066155366b04b
|
@ -239,7 +239,7 @@ namespace hex {
|
||||
|
||||
namespace impl {
|
||||
|
||||
using VisualizerFunctionCallback = std::function<void(pl::ptrn::Pattern&, pl::ptrn::Iteratable&, bool, std::span<const pl::core::Token::Literal>)>;
|
||||
using VisualizerFunctionCallback = std::function<void(pl::ptrn::Pattern&, pl::ptrn::IIterable&, bool, std::span<const pl::core::Token::Literal>)>;
|
||||
|
||||
struct FunctionDefinition {
|
||||
pl::api::Namespace ns;
|
||||
|
@ -16,7 +16,7 @@ namespace hex {
|
||||
concept has_size = sizeof(T) == Size;
|
||||
|
||||
template<typename T>
|
||||
class Cloneable {
|
||||
class ICloneable {
|
||||
public:
|
||||
[[nodiscard]] virtual std::unique_ptr<T> clone() const = 0;
|
||||
};
|
||||
|
@ -6,6 +6,10 @@
|
||||
|
||||
#include <hex.hpp>
|
||||
|
||||
/**
|
||||
* This macro is used to define all the required entry points for a plugin.
|
||||
* Name, Author and Description will be displayed in the in the plugin list on the Welcome screen.
|
||||
*/
|
||||
#define IMHEX_PLUGIN_SETUP(name, author, description) IMHEX_PLUGIN_SETUP_IMPL(name, author, description)
|
||||
|
||||
#define IMHEX_PLUGIN_SETUP_IMPL(name, author, description) \
|
||||
|
@ -49,12 +49,12 @@ namespace hex::plugin::builtin::ui {
|
||||
constexpr static auto ChunkSize = 512;
|
||||
constexpr static auto DisplayEndStep = 64;
|
||||
|
||||
void drawArray(pl::ptrn::Pattern& pattern, pl::ptrn::Iteratable &iteratable, bool isInlined);
|
||||
void drawArray(pl::ptrn::Pattern& pattern, pl::ptrn::IIterable &iteratable, bool isInlined);
|
||||
u64& getDisplayEnd(const pl::ptrn::Pattern& pattern);
|
||||
void makeSelectable(const pl::ptrn::Pattern &pattern);
|
||||
|
||||
void drawVisualizerButton(pl::ptrn::Pattern& pattern, pl::ptrn::Iteratable &iteratable);
|
||||
void drawVisualizer(const std::vector<pl::core::Token::Literal> &arguments, pl::ptrn::Pattern &pattern, pl::ptrn::Iteratable &iteratable, bool reset);
|
||||
void drawVisualizerButton(pl::ptrn::Pattern& pattern, pl::ptrn::IIterable &iteratable);
|
||||
void drawVisualizer(const std::vector<pl::core::Token::Literal> &arguments, pl::ptrn::Pattern &pattern, pl::ptrn::IIterable &iteratable, bool reset);
|
||||
|
||||
void createLeafNode(const pl::ptrn::Pattern& pattern);
|
||||
bool createTreeNode(const pl::ptrn::Pattern& pattern);
|
||||
|
@ -42,7 +42,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
namespace {
|
||||
|
||||
void drawLinePlotVisualizer(pl::ptrn::Pattern &, pl::ptrn::Iteratable &, bool shouldReset, std::span<const pl::core::Token::Literal> arguments) {
|
||||
void drawLinePlotVisualizer(pl::ptrn::Pattern &, pl::ptrn::IIterable &, bool shouldReset, std::span<const pl::core::Token::Literal> arguments) {
|
||||
static std::vector<float> values;
|
||||
auto dataPattern = arguments[0].toPattern();
|
||||
|
||||
@ -61,7 +61,7 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
}
|
||||
|
||||
void drawScatterPlotVisualizer(pl::ptrn::Pattern &, pl::ptrn::Iteratable &, bool shouldReset, std::span<const pl::core::Token::Literal> arguments) {
|
||||
void drawScatterPlotVisualizer(pl::ptrn::Pattern &, pl::ptrn::IIterable &, bool shouldReset, std::span<const pl::core::Token::Literal> arguments) {
|
||||
static std::vector<float> xValues, yValues;
|
||||
|
||||
auto xPattern = arguments[0].toPattern();
|
||||
@ -83,7 +83,7 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
}
|
||||
|
||||
void drawImageVisualizer(pl::ptrn::Pattern &, pl::ptrn::Iteratable &, bool shouldReset, std::span<const pl::core::Token::Literal> arguments) {
|
||||
void drawImageVisualizer(pl::ptrn::Pattern &, pl::ptrn::IIterable &, bool shouldReset, std::span<const pl::core::Token::Literal> arguments) {
|
||||
static ImGui::Texture texture;
|
||||
if (shouldReset) {
|
||||
auto pattern = arguments[0].toPattern();
|
||||
@ -96,7 +96,7 @@ namespace hex::plugin::builtin {
|
||||
ImGui::Image(texture, texture.getSize());
|
||||
}
|
||||
|
||||
void drawBitmapVisualizer(pl::ptrn::Pattern &, pl::ptrn::Iteratable &, bool shouldReset, std::span<const pl::core::Token::Literal> arguments) {
|
||||
void drawBitmapVisualizer(pl::ptrn::Pattern &, pl::ptrn::IIterable &, bool shouldReset, std::span<const pl::core::Token::Literal> arguments) {
|
||||
static ImGui::Texture texture;
|
||||
if (shouldReset) {
|
||||
auto pattern = arguments[0].toPattern();
|
||||
@ -111,7 +111,7 @@ namespace hex::plugin::builtin {
|
||||
ImGui::Image(texture, texture.getSize());
|
||||
}
|
||||
|
||||
void drawDisassemblyVisualizer(pl::ptrn::Pattern &, pl::ptrn::Iteratable &, bool shouldReset, std::span<const pl::core::Token::Literal> arguments) {
|
||||
void drawDisassemblyVisualizer(pl::ptrn::Pattern &, pl::ptrn::IIterable &, bool shouldReset, std::span<const pl::core::Token::Literal> arguments) {
|
||||
struct Disassembly {
|
||||
u64 address;
|
||||
std::vector<u8> bytes;
|
||||
@ -167,7 +167,7 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
}
|
||||
|
||||
void draw3DVisualizer(pl::ptrn::Pattern &, pl::ptrn::Iteratable &, bool shouldReset, std::span<const pl::core::Token::Literal> arguments) {
|
||||
void draw3DVisualizer(pl::ptrn::Pattern &, pl::ptrn::IIterable &, bool shouldReset, std::span<const pl::core::Token::Literal> arguments) {
|
||||
auto verticesPattern = arguments[0].toPattern();
|
||||
auto indicesPattern = arguments[1].toPattern();
|
||||
|
||||
@ -339,7 +339,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
}
|
||||
|
||||
void drawSoundVisualizer(pl::ptrn::Pattern &, pl::ptrn::Iteratable &, bool shouldReset, std::span<const pl::core::Token::Literal> arguments) {
|
||||
void drawSoundVisualizer(pl::ptrn::Pattern &, pl::ptrn::IIterable &, bool shouldReset, std::span<const pl::core::Token::Literal> arguments) {
|
||||
auto wavePattern = arguments[0].toPattern();
|
||||
auto channels = arguments[1].toUnsigned();
|
||||
auto sampleRate = arguments[2].toUnsigned();
|
||||
@ -443,7 +443,7 @@ namespace hex::plugin::builtin {
|
||||
(waveData.size() / sampleRate) / 60, (waveData.size() / sampleRate) % 60);
|
||||
}
|
||||
|
||||
void drawChunkBasedEntropyVisualizer(pl::ptrn::Pattern &, pl::ptrn::Iteratable &, bool shouldReset, std::span<const pl::core::Token::Literal> arguments) {
|
||||
void drawChunkBasedEntropyVisualizer(pl::ptrn::Pattern &, pl::ptrn::IIterable &, bool shouldReset, std::span<const pl::core::Token::Literal> arguments) {
|
||||
// variable used to store the result to avoid having to recalculate the result at each frame
|
||||
static DiagramChunkBasedEntropyAnalysis analyzer;
|
||||
|
||||
|
@ -112,7 +112,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
if (!inspectorCode.empty()) {
|
||||
if (this->m_runtime.executeString(inspectorCode, {}, inVariables, true)) {
|
||||
const auto &patterns = this->m_runtime.getAllPatterns();
|
||||
const auto &patterns = this->m_runtime.getPatterns();
|
||||
|
||||
for (const auto &pattern : patterns) {
|
||||
if (pattern->getVisibility() == pl::ptrn::Visibility::Hidden)
|
||||
|
@ -44,7 +44,7 @@ namespace hex::plugin::builtin {
|
||||
this->m_shouldReset = false;
|
||||
}
|
||||
|
||||
this->m_patternDrawer.draw(runtime.getAllPatterns());
|
||||
this->m_patternDrawer.draw(runtime.getPatterns());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -471,7 +471,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
const auto &patterns = [&, this] -> const auto& {
|
||||
if (patternProvider->isReadable() && *this->m_executionDone)
|
||||
return runtime.getAllPatterns(id);
|
||||
return runtime.getPatterns(id);
|
||||
else {
|
||||
static const std::vector<std::shared_ptr<pl::ptrn::Pattern>> empty;
|
||||
return empty;
|
||||
|
@ -144,7 +144,7 @@ namespace hex::plugin::builtin::ui {
|
||||
this->m_editingPatternOffset = 0x00;
|
||||
}
|
||||
|
||||
void PatternDrawer::drawVisualizer(const std::vector<pl::core::Token::Literal> &arguments, pl::ptrn::Pattern &pattern, pl::ptrn::Iteratable &iteratable, bool reset) {
|
||||
void PatternDrawer::drawVisualizer(const std::vector<pl::core::Token::Literal> &arguments, pl::ptrn::Pattern &pattern, pl::ptrn::IIterable &iteratable, bool reset) {
|
||||
auto visualizerName = arguments.front().toString(true);
|
||||
|
||||
const auto &visualizers = ContentRegistry::PatternLanguage::impl::getVisualizers();
|
||||
@ -169,7 +169,7 @@ namespace hex::plugin::builtin::ui {
|
||||
ImGui::TextUnformatted(this->m_lastVisualizerError.c_str());
|
||||
}
|
||||
|
||||
void PatternDrawer::drawVisualizerButton(pl::ptrn::Pattern& pattern, pl::ptrn::Iteratable &iteratable) {
|
||||
void PatternDrawer::drawVisualizerButton(pl::ptrn::Pattern& pattern, pl::ptrn::IIterable &iteratable) {
|
||||
if (const auto &arguments = pattern.getAttributeArguments("hex::visualize"); !arguments.empty()) {
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0));
|
||||
if (ImGui::IconButton(ICON_VS_EYE, ImGui::GetStyleColorVec4(ImGuiCol_Text), ImVec2(ImGui::GetTextLineHeightWithSpacing(), ImGui::GetTextLineHeight()))) {
|
||||
@ -316,7 +316,7 @@ namespace hex::plugin::builtin::ui {
|
||||
drawSizeColumn(pattern);
|
||||
drawTypenameColumn(pattern, "bitfield");
|
||||
|
||||
drawVisualizerButton(pattern, static_cast<pl::ptrn::Iteratable&>(pattern));
|
||||
drawVisualizerButton(pattern, static_cast<pl::ptrn::IIterable&>(pattern));
|
||||
ImGui::TextFormatted("{}", pattern.getFormattedValue());
|
||||
}
|
||||
|
||||
@ -553,7 +553,7 @@ namespace hex::plugin::builtin::ui {
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
} else {
|
||||
drawVisualizerButton(pattern, static_cast<pl::ptrn::Iteratable&>(pattern));
|
||||
drawVisualizerButton(pattern, static_cast<pl::ptrn::IIterable&>(pattern));
|
||||
ImGui::TextFormatted("{}", pattern.getFormattedValue());
|
||||
}
|
||||
|
||||
@ -606,7 +606,7 @@ namespace hex::plugin::builtin::ui {
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
} else {
|
||||
drawVisualizerButton(pattern, static_cast<pl::ptrn::Iteratable&>(pattern));
|
||||
drawVisualizerButton(pattern, static_cast<pl::ptrn::IIterable&>(pattern));
|
||||
ImGui::TextFormatted("{}", pattern.getFormattedValue());
|
||||
}
|
||||
}
|
||||
@ -666,7 +666,7 @@ namespace hex::plugin::builtin::ui {
|
||||
pattern.accept(*this);
|
||||
}
|
||||
|
||||
void PatternDrawer::drawArray(pl::ptrn::Pattern& pattern, pl::ptrn::Iteratable &iteratable, bool isInlined) {
|
||||
void PatternDrawer::drawArray(pl::ptrn::Pattern& pattern, pl::ptrn::IIterable &iteratable, bool isInlined) {
|
||||
if (iteratable.getEntryCount() == 0)
|
||||
return;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user