refactor: 大型プラグインのモジュール分割によるコード品質向上
nyash-json-plugin: - 796行の単一ファイルから6モジュール構造へ分割 - constants.rs, provider.rs, doc_box.rs, node_box.rs, tlv_helpers.rs, ffi.rsに責任分離 - 最大ファイルサイズを374行に削減(53%削減) - 共有状態管理をprovider.rsに集約 nyash-net-plugin: - 1112行の巨大ファイルから17ファイル構造へ分割 - boxesサブディレクトリでBox実装を整理(server, client, request, response, socket系) - 最大ファイルサイズを290行に削減(74%削減) - logging, tlv, http_helpers等の共通機能を独立モジュール化 両プラグインともビルド成功確認済み、完全な後方互換性を維持 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
35
plugins/nyash-net-plugin/src/boxes/socket_client_impl.rs
Normal file
35
plugins/nyash-net-plugin/src/boxes/socket_client_impl.rs
Normal file
@ -0,0 +1,35 @@
|
||||
// --- SockClientBox ---
|
||||
extern "C" fn sockclient_resolve(name: *const std::os::raw::c_char) -> u32 {
|
||||
if name.is_null() {
|
||||
return 0;
|
||||
}
|
||||
let s = ffi::cstr_to_string(name);
|
||||
match s.as_ref() {
|
||||
"connect" => M_SC_CONNECT,
|
||||
"birth" => M_SC_BIRTH,
|
||||
"fini" => u32::MAX,
|
||||
_ => 0,
|
||||
}
|
||||
}
|
||||
extern "C" fn sockclient_invoke_id(
|
||||
instance_id: u32,
|
||||
method_id: u32,
|
||||
args: *const u8,
|
||||
args_len: usize,
|
||||
result: *mut u8,
|
||||
result_len: *mut usize,
|
||||
) -> i32 {
|
||||
unsafe {
|
||||
sockets::sock_client_invoke(method_id, instance_id, args, args_len, result, result_len)
|
||||
}
|
||||
}
|
||||
#[no_mangle]
|
||||
pub static nyash_typebox_SockClientBox: NyashTypeBoxFfi = NyashTypeBoxFfi {
|
||||
abi_tag: 0x54594258,
|
||||
version: 1,
|
||||
struct_size: std::mem::size_of::<NyashTypeBoxFfi>() as u16,
|
||||
name: b"SockClientBox\0".as_ptr() as *const std::os::raw::c_char,
|
||||
resolve: Some(sockclient_resolve),
|
||||
invoke_id: Some(sockclient_invoke_id),
|
||||
capabilities: 0,
|
||||
};
|
||||
Reference in New Issue
Block a user