From a51e4afb05cb4e07888dbbfce71bbdaf35e2d42c Mon Sep 17 00:00:00 2001 From: WerWolv Date: Mon, 23 Jan 2023 13:53:29 +0100 Subject: [PATCH] patterns: Updated pattern language --- lib/external/pattern_language | 2 +- .../source/content/pl_builtin_functions.cpp | 4 ++-- .../builtin/source/content/pl_visualizers.cpp | 20 +++++++++---------- .../content/views/view_pattern_editor.cpp | 2 +- plugins/builtin/source/ui/pattern_drawer.cpp | 8 ++++---- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/external/pattern_language b/lib/external/pattern_language index f73f87c9c..69a3d4c05 160000 --- a/lib/external/pattern_language +++ b/lib/external/pattern_language @@ -1 +1 @@ -Subproject commit f73f87c9ccb43c19ef4b02dffb752b890da7afed +Subproject commit 69a3d4c05eb6bb1efe7fd926fc99f2982e22a59a diff --git a/plugins/builtin/source/content/pl_builtin_functions.cpp b/plugins/builtin/source/content/pl_builtin_functions.cpp index e35987c5c..5b0a4f4ab 100644 --- a/plugins/builtin/source/content/pl_builtin_functions.cpp +++ b/plugins/builtin/source/content/pl_builtin_functions.cpp @@ -31,7 +31,7 @@ namespace hex::plugin::builtin { { /* demangle(mangled_string) */ ContentRegistry::PatternLanguage::addFunction(nsHexDec, "demangle", FunctionParameterCount::exactly(1), [](Evaluator *, auto params) -> std::optional { - const auto mangledString = Token::literalToString(params[0], false); + const auto mangledString = params[0].toString(false); return llvm::demangle(mangledString); }); @@ -41,7 +41,7 @@ namespace hex::plugin::builtin { { /* get(url) */ ContentRegistry::PatternLanguage::addDangerousFunction(nsHexHttp, "get", FunctionParameterCount::exactly(1), [](Evaluator *, auto params) -> std::optional { - const auto url = Token::literalToString(params[0], false); + const auto url = params[0].toString(false); hex::Net net; return net.getString(url).get().body; diff --git a/plugins/builtin/source/content/pl_visualizers.cpp b/plugins/builtin/source/content/pl_visualizers.cpp index 27e145e08..5a0917e67 100644 --- a/plugins/builtin/source/content/pl_visualizers.cpp +++ b/plugins/builtin/source/content/pl_visualizers.cpp @@ -27,7 +27,7 @@ namespace hex::plugin::builtin { ImPlot::PlotLineG("##line", [](void *data, int idx) -> ImPlotPoint { auto &iteratable = *static_cast(data); - return { static_cast(idx), pl::core::Token::literalToFloatingPoint(iteratable.getEntry(idx)->getValue()) }; + return { static_cast(idx), iteratable.getEntry(idx)->getValue().toFloatingPoint() }; }, &iteratable, iteratable.getEntryCount()); ImPlot::EndPlot(); @@ -50,8 +50,8 @@ namespace hex::plugin::builtin { void drawBitmapVisualizer(pl::ptrn::Pattern &pattern, pl::ptrn::Iteratable &, bool shouldReset, const std::vector &arguments) { static ImGui::Texture texture; if (shouldReset) { - auto width = pl::core::Token::literalToUnsigned(arguments[1]); - auto height = pl::core::Token::literalToUnsigned(arguments[2]); + auto width = arguments[1].toUnsigned(); + auto height = arguments[2].toUnsigned(); std::vector data; data.resize(width * height * 4); @@ -73,9 +73,9 @@ namespace hex::plugin::builtin { static std::vector disassembly; if (shouldReset) { - auto baseAddress = pl::core::Token::literalToUnsigned(arguments[1]); - auto architecture = pl::core::Token::literalToUnsigned(arguments[2]); - auto mode = pl::core::Token::literalToUnsigned(arguments[3]); + auto baseAddress = arguments[1].toUnsigned(); + auto architecture = arguments[2].toUnsigned(); + auto mode = arguments[3].toUnsigned(); disassembly.clear(); @@ -136,9 +136,9 @@ namespace hex::plugin::builtin { T value; if (std::floating_point) - value = pl::core::Token::literalToFloatingPoint(child->getValue()); + value = child->getValue().toFloatingPoint(); else - value = pl::core::Token::literalToUnsigned(child->getValue()); + value = child->getValue().toUnsigned(); result.push_back(value); } @@ -152,8 +152,8 @@ namespace hex::plugin::builtin { }; void draw3DVisualizer(pl::ptrn::Pattern &, pl::ptrn::Iteratable &, bool shouldReset, const std::vector &arguments) { - auto verticesPattern = pl::core::Token::literalToPattern(arguments[1]); - auto indicesPattern = pl::core::Token::literalToPattern(arguments[2]); + auto verticesPattern = arguments[1].toPattern(); + auto indicesPattern = arguments[2].toPattern(); static ImGui::Texture texture; static float scaling = 0.5F; diff --git a/plugins/builtin/source/content/views/view_pattern_editor.cpp b/plugins/builtin/source/content/views/view_pattern_editor.cpp index da6906cf1..982b80ac0 100644 --- a/plugins/builtin/source/content/views/view_pattern_editor.cpp +++ b/plugins/builtin/source/content/views/view_pattern_editor.cpp @@ -378,7 +378,7 @@ namespace hex::plugin::builtin { ImGui::TableNextColumn(); if (variable.outVariable) { - ImGui::TextUnformatted(pl::core::Token::literalToString(variable.value, true).c_str()); + ImGui::TextUnformatted(variable.value.toString(true).c_str()); } else if (variable.inVariable) { const std::string label { "##" + name }; diff --git a/plugins/builtin/source/ui/pattern_drawer.cpp b/plugins/builtin/source/ui/pattern_drawer.cpp index d4de87ae7..30fecc1e9 100644 --- a/plugins/builtin/source/ui/pattern_drawer.cpp +++ b/plugins/builtin/source/ui/pattern_drawer.cpp @@ -114,7 +114,7 @@ namespace hex::plugin::builtin::ui { } void drawVisualizer(const std::vector &arguments, pl::ptrn::Pattern &pattern, pl::ptrn::Iteratable &iteratable, bool reset) { - auto visualizerName = pl::core::Token::literalToString(arguments.front(), true); + auto visualizerName = arguments.front().toString(true); const auto &visualizers = ContentRegistry::PatternLanguage::impl::getVisualizers(); @@ -360,10 +360,10 @@ namespace hex::plugin::builtin::ui { ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x); if (ImGui::BeginCombo("##Enum", pattern.getFormattedValue().c_str())) { - auto currValue = pl::core::Token::literalToUnsigned(pattern.getValue()); + auto currValue = pattern.getValue().toUnsigned(); for (auto &value : pattern.getEnumValues()) { - auto min = pl::core::Token::literalToUnsigned(value.min); - auto max = pl::core::Token::literalToUnsigned(value.max); + auto min = value.min.toUnsigned(); + auto max = value.max.toUnsigned(); bool isSelected = min <= currValue && max >= currValue; if (ImGui::Selectable(fmt::format("{}::{} (0x{:0{}X})", pattern.getTypeName(), value.name, min, pattern.getSize() * 2).c_str(), isSelected)) {