impr: General code cleanup

This commit is contained in:
WerWolv
2023-11-10 20:47:08 +01:00
parent 3aacf0f1fb
commit 498d8c1d65
181 changed files with 1431 additions and 1579 deletions

View File

@@ -4,7 +4,6 @@
#include <hex/helpers/http_requests.hpp>
#include <pl/core/token.hpp>
#include <pl/core/log_console.hpp>
#include <pl/core/evaluator.hpp>
#include <pl/patterns/pattern.hpp>
@@ -16,8 +15,9 @@ namespace hex::plugin::builtin {
using namespace pl::core;
using FunctionParameterCount = pl::api::FunctionParameterCount;
pl::api::Namespace nsHexCore = { "builtin", "hex", "core" };
{
const pl::api::Namespace nsHexCore = { "builtin", "hex", "core" };
/* get_selection() */
ContentRegistry::PatternLanguage::addFunction(nsHexCore, "get_selection", FunctionParameterCount::none(), [](Evaluator *, auto) -> std::optional<Token::Literal> {
if (!ImHexApi::HexEditor::isSelectionValid())
@@ -29,8 +29,9 @@ namespace hex::plugin::builtin {
});
}
pl::api::Namespace nsHexPrv = { "builtin", "hex", "prv" };
{
const pl::api::Namespace nsHexPrv = { "builtin", "hex", "prv" };
/* get_information() */
ContentRegistry::PatternLanguage::addFunction(nsHexPrv, "get_information", FunctionParameterCount::between(1, 2), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
std::string category = params[0].toString(false);
@@ -52,8 +53,9 @@ namespace hex::plugin::builtin {
});
}
pl::api::Namespace nsHexDec = { "builtin", "hex", "dec" };
{
const pl::api::Namespace nsHexDec = { "builtin", "hex", "dec" };
/* demangle(mangled_string) */
ContentRegistry::PatternLanguage::addFunction(nsHexDec, "demangle", FunctionParameterCount::exactly(1), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
const auto mangledString = params[0].toString(false);
@@ -62,8 +64,9 @@ namespace hex::plugin::builtin {
});
}
pl::api::Namespace nsHexHttp = { "builtin", "hex", "http" };
{
const pl::api::Namespace nsHexHttp = { "builtin", "hex", "http" };
/* get(url) */
ContentRegistry::PatternLanguage::addDangerousFunction(nsHexHttp, "get", FunctionParameterCount::exactly(1), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
const auto url = params[0].toString(false);