@@ -174,10 +174,16 @@ macro_rules! generate_reg_read {
174174 impl [ <$servo_name: camel SyncController >] {
175175 pub fn [ <read_ $reg_name>] (
176176 & self ,
177- ids: Vec <u8 >,
178- ) -> PyResult <Vec <$reg_type>> {
179- self . 0 . lock( ) . unwrap( ) . [ <read_ $reg_name>] ( & ids)
180- . map_err( |e| pyo3:: exceptions:: PyRuntimeError :: new_err( e. to_string( ) ) )
177+ py: Python ,
178+ ids: & Bound <' _, pyo3:: types:: PyList >,
179+ ) -> PyResult <PyObject > {
180+ let ids = ids. extract:: <Vec <u8 >>( ) ?;
181+
182+ let x = self . 0 . lock( ) . unwrap( ) . [ <read_ $reg_name>] ( & ids)
183+ . map_err( |e| pyo3:: exceptions:: PyRuntimeError :: new_err( e. to_string( ) ) ) ?;
184+ let l = pyo3:: types:: PyList :: new( py, x. clone( ) ) ?;
185+
186+ Ok ( l. into( ) )
181187 }
182188 }
183189
@@ -257,8 +263,10 @@ macro_rules! generate_reg_read {
257263 pub fn [ <read_ $reg_name>] (
258264 & self ,
259265 py: Python ,
260- ids: Vec < u8 >,
266+ ids: Bound < ' _ , pyo3 :: types :: PyList >,
261267 ) -> PyResult <PyObject > {
268+ let ids = ids. extract:: <Vec <u8 >>( ) ?;
269+
262270 let x = self . 0 . lock( ) . unwrap( ) . [ <read_ $reg_name>] ( & ids)
263271 . map_err( |e| pyo3:: exceptions:: PyRuntimeError :: new_err( e. to_string( ) ) ) ?;
264272 let l = pyo3:: types:: PyList :: new( py, x. clone( ) ) ?;
@@ -323,10 +331,13 @@ macro_rules! generate_reg_write {
323331 #[ doc = concat!( "Write register *" , stringify!( $name) , "* (addr: " , stringify!( $addr) , ", type: " , stringify!( $reg_type) , ")" ) ]
324332 pub fn [ <write_ $reg_name>] (
325333 & self ,
326- ids: & [ u8 ] ,
327- values: Vec <$reg_type >,
334+ ids: Bound < ' _ , pyo3 :: types :: PyList > ,
335+ values: Bound < ' _ , pyo3 :: types :: PyList >,
328336 ) -> PyResult <( ) > {
329- self . 0 . lock( ) . unwrap( ) . [ <write_ $reg_name>] ( ids, & values) . map_err( |e| {
337+ let ids = ids. extract:: <Vec <u8 >>( ) ?;
338+ let values = values. extract:: <Vec <$reg_type>>( ) ?;
339+
340+ self . 0 . lock( ) . unwrap( ) . [ <write_ $reg_name>] ( & ids, & values) . map_err( |e| {
330341 pyo3:: exceptions:: PyRuntimeError :: new_err( e. to_string( ) )
331342 } )
332343 }
@@ -410,12 +421,13 @@ macro_rules! generate_reg_write {
410421 #[ doc = concat!( "Write register *" , stringify!( $name) , "* (addr: " , stringify!( $addr) , ", type: " , stringify!( $reg_type) , ")" ) ]
411422 pub fn [ <write_ $reg_name>] (
412423 & self ,
413- ids: & [ u8 ] ,
424+ ids: & Bound < ' _ , pyo3 :: types :: PyList > ,
414425 values: & Bound <' _, pyo3:: types:: PyList >,
415426 ) -> PyResult <( ) > {
427+ let ids = ids. extract:: <Vec <u8 >>( ) ?;
416428 let values = values. extract:: <Vec <<$conv as Conversion >:: UsiType >>( ) ?;
417429
418- self . 0 . lock( ) . unwrap( ) . [ <write_ $reg_name>] ( ids, & values) . map_err( |e| {
430+ self . 0 . lock( ) . unwrap( ) . [ <write_ $reg_name>] ( & ids, & values) . map_err( |e| {
419431 pyo3:: exceptions:: PyRuntimeError :: new_err( e. to_string( ) )
420432 } )
421433 }
0 commit comments