Skip to content

Commit 26488f2

Browse files
committed
Fix errors + regen
1 parent 07ebdab commit 26488f2

File tree

11 files changed

+7688
-4119
lines changed

11 files changed

+7688
-4119
lines changed

crates/bevy_script_api/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ bevy = { workspace = true, default-features = false, features = [
2828
"bevy_sprite",
2929
"file_watcher",
3030
"multi_threaded",
31+
"bevy_reflect",
3132
] }
3233
uuid = "1.10"
3334
bevy_mod_scripting_core = { workspace = true }
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// @generated by cargo bevy-api-gen generate, modify the templates not this file
2+
#![allow(clippy::all)]
3+
#![allow(unused, deprecated, dead_code)]
4+
#![cfg_attr(rustfmt, rustfmt_skip)]
5+
use super::bevy_ecs::*;
6+
use super::bevy_reflect::*;
7+
extern crate self as bevy_script_api;
8+
use bevy_script_api::{
9+
lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld,
10+
};
11+
#[derive(bevy_mod_scripting_lua_derive::LuaProxy)]
12+
#[proxy(derive(), remote = "bevy::a11y::Focus", functions[])]
13+
struct Focus(ReflectedValue);
14+
#[derive(Default)]
15+
pub(crate) struct Globals;
16+
impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals {
17+
fn add_instances<
18+
'lua,
19+
T: bevy_mod_scripting_lua::tealr::mlu::InstanceCollector<'lua>,
20+
>(self, instances: &mut T) -> bevy_mod_scripting_lua::tealr::mlu::mlua::Result<()> {
21+
Ok(())
22+
}
23+
}
24+
pub struct BevyA11YAPIProvider;
25+
impl bevy_mod_scripting_core::hosts::APIProvider for BevyA11YAPIProvider {
26+
type APITarget = std::sync::Mutex<bevy_mod_scripting_lua::tealr::mlu::mlua::Lua>;
27+
type ScriptContext = std::sync::Mutex<bevy_mod_scripting_lua::tealr::mlu::mlua::Lua>;
28+
type DocTarget = bevy_mod_scripting_lua::docs::LuaDocFragment;
29+
fn attach_api(
30+
&mut self,
31+
ctx: &mut Self::APITarget,
32+
) -> Result<(), bevy_mod_scripting_core::error::ScriptError> {
33+
let ctx = ctx.get_mut().expect("Unable to acquire lock on Lua context");
34+
bevy_mod_scripting_lua::tealr::mlu::set_global_env(Globals, ctx)
35+
.map_err(|e| bevy_mod_scripting_core::error::ScriptError::Other(
36+
e.to_string(),
37+
))
38+
}
39+
fn get_doc_fragment(&self) -> Option<Self::DocTarget> {
40+
Some(
41+
bevy_mod_scripting_lua::docs::LuaDocFragment::new(
42+
"BevyA11YAPI",
43+
|tw| {
44+
tw.document_global_instance::<Globals>()
45+
.expect("Something went wrong documenting globals")
46+
.process_type::<LuaFocus>()
47+
},
48+
),
49+
)
50+
}
51+
fn setup_script(
52+
&mut self,
53+
script_data: &bevy_mod_scripting_core::hosts::ScriptData,
54+
ctx: &mut Self::ScriptContext,
55+
) -> Result<(), bevy_mod_scripting_core::error::ScriptError> {
56+
Ok(())
57+
}
58+
fn setup_script_runtime(
59+
&mut self,
60+
world_ptr: bevy_mod_scripting_core::world::WorldPointer,
61+
_script_data: &bevy_mod_scripting_core::hosts::ScriptData,
62+
ctx: &mut Self::ScriptContext,
63+
) -> Result<(), bevy_mod_scripting_core::error::ScriptError> {
64+
Ok(())
65+
}
66+
fn register_with_app(&self, app: &mut bevy::app::App) {
67+
app.register_foreign_lua_type::<bevy::a11y::Focus>();
68+
}
69+
}

crates/bevy_script_api/src/providers/bevy_ecs.rs

Lines changed: 99 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -85,38 +85,73 @@ use bevy_script_api::{
8585
r#"
8686
#[lua(kind="MetaMethod", metamethod="ToString")]
8787
fn index(&self) -> String {
88-
format!("{}", _self)
88+
format!("{:?}", _self)
8989
}
9090
"#]
9191
)]
9292
struct Entity {}
9393
#[derive(bevy_mod_scripting_lua_derive::LuaProxy)]
94-
#[proxy(derive(), remote = "bevy::ecs::world::OnAdd", functions[])]
94+
#[proxy(
95+
derive(),
96+
remote = "bevy::ecs::world::OnAdd",
97+
functions[r#"
98+
#[lua(kind="MetaMethod", metamethod="ToString")]
99+
fn index(&self) -> String {
100+
format!("{:?}", _self)
101+
}
102+
"#]
103+
)]
95104
struct OnAdd {}
96105
#[derive(bevy_mod_scripting_lua_derive::LuaProxy)]
97-
#[proxy(derive(), remote = "bevy::ecs::world::OnInsert", functions[])]
106+
#[proxy(
107+
derive(),
108+
remote = "bevy::ecs::world::OnInsert",
109+
functions[r#"
110+
#[lua(kind="MetaMethod", metamethod="ToString")]
111+
fn index(&self) -> String {
112+
format!("{:?}", _self)
113+
}
114+
"#]
115+
)]
98116
struct OnInsert {}
99117
#[derive(bevy_mod_scripting_lua_derive::LuaProxy)]
100-
#[proxy(derive(), remote = "bevy::ecs::world::OnRemove", functions[])]
118+
#[proxy(
119+
derive(),
120+
remote = "bevy::ecs::world::OnRemove",
121+
functions[r#"
122+
#[lua(kind="MetaMethod", metamethod="ToString")]
123+
fn index(&self) -> String {
124+
format!("{:?}", _self)
125+
}
126+
"#]
127+
)]
101128
struct OnRemove {}
102129
#[derive(bevy_mod_scripting_lua_derive::LuaProxy)]
130+
#[proxy(
131+
derive(),
132+
remote = "bevy::ecs::world::OnReplace",
133+
functions[r#"
134+
#[lua(kind="MetaMethod", metamethod="ToString")]
135+
fn index(&self) -> String {
136+
format!("{:?}", _self)
137+
}
138+
"#]
139+
)]
140+
struct OnReplace {}
141+
#[derive(bevy_mod_scripting_lua_derive::LuaProxy)]
103142
#[proxy(
104143
derive(clone),
105144
remote = "bevy::ecs::component::ComponentId",
106145
functions[r#"
107-
/// Creates a new [`ComponentId`].
108-
/// The `index` is a unique value associated with each type of component in a given world.
109-
/// Usually, this value is taken from a counter incremented for each type of component registered with the world.
110146
111-
#[lua(kind = "Function", output(proxy))]
112-
fn new(index: usize) -> bevy::ecs::component::ComponentId;
147+
#[lua(as_trait = "std::cmp::Eq", kind = "Method")]
148+
fn assert_receiver_is_total_eq(&self) -> ();
113149
114150
"#,
115151
r#"
116-
/// Returns the index of the current component.
117152
118-
#[lua(kind = "Method")]
119-
fn index(self) -> usize;
153+
#[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))]
154+
fn clone(&self) -> bevy::ecs::component::ComponentId;
120155
121156
"#,
122157
r#"
@@ -131,15 +166,19 @@ struct OnRemove {}
131166
132167
"#,
133168
r#"
169+
/// Creates a new [`ComponentId`].
170+
/// The `index` is a unique value associated with each type of component in a given world.
171+
/// Usually, this value is taken from a counter incremented for each type of component registered with the world.
134172
135-
#[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))]
136-
fn clone(&self) -> bevy::ecs::component::ComponentId;
173+
#[lua(kind = "Function", output(proxy))]
174+
fn new(index: usize) -> bevy::ecs::component::ComponentId;
137175
138176
"#,
139177
r#"
178+
/// Returns the index of the current component.
140179
141-
#[lua(as_trait = "std::cmp::Eq", kind = "Method")]
142-
fn assert_receiver_is_total_eq(&self) -> ();
180+
#[lua(kind = "Method")]
181+
fn index(self) -> usize;
143182
144183
"#,
145184
r#"
@@ -156,13 +195,8 @@ struct ComponentId();
156195
remote = "bevy::ecs::component::Tick",
157196
functions[r#"
158197
159-
#[lua(
160-
as_trait = "std::cmp::PartialEq",
161-
kind = "MetaFunction",
162-
composite = "eq",
163-
metamethod = "Eq",
164-
)]
165-
fn eq(&self, #[proxy] other: &component::Tick) -> bool;
198+
#[lua(as_trait = "std::cmp::Eq", kind = "Method")]
199+
fn assert_receiver_is_total_eq(&self) -> ();
166200
167201
"#,
168202
r#"
@@ -208,8 +242,13 @@ struct ComponentId();
208242
"#,
209243
r#"
210244
211-
#[lua(as_trait = "std::cmp::Eq", kind = "Method")]
212-
fn assert_receiver_is_total_eq(&self) -> ();
245+
#[lua(
246+
as_trait = "std::cmp::PartialEq",
247+
kind = "MetaFunction",
248+
composite = "eq",
249+
metamethod = "Eq",
250+
)]
251+
fn eq(&self, #[proxy] other: &component::Tick) -> bool;
213252
214253
"#,
215254
r#"
@@ -311,12 +350,6 @@ struct ComponentTicks {}
311350
)]
312351
fn eq(&self, #[proxy] other: &identifier::Identifier) -> bool;
313352
314-
"#,
315-
r#"
316-
317-
#[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))]
318-
fn clone(&self) -> bevy::ecs::identifier::Identifier;
319-
320353
"#,
321354
r#"
322355
/// Returns the value of the low segment of the [`Identifier`].
@@ -348,6 +381,12 @@ struct ComponentTicks {}
348381
#[lua(kind = "Function", output(proxy))]
349382
fn from_bits(value: u64) -> bevy::ecs::identifier::Identifier;
350383
384+
"#,
385+
r#"
386+
387+
#[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))]
388+
fn clone(&self) -> bevy::ecs::identifier::Identifier;
389+
351390
"#,
352391
r#"
353392
#[lua(kind="MetaMethod", metamethod="ToString")]
@@ -369,6 +408,27 @@ struct Identifier {}
369408
"#]
370409
)]
371410
struct EntityHash {}
411+
#[derive(bevy_mod_scripting_lua_derive::LuaProxy)]
412+
#[proxy(
413+
derive(clone),
414+
remote = "bevy::ecs::removal_detection::RemovedComponentEntity",
415+
functions[r#"
416+
417+
#[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))]
418+
fn clone(&self) -> bevy::ecs::removal_detection::RemovedComponentEntity;
419+
420+
"#,
421+
r#"
422+
#[lua(kind="MetaMethod", metamethod="ToString")]
423+
fn index(&self) -> String {
424+
format!("{:?}", _self)
425+
}
426+
"#]
427+
)]
428+
struct RemovedComponentEntity();
429+
#[derive(bevy_mod_scripting_lua_derive::LuaProxy)]
430+
#[proxy(derive(), remote = "bevy::ecs::system::SystemIdMarker", functions[])]
431+
struct SystemIdMarker {}
372432
#[derive(Default)]
373433
pub(crate) struct Globals;
374434
impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals {
@@ -428,6 +488,7 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyEcsAPIProvider {
428488
.process_type::<LuaOnAdd>()
429489
.process_type::<LuaOnInsert>()
430490
.process_type::<LuaOnRemove>()
491+
.process_type::<LuaOnReplace>()
431492
.process_type::<LuaComponentId>()
432493
.process_type::<
433494
bevy_mod_scripting_lua::tealr::mlu::UserDataProxy<
@@ -446,6 +507,8 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyEcsAPIProvider {
446507
>,
447508
>()
448509
.process_type::<LuaEntityHash>()
510+
.process_type::<LuaRemovedComponentEntity>()
511+
.process_type::<LuaSystemIdMarker>()
449512
},
450513
),
451514
)
@@ -470,10 +533,15 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyEcsAPIProvider {
470533
app.register_foreign_lua_type::<bevy::ecs::world::OnAdd>();
471534
app.register_foreign_lua_type::<bevy::ecs::world::OnInsert>();
472535
app.register_foreign_lua_type::<bevy::ecs::world::OnRemove>();
536+
app.register_foreign_lua_type::<bevy::ecs::world::OnReplace>();
473537
app.register_foreign_lua_type::<bevy::ecs::component::ComponentId>();
474538
app.register_foreign_lua_type::<bevy::ecs::component::Tick>();
475539
app.register_foreign_lua_type::<bevy::ecs::component::ComponentTicks>();
476540
app.register_foreign_lua_type::<bevy::ecs::identifier::Identifier>();
477541
app.register_foreign_lua_type::<bevy::ecs::entity::EntityHash>();
542+
app.register_foreign_lua_type::<
543+
bevy::ecs::removal_detection::RemovedComponentEntity,
544+
>();
545+
app.register_foreign_lua_type::<bevy::ecs::system::SystemIdMarker>();
478546
}
479547
}

crates/bevy_script_api/src/providers/bevy_hierarchy.rs

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,46 @@ struct Children();
3333
derive(),
3434
remote = "bevy::hierarchy::prelude::Parent",
3535
functions[r#"
36+
37+
#[lua(
38+
as_trait = "std::cmp::PartialEq",
39+
kind = "MetaFunction",
40+
composite = "eq",
41+
metamethod = "Eq",
42+
)]
43+
fn eq(&self, #[proxy] other: &components::parent::Parent) -> bool;
44+
45+
"#,
46+
r#"
3647
/// Gets the [`Entity`] ID of the parent.
3748
3849
#[lua(kind = "Method", output(proxy))]
3950
fn get(&self) -> bevy::ecs::entity::Entity;
4051
52+
"#,
53+
r#"
54+
55+
#[lua(as_trait = "std::cmp::Eq", kind = "Method")]
56+
fn assert_receiver_is_total_eq(&self) -> ();
57+
58+
"#,
59+
r#"
60+
#[lua(kind="MetaMethod", metamethod="ToString")]
61+
fn index(&self) -> String {
62+
format!("{:?}", _self)
63+
}
64+
"#]
65+
)]
66+
struct Parent();
67+
#[derive(bevy_mod_scripting_lua_derive::LuaProxy)]
68+
#[proxy(
69+
derive(clone),
70+
remote = "bevy::hierarchy::HierarchyEvent",
71+
functions[r#"
72+
73+
#[lua(as_trait = "std::cmp::Eq", kind = "Method")]
74+
fn assert_receiver_is_total_eq(&self) -> ();
75+
4176
"#,
4277
r#"
4378
@@ -47,13 +82,13 @@ struct Children();
4782
composite = "eq",
4883
metamethod = "Eq",
4984
)]
50-
fn eq(&self, #[proxy] other: &components::parent::Parent) -> bool;
85+
fn eq(&self, #[proxy] other: &events::HierarchyEvent) -> bool;
5186
5287
"#,
5388
r#"
5489
55-
#[lua(as_trait = "std::cmp::Eq", kind = "Method")]
56-
fn assert_receiver_is_total_eq(&self) -> ();
90+
#[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))]
91+
fn clone(&self) -> bevy::hierarchy::HierarchyEvent;
5792
5893
"#,
5994
r#"
@@ -63,7 +98,7 @@ fn index(&self) -> String {
6398
}
6499
"#]
65100
)]
66-
struct Parent();
101+
struct HierarchyEvent {}
67102
#[derive(Default)]
68103
pub(crate) struct Globals;
69104
impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals {
@@ -98,6 +133,7 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyHierarchyAPIProvider {
98133
.expect("Something went wrong documenting globals")
99134
.process_type::<LuaChildren>()
100135
.process_type::<LuaParent>()
136+
.process_type::<LuaHierarchyEvent>()
101137
},
102138
),
103139
)
@@ -120,5 +156,6 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyHierarchyAPIProvider {
120156
fn register_with_app(&self, app: &mut bevy::app::App) {
121157
app.register_foreign_lua_type::<bevy::hierarchy::prelude::Children>();
122158
app.register_foreign_lua_type::<bevy::hierarchy::prelude::Parent>();
159+
app.register_foreign_lua_type::<bevy::hierarchy::HierarchyEvent>();
123160
}
124161
}

0 commit comments

Comments
 (0)