Revert some unnecessary stylistic changes

This commit is contained in:
Filip Tibell 2024-10-16 21:41:16 +02:00
parent df4fb9be91
commit 93fa14d832
No known key found for this signature in database
5 changed files with 13 additions and 18 deletions

View file

@ -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 { fn get_or_create_material_colors(instance: &Instance) -> MaterialColors {
if let Variant::MaterialColors(inner) = instance if let Some(Variant::MaterialColors(inner)) = instance.get_property("MaterialColors") {
.get_property("MaterialColors")
.unwrap_or(Variant::MaterialColors(MaterialColors::default()))
{
inner inner
} else { } else {
unreachable!() MaterialColors::default()
} }
} }

View file

@ -7,9 +7,10 @@ use tokio::{
io::{stdin, AsyncReadExt as _}, io::{stdin, AsyncReadExt as _},
}; };
use super::utils::files::{discover_script_path_including_lune_dirs, strip_shebang};
use lune::Runtime; use lune::Runtime;
use super::utils::files::{discover_script_path_including_lune_dirs, strip_shebang};
/// Run a script /// Run a script
#[derive(Debug, Clone, Parser)] #[derive(Debug, Clone, Parser)]
pub struct RunCommand { pub struct RunCommand {
@ -39,11 +40,13 @@ impl RunCommand {
(file_display_name, file_contents) (file_display_name, file_contents)
}; };
// Create a new lune object with all globals & run the script // Create a new lune runtime with all globals & run the script
let mut runtime = Runtime::new().with_args(self.script_args); let mut rt = Runtime::new().with_args(self.script_args);
let result = runtime
let result = rt
.run(&script_display_name, strip_shebang(script_contents)) .run(&script_display_name, strip_shebang(script_contents))
.await; .await;
Ok(match result { Ok(match result {
Err(err) => { Err(err) => {
eprintln!("{err}"); eprintln!("{err}");

View file

@ -144,7 +144,6 @@ impl Runtime {
script_name: impl AsRef<str>, script_name: impl AsRef<str>,
script_contents: impl AsRef<[u8]>, script_contents: impl AsRef<[u8]>,
) -> RuntimeResult<(u8, Vec<LuaValue>)> { ) -> RuntimeResult<(u8, Vec<LuaValue>)> {
// Create a new scheduler for this run
let lua = self.inner.lua(); let lua = self.inner.lua();
let sched = self.inner.scheduler(); let sched = self.inner.scheduler();
@ -165,17 +164,16 @@ impl Runtime {
let main_thread_id = sched.push_thread_back(main, ())?; let main_thread_id = sched.push_thread_back(main, ())?;
sched.run().await; 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, Some(res) => res,
None => LuaValue::Nil.into_lua_multi(lua), None => LuaValue::Nil.into_lua_multi(lua),
}? }?;
.into_vec();
Ok(( Ok((
sched sched
.get_exit_code() .get_exit_code()
.unwrap_or(u8::from(got_any_error.load(Ordering::SeqCst))), .unwrap_or(u8::from(got_any_error.load(Ordering::SeqCst))),
thread_res, main_thread_res.into_vec(),
)) ))
} }
} }

View file

@ -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 meta = Metadata::from_bytes(patched_bin).expect("must be a standalone binary");
let mut rt = Runtime::new().with_args(args); let mut rt = Runtime::new().with_args(args);
let result = rt.run("STANDALONE", meta.bytecode).await; let result = rt.run("STANDALONE", meta.bytecode).await;
Ok(match result { Ok(match result {

View file

@ -1,15 +1,11 @@
#![allow(unused_imports)]
#![allow(clippy::too_many_lines)] #![allow(clippy::too_many_lines)]
use std::process::{ExitCode, ExitStatus};
use mlua::prelude::*; use mlua::prelude::*;
use crate::{ use crate::{
error_callback::ThreadErrorCallback, error_callback::ThreadErrorCallback,
queue::{DeferredThreadQueue, SpawnedThreadQueue}, queue::{DeferredThreadQueue, SpawnedThreadQueue},
result_map::ThreadResultMap, result_map::ThreadResultMap,
scheduler::Scheduler,
thread_id::ThreadId, thread_id::ThreadId,
traits::LuaSchedulerExt, traits::LuaSchedulerExt,
util::{is_poll_pending, LuaThreadOrFunction, ThreadResult}, util::{is_poll_pending, LuaThreadOrFunction, ThreadResult},