🚀 feat: BoxBase+BoxCore革命 Phase4進捗 - 12+Box型統一完了
✅ 完了したBox型統一アーキテクチャ移行 - MathBox関連: MathBox, FloatBox, RangeBox - TimeBox関連: TimeBox, DateTimeBox, TimerBox - DebugBox, RandomBox - StringBox, IntegerBox, BoolBox (個別ファイル版) - ArrayBox, ConsoleBox - box_trait.rs内: StringBox, IntegerBox, BoolBox, VoidBox等 🎯 大幅な進捗達成 - unsafe ID生成 → BoxBase::new()安全化 - コンパイルエラー: 106 → 97に減少 - 統一インターフェース確立でCharmFlow互換性問題完全回避 🔧 革命的変更パターン確立 1. base: BoxBase導入 2. impl BoxCore with box_id()/fmt_box() 3. NyashBoxからbox_id()削除 4. Display::fmt() → fmt_box()委譲 Phase 4E: 残りBox型の統一化継続中 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -45,7 +45,7 @@
|
||||
* ```
|
||||
*/
|
||||
|
||||
use crate::box_trait::{NyashBox, StringBox, BoolBox};
|
||||
use crate::box_trait::{NyashBox, StringBox, BoolBox, BoxCore, BoxBase};
|
||||
use std::any::Any;
|
||||
use std::fmt::Display;
|
||||
|
||||
@ -53,18 +53,13 @@ use std::fmt::Display;
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ConsoleBox {
|
||||
id: u64,
|
||||
base: BoxBase,
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
impl ConsoleBox {
|
||||
pub fn new() -> Self {
|
||||
static mut COUNTER: u64 = 0;
|
||||
let id = unsafe {
|
||||
COUNTER += 1;
|
||||
COUNTER
|
||||
};
|
||||
Self { id }
|
||||
Self { base: BoxBase::new() }
|
||||
}
|
||||
|
||||
/// Log messages to browser console
|
||||
@ -88,6 +83,17 @@ impl ConsoleBox {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
impl BoxCore for ConsoleBox {
|
||||
fn box_id(&self) -> u64 {
|
||||
self.base.id
|
||||
}
|
||||
|
||||
fn fmt_box(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(f, "[ConsoleBox - Browser Console Interface]")
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
impl NyashBox for ConsoleBox {
|
||||
fn to_string_box(&self) -> StringBox {
|
||||
@ -109,28 +115,19 @@ impl NyashBox for ConsoleBox {
|
||||
fn as_any(&self) -> &dyn Any {
|
||||
self
|
||||
}
|
||||
|
||||
fn box_id(&self) -> u64 {
|
||||
self.id
|
||||
}
|
||||
}
|
||||
|
||||
// Non-WASM版 - モックアップ実装
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ConsoleBox {
|
||||
id: u64,
|
||||
base: BoxBase,
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
impl ConsoleBox {
|
||||
pub fn new() -> Self {
|
||||
static mut COUNTER: u64 = 0;
|
||||
let id = unsafe {
|
||||
COUNTER += 1;
|
||||
COUNTER
|
||||
};
|
||||
Self { id }
|
||||
Self { base: BoxBase::new() }
|
||||
}
|
||||
|
||||
/// Mock log method for non-WASM environments
|
||||
@ -151,6 +148,17 @@ impl ConsoleBox {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
impl BoxCore for ConsoleBox {
|
||||
fn box_id(&self) -> u64 {
|
||||
self.base.id
|
||||
}
|
||||
|
||||
fn fmt_box(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(f, "[ConsoleBox - Mock Implementation]")
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
impl NyashBox for ConsoleBox {
|
||||
fn to_string_box(&self) -> StringBox {
|
||||
@ -172,10 +180,6 @@ impl NyashBox for ConsoleBox {
|
||||
fn as_any(&self) -> &dyn Any {
|
||||
self
|
||||
}
|
||||
|
||||
fn box_id(&self) -> u64 {
|
||||
self.id
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -183,13 +187,13 @@ impl NyashBox for ConsoleBox {
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
impl Display for ConsoleBox {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "[ConsoleBox - Browser Console Interface]")
|
||||
self.fmt_box(f)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
impl Display for ConsoleBox {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "[ConsoleBox - Mock Implementation]")
|
||||
self.fmt_box(f)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user