diff --git a/src/main.rs b/src/main.rs index 7518f52..36772b3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -47,20 +47,17 @@ fn main() { Box::new(maaru_lang::Maaru::new()), Box::new(robo_lang::Robo::new()), ]; - let languages2: Vec> = - vec![ - Box::new(schala_lang::Schala::new()), - Box::new(maaru_lang::Maaru::new()), - Box::new(robo_lang::Robo::new()), - ]; - let func = Box::new(|| { let x: Box = Box::new(schala_lang::Schala::new()); x }); + let generators: Vec = vec![ + Box::new(|| { let x: Box = Box::new(schala_lang::Schala::new()); x }), + Box::new(|| { let x: Box = Box::new(maaru_lang::Maaru::new()); x }), + Box::new(|| { let x: Box = Box::new(robo_lang::Robo::new()); x }), + ]; - webapp::web_main(languages2, func); - schala_main(languages); + schala_main(languages, generators); } -fn schala_main(languages: Vec>) { +fn schala_main(languages: Vec>, generators: Vec) { let option_matches = program_options().parse(std::env::args()).unwrap_or_else(|e| { println!("{:?}", e); @@ -80,7 +77,7 @@ fn schala_main(languages: Vec>) { } if option_matches.opt_present("webapp") { - //webapp::web_main(languages); + webapp::web_main(languages, generators); exit(0); } diff --git a/src/webapp.rs b/src/webapp.rs index 11120ed..1918f55 100644 --- a/src/webapp.rs +++ b/src/webapp.rs @@ -32,12 +32,12 @@ struct Output { } #[post("/input", format = "application/json", data = "")] -fn interpreter_input(input: Json, schala_gen: State) -> Json { - let mut schala: Box = schala_gen(); +fn interpreter_input(input: Json, schala_gen: State>) -> Json { + let mut schala: Box = (schala_gen.get(0).unwrap())(); let code_output = schala.evaluate_in_repl(&input.source, &EvalOptions::default()); Json(Output { text: code_output.to_string() }) } -pub fn web_main(language_generators: Vec>, func: PLIGenerator) { +pub fn web_main(language_generators: Vec>, func: Vec) { rocket::ignite().manage(func).mount("/", routes![index, js_bundle, interpreter_input]).launch(); }