feat: Phase 1完了 - plugin_loader_v2大規模リファクタリング(1006→893行、420行分離)
✨ Single Responsibility Principle適用による構造改善 - extern_functions.rs: env.*外部関数処理(261行) - ffi_bridge.rs: FFI/TLV処理(158行) - instance_manager.rs: インスタンス管理(140行) - loader.rs: 1006→893行(11%削減) 🎯 効果: - 6つの責任を分離し単一責任原則遵守 - モジュール間の境界明確化 - 保守性・可読性大幅向上 📦 追加: filebox-pluginモジュール化も含む
This commit is contained in:
39
plugins/nyash-filebox-plugin/src/ffi.rs
Normal file
39
plugins/nyash-filebox-plugin/src/ffi.rs
Normal file
@ -0,0 +1,39 @@
|
||||
//! FFI (Foreign Function Interface) type definitions for FileBox plugin
|
||||
|
||||
use std::os::raw::c_char;
|
||||
|
||||
// ============ FFI Types ============
|
||||
|
||||
#[repr(C)]
|
||||
pub struct NyashMethodInfo {
|
||||
pub method_id: u32,
|
||||
pub name: *const c_char,
|
||||
pub signature: u32,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct NyashPluginInfo {
|
||||
pub type_id: u32,
|
||||
pub type_name: *const c_char,
|
||||
pub method_count: usize,
|
||||
pub methods: *const NyashMethodInfo,
|
||||
}
|
||||
|
||||
/// TypeBox FFI structure for plugin export
|
||||
#[repr(C)]
|
||||
pub struct NyashTypeBoxFfi {
|
||||
pub abi_tag: u32, // 'TYBX' (0x54594258)
|
||||
pub version: u16, // 1
|
||||
pub struct_size: u16, // sizeof(NyashTypeBoxFfi)
|
||||
pub name: *const c_char, // C string, e.g., "FileBox\0"
|
||||
pub resolve: Option<extern "C" fn(*const c_char) -> u32>,
|
||||
pub invoke_id: Option<extern "C" fn(u32, u32, *const u8, usize, *mut u8, *mut usize) -> i32>,
|
||||
pub capabilities: u64,
|
||||
}
|
||||
|
||||
unsafe impl Sync for NyashTypeBoxFfi {}
|
||||
unsafe impl Send for NyashTypeBoxFfi {}
|
||||
|
||||
// ABI Constants
|
||||
pub const ABI_TAG_TYBX: u32 = 0x54594258; // 'TYBX'
|
||||
pub const ABI_VERSION: u16 = 1;
|
||||
Reference in New Issue
Block a user