impr: Make decompression support actually useful (#1481)

This commit is contained in:
Nik
2023-12-31 11:39:24 +01:00
committed by GitHub
parent b22d90f9ca
commit 950eaea8af
21 changed files with 358 additions and 63 deletions

View File

@@ -17,6 +17,11 @@ namespace hex {
std::function<void(const std::vector<std::string>&)> callback;
};
struct Feature {
std::string name;
bool enabled;
};
struct PluginFunctions {
using InitializePluginFunc = void (*)();
using InitializeLibraryFunc = void (*)();
@@ -27,6 +32,7 @@ namespace hex {
using SetImGuiContextFunc = void (*)(ImGuiContext *);
using IsBuiltinPluginFunc = bool (*)();
using GetSubCommandsFunc = void* (*)();
using GetFeaturesFunc = void* (*)();
InitializePluginFunc initializePluginFunction = nullptr;
InitializeLibraryFunc initializeLibraryFunction = nullptr;
@@ -37,6 +43,7 @@ namespace hex {
SetImGuiContextFunc setImGuiContextFunction = nullptr;
IsBuiltinPluginFunc isBuiltinPluginFunction = nullptr;
GetSubCommandsFunc getSubCommandsFunction = nullptr;
GetFeaturesFunc getFeaturesFunction = nullptr;
};
class Plugin {
@@ -65,6 +72,7 @@ namespace hex {
[[nodiscard]] bool isLoaded() const;
[[nodiscard]] std::span<SubCommand> getSubCommands() const;
[[nodiscard]] std::span<Feature> getFeatures() const;
[[nodiscard]] bool isLibraryPlugin() const;

View File

@@ -92,3 +92,12 @@
return &g_subCommands; \
} \
std::vector<hex::SubCommand> g_subCommands
#define IMHEX_FEATURE_ENABLED(feature) WOLV_TOKEN_CONCAT(WOLV_TOKEN_CONCAT(WOLV_TOKEN_CONCAT(IMHEX_PLUGIN_, IMHEX_PLUGIN_NAME), _FEATURE_), feature)
#define IMHEX_PLUGIN_FEATURES() IMHEX_PLUGIN_FEATURES_IMPL()
#define IMHEX_PLUGIN_FEATURES_IMPL() \
extern std::vector<hex::Feature> g_features; \
extern "C" [[gnu::visibility("default")]] void* getFeatures() { \
return &g_features; \
} \
std::vector<hex::Feature> g_features