This commit is contained in:
meehl committed 2026-08-24 10:24:51 +02:00
1 parent 8cf5110eb2
commit 6224a1b0a4
12 files changed
+54 -56

No files matched your search

+1 -1
View File
@@ -161,7 +161,7 @@ fn restart(l: &Lua, _: ()) -> LuaResult<()> {
fn open_url(l: &Lua, url: String) -> LuaResult<MultiValue> {
match open::that(url) {
Ok(_) => ().into_lua_multi(l),
Ok(()) => ().into_lua_multi(l),
Err(_) => "Unable to open url!".into_lua_multi(l),
}
}
+2 -2
View File
@@ -14,7 +14,7 @@ pub fn protected_call(l: &Lua, (func, args): (Function, MultiValue)) -> LuaResul
pub fn load_module(l: &Lua, (name, args): (String, MultiValue)) -> LuaResult<MultiValue> {
let script_dir = {
let ctx = l.app_data_ref::<Context>().unwrap();
ctx.script_dir.to_owned()
ctx.script_dir.clone()
};
let mut module_path = script_dir.join(name);
if module_path.extension().is_none() {
@@ -31,7 +31,7 @@ pub fn load_module(l: &Lua, (name, args): (String, MultiValue)) -> LuaResult<Mul
pub fn protected_load_module(l: &Lua, (name, args): (String, MultiValue)) -> LuaResult<MultiValue> {
let script_dir = {
let ctx = l.app_data_ref::<Context>().unwrap();
ctx.script_dir.to_owned()
ctx.script_dir.clone()
};
let mut module_path = script_dir.join(name);
if module_path.extension().is_none() {
+2 -2
View File
@@ -42,7 +42,7 @@ pub fn set_work_dir(l: &Lua, path: String) -> LuaResult<()> {
pub fn make_dir(l: &Lua, path: String) -> LuaResult<MultiValue> {
match fs::create_dir_all(path) {
// callers expect first return value to be true on success
Ok(_) => (true).into_lua_multi(l),
Ok(()) => (true).into_lua_multi(l),
// otherwise it is set to Nil and second return value is set to error msg
Err(err) => (Value::Nil, err.to_string()).into_lua_multi(l),
}
@@ -55,7 +55,7 @@ pub fn remove_dir(l: &Lua, (path, recursive): (String, Option<bool>)) -> LuaResu
fs::remove_dir(&path)
};
match result {
Ok(_) => (true).into_lua_multi(l),
Ok(()) => (true).into_lua_multi(l),
Err(err) => (Value::Nil, err.to_string()).into_lua_multi(l),
}
}
+19 -20
View File
@@ -168,7 +168,7 @@ unsafe extern "C-unwind" fn set_draw_layer(state: *mut ffi::lua_State) -> c_int
let layer = i32_from_stack!(state, -nargs);
Some(layer)
}
t => panic!("Expected Nil or Number, got {:?}", t),
t => panic!("Expected Nil or Number, got {t:?}"),
};
let sublayer = i32_from_stack!(state, -nargs + 1);
if let Some(layer) = layer {
@@ -189,9 +189,10 @@ unsafe extern "C-unwind" fn draw_image(state: *mut ffi::lua_State) -> c_int {
let mut ctx = lua_instance.app_data_mut::<Context>().unwrap();
let nargs = unsafe { ffi::lua_gettop(state) };
if !matches!(nargs, 5 | 6 | 7 | 9 | 10 | 11) {
panic!("Unexpected number of arguments");
}
assert!(
matches!(nargs, 5 | 6 | 7 | 9 | 10 | 11),
"Unexpected number of arguments"
);
#[allow(clippy::manual_range_patterns)]
let parse_uv = matches!(nargs, 9 | 10 | 11);
@@ -237,9 +238,10 @@ unsafe extern "C-unwind" fn draw_image_quad(state: *mut ffi::lua_State) -> c_int
let mut ctx = lua_instance.app_data_mut::<Context>().unwrap();
let nargs = unsafe { ffi::lua_gettop(state) };
if !matches!(nargs, 9 | 10 | 11 | 17 | 18 | 19) {
panic!("Unexpected number of arguments");
}
assert!(
matches!(nargs, 9 | 10 | 11 | 17 | 18 | 19),
"Unexpected number of arguments"
);
#[allow(clippy::manual_range_patterns)]
let parse_uv = matches!(nargs, 17 | 18 | 19);
@@ -560,17 +562,14 @@ impl<'a> Iterator for PoBStringSegmentIterator<'a> {
let color = Some(Srgba::from_escape_code(escape_str));
let _ = self.captures.next(); // pop current code to peek the next one
match self.captures.peek() {
Some(next_code) => {
// found another escape code. return text up the next code
let next_code_start = next_code.get(0).unwrap().start();
Some((color, &self.haystack[code_end..next_code_start]))
}
None => {
// no additional escape codes found. return rest of string
self.is_done = true;
Some((color, &self.haystack[code_end..]))
}
if let Some(next_code) = self.captures.peek() {
// found another escape code. return text up the next code
let next_code_start = next_code.get(0).unwrap().start();
Some((color, &self.haystack[code_end..next_code_start]))
} else {
// no additional escape codes found. return rest of string
self.is_done = true;
Some((color, &self.haystack[code_end..]))
}
}
None => {
@@ -647,12 +646,12 @@ impl std::str::FromStr for PoBFontType {
}
}
#[inline(always)]
#[inline]
fn hex_byte(a: u8, b: u8) -> u8 {
(hex_digit(a) << 4) | hex_digit(b)
}
#[inline(always)]
#[inline]
fn hex_digit(c: u8) -> u8 {
match c {
b'0'..=b'9' => c - b'0',
+1 -1
View File
@@ -21,7 +21,7 @@ pub fn launch_subscript(
let arguments = args.try_into()?;
let ctx = l.app_data_ref::<Context>().unwrap();
let script_dir = ctx.script_dir.to_owned();
let script_dir = ctx.script_dir.clone();
let subscript_id = ctx.subscript_manager.borrow_mut().push(
script_dir,
script_text,
+1 -1
View File
@@ -175,7 +175,7 @@ impl Subscript {
}
}
fn handle_calls(&mut self, lua: &Lua) {
fn handle_calls(&self, lua: &Lua) {
match self.receiver.try_recv() {
Ok(SubscriptCall::Blocking {
function_name,