1
1
use crate :: {
2
+ PythonBindType ,
2
3
generator:: Generator ,
3
4
structs:: { InnerOptionType , InnerVecType , RustType } ,
4
- PythonBindType ,
5
5
} ;
6
6
use std:: { borrow:: Cow , fs, io} ;
7
7
@@ -49,8 +49,8 @@ pub fn generator(type_data: &[PythonBindType]) -> io::Result<()> {
49
49
write_fmt ! ( file, "class {type_name}:" ) ;
50
50
51
51
match item {
52
- PythonBindType :: Union ( gen ) => {
53
- let types = gen
52
+ PythonBindType :: Union ( bind ) => {
53
+ let types = bind
54
54
. types
55
55
. iter ( )
56
56
. map ( |variable_info| variable_info. name . as_str ( ) )
@@ -68,8 +68,8 @@ pub fn generator(type_data: &[PythonBindType]) -> io::Result<()> {
68
68
write_fmt ! ( file, " self, item: {union_str} = {default_value}()" ) ;
69
69
write_str ! ( file, " ): ...\n " ) ;
70
70
}
71
- PythonBindType :: Enum ( gen ) => {
72
- for variable_info in & gen . types {
71
+ PythonBindType :: Enum ( bind ) => {
72
+ for variable_info in & bind . types {
73
73
let variable_name = variable_info. name . as_str ( ) ;
74
74
if variable_name == "NONE" {
75
75
continue ;
@@ -105,8 +105,8 @@ pub fn generator(type_data: &[PythonBindType]) -> io::Result<()> {
105
105
) ;
106
106
write_str ! ( file, " def __hash__(self) -> str: ..." ) ;
107
107
}
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 ( ) {
110
110
write_str ! ( file, " \" \" \" " ) ;
111
111
112
112
for line in docs {
@@ -118,7 +118,7 @@ pub fn generator(type_data: &[PythonBindType]) -> io::Result<()> {
118
118
119
119
let mut python_types = Vec :: new ( ) ;
120
120
121
- ' outer: for variable_info in & gen . types {
121
+ ' outer: for variable_info in & bind . types {
122
122
let variable_name = variable_info. name . as_str ( ) ;
123
123
let variable_type = variable_info. raw_type . as_str ( ) ;
124
124
@@ -215,11 +215,11 @@ pub fn generator(type_data: &[PythonBindType]) -> io::Result<()> {
215
215
let union_types = type_data
216
216
. iter ( )
217
217
. 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 =>
220
220
{
221
221
Some (
222
- gen . types
222
+ bind . types
223
223
. iter ( )
224
224
. skip ( 1 )
225
225
. map ( |v| v. name . as_str ( ) )
@@ -250,17 +250,17 @@ pub fn generator(type_data: &[PythonBindType]) -> io::Result<()> {
250
250
}
251
251
}
252
252
253
- if !gen . types . is_empty ( ) {
253
+ if !bind . types . is_empty ( ) {
254
254
write_str ! ( file, "" ) ;
255
255
write_str ! ( file, " __match_args__ = (" ) ;
256
256
257
- for variable_info in & gen . types {
257
+ for variable_info in & bind . types {
258
258
write_fmt ! ( file, " \" {}\" ," , variable_info. name) ;
259
259
}
260
260
write_str ! ( file, " )" ) ;
261
261
}
262
262
263
- if gen . types . is_empty ( ) {
263
+ if bind . types . is_empty ( ) {
264
264
write_str ! ( file, " def __init__(self): ..." ) ;
265
265
} else {
266
266
write_str ! ( file, "" ) ;
@@ -271,7 +271,7 @@ pub fn generator(type_data: &[PythonBindType]) -> io::Result<()> {
271
271
write_fmt ! ( file, " def __{func}__(" ) ;
272
272
write_fmt ! ( file, " {first_arg}," ) ;
273
273
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) {
275
275
let variable_name = variable_info. name . as_str ( ) ;
276
276
277
277
let default_value = match variable_info. raw_type . as_str ( ) {
@@ -315,7 +315,7 @@ pub fn generator(type_data: &[PythonBindType]) -> io::Result<()> {
315
315
write_str ! ( file, " Serializes this instance into a byte array" ) ;
316
316
write_str ! ( file, " \" \" \" " ) ;
317
317
318
- if !gen . is_frozen {
318
+ if !bind . is_frozen {
319
319
write_str ! ( file, " def unpack_with(self, data: bytes):" ) ;
320
320
write_str ! ( file, " \" \" \" " ) ;
321
321
write_str ! ( file, " Deserializes the data into this instance\n " ) ;
0 commit comments