From e5a793e8de7ee94da9687140d0105bf026778160 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Fri, 21 Jul 2023 14:12:08 +0200 Subject: [PATCH] fix: Subcommands not working at all on Linux --- lib/libimhex/include/hex/api/plugin_manager.hpp | 7 +------ lib/libimhex/include/hex/plugin.hpp | 7 ++----- lib/libimhex/source/api/plugin_manager.cpp | 2 +- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/lib/libimhex/include/hex/api/plugin_manager.hpp b/lib/libimhex/include/hex/api/plugin_manager.hpp index 087d83202..9fceacb8a 100644 --- a/lib/libimhex/include/hex/api/plugin_manager.hpp +++ b/lib/libimhex/include/hex/api/plugin_manager.hpp @@ -24,11 +24,6 @@ namespace hex { std::function&)> callback; }; - struct SubCommandList { - hex::SubCommand *subCommands; - size_t size; - }; - class Plugin { public: explicit Plugin(const std::fs::path &path); @@ -58,7 +53,7 @@ namespace hex { using GetCompatibleVersionFunc = const char *(*)(); using SetImGuiContextFunc = void (*)(ImGuiContext *); using IsBuiltinPluginFunc = bool (*)(); - using GetSubCommandsFunc = SubCommandList* (*)(); + using GetSubCommandsFunc = void* (*)(); #if defined(OS_WINDOWS) HMODULE m_handle = nullptr; diff --git a/lib/libimhex/include/hex/plugin.hpp b/lib/libimhex/include/hex/plugin.hpp index b60410ec1..346498d1a 100644 --- a/lib/libimhex/include/hex/plugin.hpp +++ b/lib/libimhex/include/hex/plugin.hpp @@ -39,10 +39,7 @@ #define IMHEX_PLUGIN_SUBCOMMANDS_IMPL() \ extern std::vector g_subCommands; \ - extern "C" [[gnu::visibility("default")]] hex::SubCommandList getSubCommands() { \ - return hex::SubCommandList { \ - g_subCommands.data(), \ - g_subCommands.size() \ - }; \ + extern "C" [[gnu::visibility("default")]] void* getSubCommands() { \ + return &g_subCommands; \ } \ std::vector g_subCommands diff --git a/lib/libimhex/source/api/plugin_manager.cpp b/lib/libimhex/source/api/plugin_manager.cpp index 2dd48aff1..5d917b0c1 100644 --- a/lib/libimhex/source/api/plugin_manager.cpp +++ b/lib/libimhex/source/api/plugin_manager.cpp @@ -155,7 +155,7 @@ namespace hex { std::span Plugin::getSubCommands() const { if (this->m_getSubCommandsFunction != nullptr) { auto result = this->m_getSubCommandsFunction(); - return { result->subCommands, result->size }; + return *reinterpret_cast*>(result); } else return { }; }