Skip to content

Commit 05001fc

Browse files
committed
update to mlua 10.0
1 parent 69a1344 commit 05001fc

File tree

8 files changed

+19
-21
lines changed

8 files changed

+19
-21
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ bevy_mod_scripting_core = { path = "crates/bevy_mod_scripting_core", version = "
6565
bevy_mod_scripting_common = { path = "crates/bevy_mod_scripting_common", version = "0.8.0-alpha.2" }
6666
bevy_mod_scripting_functions = { path = "crates/bevy_mod_scripting_functions", version = "0.8.0-alpha.2" }
6767
test_utils = { path = "crates/test_utils" }
68+
mlua = { version = "0.10" }
6869

6970
[dev-dependencies]
7071
bevy = { workspace = true, default-features = true }

assets/scripts/bevy_api.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ function table_to_string(t)
66
return result .. "]"
77
end
88

9-
9+
1010
function on_event()
11+
-- send exit event, to finish after one call
1112
world:exit()
1213

1314
print(entity)
@@ -22,7 +23,7 @@ function on_event()
2223

2324
print("\noption")
2425
-- print(comp:get("option_usize"))
25-
print(comp.option_usie)
26+
print(comp.option_usize)
2627
comp.option_usize = 69
2728
print(comp.option_usize)
2829
comp.option_usize = nil

crates/bevy_mod_scripting_core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ doc_always = []
2323
mlua_impls = ["mlua"]
2424

2525
[dependencies]
26-
mlua = { version = "0.9", optional = true }
26+
mlua = { optional = true, workspace = true }
2727
bevy = { workspace = true, default-features = false, features = [
2828
"bevy_asset",
2929
"reflect_functions",

crates/languages/bevy_mod_scripting_lua/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ bevy_mod_scripting_functions = { workspace = true, features = [
4646
"core_functions",
4747
] }
4848
bevy_mod_scripting_derive = { path = "../../bevy_mod_scripting_derive" }
49-
mlua = { version = "0.9", features = ["vendored", "send", "macros"] }
49+
mlua = { workspace = true, features = ["vendored", "send", "macros"] }
5050
parking_lot = "0.12.1"
5151
serde_json = "1.0.81"
5252
anyhow = "1.0.75"

crates/languages/bevy_mod_scripting_lua/src/bindings/reference.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,7 @@ impl From<ReflectReference> for LuaReflectReference {
6060
}
6161

6262
/// Looks up a function in the registry on the given type id
63-
fn lookup_function<'lua>(
64-
lua: &'lua Lua,
65-
key: &str,
66-
type_id: TypeId,
67-
) -> Option<Result<Function<'lua>, mlua::Error>> {
63+
fn lookup_function(lua: &Lua, key: &str, type_id: TypeId) -> Option<Result<Function, mlua::Error>> {
6864
let function = lookup_dynamic_function(lua, key, type_id);
6965

7066
function.map(|function| {
@@ -103,7 +99,7 @@ fn lookup_dynamic_function_typed<'lua, T: 'static + ?Sized>(
10399
}
104100

105101
impl UserData for LuaReflectReference {
106-
fn add_methods<'lua, T: UserDataMethods<'lua, Self>>(m: &mut T) {
102+
fn add_methods<T: UserDataMethods<Self>>(m: &mut T) {
107103
m.add_meta_function(
108104
MetaMethod::Index,
109105
|lua, (self_, key): (LuaReflectReference, LuaScriptValue)| {

crates/languages/bevy_mod_scripting_lua/src/bindings/script_value.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ impl From<ScriptValue> for LuaScriptValue {
2828
}
2929
}
3030

31-
impl<'lua> FromLua<'lua> for LuaScriptValue {
32-
fn from_lua(value: mlua::Value<'lua>, lua: &'lua mlua::Lua) -> mlua::Result<Self> {
31+
impl FromLua for LuaScriptValue {
32+
fn from_lua(value: mlua::Value, _lua: &mlua::Lua) -> mlua::Result<Self> {
3333
Ok(match value {
3434
Value::Nil => ScriptValue::Unit,
3535
Value::Boolean(b) => ScriptValue::Bool(b),
@@ -52,7 +52,7 @@ impl<'lua> FromLua<'lua> for LuaScriptValue {
5252
_ => {
5353
return Err(mlua::Error::FromLuaConversionError {
5454
from: value.type_name(),
55-
to: "ScriptValue",
55+
to: "ScriptValue".to_owned(),
5656
message: Some("unsupported value type".to_owned()),
5757
})
5858
}
@@ -61,8 +61,8 @@ impl<'lua> FromLua<'lua> for LuaScriptValue {
6161
}
6262
}
6363

64-
impl<'lua> IntoLua<'lua> for LuaScriptValue {
65-
fn into_lua(self, lua: &'lua mlua::Lua) -> mlua::Result<mlua::Value<'lua>> {
64+
impl IntoLua for LuaScriptValue {
65+
fn into_lua(self, lua: &mlua::Lua) -> mlua::Result<mlua::Value> {
6666
Ok(match self.0 {
6767
ScriptValue::Unit => Value::Nil,
6868
ScriptValue::Bool(b) => Value::Boolean(b),

crates/languages/bevy_mod_scripting_lua/src/bindings/world.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl LuaWorld {
2929
}
3030

3131
impl UserData for LuaWorld {
32-
fn add_methods<'lua, T: UserDataMethods<'lua, Self>>(methods: &mut T) {
32+
fn add_methods<T: UserDataMethods<Self>>(methods: &mut T) {
3333
// methods.add_meta_function(
3434
// MetaMethod::Index,
3535
// |lua, (world, key): (LuaWorld, String)| {

crates/languages/bevy_mod_scripting_lua/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ pub mod prelude {
3535
pub use crate::mlua::{self, prelude::*, Value};
3636
}
3737

38-
pub trait LuaEventArg: Args + for<'l> IntoLuaMulti<'l> {}
39-
impl<T: Args + for<'l> IntoLuaMulti<'l>> LuaEventArg for T {}
38+
pub trait LuaEventArg: Args + IntoLuaMulti {}
39+
impl<T: Args + IntoLuaMulti> LuaEventArg for T {}
4040

41-
pub struct LuaScriptingPlugin<A: Args + for<'l> IntoLuaMulti<'l>> {
41+
pub struct LuaScriptingPlugin<A: Args + IntoLuaMulti> {
4242
pub scripting_plugin: ScriptingPlugin<A, Lua, ()>,
4343
}
4444

@@ -147,7 +147,7 @@ pub fn lua_context_reload(
147147
}
148148

149149
#[allow(clippy::too_many_arguments)]
150-
pub fn lua_handler<A: Args + for<'l> IntoLuaMulti<'l>>(
150+
pub fn lua_handler<A: Args + IntoLuaMulti>(
151151
args: A,
152152
entity: bevy::ecs::entity::Entity,
153153
script_id: &ScriptId,
@@ -169,7 +169,7 @@ pub fn lua_handler<A: Args + for<'l> IntoLuaMulti<'l>>(
169169
};
170170

171171
handler
172-
.call::<_, ()>(args)
172+
.call::<()>(args)
173173
.map_err(ScriptError::from_mlua_error)?;
174174
Ok(())
175175
})

0 commit comments

Comments
 (0)