Skip to content

Commit

Permalink
Fix errors + regen
Browse files Browse the repository at this point in the history
  • Loading branch information
makspll committed Nov 6, 2024
1 parent 07ebdab commit 26488f2
Show file tree
Hide file tree
Showing 11 changed files with 7,688 additions and 4,119 deletions.
1 change: 1 addition & 0 deletions crates/bevy_script_api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ bevy = { workspace = true, default-features = false, features = [
"bevy_sprite",
"file_watcher",
"multi_threaded",
"bevy_reflect",
] }
uuid = "1.10"
bevy_mod_scripting_core = { workspace = true }
Expand Down
69 changes: 69 additions & 0 deletions crates/bevy_script_api/src/providers/bevy_a11y.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// @generated by cargo bevy-api-gen generate, modify the templates not this file
#![allow(clippy::all)]
#![allow(unused, deprecated, dead_code)]
#![cfg_attr(rustfmt, rustfmt_skip)]
use super::bevy_ecs::*;
use super::bevy_reflect::*;
extern crate self as bevy_script_api;
use bevy_script_api::{
lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld,
};
#[derive(bevy_mod_scripting_lua_derive::LuaProxy)]
#[proxy(derive(), remote = "bevy::a11y::Focus", functions[])]
struct Focus(ReflectedValue);
#[derive(Default)]
pub(crate) struct Globals;
impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals {
fn add_instances<
'lua,
T: bevy_mod_scripting_lua::tealr::mlu::InstanceCollector<'lua>,
>(self, instances: &mut T) -> bevy_mod_scripting_lua::tealr::mlu::mlua::Result<()> {
Ok(())
}
}
pub struct BevyA11YAPIProvider;
impl bevy_mod_scripting_core::hosts::APIProvider for BevyA11YAPIProvider {
type APITarget = std::sync::Mutex<bevy_mod_scripting_lua::tealr::mlu::mlua::Lua>;
type ScriptContext = std::sync::Mutex<bevy_mod_scripting_lua::tealr::mlu::mlua::Lua>;
type DocTarget = bevy_mod_scripting_lua::docs::LuaDocFragment;
fn attach_api(
&mut self,
ctx: &mut Self::APITarget,
) -> Result<(), bevy_mod_scripting_core::error::ScriptError> {
let ctx = ctx.get_mut().expect("Unable to acquire lock on Lua context");
bevy_mod_scripting_lua::tealr::mlu::set_global_env(Globals, ctx)
.map_err(|e| bevy_mod_scripting_core::error::ScriptError::Other(
e.to_string(),
))
}
fn get_doc_fragment(&self) -> Option<Self::DocTarget> {
Some(
bevy_mod_scripting_lua::docs::LuaDocFragment::new(
"BevyA11YAPI",
|tw| {
tw.document_global_instance::<Globals>()
.expect("Something went wrong documenting globals")
.process_type::<LuaFocus>()
},
),
)
}
fn setup_script(
&mut self,
script_data: &bevy_mod_scripting_core::hosts::ScriptData,
ctx: &mut Self::ScriptContext,
) -> Result<(), bevy_mod_scripting_core::error::ScriptError> {
Ok(())
}
fn setup_script_runtime(
&mut self,
world_ptr: bevy_mod_scripting_core::world::WorldPointer,
_script_data: &bevy_mod_scripting_core::hosts::ScriptData,
ctx: &mut Self::ScriptContext,
) -> Result<(), bevy_mod_scripting_core::error::ScriptError> {
Ok(())
}
fn register_with_app(&self, app: &mut bevy::app::App) {
app.register_foreign_lua_type::<bevy::a11y::Focus>();
}
}
130 changes: 99 additions & 31 deletions crates/bevy_script_api/src/providers/bevy_ecs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,38 +85,73 @@ use bevy_script_api::{
r#"
#[lua(kind="MetaMethod", metamethod="ToString")]
fn index(&self) -> String {
format!("{}", _self)
format!("{:?}", _self)
}
"#]
)]
struct Entity {}
#[derive(bevy_mod_scripting_lua_derive::LuaProxy)]
#[proxy(derive(), remote = "bevy::ecs::world::OnAdd", functions[])]
#[proxy(
derive(),
remote = "bevy::ecs::world::OnAdd",
functions[r#"
#[lua(kind="MetaMethod", metamethod="ToString")]
fn index(&self) -> String {
format!("{:?}", _self)
}
"#]
)]
struct OnAdd {}
#[derive(bevy_mod_scripting_lua_derive::LuaProxy)]
#[proxy(derive(), remote = "bevy::ecs::world::OnInsert", functions[])]
#[proxy(
derive(),
remote = "bevy::ecs::world::OnInsert",
functions[r#"
#[lua(kind="MetaMethod", metamethod="ToString")]
fn index(&self) -> String {
format!("{:?}", _self)
}
"#]
)]
struct OnInsert {}
#[derive(bevy_mod_scripting_lua_derive::LuaProxy)]
#[proxy(derive(), remote = "bevy::ecs::world::OnRemove", functions[])]
#[proxy(
derive(),
remote = "bevy::ecs::world::OnRemove",
functions[r#"
#[lua(kind="MetaMethod", metamethod="ToString")]
fn index(&self) -> String {
format!("{:?}", _self)
}
"#]
)]
struct OnRemove {}
#[derive(bevy_mod_scripting_lua_derive::LuaProxy)]
#[proxy(
derive(),
remote = "bevy::ecs::world::OnReplace",
functions[r#"
#[lua(kind="MetaMethod", metamethod="ToString")]
fn index(&self) -> String {
format!("{:?}", _self)
}
"#]
)]
struct OnReplace {}
#[derive(bevy_mod_scripting_lua_derive::LuaProxy)]
#[proxy(
derive(clone),
remote = "bevy::ecs::component::ComponentId",
functions[r#"
/// Creates a new [`ComponentId`].
/// The `index` is a unique value associated with each type of component in a given world.
/// Usually, this value is taken from a counter incremented for each type of component registered with the world.
#[lua(kind = "Function", output(proxy))]
fn new(index: usize) -> bevy::ecs::component::ComponentId;
#[lua(as_trait = "std::cmp::Eq", kind = "Method")]
fn assert_receiver_is_total_eq(&self) -> ();
"#,
r#"
/// Returns the index of the current component.
#[lua(kind = "Method")]
fn index(self) -> usize;
#[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))]
fn clone(&self) -> bevy::ecs::component::ComponentId;
"#,
r#"
Expand All @@ -131,15 +166,19 @@ struct OnRemove {}
"#,
r#"
/// Creates a new [`ComponentId`].
/// The `index` is a unique value associated with each type of component in a given world.
/// Usually, this value is taken from a counter incremented for each type of component registered with the world.
#[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))]
fn clone(&self) -> bevy::ecs::component::ComponentId;
#[lua(kind = "Function", output(proxy))]
fn new(index: usize) -> bevy::ecs::component::ComponentId;
"#,
r#"
/// Returns the index of the current component.
#[lua(as_trait = "std::cmp::Eq", kind = "Method")]
fn assert_receiver_is_total_eq(&self) -> ();
#[lua(kind = "Method")]
fn index(self) -> usize;
"#,
r#"
Expand All @@ -156,13 +195,8 @@ struct ComponentId();
remote = "bevy::ecs::component::Tick",
functions[r#"
#[lua(
as_trait = "std::cmp::PartialEq",
kind = "MetaFunction",
composite = "eq",
metamethod = "Eq",
)]
fn eq(&self, #[proxy] other: &component::Tick) -> bool;
#[lua(as_trait = "std::cmp::Eq", kind = "Method")]
fn assert_receiver_is_total_eq(&self) -> ();
"#,
r#"
Expand Down Expand Up @@ -208,8 +242,13 @@ struct ComponentId();
"#,
r#"
#[lua(as_trait = "std::cmp::Eq", kind = "Method")]
fn assert_receiver_is_total_eq(&self) -> ();
#[lua(
as_trait = "std::cmp::PartialEq",
kind = "MetaFunction",
composite = "eq",
metamethod = "Eq",
)]
fn eq(&self, #[proxy] other: &component::Tick) -> bool;
"#,
r#"
Expand Down Expand Up @@ -311,12 +350,6 @@ struct ComponentTicks {}
)]
fn eq(&self, #[proxy] other: &identifier::Identifier) -> bool;
"#,
r#"
#[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))]
fn clone(&self) -> bevy::ecs::identifier::Identifier;
"#,
r#"
/// Returns the value of the low segment of the [`Identifier`].
Expand Down Expand Up @@ -348,6 +381,12 @@ struct ComponentTicks {}
#[lua(kind = "Function", output(proxy))]
fn from_bits(value: u64) -> bevy::ecs::identifier::Identifier;
"#,
r#"
#[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))]
fn clone(&self) -> bevy::ecs::identifier::Identifier;
"#,
r#"
#[lua(kind="MetaMethod", metamethod="ToString")]
Expand All @@ -369,6 +408,27 @@ struct Identifier {}
"#]
)]
struct EntityHash {}
#[derive(bevy_mod_scripting_lua_derive::LuaProxy)]
#[proxy(
derive(clone),
remote = "bevy::ecs::removal_detection::RemovedComponentEntity",
functions[r#"
#[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))]
fn clone(&self) -> bevy::ecs::removal_detection::RemovedComponentEntity;
"#,
r#"
#[lua(kind="MetaMethod", metamethod="ToString")]
fn index(&self) -> String {
format!("{:?}", _self)
}
"#]
)]
struct RemovedComponentEntity();
#[derive(bevy_mod_scripting_lua_derive::LuaProxy)]
#[proxy(derive(), remote = "bevy::ecs::system::SystemIdMarker", functions[])]
struct SystemIdMarker {}
#[derive(Default)]
pub(crate) struct Globals;
impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals {
Expand Down Expand Up @@ -428,6 +488,7 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyEcsAPIProvider {
.process_type::<LuaOnAdd>()
.process_type::<LuaOnInsert>()
.process_type::<LuaOnRemove>()
.process_type::<LuaOnReplace>()
.process_type::<LuaComponentId>()
.process_type::<
bevy_mod_scripting_lua::tealr::mlu::UserDataProxy<
Expand All @@ -446,6 +507,8 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyEcsAPIProvider {
>,
>()
.process_type::<LuaEntityHash>()
.process_type::<LuaRemovedComponentEntity>()
.process_type::<LuaSystemIdMarker>()
},
),
)
Expand All @@ -470,10 +533,15 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyEcsAPIProvider {
app.register_foreign_lua_type::<bevy::ecs::world::OnAdd>();
app.register_foreign_lua_type::<bevy::ecs::world::OnInsert>();
app.register_foreign_lua_type::<bevy::ecs::world::OnRemove>();
app.register_foreign_lua_type::<bevy::ecs::world::OnReplace>();
app.register_foreign_lua_type::<bevy::ecs::component::ComponentId>();
app.register_foreign_lua_type::<bevy::ecs::component::Tick>();
app.register_foreign_lua_type::<bevy::ecs::component::ComponentTicks>();
app.register_foreign_lua_type::<bevy::ecs::identifier::Identifier>();
app.register_foreign_lua_type::<bevy::ecs::entity::EntityHash>();
app.register_foreign_lua_type::<
bevy::ecs::removal_detection::RemovedComponentEntity,
>();
app.register_foreign_lua_type::<bevy::ecs::system::SystemIdMarker>();
}
}
45 changes: 41 additions & 4 deletions crates/bevy_script_api/src/providers/bevy_hierarchy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,46 @@ struct Children();
derive(),
remote = "bevy::hierarchy::prelude::Parent",
functions[r#"
#[lua(
as_trait = "std::cmp::PartialEq",
kind = "MetaFunction",
composite = "eq",
metamethod = "Eq",
)]
fn eq(&self, #[proxy] other: &components::parent::Parent) -> bool;
"#,
r#"
/// Gets the [`Entity`] ID of the parent.
#[lua(kind = "Method", output(proxy))]
fn get(&self) -> bevy::ecs::entity::Entity;
"#,
r#"
#[lua(as_trait = "std::cmp::Eq", kind = "Method")]
fn assert_receiver_is_total_eq(&self) -> ();
"#,
r#"
#[lua(kind="MetaMethod", metamethod="ToString")]
fn index(&self) -> String {
format!("{:?}", _self)
}
"#]
)]
struct Parent();
#[derive(bevy_mod_scripting_lua_derive::LuaProxy)]
#[proxy(
derive(clone),
remote = "bevy::hierarchy::HierarchyEvent",
functions[r#"
#[lua(as_trait = "std::cmp::Eq", kind = "Method")]
fn assert_receiver_is_total_eq(&self) -> ();
"#,
r#"
Expand All @@ -47,13 +82,13 @@ struct Children();
composite = "eq",
metamethod = "Eq",
)]
fn eq(&self, #[proxy] other: &components::parent::Parent) -> bool;
fn eq(&self, #[proxy] other: &events::HierarchyEvent) -> bool;
"#,
r#"
#[lua(as_trait = "std::cmp::Eq", kind = "Method")]
fn assert_receiver_is_total_eq(&self) -> ();
#[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))]
fn clone(&self) -> bevy::hierarchy::HierarchyEvent;
"#,
r#"
Expand All @@ -63,7 +98,7 @@ fn index(&self) -> String {
}
"#]
)]
struct Parent();
struct HierarchyEvent {}
#[derive(Default)]
pub(crate) struct Globals;
impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals {
Expand Down Expand Up @@ -98,6 +133,7 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyHierarchyAPIProvider {
.expect("Something went wrong documenting globals")
.process_type::<LuaChildren>()
.process_type::<LuaParent>()
.process_type::<LuaHierarchyEvent>()
},
),
)
Expand All @@ -120,5 +156,6 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyHierarchyAPIProvider {
fn register_with_app(&self, app: &mut bevy::app::App) {
app.register_foreign_lua_type::<bevy::hierarchy::prelude::Children>();
app.register_foreign_lua_type::<bevy::hierarchy::prelude::Parent>();
app.register_foreign_lua_type::<bevy::hierarchy::HierarchyEvent>();
}
}
Loading

0 comments on commit 26488f2

Please sign in to comment.