Phase 12: 統一TypeBox ABI実装開始 - ChatGPT5による極小コアABI基盤構築

- TypeBox ABI雛形: メソッドスロット管理システム追加
- Type Registry: Array/Map/StringBoxの基本メソッド定義
- Host API: C ABI逆呼び出しシステム実装
- Phase 12ドキュメント整理: 設計文書統合・アーカイブ化
- MIR Builder: クリーンアップと分離実装完了

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Moe Charm
2025-09-03 05:04:56 +09:00
parent e2e25f6615
commit 53d88157aa
84 changed files with 4739 additions and 2750 deletions

View File

@ -28,6 +28,12 @@ pub mod decode {
if buf.len() < 8 + size { return None; }
Some((tag, size, &buf[8..8 + size]))
}
/// Decode u64 payload (size must be 8)
pub fn u64(payload: &[u8]) -> Option<u64> {
if payload.len() != 8 { return None; }
let mut b = [0u8;8]; b.copy_from_slice(payload);
Some(u64::from_le_bytes(b))
}
/// Decode bool payload (size must be 1; nonzero => true)
pub fn bool(payload: &[u8]) -> Option<bool> {
if payload.len() != 1 { return None; }
@ -50,6 +56,16 @@ pub mod decode {
String::from_utf8_lossy(payload).to_string()
}
/// Decode plugin handle payload (type_id:u32 + instance_id:u32)
pub fn plugin_handle(payload: &[u8]) -> Option<(u32, u32)> {
if payload.len() != 8 { return None; }
let mut a = [0u8;4];
let mut b = [0u8;4];
a.copy_from_slice(&payload[0..4]);
b.copy_from_slice(&payload[4..8]);
Some((u32::from_le_bytes(a), u32::from_le_bytes(b)))
}
/// Get nth TLV entry from a buffer with header
pub fn tlv_nth(buf: &[u8], n: usize) -> Option<(u8, usize, &[u8])> {
if buf.len() < 4 { return None; }
@ -87,6 +103,8 @@ pub mod encode {
const TAG_BYTES: u8 = 7;
/// tag for Plugin Handle (type_id + instance_id)
const TAG_HANDLE: u8 = 8;
/// tag for Host Handle (host-managed handle id u64)
const TAG_HOST_HANDLE: u8 = 9;
/// Append a bool TLV entry (tag=1, size=1)
pub fn bool(buf: &mut Vec<u8>, v: bool) {
@ -150,6 +168,13 @@ pub mod encode {
buf.extend_from_slice(&type_id.to_le_bytes());
buf.extend_from_slice(&instance_id.to_le_bytes());
}
/// Append a host handle TLV entry (tag=9, size=8, handle_id:u64)
pub fn host_handle(buf: &mut Vec<u8>, handle_id: u64) {
buf.push(TAG_HOST_HANDLE);
buf.push(0u8);
buf.extend_from_slice(&(8u16).to_le_bytes());
buf.extend_from_slice(&handle_id.to_le_bytes());
}
}
#[cfg(test)]