fix: StringBox/IntegerBoxプラグインにM_BIRTH/M_FINI実装、v1互換削除

- StringBoxプラグイン:nyash_plugin_invoke削除(TypeBox v2のみ使用)
- IntegerBoxプラグイン:M_BIRTH/M_FINI実装追加
- 根本原因判明:BuiltinBoxFactoryがプラグインより優先される問題
- Phase 15.5 Core Box統一の未完了部分を特定

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Selfhosting Dev
2025-09-24 10:32:15 +09:00
parent 73b90a7c28
commit 26716e74e9
2 changed files with 66 additions and 4 deletions

View File

@ -149,6 +149,27 @@ extern "C" fn integer_invoke_id(
) -> i32 {
unsafe {
match method_id {
M_BIRTH => {
// Create new IntegerBox instance
let id = NEXT_ID.fetch_add(1, Ordering::Relaxed);
let init = read_arg_i64(args, args_len, 0).unwrap_or(0);
eprintln!("[IntegerBox] M_BIRTH called: id={}, init={}", id, init);
if let Ok(mut m) = INST.lock() {
m.insert(id, IntInstance { value: init });
return write_tlv_handle(TYPE_ID_INTEGER, id, result, result_len);
} else {
return E_PLUGIN;
}
}
M_FINI => {
// Destroy IntegerBox instance
if let Ok(mut m) = INST.lock() {
m.remove(&instance_id);
return OK;
} else {
return E_PLUGIN;
}
}
M_GET => {
if let Ok(m) = INST.lock() {
if let Some(inst) = m.get(&instance_id) {
@ -235,6 +256,18 @@ fn write_tlv_i64(v: i64, result: *mut u8, result_len: *mut usize) -> i32 {
write_tlv_result(&[(3u8, &v.to_le_bytes())], result, result_len)
}
fn write_tlv_handle(
type_id: u32,
instance_id: u32,
result: *mut u8,
result_len: *mut usize,
) -> i32 {
let mut payload = Vec::with_capacity(8);
payload.extend_from_slice(&type_id.to_le_bytes());
payload.extend_from_slice(&instance_id.to_le_bytes());
write_tlv_result(&[(8u8, &payload)], result, result_len)
}
fn read_arg_i64(args: *const u8, args_len: usize, n: usize) -> Option<i64> {
if args.is_null() || args_len < 4 {
return None;