fix: Kilo/CHIP-8アプリエラー修正 - toInteger, substring, レガシーBox削除

## 修正内容
1. **toIntegerメソッド実装** (#125)
   - StringBoxにtoInteger()メソッド追加
   - box_trait::IntegerBoxを返すよう統一(レガシーboxes::IntegerBox削除)

2. **substringメソッド実装**
   - StringBoxにsubstring(start, end)メソッド追加
   - Kiloエディタで必要な文字列操作を完全サポート

3. **レガシーコード削除**
   - src/boxes/mod.rsから重複StringBox/IntegerBox/BoolBoxエクスポート削除
   - 全てbox_trait実装に統一

4. **プラグインドキュメント整理**
   - 古い仕様書に「理想案・未実装」「将来構想」明記
   - 実装ベースの正確な仕様書作成
   - migration-guide.md追加

## テスト結果
-  Kiloエディタ: 完全動作確認("Enhanced Kilo Editor test complete")
-  toInteger()の乗算: 正常動作
-  substring(): 正常動作

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Moe Charm
2025-08-20 14:13:47 +09:00
parent 163cab0c25
commit 3e8b75f4de
15 changed files with 1020 additions and 15 deletions

View File

@ -214,6 +214,17 @@ impl StringBox {
Box::new(IntegerBox::new(self.value.len() as i64))
}
/// Convert string to integer (parse as i64)
pub fn to_integer(&self) -> Box<dyn NyashBox> {
match self.value.trim().parse::<i64>() {
Ok(n) => Box::new(IntegerBox::new(n)),
Err(_) => {
// If parsing fails, return 0 (JavaScript-like behavior)
Box::new(IntegerBox::new(0))
}
}
}
/// Get character at index
pub fn get(&self, index: usize) -> Option<Box<dyn NyashBox>> {
if let Some(ch) = self.value.chars().nth(index) {
@ -222,6 +233,15 @@ impl StringBox {
None
}
}
/// Get substring from start to end (exclusive)
pub fn substring(&self, start: usize, end: usize) -> Box<dyn NyashBox> {
let chars: Vec<char> = self.value.chars().collect();
let actual_end = end.min(chars.len());
let actual_start = start.min(actual_end);
let substring: String = chars[actual_start..actual_end].iter().collect();
Box::new(StringBox::new(substring))
}
}
impl BoxCore for StringBox {