11use crate :: {
2+ PythonBindType ,
23 generator:: Generator ,
34 structs:: { InnerOptionType , InnerVecType , RustType } ,
4- PythonBindType ,
55} ;
66use 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