use serde::{Serialize, Deserialize}; use shm_rs::static_scheme::generator::RustCode; use shm_rs::static_scheme::init; use shm_rs::dynamic_scheme::environment; use shm_rs::serializator::serializator; #[derive(Clone, Debug, Serialize, Deserialize)] pub struct CfgCharacterComposer { pub cc_external_chars: Option> } fn main() { let curdir = std::env::current_dir().unwrap(); println!("{}", curdir.display()); let schm = init::SchemeInit::new_with_path(curdir).unwrap(); let res = schm.run_from_file("examples/scheme_vector_proc/init.shm", None).unwrap(); let resser = res.get("use1").unwrap().clone(); let mut curdir = std::env::current_dir().unwrap(); curdir.push("examples/scheme_vector_proc/dyn.shm"); // let lex = lexer::Lexer::from_file(curdir).unwrap(); let (_dynenv, dyn_res) = environment::DynEnvironment::from_file(curdir, resser.clone()).unwrap(); // let dynenv = environment::DynEnvironment::new_root(resser.clone()); //let dyn_res = environment::DynEnvironment::run(&lex, dynenv).unwrap(); let ret = serializator::Serialization::serialize(resser.clone(), dyn_res.clone()).unwrap(); let serialized = serde_json::to_string(&ret).unwrap(); println!("Result:\n{}", serialized); let local_inst = CfgCharacterComposer { cc_external_chars: Some( vec![ "characters/descr/lena.shm".to_string(), "characters/descr/slav.shm".to_string(), "characters/descr/alis.shm".to_string(), "characters/descr/miku.shm".to_string(), "characters/descr/ulya.shm".to_string(), "characters/descr/zhen.shm".to_string(), ] ) }; let local_inst_ser = serde_json::to_string(&local_inst).unwrap(); assert_eq!(local_inst_ser.as_str(), serialized); /*let deserialized: TestUseEnum = serde_json::from_str(&serialized).unwrap(); println!("Deserialized result: \n{:?}", deserialized);*/ let mut rc = RustCode::new(&["Clone", "Debug", "Serialize", "Deserialize"], &["Clone", "Debug", "Serialize", "Deserialize"]); println!("Structures: "); match resser.generate_rust_structs(&mut rc) { Ok(_) => { println!("{}", rc); }, Err(e) => { println!("{}", e); } } }