@@ -128,8 +128,9 @@ bytes(cdata)
128
128
129
129
/*[clinic input]
130
130
module _ctypes
131
+ class _ctypes.CFuncPtr "PyCFuncPtrObject *" "&PyCFuncPtr_Type"
131
132
[clinic start generated code]*/
132
- /*[clinic end generated code: output=da39a3ee5e6b4b0d input=476a19c49b31a75c ]*/
133
+ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=58e8c99474bc631e ]*/
133
134
134
135
#define clinic_state () (get_module_state_by_class(cls))
135
136
#define clinic_state_sub () (get_module_state_by_class(cls->tp_base))
@@ -3422,33 +3423,56 @@ generic_pycdata_new(ctypes_state *st,
3422
3423
PyCFuncPtr_Type
3423
3424
*/
3424
3425
3426
+ /*[clinic input]
3427
+ @critical_section
3428
+ @setter
3429
+ _ctypes.CFuncPtr.errcheck
3430
+ [clinic start generated code]*/
3431
+
3425
3432
static int
3426
- PyCFuncPtr_set_errcheck (PyCFuncPtrObject * self , PyObject * ob , void * Py_UNUSED (ignored ))
3433
+ _ctypes_CFuncPtr_errcheck_set_impl (PyCFuncPtrObject * self , PyObject * value )
3434
+ /*[clinic end generated code: output=6580cf1ffdf3b9fb input=84930bb16c490b33]*/
3427
3435
{
3428
- if (ob && !PyCallable_Check (ob )) {
3436
+ if (value && !PyCallable_Check (value )) {
3429
3437
PyErr_SetString (PyExc_TypeError ,
3430
3438
"the errcheck attribute must be callable" );
3431
3439
return -1 ;
3432
3440
}
3433
- Py_XINCREF (ob );
3434
- Py_XSETREF (self -> errcheck , ob );
3441
+ Py_XINCREF (value );
3442
+ Py_XSETREF (self -> errcheck , value );
3435
3443
return 0 ;
3436
3444
}
3437
3445
3446
+ /*[clinic input]
3447
+ @critical_section
3448
+ @getter
3449
+ _ctypes.CFuncPtr.errcheck
3450
+
3451
+ a function to check for errors
3452
+ [clinic start generated code]*/
3453
+
3438
3454
static PyObject *
3439
- PyCFuncPtr_get_errcheck (PyCFuncPtrObject * self , void * Py_UNUSED (ignored ))
3455
+ _ctypes_CFuncPtr_errcheck_get_impl (PyCFuncPtrObject * self )
3456
+ /*[clinic end generated code: output=dfa6fb5c6f90fd14 input=4672135fef37819f]*/
3440
3457
{
3441
3458
if (self -> errcheck ) {
3442
3459
return Py_NewRef (self -> errcheck );
3443
3460
}
3444
3461
Py_RETURN_NONE ;
3445
3462
}
3446
3463
3464
+ /*[clinic input]
3465
+ @setter
3466
+ @critical_section
3467
+ _ctypes.CFuncPtr.restype
3468
+ [clinic start generated code]*/
3469
+
3447
3470
static int
3448
- PyCFuncPtr_set_restype (PyCFuncPtrObject * self , PyObject * ob , void * Py_UNUSED (ignored ))
3471
+ _ctypes_CFuncPtr_restype_set_impl (PyCFuncPtrObject * self , PyObject * value )
3472
+ /*[clinic end generated code: output=0be0a086abbabf18 input=683c3bef4562ccc6]*/
3449
3473
{
3450
3474
PyObject * checker , * oldchecker ;
3451
- if (ob == NULL ) {
3475
+ if (value == NULL ) {
3452
3476
oldchecker = self -> checker ;
3453
3477
self -> checker = NULL ;
3454
3478
Py_CLEAR (self -> restype );
@@ -3457,27 +3481,36 @@ PyCFuncPtr_set_restype(PyCFuncPtrObject *self, PyObject *ob, void *Py_UNUSED(ign
3457
3481
}
3458
3482
ctypes_state * st = get_module_state_by_def (Py_TYPE (Py_TYPE (self )));
3459
3483
StgInfo * info ;
3460
- if (PyStgInfo_FromType (st , ob , & info ) < 0 ) {
3484
+ if (PyStgInfo_FromType (st , value , & info ) < 0 ) {
3461
3485
return -1 ;
3462
3486
}
3463
- if (ob != Py_None && !info && !PyCallable_Check (ob )) {
3487
+ if (value != Py_None && !info && !PyCallable_Check (value )) {
3464
3488
PyErr_SetString (PyExc_TypeError ,
3465
3489
"restype must be a type, a callable, or None" );
3466
3490
return -1 ;
3467
3491
}
3468
- if (PyObject_GetOptionalAttr (ob , & _Py_ID (_check_retval_ ), & checker ) < 0 ) {
3492
+ if (PyObject_GetOptionalAttr (value , & _Py_ID (_check_retval_ ), & checker ) < 0 ) {
3469
3493
return -1 ;
3470
3494
}
3471
3495
oldchecker = self -> checker ;
3472
3496
self -> checker = checker ;
3473
- Py_INCREF (ob );
3474
- Py_XSETREF (self -> restype , ob );
3497
+ Py_INCREF (value );
3498
+ Py_XSETREF (self -> restype , value );
3475
3499
Py_XDECREF (oldchecker );
3476
3500
return 0 ;
3477
3501
}
3478
3502
3503
+ /*[clinic input]
3504
+ @getter
3505
+ @critical_section
3506
+ _ctypes.CFuncPtr.restype
3507
+
3508
+ specify the result type
3509
+ [clinic start generated code]*/
3510
+
3479
3511
static PyObject *
3480
- PyCFuncPtr_get_restype (PyCFuncPtrObject * self , void * Py_UNUSED (ignored ))
3512
+ _ctypes_CFuncPtr_restype_get_impl (PyCFuncPtrObject * self )
3513
+ /*[clinic end generated code: output=c8f44cd16f1dee5e input=5e3ed95116204fd2]*/
3481
3514
{
3482
3515
if (self -> restype ) {
3483
3516
return Py_NewRef (self -> restype );
@@ -3495,28 +3528,44 @@ PyCFuncPtr_get_restype(PyCFuncPtrObject *self, void *Py_UNUSED(ignored))
3495
3528
}
3496
3529
}
3497
3530
3531
+ /*[clinic input]
3532
+ @setter
3533
+ @critical_section
3534
+ _ctypes.CFuncPtr.argtypes
3535
+ [clinic start generated code]*/
3536
+
3498
3537
static int
3499
- PyCFuncPtr_set_argtypes (PyCFuncPtrObject * self , PyObject * ob , void * Py_UNUSED (ignored ))
3538
+ _ctypes_CFuncPtr_argtypes_set_impl (PyCFuncPtrObject * self , PyObject * value )
3539
+ /*[clinic end generated code: output=596a36e2ae89d7d1 input=c4627573e980aa8b]*/
3500
3540
{
3501
3541
PyObject * converters ;
3502
3542
3503
- if (ob == NULL || ob == Py_None ) {
3543
+ if (value == NULL || value == Py_None ) {
3504
3544
Py_CLEAR (self -> converters );
3505
3545
Py_CLEAR (self -> argtypes );
3506
3546
} else {
3507
3547
ctypes_state * st = get_module_state_by_def (Py_TYPE (Py_TYPE (self )));
3508
- converters = converters_from_argtypes (st , ob );
3548
+ converters = converters_from_argtypes (st , value );
3509
3549
if (!converters )
3510
3550
return -1 ;
3511
3551
Py_XSETREF (self -> converters , converters );
3512
- Py_INCREF (ob );
3513
- Py_XSETREF (self -> argtypes , ob );
3552
+ Py_INCREF (value );
3553
+ Py_XSETREF (self -> argtypes , value );
3514
3554
}
3515
3555
return 0 ;
3516
3556
}
3517
3557
3558
+ /*[clinic input]
3559
+ @getter
3560
+ @critical_section
3561
+ _ctypes.CFuncPtr.argtypes
3562
+
3563
+ specify the argument types
3564
+ [clinic start generated code]*/
3565
+
3518
3566
static PyObject *
3519
- PyCFuncPtr_get_argtypes (PyCFuncPtrObject * self , void * Py_UNUSED (ignored ))
3567
+ _ctypes_CFuncPtr_argtypes_get_impl (PyCFuncPtrObject * self )
3568
+ /*[clinic end generated code: output=c46b05a1b0f99172 input=37a8a545a56f8ae2]*/
3520
3569
{
3521
3570
if (self -> argtypes ) {
3522
3571
return Py_NewRef (self -> argtypes );
@@ -3535,13 +3584,9 @@ PyCFuncPtr_get_argtypes(PyCFuncPtrObject *self, void *Py_UNUSED(ignored))
3535
3584
}
3536
3585
3537
3586
static PyGetSetDef PyCFuncPtr_getsets [] = {
3538
- { "errcheck" , (getter )PyCFuncPtr_get_errcheck , (setter )PyCFuncPtr_set_errcheck ,
3539
- "a function to check for errors" , NULL },
3540
- { "restype" , (getter )PyCFuncPtr_get_restype , (setter )PyCFuncPtr_set_restype ,
3541
- "specify the result type" , NULL },
3542
- { "argtypes" , (getter )PyCFuncPtr_get_argtypes ,
3543
- (setter )PyCFuncPtr_set_argtypes ,
3544
- "specify the argument types" , NULL },
3587
+ _CTYPES_CFUNCPTR_ERRCHECK_GETSETDEF
3588
+ _CTYPES_CFUNCPTR_RESTYPE_GETSETDEF
3589
+ _CTYPES_CFUNCPTR_ARGTYPES_GETSETDEF
3545
3590
{ NULL , NULL }
3546
3591
};
3547
3592
@@ -5054,7 +5099,6 @@ class _ctypes.Simple "PyObject *" "clinic_state()->Simple_Type"
5054
5099
[clinic start generated code]*/
5055
5100
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=016c476c7aa8b8a8]*/
5056
5101
5057
-
5058
5102
static int
5059
5103
Simple_set_value (CDataObject * self , PyObject * value , void * Py_UNUSED (ignored ))
5060
5104
{
0 commit comments