patterns: Update pattern language

This commit is contained in:
WerWolv
2025-12-21 20:52:46 +01:00
parent 33e315709a
commit 018bedb2bd
7 changed files with 8 additions and 8 deletions

View File

@@ -122,7 +122,7 @@ namespace hex::plugin::builtin {
std::atomic<bool> m_triggerAutoEvaluate = false;
volatile bool m_lastEvaluationProcessed = true;
bool m_lastEvaluationResult = false;
int m_lastEvaluationResult = false;
std::atomic<u32> m_runningEvaluators = 0;
std::atomic<u32> m_runningParsers = 0;

View File

@@ -100,7 +100,7 @@ namespace hex::plugin::builtin {
m_foundPattern = pattern;
constexpr static auto DataDescriptionFunction = "get_data_description";
if (runtime.executeFile(pattern.patternFilePath)) {
if (runtime.executeFile(pattern.patternFilePath) == 0) {
const auto &evaluator = runtime.getInternals().evaluator;
const auto &functions = evaluator->getCustomFunctions();
if (const auto function = functions.find(DataDescriptionFunction); function != functions.end()) {

View File

@@ -34,7 +34,7 @@ namespace hex::plugin::builtin {
ContentRegistry::PatternLanguage::configureRuntime(runtime, &m_provider);
constexpr static auto DataDescriptionFunction = "get_data_description";
if (runtime.executeFile(m_foundPatterns.front().patternFilePath)) {
if (runtime.executeFile(m_foundPatterns.front().patternFilePath) == 0) {
const auto &evaluator = runtime.getInternals().evaluator;
const auto &functions = evaluator->getCustomFunctions();
if (const auto function = functions.find(DataDescriptionFunction); function != functions.end()) {

View File

@@ -73,7 +73,7 @@ namespace hex::plugin::builtin {
}
ContentRegistry::PatternLanguage::configureRuntime(m_runtime, &m_provider);
if (!m_runtime.executeString(this->m_sourceCode)) {
if (m_runtime.executeString(this->m_sourceCode) != 0) {
ui::ToastError::open("hex.builtin.view.fullscreen.save_editor.error.failed_execution"_lang);
for (const auto &error : m_runtime.getCompileErrors()) {
log::error("Save Editor Error: {}", error.format());

View File

@@ -170,7 +170,7 @@ namespace hex::plugin::builtin {
}
void ViewDataInspector::executeInspector(const std::string& code, const std::fs::path& path, const std::map<std::string, pl::core::Token::Literal>& inVariables) {
if (!m_runtime.executeString(code, pl::api::Source::DefaultSource, {}, inVariables, true)) {
if (m_runtime.executeString(code, pl::api::Source::DefaultSource, {}, inVariables, true) == 0) {
auto displayFunction = createPatternErrorDisplayFunction();

View File

@@ -1335,7 +1335,7 @@ namespace hex::plugin::builtin {
return;
if (!m_lastEvaluationProcessed) {
if (!m_lastEvaluationResult) {
if (m_lastEvaluationResult != 0) {
const auto processMessage = [](const auto &message) {
auto lines = wolv::util::splitString(message, "\n");
@@ -1796,7 +1796,7 @@ namespace hex::plugin::builtin {
m_lastEvaluationResult = runtime.executeString(code, pl::api::Source::DefaultSource, envVars, inVariables);
if (!m_lastEvaluationResult) {
if (m_lastEvaluationResult != 0) {
*m_lastEvaluationError = runtime.getEvalError();
*m_lastCompileError = runtime.getCompileErrors();
*m_callStack = &runtime.getInternals().evaluator->getCallStack();