From d02b6375c6cdb9e54bc463648e363277cc51e7c7 Mon Sep 17 00:00:00 2001 From: Jaroslaw Konik Date: Tue, 13 May 2025 18:02:57 +0200 Subject: [PATCH] get rid of warnings --- src/runtimes/lua.rs | 4 ++-- src/runtimes/rhai.rs | 4 ++-- src/runtimes/ruby.rs | 46 +++++++++++++++++++------------------------- tests/tests.rs | 10 +++++----- 4 files changed, 29 insertions(+), 35 deletions(-) diff --git a/src/runtimes/lua.rs b/src/runtimes/lua.rs index 0e55625..eda2ba2 100644 --- a/src/runtimes/lua.rs +++ b/src/runtimes/lua.rs @@ -260,14 +260,14 @@ impl Runtime for LuaRuntime { fn with_engine_thread_mut( &mut self, - f: impl FnOnce(&mut Self::RawEngine) -> T + Send + 'static, + _f: impl FnOnce(&mut Self::RawEngine) -> T + Send + 'static, ) -> T { todo!() } fn with_engine_thread( &self, - f: impl FnOnce(&Self::RawEngine) -> T + Send + 'static, + _f: impl FnOnce(&Self::RawEngine) -> T + Send + 'static, ) -> T { todo!() } diff --git a/src/runtimes/rhai.rs b/src/runtimes/rhai.rs index c17e8b4..5f486e8 100644 --- a/src/runtimes/rhai.rs +++ b/src/runtimes/rhai.rs @@ -163,14 +163,14 @@ impl Runtime for RhaiRuntime { fn with_engine_thread_mut( &mut self, - f: impl FnOnce(&mut Self::RawEngine) -> T + Send + 'static, + _f: impl FnOnce(&mut Self::RawEngine) -> T + Send + 'static, ) -> T { todo!() } fn with_engine_thread( &self, - f: impl FnOnce(&Self::RawEngine) -> T + Send + 'static, + _f: impl FnOnce(&Self::RawEngine) -> T + Send + 'static, ) -> T { todo!() } diff --git a/src/runtimes/ruby.rs b/src/runtimes/ruby.rs index b439c58..d124c6a 100644 --- a/src/runtimes/ruby.rs +++ b/src/runtimes/ruby.rs @@ -2,7 +2,7 @@ // TODO: make sure ruby is statically linked use std::{ collections::HashMap, - sync::{Arc, Condvar, LazyLock, Mutex, MutexGuard}, + sync::{Arc, Condvar, LazyLock, Mutex}, thread::{self, JoinHandle}, }; @@ -12,13 +12,12 @@ use bevy::{ reflect::TypePath, }; use magnus::Ruby; -use magnus::{embed::Cleanup, function, prelude::*}; +use magnus::{function, prelude::*}; use serde::Deserialize; use crate::{ assets::GetExtensions, callback::{FromRuntimeValueWithEngine, IntoRuntimeValueWithEngine}, - runtimes::ruby, FuncArgs, Runtime, }; @@ -47,10 +46,11 @@ impl From for RubyScript { Self(value) } } -struct RubyEngine(Cleanup); + +type RubyClosure = Box; struct RubyThread { - sender: Option>>, + sender: Option>, handle: Option>, } @@ -157,11 +157,11 @@ impl Runtime for RubyRuntime { .execute(Box::new(move |ruby| f(&ruby))) } - fn with_engine_mut(&mut self, f: impl FnOnce(&mut Self::RawEngine) -> T) -> T { + fn with_engine_mut(&mut self, _f: impl FnOnce(&mut Self::RawEngine) -> T) -> T { unimplemented!(); } - fn with_engine(&self, f: impl FnOnce(&Self::RawEngine) -> T) -> T { + fn with_engine(&self, _f: impl FnOnce(&Self::RawEngine) -> T) -> T { unimplemented!(); } @@ -195,24 +195,18 @@ impl Runtime for RubyRuntime { + Sync + 'static, ) -> Result<(), crate::ScriptingError> { - static RUBY_CALLBACKS: LazyLock< - Mutex< - HashMap< - String, - Box< - dyn Fn( - (), - Vec, - ) -> Result< - crate::promise::Promise<(), RubyValue>, - crate::ScriptingError, - > + Send - + Sync - + 'static, - >, - >, - >, - > = LazyLock::new(|| Mutex::new(HashMap::new())); + type CallbackClosure = Box< + dyn Fn( + (), + Vec, + ) + -> Result, crate::ScriptingError> + + Send + + Sync + + 'static, + >; + static RUBY_CALLBACKS: LazyLock>> = + LazyLock::new(|| Mutex::new(HashMap::new())); let mut callbacks = RUBY_CALLBACKS.lock().unwrap(); callbacks.insert(name.clone(), Box::new(f)); @@ -223,7 +217,7 @@ impl Runtime for RubyRuntime { let method_name = method_name.to_string(); let callbacks = RUBY_CALLBACKS.lock().unwrap(); let f = callbacks.get(&method_name).unwrap(); - f((), vec![]); + f((), vec![]).unwrap(); ruby.qnil().as_value() } diff --git a/tests/tests.rs b/tests/tests.rs index 6e3da70..ad1a927 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -487,7 +487,7 @@ mod lua_tests { mod ruby_tests { use bevy::prelude::*; use bevy_scriptum::runtimes::ruby::{prelude::*, RubyScriptData}; - use magnus::{value::ReprValue, Module, Object, Ruby}; + use magnus::{value::ReprValue, Module}; impl AssertStateKeyValue for RubyRuntime { type ScriptData = RubyScriptData; @@ -502,15 +502,15 @@ mod ruby_tests { }) } - fn assert_state_key_value_i32(world: &World, _entity_id: Entity, key: &str, value: i32) { + fn assert_state_key_value_i32(_world: &World, _entity_id: Entity, _key: &str, _value: i32) { todo!(); } fn assert_state_key_value_string( - world: &World, + _world: &World, _entity_id: Entity, - key: &str, - value: &str, + _key: &str, + _value: &str, ) { todo!(); }