fix: Subcommands not working at all on Linux
This commit is contained in:
parent
3149183450
commit
e5a793e8de
@ -24,11 +24,6 @@ namespace hex {
|
|||||||
std::function<void(const std::vector<std::string>&)> callback;
|
std::function<void(const std::vector<std::string>&)> callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SubCommandList {
|
|
||||||
hex::SubCommand *subCommands;
|
|
||||||
size_t size;
|
|
||||||
};
|
|
||||||
|
|
||||||
class Plugin {
|
class Plugin {
|
||||||
public:
|
public:
|
||||||
explicit Plugin(const std::fs::path &path);
|
explicit Plugin(const std::fs::path &path);
|
||||||
@ -58,7 +53,7 @@ namespace hex {
|
|||||||
using GetCompatibleVersionFunc = const char *(*)();
|
using GetCompatibleVersionFunc = const char *(*)();
|
||||||
using SetImGuiContextFunc = void (*)(ImGuiContext *);
|
using SetImGuiContextFunc = void (*)(ImGuiContext *);
|
||||||
using IsBuiltinPluginFunc = bool (*)();
|
using IsBuiltinPluginFunc = bool (*)();
|
||||||
using GetSubCommandsFunc = SubCommandList* (*)();
|
using GetSubCommandsFunc = void* (*)();
|
||||||
|
|
||||||
#if defined(OS_WINDOWS)
|
#if defined(OS_WINDOWS)
|
||||||
HMODULE m_handle = nullptr;
|
HMODULE m_handle = nullptr;
|
||||||
|
@ -39,10 +39,7 @@
|
|||||||
|
|
||||||
#define IMHEX_PLUGIN_SUBCOMMANDS_IMPL() \
|
#define IMHEX_PLUGIN_SUBCOMMANDS_IMPL() \
|
||||||
extern std::vector<hex::SubCommand> g_subCommands; \
|
extern std::vector<hex::SubCommand> g_subCommands; \
|
||||||
extern "C" [[gnu::visibility("default")]] hex::SubCommandList getSubCommands() { \
|
extern "C" [[gnu::visibility("default")]] void* getSubCommands() { \
|
||||||
return hex::SubCommandList { \
|
return &g_subCommands; \
|
||||||
g_subCommands.data(), \
|
|
||||||
g_subCommands.size() \
|
|
||||||
}; \
|
|
||||||
} \
|
} \
|
||||||
std::vector<hex::SubCommand> g_subCommands
|
std::vector<hex::SubCommand> g_subCommands
|
||||||
|
@ -155,7 +155,7 @@ namespace hex {
|
|||||||
std::span<SubCommand> Plugin::getSubCommands() const {
|
std::span<SubCommand> Plugin::getSubCommands() const {
|
||||||
if (this->m_getSubCommandsFunction != nullptr) {
|
if (this->m_getSubCommandsFunction != nullptr) {
|
||||||
auto result = this->m_getSubCommandsFunction();
|
auto result = this->m_getSubCommandsFunction();
|
||||||
return { result->subCommands, result->size };
|
return *reinterpret_cast<std::vector<SubCommand>*>(result);
|
||||||
} else
|
} else
|
||||||
return { };
|
return { };
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user