Skip to content

Commit 7921e19

Browse files
chore: Fix bindings stability, order things more (#200)
* chore: sort functions in bevy_api_gen * chore(codegen): update bevy bindings (#201) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * chore: trigger ci --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent d9bfc37 commit 7921e19

File tree

12 files changed

+10769
-10777
lines changed

12 files changed

+10769
-10777
lines changed

.github/workflows/generate_bindings.yml

-7
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,6 @@ name: Generate Bindings (Bevy, Glam)
22

33
on:
44
workflow_call:
5-
# inputs:
6-
# config-path:
7-
# required: true
8-
# type: string
9-
# secrets:
10-
# token:
11-
# required: true
125
workflow_dispatch:
136

147
env:

crates/bevy_api_gen/src/passes/populate_template_data.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ pub(crate) fn populate_template_data(ctxt: &mut BevyCtxt<'_>, args: &Args) -> bo
3131

3232
let has_static_methods = fn_ctxts.iter().any(|fn_ctxt| !fn_ctxt.has_self);
3333

34-
let functions = process_functions(ctxt, fn_ctxts);
34+
let mut functions = process_functions(ctxt, fn_ctxts);
35+
functions.sort_by(|a, b| a.ident.cmp(&b.ident));
36+
3537
let variant = ty_ctxt.variant_data.as_ref().unwrap();
3638

3739
let is_tuple_struct = variant.is_struct()

crates/bevy_mod_scripting_functions/src/bevy_bindings/bevy_core.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ impl ::bevy::app::Plugin for BevyCoreScriptingPlugin {
2020
fn build(&self, app: &mut ::bevy::prelude::App) {
2121
let mut world = app.world_mut();
2222
NamespaceBuilder::<::bevy::core::prelude::Name>::new(world)
23+
.register(
24+
"clone",
25+
|_self: Ref<bevy::core::prelude::Name>| {
26+
let output: Val<bevy::core::prelude::Name> = <bevy::core::prelude::Name as std::clone::Clone>::clone(
27+
&_self,
28+
)
29+
.into();
30+
output
31+
},
32+
)
2333
.register(
2434
"eq",
2535
|
@@ -32,16 +42,6 @@ impl ::bevy::app::Plugin for BevyCoreScriptingPlugin {
3242
.into();
3343
output
3444
},
35-
)
36-
.register(
37-
"clone",
38-
|_self: Ref<bevy::core::prelude::Name>| {
39-
let output: Val<bevy::core::prelude::Name> = <bevy::core::prelude::Name as std::clone::Clone>::clone(
40-
&_self,
41-
)
42-
.into();
43-
output
44-
},
4545
);
4646
}
4747
}

crates/bevy_mod_scripting_functions/src/bevy_bindings/bevy_ecs.rs

+74-74
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,24 @@ impl ::bevy::app::Plugin for BevyEcsScriptingPlugin {
2020
let mut world = app.world_mut();
2121
NamespaceBuilder::<::bevy::ecs::entity::Entity>::new(world)
2222
.register(
23-
"from_raw",
24-
|index: u32| {
25-
let output: Val<bevy::ecs::entity::Entity> = bevy::ecs::entity::Entity::from_raw(
26-
index,
23+
"clone",
24+
|_self: Ref<bevy::ecs::entity::Entity>| {
25+
let output: Val<bevy::ecs::entity::Entity> = <bevy::ecs::entity::Entity as std::clone::Clone>::clone(
26+
&_self,
2727
)
2828
.into();
2929
output
3030
},
3131
)
3232
.register(
33-
"to_bits",
34-
|_self: Val<bevy::ecs::entity::Entity>| {
35-
let output: u64 = bevy::ecs::entity::Entity::to_bits(
36-
_self.into_inner(),
37-
)
33+
"eq",
34+
|
35+
_self: Ref<bevy::ecs::entity::Entity>,
36+
other: Ref<bevy::ecs::entity::Entity>|
37+
{
38+
let output: bool = <bevy::ecs::entity::Entity as std::cmp::PartialEq<
39+
bevy::ecs::entity::Entity,
40+
>>::eq(&_self, &other)
3841
.into();
3942
output
4043
},
@@ -50,10 +53,10 @@ impl ::bevy::app::Plugin for BevyEcsScriptingPlugin {
5053
},
5154
)
5255
.register(
53-
"index",
54-
|_self: Val<bevy::ecs::entity::Entity>| {
55-
let output: u32 = bevy::ecs::entity::Entity::index(
56-
_self.into_inner(),
56+
"from_raw",
57+
|index: u32| {
58+
let output: Val<bevy::ecs::entity::Entity> = bevy::ecs::entity::Entity::from_raw(
59+
index,
5760
)
5861
.into();
5962
output
@@ -70,24 +73,21 @@ impl ::bevy::app::Plugin for BevyEcsScriptingPlugin {
7073
},
7174
)
7275
.register(
73-
"clone",
74-
|_self: Ref<bevy::ecs::entity::Entity>| {
75-
let output: Val<bevy::ecs::entity::Entity> = <bevy::ecs::entity::Entity as std::clone::Clone>::clone(
76-
&_self,
76+
"index",
77+
|_self: Val<bevy::ecs::entity::Entity>| {
78+
let output: u32 = bevy::ecs::entity::Entity::index(
79+
_self.into_inner(),
7780
)
7881
.into();
7982
output
8083
},
8184
)
8285
.register(
83-
"eq",
84-
|
85-
_self: Ref<bevy::ecs::entity::Entity>,
86-
other: Ref<bevy::ecs::entity::Entity>|
87-
{
88-
let output: bool = <bevy::ecs::entity::Entity as std::cmp::PartialEq<
89-
bevy::ecs::entity::Entity,
90-
>>::eq(&_self, &other)
86+
"to_bits",
87+
|_self: Val<bevy::ecs::entity::Entity>| {
88+
let output: u64 = bevy::ecs::entity::Entity::to_bits(
89+
_self.into_inner(),
90+
)
9191
.into();
9292
output
9393
},
@@ -107,6 +107,16 @@ impl ::bevy::app::Plugin for BevyEcsScriptingPlugin {
107107
output
108108
},
109109
)
110+
.register(
111+
"clone",
112+
|_self: Ref<bevy::ecs::component::ComponentId>| {
113+
let output: Val<bevy::ecs::component::ComponentId> = <bevy::ecs::component::ComponentId as std::clone::Clone>::clone(
114+
&_self,
115+
)
116+
.into();
117+
output
118+
},
119+
)
110120
.register(
111121
"eq",
112122
|
@@ -121,10 +131,10 @@ impl ::bevy::app::Plugin for BevyEcsScriptingPlugin {
121131
},
122132
)
123133
.register(
124-
"clone",
125-
|_self: Ref<bevy::ecs::component::ComponentId>| {
126-
let output: Val<bevy::ecs::component::ComponentId> = <bevy::ecs::component::ComponentId as std::clone::Clone>::clone(
127-
&_self,
134+
"index",
135+
|_self: Val<bevy::ecs::component::ComponentId>| {
136+
let output: usize = bevy::ecs::component::ComponentId::index(
137+
_self.into_inner(),
128138
)
129139
.into();
130140
output
@@ -139,22 +149,22 @@ impl ::bevy::app::Plugin for BevyEcsScriptingPlugin {
139149
.into();
140150
output
141151
},
142-
)
152+
);
153+
NamespaceBuilder::<::bevy::ecs::component::Tick>::new(world)
143154
.register(
144-
"index",
145-
|_self: Val<bevy::ecs::component::ComponentId>| {
146-
let output: usize = bevy::ecs::component::ComponentId::index(
147-
_self.into_inner(),
155+
"assert_receiver_is_total_eq",
156+
|_self: Ref<bevy::ecs::component::Tick>| {
157+
let output: () = <bevy::ecs::component::Tick as std::cmp::Eq>::assert_receiver_is_total_eq(
158+
&_self,
148159
)
149160
.into();
150161
output
151162
},
152-
);
153-
NamespaceBuilder::<::bevy::ecs::component::Tick>::new(world)
163+
)
154164
.register(
155-
"assert_receiver_is_total_eq",
165+
"clone",
156166
|_self: Ref<bevy::ecs::component::Tick>| {
157-
let output: () = <bevy::ecs::component::Tick as std::cmp::Eq>::assert_receiver_is_total_eq(
167+
let output: Val<bevy::ecs::component::Tick> = <bevy::ecs::component::Tick as std::clone::Clone>::clone(
158168
&_self,
159169
)
160170
.into();
@@ -174,16 +184,6 @@ impl ::bevy::app::Plugin for BevyEcsScriptingPlugin {
174184
output
175185
},
176186
)
177-
.register(
178-
"new",
179-
|tick: u32| {
180-
let output: Val<bevy::ecs::component::Tick> = bevy::ecs::component::Tick::new(
181-
tick,
182-
)
183-
.into();
184-
output
185-
},
186-
)
187187
.register(
188188
"get",
189189
|_self: Val<bevy::ecs::component::Tick>| {
@@ -192,14 +192,6 @@ impl ::bevy::app::Plugin for BevyEcsScriptingPlugin {
192192
output
193193
},
194194
)
195-
.register(
196-
"set",
197-
|mut _self: Mut<bevy::ecs::component::Tick>, tick: u32| {
198-
let output: () = bevy::ecs::component::Tick::set(&mut _self, tick)
199-
.into();
200-
output
201-
},
202-
)
203195
.register(
204196
"is_newer_than",
205197
|
@@ -217,14 +209,22 @@ impl ::bevy::app::Plugin for BevyEcsScriptingPlugin {
217209
},
218210
)
219211
.register(
220-
"clone",
221-
|_self: Ref<bevy::ecs::component::Tick>| {
222-
let output: Val<bevy::ecs::component::Tick> = <bevy::ecs::component::Tick as std::clone::Clone>::clone(
223-
&_self,
212+
"new",
213+
|tick: u32| {
214+
let output: Val<bevy::ecs::component::Tick> = bevy::ecs::component::Tick::new(
215+
tick,
224216
)
225217
.into();
226218
output
227219
},
220+
)
221+
.register(
222+
"set",
223+
|mut _self: Mut<bevy::ecs::component::Tick>, tick: u32| {
224+
let output: () = bevy::ecs::component::Tick::set(&mut _self, tick)
225+
.into();
226+
output
227+
},
228228
);
229229
NamespaceBuilder::<::bevy::ecs::component::ComponentTicks>::new(world)
230230
.register(
@@ -294,6 +294,16 @@ impl ::bevy::app::Plugin for BevyEcsScriptingPlugin {
294294
},
295295
);
296296
NamespaceBuilder::<::bevy::ecs::identifier::Identifier>::new(world)
297+
.register(
298+
"clone",
299+
|_self: Ref<bevy::ecs::identifier::Identifier>| {
300+
let output: Val<bevy::ecs::identifier::Identifier> = <bevy::ecs::identifier::Identifier as std::clone::Clone>::clone(
301+
&_self,
302+
)
303+
.into();
304+
output
305+
},
306+
)
297307
.register(
298308
"eq",
299309
|
@@ -308,10 +318,10 @@ impl ::bevy::app::Plugin for BevyEcsScriptingPlugin {
308318
},
309319
)
310320
.register(
311-
"clone",
312-
|_self: Ref<bevy::ecs::identifier::Identifier>| {
313-
let output: Val<bevy::ecs::identifier::Identifier> = <bevy::ecs::identifier::Identifier as std::clone::Clone>::clone(
314-
&_self,
321+
"from_bits",
322+
|value: u64| {
323+
let output: Val<bevy::ecs::identifier::Identifier> = bevy::ecs::identifier::Identifier::from_bits(
324+
value,
315325
)
316326
.into();
317327
output
@@ -346,16 +356,6 @@ impl ::bevy::app::Plugin for BevyEcsScriptingPlugin {
346356
.into();
347357
output
348358
},
349-
)
350-
.register(
351-
"from_bits",
352-
|value: u64| {
353-
let output: Val<bevy::ecs::identifier::Identifier> = bevy::ecs::identifier::Identifier::from_bits(
354-
value,
355-
)
356-
.into();
357-
output
358-
},
359359
);
360360
NamespaceBuilder::<::bevy::ecs::entity::EntityHash>::new(world)
361361
.register(

crates/bevy_mod_scripting_functions/src/bevy_bindings/bevy_hierarchy.rs

+22-22
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ impl ::bevy::app::Plugin for BevyHierarchyScriptingPlugin {
3838
},
3939
);
4040
NamespaceBuilder::<::bevy::hierarchy::prelude::Parent>::new(world)
41+
.register(
42+
"assert_receiver_is_total_eq",
43+
|_self: Ref<bevy::hierarchy::prelude::Parent>| {
44+
let output: () = <bevy::hierarchy::prelude::Parent as std::cmp::Eq>::assert_receiver_is_total_eq(
45+
&_self,
46+
)
47+
.into();
48+
output
49+
},
50+
)
4151
.register(
4252
"eq",
4353
|
@@ -50,30 +60,17 @@ impl ::bevy::app::Plugin for BevyHierarchyScriptingPlugin {
5060
.into();
5161
output
5262
},
53-
)
63+
);
64+
NamespaceBuilder::<::bevy::hierarchy::HierarchyEvent>::new(world)
5465
.register(
5566
"assert_receiver_is_total_eq",
56-
|_self: Ref<bevy::hierarchy::prelude::Parent>| {
57-
let output: () = <bevy::hierarchy::prelude::Parent as std::cmp::Eq>::assert_receiver_is_total_eq(
67+
|_self: Ref<bevy::hierarchy::HierarchyEvent>| {
68+
let output: () = <bevy::hierarchy::HierarchyEvent as std::cmp::Eq>::assert_receiver_is_total_eq(
5869
&_self,
5970
)
6071
.into();
6172
output
6273
},
63-
);
64-
NamespaceBuilder::<::bevy::hierarchy::HierarchyEvent>::new(world)
65-
.register(
66-
"eq",
67-
|
68-
_self: Ref<bevy::hierarchy::HierarchyEvent>,
69-
other: Ref<bevy::hierarchy::HierarchyEvent>|
70-
{
71-
let output: bool = <bevy::hierarchy::HierarchyEvent as std::cmp::PartialEq<
72-
bevy::hierarchy::HierarchyEvent,
73-
>>::eq(&_self, &other)
74-
.into();
75-
output
76-
},
7774
)
7875
.register(
7976
"clone",
@@ -86,11 +83,14 @@ impl ::bevy::app::Plugin for BevyHierarchyScriptingPlugin {
8683
},
8784
)
8885
.register(
89-
"assert_receiver_is_total_eq",
90-
|_self: Ref<bevy::hierarchy::HierarchyEvent>| {
91-
let output: () = <bevy::hierarchy::HierarchyEvent as std::cmp::Eq>::assert_receiver_is_total_eq(
92-
&_self,
93-
)
86+
"eq",
87+
|
88+
_self: Ref<bevy::hierarchy::HierarchyEvent>,
89+
other: Ref<bevy::hierarchy::HierarchyEvent>|
90+
{
91+
let output: bool = <bevy::hierarchy::HierarchyEvent as std::cmp::PartialEq<
92+
bevy::hierarchy::HierarchyEvent,
93+
>>::eq(&_self, &other)
9494
.into();
9595
output
9696
},

0 commit comments

Comments
 (0)