Skip to content

Commit 3fee82e

Browse files
authored
Make generated wrappers publically accessible (#114)
1 parent 7b295ce commit 3fee82e

File tree

12 files changed

+3431
-3431
lines changed

12 files changed

+3431
-3431
lines changed

crates/bevy_api_gen/templates/item.tera

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ functions[
7676
{% set close_item = "}" %}
7777
{% endif %}
7878

79-
pub struct {{ item.ident -}} {{ open_item }}
79+
struct {{ item.ident -}} {{ open_item }}
8080
{% if not item.is_enum %}
8181
{% for field in item.variants[0].fields %}
8282
{% if field.reflection_strategy != "Filtered" %}

crates/bevy_api_gen/templates/mod.tera

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#![cfg_attr(rustfmt, rustfmt_skip)]
55
{% filter prettyplease %}
66
{%- for crate in crates %}
7-
pub(crate) mod {{ crate.name }};
7+
pub mod {{ crate.name }};
88
{% endfor -%}
99

1010
{% if args.self_is_bevy_script_api %}

crates/bevy_script_api/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ pub mod rhai;
99
pub mod common;
1010

1111
#[cfg(feature = "lua")]
12-
pub(crate) mod core_providers;
12+
pub mod core_providers;
1313
// for now providers do not support any other lang so just remove this whole module if they are not needed
1414
#[cfg(feature = "lua")]
15-
pub(crate) mod providers;
15+
pub mod providers;
1616

1717
pub mod script_ref;
1818
pub mod sub_reflect;

crates/bevy_script_api/src/providers/bevy_core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn index(&self) -> String {
3636
}
3737
"#]
3838
)]
39-
pub struct Name {}
39+
struct Name {}
4040
#[derive(Default)]
4141
pub(crate) struct Globals;
4242
impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals {

crates/bevy_script_api/src/providers/bevy_ecs.rs

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,23 @@ use bevy_script_api::{
1212
derive(clone),
1313
remote = "bevy::ecs::entity::Entity",
1414
functions[r#"
15+
16+
#[lua(
17+
as_trait = "std::cmp::PartialEq",
18+
kind = "MetaFunction",
19+
composite = "eq",
20+
metamethod = "Eq",
21+
)]
22+
fn eq(&self, #[proxy] other: &entity::Entity) -> bool;
23+
24+
"#,
25+
r#"
26+
27+
#[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))]
28+
fn clone(&self) -> bevy::ecs::entity::Entity;
29+
30+
"#,
31+
r#"
1532
/// Creates a new entity ID with the specified `index` and a generation of 1.
1633
/// # Note
1734
/// Spawning a specific `entity` value is __rarely the right choice__. Most apps should favor
@@ -64,23 +81,6 @@ use bevy_script_api::{
6481
#[lua(kind = "Method")]
6582
fn generation(self) -> u32;
6683
67-
"#,
68-
r#"
69-
70-
#[lua(
71-
as_trait = "std::cmp::PartialEq",
72-
kind = "MetaFunction",
73-
composite = "eq",
74-
metamethod = "Eq",
75-
)]
76-
fn eq(&self, #[proxy] other: &entity::Entity) -> bool;
77-
78-
"#,
79-
r#"
80-
81-
#[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))]
82-
fn clone(&self) -> bevy::ecs::entity::Entity;
83-
8484
"#,
8585
r#"
8686
#[lua(kind="MetaMethod", metamethod="ToString")]
@@ -89,18 +89,12 @@ fn index(&self) -> String {
8989
}
9090
"#]
9191
)]
92-
pub struct Entity {}
92+
struct Entity {}
9393
#[derive(bevy_mod_scripting_lua_derive::LuaProxy)]
9494
#[proxy(
9595
derive(clone),
9696
remote = "bevy::ecs::component::ComponentId",
9797
functions[r#"
98-
99-
#[lua(as_trait = "std::cmp::Eq", kind = "Method")]
100-
fn assert_receiver_is_total_eq(&self) -> ();
101-
102-
"#,
103-
r#"
10498
/// Creates a new [`ComponentId`].
10599
/// The `index` is a unique value associated with each type of component in a given world.
106100
/// Usually, this value is taken from a counter incremented for each type of component registered with the world.
@@ -118,8 +112,8 @@ pub struct Entity {}
118112
"#,
119113
r#"
120114
121-
#[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))]
122-
fn clone(&self) -> bevy::ecs::component::ComponentId;
115+
#[lua(as_trait = "std::cmp::Eq", kind = "Method")]
116+
fn assert_receiver_is_total_eq(&self) -> ();
123117
124118
"#,
125119
r#"
@@ -132,6 +126,12 @@ pub struct Entity {}
132126
)]
133127
fn eq(&self, #[proxy] other: &component::ComponentId) -> bool;
134128
129+
"#,
130+
r#"
131+
132+
#[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))]
133+
fn clone(&self) -> bevy::ecs::component::ComponentId;
134+
135135
"#,
136136
r#"
137137
#[lua(kind="MetaMethod", metamethod="ToString")]
@@ -140,20 +140,21 @@ fn index(&self) -> String {
140140
}
141141
"#]
142142
)]
143-
pub struct ComponentId();
143+
struct ComponentId();
144144
#[derive(bevy_mod_scripting_lua_derive::LuaProxy)]
145145
#[proxy(
146146
derive(clone),
147147
remote = "bevy::ecs::component::Tick",
148148
functions[r#"
149149
150-
#[lua(
151-
as_trait = "std::cmp::PartialEq",
152-
kind = "MetaFunction",
153-
composite = "eq",
154-
metamethod = "Eq",
155-
)]
156-
fn eq(&self, #[proxy] other: &component::Tick) -> bool;
150+
#[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))]
151+
fn clone(&self) -> bevy::ecs::component::Tick;
152+
153+
"#,
154+
r#"
155+
156+
#[lua(as_trait = "std::cmp::Eq", kind = "Method")]
157+
fn assert_receiver_is_total_eq(&self) -> ();
157158
158159
"#,
159160
r#"
@@ -193,14 +194,13 @@ pub struct ComponentId();
193194
"#,
194195
r#"
195196
196-
#[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))]
197-
fn clone(&self) -> bevy::ecs::component::Tick;
198-
199-
"#,
200-
r#"
201-
202-
#[lua(as_trait = "std::cmp::Eq", kind = "Method")]
203-
fn assert_receiver_is_total_eq(&self) -> ();
197+
#[lua(
198+
as_trait = "std::cmp::PartialEq",
199+
kind = "MetaFunction",
200+
composite = "eq",
201+
metamethod = "Eq",
202+
)]
203+
fn eq(&self, #[proxy] other: &component::Tick) -> bool;
204204
205205
"#,
206206
r#"
@@ -210,12 +210,18 @@ fn index(&self) -> String {
210210
}
211211
"#]
212212
)]
213-
pub struct Tick {}
213+
struct Tick {}
214214
#[derive(bevy_mod_scripting_lua_derive::LuaProxy)]
215215
#[proxy(
216216
derive(clone),
217217
remote = "bevy::ecs::component::ComponentTicks",
218218
functions[r#"
219+
220+
#[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))]
221+
fn clone(&self) -> bevy::ecs::component::ComponentTicks;
222+
223+
"#,
224+
r#"
219225
/// Returns `true` if the component or resource was added after the system last ran.
220226
221227
#[lua(kind = "Method")]
@@ -271,12 +277,6 @@ pub struct Tick {}
271277
#[lua(kind = "MutatingMethod")]
272278
fn set_changed(&mut self, #[proxy] change_tick: bevy::ecs::component::Tick) -> ();
273279
274-
"#,
275-
r#"
276-
277-
#[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))]
278-
fn clone(&self) -> bevy::ecs::component::ComponentTicks;
279-
280280
"#,
281281
r#"
282282
#[lua(kind="MetaMethod", metamethod="ToString")]
@@ -285,7 +285,7 @@ fn index(&self) -> String {
285285
}
286286
"#]
287287
)]
288-
pub struct ComponentTicks {}
288+
struct ComponentTicks {}
289289
#[derive(bevy_mod_scripting_lua_derive::LuaProxy)]
290290
#[proxy(
291291
derive(clone),
@@ -297,7 +297,7 @@ pub struct ComponentTicks {}
297297
298298
"#]
299299
)]
300-
pub struct EntityHash {}
300+
struct EntityHash {}
301301
#[derive(Default)]
302302
pub(crate) struct Globals;
303303
impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals {

crates/bevy_script_api/src/providers/bevy_hierarchy.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,19 @@ fn index(&self) -> String {
2727
}
2828
"#]
2929
)]
30-
pub struct Children();
30+
struct Children();
3131
#[derive(bevy_mod_scripting_lua_derive::LuaProxy)]
3232
#[proxy(
3333
derive(),
3434
remote = "bevy::hierarchy::prelude::Parent",
3535
functions[r#"
36+
/// Gets the [`Entity`] ID of the parent.
37+
38+
#[lua(kind = "Method", output(proxy))]
39+
fn get(&self) -> bevy::ecs::entity::Entity;
40+
41+
"#,
42+
r#"
3643
3744
#[lua(
3845
as_trait = "std::cmp::PartialEq",
@@ -48,13 +55,6 @@ pub struct Children();
4855
#[lua(as_trait = "std::cmp::Eq", kind = "Method")]
4956
fn assert_receiver_is_total_eq(&self) -> ();
5057
51-
"#,
52-
r#"
53-
/// Gets the [`Entity`] ID of the parent.
54-
55-
#[lua(kind = "Method", output(proxy))]
56-
fn get(&self) -> bevy::ecs::entity::Entity;
57-
5858
"#,
5959
r#"
6060
#[lua(kind="MetaMethod", metamethod="ToString")]
@@ -63,7 +63,7 @@ fn index(&self) -> String {
6363
}
6464
"#]
6565
)]
66-
pub struct Parent();
66+
struct Parent();
6767
#[derive(Default)]
6868
pub(crate) struct Globals;
6969
impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals {

0 commit comments

Comments
 (0)