From 72e30a9e7c039d4c478a18ccc0ada8820fe66c00 Mon Sep 17 00:00:00 2001 From: makspll Date: Wed, 17 Jan 2024 19:16:10 +0000 Subject: [PATCH 01/14] initial work --- bevy_script_api/src/lua/bevy/mod.rs | 4 +- bevy_script_api/src/lua/mod.rs | 36 ++++---- bevy_script_api/src/lua/std.rs | 48 +++++------ bevy_script_api/src/lua/util.rs | 83 +++++++++++-------- examples/lua/complex_game_loop.rs | 6 +- examples/lua/documentation_gen.rs | 4 +- examples/lua/event_recipients.rs | 6 +- languages/bevy_mod_scripting_lua/Cargo.toml | 8 +- languages/bevy_mod_scripting_lua/src/lib.rs | 6 +- .../src/implementor.rs | 5 +- 10 files changed, 104 insertions(+), 102 deletions(-) diff --git a/bevy_script_api/src/lua/bevy/mod.rs b/bevy_script_api/src/lua/bevy/mod.rs index 32d29d7059..d9fc339a45 100644 --- a/bevy_script_api/src/lua/bevy/mod.rs +++ b/bevy_script_api/src/lua/bevy/mod.rs @@ -1,5 +1,5 @@ use crate::common::bevy::{ScriptTypeRegistration, ScriptWorld}; -use crate::impl_tealr_type; +use crate::{impl_from_lua_with_clone, impl_tealr_type}; use std::sync::Arc; @@ -21,6 +21,7 @@ use super::util::LuaIndex; pub type LuaTypeRegistration = ScriptTypeRegistration; impl_tealr_type!(LuaTypeRegistration); +impl_from_lua_with_clone!(LuaTypeRegistration); impl TealData for LuaTypeRegistration { fn add_methods<'lua, T: TealDataMethods<'lua, Self>>(methods: &mut T) { @@ -66,6 +67,7 @@ impl TealData for LuaScriptData { pub type LuaWorld = ScriptWorld; impl_tealr_type!(LuaWorld); +impl_from_lua_with_clone!(LuaWorld); impl TealData for LuaWorld { fn add_methods<'lua, T: TealDataMethods<'lua, Self>>(methods: &mut T) { diff --git a/bevy_script_api/src/lua/mod.rs b/bevy_script_api/src/lua/mod.rs index c3fc0fa84c..5114e93cdc 100644 --- a/bevy_script_api/src/lua/mod.rs +++ b/bevy_script_api/src/lua/mod.rs @@ -2,20 +2,19 @@ use ::std::any::TypeId; use ::std::borrow::Cow; use crate::common::bevy::GetWorld; -use crate::impl_tealr_type; +use crate::{impl_from_lua_with_clone, impl_tealr_type}; use ::bevy::prelude::{App, AppTypeRegistry}; use ::bevy::reflect::{FromType, GetTypeRegistration, Reflect}; use bevy_mod_scripting_core::world::WorldPointer; -use bevy_mod_scripting_lua::tealr; +use bevy_mod_scripting_lua::tealr::{self, ToTypename}; use tealr::mlu::mlua::MetaMethod; use tealr::mlu::{ - mlua::{self, FromLua, Lua, ToLua, UserData, Value}, + mlua::{self, FromLua, IntoLua, Lua, UserData, Value}, TealData, TealDataMethods, }; -use tealr::TypeName; use crate::script_ref::{ReflectedValue, ScriptRef, ValueIndex}; @@ -126,13 +125,13 @@ impl ApplyLua for ScriptRef { } } -impl<'lua> ToLua<'lua> for ScriptRef { +impl<'lua> IntoLua<'lua> for ScriptRef { /// Converts the LuaRef to the most convenient representation /// checking conversions in this order: /// - A primitive or bevy type which has a reflect interface is converted to a custom UserData exposing its API to lua conveniently /// - A type implementing CustomUserData is converted with its `ref_to_lua` method /// - Finally the method is represented as a `ReflectedValue` which exposes the Reflect interface - fn to_lua(self, ctx: &'lua Lua) -> mlua::Result> { + fn into_lua(self, ctx: &'lua Lua) -> mlua::Result> { let world = self.world_ptr.clone(); let world = world.read(); @@ -143,26 +142,19 @@ impl<'lua> ToLua<'lua> for ScriptRef { if let Some(v) = g.get_type_data::(type_id) { v.ref_to_lua(self, ctx) } else { - ReflectedValue { ref_: self }.to_lua(ctx) + ReflectedValue { ref_: self }.into_lua(ctx) } } } -impl TypeName for ScriptRef { - /// ReflectedValue represents the "lowest common denominator" across the possible returned types - /// people can always use 'as' to cast to the right type - /// but the static analysis will be conservative, i.e. the compiler will assume the smallest set of functionality - /// by default - fn get_type_parts() -> Cow<'static, [tealr::NamePart]> { - Cow::Borrowed(&[tealr::NamePart::Type(tealr::TealType { - name: Cow::Borrowed("ReflectedValue"), - generics: None, - type_kind: tealr::KindOfType::Builtin, - })]) +impl ToTypename for ScriptRef { + fn to_typename() -> tealr::Type { + tealr::Type::new_single("ReflectedValue", tealr::KindOfType::External) } } impl_tealr_type!(ReflectedValue); +impl_from_lua_with_clone!(ReflectedValue); impl TealData for ReflectedValue { fn add_methods<'lua, T: TealDataMethods<'lua, Self>>(methods: &mut T) { methods.document_type("This type represents a generic reflected value."); @@ -266,7 +258,7 @@ pub trait ValueLuaType {} impl LuaProxyable for T { fn ref_to_lua(self_: ScriptRef, lua: &Lua) -> mlua::Result { - self_.get_typed(|s: &Self| s.clone().to_lua(lua))? + self_.get_typed(|s: &Self| s.clone().into_lua(lua))? } fn apply_lua<'lua>( @@ -288,7 +280,9 @@ impl LuaProxyable } } -impl<'lua, T: Clone + UserData + Send + ValueLuaType + Reflect + 'static> FromLuaProxy<'lua> for T { +impl<'lua, T: Clone + UserData + FromLua<'lua> + Send + ValueLuaType + Reflect + 'static> + FromLuaProxy<'lua> for T +{ fn from_lua_proxy(new_val: Value<'lua>, lua: &'lua Lua) -> mlua::Result { T::from_lua(new_val, lua) } @@ -296,7 +290,7 @@ impl<'lua, T: Clone + UserData + Send + ValueLuaType + Reflect + 'static> FromLu impl<'lua, T: Clone + UserData + Send + ValueLuaType + Reflect + 'static> ToLuaProxy<'lua> for T { fn to_lua_proxy(self, lua: &'lua Lua) -> mlua::Result> { - self.to_lua(lua) + self.into_lua(lua) } } diff --git a/bevy_script_api/src/lua/std.rs b/bevy_script_api/src/lua/std.rs index b9df2e66c8..92d7b1ca08 100644 --- a/bevy_script_api/src/lua/std.rs +++ b/bevy_script_api/src/lua/std.rs @@ -6,10 +6,11 @@ use bevy::reflect::Reflect; use bevy::reflect::TypePath; use bevy_mod_scripting_lua::tealr; +use bevy_mod_scripting_lua::tealr::ToTypename; use tealr::mlu::mlua::MetaMethod; use tealr::mlu::TypedFunction; use tealr::mlu::{ - mlua::{self, FromLua, Lua, ToLua, UserData, Value}, + mlua::{self, FromLua, IntoLua, Lua, UserData, Value}, TealData, TealDataMethods, }; use tealr::TypeBody; @@ -38,7 +39,7 @@ macro_rules! impl_proxyable_by_copy( $( impl $crate::lua::LuaProxyable for $num_ty { fn ref_to_lua(self_: $crate::script_ref::ScriptRef,lua: & tealr::mlu::mlua::Lua) -> tealr::mlu::mlua::Result > { - self_.get_typed(|self_ : &Self| self_.to_lua(lua))? + self_.get_typed(|self_ : &Self| self_.into_lua(lua))? } fn apply_lua< 'lua>(self_: &mut $crate::script_ref::ScriptRef,lua: & 'lua tealr::mlu::mlua::Lua,new_val:tealr::mlu::mlua::Value< 'lua>) -> tealr::mlu::mlua::Result<()> { @@ -57,7 +58,7 @@ macro_rules! impl_proxyable_by_copy( impl <'lua>$crate::lua::ToLuaProxy<'lua> for $num_ty { #[inline(always)] fn to_lua_proxy(self, lua: &'lua Lua) -> tealr::mlu::mlua::Result> { - self.to_lua(lua) + self.into_lua(lua) } } )* @@ -72,7 +73,7 @@ impl_proxyable_by_copy!(u8, u16, u32, u64, u128, usize); impl LuaProxyable for String { fn ref_to_lua(self_: ScriptRef, lua: &Lua) -> mlua::Result { - self_.get_typed(|self_: &String| self_.as_str().to_lua(lua))? + self_.get_typed(|self_: &String| self_.as_str().into_lua(lua))? } fn apply_lua<'lua>( @@ -95,7 +96,7 @@ impl<'lua> FromLuaProxy<'lua> for String { impl<'lua> ToLuaProxy<'lua> for String { fn to_lua_proxy(self, lua: &'lua Lua) -> mlua::Result> { - self.to_lua(lua) + self.into_lua(lua) } } @@ -234,7 +235,7 @@ impl<'lua, T: for<'a> ToLuaProxy<'a>> ToLuaProxy<'lua> for Option { pub type LuaVec = ScriptVec; impl< - T: TypeName + T: ToTypename + FromReflect + TypePath + LuaProxyable @@ -253,24 +254,15 @@ impl< } } -impl TypeName for LuaVec { - fn get_type_parts() -> Cow<'static, [tealr::NamePart]> { - let mut parts = vec![ - tealr::NamePart::Type(tealr::TealType { - name: Cow::Borrowed("LuaVec"), - type_kind: tealr::KindOfType::External, - generics: None, - }), - tealr::NamePart::Symbol("<".into()), - ]; - parts.extend(T::get_type_parts().iter().cloned()); - parts.push(tealr::NamePart::Symbol(">".into())); - parts.into() +impl ToTypename for LuaVec { + /// Before tealr deprecated TypeName, this used to incorporate generics here, but right now I don't think they're supported anymore + fn to_typename() -> tealr::Type { + tealr::Type::new_single("LuaVec", tealr::KindOfType::External) } } impl< - T: TypeName + T: ToTypename + FromReflect + TypePath + LuaProxyable @@ -289,7 +281,7 @@ impl< } impl< - T: TypeName + T: ToTypename + FromReflect + TypePath + LuaProxyable @@ -325,8 +317,8 @@ impl< move |ctx, ()| { let o = if curr_idx < len { ( - to_lua_idx(curr_idx).to_lua(ctx)?, - ref_.index(curr_idx).to_lua(ctx)?, + to_lua_idx(curr_idx).into_lua(ctx)?, + ref_.index(curr_idx).into_lua(ctx)?, ) } else { (Value::Nil, Value::Nil) @@ -346,7 +338,7 @@ impl< let len = s.len()?; for i in 0..len { - table.raw_set(to_lua_idx(i), s.index(i).to_lua(ctx)?)?; + table.raw_set(to_lua_idx(i), s.index(i).into_lua(ctx)?)?; } Ok(table) @@ -378,7 +370,7 @@ impl< } impl< - T: TypeName + T: ToTypename + FromReflect + TypePath + LuaProxyable @@ -388,7 +380,7 @@ impl< > LuaProxyable for Vec { fn ref_to_lua(self_: ScriptRef, lua: &Lua) -> mlua::Result { - LuaVec::::new_ref(self_).to_lua(lua) + LuaVec::::new_ref(self_).into_lua(lua) } fn apply_lua<'lua>( @@ -436,7 +428,7 @@ impl< impl< 'lua, - T: TypeName + T: ToTypename + for<'a> FromLuaProxy<'a> + for<'a> ToLuaProxy<'a> + Clone @@ -478,6 +470,6 @@ impl<'lua, T: for<'a> ToLuaProxy<'a> + Clone + FromReflect + LuaProxyable> ToLua proxies.raw_set(idx, elem.to_lua_proxy(lua)?)?; } - proxies.to_lua(lua) + proxies.into_lua(lua) } } diff --git a/bevy_script_api/src/lua/util.rs b/bevy_script_api/src/lua/util.rs index 9b1d4166b7..9c6b708228 100644 --- a/bevy_script_api/src/lua/util.rs +++ b/bevy_script_api/src/lua/util.rs @@ -1,6 +1,6 @@ use bevy_mod_scripting_lua::{ - prelude::{FromLua, Lua, LuaError, LuaValue, ToLua}, - tealr, + prelude::{FromLua, IntoLua, Lua, LuaError, LuaValue}, + tealr::{self, ToTypename}, }; use std::{ marker::PhantomData, @@ -14,9 +14,9 @@ use tealr::TypeName; #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct LuaIndex(usize); -impl TypeName for LuaIndex { - fn get_type_parts() -> std::borrow::Cow<'static, [tealr::NamePart]> { - usize::get_type_parts() +impl ToTypename for LuaIndex { + fn to_typename() -> tealr::Type { + ::to_typename() } } @@ -34,9 +34,9 @@ impl DerefMut for LuaIndex { } } -impl ToLua<'_> for LuaIndex { - fn to_lua(self, lua: &Lua) -> Result { - to_lua_idx(self.0).to_lua(lua) +impl IntoLua<'_> for LuaIndex { + fn into_lua(self, lua: &Lua) -> Result { + to_lua_idx(self.0).into_lua(lua) } } @@ -71,8 +71,8 @@ impl DummyTypeName { } } -impl<'lua, T> bevy_mod_scripting_lua::tealr::mlu::mlua::ToLua<'lua> for DummyTypeName { - fn to_lua( +impl<'lua, T> bevy_mod_scripting_lua::tealr::mlu::mlua::IntoLua<'lua> for DummyTypeName { + fn into_lua( self, _: &'lua bevy_mod_scripting_lua::tealr::mlu::mlua::Lua, ) -> bevy_mod_scripting_lua::tealr::mlu::mlua::Result< @@ -82,23 +82,45 @@ impl<'lua, T> bevy_mod_scripting_lua::tealr::mlu::mlua::ToLua<'lua> for DummyTyp } } -impl bevy_mod_scripting_lua::tealr::TypeName for DummyTypeName { - fn get_type_parts() -> std::borrow::Cow<'static, [bevy_mod_scripting_lua::tealr::NamePart]> { - T::get_type_parts() +impl ToTypename for DummyTypeName { + fn to_typename() -> bevy_mod_scripting_lua::tealr::Type { + T::to_typename() } } +#[macro_export] +macro_rules! impl_from_lua_with_clone { + ($v:ty) => { + impl<'lua> bevy_mod_scripting_lua::tealr::mlu::mlua::FromLua<'lua> for $v { + #[inline] + fn from_lua( + value: bevy_mod_scripting_lua::tealr::mlu::mlua::Value<'lua>, + _: &'lua bevy_mod_scripting_lua::tealr::mlu::mlua::Lua, + ) -> bevy_mod_scripting_lua::tealr::mlu::mlua::Result<$v> { + match value { + bevy_mod_scripting_lua::tealr::mlu::mlua::Value::UserData(ud) => { + Ok(ud.borrow::<$v>()?.clone()) + } + _ => Err( + bevy_mod_scripting_lua::tealr::mlu::mlua::Error::FromLuaConversionError { + from: value.type_name(), + to: "userdata", + message: None, + }, + ), + } + } + } + }; +} + /// Implements :tealr::TypeName, tealr::TypeBody and mlua::Userdata based on non-generic single token type name implementing TealData #[macro_export] macro_rules! impl_tealr_type { ($v:ty) => { - impl bevy_mod_scripting_lua::tealr::TypeName for $v { - fn get_type_parts() -> ::std::borrow::Cow<'static, [bevy_mod_scripting_lua::tealr::NamePart]> { - ::std::borrow::Cow::Borrowed(&[bevy_mod_scripting_lua::tealr::NamePart::Type(bevy_mod_scripting_lua::tealr::TealType { - name: ::std::borrow::Cow::Borrowed(stringify!($v)), - generics: None, - type_kind: bevy_mod_scripting_lua::tealr::KindOfType::External, - })]) + impl bevy_mod_scripting_lua::tealr::ToTypename for $v { + fn to_typename() -> bevy_mod_scripting_lua::tealr::Type { + bevy_mod_scripting_lua::tealr::Type::new_single(stringify!($v), bevy_mod_scripting_lua::tealr::KindOfType::External) } } @@ -138,10 +160,10 @@ macro_rules! impl_tealr_any_union { $visibility enum $type_name { $($sub_types($sub_types) ,)* } - impl<'lua> ::bevy_mod_scripting_lua::tealr::mlu::mlua::ToLua<'lua> for $type_name { - fn to_lua(self, lua: &'lua ::bevy_mod_scripting_lua::tealr::mlu::mlua::Lua) -> ::std::result::Result<::bevy_mod_scripting_lua::tealr::mlu::mlua::Value<'lua>, ::bevy_mod_scripting_lua::tealr::mlu::mlua::Error> { + impl<'lua> ::bevy_mod_scripting_lua::tealr::mlu::mlua::IntoLua<'lua> for $type_name { + fn into_lua(self, lua: &'lua ::bevy_mod_scripting_lua::tealr::mlu::mlua::Lua) -> ::std::result::Result<::bevy_mod_scripting_lua::tealr::mlu::mlua::Value<'lua>, ::bevy_mod_scripting_lua::tealr::mlu::mlua::Error> { match self { - $($type_name::$sub_types(x) => x.to_lua(lua),)* + $($type_name::$sub_types(x) => x.into_lua(lua),)* } } } @@ -159,17 +181,9 @@ macro_rules! impl_tealr_any_union { }) } } - impl ::bevy_mod_scripting_lua::tealr::TypeName for $type_name { - fn get_type_parts() -> ::std::borrow::Cow<'static,[::bevy_mod_scripting_lua::tealr::NamePart]> { - ::std::borrow::Cow::Borrowed(&[::bevy_mod_scripting_lua::tealr::NamePart::Type(::bevy_mod_scripting_lua::tealr::TealType { - name: ::std::borrow::Cow::Borrowed("any"), - generics: None, - type_kind: ::bevy_mod_scripting_lua::tealr::KindOfType::Builtin, - })]) - } - - fn get_type_kind() -> ::bevy_mod_scripting_lua::tealr::KindOfType { - ::bevy_mod_scripting_lua::tealr::KindOfType::Builtin + impl ::bevy_mod_scripting_lua::tealr::ToTypename for $type_name { + fn to_typename() -> bevy_mod_scripting_lua::tealr::Type { + bevy_mod_scripting_lua::tealr::Type::new_single("any", bevy_mod_scripting_lua::tealr::KindOfType::Builtin) } } }; @@ -264,6 +278,7 @@ macro_rules! impl_tealr_generic{ } $crate::impl_tealr_type!($name); + $crate::impl_from_lua_with_clone!($name); } } diff --git a/examples/lua/complex_game_loop.rs b/examples/lua/complex_game_loop.rs index 6d46a9258a..08e47d4593 100644 --- a/examples/lua/complex_game_loop.rs +++ b/examples/lua/complex_game_loop.rs @@ -10,9 +10,9 @@ use std::sync::atomic::Ordering::Relaxed; /// The type we will be using to send data to Lua pub struct MyLuaArg(usize); -impl<'lua> ToLua<'lua> for MyLuaArg { - fn to_lua(self, lua: &'lua Lua) -> mlua::Result> { - self.0.to_lua(lua) +impl<'lua> IntoLua<'lua> for MyLuaArg { + fn into_lua(self, lua: &'lua Lua) -> mlua::Result> { + self.0.into_lua(lua) } } diff --git a/examples/lua/documentation_gen.rs b/examples/lua/documentation_gen.rs index bbf4d9dcc8..84e9021db7 100644 --- a/examples/lua/documentation_gen.rs +++ b/examples/lua/documentation_gen.rs @@ -10,8 +10,8 @@ use std::{sync::Mutex, time::Duration}; #[derive(Clone)] pub struct MyLuaArg; -impl<'lua> ToLua<'lua> for MyLuaArg { - fn to_lua(self, _lua: &'lua Lua) -> mlua::Result> { +impl<'lua> IntoLua<'lua> for MyLuaArg { + fn into_lua(self, _lua: &'lua Lua) -> mlua::Result> { Ok(Value::Nil) } } diff --git a/examples/lua/event_recipients.rs b/examples/lua/event_recipients.rs index 1c65e47a83..07cac41c2a 100644 --- a/examples/lua/event_recipients.rs +++ b/examples/lua/event_recipients.rs @@ -9,9 +9,9 @@ use std::time::Duration; #[derive(Clone)] pub struct MyLuaArg(usize); -impl<'lua> ToLua<'lua> for MyLuaArg { - fn to_lua(self, lua: &'lua Lua) -> mlua::Result> { - self.0.to_lua(lua) +impl<'lua> IntoLua<'lua> for MyLuaArg { + fn into_lua(self, lua: &'lua Lua) -> mlua::Result> { + self.0.into_lua(lua) } } diff --git a/languages/bevy_mod_scripting_lua/Cargo.toml b/languages/bevy_mod_scripting_lua/Cargo.toml index 4950abbbee..d247b38aac 100644 --- a/languages/bevy_mod_scripting_lua/Cargo.toml +++ b/languages/bevy_mod_scripting_lua/Cargo.toml @@ -45,13 +45,11 @@ path = "src/lib.rs" [dependencies] bevy = { version = "0.11", default-features = false } bevy_mod_scripting_core = { path = "../../bevy_mod_scripting_core", version = "0.3.0" } -#Git pin required for v0.9.0-alpha4 dependancy, without it 0.9.1 is pulled -tealr = { git = "https://github.com/lenscas/tealr.git", rev = "05c9cdbace8abb6c12fc200e03a7ffcc5afff308", features = [ +tealr = { version = "0.9", features = [ "mlua_vendored", "mlua_send", + "mlua_macros", ] } -tealr_derive = { git = "https://github.com/lenscas/tealr.git", rev = "05c9cdbace8abb6c12fc200e03a7ffcc5afff308" } - -parking_lot = "0.12.1" +parking_lot = "0.12.1" #Git pin required for v0.9.0-alpha4 dependancy, without it 0.9.1 is pulled serde_json = "1.0.81" serde = { version = "1", features = ["derive"] } diff --git a/languages/bevy_mod_scripting_lua/src/lib.rs b/languages/bevy_mod_scripting_lua/src/lib.rs index 060f87e495..250b6c5b8b 100644 --- a/languages/bevy_mod_scripting_lua/src/lib.rs +++ b/languages/bevy_mod_scripting_lua/src/lib.rs @@ -29,9 +29,9 @@ pub mod prelude { }; } -pub trait LuaArg: for<'lua> ToLuaMulti<'lua> + Clone + Sync + Send + 'static {} +pub trait LuaArg: for<'lua> IntoLuaMulti<'lua> + Clone + Sync + Send + 'static {} -impl ToLuaMulti<'lua> + Clone + Sync + Send + 'static> LuaArg for T {} +impl IntoLuaMulti<'lua> + Clone + Sync + Send + 'static> LuaArg for T {} #[derive(Clone, Event)] /// A Lua Hook. The result of creating this event will be @@ -115,7 +115,7 @@ impl ScriptHost for LuaScriptHost { lua.load(script) .set_name(script_data.name) - .and_then(|c| c.exec()) + .exec() .map_err(|e| ScriptError::FailedToLoad { script: script_data.name.to_owned(), msg: e.to_string(), diff --git a/languages/bevy_mod_scripting_lua_derive/src/implementor.rs b/languages/bevy_mod_scripting_lua_derive/src/implementor.rs index 7ebd8ece4a..bbb3653433 100644 --- a/languages/bevy_mod_scripting_lua_derive/src/implementor.rs +++ b/languages/bevy_mod_scripting_lua_derive/src/implementor.rs @@ -73,6 +73,7 @@ impl WrapperImplementor for LuaImplementor { definition = quote_spanned! {newtype.span()=> #definition bevy_script_api::make_script_wrapper!(#base_type as #newtype_name with Clone); + bevy_script_api::impl_from_lua_with_clone!(#newtype_name); }; } else { definition = quote_spanned! {newtype.span()=> @@ -144,7 +145,7 @@ impl WrapperImplementor for LuaImplementor { impl bevy_script_api::lua::LuaProxyable for #wrapped_type { fn ref_to_lua<'lua>(self_ : bevy_script_api::script_ref::ScriptRef, lua: &'lua #tealr::mlu::mlua::Lua) -> #tealr::mlu::mlua::Result<#tealr::mlu::mlua::Value<'lua>> { - <#wrapper_type as #tealr::mlu::mlua::ToLua>::to_lua(#wrapper_type::new_ref(self_),lua) + <#wrapper_type as #tealr::mlu::mlua::IntoLua>::into_lua(#wrapper_type::new_ref(self_),lua) } fn apply_lua<'lua>(self_ : &mut bevy_script_api::script_ref::ScriptRef, lua: &'lua #tealr::mlu::mlua::Lua, new_val: #tealr::mlu::mlua::Value<'lua>) -> #tealr::mlu::mlua::Result<()> { @@ -164,7 +165,7 @@ impl WrapperImplementor for LuaImplementor { impl bevy_script_api::lua::ToLuaProxy<'_> for #wrapped_type { fn to_lua_proxy<'lua>(self, lua: &'lua #tealr::mlu::mlua::Lua) -> #tealr::mlu::mlua::Result<#tealr::mlu::mlua::Value<'lua>>{ - <#wrapper_type as #tealr::mlu::mlua::ToLua>::to_lua(#wrapper_type::new(self),lua) + <#wrapper_type as #tealr::mlu::mlua::IntoLua>::into_lua(#wrapper_type::new(self),lua) } } }; From 3675b6e55b18d9df9357ae60655a0b9e39697d66 Mon Sep 17 00:00:00 2001 From: makspll Date: Fri, 19 Jan 2024 16:45:40 +0000 Subject: [PATCH 02/14] change readme --- languages/bevy_mod_scripting_lua/src/docs.rs | 1 + tealr_doc_gen_config.json | 15 --------------- 2 files changed, 1 insertion(+), 15 deletions(-) delete mode 100644 tealr_doc_gen_config.json diff --git a/languages/bevy_mod_scripting_lua/src/docs.rs b/languages/bevy_mod_scripting_lua/src/docs.rs index 0c700962c3..807ae1a903 100644 --- a/languages/bevy_mod_scripting_lua/src/docs.rs +++ b/languages/bevy_mod_scripting_lua/src/docs.rs @@ -20,6 +20,7 @@ static DEFAULT_DOC_CONFIG: fn(&str) -> String = |s| { "page_root": "", "store_in": "{s}", "name": "{s}", + "is_global": true, "type_def_files": {{ "runner": "Builtin", "templates": {{ diff --git a/tealr_doc_gen_config.json b/tealr_doc_gen_config.json deleted file mode 100644 index 564e55e1d3..0000000000 --- a/tealr_doc_gen_config.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "doc_template": "Builtin", - "page_root": "", - "store_in": "BevyAPI", - "name": "BevyAPI", - "type_def_files": { - "runner": "Builtin", - "templates": { - "teal": { - "extension": ".d.tl", - "template": "Teal" - } - } - } -} \ No newline at end of file From 283ff15f659368351d5253b8f3b815298c34480e Mon Sep 17 00:00:00 2001 From: makspll Date: Fri, 19 Jan 2024 16:46:03 +0000 Subject: [PATCH 03/14] change readme --- readme.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index bafcf517fc..1c79c96175 100644 --- a/readme.md +++ b/readme.md @@ -295,7 +295,9 @@ It is probably a wise idea to set up a separate executable whose only purpose is Lua documentation is provided by `tealr`, a wrapper around the `mlua` lua API which decorates their standard types. On top of providing documentation generation, it's also capable of generating `d.tl` files which can be used to introduce static typing to lua via the `teal` project (you do not need to use teal to generate documentation). -This can all be seen at work in [this example](bevy_mod_scripting/examples/lua/documentation_gen.rs). +This can all be seen at work in [this example](bevy_mod_scripting/examples/lua/documentation_gen.rs). + +The docs for the bevy API provided in this crate are generated automatically each release onto this repo [here](https://github.com/makspll/bevy_mod_scripting_lua) and deployed [here](https://makspll.github.io/bevy_mod_scripting_lua/v0.3.0/). You might need to set the `page_root` to the path to something like: `assets/doc/YourAPI` in the automatically generated config file over at: `assets/doc/tealr_doc_gen_config.json` ##### Teal - Lua static typing From d54c65fc13ed63d700e5175ee4db324481bd36e9 Mon Sep 17 00:00:00 2001 From: makspll Date: Fri, 19 Jan 2024 17:01:26 +0000 Subject: [PATCH 04/14] re-factor CI --- .github/workflows/ci.yml | 45 +++++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7844cf4c89..85fb33ace4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,7 +34,14 @@ jobs: profile: minimal toolchain: stable override: true - - uses: Swatinem/rust-cache@v2.7.0 + - name: Configure sccache env var and set build profile to ephemeral build + run: | + echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV + echo “SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + echo “RUSTFLAGS='--cfg profile=ephemeral-build'” >> $GITHUB_ENV + + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.2 # for x86 builds - if: matrix.run_args.cross == null uses: actions-rs/cargo@v1 @@ -62,7 +69,14 @@ jobs: components: rustfmt toolchain: stable override: true - - uses: Swatinem/rust-cache@v2.7.0 + - name: Configure sccache env var and set build profile to ephemeral build + run: | + echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV + echo “SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + echo “RUSTFLAGS='--cfg profile=ephemeral-build'” >> $GITHUB_ENV + + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.2 - uses: actions-rs/cargo@v1 with: command: fmt @@ -80,7 +94,14 @@ jobs: toolchain: stable components: clippy override: true - - uses: Swatinem/rust-cache@v2.7.0 + - name: Configure sccache env var and set build profile to ephemeral build + run: | + echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV + echo “SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + echo “RUSTFLAGS='--cfg profile=ephemeral-build'” >> $GITHUB_ENV + + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.2 - uses: actions-rs/cargo@v1 with: command: clippy @@ -108,7 +129,14 @@ jobs: with: toolchain: stable override: true - - uses: Swatinem/rust-cache@v2.7.0 + - name: Configure sccache env var and set build profile to ephemeral build + run: | + echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV + echo “SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + echo “RUSTFLAGS='--cfg profile=ephemeral-build'” >> $GITHUB_ENV + + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.2 - uses: actions-rs/cargo@v1 with: command: test @@ -124,7 +152,14 @@ jobs: with: toolchain: stable override: true - - uses: Swatinem/rust-cache@v2.7.0 + - name: Configure sccache env var and set build profile to ephemeral build + run: | + echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV + echo “SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + echo “RUSTFLAGS='--cfg profile=ephemeral-build'” >> $GITHUB_ENV + + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.2 - name: Find docs.rs features run: echo "DOCS_FEATURES=$(cargo metadata --no-deps | python -c "import sys,json; [print(','.join(x['metadata']['docs.rs']['features'])) for x in json.load(sys.stdin)['packages'] if x['name'] == 'bevy_mod_scripting']")" >> $GITHUB_OUTPUT id: features From 0ea155227c2ae45fc28e57939c65e654580500a4 Mon Sep 17 00:00:00 2001 From: makspll Date: Fri, 19 Jan 2024 17:02:10 +0000 Subject: [PATCH 05/14] spaces --- .github/workflows/ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 85fb33ace4..a210c61d4e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,7 +37,7 @@ jobs: - name: Configure sccache env var and set build profile to ephemeral build run: | echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo “SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + echo “SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV echo “RUSTFLAGS='--cfg profile=ephemeral-build'” >> $GITHUB_ENV - name: Run sccache-cache @@ -72,7 +72,7 @@ jobs: - name: Configure sccache env var and set build profile to ephemeral build run: | echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo “SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + echo “SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV echo “RUSTFLAGS='--cfg profile=ephemeral-build'” >> $GITHUB_ENV - name: Run sccache-cache @@ -97,7 +97,7 @@ jobs: - name: Configure sccache env var and set build profile to ephemeral build run: | echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo “SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + echo “SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV echo “RUSTFLAGS='--cfg profile=ephemeral-build'” >> $GITHUB_ENV - name: Run sccache-cache @@ -132,7 +132,7 @@ jobs: - name: Configure sccache env var and set build profile to ephemeral build run: | echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo “SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + echo “SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV echo “RUSTFLAGS='--cfg profile=ephemeral-build'” >> $GITHUB_ENV - name: Run sccache-cache @@ -155,7 +155,7 @@ jobs: - name: Configure sccache env var and set build profile to ephemeral build run: | echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo “SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + echo “SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV echo “RUSTFLAGS='--cfg profile=ephemeral-build'” >> $GITHUB_ENV - name: Run sccache-cache From 2a483f2241528233415ccc078ec68a00f34e79b9 Mon Sep 17 00:00:00 2001 From: makspll Date: Fri, 19 Jan 2024 17:03:25 +0000 Subject: [PATCH 06/14] remove goblins --- .github/workflows/ci.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a210c61d4e..30922c7176 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,8 +37,8 @@ jobs: - name: Configure sccache env var and set build profile to ephemeral build run: | echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo “SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV - echo “RUSTFLAGS='--cfg profile=ephemeral-build'” >> $GITHUB_ENV + echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + echo "RUSTFLAGS='--cfg profile=ephemeral-build'" >> $GITHUB_ENV - name: Run sccache-cache uses: mozilla-actions/sccache-action@v0.0.2 @@ -72,8 +72,8 @@ jobs: - name: Configure sccache env var and set build profile to ephemeral build run: | echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo “SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV - echo “RUSTFLAGS='--cfg profile=ephemeral-build'” >> $GITHUB_ENV + echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + echo "RUSTFLAGS='--cfg profile=ephemeral-build'" >> $GITHUB_ENV - name: Run sccache-cache uses: mozilla-actions/sccache-action@v0.0.2 @@ -97,8 +97,8 @@ jobs: - name: Configure sccache env var and set build profile to ephemeral build run: | echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo “SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV - echo “RUSTFLAGS='--cfg profile=ephemeral-build'” >> $GITHUB_ENV + echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + echo "RUSTFLAGS='--cfg profile=ephemeral-build'" >> $GITHUB_ENV - name: Run sccache-cache uses: mozilla-actions/sccache-action@v0.0.2 @@ -132,8 +132,8 @@ jobs: - name: Configure sccache env var and set build profile to ephemeral build run: | echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo “SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV - echo “RUSTFLAGS='--cfg profile=ephemeral-build'” >> $GITHUB_ENV + echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + echo "RUSTFLAGS='--cfg profile=ephemeral-build'" >> $GITHUB_ENV - name: Run sccache-cache uses: mozilla-actions/sccache-action@v0.0.2 @@ -155,8 +155,8 @@ jobs: - name: Configure sccache env var and set build profile to ephemeral build run: | echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo “SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV - echo “RUSTFLAGS='--cfg profile=ephemeral-build'” >> $GITHUB_ENV + echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + echo "RUSTFLAGS='--cfg profile=ephemeral-build'" >> $GITHUB_ENV - name: Run sccache-cache uses: mozilla-actions/sccache-action@v0.0.2 From 1d07c8ae35f498fc5276b1a1715bfcee309fbb49 Mon Sep 17 00:00:00 2001 From: makspll Date: Fri, 19 Jan 2024 17:08:58 +0000 Subject: [PATCH 07/14] change ci --- .github/workflows/ci.yml | 39 ++++++++++----------------------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 30922c7176..faafd2f153 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,13 +35,10 @@ jobs: toolchain: stable override: true - name: Configure sccache env var and set build profile to ephemeral build - run: | - echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV - echo "RUSTFLAGS='--cfg profile=ephemeral-build'" >> $GITHUB_ENV + run: echo "RUSTFLAGS='--cfg profile=ephemeral-build'" >> $GITHUB_ENV - name: Run sccache-cache - uses: mozilla-actions/sccache-action@v0.0.2 + uses: mozilla-actions/sccache-action@v0.0.3 # for x86 builds - if: matrix.run_args.cross == null uses: actions-rs/cargo@v1 @@ -70,13 +67,9 @@ jobs: toolchain: stable override: true - name: Configure sccache env var and set build profile to ephemeral build - run: | - echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV - echo "RUSTFLAGS='--cfg profile=ephemeral-build'" >> $GITHUB_ENV - + run: echo "RUSTFLAGS='--cfg profile=ephemeral-build'" >> $GITHUB_ENV - name: Run sccache-cache - uses: mozilla-actions/sccache-action@v0.0.2 + uses: mozilla-actions/sccache-action@v0.0.3 - uses: actions-rs/cargo@v1 with: command: fmt @@ -95,13 +88,9 @@ jobs: components: clippy override: true - name: Configure sccache env var and set build profile to ephemeral build - run: | - echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV - echo "RUSTFLAGS='--cfg profile=ephemeral-build'" >> $GITHUB_ENV - + run: echo "RUSTFLAGS='--cfg profile=ephemeral-build'" >> $GITHUB_ENV - name: Run sccache-cache - uses: mozilla-actions/sccache-action@v0.0.2 + uses: mozilla-actions/sccache-action@v0.0.3 - uses: actions-rs/cargo@v1 with: command: clippy @@ -130,13 +119,9 @@ jobs: toolchain: stable override: true - name: Configure sccache env var and set build profile to ephemeral build - run: | - echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV - echo "RUSTFLAGS='--cfg profile=ephemeral-build'" >> $GITHUB_ENV - + run: echo "RUSTFLAGS='--cfg profile=ephemeral-build'" >> $GITHUB_ENV - name: Run sccache-cache - uses: mozilla-actions/sccache-action@v0.0.2 + uses: mozilla-actions/sccache-action@v0.0.3 - uses: actions-rs/cargo@v1 with: command: test @@ -153,13 +138,9 @@ jobs: toolchain: stable override: true - name: Configure sccache env var and set build profile to ephemeral build - run: | - echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV - echo "RUSTFLAGS='--cfg profile=ephemeral-build'" >> $GITHUB_ENV - + run: echo "RUSTFLAGS='--cfg profile=ephemeral-build'" >> $GITHUB_ENV - name: Run sccache-cache - uses: mozilla-actions/sccache-action@v0.0.2 + uses: mozilla-actions/sccache-action@v0.0.3 - name: Find docs.rs features run: echo "DOCS_FEATURES=$(cargo metadata --no-deps | python -c "import sys,json; [print(','.join(x['metadata']['docs.rs']['features'])) for x in json.load(sys.stdin)['packages'] if x['name'] == 'bevy_mod_scripting']")" >> $GITHUB_OUTPUT id: features From da9cd3e45d8017256774a5d043eb336973792f6c Mon Sep 17 00:00:00 2001 From: makspll Date: Fri, 19 Jan 2024 17:13:46 +0000 Subject: [PATCH 08/14] change ci --- .github/workflows/ci.yml | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index faafd2f153..07735a184d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,9 +34,6 @@ jobs: profile: minimal toolchain: stable override: true - - name: Configure sccache env var and set build profile to ephemeral build - run: echo "RUSTFLAGS='--cfg profile=ephemeral-build'" >> $GITHUB_ENV - - name: Run sccache-cache uses: mozilla-actions/sccache-action@v0.0.3 # for x86 builds @@ -51,7 +48,7 @@ jobs: with: command: check target: ${{ matrix.run_args.cross }} - args: --workspace --features=${{ matrix.run_args.lua }},rhai,teal,lua_script_api,rhai_script_api + args: --workspace --features=${{ matrix.run_args.lua }},rhai,teal,lua_script_api,rhai_script_api --profile=ephemeral-build fmt: name: Rustfmt @@ -66,8 +63,6 @@ jobs: components: rustfmt toolchain: stable override: true - - name: Configure sccache env var and set build profile to ephemeral build - run: echo "RUSTFLAGS='--cfg profile=ephemeral-build'" >> $GITHUB_ENV - name: Run sccache-cache uses: mozilla-actions/sccache-action@v0.0.3 - uses: actions-rs/cargo@v1 @@ -87,14 +82,12 @@ jobs: toolchain: stable components: clippy override: true - - name: Configure sccache env var and set build profile to ephemeral build - run: echo "RUSTFLAGS='--cfg profile=ephemeral-build'" >> $GITHUB_ENV - name: Run sccache-cache uses: mozilla-actions/sccache-action@v0.0.3 - uses: actions-rs/cargo@v1 with: command: clippy - args: --features=lua54,rhai,teal,lua_script_api,rhai_script_api -- -D warnings + args: --features=lua54,rhai,teal,lua_script_api,rhai_script_api --profile=ephemeral-build -- -D warnings tests: name: Tests runs-on: ubuntu-latest @@ -125,7 +118,7 @@ jobs: - uses: actions-rs/cargo@v1 with: command: test - args: --workspace --features=lua54,rhai,teal,lua_script_api,rhai_script_api + args: --workspace --features=lua54,rhai,teal,lua_script_api,rhai_script_api --profile=ephemeral-build docs: name: Docs runs-on: ubuntu-latest @@ -147,4 +140,4 @@ jobs: - uses: actions-rs/cargo@v1 with: command: doc - args: --workspace --features=${{ steps.features.outputs.DOCS_FEATURES }} + args: --workspace --features=${{ steps.features.outputs.DOCS_FEATURES }} --profile=ephemeral-build From 36825e74cab6937b7219372094f3445e9f070f30 Mon Sep 17 00:00:00 2001 From: makspll Date: Fri, 19 Jan 2024 17:20:01 +0000 Subject: [PATCH 09/14] change ci --- .github/workflows/ci.yml | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 07735a184d..3a8e60ae5d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,8 +34,8 @@ jobs: profile: minimal toolchain: stable override: true - - name: Run sccache-cache - uses: mozilla-actions/sccache-action@v0.0.3 + - name: Rust Cache + uses: Swatinem/rust-cache@v2.7.3 # for x86 builds - if: matrix.run_args.cross == null uses: actions-rs/cargo@v1 @@ -63,8 +63,8 @@ jobs: components: rustfmt toolchain: stable override: true - - name: Run sccache-cache - uses: mozilla-actions/sccache-action@v0.0.3 + - name: Rust Cache + uses: Swatinem/rust-cache@v2.7.3 - uses: actions-rs/cargo@v1 with: command: fmt @@ -82,8 +82,8 @@ jobs: toolchain: stable components: clippy override: true - - name: Run sccache-cache - uses: mozilla-actions/sccache-action@v0.0.3 + - name: Rust Cache + uses: Swatinem/rust-cache@v2.7.3 - uses: actions-rs/cargo@v1 with: command: clippy @@ -111,10 +111,8 @@ jobs: with: toolchain: stable override: true - - name: Configure sccache env var and set build profile to ephemeral build - run: echo "RUSTFLAGS='--cfg profile=ephemeral-build'" >> $GITHUB_ENV - - name: Run sccache-cache - uses: mozilla-actions/sccache-action@v0.0.3 + - name: Rust Cache + uses: Swatinem/rust-cache@v2.7.3 - uses: actions-rs/cargo@v1 with: command: test @@ -130,10 +128,8 @@ jobs: with: toolchain: stable override: true - - name: Configure sccache env var and set build profile to ephemeral build - run: echo "RUSTFLAGS='--cfg profile=ephemeral-build'" >> $GITHUB_ENV - - name: Run sccache-cache - uses: mozilla-actions/sccache-action@v0.0.3 + - name: Rust Cache + uses: Swatinem/rust-cache@v2.7.3 - name: Find docs.rs features run: echo "DOCS_FEATURES=$(cargo metadata --no-deps | python -c "import sys,json; [print(','.join(x['metadata']['docs.rs']['features'])) for x in json.load(sys.stdin)['packages'] if x['name'] == 'bevy_mod_scripting']")" >> $GITHUB_OUTPUT id: features From bae63ddf5ba20fc6eb9989300fe8221e308a2d28 Mon Sep 17 00:00:00 2001 From: makspll Date: Fri, 19 Jan 2024 17:21:13 +0000 Subject: [PATCH 10/14] forgot to save --- Cargo.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 948a4ef5ad..0c35121ed3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -93,6 +93,10 @@ opt-level = 1 [profile.dev.package."*"] opt-level = 3 +[profile.ephemeral-build] +opt-level = 2 +codegen-units = 8 + [[example]] name = "console_integration_lua" From 7005b7e0f58c7b9d8a3bdd13d5b03c2d27080156 Mon Sep 17 00:00:00 2001 From: makspll Date: Fri, 19 Jan 2024 17:23:25 +0000 Subject: [PATCH 11/14] add inherits --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index 0c35121ed3..e1fcb81590 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -94,6 +94,7 @@ opt-level = 1 opt-level = 3 [profile.ephemeral-build] +inherits = "release" opt-level = 2 codegen-units = 8 From 538635399acc111dde3e3da2dd34d63d9d788dff Mon Sep 17 00:00:00 2001 From: makspll Date: Fri, 19 Jan 2024 17:28:51 +0000 Subject: [PATCH 12/14] clippy --- bevy_script_api/src/lua/std.rs | 4 ++-- bevy_script_api/src/lua/util.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bevy_script_api/src/lua/std.rs b/bevy_script_api/src/lua/std.rs index 92d7b1ca08..4adeae58f6 100644 --- a/bevy_script_api/src/lua/std.rs +++ b/bevy_script_api/src/lua/std.rs @@ -1,4 +1,4 @@ -use ::std::borrow::Cow; + use bevy::reflect::FromReflect; use bevy::reflect::Reflect; @@ -14,7 +14,7 @@ use tealr::mlu::{ TealData, TealDataMethods, }; use tealr::TypeBody; -use tealr::TypeName; + use paste::paste; diff --git a/bevy_script_api/src/lua/util.rs b/bevy_script_api/src/lua/util.rs index 9c6b708228..d7e39b7959 100644 --- a/bevy_script_api/src/lua/util.rs +++ b/bevy_script_api/src/lua/util.rs @@ -7,7 +7,7 @@ use std::{ ops::{Deref, DerefMut}, }; -use tealr::TypeName; + /// Newtype abstraction of usize to represent a lua integer indexing things. /// Lua is 1 based, host is 0 based, and this type performs this conversion automatically via ToLua and FromLua traits. From 17e354e045535d119770870124e048e5086656b0 Mon Sep 17 00:00:00 2001 From: makspll Date: Fri, 19 Jan 2024 17:29:50 +0000 Subject: [PATCH 13/14] fmt --- bevy_script_api/src/lua/std.rs | 3 --- bevy_script_api/src/lua/util.rs | 2 -- 2 files changed, 5 deletions(-) diff --git a/bevy_script_api/src/lua/std.rs b/bevy_script_api/src/lua/std.rs index 4adeae58f6..9d6dbd76cb 100644 --- a/bevy_script_api/src/lua/std.rs +++ b/bevy_script_api/src/lua/std.rs @@ -1,5 +1,3 @@ - - use bevy::reflect::FromReflect; use bevy::reflect::Reflect; @@ -15,7 +13,6 @@ use tealr::mlu::{ }; use tealr::TypeBody; - use paste::paste; use crate::common::std::ScriptVec; diff --git a/bevy_script_api/src/lua/util.rs b/bevy_script_api/src/lua/util.rs index d7e39b7959..d7f2fc9894 100644 --- a/bevy_script_api/src/lua/util.rs +++ b/bevy_script_api/src/lua/util.rs @@ -7,8 +7,6 @@ use std::{ ops::{Deref, DerefMut}, }; - - /// Newtype abstraction of usize to represent a lua integer indexing things. /// Lua is 1 based, host is 0 based, and this type performs this conversion automatically via ToLua and FromLua traits. #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] From 1cc446212c92bee432fec8dcf3314814c3a063dc Mon Sep 17 00:00:00 2001 From: makspll Date: Fri, 19 Jan 2024 17:46:43 +0000 Subject: [PATCH 14/14] change profile --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index e1fcb81590..e60d32284c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -94,7 +94,7 @@ opt-level = 1 opt-level = 3 [profile.ephemeral-build] -inherits = "release" +inherits = "dev" opt-level = 2 codegen-units = 8