105 lines
2.8 KiB
C++
105 lines
2.8 KiB
C++
#include <echoion/api/module/LegacyModuleAbi.hpp>
|
|
|
|
#include "ModuleContracts.hpp"
|
|
|
|
#include <iterator>
|
|
#include <memory>
|
|
#include <string_view>
|
|
|
|
namespace Echoion::CoreModule
|
|
{
|
|
namespace
|
|
{
|
|
class LifecycleModule final : public Void::Plugin::IModule
|
|
{
|
|
public:
|
|
|
|
[[nodiscard]] std::string_view name() const noexcept override
|
|
{
|
|
return "EchoionCore";
|
|
}
|
|
};
|
|
|
|
std::unique_ptr<Void::Plugin::IModule> createCoreModule()
|
|
{
|
|
return std::make_unique<LifecycleModule>();
|
|
}
|
|
} // namespace
|
|
|
|
const Void::Plugin::ModuleDescriptor& coreModuleDescriptor()
|
|
{
|
|
static const Void::Plugin::ModuleDescriptor descriptor{
|
|
.module_id = "EchoionCore",
|
|
.component_version =
|
|
{
|
|
.major = ECHOION_COMPONENT_VERSION_MAJOR,
|
|
.minor = ECHOION_COMPONENT_VERSION_MINOR,
|
|
.patch = ECHOION_COMPONENT_VERSION_PATCH,
|
|
.pre_release = {},
|
|
.build = {},
|
|
},
|
|
.abi_hash = coreAbiHash,
|
|
.abi_contract = Void::Json::object({
|
|
{"schemaVersion", 1},
|
|
{"contractId", "echoion.module.core"},
|
|
{"descriptor", "echoion_module_descriptor_v1"},
|
|
}),
|
|
.dependencies =
|
|
{
|
|
{
|
|
.module_id = "EchoionApi",
|
|
.version_range = "^2.0.0",
|
|
.abi_hash = apiAbiHash,
|
|
},
|
|
},
|
|
.activation_policy = Void::Plugin::ActivationPolicy::Reloadable,
|
|
.create = createCoreModule,
|
|
};
|
|
return descriptor;
|
|
}
|
|
|
|
const echoion_module_descriptor_v1& coreModuleAbiDescriptor()
|
|
{
|
|
using Bridge = Api::Module::LegacyModuleAbi<createCoreModule>;
|
|
static const echoion_module_dependency_v1 dependencies[]{
|
|
{
|
|
.struct_size = sizeof(echoion_module_dependency_v1),
|
|
.component_id = Api::Module::Detail::stringView("EchoionApi"),
|
|
.version_range =
|
|
Api::Module::Detail::stringView(">=2.0.0 <3.0.0"),
|
|
.abi_hash = Api::Module::Detail::stringView(apiAbiHash),
|
|
.optional = 0,
|
|
.reserved_bytes = {},
|
|
},
|
|
};
|
|
static const echoion_module_descriptor_v1 descriptor{
|
|
.struct_size = sizeof(echoion_module_descriptor_v1),
|
|
.abi_version = ECHOION_MODULE_ABI_VERSION,
|
|
.component_id = Api::Module::Detail::stringView("EchoionCore"),
|
|
.version_major = ECHOION_COMPONENT_VERSION_MAJOR,
|
|
.version_minor = ECHOION_COMPONENT_VERSION_MINOR,
|
|
.version_patch = ECHOION_COMPONENT_VERSION_PATCH,
|
|
.version_prerelease = {},
|
|
.abi_hash = Api::Module::Detail::stringView(coreAbiHash),
|
|
.dependencies = dependencies,
|
|
.dependency_count = std::size(dependencies),
|
|
.activation_policy = ECHOION_ACTIVATION_RELOADABLE_V1,
|
|
.api = &Bridge::api,
|
|
.reserved = {},
|
|
};
|
|
return descriptor;
|
|
}
|
|
} // namespace Echoion::CoreModule
|
|
|
|
extern "C" ECHOION_MODULE_EXPORT const Void::Plugin::ModuleDescriptor*
|
|
echoion_module_query()
|
|
{
|
|
return &Echoion::CoreModule::coreModuleDescriptor();
|
|
}
|
|
|
|
extern "C" ECHOION_MODULE_ABI_EXPORT const echoion_module_descriptor_v1*
|
|
echoion_module_abi_query()
|
|
{
|
|
return &Echoion::CoreModule::coreModuleAbiDescriptor();
|
|
}
|