1
0
mirror of synced 2024-11-30 18:34:29 +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")
endif()
if (UNIX)
if (UNIX AND CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(IMHEX_COMMON_FLAGS "${IMHEX_COMMON_FLAGS} -rdynamic")
endif()

View File

@ -63,6 +63,9 @@ namespace hex {
[[nodiscard]] std::string to_string(u128 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::optional<u8> parseBinaryString(const std::string &string);
[[nodiscard]] std::string toByteString(u64 bytes);

View File

@ -43,11 +43,11 @@ namespace hex {
return this->m_patches.rbegin()->first;
}
void resizeRaw(size_t newSize) override {
void resizeRaw(u64 newSize) override {
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;
for (auto &[address, value] : this->m_patches) {
@ -61,7 +61,7 @@ namespace hex {
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;
for (auto &[address, value] : this->m_patches) {

View File

@ -71,6 +71,20 @@ namespace hex {
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) {
if (string.empty())
return { };

View File

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

View File

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

View File

@ -20,9 +20,9 @@ namespace hex::plugin::builtin {
[[nodiscard]] bool isResizable() const override;
[[nodiscard]] bool isSavable() const override;
void resizeRaw(size_t newSize) override;
void insertRaw(u64 offset, size_t size) override;
void removeRaw(u64 offset, size_t size) override;
void resizeRaw(u64 newSize) override;
void insertRaw(u64 offset, u64 size) override;
void removeRaw(u64 offset, u64 size) override;
void readRaw(u64 offset, 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;
[[nodiscard]] u64 getActualSize() const override { return this->m_data.size(); }
void resizeRaw(size_t newSize) override;
void insertRaw(u64 offset, size_t size) override;
void removeRaw(u64 offset, size_t size) override;
void resizeRaw(u64 newSize) override;
void insertRaw(u64 offset, u64 size) override;
void removeRaw(u64 offset, u64 size) override;
void save() override;

View File

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

View File

@ -82,7 +82,7 @@ namespace hex::plugin::builtin {
Provider::saveAs(path);
}
void FileProvider::resizeRaw(size_t newSize) {
void FileProvider::resizeRaw(u64 newSize) {
this->close();
{
@ -94,7 +94,7 @@ namespace hex::plugin::builtin {
(void)this->open();
}
void FileProvider::insertRaw(u64 offset, size_t size) {
void FileProvider::insertRaw(u64 offset, u64 size) {
auto oldSize = this->getActualSize();
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)
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);
}
void MemoryFileProvider::insertRaw(u64 offset, size_t size) {
void MemoryFileProvider::insertRaw(u64 offset, u64 size) {
auto oldSize = this->getActualSize();
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();
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()));
if (ImGui::IsItemClicked()) {
hex::openWebpage(ImHexApiURL + hex::format("/info/{}/link",
ImHexApi::System::getOSName() | std::views::transform([](char c) { return std::tolower(c); })
));
hex::openWebpage(ImHexApiURL + hex::format("/info/{}/link", hex::toLower(ImHexApi::System::getOSName())));
}
}
ImGuiExt::EndSubWindow();
@ -644,10 +642,7 @@ namespace hex::plugin::builtin {
if (!s_infoBannerTexture.isValid()) {
TaskManager::createBackgroundTask("Load banner", [](auto&) {
HttpRequest request("GET",
ImHexApiURL + hex::format("/info/{}/image",
ImHexApi::System::getOSName() | std::views::transform([](char c) { return std::tolower(c); })
)
);
ImHexApiURL + hex::format("/info/{}/image", hex::toLower(ImHexApi::System::getOSName())));
auto response = request.downloadFile().get();