Finally removed schala dependency

Now need to clena up everything
This commit is contained in:
greg 2017-10-29 03:41:40 -07:00
parent 1d9d0c4395
commit 708c0ab103

View File

@ -3,7 +3,6 @@ use rocket::State;
use rocket::response::Content; use rocket::response::Content;
use rocket::http::ContentType; use rocket::http::ContentType;
use rocket_contrib::Json; use rocket_contrib::Json;
use schala_lang;
use language::{ProgrammingLanguageInterface, EvalOptions}; use language::{ProgrammingLanguageInterface, EvalOptions};
use WEBFILES; use WEBFILES;
use ::PLIGenerator; use ::PLIGenerator;
@ -34,14 +33,12 @@ struct Output {
} }
#[post("/input", format = "application/json", data = "<input>")] #[post("/input", format = "application/json", data = "<input>")]
fn interpreter_input(input: Json<Input>) -> Json<Output> { fn interpreter_input(input: Json<Input>, schala_gen: State<Mutex<PLIGenerator>>) -> Json<Output> {
let mut schala = schala_lang::Schala::new(); let mut schala: Box<ProgrammingLanguageInterface> = schala_gen.lock().unwrap()();
let code_output = schala.evaluate_in_repl(&input.source, &EvalOptions::default()); let code_output = schala.evaluate_in_repl(&input.source, &EvalOptions::default());
Json(Output { text: code_output.to_string() }) Json(Output { text: code_output.to_string() })
} }
pub fn web_main(language_generators: Vec<Box<ProgrammingLanguageInterface>>, func: PLIGenerator) { pub fn web_main(language_generators: Vec<Box<ProgrammingLanguageInterface>>, func: PLIGenerator) {
let wrapped_func = Mutex::new(func); rocket::ignite().manage(Mutex::new(func)).mount("/", routes![index, js_bundle, interpreter_input]).launch();
//let wrapped_func = Box::new(|| { 5 });
rocket::ignite().manage(wrapped_func).mount("/", routes![index, js_bundle, interpreter_input]).launch();
} }