rlbot-flatbuffers 0.14.5__tar.gz → 0.14.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. {rlbot_flatbuffers-0.14.5 → rlbot_flatbuffers-0.14.7}/Cargo.lock +7 -7
  2. {rlbot_flatbuffers-0.14.5 → rlbot_flatbuffers-0.14.7}/Cargo.toml +1 -1
  3. {rlbot_flatbuffers-0.14.5 → rlbot_flatbuffers-0.14.7}/PKG-INFO +1 -1
  4. {rlbot_flatbuffers-0.14.5 → rlbot_flatbuffers-0.14.7}/codegen/enums.rs +17 -67
  5. {rlbot_flatbuffers-0.14.5 → rlbot_flatbuffers-0.14.7}/codegen/main.rs +10 -30
  6. {rlbot_flatbuffers-0.14.5 → rlbot_flatbuffers-0.14.7}/codegen/pyi.rs +23 -39
  7. {rlbot_flatbuffers-0.14.5 → rlbot_flatbuffers-0.14.7}/codegen/structs.rs +122 -218
  8. {rlbot_flatbuffers-0.14.5 → rlbot_flatbuffers-0.14.7}/codegen/unions.rs +11 -54
  9. {rlbot_flatbuffers-0.14.5 → rlbot_flatbuffers-0.14.7}/flatbuffers-schema/matchconfig.fbs +124 -5
  10. {rlbot_flatbuffers-0.14.5 → rlbot_flatbuffers-0.14.7}/src/lib.rs +14 -15
  11. {rlbot_flatbuffers-0.14.5 → rlbot_flatbuffers-0.14.7}/LICENSE +0 -0
  12. {rlbot_flatbuffers-0.14.5 → rlbot_flatbuffers-0.14.7}/README.md +0 -0
  13. {rlbot_flatbuffers-0.14.5 → rlbot_flatbuffers-0.14.7}/codegen/class_inject.rs +0 -0
  14. {rlbot_flatbuffers-0.14.5 → rlbot_flatbuffers-0.14.7}/codegen/generator.rs +0 -0
  15. {rlbot_flatbuffers-0.14.5 → rlbot_flatbuffers-0.14.7}/flatbuffers-schema/FLATBUFFERS-LICENSE +0 -0
  16. {rlbot_flatbuffers-0.14.5 → rlbot_flatbuffers-0.14.7}/flatbuffers-schema/README.md +0 -0
  17. {rlbot_flatbuffers-0.14.5 → rlbot_flatbuffers-0.14.7}/flatbuffers-schema/comms.fbs +0 -0
  18. {rlbot_flatbuffers-0.14.5 → rlbot_flatbuffers-0.14.7}/flatbuffers-schema/flatc +0 -0
  19. {rlbot_flatbuffers-0.14.5 → rlbot_flatbuffers-0.14.7}/flatbuffers-schema/flatc.exe +0 -0
  20. {rlbot_flatbuffers-0.14.5 → rlbot_flatbuffers-0.14.7}/flatbuffers-schema/gamedata.fbs +0 -0
  21. {rlbot_flatbuffers-0.14.5 → rlbot_flatbuffers-0.14.7}/flatbuffers-schema/gamestatemanip.fbs +0 -0
  22. {rlbot_flatbuffers-0.14.5 → rlbot_flatbuffers-0.14.7}/flatbuffers-schema/rendering.fbs +0 -0
  23. {rlbot_flatbuffers-0.14.5 → rlbot_flatbuffers-0.14.7}/flatbuffers-schema/rlbot.fbs +0 -0
  24. {rlbot_flatbuffers-0.14.5 → rlbot_flatbuffers-0.14.7}/pyproject.toml +0 -0
@@ -115,9 +115,9 @@ checksum = "71dd52191aae121e8611f1e8dc3e324dd0dd1dee1e6dd91d10ee07a3cfb4d9d8"
115
115
 
116
116
  [[package]]
117
117
  name = "libc"
118
- version = "0.2.170"
118
+ version = "0.2.171"
119
119
  source = "registry+https://github.com/rust-lang/crates.io-index"
120
- checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828"
120
+ checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6"
121
121
 
122
122
  [[package]]
123
123
  name = "manyhow"
@@ -153,9 +153,9 @@ dependencies = [
153
153
 
154
154
  [[package]]
155
155
  name = "once_cell"
156
- version = "1.20.3"
156
+ version = "1.21.3"
157
157
  source = "registry+https://github.com/rust-lang/crates.io-index"
158
- checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e"
158
+ checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
159
159
 
160
160
  [[package]]
161
161
  name = "portable-atomic"
@@ -248,9 +248,9 @@ dependencies = [
248
248
 
249
249
  [[package]]
250
250
  name = "quote"
251
- version = "1.0.39"
251
+ version = "1.0.40"
252
252
  source = "registry+https://github.com/rust-lang/crates.io-index"
253
- checksum = "c1f1914ce909e1658d9907913b4b91947430c7d9be598b15a1912935b8c04801"
253
+ checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
254
254
  dependencies = [
255
255
  "proc-macro2",
256
256
  ]
@@ -279,7 +279,7 @@ dependencies = [
279
279
 
280
280
  [[package]]
281
281
  name = "rlbot_flatbuffers"
282
- version = "0.14.5"
282
+ version = "0.14.7"
283
283
  dependencies = [
284
284
  "flatbuffers",
285
285
  "get-size",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "rlbot_flatbuffers"
3
- version = "0.14.5"
3
+ version = "0.14.7"
4
4
  edition = "2024"
5
5
  description = "A Python module implemented in Rust for serializing and deserializing RLBot's flatbuffers"
6
6
  repository = "https://github.com/VirxEC/rlbot_flatbuffers_py"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rlbot_flatbuffers
3
- Version: 0.14.5
3
+ Version: 0.14.7
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Python :: Implementation :: PyPy
@@ -16,10 +16,7 @@ fn camel_to_snake_case(variable_name: &str) -> String {
16
16
  for c in variable_name.chars() {
17
17
  if c.is_uppercase() {
18
18
  if last_was_uppercase {
19
- snake_case_parts
20
- .last_mut()
21
- .unwrap()
22
- .push(c.to_lowercase().next().unwrap());
19
+ snake_case_parts.last_mut().unwrap().push(c.to_lowercase().next().unwrap());
23
20
  } else {
24
21
  snake_case_parts.push(c.to_lowercase().to_string());
25
22
  }
@@ -80,9 +77,7 @@ impl EnumBindGenerator {
80
77
  })
81
78
  }
82
79
 
83
- pub fn raw_types_to_custom(
84
- raw_types: Vec<(&str, &str, Option<Vec<String>>)>,
85
- ) -> Vec<CustomEnumType> {
80
+ pub fn raw_types_to_custom(raw_types: Vec<(&str, &str, Option<Vec<String>>)>) -> Vec<CustomEnumType> {
86
81
  raw_types
87
82
  .into_iter()
88
83
  .map(|(name, raw_type, doc_str)| CustomEnumType {
@@ -129,17 +124,12 @@ impl EnumBindGenerator {
129
124
  continue;
130
125
  }
131
126
 
132
- let definition = line_trim
133
- .trim_start_matches("pub const ")
134
- .trim_end_matches(';');
127
+ let definition = line_trim.trim_start_matches("pub const ").trim_end_matches(';');
135
128
 
136
129
  let mut parts = definition.split(": Self = ");
137
130
 
138
131
  let variable_name = parts.next()?;
139
- let variable_value = parts
140
- .next()?
141
- .trim_start_matches("Self(")
142
- .trim_end_matches(')');
132
+ let variable_value = parts.next()?.trim_start_matches("Self(").trim_end_matches(')');
143
133
 
144
134
  let docs = if docs.is_empty() {
145
135
  None
@@ -169,14 +159,11 @@ impl EnumBindGenerator {
169
159
  let union_end_definition = "}\n";
170
160
  let union_end = contents[union_start..].find(union_end_definition).unwrap();
171
161
 
172
- let union_definition = &contents[union_start + union_definition.len()
173
- ..union_start + union_end - union_end_definition.len()];
162
+ let union_definition =
163
+ &contents[union_start + union_definition.len()..union_start + union_end - union_end_definition.len()];
174
164
 
175
165
  for (line, variable) in union_definition.split('\n').zip(&mut custom_types) {
176
- let line_trim = line
177
- .trim()
178
- .trim_start_matches(&variable.name)
179
- .trim_end_matches(',');
166
+ let line_trim = line.trim().trim_start_matches(&variable.name).trim_end_matches(',');
180
167
 
181
168
  if line_trim.is_empty() {
182
169
  variable.value = None;
@@ -185,9 +172,7 @@ impl EnumBindGenerator {
185
172
 
186
173
  variable.snake_case_name = camel_to_snake_case(variable.name.as_str());
187
174
 
188
- let new_type = line_trim
189
- .trim_start_matches("(Box<")
190
- .trim_end_matches("T>)");
175
+ let new_type = line_trim.trim_start_matches("(Box<").trim_end_matches("T>)");
191
176
  variable.value = Some(new_type.to_string());
192
177
  }
193
178
 
@@ -204,11 +189,7 @@ impl EnumBindGenerator {
204
189
 
205
190
  for variable_info in &self.types {
206
191
  let variable_name = variable_info.name.as_str();
207
- write_fmt!(
208
- self,
209
- " {} => Ok(Self::{variable_name}),",
210
- variable_info.raw_type
211
- );
192
+ write_fmt!(self, " {} => Ok(Self::{variable_name}),", variable_info.raw_type);
212
193
  }
213
194
 
214
195
  if self.types.len() != usize::from(u8::MAX) {
@@ -256,10 +237,7 @@ impl Generator for EnumBindGenerator {
256
237
  contents = contents.replace("\r\n", "\n");
257
238
  }
258
239
 
259
- contents = contents.replace(
260
- "use self::flatbuffers",
261
- "use get_size::GetSize;\nuse self::flatbuffers",
262
- );
240
+ contents = contents.replace("use self::flatbuffers", "use get_size::GetSize;\nuse self::flatbuffers");
263
241
 
264
242
  contents = contents.replace(
265
243
  "#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]\n",
@@ -288,14 +266,8 @@ impl Generator for EnumBindGenerator {
288
266
 
289
267
  fn generate_definition(&mut self) {
290
268
  write_str!(self, "#[allow(non_camel_case_types)]");
291
- write_str!(
292
- self,
293
- "#[pyclass(module = \"rlbot_flatbuffers\", frozen, hash, eq, eq_int)]"
294
- );
295
- write_str!(
296
- self,
297
- "#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]"
298
- );
269
+ write_str!(self, "#[pyclass(module = \"rlbot_flatbuffers\", frozen, hash, eq, eq_int)]");
270
+ write_str!(self, "#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]");
299
271
  write_fmt!(self, "pub enum {} {{", self.struct_name);
300
272
  write_str!(self, " #[default]");
301
273
 
@@ -309,17 +281,8 @@ impl Generator for EnumBindGenerator {
309
281
  }
310
282
 
311
283
  fn generate_from_flat_impls(&mut self) {
312
- write_fmt!(
313
- self,
314
- "impl From<flat::{}> for {} {{",
315
- self.struct_name,
316
- self.struct_name
317
- );
318
- write_fmt!(
319
- self,
320
- " fn from(flat_t: flat::{}) -> Self {{",
321
- self.struct_name
322
- );
284
+ write_fmt!(self, "impl From<flat::{}> for {} {{", self.struct_name, self.struct_name);
285
+ write_fmt!(self, " fn from(flat_t: flat::{}) -> Self {{", self.struct_name);
323
286
  write_str!(self, " match flat_t {");
324
287
 
325
288
  for variable_info in &self.types {
@@ -332,11 +295,7 @@ impl Generator for EnumBindGenerator {
332
295
  );
333
296
  }
334
297
 
335
- write_fmt!(
336
- self,
337
- " _ => Self::{},",
338
- self.types.last().unwrap().name.as_str()
339
- );
298
+ write_fmt!(self, " _ => Self::{},", self.types.last().unwrap().name.as_str());
340
299
 
341
300
  write_str!(self, " }");
342
301
  write_str!(self, " }");
@@ -345,17 +304,8 @@ impl Generator for EnumBindGenerator {
345
304
  }
346
305
 
347
306
  fn generate_to_flat_impls(&mut self) {
348
- write_fmt!(
349
- self,
350
- "impl From<&{}> for flat::{} {{",
351
- self.struct_name,
352
- self.struct_name
353
- );
354
- write_fmt!(
355
- self,
356
- " fn from(py_type: &{}) -> Self {{",
357
- self.struct_name
358
- );
307
+ write_fmt!(self, "impl From<&{}> for flat::{} {{", self.struct_name, self.struct_name);
308
+ write_fmt!(self, " fn from(py_type: &{}) -> Self {{", self.struct_name);
359
309
  write_str!(self, " match *py_type {");
360
310
 
361
311
  for variable_info in &self.types {
@@ -53,15 +53,10 @@ impl PythonBindType {
53
53
  "PredictionSlice",
54
54
  "BallPrediction",
55
55
  ];
56
- pub const UNIONS: [&'static str; 4] = [
57
- "PlayerClass",
58
- "CollisionShape",
59
- "RelativeAnchor",
60
- "RenderType",
61
- ];
56
+ pub const UNIONS: [&'static str; 4] = ["PlayerClass", "CollisionShape", "RelativeAnchor", "RenderType"];
62
57
 
63
- pub const DEFAULT_OVERRIDES: [(&'static str, &'static str, &'static str); 1] =
64
- [("Color", "a", "255")];
58
+ pub const OPTIONAL_UNIONS: [&'static str; 1] = ["RelativeAnchor"];
59
+ pub const DEFAULT_OVERRIDES: [(&'static str, &'static str, &'static str); 1] = [("Color", "a", "255")];
65
60
  pub const FREELIST_TYPES: [(&'static str, usize); 0] = [];
66
61
 
67
62
  fn new(path: &Path) -> Option<Self> {
@@ -106,12 +101,7 @@ impl PythonBindType {
106
101
  let struct_doc_str = if docs.is_empty() {
107
102
  None
108
103
  } else {
109
- Some(
110
- docs.into_iter()
111
- .map(|s| s.to_string())
112
- .rev()
113
- .collect::<Vec<_>>(),
114
- )
104
+ Some(docs.into_iter().map(|s| s.to_string()).rev().collect::<Vec<_>>())
115
105
  };
116
106
 
117
107
  if let Some(types) = StructBindGenerator::get_types(&contents, &struct_t_name) {
@@ -125,15 +115,11 @@ impl PythonBindType {
125
115
  )?));
126
116
  }
127
117
 
128
- if let Some((types, enum_type)) =
129
- enums::EnumBindGenerator::get_types(&contents, &struct_name)
130
- {
118
+ if let Some((types, enum_type)) = enums::EnumBindGenerator::get_types(&contents, &struct_name) {
131
119
  return Some(match enum_type {
132
- enums::EnumType::Enum => Self::Enum(enums::EnumBindGenerator::new(
133
- filename.to_string(),
134
- struct_name,
135
- types,
136
- )?),
120
+ enums::EnumType::Enum => {
121
+ Self::Enum(enums::EnumBindGenerator::new(filename.to_string(), struct_name, types)?)
122
+ }
137
123
  enums::EnumType::Union => Self::Union(unions::UnionBindGenerator::new(
138
124
  filename.to_string(),
139
125
  struct_name,
@@ -183,10 +169,7 @@ fn mod_rs_generator(type_data: &[PythonBindType]) -> io::Result<()> {
183
169
 
184
170
  file_contents.push(Cow::Borrowed(""));
185
171
 
186
- fs::write(
187
- format!("{PYTHON_OUT_FOLDER}/mod.rs"),
188
- file_contents.join("\n"),
189
- )?;
172
+ fs::write(format!("{PYTHON_OUT_FOLDER}/mod.rs"), file_contents.join("\n"))?;
190
173
 
191
174
  Ok(())
192
175
  }
@@ -204,10 +187,7 @@ fn run_flatc() -> io::Result<()> {
204
187
  let mut schema_folder = Path::new(SCHEMA_FOLDER);
205
188
  if !schema_folder.exists() {
206
189
  schema_folder = Path::new(SCHEMA_FOLDER_BACKUP);
207
- assert!(
208
- schema_folder.exists(),
209
- "Could not find flatbuffers schema folder"
210
- );
190
+ assert!(schema_folder.exists(), "Could not find flatbuffers schema folder");
211
191
  }
212
192
 
213
193
  let schema_folder_str = schema_folder.display();
@@ -93,16 +93,10 @@ pub fn generator(type_data: &[PythonBindType]) -> io::Result<()> {
93
93
  write_str!(file, " def __new__(cls, value: int = 0): ...");
94
94
  write_str!(file, " def __init__(self, value: int = 0):");
95
95
  write_str!(file, " \"\"\"");
96
- write_str!(
97
- file,
98
- " :raises ValueError: If the `value` is not a valid enum value"
99
- );
96
+ write_str!(file, " :raises ValueError: If the `value` is not a valid enum value");
100
97
  write_str!(file, " \"\"\"");
101
98
  write_str!(file, " def __int__(self) -> int: ...");
102
- write_fmt!(
103
- file,
104
- " def __eq__(self, other: {type_name}) -> bool: ..."
105
- );
99
+ write_fmt!(file, " def __eq__(self, other: {type_name}) -> bool: ...");
106
100
  write_str!(file, " def __hash__(self) -> str: ...");
107
101
  }
108
102
  PythonBindType::Struct(bind) => {
@@ -208,32 +202,32 @@ pub fn generator(type_data: &[PythonBindType]) -> io::Result<()> {
208
202
  python_types.push("str".to_string());
209
203
  write_fmt!(file, " {variable_name}: str");
210
204
  }
211
- RustType::Union(type_name) => {
212
- write_fmt!(file, " {variable_name}: {type_name}");
205
+ RustType::Union(type_name, is_optional) => {
206
+ if *is_optional {
207
+ write_fmt!(file, " {variable_name}: Optional[{type_name}]");
208
+ } else {
209
+ write_fmt!(file, " {variable_name}: {type_name}");
210
+ }
213
211
 
214
212
  // search for the union with the name `type_name` and get the types
215
213
  let union_types = type_data
216
214
  .iter()
217
215
  .find_map(|item| match item {
218
- PythonBindType::Union(bind)
219
- if bind.struct_name() == type_name =>
220
- {
221
- Some(
222
- bind.types
223
- .iter()
224
- .skip(1)
225
- .map(|v| v.name.as_str())
226
- .collect::<Vec<_>>(),
227
- )
216
+ PythonBindType::Union(bind) if bind.struct_name() == type_name => {
217
+ Some(bind.types.iter().skip(1).map(|v| v.name.as_str()).collect::<Vec<_>>())
228
218
  }
229
219
  _ => None,
230
220
  })
231
221
  .unwrap();
232
- python_types.push(union_types.join(" | "));
222
+
223
+ let python_type = union_types.join(" | ");
224
+ python_types.push(if *is_optional {
225
+ format!("Optional[{python_type}]")
226
+ } else {
227
+ python_type
228
+ });
233
229
  }
234
- RustType::Custom(type_name)
235
- | RustType::Other(type_name)
236
- | RustType::Base(type_name) => {
230
+ RustType::Custom(type_name) | RustType::Other(type_name) | RustType::Base(type_name) => {
237
231
  python_types.push(type_name.to_string());
238
232
  write_fmt!(file, " {variable_name}: {type_name}");
239
233
  }
@@ -276,10 +270,7 @@ pub fn generator(type_data: &[PythonBindType]) -> io::Result<()> {
276
270
 
277
271
  if let Some((field, value)) = bind.default_override {
278
272
  if field == variable_name {
279
- write_fmt!(
280
- file,
281
- " {variable_name}: {python_type} = {value},"
282
- );
273
+ write_fmt!(file, " {variable_name}: {python_type} = {value},");
283
274
  continue;
284
275
  }
285
276
  }
@@ -290,19 +281,15 @@ pub fn generator(type_data: &[PythonBindType]) -> io::Result<()> {
290
281
  "String" => Cow::Borrowed("\"\""),
291
282
  "Vec<u8>" => Cow::Borrowed("b\"\""),
292
283
  t => {
293
- if python_type.starts_with("Optional")
294
- || t.starts_with("Option<")
295
- {
284
+ if python_type.starts_with("Optional") || t.starts_with("Option<") {
296
285
  Cow::Borrowed("None")
297
286
  } else if let Some(pos) = python_type.find('|') {
298
287
  Cow::Owned(format!("{}()", &python_type[..pos - 1]))
299
288
  } else if t.starts_with("Vec<") {
300
289
  Cow::Borrowed("[]")
301
290
  } else if t.starts_with("Box<") {
302
- let inner_type = t
303
- .trim_start_matches("Box<")
304
- .trim_end_matches('>')
305
- .trim_end_matches('T');
291
+ let inner_type =
292
+ t.trim_start_matches("Box<").trim_end_matches('>').trim_end_matches('T');
306
293
  Cow::Owned(format!("{inner_type}()"))
307
294
  } else {
308
295
  Cow::Owned(format!("{}()", t.trim_end_matches('T')))
@@ -310,10 +297,7 @@ pub fn generator(type_data: &[PythonBindType]) -> io::Result<()> {
310
297
  }
311
298
  };
312
299
 
313
- write_fmt!(
314
- file,
315
- " {variable_name}: {python_type} = {default_value},"
316
- );
300
+ write_fmt!(file, " {variable_name}: {python_type} = {default_value},");
317
301
  }
318
302
 
319
303
  write_str!(file, " ): ...");