From 84530e08174a49890402f13437f3db8ac3125fcf Mon Sep 17 00:00:00 2001 From: WerWolv Date: Fri, 30 Sep 2022 12:49:49 +0200 Subject: [PATCH] patterns: Added demangle function --- .../builtin/source/content/pl_builtin_functions.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/builtin/source/content/pl_builtin_functions.cpp b/plugins/builtin/source/content/pl_builtin_functions.cpp index 812f2bae4..e35987c5c 100644 --- a/plugins/builtin/source/content/pl_builtin_functions.cpp +++ b/plugins/builtin/source/content/pl_builtin_functions.cpp @@ -7,6 +7,7 @@ #include #include +#include namespace hex::plugin::builtin { void registerPatternLanguageFunctions() { @@ -16,7 +17,7 @@ namespace hex::plugin::builtin { pl::api::Namespace nsHexCore = { "builtin", "hex", "core" }; { /* get_selection() */ - ContentRegistry::PatternLanguage::addDangerousFunction(nsHexCore, "get_selection", FunctionParameterCount::none(), [](Evaluator *, auto) -> std::optional { + ContentRegistry::PatternLanguage::addFunction(nsHexCore, "get_selection", FunctionParameterCount::none(), [](Evaluator *, auto) -> std::optional { if (!ImHexApi::HexEditor::isSelectionValid()) return std::numeric_limits::max(); @@ -26,6 +27,16 @@ namespace hex::plugin::builtin { }); } + pl::api::Namespace nsHexDec = { "builtin", "hex", "dec" }; + { + /* demangle(mangled_string) */ + ContentRegistry::PatternLanguage::addFunction(nsHexDec, "demangle", FunctionParameterCount::exactly(1), [](Evaluator *, auto params) -> std::optional { + const auto mangledString = Token::literalToString(params[0], false); + + return llvm::demangle(mangledString); + }); + } + pl::api::Namespace nsHexHttp = { "builtin", "hex", "http" }; { /* get(url) */