18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-27 21:45:16 +01:00

refactor: rename the import methods and the module variables (Sonar S1669) (#363)

import and module are contextual keywords of C++20 modules. The text
loaders of the scene nodes (shape_node, lines_node, road_node,
junction_node, roadpoint_node, sweep_node) become import_from(), the
WASM module of the screen host's cache entry and of load() becomes
wasm_module, and the path of the written test module becomes
module_path. Renames only.
This commit is contained in:
jerrrrycho
2026-11-20 03:42:41 +01:00
committed by GitHub
parent 7f2c611772
commit 357ccabd0c
12 changed files with 39 additions and 39 deletions

View File

@@ -523,9 +523,9 @@ class wasm_runtime_host final : public runtime
{
for (auto const &[script, entry] : m_modules)
{
if (entry.module != nullptr)
if (entry.wasm_module != nullptr)
{
wasm_runtime_unload(entry.module);
wasm_runtime_unload(entry.wasm_module);
}
}
if (m_started)
@@ -551,7 +551,7 @@ class wasm_runtime_host final : public runtime
struct module_entry
{
std::vector<std::uint8_t> bytes; // the runtime reads the module from here as long as it is loaded
wasm_module_t module{nullptr};
wasm_module_t wasm_module{nullptr};
};
wasm_module_t load_module(std::string const &Script);
@@ -584,7 +584,7 @@ wasm_module_t wasm_runtime_host::load_module(std::string const &Script)
{
if (auto const lookup{m_modules.find(Script)}; lookup != m_modules.end())
{
return lookup->second.module;
return lookup->second.wasm_module;
}
// a failure is kept as well, so the module isn't tried again for every screen using it
auto &entry{m_modules[Script]};
@@ -601,23 +601,23 @@ wasm_module_t wasm_runtime_host::load_module(std::string const &Script)
return nullptr;
}
std::array<char, 256> error{};
entry.module = wasm_runtime_load(entry.bytes.data(), static_cast<std::uint32_t>(entry.bytes.size()), error.data(), static_cast<std::uint32_t>(error.size()));
if (entry.module == nullptr)
entry.wasm_module = wasm_runtime_load(entry.bytes.data(), static_cast<std::uint32_t>(entry.bytes.size()), error.data(), static_cast<std::uint32_t>(error.size()));
if (entry.wasm_module == nullptr)
{
ErrorLog(std::format("WASM screen \"{}\": failed to load the module: {}", Script, error.data()));
}
return entry.module;
return entry.wasm_module;
}
std::unique_ptr<program> wasm_runtime_host::load(std::string const &Script, script_screen_kind const Kind)
{
auto *module{load_module(Script)};
if (module == nullptr)
auto *wasm_module{load_module(Script)};
if (wasm_module == nullptr)
{
return nullptr;
}
auto loaded{std::make_unique<wasm_program>(Script, Kind)};
if (false == loaded->instantiate(module))
if (false == loaded->instantiate(wasm_module))
{
return nullptr;
}