### ABI 1.5 - VDE_PLUGIN_ABI_MINOR 5;VdePluginKind OPTIMIZER=9/IO_BATCH=10; VdeOptimizer*/VdeIoBatch* 结构(JSON 输入输出回调);VdePluginRegistration 尾追加两指针 56→72B(offset 56/64), 旧 1.0–1.4 按 struct_size 安全加载、新 kind 结构不足拒绝; - PluginManager:OptimizerInfo/IoBatchInfo、optimizers()/invoke_optimizer、io_batches()/invoke_io_batch、 校验/失败隔离/卸载清理(IO_BATCH 支持 PARTIAL); - sample_optimizer/sample_io_batch(mock);ABI 矩阵 1.0–1.5 accepted=6+2.0 rejected;--abi/--check 适配; - test_plugin_abi15 6/6 + fixtures;既有 ABI 1.4 断言适配; - 文档 plugin-development §16/§17、plugin-distribution ABI 矩阵、plugin-ecosystem-handoff/ecosystem、plugin-ci-template; ### WP/claim - WP-P4-11 交付并移入 Delivered;claim Released 归档;统计 42=31 Delivered+11 Candidate; - claim check 修正:Released claim 可指向 Delivered WP(仅 Active 需要释放); ### 工程 - 版本 1.0.83;全量构建 0 error(421 targets);全量 ctest 7576 注册、7481/7481 PASS(0 failed,25 skipped,302.66s); - 收录 1.0.82 独立验证报告 80。
108 lines
4.0 KiB
C++
108 lines
4.0 KiB
C++
// tests/plugin/fixtures/abi15_plugin.cpp
|
||
// ABI 1.5 兼容性夹具:
|
||
// - FORMAT56:ABI 1.4 旧插件注册结构 56B(kind=format),宿主 1.5 应可加载;
|
||
// - OPTIMIZER56 / IOBATCH56:清单声明 ABI 1.5 新 kind,但注册结构仍为 56B(缺新指针),
|
||
// 宿主应按 struct_size 明确拒绝。
|
||
#include <cstddef>
|
||
#include <cstdint>
|
||
|
||
#include "vde/plugin/vde_plugin_api.h"
|
||
|
||
namespace {
|
||
|
||
int probe(const void* head, std::size_t head_size) {
|
||
(void)head;
|
||
(void)head_size;
|
||
return 0;
|
||
}
|
||
int read_file(const VdePluginHost* host, const char* path, VdeBody** bodies, size_t* count) {
|
||
(void)host; (void)path;
|
||
if (bodies) *bodies = nullptr;
|
||
if (count) *count = 0;
|
||
return VDE_PLUGIN_ERR_UNSUPPORTED;
|
||
}
|
||
int read_memory(const VdePluginHost* host, const void* data, size_t size, VdeBody** bodies,
|
||
size_t* count) {
|
||
(void)host; (void)data; (void)size;
|
||
if (bodies) *bodies = nullptr;
|
||
if (count) *count = 0;
|
||
return VDE_PLUGIN_ERR_UNSUPPORTED;
|
||
}
|
||
int write_file(const VdePluginHost* host, const char* path, const VdeBody* bodies, size_t count) {
|
||
(void)host; (void)path; (void)bodies; (void)count;
|
||
return VDE_PLUGIN_ERR_UNSUPPORTED;
|
||
}
|
||
const char* format_describe() { return "ABI 1.4 56B format fixture"; }
|
||
const VdeFormatPlugin kFormat = {sizeof(VdeFormatPlugin), "abi15.format56", ".abi15", probe,
|
||
read_file, read_memory, write_file, nullptr, format_describe};
|
||
|
||
#if defined(VDE_ABI15_OPTIMIZER56) || defined(VDE_ABI15_IOBATCH56)
|
||
int unused_callback(const VdePluginHost*, const char*, const char*, size_t, VdeBuffer*,
|
||
char*, size_t) {
|
||
return VDE_PLUGIN_ERR_UNSUPPORTED;
|
||
}
|
||
const VdeOptimizerPlugin kOptimizer = {sizeof(VdeOptimizerPlugin), "abi15.optimizer56", nullptr,
|
||
unused_callback, nullptr};
|
||
const VdeIoBatchPlugin kIoBatch = {sizeof(VdeIoBatchPlugin), "abi15.io_batch56", nullptr,
|
||
unused_callback, nullptr};
|
||
#endif
|
||
|
||
} // namespace
|
||
|
||
extern "C" {
|
||
|
||
VDE_PLUGIN_EXPORT int vde_plugin_query(std::uint32_t host_abi_major, VdePluginInfo* info) {
|
||
if (!info || info->struct_size < sizeof(VdePluginInfo)) return VDE_PLUGIN_ERR_INVALID_ARG;
|
||
if (host_abi_major != VDE_PLUGIN_ABI_MAJOR) return VDE_PLUGIN_ERR_ABI;
|
||
#if defined(VDE_ABI15_OPTIMIZER56)
|
||
info->id = "com.vde.test.abi15.optimizer56";
|
||
info->name = "ABI 1.5 optimizer declared with 56B registration";
|
||
info->kind = VDE_PLUGIN_KIND_OPTIMIZER;
|
||
info->capabilities = "optimizer:mock";
|
||
info->abi_minor = 5;
|
||
#elif defined(VDE_ABI15_IOBATCH56)
|
||
info->id = "com.vde.test.abi15.iobatch56";
|
||
info->name = "ABI 1.5 io_batch declared with 56B registration";
|
||
info->kind = VDE_PLUGIN_KIND_IO_BATCH;
|
||
info->capabilities = "io_batch:mock";
|
||
info->abi_minor = 5;
|
||
#else
|
||
info->id = "com.vde.test.abi15.format56";
|
||
info->name = "ABI 1.4 56B format plugin";
|
||
info->kind = VDE_PLUGIN_KIND_FORMAT;
|
||
info->capabilities = "format:abi15";
|
||
info->abi_minor = 4;
|
||
#endif
|
||
info->version = "0.1.0";
|
||
info->abi_major = VDE_PLUGIN_ABI_MAJOR;
|
||
info->license = "Apache-2.0";
|
||
return VDE_PLUGIN_OK;
|
||
}
|
||
|
||
VDE_PLUGIN_EXPORT int vde_plugin_init(const VdePluginHost* host, VdePluginRegistration* reg) {
|
||
(void)host;
|
||
if (!reg) return VDE_PLUGIN_ERR_INVALID_ARG;
|
||
// 模拟 ABI 1.4 旧插件:struct_size = 56(只到 mesher 字段末尾)。
|
||
reg->struct_size = static_cast<std::uint32_t>(
|
||
offsetof(VdePluginRegistration, optimizer));
|
||
reg->format = nullptr;
|
||
reg->generic = nullptr;
|
||
reg->cae_solver = nullptr;
|
||
reg->cam_strategy = nullptr;
|
||
reg->gcs_solver = nullptr;
|
||
reg->mesher = nullptr;
|
||
#if defined(VDE_ABI15_OPTIMIZER56)
|
||
reg->kind = VDE_PLUGIN_KIND_OPTIMIZER;
|
||
#elif defined(VDE_ABI15_IOBATCH56)
|
||
reg->kind = VDE_PLUGIN_KIND_IO_BATCH;
|
||
#else
|
||
reg->kind = VDE_PLUGIN_KIND_FORMAT;
|
||
reg->format = &kFormat;
|
||
#endif
|
||
return VDE_PLUGIN_OK;
|
||
}
|
||
|
||
VDE_PLUGIN_EXPORT void vde_plugin_shutdown() {}
|
||
|
||
} // extern "C"
|