Skip to content

Commit

Permalink
Update to the newest flatbuffers spec
Browse files Browse the repository at this point in the history
  • Loading branch information
VirxEC committed Feb 26, 2024
1 parent 1224bd1 commit 6a40fe2
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 114 deletions.
68 changes: 38 additions & 30 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rlbot-flatbuffers-py"
version = "0.1.5"
version = "0.1.6"
edition = "2021"
description = "A Python module implemented in Rust for serializing and deserializing RLBot's flatbuffers"
repository = "https://github.com/VirxEC/rlbot-flatbuffers-py"
Expand All @@ -18,8 +18,8 @@ name = "rlbot_flatbuffers"
crate-type = ["cdylib"]

[dependencies]
pyo3 = "0.20.2"
serde = "1.0.195"
pyo3 = "0.20.3"
serde = "1.0.197"
flatbuffers = { git = "https://github.com/google/flatbuffers", branch = "master" }
get-size = { version = "0.1.4", features = ["derive"] }

Expand Down
22 changes: 10 additions & 12 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -696,16 +696,15 @@ impl PythonBindGenerator {
let snake_case_name = &variable_info[2];

self.file_contents.push(Cow::Borrowed(""));
self.file_contents
.push(Cow::Owned(format!(" if {snake_case_name}.is_some() {{",)));
self.file_contents.push(Cow::Owned(format!(
" if {snake_case_name}.is_some() {{",
)));
self.file_contents.push(Cow::Owned(format!(
" item_type = {}Type::{variable_name};",self.struct_name
" item_type = {}Type::{variable_name};",
self.struct_name
)));
self.file_contents.push(Cow::Borrowed(" }"));
}


self.write_str("");
self.write_str(" Self {");
self.write_str(" item_type,");
Expand Down Expand Up @@ -1040,15 +1039,14 @@ fn mod_rs_generator(type_data: &[(String, String, Vec<Vec<String>>)]) -> io::Res
}

fn class_names_txt_generator(type_data: &[(String, String, Vec<Vec<String>>)]) -> io::Result<()> {
let mut file_contents = vec!["[".to_string()];

for (_, type_name, _) in type_data {
file_contents.push(format!(" {type_name},"));
}
let class_names = type_data
.iter()
.map(|(_, type_name, _)| format!(" {type_name}"))
.collect::<Vec<_>>();

file_contents.push("]".to_string());
let file_contents = format!("[\n{}\n]", class_names.join(",\n"));

fs::write("classes.txt", file_contents.join("\n"))?;
fs::write("classes.txt", file_contents)?;

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion flatbuffers-schema
3 changes: 3 additions & 0 deletions pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@
ready_message = ReadyMessage(True, wants_game_messages=True)
print(repr(ready_message))
print(ready_message)

print(repr(StopCommand()))
print(StopCommand(True))
Loading

0 comments on commit 6a40fe2

Please sign in to comment.