impr: Replace hex::unused with std::ignore

This commit is contained in:
WerWolv
2024-12-14 21:35:54 +01:00
parent 3f316e42f2
commit 7f75706584
43 changed files with 173 additions and 139 deletions

View File

@@ -1,4 +1,3 @@
#pragma once
#include <hex/helpers/types.hpp>
#include <hex/helpers/intrinsics.hpp>

View File

@@ -3,7 +3,6 @@
#include <hex.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/helpers/intrinsics.hpp>
#include <hex/data_processor/attribute.hpp>
#include <set>
@@ -47,8 +46,8 @@ namespace hex::dp {
virtual void process() = 0;
virtual void reset() { }
virtual void store(nlohmann::json &j) const { hex::unused(j); }
virtual void load(const nlohmann::json &j) { hex::unused(j); }
virtual void store(nlohmann::json &j) const { std::ignore = j; }
virtual void load(const nlohmann::json &j) { std::ignore = j; }
struct NodeError {
Node *node;

View File

@@ -25,13 +25,16 @@
template<typename T>
std::future<HttpRequest::Result<T>> HttpRequest::uploadFile(const std::fs::path &path, const std::string &mimeName) {
hex::unused(path, mimeName);
std::ignore = path;
std::ignore = mimeName;
throw std::logic_error("Not implemented");
}
template<typename T>
std::future<HttpRequest::Result<T>> HttpRequest::uploadFile(std::vector<u8> data, const std::string &mimeName, const std::fs::path &fileName) {
hex::unused(data, mimeName, fileName);
std::ignore = data;
std::ignore = mimeName;
std::ignore = fileName;
throw std::logic_error("Not implemented");
}

View File

@@ -1,9 +0,0 @@
#pragma once
namespace hex {
void unused(auto && ... x) {
((void)x, ...);
}
}

View File

@@ -70,7 +70,7 @@ void* PluginSubCommandsFunctionHelper<T>::getSubCommands() {
#define IMHEX_LIBRARY_SETUP(name) IMHEX_LIBRARY_SETUP_IMPL(name)
#define IMHEX_LIBRARY_SETUP_IMPL(name) \
namespace { static struct EXIT_HANDLER { ~EXIT_HANDLER() { hex::log::debug("Unloaded library '{}'", name); } } HANDLER; } \
namespace { static struct EXIT_HANDLER { ~EXIT_HANDLER() { hex::log::info("Unloaded library '{}'", name); } } HANDLER; } \
IMHEX_PLUGIN_VISIBILITY_PREFIX void WOLV_TOKEN_CONCAT(initializeLibrary_, IMHEX_PLUGIN_NAME)(); \
IMHEX_PLUGIN_VISIBILITY_PREFIX const char *WOLV_TOKEN_CONCAT(getLibraryName_, IMHEX_PLUGIN_NAME)() { return name; } \
IMHEX_PLUGIN_VISIBILITY_PREFIX void WOLV_TOKEN_CONCAT(setImGuiContext_, IMHEX_PLUGIN_NAME)(ImGuiContext *ctx) { \

View File

@@ -165,7 +165,7 @@ namespace hex::prv {
void insert(u64 offset, u64 size);
void remove(u64 offset, u64 size);
virtual void resizeRaw(u64 newSize) { hex::unused(newSize); }
virtual void resizeRaw(u64 newSize) { std::ignore = newSize; }
virtual void insertRaw(u64 offset, u64 size);
virtual void removeRaw(u64 offset, u64 size);

View File

@@ -815,7 +815,7 @@ namespace hex {
return std::string(GIT_COMMIT_HASH_LONG).substr(0, 7);
}
#else
hex::unused(longHash);
std::ignore = longHash;
return "Unknown";
#endif
}

View File

@@ -112,10 +112,6 @@ namespace hex {
}
Plugin::~Plugin() {
if (isLoaded()) {
log::info("Trying to unload plugin '{}'", getPluginName());
}
unloadLibrary(m_handle, m_path);
}
@@ -335,7 +331,7 @@ namespace hex {
void PluginManager::initializeNewPlugins() {
for (const auto &plugin : getPlugins()) {
if (!plugin.isLoaded())
hex::unused(plugin.initializePlugin());
std::ignore = plugin.initializePlugin();
}
}

View File

@@ -490,7 +490,7 @@ namespace hex {
#elif defined(OS_LINUX)
pthread_setname_np(pthread_self(), name.c_str());
#elif defined(OS_WEB)
hex::unused(name);
std::ignore = name;
#elif defined(OS_MACOS)
pthread_setname_np(name.c_str());
#endif

View File

@@ -79,7 +79,7 @@ namespace hex::paths {
#elif defined(OS_MACOS)
return getDataPaths(includeSystemFolders);
#elif defined(OS_LINUX) || defined(OS_WEB)
hex::unused(includeSystemFolders);
std::ignore = includeSystemFolders;
return {xdg::ConfigHomeDir() / "imhex"};
#endif
}

View File

@@ -51,13 +51,11 @@ namespace hex::fs {
}
#if defined(OS_WINDOWS)
hex::unused(
ShellExecuteW(nullptr, L"open", filePath.c_str(), nullptr, nullptr, SW_SHOWNORMAL)
);
std::ignore = ShellExecuteW(nullptr, L"open", filePath.c_str(), nullptr, nullptr, SW_SHOWNORMAL);
#elif defined(OS_MACOS)
hex::unused(system(
std::ignore = system(
hex::format("open {}", wolv::util::toUTF8String(filePath)).c_str()
));
);
#elif defined(OS_LINUX)
executeCmd({"xdg-open", wolv::util::toUTF8String(filePath)});
#endif
@@ -73,9 +71,9 @@ namespace hex::fs {
auto args = fmt::format(L"\"{}\"", dirPath.c_str());
ShellExecuteW(nullptr, L"open", L"explorer.exe", args.c_str(), nullptr, SW_SHOWNORMAL);
#elif defined(OS_MACOS)
hex::unused(system(
std::ignore = system(
hex::format("open {}", wolv::util::toUTF8String(dirPath)).c_str()
));
);
#elif defined(OS_LINUX)
executeCmd({"xdg-open", wolv::util::toUTF8String(dirPath)});
#endif
@@ -91,12 +89,12 @@ namespace hex::fs {
auto args = fmt::format(L"/select,\"{}\"", selectedFilePath.c_str());
ShellExecuteW(nullptr, L"open", L"explorer.exe", args.c_str(), nullptr, SW_SHOWNORMAL);
#elif defined(OS_MACOS)
hex::unused(system(
std::ignore = system(
hex::format(
R"(osascript -e 'tell application "Finder" to reveal POSIX file "{}"')",
wolv::util::toUTF8String(selectedFilePath)
).c_str()
));
);
system(R"(osascript -e 'tell application "Finder" to activate')");
#elif defined(OS_LINUX)
// Fallback to only opening the folder for now

View File

@@ -41,17 +41,21 @@ namespace hex {
}
void HttpRequest::setProxyUrl(std::string proxy) {
hex::unused(proxy);
std::ignore = proxy;
}
void HttpRequest::setProxyState(bool state) {
hex::unused(state);
std::ignore = state;
}
void HttpRequest::checkProxyErrors() { }
int HttpRequest::progressCallback(void *contents, curl_off_t dlTotal, curl_off_t dlNow, curl_off_t ulTotal, curl_off_t ulNow) {
hex::unused(contents, dlTotal, dlNow, ulTotal, ulNow);
std::ignore = contents;
std::ignore = dlTotal;
std::ignore = dlNow;
std::ignore = ulTotal;
std::ignore = ulNow;
return -1;
}
}

View File

@@ -28,7 +28,9 @@ namespace hex {
void close() override { }
void readRaw(u64 offset, void *buffer, size_t size) override {
hex::unused(offset, buffer, size);
std::ignore = offset;
std::ignore = buffer;
std::ignore = size;
}
void writeRaw(u64 offset, const void *buffer, size_t size) override {
@@ -44,7 +46,7 @@ namespace hex {
}
void resizeRaw(u64 newSize) override {
hex::unused(newSize);
std::ignore = newSize;
}
void insertRaw(u64 offset, u64 size) override {

View File

@@ -336,13 +336,13 @@ namespace hex {
void startProgram(const std::string &command) {
#if defined(OS_WINDOWS)
hex::unused(system(hex::format("start {0}", command).c_str()));
std::ignore = system(hex::format("start {0}", command).c_str());
#elif defined(OS_MACOS)
hex::unused(system(hex::format("open {0}", command).c_str()));
std::ignore = system(hex::format("open {0}", command).c_str());
#elif defined(OS_LINUX)
executeCmd({"xdg-open", command});
#elif defined(OS_WEB)
hex::unused(command);
std::ignore = command;
#endif
}
@@ -839,7 +839,7 @@ namespace hex {
return dlopen(info.dli_fname, RTLD_LAZY);
#else
hex::unused(symbol);
std::ignore = symbol;
return nullptr;
#endif
}