@@ -3,9 +3,10 @@ use crate::{Py, PyObjectRef, PyPayload};
33use crate :: { PyResult , VirtualMachine , builtins:: PyTypeRef , types:: Constructor } ;
44use crossbeam_utils:: atomic:: AtomicCell ;
55use rustpython_common:: lock:: PyRwLock ;
6+ use rustpython_vm:: stdlib:: ctypes:: base:: PyCSimple ;
67
78// TODO: make it metaclass
8- #[ pyclass( name = "Array " , module = "_ctypes" ) ]
9+ #[ pyclass( name = "ArrayType " , module = "_ctypes" ) ]
910#[ derive( PyPayload ) ]
1011pub struct PyCArrayType {
1112 pub ( super ) inner : PyCArray ,
@@ -34,15 +35,15 @@ impl Callable for PyCArrayType {
3435impl Constructor for PyCArrayType {
3536 type Args = PyObjectRef ;
3637
37- fn py_new ( _cls : PyTypeRef , args : Self :: Args , vm : & VirtualMachine ) -> PyResult {
38+ fn py_new ( _cls : PyTypeRef , _args : Self :: Args , _vm : & VirtualMachine ) -> PyResult {
3839 unreachable ! ( )
3940 }
4041}
4142
42- #[ pyclass( flags( IMMUTABLETYPE ) ) ]
43+ #[ pyclass( flags( IMMUTABLETYPE ) , with ( Callable , Constructor ) ) ]
4344impl PyCArrayType { }
4445
45- #[ pyclass( name = "Array" , module = "_ctypes" ) ]
46+ #[ pyclass( name = "Array" , base = "PyCSimple" , module = "_ctypes" ) ]
4647#[ derive( PyPayload ) ]
4748pub struct PyCArray {
4849 pub ( super ) typ : PyRwLock < PyTypeRef > ,
@@ -72,7 +73,7 @@ impl Constructor for PyCArray {
7273 }
7374}
7475
75- #[ pyclass( flags( BASETYPE , IMMUTABLETYPE ) ) ]
76+ #[ pyclass( flags( BASETYPE , IMMUTABLETYPE ) , with ( Constructor ) ) ]
7677impl PyCArray {
7778 #[ pygetset( name = "_type_" ) ]
7879 fn typ ( & self ) -> PyTypeRef {
@@ -84,12 +85,12 @@ impl PyCArray {
8485 self . length . load ( )
8586 }
8687
87- #[ pygetset( name = "_value_" ) ]
88+ #[ pygetset]
8889 fn value ( & self ) -> PyObjectRef {
8990 self . value . read ( ) . clone ( )
9091 }
9192
92- #[ pygetset( setter, name = "_value_" ) ]
93+ #[ pygetset( setter) ]
9394 fn set_value ( & self , value : PyObjectRef ) {
9495 * self . value . write ( ) = value;
9596 }
0 commit comments