From ae02391270aca02e17c13dded2dc725ff448c850 Mon Sep 17 00:00:00 2001 From: greg Date: Thu, 26 Oct 2017 22:54:13 -0700 Subject: [PATCH] Working on solution to Rocket state problem --- src/main.rs | 14 +++++++++++++- src/webapp.rs | 4 ++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 25b5542..10f9cdd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -38,6 +38,8 @@ include!(concat!(env!("OUT_DIR"), "/static.rs")); #[link_args="-ltinfo"] extern { } +type PLIGenerator = Box Box>; + fn main() { let languages: Vec> = vec![ @@ -45,6 +47,16 @@ 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 }); + + webapp::web_main(languages2, func); schala_main(languages); } @@ -68,7 +80,7 @@ fn schala_main(languages: Vec>) { } if option_matches.opt_present("webapp") { - webapp::web_main(languages); + //webapp::web_main(languages); exit(0); } diff --git a/src/webapp.rs b/src/webapp.rs index 303aea5..70c259f 100644 --- a/src/webapp.rs +++ b/src/webapp.rs @@ -5,7 +5,7 @@ use rocket_contrib::Json; use schala_lang; use language::{ProgrammingLanguageInterface, EvalOptions}; use WEBFILES; - +use ::PLIGenerator; #[get("/")] fn index() -> Content { @@ -38,6 +38,6 @@ fn interpreter_input(input: Json) -> Json { Json(Output { text: code_output.to_string() }) } -pub fn web_main(languages: Vec>) { +pub fn web_main(language_generators: Vec>, func: PLIGenerator) { rocket::ignite().mount("/", routes![index, js_bundle, interpreter_input]).launch(); }