Working on solution to Rocket state problem

This commit is contained in:
greg 2017-10-26 22:54:13 -07:00
parent 9379485713
commit ae02391270
2 changed files with 15 additions and 3 deletions

View File

@ -38,6 +38,8 @@ include!(concat!(env!("OUT_DIR"), "/static.rs"));
#[link_args="-ltinfo"]
extern { }
type PLIGenerator = Box<Fn() -> Box<ProgrammingLanguageInterface>>;
fn main() {
let languages: Vec<Box<ProgrammingLanguageInterface>> =
vec![
@ -45,6 +47,16 @@ fn main() {
Box::new(maaru_lang::Maaru::new()),
Box::new(robo_lang::Robo::new()),
];
let languages2: Vec<Box<ProgrammingLanguageInterface>> =
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<ProgrammingLanguageInterface> = Box::new(schala_lang::Schala::new()); x });
webapp::web_main(languages2, func);
schala_main(languages);
}
@ -68,7 +80,7 @@ fn schala_main(languages: Vec<Box<ProgrammingLanguageInterface>>) {
}
if option_matches.opt_present("webapp") {
webapp::web_main(languages);
//webapp::web_main(languages);
exit(0);
}

View File

@ -5,7 +5,7 @@ use rocket_contrib::Json;
use schala_lang;
use language::{ProgrammingLanguageInterface, EvalOptions};
use WEBFILES;
use ::PLIGenerator;
#[get("/")]
fn index() -> Content<String> {
@ -38,6 +38,6 @@ fn interpreter_input(input: Json<Input>) -> Json<Output> {
Json(Output { text: code_output.to_string() })
}
pub fn web_main(languages: Vec<Box<ProgrammingLanguageInterface>>) {
pub fn web_main(language_generators: Vec<Box<ProgrammingLanguageInterface>>, func: PLIGenerator) {
rocket::ignite().mount("/", routes![index, js_bundle, interpreter_input]).launch();
}