impr: Move plugin unload logging to plugins
This commit is contained in:
parent
874bac7de2
commit
301e95b708
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include <wolv/utils/string.hpp>
|
#include <wolv/utils/string.hpp>
|
||||||
#include <wolv/utils/preproc.hpp>
|
#include <wolv/utils/preproc.hpp>
|
||||||
|
#include <wolv/utils/guards.hpp>
|
||||||
|
|
||||||
#if defined (IMHEX_STATIC_LINK_PLUGINS)
|
#if defined (IMHEX_STATIC_LINK_PLUGINS)
|
||||||
#define IMHEX_PLUGIN_VISIBILITY_PREFIX static
|
#define IMHEX_PLUGIN_VISIBILITY_PREFIX static
|
||||||
@ -23,57 +24,59 @@
|
|||||||
* Name, Author and Description will be displayed in the in the plugin list on the Welcome screen.
|
* Name, Author and Description will be displayed in the in the plugin list on the Welcome screen.
|
||||||
*/
|
*/
|
||||||
#define IMHEX_PLUGIN_SETUP(name, author, description) IMHEX_PLUGIN_SETUP_IMPL(name, author, description)
|
#define IMHEX_PLUGIN_SETUP(name, author, description) IMHEX_PLUGIN_SETUP_IMPL(name, author, description)
|
||||||
#define IMHEX_LIBRARY_SETUP() IMHEX_LIBRARY_SETUP_IMPL()
|
#define IMHEX_LIBRARY_SETUP(name) IMHEX_LIBRARY_SETUP_IMPL(name)
|
||||||
|
|
||||||
#define IMHEX_LIBRARY_SETUP_IMPL() \
|
#define IMHEX_LIBRARY_SETUP_IMPL(name) \
|
||||||
IMHEX_PLUGIN_VISIBILITY_PREFIX void initializeLibrary(); \
|
namespace { static struct EXIT_HANDLER { ~EXIT_HANDLER() { hex::log::info("Unloading library '{}'", name); } } HANDLER; } \
|
||||||
static auto WOLV_TOKEN_CONCAT(libraryInitializer_, IMHEX_PLUGIN_NAME) = [] { \
|
IMHEX_PLUGIN_VISIBILITY_PREFIX void initializeLibrary(); \
|
||||||
initializeLibrary(); \
|
static auto WOLV_TOKEN_CONCAT(libraryInitializer_, IMHEX_PLUGIN_NAME) = [] { \
|
||||||
hex::log::info("Library plugin '{}' initialized successfully", WOLV_STRINGIFY(IMHEX_PLUGIN_NAME)); \
|
initializeLibrary(); \
|
||||||
return 0; \
|
hex::log::info("Library plugin '{}' initialized successfully", WOLV_STRINGIFY(IMHEX_PLUGIN_NAME)); \
|
||||||
}(); \
|
return 0; \
|
||||||
IMHEX_PLUGIN_VISIBILITY_PREFIX void setImGuiContext(ImGuiContext *ctx) { \
|
}(); \
|
||||||
ImGui::SetCurrentContext(ctx); \
|
IMHEX_PLUGIN_VISIBILITY_PREFIX void setImGuiContext(ImGuiContext *ctx) { \
|
||||||
GImGui = ctx; \
|
ImGui::SetCurrentContext(ctx); \
|
||||||
} \
|
GImGui = ctx; \
|
||||||
extern "C" [[gnu::visibility("default")]] void WOLV_TOKEN_CONCAT(forceLinkPlugin_, IMHEX_PLUGIN_NAME)() { \
|
} \
|
||||||
hex::PluginManager::addPlugin(hex::PluginFunctions { \
|
extern "C" [[gnu::visibility("default")]] void WOLV_TOKEN_CONCAT(forceLinkPlugin_, IMHEX_PLUGIN_NAME)() { \
|
||||||
nullptr, \
|
hex::PluginManager::addPlugin(hex::PluginFunctions { \
|
||||||
initializeLibrary, \
|
nullptr, \
|
||||||
nullptr, \
|
initializeLibrary, \
|
||||||
nullptr, \
|
nullptr, \
|
||||||
nullptr, \
|
nullptr, \
|
||||||
nullptr, \
|
nullptr, \
|
||||||
setImGuiContext, \
|
nullptr, \
|
||||||
nullptr, \
|
setImGuiContext, \
|
||||||
nullptr \
|
nullptr, \
|
||||||
}); \
|
nullptr \
|
||||||
} \
|
}); \
|
||||||
|
} \
|
||||||
IMHEX_PLUGIN_VISIBILITY_PREFIX void initializeLibrary()
|
IMHEX_PLUGIN_VISIBILITY_PREFIX void initializeLibrary()
|
||||||
|
|
||||||
#define IMHEX_PLUGIN_SETUP_IMPL(name, author, description) \
|
#define IMHEX_PLUGIN_SETUP_IMPL(name, author, description) \
|
||||||
IMHEX_PLUGIN_VISIBILITY_PREFIX const char *getPluginName() { return name; } \
|
namespace { static struct EXIT_HANDLER { ~EXIT_HANDLER() { hex::log::info("Unloading plugin '{}'", name); } } HANDLER; } \
|
||||||
IMHEX_PLUGIN_VISIBILITY_PREFIX const char *getPluginAuthor() { return author; } \
|
IMHEX_PLUGIN_VISIBILITY_PREFIX const char *getPluginName() { return name; } \
|
||||||
IMHEX_PLUGIN_VISIBILITY_PREFIX const char *getPluginDescription() { return description; } \
|
IMHEX_PLUGIN_VISIBILITY_PREFIX const char *getPluginAuthor() { return author; } \
|
||||||
IMHEX_PLUGIN_VISIBILITY_PREFIX const char *getCompatibleVersion() { return IMHEX_VERSION; } \
|
IMHEX_PLUGIN_VISIBILITY_PREFIX const char *getPluginDescription() { return description; } \
|
||||||
IMHEX_PLUGIN_VISIBILITY_PREFIX void setImGuiContext(ImGuiContext *ctx) { \
|
IMHEX_PLUGIN_VISIBILITY_PREFIX const char *getCompatibleVersion() { return IMHEX_VERSION; } \
|
||||||
ImGui::SetCurrentContext(ctx); \
|
IMHEX_PLUGIN_VISIBILITY_PREFIX void setImGuiContext(ImGuiContext *ctx) { \
|
||||||
GImGui = ctx; \
|
ImGui::SetCurrentContext(ctx); \
|
||||||
} \
|
GImGui = ctx; \
|
||||||
IMHEX_PLUGIN_VISIBILITY_PREFIX void initializePlugin(); \
|
} \
|
||||||
extern "C" [[gnu::visibility("default")]] void WOLV_TOKEN_CONCAT(forceLinkPlugin_, IMHEX_PLUGIN_NAME)() { \
|
IMHEX_PLUGIN_VISIBILITY_PREFIX void initializePlugin(); \
|
||||||
hex::PluginManager::addPlugin(hex::PluginFunctions { \
|
extern "C" [[gnu::visibility("default")]] void WOLV_TOKEN_CONCAT(forceLinkPlugin_, IMHEX_PLUGIN_NAME)() { \
|
||||||
initializePlugin, \
|
hex::PluginManager::addPlugin(hex::PluginFunctions { \
|
||||||
nullptr, \
|
initializePlugin, \
|
||||||
getPluginName, \
|
nullptr, \
|
||||||
getPluginAuthor, \
|
getPluginName, \
|
||||||
getPluginDescription, \
|
getPluginAuthor, \
|
||||||
getCompatibleVersion, \
|
getPluginDescription, \
|
||||||
setImGuiContext, \
|
getCompatibleVersion, \
|
||||||
nullptr, \
|
setImGuiContext, \
|
||||||
nullptr \
|
nullptr, \
|
||||||
}); \
|
nullptr \
|
||||||
} \
|
}); \
|
||||||
|
} \
|
||||||
IMHEX_PLUGIN_VISIBILITY_PREFIX void initializePlugin()
|
IMHEX_PLUGIN_VISIBILITY_PREFIX void initializePlugin()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -260,11 +260,6 @@ namespace hex {
|
|||||||
auto &plugins = getPlugins();
|
auto &plugins = getPlugins();
|
||||||
const auto pluginCount = plugins.size();
|
const auto pluginCount = plugins.size();
|
||||||
for (size_t i = 0; i < pluginCount; i++) {
|
for (size_t i = 0; i < pluginCount; i++) {
|
||||||
auto &plugin = plugins[pluginCount - 1 - i];
|
|
||||||
if (plugin.isLoaded()) {
|
|
||||||
log::info("Unloading plugin '{}'", plugin.getPluginName());
|
|
||||||
}
|
|
||||||
|
|
||||||
plugins.pop_back();
|
plugins.pop_back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include <ui/pattern_drawer.hpp>
|
#include <ui/pattern_drawer.hpp>
|
||||||
#include <ui/widgets.hpp>
|
#include <ui/widgets.hpp>
|
||||||
|
|
||||||
IMHEX_LIBRARY_SETUP() {
|
IMHEX_LIBRARY_SETUP("UI") {
|
||||||
hex::log::debug("Using romfs: '{}'", romfs::name());
|
hex::log::debug("Using romfs: '{}'", romfs::name());
|
||||||
for (auto &path : romfs::list("lang"))
|
for (auto &path : romfs::list("lang"))
|
||||||
hex::ContentRegistry::Language::addLocalization(nlohmann::json::parse(romfs::get(path).string()));
|
hex::ContentRegistry::Language::addLocalization(nlohmann::json::parse(romfs::get(path).string()));
|
||||||
|
Loading…
Reference in New Issue
Block a user