🚀 feat: NewP2PBox天才アルゴリズム完全実装 - P2P通信革命達成
## 🧠 天才アルゴリズム実装 - ローカル配送: MessageBus経由(爆速) - リモート配送: Transport経由(柔軟) - 完全自動判別・透明処理 ## 📡 実装完了機能 1. NewP2PBox本体(天才アルゴリズム内蔵) 2. MessageBusシングルトン(高速ローカル配送) 3. Transport trait抽象化(InProcess/WebSocket/WebRTC) 4. MethodBox統合(Nyash側コールバック) 5. インタープリター完全統合 ## ✅ 動作確認済み - Rustクロージャ版: 全機能完璧動作 - MethodBox統合: コールバック正常動作 - インタープリター統合: Nyashから直接利用可能 ## 🎯 利用可能Nyash構文 ```nyash alice = new NewP2PBox("alice", "InProcess") msg = new MessageIntentBox("greeting") msg.set("text", "Hello\!") alice.send("bob", msg) bob.onMethod("greeting", handler) ``` 🎉 NyaMeshP2Pライブラリの基盤完成!次はP2PBoxデリゲート実装へ 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
|
||||
use super::*;
|
||||
use crate::ast::UnaryOperator;
|
||||
use crate::boxes::{buffer::BufferBox, JSONBox, HttpClientBox, StreamBox, RegexBox, IntentBox, P2PBox};
|
||||
use crate::boxes::{buffer::BufferBox, JSONBox, HttpClientBox, StreamBox, RegexBox, IntentBox, P2PBox, NewP2PBox, MessageIntentBox};
|
||||
use crate::boxes::{MathBox, ConsoleBox, TimeBox, RandomBox, SoundBox, DebugBox, file::FileBox, MapBox};
|
||||
use crate::operator_traits::OperatorResolver;
|
||||
// TODO: Fix NullBox import issue later
|
||||
@ -747,7 +747,7 @@ impl NyashInterpreter {
|
||||
"TimeBox" | "DateTimeBox" | "TimerBox" | "RandomBox" | "SoundBox" |
|
||||
"DebugBox" | "MethodBox" | "NullBox" | "ConsoleBox" | "FloatBox" |
|
||||
"BufferBox" | "RegexBox" | "JSONBox" | "StreamBox" | "HTTPClientBox" |
|
||||
"IntentBox" | "P2PBox" | "EguiBox"
|
||||
"IntentBox" | "P2PBox" | "NewP2PBox" | "MessageIntentBox" | "EguiBox"
|
||||
);
|
||||
|
||||
if is_builtin {
|
||||
@ -905,7 +905,7 @@ impl NyashInterpreter {
|
||||
}
|
||||
|
||||
/// 🔥 ビルトインBoxのメソッド呼び出し
|
||||
fn execute_builtin_box_method(&mut self, parent: &str, method: &str, current_instance: Box<dyn NyashBox>, arguments: &[ASTNode])
|
||||
fn execute_builtin_box_method(&mut self, parent: &str, method: &str, mut current_instance: Box<dyn NyashBox>, arguments: &[ASTNode])
|
||||
-> Result<Box<dyn NyashBox>, RuntimeError> {
|
||||
|
||||
// ビルトインBoxのインスタンスを作成または取得
|
||||
@ -941,6 +941,26 @@ impl NyashInterpreter {
|
||||
message: format!("P2PBox delegation not yet fully implemented: {}.{}", parent, method),
|
||||
});
|
||||
}
|
||||
"NewP2PBox" => {
|
||||
// NewP2PBoxの場合、current_instanceから実際のNewP2PBoxインスタンスを取得
|
||||
if let Some(p2p_box) = current_instance.as_any().downcast_ref::<NewP2PBox>() {
|
||||
self.execute_new_p2p_box_method(p2p_box, method, arguments)
|
||||
} else {
|
||||
Err(RuntimeError::TypeError {
|
||||
message: format!("Expected NewP2PBox instance for method call {}.{}", parent, method),
|
||||
})
|
||||
}
|
||||
}
|
||||
"MessageIntentBox" => {
|
||||
// MessageIntentBoxの場合、current_instanceから実際のMessageIntentBoxインスタンスを取得
|
||||
if let Some(message_box) = current_instance.as_any_mut().downcast_mut::<MessageIntentBox>() {
|
||||
self.execute_message_intent_box_method(message_box, method, arguments)
|
||||
} else {
|
||||
Err(RuntimeError::TypeError {
|
||||
message: format!("Expected MessageIntentBox instance for method call {}.{}", parent, method),
|
||||
})
|
||||
}
|
||||
}
|
||||
"FileBox" => {
|
||||
let file_box = crate::boxes::file::FileBox::new();
|
||||
self.execute_file_method(&file_box, method, arguments)
|
||||
|
||||
Reference in New Issue
Block a user