diff --git a/local_tests/test_filebox_v2.nyash b/local_tests/test_filebox_v2.nyash new file mode 100644 index 00000000..49b1bc48 --- /dev/null +++ b/local_tests/test_filebox_v2.nyash @@ -0,0 +1,13 @@ +// FileBox v2プラグインシステムテスト +print("=== FileBox v2 Plugin Test ===") + +// FileBoxを生成してみる +print("Creating FileBox instance...") +local fileBox +fileBox = new FileBox() + +// ファイル情報を表示 +print("FileBox created: " + fileBox.toString()) + +// とりあえずここまでで動作確認 +print("=== Test completed ===") \ No newline at end of file diff --git a/src/bid/generic_plugin_box.rs b/src/bid/generic_plugin_box.rs index 57dfd576..1d1d32bf 100644 --- a/src/bid/generic_plugin_box.rs +++ b/src/bid/generic_plugin_box.rs @@ -109,15 +109,9 @@ impl NyashBox for GenericPluginBox { } fn clone_box(&self) -> Box { - // 新しいインスタンスを作成 - if let Some(reg) = crate::bid::registry::global() { - if let Some(plugin) = reg.get_by_name(&self.box_name) { - if let Ok(new_box) = GenericPluginBox::birth(plugin, self.box_name.clone()) { - return Box::new(new_box); - } - } - } - Box::new(StringBox::new("")) + // v2 plugin system migration: simplified clone for now + // TODO: Implement proper cloning through v2 plugin loader + Box::new(StringBox::new(format!("{}(plugin-clone)", self.box_name))) } fn share_box(&self) -> Box { diff --git a/src/bid/mod.rs b/src/bid/mod.rs index bf3f2382..92fb33e1 100644 --- a/src/bid/mod.rs +++ b/src/bid/mod.rs @@ -9,7 +9,7 @@ pub mod plugin_api; pub mod bridge; pub mod plugins; pub mod loader; -pub mod registry; +// pub mod registry; // legacy - v2 plugin system uses BoxFactoryRegistry instead // pub mod plugin_box; // legacy - FileBox専用実装 pub mod generic_plugin_box; @@ -20,7 +20,7 @@ pub use metadata::*; pub use plugin_api::*; pub use bridge::*; pub use loader::*; -pub use registry::*; +// pub use registry::*; // legacy - v2 plugin system uses BoxFactoryRegistry instead // pub use plugin_box::*; // legacy pub use generic_plugin_box::*; diff --git a/src/interpreter/objects.rs b/src/interpreter/objects.rs index 095badb6..6b222e18 100644 --- a/src/interpreter/objects.rs +++ b/src/interpreter/objects.rs @@ -640,6 +640,7 @@ impl NyashInterpreter { }); } + /* v2 plugin system migration - old BID registry disabled // 🚀 プラグインレジストリをチェック(nyash.tomlから動的) let plugin_exists = if let Some(reg) = crate::bid::registry::global() { reg.get_by_name(class).is_some() @@ -664,6 +665,14 @@ impl NyashInterpreter { if plugin_exists { if let Some(reg) = crate::bid::registry::global() { if let Some(plugin) = reg.get_by_name(class) { + */ + + // ユーザー定義Box宣言をチェック + let user_defined_exists = { + let box_decls = self.shared.box_declarations.read().unwrap(); + box_decls.contains_key(class) + }; + /* continuing old BID registry code - disabled for v2 // プラグイン版:引数なしでbirthメソッド呼び出し(nyash.tomlに従う) if arguments.len() == 0 { // 汎用プラグインBox生成システム @@ -682,6 +691,7 @@ impl NyashInterpreter { } } } + */ // ユーザー定義Box宣言を探す if user_defined_exists { diff --git a/src/lib.rs b/src/lib.rs index 342deba9..da29e7df 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -48,6 +48,9 @@ pub mod bid; // Configuration system pub mod config; +// CLI system +pub mod cli; + // Runtime system (plugins, registry, etc.) pub mod runtime; diff --git a/src/main.rs b/src/main.rs index 34de4254..a1dfce66 100644 --- a/src/main.rs +++ b/src/main.rs @@ -45,7 +45,7 @@ pub mod runner; // BID-FFI / Plugin System (prototype) pub mod bid; -use cli::CliConfig; +use nyash_rust::cli::CliConfig; use runner::NyashRunner; /// Thin entry point - delegates to CLI parsing and runner execution diff --git a/src/runner.rs b/src/runner.rs index 920fb5ac..ddbc526d 100644 --- a/src/runner.rs +++ b/src/runner.rs @@ -5,8 +5,8 @@ * separated from CLI parsing and the main entry point. */ -use crate::cli::CliConfig; -use crate::{ +use nyash_rust::cli::CliConfig; +use nyash_rust::{ box_trait::{NyashBox, StringBox, IntegerBox, BoolBox, VoidBox, AddBox, BoxCore}, tokenizer::{NyashTokenizer}, ast::ASTNode, @@ -17,11 +17,11 @@ use crate::{ }; #[cfg(feature = "llvm")] -use crate::backend::{llvm_compile_and_execute}; +use nyash_rust::backend::{llvm_compile_and_execute}; use std::{fs, process}; // v2 plugin system imports -use crate::runtime::init_global_loader_v2; +use nyash_rust::runtime::{init_global_loader_v2, get_global_registry, get_global_loader_v2, PluginConfig}; /// Main execution coordinator pub struct NyashRunner { @@ -57,7 +57,7 @@ impl NyashRunner { } fn init_bid_plugins(&self) { - // Best-effort init; do not fail the program if missing + // v2プラグインシステムを初期化 eprintln!("🔍 DEBUG: Initializing v2 plugin system"); // Try to load nyash.toml configuration @@ -65,8 +65,6 @@ impl NyashRunner { println!("🔌 v2 plugin system initialized from nyash.toml"); // Apply plugin configuration to the box registry - use crate::runtime::{get_global_registry, get_global_loader_v2}; - let loader = get_global_loader_v2(); let loader = loader.read().unwrap(); @@ -78,11 +76,13 @@ impl NyashRunner { for box_name in &lib_def.boxes { eprintln!(" 📦 Registering plugin provider for {}", box_name); // Note: plugin_name is lib_name in v2 system - registry.apply_plugin_config(&crate::runtime::PluginConfig { + registry.apply_plugin_config(&PluginConfig { plugins: [(box_name.clone(), lib_name.clone())].into(), }); } } + + println!("✅ v2 plugin system fully configured"); } } else { eprintln!("⚠️ Failed to load nyash.toml - plugins disabled");