use serde::{Serialize, Deserialize}; use shm_rs::lexer::lexer; use shm_rs::scheme_composer::composer::from_struct; use shm_rs::serializator::serializator; use shm_rs::static_scheme::init; use shm_rs::dynamic_scheme::environment; pub const AUTO: u64 = 0; #[derive(Debug, Serialize, Deserialize)] pub enum TestUseEnum { Yellow, Red, Green, ColorRgb(u64, u64, u64), ColorRgbaProfile{ profile_name: String, col_r: u64, col_g: u64, col_b: u64, col_a: u64 } } pub fn main() { let mut curdir = std::env::current_dir().unwrap(); curdir.push("examples/struct_to_scheme/enum_proc/init_use1.shm"); println!("{}", curdir.display()); let lex = lexer::Lexer::from_file(curdir).unwrap(); let schm = init::SchemeInit::new().unwrap(); let res = schm.run(&lex, None).unwrap(); let resser = res.get("use1").unwrap().clone(); println!("Static: \n{:?}\n", res); let mut curdir = std::env::current_dir().unwrap(); curdir.push("examples/struct_to_scheme/enum_proc/init_use_dyn1.shm"); let lex = lexer::Lexer::from_file(curdir).unwrap(); let dynenv = environment::DynEnvironment::new_root(resser.clone()).unwrap(); let dynres = environment::DynEnvironment::run(&lex, dynenv).unwrap(); let ret = serializator::Serialization::serialize(resser.clone(), dynres.clone()).unwrap(); let serialized = serde_json::to_string(&ret).unwrap(); let n: TestUseEnum = serde_json::from_str(&serialized).unwrap(); let resser = from_struct(n, resser); println!("result:"); if resser.is_err() == true { panic!("{}", resser.err().unwrap()); } else { println!("{}", resser.unwrap()); } }