mirror of
https://github.com/lune-org/lune.git
synced 2024-12-12 04:50:36 +00:00
Revert some unnecessary stylistic changes
This commit is contained in:
parent
df4fb9be91
commit
93fa14d832
5 changed files with 13 additions and 18 deletions
|
@ -27,13 +27,10 @@ pub fn add_methods<'lua, M: LuaUserDataMethods<'lua, Instance>>(methods: &mut M)
|
|||
}
|
||||
|
||||
fn get_or_create_material_colors(instance: &Instance) -> MaterialColors {
|
||||
if let Variant::MaterialColors(inner) = instance
|
||||
.get_property("MaterialColors")
|
||||
.unwrap_or(Variant::MaterialColors(MaterialColors::default()))
|
||||
{
|
||||
if let Some(Variant::MaterialColors(inner)) = instance.get_property("MaterialColors") {
|
||||
inner
|
||||
} else {
|
||||
unreachable!()
|
||||
MaterialColors::default()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,9 +7,10 @@ use tokio::{
|
|||
io::{stdin, AsyncReadExt as _},
|
||||
};
|
||||
|
||||
use super::utils::files::{discover_script_path_including_lune_dirs, strip_shebang};
|
||||
use lune::Runtime;
|
||||
|
||||
use super::utils::files::{discover_script_path_including_lune_dirs, strip_shebang};
|
||||
|
||||
/// Run a script
|
||||
#[derive(Debug, Clone, Parser)]
|
||||
pub struct RunCommand {
|
||||
|
@ -39,11 +40,13 @@ impl RunCommand {
|
|||
(file_display_name, file_contents)
|
||||
};
|
||||
|
||||
// Create a new lune object with all globals & run the script
|
||||
let mut runtime = Runtime::new().with_args(self.script_args);
|
||||
let result = runtime
|
||||
// Create a new lune runtime with all globals & run the script
|
||||
let mut rt = Runtime::new().with_args(self.script_args);
|
||||
|
||||
let result = rt
|
||||
.run(&script_display_name, strip_shebang(script_contents))
|
||||
.await;
|
||||
|
||||
Ok(match result {
|
||||
Err(err) => {
|
||||
eprintln!("{err}");
|
||||
|
|
|
@ -144,7 +144,6 @@ impl Runtime {
|
|||
script_name: impl AsRef<str>,
|
||||
script_contents: impl AsRef<[u8]>,
|
||||
) -> RuntimeResult<(u8, Vec<LuaValue>)> {
|
||||
// Create a new scheduler for this run
|
||||
let lua = self.inner.lua();
|
||||
let sched = self.inner.scheduler();
|
||||
|
||||
|
@ -165,17 +164,16 @@ impl Runtime {
|
|||
let main_thread_id = sched.push_thread_back(main, ())?;
|
||||
sched.run().await;
|
||||
|
||||
let thread_res = match sched.get_thread_result(main_thread_id) {
|
||||
let main_thread_res = match sched.get_thread_result(main_thread_id) {
|
||||
Some(res) => res,
|
||||
None => LuaValue::Nil.into_lua_multi(lua),
|
||||
}?
|
||||
.into_vec();
|
||||
}?;
|
||||
|
||||
Ok((
|
||||
sched
|
||||
.get_exit_code()
|
||||
.unwrap_or(u8::from(got_any_error.load(Ordering::SeqCst))),
|
||||
thread_res,
|
||||
main_thread_res.into_vec(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ pub async fn run(patched_bin: impl AsRef<[u8]>) -> Result<ExitCode> {
|
|||
let meta = Metadata::from_bytes(patched_bin).expect("must be a standalone binary");
|
||||
|
||||
let mut rt = Runtime::new().with_args(args);
|
||||
|
||||
let result = rt.run("STANDALONE", meta.bytecode).await;
|
||||
|
||||
Ok(match result {
|
||||
|
|
|
@ -1,15 +1,11 @@
|
|||
#![allow(unused_imports)]
|
||||
#![allow(clippy::too_many_lines)]
|
||||
|
||||
use std::process::{ExitCode, ExitStatus};
|
||||
|
||||
use mlua::prelude::*;
|
||||
|
||||
use crate::{
|
||||
error_callback::ThreadErrorCallback,
|
||||
queue::{DeferredThreadQueue, SpawnedThreadQueue},
|
||||
result_map::ThreadResultMap,
|
||||
scheduler::Scheduler,
|
||||
thread_id::ThreadId,
|
||||
traits::LuaSchedulerExt,
|
||||
util::{is_poll_pending, LuaThreadOrFunction, ThreadResult},
|
||||
|
|
Loading…
Reference in a new issue