@@ -5179,15 +5179,21 @@ PyCArrayType_from_ctype(ctypes_state *st, PyObject *itemtype, Py_ssize_t length)
51795179*/
51805180
51815181/*[clinic input]
5182- class _ctypes.Simple "PyObject *" "clinic_state()->Simple_Type"
5182+ class _ctypes.Simple "CDataObject *" "clinic_state()->Simple_Type"
5183+ [clinic start generated code]*/
5184+ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=e0493451fecf8cd4]*/
5185+
5186+ /*[clinic input]
5187+ @critical_section
5188+ @setter
5189+ _ctypes.Simple.value
51835190[clinic start generated code]*/
5184- /*[clinic end generated code: output=da39a3ee5e6b4b0d input=016c476c7aa8b8a8]*/
51855191
51865192static int
5187- Simple_set_value (PyObject * op , PyObject * value , void * Py_UNUSED (ignored ))
5193+ _ctypes_Simple_value_set_impl (CDataObject * self , PyObject * value )
5194+ /*[clinic end generated code: output=f267186118939863 input=977af9dc9e71e857]*/
51885195{
51895196 PyObject * result ;
5190- CDataObject * self = _CDataObject_CAST (op );
51915197
51925198 if (value == NULL ) {
51935199 PyErr_SetString (PyExc_TypeError ,
@@ -5197,54 +5203,57 @@ Simple_set_value(PyObject *op, PyObject *value, void *Py_UNUSED(ignored))
51975203
51985204 ctypes_state * st = get_module_state_by_def (Py_TYPE (Py_TYPE (self )));
51995205 StgInfo * info ;
5200- if (PyStgInfo_FromObject (st , op , & info ) < 0 ) {
5206+ if (PyStgInfo_FromObject (st , ( PyObject * ) self , & info ) < 0 ) {
52015207 return -1 ;
52025208 }
52035209 assert (info ); /* Cannot be NULL for CDataObject instances */
52045210 assert (info -> setfunc );
52055211
5206- LOCK_PTR (self );
52075212 result = info -> setfunc (self -> b_ptr , value , info -> size );
5208- UNLOCK_PTR (self );
52095213 if (!result )
52105214 return -1 ;
52115215
52125216 /* consumes the refcount the setfunc returns */
52135217 return KeepRef (self , 0 , result );
52145218}
52155219
5220+
52165221static int
52175222Simple_init (PyObject * self , PyObject * args , PyObject * kw )
52185223{
52195224 PyObject * value = NULL ;
52205225 if (!PyArg_UnpackTuple (args , "__init__" , 0 , 1 , & value ))
52215226 return -1 ;
52225227 if (value )
5223- return Simple_set_value (self , value , NULL );
5228+ return _ctypes_Simple_value_set (self , value , NULL );
52245229 return 0 ;
52255230}
52265231
5232+
5233+ /*[clinic input]
5234+ @critical_section
5235+ @getter
5236+ _ctypes.Simple.value
5237+ [clinic start generated code]*/
5238+
52275239static PyObject *
5228- Simple_get_value (PyObject * op , void * Py_UNUSED (ignored ))
5240+ _ctypes_Simple_value_get_impl (CDataObject * self )
5241+ /*[clinic end generated code: output=ce5a26570830a243 input=3ed3f735cec89282]*/
52295242{
5230- CDataObject * self = _CDataObject_CAST (op );
52315243 ctypes_state * st = get_module_state_by_def (Py_TYPE (Py_TYPE (self )));
52325244 StgInfo * info ;
5233- if (PyStgInfo_FromObject (st , op , & info ) < 0 ) {
5245+ if (PyStgInfo_FromObject (st , ( PyObject * ) self , & info ) < 0 ) {
52345246 return NULL ;
52355247 }
52365248 assert (info ); /* Cannot be NULL for CDataObject instances */
52375249 assert (info -> getfunc );
52385250 PyObject * res ;
5239- LOCK_PTR (self );
52405251 res = info -> getfunc (self -> b_ptr , self -> b_size );
5241- UNLOCK_PTR (self );
52425252 return res ;
52435253}
52445254
52455255static PyGetSetDef Simple_getsets [] = {
5246- { "value" , Simple_get_value , Simple_set_value ,
5247- "current value" , NULL },
5256+ _CTYPES_SIMPLE_VALUE_GETSETDEF
52485257 { NULL , NULL }
52495258};
52505259
@@ -5265,7 +5274,7 @@ Simple_from_outparm_impl(PyObject *self, PyTypeObject *cls)
52655274 return Py_NewRef (self );
52665275 }
52675276 /* call stginfo->getfunc */
5268- return Simple_get_value (self , NULL );
5277+ return _ctypes_Simple_value_get (self , NULL );
52695278}
52705279
52715280static PyMethodDef Simple_methods [] = {
@@ -5296,7 +5305,7 @@ Simple_repr(PyObject *self)
52965305 Py_TYPE (self )-> tp_name , self );
52975306 }
52985307
5299- val = Simple_get_value (self , NULL );
5308+ val = _ctypes_Simple_value_get (self , NULL );
53005309 if (val == NULL )
53015310 return NULL ;
53025311
0 commit comments