1
0
mirror of synced 2024-12-01 02:37:18 +01:00

fix: Various build errors

This commit is contained in:
WerWolv 2023-12-08 16:22:36 +01:00
parent 48bc0985d9
commit 878f45dd80
12 changed files with 41 additions and 29 deletions

View File

@ -445,7 +445,7 @@ macro(setupCompilerFlags target)
set(IMHEX_COMMON_FLAGS "${IMHEX_COMMON_FLAGS} -Wall -Wextra -Wpedantic -Werror") set(IMHEX_COMMON_FLAGS "${IMHEX_COMMON_FLAGS} -Wall -Wextra -Wpedantic -Werror")
endif() endif()
if (UNIX) if (UNIX AND CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(IMHEX_COMMON_FLAGS "${IMHEX_COMMON_FLAGS} -rdynamic") set(IMHEX_COMMON_FLAGS "${IMHEX_COMMON_FLAGS} -rdynamic")
endif() endif()

View File

@ -63,6 +63,9 @@ namespace hex {
[[nodiscard]] std::string to_string(u128 value); [[nodiscard]] std::string to_string(u128 value);
[[nodiscard]] std::string to_string(i128 value); [[nodiscard]] std::string to_string(i128 value);
[[nodiscard]] std::string toLower(std::string string);
[[nodiscard]] std::string toUpper(std::string string);
[[nodiscard]] std::vector<u8> parseHexString(std::string string); [[nodiscard]] std::vector<u8> parseHexString(std::string string);
[[nodiscard]] std::optional<u8> parseBinaryString(const std::string &string); [[nodiscard]] std::optional<u8> parseBinaryString(const std::string &string);
[[nodiscard]] std::string toByteString(u64 bytes); [[nodiscard]] std::string toByteString(u64 bytes);

View File

@ -43,11 +43,11 @@ namespace hex {
return this->m_patches.rbegin()->first; return this->m_patches.rbegin()->first;
} }
void resizeRaw(size_t newSize) override { void resizeRaw(u64 newSize) override {
hex::unused(newSize); hex::unused(newSize);
} }
void insertRaw(u64 offset, size_t size) override { void insertRaw(u64 offset, u64 size) override {
std::vector<std::pair<u64, u8>> patchesToMove; std::vector<std::pair<u64, u8>> patchesToMove;
for (auto &[address, value] : this->m_patches) { for (auto &[address, value] : this->m_patches) {
@ -61,7 +61,7 @@ namespace hex {
this->m_patches.insert({ address + size, value }); this->m_patches.insert({ address + size, value });
} }
void removeRaw(u64 offset, size_t size) override { void removeRaw(u64 offset, u64 size) override {
std::vector<std::pair<u64, u8>> patchesToMove; std::vector<std::pair<u64, u8>> patchesToMove;
for (auto &[address, value] : this->m_patches) { for (auto &[address, value] : this->m_patches) {

View File

@ -71,6 +71,20 @@ namespace hex {
return { data + index + 1 }; return { data + index + 1 };
} }
std::string toLower(std::string string) {
for (char &c : string)
c = std::tolower(c);
return string;
}
std::string toUpper(std::string string) {
for (char &c : string)
c = std::toupper(c);
return string;
}
std::vector<u8> parseHexString(std::string string) { std::vector<u8> parseHexString(std::string string) {
if (string.empty()) if (string.empty())
return { }; return { };

View File

@ -170,8 +170,8 @@ namespace {
emscripten_set_main_loop_arg([](void *arg) { emscripten_set_main_loop_arg([](void *arg) {
auto splashWindow = reinterpret_cast<WindowSplash*>(arg); auto splashWindow = reinterpret_cast<WindowSplash*>(arg);
FrameResult res = splashWindow->fullFrame(); FrameResult frameResult = splashWindow->fullFrame();
if (res == FrameResult::success) { if (frameResult == FrameResult::Success) {
handleFileOpenRequest(); handleFileOpenRequest();
// Clean up everything after the main window is closed // Clean up everything after the main window is closed

View File

@ -34,7 +34,7 @@ EM_JS(bool, isDarkModeEnabled, (), {
EMSCRIPTEN_KEEPALIVE EMSCRIPTEN_KEEPALIVE
extern "C" void handleThemeChange() { extern "C" void handleThemeChange() {
hex::hex::EventOSThemeChanged::post(); hex::EventOSThemeChanged::post();
} }
namespace hex { namespace hex {

View File

@ -20,9 +20,9 @@ namespace hex::plugin::builtin {
[[nodiscard]] bool isResizable() const override; [[nodiscard]] bool isResizable() const override;
[[nodiscard]] bool isSavable() const override; [[nodiscard]] bool isSavable() const override;
void resizeRaw(size_t newSize) override; void resizeRaw(u64 newSize) override;
void insertRaw(u64 offset, size_t size) override; void insertRaw(u64 offset, u64 size) override;
void removeRaw(u64 offset, size_t size) override; void removeRaw(u64 offset, u64 size) override;
void readRaw(u64 offset, void *buffer, size_t size) override; void readRaw(u64 offset, void *buffer, size_t size) override;
void writeRaw(u64 offset, const void *buffer, size_t size) override; void writeRaw(u64 offset, const void *buffer, size_t size) override;

View File

@ -23,9 +23,9 @@ namespace hex::plugin::builtin {
void writeRaw(u64 offset, const void *buffer, size_t size) override; void writeRaw(u64 offset, const void *buffer, size_t size) override;
[[nodiscard]] u64 getActualSize() const override { return this->m_data.size(); } [[nodiscard]] u64 getActualSize() const override { return this->m_data.size(); }
void resizeRaw(size_t newSize) override; void resizeRaw(u64 newSize) override;
void insertRaw(u64 offset, size_t size) override; void insertRaw(u64 offset, u64 size) override;
void removeRaw(u64 offset, size_t size) override; void removeRaw(u64 offset, u64 size) override;
void save() override; void save() override;

View File

@ -53,10 +53,10 @@ namespace hex::plugin::builtin {
[[nodiscard]] bool open() override { return true; } [[nodiscard]] bool open() override { return true; }
void close() override { } void close() override { }
void resizeRaw(size_t newSize) override { void resizeRaw(u64 newSize) override {
this->m_size = newSize; this->m_size = newSize;
} }
void insertRaw(u64 offset, size_t size) override { void insertRaw(u64 offset, u64 size) override {
if (this->m_provider == nullptr) if (this->m_provider == nullptr)
return; return;
@ -64,7 +64,7 @@ namespace hex::plugin::builtin {
this->m_provider->insert(offset + this->m_startAddress, size); this->m_provider->insert(offset + this->m_startAddress, size);
} }
void removeRaw(u64 offset, size_t size) override { void removeRaw(u64 offset, u64 size) override {
if (this->m_provider == nullptr) if (this->m_provider == nullptr)
return; return;

View File

@ -82,7 +82,7 @@ namespace hex::plugin::builtin {
Provider::saveAs(path); Provider::saveAs(path);
} }
void FileProvider::resizeRaw(size_t newSize) { void FileProvider::resizeRaw(u64 newSize) {
this->close(); this->close();
{ {
@ -94,7 +94,7 @@ namespace hex::plugin::builtin {
(void)this->open(); (void)this->open();
} }
void FileProvider::insertRaw(u64 offset, size_t size) { void FileProvider::insertRaw(u64 offset, u64 size) {
auto oldSize = this->getActualSize(); auto oldSize = this->getActualSize();
this->resizeRaw(oldSize + size); this->resizeRaw(oldSize + size);
@ -113,7 +113,7 @@ namespace hex::plugin::builtin {
} }
} }
void FileProvider::removeRaw(u64 offset, size_t size) { void FileProvider::removeRaw(u64 offset, u64 size) {
if (offset > this->getActualSize() || size == 0) if (offset > this->getActualSize() || size == 0)
return; return;

View File

@ -66,11 +66,11 @@ namespace hex::plugin::builtin {
}); });
} }
void MemoryFileProvider::resizeRaw(size_t newSize) { void MemoryFileProvider::resizeRaw(u64 newSize) {
this->m_data.resize(newSize); this->m_data.resize(newSize);
} }
void MemoryFileProvider::insertRaw(u64 offset, size_t size) { void MemoryFileProvider::insertRaw(u64 offset, u64 size) {
auto oldSize = this->getActualSize(); auto oldSize = this->getActualSize();
this->resizeRaw(oldSize + size); this->resizeRaw(oldSize + size);
@ -89,7 +89,7 @@ namespace hex::plugin::builtin {
} }
} }
void MemoryFileProvider::removeRaw(u64 offset, size_t size) { void MemoryFileProvider::removeRaw(u64 offset, u64 size) {
auto oldSize = this->getActualSize(); auto oldSize = this->getActualSize();
std::vector<u8> buffer(0x1000); std::vector<u8> buffer(0x1000);

View File

@ -350,9 +350,7 @@ namespace hex::plugin::builtin {
ImGui::Image(s_infoBannerTexture, ImVec2(width, width / s_infoBannerTexture.getAspectRatio())); ImGui::Image(s_infoBannerTexture, ImVec2(width, width / s_infoBannerTexture.getAspectRatio()));
if (ImGui::IsItemClicked()) { if (ImGui::IsItemClicked()) {
hex::openWebpage(ImHexApiURL + hex::format("/info/{}/link", hex::openWebpage(ImHexApiURL + hex::format("/info/{}/link", hex::toLower(ImHexApi::System::getOSName())));
ImHexApi::System::getOSName() | std::views::transform([](char c) { return std::tolower(c); })
));
} }
} }
ImGuiExt::EndSubWindow(); ImGuiExt::EndSubWindow();
@ -644,10 +642,7 @@ namespace hex::plugin::builtin {
if (!s_infoBannerTexture.isValid()) { if (!s_infoBannerTexture.isValid()) {
TaskManager::createBackgroundTask("Load banner", [](auto&) { TaskManager::createBackgroundTask("Load banner", [](auto&) {
HttpRequest request("GET", HttpRequest request("GET",
ImHexApiURL + hex::format("/info/{}/image", ImHexApiURL + hex::format("/info/{}/image", hex::toLower(ImHexApi::System::getOSName())));
ImHexApi::System::getOSName() | std::views::transform([](char c) { return std::tolower(c); })
)
);
auto response = request.downloadFile().get(); auto response = request.downloadFile().get();