feat(phase-9.75g-0): Implement BID-FFI Day 3 - Box type integration
- Implement BID Box Bridge interface for Nyash Box <-> BID Handle conversion - Add StringBox BID bridge implementation with handle/TLV support - Add IntegerBox BID bridge implementation with handle/TLV support - Implement BoxRegistry for managing Box instances and handles - Add comprehensive tests for StringBox/IntegerBox BID round-trip - Extract helper functions for string/integer value extraction Everything is Box philosophy shines through unified BID integration! 🎉 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -38,6 +38,7 @@
|
||||
*/
|
||||
|
||||
use crate::box_trait::{NyashBox, BoxCore, BoxBase};
|
||||
use crate::bid::{BidBridge, BidHandle, BidType, BidError, BoxRegistry};
|
||||
use std::any::Any;
|
||||
use std::fmt::Display;
|
||||
|
||||
@ -116,4 +117,23 @@ impl Display for IntegerBox {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
self.fmt_box(f)
|
||||
}
|
||||
}
|
||||
|
||||
impl BidBridge for IntegerBox {
|
||||
fn to_bid_handle(&self, registry: &mut BoxRegistry) -> Result<BidHandle, BidError> {
|
||||
use std::sync::Arc;
|
||||
let arc_box: Arc<dyn NyashBox> = Arc::new(self.clone());
|
||||
let handle = registry.register_box(
|
||||
crate::bid::types::BoxTypeId::IntegerBox as u32,
|
||||
arc_box
|
||||
);
|
||||
Ok(handle)
|
||||
}
|
||||
|
||||
fn bid_type(&self) -> BidType {
|
||||
BidType::Handle {
|
||||
type_id: crate::bid::types::BoxTypeId::IntegerBox as u32,
|
||||
instance_id: 0 // Will be filled by registry
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -28,6 +28,7 @@
|
||||
* ```
|
||||
*/
|
||||
use crate::box_trait::{NyashBox, BoxCore, BoxBase};
|
||||
use crate::bid::{BidBridge, BidHandle, BidType, BidError, BoxRegistry};
|
||||
use std::any::Any;
|
||||
use std::fmt::Display;
|
||||
|
||||
@ -184,4 +185,23 @@ impl Display for StringBox {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
self.fmt_box(f)
|
||||
}
|
||||
}
|
||||
|
||||
impl BidBridge for StringBox {
|
||||
fn to_bid_handle(&self, registry: &mut BoxRegistry) -> Result<BidHandle, BidError> {
|
||||
use std::sync::Arc;
|
||||
let arc_box: Arc<dyn NyashBox> = Arc::new(self.clone());
|
||||
let handle = registry.register_box(
|
||||
crate::bid::types::BoxTypeId::StringBox as u32,
|
||||
arc_box
|
||||
);
|
||||
Ok(handle)
|
||||
}
|
||||
|
||||
fn bid_type(&self) -> BidType {
|
||||
BidType::Handle {
|
||||
type_id: crate::bid::types::BoxTypeId::StringBox as u32,
|
||||
instance_id: 0 // Will be filled by registry
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user