Skip to content

Commit 8bf3796

Browse files
authored
Add Bevy 0.11 support (#63)
* Begin bevy version migration * WIP, correct api gen, TODO: examples * Migrate complex_game_loop example * tweak docs and public API * fix some migration issues, migrate bevy_api, move all reflection indexing on lua side to 1-based * Migrate examples, untested * migrate rhai examples untested * Fix examples * Further improvements to examples * fix wrappers.rs issue * clippy fixes * clippy fixes * clippy fixes * fix typos and doctests * cargo fmt fixes
1 parent 11cbdd8 commit 8bf3796

File tree

44 files changed

+2241
-1170
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2241
-1170
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,17 @@ rhai = ["bevy_mod_scripting_rhai"]
5959
rhai_script_api=["bevy_script_api/rhai"]
6060

6161
[dependencies]
62-
bevy = { version = "0.10.1", default-features = false}
62+
bevy = { version = "0.11", default-features = false}
6363
bevy_mod_scripting_core = { path = "bevy_mod_scripting_core", version = "0.3.0" }
6464
bevy_mod_scripting_lua = { path = "languages/bevy_mod_scripting_lua", version = "0.3.0", optional = true }
6565
bevy_mod_scripting_rhai = { path = "languages/bevy_mod_scripting_rhai", version = "0.3.0", optional = true}
6666
bevy_script_api = { path = "bevy_script_api", version = "0.3.0", optional = true }
6767

6868
[dev-dependencies]
69-
bevy = { version = "0.10.1"}
69+
bevy = { version = "0.11"}
7070
clap = { version = "4.1", features = ["derive"]}
7171
rand = "0.8.5"
72-
bevy_console = "0.7.0"
72+
bevy_console = "0.8.0"
7373
rhai-rand = "0.1"
7474

7575
[workspace]

api_gen_config.toml

Lines changed: 42 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ use {
66
tealr::mlu::mlua::MetaMethod,
77
docs::LuaDocFragment
88
},
9-
crate::{common::bevy::GetWorld, lua::{RegisterForeignLuaType}},
9+
crate::{common::bevy::GetWorld, lua::{RegisterForeignLuaType, util::LuaIndex}},
1010
};
1111
use std::ops::*;
1212
use crate::{script_ref::{ReflectedValue,ValueIndex},
1313
sub_reflect::ReflectPathElem,
14-
error::ReflectionError
14+
error::ReflectionError,
1515
};
1616
use std::sync::Mutex;
1717
use bevy_mod_scripting_core::prelude::*;
@@ -145,10 +145,6 @@ source="bevy_ui"
145145
type="CalculatedClip"
146146
source="bevy_ui"
147147

148-
[[types]]
149-
type="CalculatedSize"
150-
source="bevy_ui"
151-
152148
[[types]]
153149
type="Node"
154150
source="bevy_ui"
@@ -493,26 +489,26 @@ source="bevy_asset"
493489
type="Vec2"
494490
source="bevy_math"
495491
lua_methods=[
496-
"(MetaMethod::Index) => |_,s,idx: usize| {Ok(s.inner()?[idx])}",
497-
"mut (MetaMethod::NewIndex) => |_,s,(idx,val): (usize,f32)| {s.val_mut(|s| Ok(s[idx] = val))?}"
492+
"(MetaMethod::Index) => |_,s,idx: LuaIndex| {Ok(s.inner()?[*idx])}",
493+
"mut (MetaMethod::NewIndex) => |_,s,(idx,val): (LuaIndex,f32)| {s.val_mut(|s| Ok(s[*idx] = val))?}"
498494
]
499495
import_path="glam::f32::Vec2"
500496

501497
[[types]]
502498
type="Vec3"
503499
source="bevy_math"
504500
lua_methods=[
505-
"(MetaMethod::Index) => |_,s,idx: usize| {Ok(s.inner()?[idx])}",
506-
"mut (MetaMethod::NewIndex) => |_,s,(idx,val): (usize,f32)| {s.val_mut(|s| Ok(s[idx] = val))?}"
501+
"(MetaMethod::Index) => |_,s,idx: LuaIndex| {Ok(s.inner()?[*idx])}",
502+
"mut (MetaMethod::NewIndex) => |_,s,(idx,val): (LuaIndex,f32)| {s.val_mut(|s| Ok(s[*idx] = val))?}"
507503
]
508504
import_path="glam::f32::Vec3"
509505

510506
[[types]]
511507
type="Vec3A"
512508
source="bevy_math"
513509
lua_methods=[
514-
"(MetaMethod::Index) => |_,s,idx: usize| {Ok(s.inner()?[idx])}",
515-
"mut (MetaMethod::NewIndex) => |_,s,(idx,val): (usize,f32)| {s.val_mut(|s| Ok(s[idx] = val))?}"
510+
"(MetaMethod::Index) => |_,s,idx: LuaIndex| {Ok(s.inner()?[*idx])}",
511+
"mut (MetaMethod::NewIndex) => |_,s,(idx,val): (LuaIndex,f32)| {s.val_mut(|s| Ok(s[*idx] = val))?}"
516512
]
517513
import_path="glam::f32::Vec3A"
518514

@@ -521,8 +517,8 @@ import_path="glam::f32::Vec3A"
521517
type="Vec4"
522518
source="bevy_math"
523519
lua_methods=[
524-
"(MetaMethod::Index) => |_,s,idx: usize| {Ok(s.inner()?[idx])}",
525-
"mut (MetaMethod::NewIndex) => |_,s,(idx,val): (usize,f32)| {s.val_mut(|s| Ok(s[idx] = val))?}"
520+
"(MetaMethod::Index) => |_,s,idx: LuaIndex| {Ok(s.inner()?[*idx])}",
521+
"mut (MetaMethod::NewIndex) => |_,s,(idx,val): (LuaIndex,f32)| {s.val_mut(|s| Ok(s[*idx] = val))?}"
526522
]
527523
import_path="glam::f32::Vec4"
528524

@@ -555,80 +551,80 @@ import_path="glam::bool::BVec4A"
555551
type="DVec2"
556552
source="bevy_math"
557553
lua_methods=[
558-
"(MetaMethod::Index) => |_,s,idx: usize| {Ok(s.inner()?[idx])}",
559-
"mut (MetaMethod::NewIndex) => |_,s,(idx,val): (usize,f64)| {s.val_mut(|s| Ok(s[idx] = val))?}"
554+
"(MetaMethod::Index) => |_,s,idx: LuaIndex| {Ok(s.inner()?[*idx])}",
555+
"mut (MetaMethod::NewIndex) => |_,s,(idx,val): (LuaIndex,f64)| {s.val_mut(|s| Ok(s[*idx] = val))?}"
560556
]
561557
import_path="glam::f64::DVec2"
562558

563559
[[types]]
564560
type="DVec3"
565561
source="bevy_math"
566562
lua_methods=[
567-
"(MetaMethod::Index) => |_,s,idx: usize| {Ok(s.inner()?[idx])}",
568-
"mut (MetaMethod::NewIndex) => |_,s,(idx,val): (usize,f64)| {s.val_mut(|s| Ok(s[idx] = val))?}"
563+
"(MetaMethod::Index) => |_,s,idx: LuaIndex| {Ok(s.inner()?[*idx])}",
564+
"mut (MetaMethod::NewIndex) => |_,s,(idx,val): (LuaIndex,f64)| {s.val_mut(|s| Ok(s[*idx] = val))?}"
569565
]
570566
import_path="glam::f64::DVec3"
571567

572568
[[types]]
573569
type="DVec4"
574570
source="bevy_math"
575571
lua_methods=[
576-
"(MetaMethod::Index) => |_,s,idx: usize| {Ok(s.inner()?[idx])}",
577-
"mut (MetaMethod::NewIndex) => |_,s,(idx,val): (usize,f64)| {s.val_mut(|s| Ok(s[idx] = val))?}"
572+
"(MetaMethod::Index) => |_,s,idx: LuaIndex| {Ok(s.inner()?[*idx])}",
573+
"mut (MetaMethod::NewIndex) => |_,s,(idx,val): (LuaIndex,f64)| {s.val_mut(|s| Ok(s[*idx] = val))?}"
578574
]
579575
import_path="glam::f64::DVec4"
580576

581577
[[types]]
582578
type="IVec2"
583579
source="bevy_math"
584580
lua_methods=[
585-
"(MetaMethod::Index) => |_,s,idx: usize| {Ok(s.inner()?[idx])}",
586-
"mut (MetaMethod::NewIndex) => |_,s,(idx,val): (usize,i32)| {s.val_mut(|s| Ok(s[idx] = val))?}"
581+
"(MetaMethod::Index) => |_,s,idx: LuaIndex| {Ok(s.inner()?[*idx])}",
582+
"mut (MetaMethod::NewIndex) => |_,s,(idx,val): (LuaIndex,i32)| {s.val_mut(|s| Ok(s[*idx] = val))?}"
587583
]
588584
import_path="glam::i32::IVec2"
589585

590586
[[types]]
591587
type="IVec3"
592588
source="bevy_math"
593589
lua_methods=[
594-
"(MetaMethod::Index) => |_,s,idx: usize| {Ok(s.inner()?[idx])}",
595-
"mut (MetaMethod::NewIndex) => |_,s,(idx,val): (usize,i32)| {s.val_mut(|s| Ok(s[idx] = val))?}"
590+
"(MetaMethod::Index) => |_,s,idx: LuaIndex| {Ok(s.inner()?[*idx])}",
591+
"mut (MetaMethod::NewIndex) => |_,s,(idx,val): (LuaIndex,i32)| {s.val_mut(|s| Ok(s[*idx] = val))?}"
596592
]
597593
import_path="glam::i32::IVec3"
598594

599595
[[types]]
600596
type="IVec4"
601597
source="bevy_math"
602598
lua_methods=[
603-
"(MetaMethod::Index) => |_,s,idx: usize| {Ok(s.inner()?[idx])}",
604-
"mut (MetaMethod::NewIndex) => |_,s,(idx,val): (usize,i32)| {s.val_mut(|s| Ok(s[idx] = val))?}"
599+
"(MetaMethod::Index) => |_,s,idx: LuaIndex| {Ok(s.inner()?[*idx])}",
600+
"mut (MetaMethod::NewIndex) => |_,s,(idx,val): (LuaIndex,i32)| {s.val_mut(|s| Ok(s[*idx] = val))?}"
605601
]
606602
import_path="glam::i32::IVec4"
607603

608604
[[types]]
609605
type="UVec2"
610606
source="bevy_math"
611607
lua_methods=[
612-
"(MetaMethod::Index) => |_,s,idx: usize| {Ok(s.inner()?[idx])}",
613-
"mut (MetaMethod::NewIndex) => |_,s,(idx,val): (usize,u32)| {s.val_mut(|s| Ok(s[idx] = val))?}"
608+
"(MetaMethod::Index) => |_,s,idx: LuaIndex| {Ok(s.inner()?[*idx])}",
609+
"mut (MetaMethod::NewIndex) => |_,s,(idx,val): (LuaIndex,u32)| {s.val_mut(|s| Ok(s[*idx] = val))?}"
614610
]
615611
import_path="glam::u32::UVec2"
616612

617613
[[types]]
618614
type="UVec3"
619615
source="bevy_math"
620616
lua_methods=[
621-
"(MetaMethod::Index) => |_,s,idx: usize| {Ok(s.inner()?[idx])}",
622-
"mut (MetaMethod::NewIndex) => |_,s,(idx,val): (usize,u32)| {s.val_mut(|s| Ok(s[idx] = val))?}"
617+
"(MetaMethod::Index) => |_,s,idx: LuaIndex| {Ok(s.inner()?[*idx])}",
618+
"mut (MetaMethod::NewIndex) => |_,s,(idx,val): (LuaIndex,u32)| {s.val_mut(|s| Ok(s[*idx] = val))?}"
623619
]
624620
import_path="glam::u32::UVec3"
625621

626622
[[types]]
627623
type="UVec4"
628624
source="bevy_math"
629625
lua_methods=[
630-
"(MetaMethod::Index) => |_,s,idx: usize| {Ok(s.inner()?[idx])}",
631-
"mut (MetaMethod::NewIndex) => |_,s,(idx,val): (usize,u32)| {s.val_mut(|s| Ok(s[idx] = val))?}"
626+
"(MetaMethod::Index) => |_,s,idx: LuaIndex| {Ok(s.inner()?[*idx])}",
627+
"mut (MetaMethod::NewIndex) => |_,s,(idx,val): (LuaIndex,u32)| {s.val_mut(|s| Ok(s[*idx] = val))?}"
632628
]
633629
import_path="glam::u32::UVec4"
634630

@@ -637,11 +633,11 @@ type="Mat3"
637633
source="bevy_math"
638634
lua_methods=[
639635
"""
640-
mut (MetaMethod::Index) => |ctx,s,idx : usize| {
636+
mut (MetaMethod::Index) => |ctx,s,idx : LuaIndex| {
641637
Ok(LuaVec3::new_ref(
642638
s.script_ref(ctx.get_world()?).sub_ref(ReflectPathElem::SubReflectionIndexed{
643639
label:"col",
644-
index: idx,
640+
index: *idx,
645641
get: |idx,ref_| Err(ReflectionError::InsufficientProvenance{
646642
path: "".to_owned(),
647643
msg: "Cannot get column of matrix with immutable reference".to_owned()
@@ -668,11 +664,11 @@ type="Mat2"
668664
source="bevy_math"
669665
lua_methods=[
670666
"""
671-
mut (MetaMethod::Index) => |ctx,s,idx : usize| {
667+
mut (MetaMethod::Index) => |ctx,s,idx : LuaIndex| {
672668
Ok(LuaVec2::new_ref(
673669
s.script_ref(ctx.get_world()?).sub_ref(ReflectPathElem::SubReflectionIndexed{
674670
label:"col",
675-
index: idx,
671+
index: *idx,
676672
get: |idx,ref_| Err(ReflectionError::InsufficientProvenance{
677673
path: "".to_owned(),
678674
msg: "Cannot get column of matrix with immutable reference".to_owned()
@@ -700,11 +696,11 @@ type="Mat3A"
700696
source="bevy_math"
701697
lua_methods=[
702698
"""
703-
mut (MetaMethod::Index) => |ctx,s,idx : usize| {
699+
mut (MetaMethod::Index) => |ctx,s,idx : LuaIndex| {
704700
Ok(LuaVec3A::new_ref(
705701
s.script_ref(ctx.get_world()?).sub_ref(ReflectPathElem::SubReflectionIndexed{
706702
label:"col",
707-
index: idx,
703+
index: *idx,
708704
get: |idx,ref_| Err(ReflectionError::InsufficientProvenance{
709705
path: "".to_owned(),
710706
msg: "Cannot get column of matrix with immutable reference".to_owned()
@@ -731,11 +727,11 @@ type="Mat4"
731727
source="bevy_math"
732728
lua_methods=[
733729
"""
734-
mut (MetaMethod::Index) => |ctx,s,idx : usize| {
730+
mut (MetaMethod::Index) => |ctx,s,idx : LuaIndex| {
735731
Ok(LuaVec4::new_ref(
736732
s.script_ref(ctx.get_world()?).sub_ref(ReflectPathElem::SubReflectionIndexed{
737733
label:"col",
738-
index: idx,
734+
index: *idx,
739735
get: |idx,ref_| Err(ReflectionError::InsufficientProvenance{
740736
path: "".to_owned(),
741737
msg: "Cannot get column of matrix with immutable reference".to_owned()
@@ -763,11 +759,11 @@ type="DMat2"
763759
source="bevy_math"
764760
lua_methods=[
765761
"""
766-
mut (MetaMethod::Index) => |ctx,s,idx : usize| {
762+
mut (MetaMethod::Index) => |ctx,s,idx : LuaIndex| {
767763
Ok(LuaDVec2::new_ref(
768764
s.script_ref(ctx.get_world()?).sub_ref(ReflectPathElem::SubReflectionIndexed{
769765
label:"col",
770-
index: idx,
766+
index: *idx,
771767
get: |idx,ref_| Err(ReflectionError::InsufficientProvenance{
772768
path: "".to_owned(),
773769
msg: "Cannot get column of matrix with immutable reference".to_owned()
@@ -794,11 +790,11 @@ type="DMat3"
794790
source="bevy_math"
795791
lua_methods=[
796792
"""
797-
mut (MetaMethod::Index) => |ctx,s,idx : usize| {
793+
mut (MetaMethod::Index) => |ctx,s,idx : LuaIndex| {
798794
Ok(LuaDVec3::new_ref(
799795
s.script_ref(ctx.get_world()?).sub_ref(ReflectPathElem::SubReflectionIndexed{
800796
label:"col",
801-
index: idx,
797+
index: *idx,
802798
get: |idx,ref_| Err(ReflectionError::InsufficientProvenance{
803799
path: "".to_owned(),
804800
msg: "Cannot get column of matrix with immutable reference".to_owned()
@@ -825,11 +821,11 @@ type="DMat4"
825821
source="bevy_math"
826822
lua_methods=[
827823
"""
828-
mut (MetaMethod::Index) => |ctx,s,idx : usize| {
824+
mut (MetaMethod::Index) => |ctx,s,idx : LuaIndex| {
829825
Ok(LuaDVec4::new_ref(
830826
s.script_ref(ctx.get_world()?).sub_ref(ReflectPathElem::SubReflectionIndexed{
831827
label:"col",
832-
index: idx,
828+
index: *idx,
833829
get: |idx,ref_| Err(ReflectionError::InsufficientProvenance{
834830
path: "".to_owned(),
835831
msg: "Cannot get column of matrix with immutable reference".to_owned()
Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,17 @@
11

22

3-
function on_pre_physics_one(id)
4-
print("on_pre_physics_one, Handling:")
3+
function on_pre_physics(id)
4+
print("on_pre_physics, Handling:")
55
print(string.format("\t-> id: %d",id))
66
end
77

8-
function on_pre_physics_two(id)
9-
print("on_pre_physics_two, Handling:")
10-
print(string.format("\t-> id: %d",id))
11-
end
12-
13-
function on_post_physics_one(id)
14-
print("on_post_physics_one, Handling:")
8+
function on_post_physics(id)
9+
print("on_post_physics, Handling:")
1510
print(string.format("\t-> id: %d",id))
1611
end
1712

18-
function on_post_physics_two(id)
19-
print("on_post_physics_two, Handling:")
20-
print(string.format("\t-> id: %d",id))
21-
end
2213

23-
function on_post_update_one(id)
24-
print("on_post_update_one, Handling:")
14+
function on_post_update(id)
15+
print("on_post_update, Handling:")
2516
print(string.format("\t-> id: %d",id))
2617
end
27-
28-
function on_post_update_two(id)
29-
print("on_post_update_two, Handling:")
30-
print(string.format("\t-> id: %d",id))
31-
end

assets/scripts/game_of_life.tl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ global function on_update()
3030
prev_state[k] = (not(v == 0)) and 1 or 0
3131
end
3232

33-
for i=1,(dimensions[0] * dimensions[1]) do
34-
local north = prev_state[i - dimensions[0]] or 1
35-
local south = prev_state[i + dimensions[0]] or 1
33+
for i=1,(dimensions[1] * dimensions[2]) do
34+
local north = prev_state[i - dimensions[1]] or 1
35+
local south = prev_state[i + dimensions[1]] or 1
3636
local east = prev_state[i + 1] or 1
3737
local west = prev_state[i - 1] or 1
38-
local northeast = prev_state[i - dimensions[0] + 1] or 1
39-
local southeast = prev_state[i + dimensions[0] + 1] or 1
40-
local northwest = prev_state[i - dimensions[0] - 1] or 1
41-
local southwest = prev_state[i + dimensions[0] - 1] or 1
38+
local northeast = prev_state[i - dimensions[1] + 1] or 1
39+
local southeast = prev_state[i + dimensions[1] + 1] or 1
40+
local northwest = prev_state[i - dimensions[1] - 1] or 1
41+
local southwest = prev_state[i + dimensions[1] - 1] or 1
4242

4343
local neighbours = north + south + east + west
4444
+ northeast + southeast + northwest + southwest

bevy_api_gen/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ path = "src/main.rs"
2626

2727

2828
[dependencies]
29-
rustdoc-types = "0.19.0"
29+
rustdoc-types = "0.22.0"
3030
clap = { version = "3.2.6", features = ["derive"] }
3131
serde_json = "1.0.81"
3232
toml = "0.5.9"

bevy_api_gen/src/config.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use std::collections::HashSet;
2-
31
use clap::Parser;
42
use indexmap::{IndexMap, IndexSet};
53
use rustdoc_types::{Crate, Item, ItemEnum, Visibility};

bevy_event_priority/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ name = "bevy_event_priority"
2121
path = "src/lib.rs"
2222

2323
[dependencies]
24-
bevy = { version = "0.10.1", default-features = false}
24+
bevy = { version = "0.11", default-features = false}
2525

0 commit comments

Comments
 (0)