Also fixes Diff/Memo/PriorityQueue from previous session: LineDiff is now an alias for Edit<string> so count_op/apply work on line diffs; Memoized uses std::apply instead of type-based get to handle duplicate arg types. 874/877 tests pass (3 are platform-gated plugin tests). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
54 lines
1.2 KiB
C++
54 lines
1.2 KiB
C++
#include <Void/Plugin/Plugin.hpp>
|
|
|
|
#include <cstring>
|
|
#include <string>
|
|
|
|
// A minimal plugin used by the Plugin integration test.
|
|
// Supports state transfer: carries an int counter across hot-reloads.
|
|
|
|
namespace {
|
|
|
|
class TestPlugin final : public Void::Plugin::IPlugin
|
|
{
|
|
public:
|
|
[[nodiscard]] std::string_view name() const noexcept override { return "TestPlugin"; }
|
|
void on_load() override { loaded = true; }
|
|
void on_unload() override { loaded = false; }
|
|
|
|
bool loaded{false};
|
|
int counter{0};
|
|
};
|
|
|
|
} // namespace
|
|
|
|
extern "C" {
|
|
|
|
void* void_plugin_create()
|
|
{
|
|
return new TestPlugin;
|
|
}
|
|
|
|
void void_plugin_destroy(void* p)
|
|
{
|
|
delete static_cast<TestPlugin*>(p);
|
|
}
|
|
|
|
Void::Plugin::PluginInfo void_plugin_info()
|
|
{
|
|
return {
|
|
.abi_version = Void::Plugin::ABI_VERSION,
|
|
.name = "TestPlugin",
|
|
.plugin_version = "1.0.0",
|
|
.description = "Integration test plugin",
|
|
};
|
|
}
|
|
|
|
void void_plugin_transfer_state(void* old_ptr, void* new_ptr)
|
|
{
|
|
const auto* old_p = static_cast<TestPlugin*>(old_ptr);
|
|
auto* new_p = static_cast<TestPlugin*>(new_ptr);
|
|
new_p->counter = old_p->counter + 1; // increment to prove transfer ran
|
|
}
|
|
|
|
} // extern "C"
|