Files
hakorune/src/boxes/console_box.rs

179 lines
5.1 KiB
Rust
Raw Normal View History

/*! 📟 ConsoleBox - コンソール出力Box
*
* ## 📝
* Webブラウザのコンソール機能を統合したBox
* WASM環境ではブラウザコンソール
*
* ## 🛠
* - `log(message)` -
feat(core): Phase 122 ConsoleBox.println / log unification ## Phase 122: ConsoleBox.println / log の統一 (完了) ### 概要 ConsoleBox.printlnをlogのエイリアスとしてVM/TypeRegistryレベルで統一。 Phase 120で発見されたesc_dirname_smoke.hakoの「Unknown method 'println'」 エラーを完全解消。 ### 完了タスク - ✅ TypeRegistry修正: printlnをlogのエイリアス(slot 400)として追加 - ✅ ConsoleBox実装: printlnメソッドのラッパ追加 - ✅ VM Method Dispatch: ConsoleBox専用ハンドラ追加 - ✅ Plugin設定: nyash.tomlにprintln (method_id 2)追加 - ✅ ドキュメント更新: 3ファイル(hako_logging/logging_policy/core_boxes) ### 実装詳細 #### 1. TypeRegistry (src/runtime/type_registry.rs) ```rust const CONSOLE_METHODS: &[MethodEntry] = &[ MethodEntry { name: "log", arity: 1, slot: 400 }, MethodEntry { name: "warn", arity: 1, slot: 401 }, MethodEntry { name: "error", arity: 1, slot: 402 }, MethodEntry { name: "clear", arity: 0, slot: 403 }, // Phase 122: println は log のエイリアス MethodEntry { name: "println", arity: 1, slot: 400 }, ]; ``` #### 2. ConsoleBox (src/boxes/console_box.rs) - WASM/非WASM両方にprintln()メソッド追加 - 内部的にlog()に委譲 #### 3. VM Method Dispatch (src/backend/mir_interpreter/handlers/calls/method.rs) - ConsoleBox専用ハンドラ追加 - log/println/warn/error/clearをサポート - args配列の正しい処理(len > 1時はargs[1]を使用) #### 4. Plugin設定 (nyash.toml) - ConsoleBox.methodsにprintln追加(method_id=2) - method_id整合性: log=1, println=2 ### テスト結果 - ✅ esc_dirname_smoke.hako実行成功 - 旧エラー: "Unknown method 'println'" ← **完全解消** - 新出力: `[Console LOG] dir1/dir2` ### Phase 120問題解決 **Phase 120ベースラインでの課題**: - ❌ esc_dirname_smoke.hako: ConsoleBox.println未実装 **Phase 122での解決**: - ✅ TypeRegistryレベルでprintln→log正規化 - ✅ 全経路(JSON v0/selfhost/通常VM)で一貫性保証 ### ファイル構成 **新規作成**: - docs/development/current/main/phase122_consolebox_println_unification.md **修正**: - src/runtime/type_registry.rs (+5行) - src/boxes/console_box.rs (+14行, WASM/非WASM両対応) - src/backend/mir_interpreter/handlers/calls/method.rs (+60行) - nyash.toml (+1メソッド定義) - docs/development/current/main/hako_logging_design.md (+40行) - docs/development/current/main/logging_policy.md (+30行) - docs/development/current/main/core_boxes_design.md (+20行) ### 技術的成果 - **Alias First原則**: VM/TypeRegistryレベルで正規化 - **Phase 120連携**: ベースライン確立→問題発見→根本解決 - **全経路統一**: selfhost/JSON v0/通常VMすべてで動作 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 05:16:06 +09:00
* - `println(message)` - `log` sugar
* - `warn(message)` -
* - `error(message)` -
* - `clear()` -
*
feat(core): Phase 122 ConsoleBox.println / log unification ## Phase 122: ConsoleBox.println / log の統一 (完了) ### 概要 ConsoleBox.printlnをlogのエイリアスとしてVM/TypeRegistryレベルで統一。 Phase 120で発見されたesc_dirname_smoke.hakoの「Unknown method 'println'」 エラーを完全解消。 ### 完了タスク - ✅ TypeRegistry修正: printlnをlogのエイリアス(slot 400)として追加 - ✅ ConsoleBox実装: printlnメソッドのラッパ追加 - ✅ VM Method Dispatch: ConsoleBox専用ハンドラ追加 - ✅ Plugin設定: nyash.tomlにprintln (method_id 2)追加 - ✅ ドキュメント更新: 3ファイル(hako_logging/logging_policy/core_boxes) ### 実装詳細 #### 1. TypeRegistry (src/runtime/type_registry.rs) ```rust const CONSOLE_METHODS: &[MethodEntry] = &[ MethodEntry { name: "log", arity: 1, slot: 400 }, MethodEntry { name: "warn", arity: 1, slot: 401 }, MethodEntry { name: "error", arity: 1, slot: 402 }, MethodEntry { name: "clear", arity: 0, slot: 403 }, // Phase 122: println は log のエイリアス MethodEntry { name: "println", arity: 1, slot: 400 }, ]; ``` #### 2. ConsoleBox (src/boxes/console_box.rs) - WASM/非WASM両方にprintln()メソッド追加 - 内部的にlog()に委譲 #### 3. VM Method Dispatch (src/backend/mir_interpreter/handlers/calls/method.rs) - ConsoleBox専用ハンドラ追加 - log/println/warn/error/clearをサポート - args配列の正しい処理(len > 1時はargs[1]を使用) #### 4. Plugin設定 (nyash.toml) - ConsoleBox.methodsにprintln追加(method_id=2) - method_id整合性: log=1, println=2 ### テスト結果 - ✅ esc_dirname_smoke.hako実行成功 - 旧エラー: "Unknown method 'println'" ← **完全解消** - 新出力: `[Console LOG] dir1/dir2` ### Phase 120問題解決 **Phase 120ベースラインでの課題**: - ❌ esc_dirname_smoke.hako: ConsoleBox.println未実装 **Phase 122での解決**: - ✅ TypeRegistryレベルでprintln→log正規化 - ✅ 全経路(JSON v0/selfhost/通常VM)で一貫性保証 ### ファイル構成 **新規作成**: - docs/development/current/main/phase122_consolebox_println_unification.md **修正**: - src/runtime/type_registry.rs (+5行) - src/boxes/console_box.rs (+14行, WASM/非WASM両対応) - src/backend/mir_interpreter/handlers/calls/method.rs (+60行) - nyash.toml (+1メソッド定義) - docs/development/current/main/hako_logging_design.md (+40行) - docs/development/current/main/logging_policy.md (+30行) - docs/development/current/main/core_boxes_design.md (+20行) ### 技術的成果 - **Alias First原則**: VM/TypeRegistryレベルで正規化 - **Phase 120連携**: ベースライン確立→問題発見→根本解決 - **全経路統一**: selfhost/JSON v0/通常VMすべてで動作 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 05:16:06 +09:00
* ## Phase 122: println / log
*
* `println` `log` slot 400 使
* `println` 使`log`
*
* ## 💡 使
* ```nyash
* local console
* console = new ConsoleBox()
*
* console.log("Hello, Nyash!") // 通常ログ
* console.warn("This is a warning") // 警告
* console.error("Something went wrong") // エラー
* console.clear() // クリア
*
* // デバッグ用途
* local value
* value = 42
* console.log("Debug: value = " + value.toString())
* ```
*
* ## 🌐
* - **WASM環境**:
* - ****:
*
* ## 🔍
* ```nyash
* // エラーハンドリング
* if (error_condition) {
* console.error("Critical error occurred!")
* return null
* }
*
* // 実行トレース
* console.log("Function start")
* // 処理...
* console.log("Function end")
* ```
*/
use crate::box_trait::{BoolBox, BoxBase, BoxCore, NyashBox, StringBox};
use std::any::Any;
use std::fmt::Display;
Phase 122.5-126完了:ConsoleBox 品質改善・最適化・統合 ## 実装成果(Phase 122.5-126) ### Phase 122.5: nyash.toml method_id 修正 - println method_id を 2 → 1 に統一(log と同じ) - TypeRegistry slot 400 との整合性確保 ### Phase 123: ConsoleBox WASM/非WASM コード統一化 - マクロ define_console_impl! による重複排除 - 67行削減(27.3% 削減達成) - ビルド成功・全テストパス ### Phase 124: VM Method Dispatch 統一化 - TypeRegistry ベースの統一ディスパッチ (dispatch_by_slot) - String/Array/ConsoleBox を一元化 - 100行削減、メソッド解決の高速化 ### Phase 125: 削除:deprecated builtin ConsoleBox - src/box_factory/builtin_impls/console_box.rs 削除 - Plugin-only 移行で "Everything is Plugin" 実現 - 52行削減 ### Phase 126: ドキュメント統合 - consolebox_complete_guide.md (27KB統合マスター) - core_boxes_design/logging_policy/hako_logging_design 更新 - ~750行の navigation・cross-reference 改善 ## 数値成果 - **総コード削減**: 219行 - **新規ドキュメント**: 1ファイル (+27KB) - **更新ドキュメント**: 6ファイル (+~750行) - **テスト**: Phase 120 representative tests ✅ PASS - **ビルド**: Zero errors ## 設計原則の完全実現 ✅ println/log エイリアス統一(Phase 122) ✅ WASM/非WASM 統一化(Phase 123) ✅ TypeRegistry 統合(Phase 124) ✅ Plugin-only 移行(Phase 125) ✅ ドキュメント統合(Phase 126) 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 06:02:03 +09:00
/// ConsoleBox メソッド実装マクロ
/// WASM/非WASM環境で異なるメソッド実装を統一化
macro_rules! define_console_impl {
(
log: $log_impl:expr,
warn: $warn_impl:expr,
error: $error_impl:expr,
clear: $clear_impl:expr,
fmt_desc: $fmt_desc:expr
) => {
impl ConsoleBox {
pub fn new() -> Self {
Self {
base: BoxBase::new(),
}
}
pub fn log(&self, message: &str) {
$log_impl(message);
}
pub fn println(&self, message: &str) {
self.log(message);
}
pub fn warn(&self, message: &str) {
$warn_impl(message);
}
pub fn error(&self, message: &str) {
$error_impl(message);
}
pub fn clear(&self) {
$clear_impl();
}
}
Phase 122.5-126完了:ConsoleBox 品質改善・最適化・統合 ## 実装成果(Phase 122.5-126) ### Phase 122.5: nyash.toml method_id 修正 - println method_id を 2 → 1 に統一(log と同じ) - TypeRegistry slot 400 との整合性確保 ### Phase 123: ConsoleBox WASM/非WASM コード統一化 - マクロ define_console_impl! による重複排除 - 67行削減(27.3% 削減達成) - ビルド成功・全テストパス ### Phase 124: VM Method Dispatch 統一化 - TypeRegistry ベースの統一ディスパッチ (dispatch_by_slot) - String/Array/ConsoleBox を一元化 - 100行削減、メソッド解決の高速化 ### Phase 125: 削除:deprecated builtin ConsoleBox - src/box_factory/builtin_impls/console_box.rs 削除 - Plugin-only 移行で "Everything is Plugin" 実現 - 52行削減 ### Phase 126: ドキュメント統合 - consolebox_complete_guide.md (27KB統合マスター) - core_boxes_design/logging_policy/hako_logging_design 更新 - ~750行の navigation・cross-reference 改善 ## 数値成果 - **総コード削減**: 219行 - **新規ドキュメント**: 1ファイル (+27KB) - **更新ドキュメント**: 6ファイル (+~750行) - **テスト**: Phase 120 representative tests ✅ PASS - **ビルド**: Zero errors ## 設計原則の完全実現 ✅ println/log エイリアス統一(Phase 122) ✅ WASM/非WASM 統一化(Phase 123) ✅ TypeRegistry 統合(Phase 124) ✅ Plugin-only 移行(Phase 125) ✅ ドキュメント統合(Phase 126) 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 06:02:03 +09:00
impl BoxCore for ConsoleBox {
fn box_id(&self) -> u64 {
self.base.id
}
Phase 122.5-126完了:ConsoleBox 品質改善・最適化・統合 ## 実装成果(Phase 122.5-126) ### Phase 122.5: nyash.toml method_id 修正 - println method_id を 2 → 1 に統一(log と同じ) - TypeRegistry slot 400 との整合性確保 ### Phase 123: ConsoleBox WASM/非WASM コード統一化 - マクロ define_console_impl! による重複排除 - 67行削減(27.3% 削減達成) - ビルド成功・全テストパス ### Phase 124: VM Method Dispatch 統一化 - TypeRegistry ベースの統一ディスパッチ (dispatch_by_slot) - String/Array/ConsoleBox を一元化 - 100行削減、メソッド解決の高速化 ### Phase 125: 削除:deprecated builtin ConsoleBox - src/box_factory/builtin_impls/console_box.rs 削除 - Plugin-only 移行で "Everything is Plugin" 実現 - 52行削減 ### Phase 126: ドキュメント統合 - consolebox_complete_guide.md (27KB統合マスター) - core_boxes_design/logging_policy/hako_logging_design 更新 - ~750行の navigation・cross-reference 改善 ## 数値成果 - **総コード削減**: 219行 - **新規ドキュメント**: 1ファイル (+27KB) - **更新ドキュメント**: 6ファイル (+~750行) - **テスト**: Phase 120 representative tests ✅ PASS - **ビルド**: Zero errors ## 設計原則の完全実現 ✅ println/log エイリアス統一(Phase 122) ✅ WASM/非WASM 統一化(Phase 123) ✅ TypeRegistry 統合(Phase 124) ✅ Plugin-only 移行(Phase 125) ✅ ドキュメント統合(Phase 126) 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 06:02:03 +09:00
fn parent_type_id(&self) -> Option<std::any::TypeId> {
self.base.parent_type_id
}
Phase 122.5-126完了:ConsoleBox 品質改善・最適化・統合 ## 実装成果(Phase 122.5-126) ### Phase 122.5: nyash.toml method_id 修正 - println method_id を 2 → 1 に統一(log と同じ) - TypeRegistry slot 400 との整合性確保 ### Phase 123: ConsoleBox WASM/非WASM コード統一化 - マクロ define_console_impl! による重複排除 - 67行削減(27.3% 削減達成) - ビルド成功・全テストパス ### Phase 124: VM Method Dispatch 統一化 - TypeRegistry ベースの統一ディスパッチ (dispatch_by_slot) - String/Array/ConsoleBox を一元化 - 100行削減、メソッド解決の高速化 ### Phase 125: 削除:deprecated builtin ConsoleBox - src/box_factory/builtin_impls/console_box.rs 削除 - Plugin-only 移行で "Everything is Plugin" 実現 - 52行削減 ### Phase 126: ドキュメント統合 - consolebox_complete_guide.md (27KB統合マスター) - core_boxes_design/logging_policy/hako_logging_design 更新 - ~750行の navigation・cross-reference 改善 ## 数値成果 - **総コード削減**: 219行 - **新規ドキュメント**: 1ファイル (+27KB) - **更新ドキュメント**: 6ファイル (+~750行) - **テスト**: Phase 120 representative tests ✅ PASS - **ビルド**: Zero errors ## 設計原則の完全実現 ✅ println/log エイリアス統一(Phase 122) ✅ WASM/非WASM 統一化(Phase 123) ✅ TypeRegistry 統合(Phase 124) ✅ Plugin-only 移行(Phase 125) ✅ ドキュメント統合(Phase 126) 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 06:02:03 +09:00
fn fmt_box(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{}", $fmt_desc)
}
Phase 122.5-126完了:ConsoleBox 品質改善・最適化・統合 ## 実装成果(Phase 122.5-126) ### Phase 122.5: nyash.toml method_id 修正 - println method_id を 2 → 1 に統一(log と同じ) - TypeRegistry slot 400 との整合性確保 ### Phase 123: ConsoleBox WASM/非WASM コード統一化 - マクロ define_console_impl! による重複排除 - 67行削減(27.3% 削減達成) - ビルド成功・全テストパス ### Phase 124: VM Method Dispatch 統一化 - TypeRegistry ベースの統一ディスパッチ (dispatch_by_slot) - String/Array/ConsoleBox を一元化 - 100行削減、メソッド解決の高速化 ### Phase 125: 削除:deprecated builtin ConsoleBox - src/box_factory/builtin_impls/console_box.rs 削除 - Plugin-only 移行で "Everything is Plugin" 実現 - 52行削減 ### Phase 126: ドキュメント統合 - consolebox_complete_guide.md (27KB統合マスター) - core_boxes_design/logging_policy/hako_logging_design 更新 - ~750行の navigation・cross-reference 改善 ## 数値成果 - **総コード削減**: 219行 - **新規ドキュメント**: 1ファイル (+27KB) - **更新ドキュメント**: 6ファイル (+~750行) - **テスト**: Phase 120 representative tests ✅ PASS - **ビルド**: Zero errors ## 設計原則の完全実現 ✅ println/log エイリアス統一(Phase 122) ✅ WASM/非WASM 統一化(Phase 123) ✅ TypeRegistry 統合(Phase 124) ✅ Plugin-only 移行(Phase 125) ✅ ドキュメント統合(Phase 126) 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 06:02:03 +09:00
fn as_any(&self) -> &dyn Any {
self
}
fn as_any_mut(&mut self) -> &mut dyn Any {
self
}
}
Phase 122.5-126完了:ConsoleBox 品質改善・最適化・統合 ## 実装成果(Phase 122.5-126) ### Phase 122.5: nyash.toml method_id 修正 - println method_id を 2 → 1 に統一(log と同じ) - TypeRegistry slot 400 との整合性確保 ### Phase 123: ConsoleBox WASM/非WASM コード統一化 - マクロ define_console_impl! による重複排除 - 67行削減(27.3% 削減達成) - ビルド成功・全テストパス ### Phase 124: VM Method Dispatch 統一化 - TypeRegistry ベースの統一ディスパッチ (dispatch_by_slot) - String/Array/ConsoleBox を一元化 - 100行削減、メソッド解決の高速化 ### Phase 125: 削除:deprecated builtin ConsoleBox - src/box_factory/builtin_impls/console_box.rs 削除 - Plugin-only 移行で "Everything is Plugin" 実現 - 52行削減 ### Phase 126: ドキュメント統合 - consolebox_complete_guide.md (27KB統合マスター) - core_boxes_design/logging_policy/hako_logging_design 更新 - ~750行の navigation・cross-reference 改善 ## 数値成果 - **総コード削減**: 219行 - **新規ドキュメント**: 1ファイル (+27KB) - **更新ドキュメント**: 6ファイル (+~750行) - **テスト**: Phase 120 representative tests ✅ PASS - **ビルド**: Zero errors ## 設計原則の完全実現 ✅ println/log エイリアス統一(Phase 122) ✅ WASM/非WASM 統一化(Phase 123) ✅ TypeRegistry 統合(Phase 124) ✅ Plugin-only 移行(Phase 125) ✅ ドキュメント統合(Phase 126) 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 06:02:03 +09:00
impl NyashBox for ConsoleBox {
fn to_string_box(&self) -> StringBox {
StringBox::new($fmt_desc)
}
Phase 122.5-126完了:ConsoleBox 品質改善・最適化・統合 ## 実装成果(Phase 122.5-126) ### Phase 122.5: nyash.toml method_id 修正 - println method_id を 2 → 1 に統一(log と同じ) - TypeRegistry slot 400 との整合性確保 ### Phase 123: ConsoleBox WASM/非WASM コード統一化 - マクロ define_console_impl! による重複排除 - 67行削減(27.3% 削減達成) - ビルド成功・全テストパス ### Phase 124: VM Method Dispatch 統一化 - TypeRegistry ベースの統一ディスパッチ (dispatch_by_slot) - String/Array/ConsoleBox を一元化 - 100行削減、メソッド解決の高速化 ### Phase 125: 削除:deprecated builtin ConsoleBox - src/box_factory/builtin_impls/console_box.rs 削除 - Plugin-only 移行で "Everything is Plugin" 実現 - 52行削減 ### Phase 126: ドキュメント統合 - consolebox_complete_guide.md (27KB統合マスター) - core_boxes_design/logging_policy/hako_logging_design 更新 - ~750行の navigation・cross-reference 改善 ## 数値成果 - **総コード削減**: 219行 - **新規ドキュメント**: 1ファイル (+27KB) - **更新ドキュメント**: 6ファイル (+~750行) - **テスト**: Phase 120 representative tests ✅ PASS - **ビルド**: Zero errors ## 設計原則の完全実現 ✅ println/log エイリアス統一(Phase 122) ✅ WASM/非WASM 統一化(Phase 123) ✅ TypeRegistry 統合(Phase 124) ✅ Plugin-only 移行(Phase 125) ✅ ドキュメント統合(Phase 126) 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 06:02:03 +09:00
fn equals(&self, other: &dyn NyashBox) -> BoolBox {
BoolBox::new(other.as_any().is::<ConsoleBox>())
}
feat(core): Phase 122 ConsoleBox.println / log unification ## Phase 122: ConsoleBox.println / log の統一 (完了) ### 概要 ConsoleBox.printlnをlogのエイリアスとしてVM/TypeRegistryレベルで統一。 Phase 120で発見されたesc_dirname_smoke.hakoの「Unknown method 'println'」 エラーを完全解消。 ### 完了タスク - ✅ TypeRegistry修正: printlnをlogのエイリアス(slot 400)として追加 - ✅ ConsoleBox実装: printlnメソッドのラッパ追加 - ✅ VM Method Dispatch: ConsoleBox専用ハンドラ追加 - ✅ Plugin設定: nyash.tomlにprintln (method_id 2)追加 - ✅ ドキュメント更新: 3ファイル(hako_logging/logging_policy/core_boxes) ### 実装詳細 #### 1. TypeRegistry (src/runtime/type_registry.rs) ```rust const CONSOLE_METHODS: &[MethodEntry] = &[ MethodEntry { name: "log", arity: 1, slot: 400 }, MethodEntry { name: "warn", arity: 1, slot: 401 }, MethodEntry { name: "error", arity: 1, slot: 402 }, MethodEntry { name: "clear", arity: 0, slot: 403 }, // Phase 122: println は log のエイリアス MethodEntry { name: "println", arity: 1, slot: 400 }, ]; ``` #### 2. ConsoleBox (src/boxes/console_box.rs) - WASM/非WASM両方にprintln()メソッド追加 - 内部的にlog()に委譲 #### 3. VM Method Dispatch (src/backend/mir_interpreter/handlers/calls/method.rs) - ConsoleBox専用ハンドラ追加 - log/println/warn/error/clearをサポート - args配列の正しい処理(len > 1時はargs[1]を使用) #### 4. Plugin設定 (nyash.toml) - ConsoleBox.methodsにprintln追加(method_id=2) - method_id整合性: log=1, println=2 ### テスト結果 - ✅ esc_dirname_smoke.hako実行成功 - 旧エラー: "Unknown method 'println'" ← **完全解消** - 新出力: `[Console LOG] dir1/dir2` ### Phase 120問題解決 **Phase 120ベースラインでの課題**: - ❌ esc_dirname_smoke.hako: ConsoleBox.println未実装 **Phase 122での解決**: - ✅ TypeRegistryレベルでprintln→log正規化 - ✅ 全経路(JSON v0/selfhost/通常VM)で一貫性保証 ### ファイル構成 **新規作成**: - docs/development/current/main/phase122_consolebox_println_unification.md **修正**: - src/runtime/type_registry.rs (+5行) - src/boxes/console_box.rs (+14行, WASM/非WASM両対応) - src/backend/mir_interpreter/handlers/calls/method.rs (+60行) - nyash.toml (+1メソッド定義) - docs/development/current/main/hako_logging_design.md (+40行) - docs/development/current/main/logging_policy.md (+30行) - docs/development/current/main/core_boxes_design.md (+20行) ### 技術的成果 - **Alias First原則**: VM/TypeRegistryレベルで正規化 - **Phase 120連携**: ベースライン確立→問題発見→根本解決 - **全経路統一**: selfhost/JSON v0/通常VMすべてで動作 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 05:16:06 +09:00
Phase 122.5-126完了:ConsoleBox 品質改善・最適化・統合 ## 実装成果(Phase 122.5-126) ### Phase 122.5: nyash.toml method_id 修正 - println method_id を 2 → 1 に統一(log と同じ) - TypeRegistry slot 400 との整合性確保 ### Phase 123: ConsoleBox WASM/非WASM コード統一化 - マクロ define_console_impl! による重複排除 - 67行削減(27.3% 削減達成) - ビルド成功・全テストパス ### Phase 124: VM Method Dispatch 統一化 - TypeRegistry ベースの統一ディスパッチ (dispatch_by_slot) - String/Array/ConsoleBox を一元化 - 100行削減、メソッド解決の高速化 ### Phase 125: 削除:deprecated builtin ConsoleBox - src/box_factory/builtin_impls/console_box.rs 削除 - Plugin-only 移行で "Everything is Plugin" 実現 - 52行削減 ### Phase 126: ドキュメント統合 - consolebox_complete_guide.md (27KB統合マスター) - core_boxes_design/logging_policy/hako_logging_design 更新 - ~750行の navigation・cross-reference 改善 ## 数値成果 - **総コード削減**: 219行 - **新規ドキュメント**: 1ファイル (+27KB) - **更新ドキュメント**: 6ファイル (+~750行) - **テスト**: Phase 120 representative tests ✅ PASS - **ビルド**: Zero errors ## 設計原則の完全実現 ✅ println/log エイリアス統一(Phase 122) ✅ WASM/非WASM 統一化(Phase 123) ✅ TypeRegistry 統合(Phase 124) ✅ Plugin-only 移行(Phase 125) ✅ ドキュメント統合(Phase 126) 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 06:02:03 +09:00
fn type_name(&self) -> &'static str {
"ConsoleBox"
}
Phase 122.5-126完了:ConsoleBox 品質改善・最適化・統合 ## 実装成果(Phase 122.5-126) ### Phase 122.5: nyash.toml method_id 修正 - println method_id を 2 → 1 に統一(log と同じ) - TypeRegistry slot 400 との整合性確保 ### Phase 123: ConsoleBox WASM/非WASM コード統一化 - マクロ define_console_impl! による重複排除 - 67行削減(27.3% 削減達成) - ビルド成功・全テストパス ### Phase 124: VM Method Dispatch 統一化 - TypeRegistry ベースの統一ディスパッチ (dispatch_by_slot) - String/Array/ConsoleBox を一元化 - 100行削減、メソッド解決の高速化 ### Phase 125: 削除:deprecated builtin ConsoleBox - src/box_factory/builtin_impls/console_box.rs 削除 - Plugin-only 移行で "Everything is Plugin" 実現 - 52行削減 ### Phase 126: ドキュメント統合 - consolebox_complete_guide.md (27KB統合マスター) - core_boxes_design/logging_policy/hako_logging_design 更新 - ~750行の navigation・cross-reference 改善 ## 数値成果 - **総コード削減**: 219行 - **新規ドキュメント**: 1ファイル (+27KB) - **更新ドキュメント**: 6ファイル (+~750行) - **テスト**: Phase 120 representative tests ✅ PASS - **ビルド**: Zero errors ## 設計原則の完全実現 ✅ println/log エイリアス統一(Phase 122) ✅ WASM/非WASM 統一化(Phase 123) ✅ TypeRegistry 統合(Phase 124) ✅ Plugin-only 移行(Phase 125) ✅ ドキュメント統合(Phase 126) 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 06:02:03 +09:00
fn clone_box(&self) -> Box<dyn NyashBox> {
Box::new(self.clone())
}
Phase 122.5-126完了:ConsoleBox 品質改善・最適化・統合 ## 実装成果(Phase 122.5-126) ### Phase 122.5: nyash.toml method_id 修正 - println method_id を 2 → 1 に統一(log と同じ) - TypeRegistry slot 400 との整合性確保 ### Phase 123: ConsoleBox WASM/非WASM コード統一化 - マクロ define_console_impl! による重複排除 - 67行削減(27.3% 削減達成) - ビルド成功・全テストパス ### Phase 124: VM Method Dispatch 統一化 - TypeRegistry ベースの統一ディスパッチ (dispatch_by_slot) - String/Array/ConsoleBox を一元化 - 100行削減、メソッド解決の高速化 ### Phase 125: 削除:deprecated builtin ConsoleBox - src/box_factory/builtin_impls/console_box.rs 削除 - Plugin-only 移行で "Everything is Plugin" 実現 - 52行削減 ### Phase 126: ドキュメント統合 - consolebox_complete_guide.md (27KB統合マスター) - core_boxes_design/logging_policy/hako_logging_design 更新 - ~750行の navigation・cross-reference 改善 ## 数値成果 - **総コード削減**: 219行 - **新規ドキュメント**: 1ファイル (+27KB) - **更新ドキュメント**: 6ファイル (+~750行) - **テスト**: Phase 120 representative tests ✅ PASS - **ビルド**: Zero errors ## 設計原則の完全実現 ✅ println/log エイリアス統一(Phase 122) ✅ WASM/非WASM 統一化(Phase 123) ✅ TypeRegistry 統合(Phase 124) ✅ Plugin-only 移行(Phase 125) ✅ ドキュメント統合(Phase 126) 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 06:02:03 +09:00
fn share_box(&self) -> Box<dyn NyashBox> {
self.clone_box()
}
}
Phase 122.5-126完了:ConsoleBox 品質改善・最適化・統合 ## 実装成果(Phase 122.5-126) ### Phase 122.5: nyash.toml method_id 修正 - println method_id を 2 → 1 に統一(log と同じ) - TypeRegistry slot 400 との整合性確保 ### Phase 123: ConsoleBox WASM/非WASM コード統一化 - マクロ define_console_impl! による重複排除 - 67行削減(27.3% 削減達成) - ビルド成功・全テストパス ### Phase 124: VM Method Dispatch 統一化 - TypeRegistry ベースの統一ディスパッチ (dispatch_by_slot) - String/Array/ConsoleBox を一元化 - 100行削減、メソッド解決の高速化 ### Phase 125: 削除:deprecated builtin ConsoleBox - src/box_factory/builtin_impls/console_box.rs 削除 - Plugin-only 移行で "Everything is Plugin" 実現 - 52行削減 ### Phase 126: ドキュメント統合 - consolebox_complete_guide.md (27KB統合マスター) - core_boxes_design/logging_policy/hako_logging_design 更新 - ~750行の navigation・cross-reference 改善 ## 数値成果 - **総コード削減**: 219行 - **新規ドキュメント**: 1ファイル (+27KB) - **更新ドキュメント**: 6ファイル (+~750行) - **テスト**: Phase 120 representative tests ✅ PASS - **ビルド**: Zero errors ## 設計原則の完全実現 ✅ println/log エイリアス統一(Phase 122) ✅ WASM/非WASM 統一化(Phase 123) ✅ TypeRegistry 統合(Phase 124) ✅ Plugin-only 移行(Phase 125) ✅ ドキュメント統合(Phase 126) 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 06:02:03 +09:00
impl Display for ConsoleBox {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.fmt_box(f)
}
}
};
}
Phase 122.5-126完了:ConsoleBox 品質改善・最適化・統合 ## 実装成果(Phase 122.5-126) ### Phase 122.5: nyash.toml method_id 修正 - println method_id を 2 → 1 に統一(log と同じ) - TypeRegistry slot 400 との整合性確保 ### Phase 123: ConsoleBox WASM/非WASM コード統一化 - マクロ define_console_impl! による重複排除 - 67行削減(27.3% 削減達成) - ビルド成功・全テストパス ### Phase 124: VM Method Dispatch 統一化 - TypeRegistry ベースの統一ディスパッチ (dispatch_by_slot) - String/Array/ConsoleBox を一元化 - 100行削減、メソッド解決の高速化 ### Phase 125: 削除:deprecated builtin ConsoleBox - src/box_factory/builtin_impls/console_box.rs 削除 - Plugin-only 移行で "Everything is Plugin" 実現 - 52行削減 ### Phase 126: ドキュメント統合 - consolebox_complete_guide.md (27KB統合マスター) - core_boxes_design/logging_policy/hako_logging_design 更新 - ~750行の navigation・cross-reference 改善 ## 数値成果 - **総コード削減**: 219行 - **新規ドキュメント**: 1ファイル (+27KB) - **更新ドキュメント**: 6ファイル (+~750行) - **テスト**: Phase 120 representative tests ✅ PASS - **ビルド**: Zero errors ## 設計原則の完全実現 ✅ println/log エイリアス統一(Phase 122) ✅ WASM/非WASM 統一化(Phase 123) ✅ TypeRegistry 統合(Phase 124) ✅ Plugin-only 移行(Phase 125) ✅ ドキュメント統合(Phase 126) 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 06:02:03 +09:00
// 🌐 Browser console access Box
#[cfg(target_arch = "wasm32")]
#[derive(Debug, Clone)]
pub struct ConsoleBox {
base: BoxBase,
}
#[cfg(target_arch = "wasm32")]
Phase 122.5-126完了:ConsoleBox 品質改善・最適化・統合 ## 実装成果(Phase 122.5-126) ### Phase 122.5: nyash.toml method_id 修正 - println method_id を 2 → 1 に統一(log と同じ) - TypeRegistry slot 400 との整合性確保 ### Phase 123: ConsoleBox WASM/非WASM コード統一化 - マクロ define_console_impl! による重複排除 - 67行削減(27.3% 削減達成) - ビルド成功・全テストパス ### Phase 124: VM Method Dispatch 統一化 - TypeRegistry ベースの統一ディスパッチ (dispatch_by_slot) - String/Array/ConsoleBox を一元化 - 100行削減、メソッド解決の高速化 ### Phase 125: 削除:deprecated builtin ConsoleBox - src/box_factory/builtin_impls/console_box.rs 削除 - Plugin-only 移行で "Everything is Plugin" 実現 - 52行削減 ### Phase 126: ドキュメント統合 - consolebox_complete_guide.md (27KB統合マスター) - core_boxes_design/logging_policy/hako_logging_design 更新 - ~750行の navigation・cross-reference 改善 ## 数値成果 - **総コード削減**: 219行 - **新規ドキュメント**: 1ファイル (+27KB) - **更新ドキュメント**: 6ファイル (+~750行) - **テスト**: Phase 120 representative tests ✅ PASS - **ビルド**: Zero errors ## 設計原則の完全実現 ✅ println/log エイリアス統一(Phase 122) ✅ WASM/非WASM 統一化(Phase 123) ✅ TypeRegistry 統合(Phase 124) ✅ Plugin-only 移行(Phase 125) ✅ ドキュメント統合(Phase 126) 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 06:02:03 +09:00
define_console_impl!(
log: |msg: &str| { web_sys::console::log_1(&msg.into()); },
warn: |msg: &str| { web_sys::console::warn_1(&msg.into()); },
error: |msg: &str| { web_sys::console::error_1(&msg.into()); },
clear: || { web_sys::console::clear(); },
fmt_desc: "[ConsoleBox - Browser Console Interface]"
);
Phase 122.5-126完了:ConsoleBox 品質改善・最適化・統合 ## 実装成果(Phase 122.5-126) ### Phase 122.5: nyash.toml method_id 修正 - println method_id を 2 → 1 に統一(log と同じ) - TypeRegistry slot 400 との整合性確保 ### Phase 123: ConsoleBox WASM/非WASM コード統一化 - マクロ define_console_impl! による重複排除 - 67行削減(27.3% 削減達成) - ビルド成功・全テストパス ### Phase 124: VM Method Dispatch 統一化 - TypeRegistry ベースの統一ディスパッチ (dispatch_by_slot) - String/Array/ConsoleBox を一元化 - 100行削減、メソッド解決の高速化 ### Phase 125: 削除:deprecated builtin ConsoleBox - src/box_factory/builtin_impls/console_box.rs 削除 - Plugin-only 移行で "Everything is Plugin" 実現 - 52行削減 ### Phase 126: ドキュメント統合 - consolebox_complete_guide.md (27KB統合マスター) - core_boxes_design/logging_policy/hako_logging_design 更新 - ~750行の navigation・cross-reference 改善 ## 数値成果 - **総コード削減**: 219行 - **新規ドキュメント**: 1ファイル (+27KB) - **更新ドキュメント**: 6ファイル (+~750行) - **テスト**: Phase 120 representative tests ✅ PASS - **ビルド**: Zero errors ## 設計原則の完全実現 ✅ println/log エイリアス統一(Phase 122) ✅ WASM/非WASM 統一化(Phase 123) ✅ TypeRegistry 統合(Phase 124) ✅ Plugin-only 移行(Phase 125) ✅ ドキュメント統合(Phase 126) 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 06:02:03 +09:00
// Non-WASM版 - モックアップ実装
#[cfg(not(target_arch = "wasm32"))]
Phase 122.5-126完了:ConsoleBox 品質改善・最適化・統合 ## 実装成果(Phase 122.5-126) ### Phase 122.5: nyash.toml method_id 修正 - println method_id を 2 → 1 に統一(log と同じ) - TypeRegistry slot 400 との整合性確保 ### Phase 123: ConsoleBox WASM/非WASM コード統一化 - マクロ define_console_impl! による重複排除 - 67行削減(27.3% 削減達成) - ビルド成功・全テストパス ### Phase 124: VM Method Dispatch 統一化 - TypeRegistry ベースの統一ディスパッチ (dispatch_by_slot) - String/Array/ConsoleBox を一元化 - 100行削減、メソッド解決の高速化 ### Phase 125: 削除:deprecated builtin ConsoleBox - src/box_factory/builtin_impls/console_box.rs 削除 - Plugin-only 移行で "Everything is Plugin" 実現 - 52行削減 ### Phase 126: ドキュメント統合 - consolebox_complete_guide.md (27KB統合マスター) - core_boxes_design/logging_policy/hako_logging_design 更新 - ~750行の navigation・cross-reference 改善 ## 数値成果 - **総コード削減**: 219行 - **新規ドキュメント**: 1ファイル (+27KB) - **更新ドキュメント**: 6ファイル (+~750行) - **テスト**: Phase 120 representative tests ✅ PASS - **ビルド**: Zero errors ## 設計原則の完全実現 ✅ println/log エイリアス統一(Phase 122) ✅ WASM/非WASM 統一化(Phase 123) ✅ TypeRegistry 統合(Phase 124) ✅ Plugin-only 移行(Phase 125) ✅ ドキュメント統合(Phase 126) 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 06:02:03 +09:00
#[derive(Debug, Clone)]
pub struct ConsoleBox {
base: BoxBase,
}
Phase 122.5-126完了:ConsoleBox 品質改善・最適化・統合 ## 実装成果(Phase 122.5-126) ### Phase 122.5: nyash.toml method_id 修正 - println method_id を 2 → 1 に統一(log と同じ) - TypeRegistry slot 400 との整合性確保 ### Phase 123: ConsoleBox WASM/非WASM コード統一化 - マクロ define_console_impl! による重複排除 - 67行削減(27.3% 削減達成) - ビルド成功・全テストパス ### Phase 124: VM Method Dispatch 統一化 - TypeRegistry ベースの統一ディスパッチ (dispatch_by_slot) - String/Array/ConsoleBox を一元化 - 100行削減、メソッド解決の高速化 ### Phase 125: 削除:deprecated builtin ConsoleBox - src/box_factory/builtin_impls/console_box.rs 削除 - Plugin-only 移行で "Everything is Plugin" 実現 - 52行削減 ### Phase 126: ドキュメント統合 - consolebox_complete_guide.md (27KB統合マスター) - core_boxes_design/logging_policy/hako_logging_design 更新 - ~750行の navigation・cross-reference 改善 ## 数値成果 - **総コード削減**: 219行 - **新規ドキュメント**: 1ファイル (+27KB) - **更新ドキュメント**: 6ファイル (+~750行) - **テスト**: Phase 120 representative tests ✅ PASS - **ビルド**: Zero errors ## 設計原則の完全実現 ✅ println/log エイリアス統一(Phase 122) ✅ WASM/非WASM 統一化(Phase 123) ✅ TypeRegistry 統合(Phase 124) ✅ Plugin-only 移行(Phase 125) ✅ ドキュメント統合(Phase 126) 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 06:02:03 +09:00
#[cfg(not(target_arch = "wasm32"))]
define_console_impl!(
log: |msg: &str| { println!("[Console LOG] {}", msg); },
warn: |msg: &str| { println!("[Console WARN] {}", msg); },
error: |msg: &str| { println!("[Console ERROR] {}", msg); },
clear: || { println!("[Console CLEAR]"); },
fmt_desc: "[ConsoleBox - Mock Implementation]"
);