Skip to content

Commit b634136

Browse files
committed
Make structs extendable in Python
1 parent 97ce1da commit b634136

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rlbot-flatbuffers-py"
3-
version = "0.3.1"
3+
version = "0.3.2"
44
edition = "2021"
55
description = "A Python module implemented in Rust for serializing and deserializing RLBot's flatbuffers"
66
repository = "https://github.com/VirxEC/rlbot-flatbuffers-py"

build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ impl PythonBindGenerator {
253253
}
254254

255255
fn generate_struct_definition(&mut self) {
256-
self.write_str("#[pyclass(module = \"rlbot_flatbuffers\", get_all, set_all)]");
256+
self.write_str("#[pyclass(module = \"rlbot_flatbuffers\", subclass, get_all, set_all)]");
257257

258258
if self.types.is_empty() {
259259
self.write_str("#[derive(Debug, Default, Clone)]");

pytest.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@
22

33
from rlbot_flatbuffers import *
44

5+
6+
class MyVector(Vector3):
7+
def __add__(self, other):
8+
return MyVector(self.x + other.x, self.y + other.y, self.z + other.z)
9+
10+
511
if __name__ == "__main__":
12+
vec1 = MyVector(1, 2, 3)
13+
vec2 = Vector3(4, 5, 6)
14+
print(vec1 + vec2)
15+
616
ready_message = ReadyMessage(True, wants_game_messages=True)
717
print(repr(ready_message))
818
print(ready_message)
@@ -51,7 +61,9 @@
5161
desired_game_state = DesiredGameState(
5262
DesiredBallState(DesiredPhysics()),
5363
car_states=[DesiredCarState(boost_amount=100)],
54-
game_info_state=DesiredGameInfoState(game_speed=1, world_gravity_z=-650, end_match=True),
64+
game_info_state=DesiredGameInfoState(
65+
game_speed=1, world_gravity_z=-650, end_match=True
66+
),
5567
console_commands=[ConsoleCommand("freeze")],
5668
)
5769
total_make_time += time_ns() - start

0 commit comments

Comments
 (0)