feat(plugin): Fix plugin BoxRef return and Box argument support

- Fixed deadlock in FileBox plugin copyFrom implementation (single lock)
- Added TLV Handle (tag=8) parsing in calls.rs for returned BoxRefs
- Improved plugin loader with config path consistency and detailed logging
- Fixed loader routing for proper Handle type_id/fini_method_id resolution
- Added detailed logging for TLV encoding/decoding in plugin_loader_v2

Test docs/examples/plugin_boxref_return.nyash now works correctly:
- cloneSelf() returns FileBox Handle properly
- copyFrom(Box) accepts plugin Box arguments
- Both FileBox instances close and fini correctly

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Moe Charm
2025-08-21 00:41:26 +09:00
parent af32896574
commit cc2a820af7
274 changed files with 7244 additions and 4608 deletions

View File

@ -0,0 +1,40 @@
Nyash言語のweak参照実装で根本的な設計問題が発覚しました。専門的分析をお願いします。
【現在の問題】
InstanceBox構造が原因でweak参照が実装できません
```rust
pub struct InstanceBox {
pub fields: Arc<Mutex<HashMap<String, Box<dyn NyashBox>>>>, // 問題の核心
}
```
NyashValue::WeakBoxを作っても、Box<dyn NyashBox>にしか格納できず、弱参照情報が失われます。
【解決策の選択肢】
1. **根本解決**(理想だが影響大)
```rust
pub fields: Arc<Mutex<HashMap<String, NyashValue>>>, // 全面アーキテクチャ変更
```
2. **暫定解決**copilot提案
```rust
pub struct InstanceBox {
pub fields: Arc<Mutex<HashMap<String, Box<dyn NyashBox>>>>, // 既存維持
pub weak_fields: Arc<Mutex<HashMap<String, Weak<Mutex<dyn NyashBox>>>>>, // 追加
}
```
【コンテキスト】
- NyashValue革命は完了済みArc<Mutex>過剰症候群解決)
- Everything is Box哲学必須
- 実用性重視(完璧より動くもの優先)
【質問】
1. 暫定解決策の技術的妥当性は?
2. パフォーマンス・保守性への影響は?
3. 根本解決は本当に必要か?
4. 段階的移行戦略の是非は?
実装可能性と設計の美しさのバランスを重視した分析をお願いします。