🔧 refactor: すべてのBoxをArc<Mutex>パターンで統一
CopilotのBox実装を私たちのArc<Mutex>パターンで統一: - BufferBox: Arc<Mutex<Vec<u8>>>で内部可変性を実現 - FileBox: Arc<Mutex<File>>でファイルハンドル管理 - JSONBox: Arc<Mutex<Value>>でJSON値を保持 - HttpClientBox: Arc<Mutex<Client>>でHTTPクライアント管理 - StreamBox: Arc<Mutex>でストリームバッファと位置を管理 - RegexBox: Arc<Regex>で軽量ラッパー実装 各Boxに実用的なメソッドも追加: - BufferBox: write, read, readAll, clear, length, append, slice - FileBox: read, write, exists, delete, copy - JSONBox: parse, stringify, get, set, has, keys - HttpClientBox: get, post, put, delete, request - StreamBox: write, read, position, length, reset - RegexBox: test, find, findAll, replace, split interpreterに新Box用のメソッド実行を追加: - data_methods.rs: BufferBox, JSONBox, RegexBox - network_methods.rs: HttpClientBox, StreamBox これでコードベース全体が一貫性のあるArc<Mutex>パターンで統一されました! 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -8,6 +8,7 @@
|
||||
|
||||
use super::*;
|
||||
use crate::ast::UnaryOperator;
|
||||
use crate::boxes::{BufferBox, JSONBox, HttpClientBox, StreamBox, RegexBox};
|
||||
// TODO: Fix NullBox import issue later
|
||||
// use crate::NullBox;
|
||||
|
||||
@ -326,6 +327,11 @@ impl NyashInterpreter {
|
||||
return self.execute_array_method(array_box, method, arguments);
|
||||
}
|
||||
|
||||
// BufferBox method calls
|
||||
if let Some(buffer_box) = obj_value.as_any().downcast_ref::<BufferBox>() {
|
||||
return self.execute_buffer_method(buffer_box, method, arguments);
|
||||
}
|
||||
|
||||
// FileBox method calls
|
||||
if let Some(file_box) = obj_value.as_any().downcast_ref::<FileBox>() {
|
||||
return self.execute_file_method(file_box, method, arguments);
|
||||
@ -346,6 +352,26 @@ impl NyashInterpreter {
|
||||
return self.execute_channel_method(channel_box, method, arguments);
|
||||
}
|
||||
|
||||
// JSONBox method calls
|
||||
if let Some(json_box) = obj_value.as_any().downcast_ref::<JSONBox>() {
|
||||
return self.execute_json_method(json_box, method, arguments);
|
||||
}
|
||||
|
||||
// HttpClientBox method calls
|
||||
if let Some(http_box) = obj_value.as_any().downcast_ref::<HttpClientBox>() {
|
||||
return self.execute_http_method(http_box, method, arguments);
|
||||
}
|
||||
|
||||
// StreamBox method calls
|
||||
if let Some(stream_box) = obj_value.as_any().downcast_ref::<StreamBox>() {
|
||||
return self.execute_stream_method(stream_box, method, arguments);
|
||||
}
|
||||
|
||||
// RegexBox method calls
|
||||
if let Some(regex_box) = obj_value.as_any().downcast_ref::<RegexBox>() {
|
||||
return self.execute_regex_method(regex_box, method, arguments);
|
||||
}
|
||||
|
||||
// MathBox method calls
|
||||
if let Some(math_box) = obj_value.as_any().downcast_ref::<MathBox>() {
|
||||
return self.execute_math_method(math_box, method, arguments);
|
||||
|
||||
Reference in New Issue
Block a user