Skip to content

Commit 0855d0a

Browse files
committed
Fix repr on raw strings
Rust 2024
1 parent 62be68e commit 0855d0a

File tree

8 files changed

+139
-73
lines changed

8 files changed

+139
-73
lines changed

Cargo.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rlbot_flatbuffers"
3-
version = "0.13.3"
4-
edition = "2021"
3+
version = "0.13.4"
4+
edition = "2024"
55
description = "A Python module implemented in Rust for serializing and deserializing RLBot's flatbuffers"
66
repository = "https://github.com/VirxEC/rlbot_flatbuffers_py"
77
build = "codegen/main.rs"

codegen/main.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,25 +144,25 @@ impl PythonBindType {
144144

145145
pub fn filename(&self) -> &str {
146146
match self {
147-
Self::Struct(gen) => gen.filename(),
148-
Self::Enum(gen) => gen.filename(),
149-
Self::Union(gen) => gen.filename(),
147+
Self::Struct(bind) => bind.filename(),
148+
Self::Enum(bind) => bind.filename(),
149+
Self::Union(bind) => bind.filename(),
150150
}
151151
}
152152

153153
pub fn struct_name(&self) -> &str {
154154
match self {
155-
Self::Struct(gen) => gen.struct_name(),
156-
Self::Enum(gen) => gen.struct_name(),
157-
Self::Union(gen) => gen.struct_name(),
155+
Self::Struct(bind) => bind.struct_name(),
156+
Self::Enum(bind) => bind.struct_name(),
157+
Self::Union(bind) => bind.struct_name(),
158158
}
159159
}
160160

161161
pub fn generate(&mut self, filepath: &Path) -> io::Result<()> {
162162
match self {
163-
Self::Struct(gen) => gen.generate(filepath),
164-
Self::Enum(gen) => gen.generate(filepath),
165-
Self::Union(gen) => gen.generate(filepath),
163+
Self::Struct(bind) => bind.generate(filepath),
164+
Self::Enum(bind) => bind.generate(filepath),
165+
Self::Union(bind) => bind.generate(filepath),
166166
}
167167
}
168168
}

codegen/pyi.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::{
2+
PythonBindType,
23
generator::Generator,
34
structs::{InnerOptionType, InnerVecType, RustType},
4-
PythonBindType,
55
};
66
use std::{borrow::Cow, fs, io};
77

@@ -49,8 +49,8 @@ pub fn generator(type_data: &[PythonBindType]) -> io::Result<()> {
4949
write_fmt!(file, "class {type_name}:");
5050

5151
match item {
52-
PythonBindType::Union(gen) => {
53-
let types = gen
52+
PythonBindType::Union(bind) => {
53+
let types = bind
5454
.types
5555
.iter()
5656
.map(|variable_info| variable_info.name.as_str())
@@ -68,8 +68,8 @@ pub fn generator(type_data: &[PythonBindType]) -> io::Result<()> {
6868
write_fmt!(file, " self, item: {union_str} = {default_value}()");
6969
write_str!(file, " ): ...\n");
7070
}
71-
PythonBindType::Enum(gen) => {
72-
for variable_info in &gen.types {
71+
PythonBindType::Enum(bind) => {
72+
for variable_info in &bind.types {
7373
let variable_name = variable_info.name.as_str();
7474
if variable_name == "NONE" {
7575
continue;
@@ -105,8 +105,8 @@ pub fn generator(type_data: &[PythonBindType]) -> io::Result<()> {
105105
);
106106
write_str!(file, " def __hash__(self) -> str: ...");
107107
}
108-
PythonBindType::Struct(gen) => {
109-
if let Some(docs) = gen.struct_doc_str.as_ref() {
108+
PythonBindType::Struct(bind) => {
109+
if let Some(docs) = bind.struct_doc_str.as_ref() {
110110
write_str!(file, " \"\"\"");
111111

112112
for line in docs {
@@ -118,7 +118,7 @@ pub fn generator(type_data: &[PythonBindType]) -> io::Result<()> {
118118

119119
let mut python_types = Vec::new();
120120

121-
'outer: for variable_info in &gen.types {
121+
'outer: for variable_info in &bind.types {
122122
let variable_name = variable_info.name.as_str();
123123
let variable_type = variable_info.raw_type.as_str();
124124

@@ -215,11 +215,11 @@ pub fn generator(type_data: &[PythonBindType]) -> io::Result<()> {
215215
let union_types = type_data
216216
.iter()
217217
.find_map(|item| match item {
218-
PythonBindType::Union(gen)
219-
if gen.struct_name() == type_name =>
218+
PythonBindType::Union(bind)
219+
if bind.struct_name() == type_name =>
220220
{
221221
Some(
222-
gen.types
222+
bind.types
223223
.iter()
224224
.skip(1)
225225
.map(|v| v.name.as_str())
@@ -250,17 +250,17 @@ pub fn generator(type_data: &[PythonBindType]) -> io::Result<()> {
250250
}
251251
}
252252

253-
if !gen.types.is_empty() {
253+
if !bind.types.is_empty() {
254254
write_str!(file, "");
255255
write_str!(file, " __match_args__ = (");
256256

257-
for variable_info in &gen.types {
257+
for variable_info in &bind.types {
258258
write_fmt!(file, " \"{}\",", variable_info.name);
259259
}
260260
write_str!(file, " )");
261261
}
262262

263-
if gen.types.is_empty() {
263+
if bind.types.is_empty() {
264264
write_str!(file, " def __init__(self): ...");
265265
} else {
266266
write_str!(file, "");
@@ -271,7 +271,7 @@ pub fn generator(type_data: &[PythonBindType]) -> io::Result<()> {
271271
write_fmt!(file, " def __{func}__(");
272272
write_fmt!(file, " {first_arg},");
273273

274-
for (variable_info, python_type) in gen.types.iter().zip(&python_types) {
274+
for (variable_info, python_type) in bind.types.iter().zip(&python_types) {
275275
let variable_name = variable_info.name.as_str();
276276

277277
let default_value = match variable_info.raw_type.as_str() {
@@ -315,7 +315,7 @@ pub fn generator(type_data: &[PythonBindType]) -> io::Result<()> {
315315
write_str!(file, " Serializes this instance into a byte array");
316316
write_str!(file, " \"\"\"");
317317

318-
if !gen.is_frozen {
318+
if !bind.is_frozen {
319319
write_str!(file, " def unpack_with(self, data: bytes):");
320320
write_str!(file, " \"\"\"");
321321
write_str!(file, " Deserializes the data into this instance\n");

0 commit comments

Comments
 (0)