@@ -2916,18 +2916,21 @@ typedef struct _PyLegacyBranchEventHandler {
2916
2916
int tool_id ;
2917
2917
} _PyLegacyBranchEventHandler ;
2918
2918
2919
+ #define _PyLegacyBranchEventHandler_CAST (op ) ((_PyLegacyBranchEventHandler *)(op))
2920
+
2919
2921
static void
2920
- dealloc_branch_handler (_PyLegacyBranchEventHandler * self )
2922
+ dealloc_branch_handler (PyObject * op )
2921
2923
{
2924
+ _PyLegacyBranchEventHandler * self = _PyLegacyBranchEventHandler_CAST (op );
2922
2925
Py_CLEAR (self -> handler );
2923
- PyObject_Free (( PyObject * ) self );
2926
+ PyObject_Free (self );
2924
2927
}
2925
2928
2926
2929
static PyTypeObject _PyLegacyBranchEventHandler_Type = {
2927
2930
PyVarObject_HEAD_INIT (& PyType_Type , 0 )
2928
2931
"sys.monitoring.branch_event_handler" ,
2929
2932
sizeof (_PyLegacyBranchEventHandler ),
2930
- .tp_dealloc = ( destructor ) dealloc_branch_handler ,
2933
+ .tp_dealloc = dealloc_branch_handler ,
2931
2934
.tp_vectorcall_offset = offsetof(_PyLegacyBranchEventHandler , vectorcall ),
2932
2935
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE |
2933
2936
Py_TPFLAGS_HAVE_VECTORCALL | Py_TPFLAGS_DISALLOW_INSTANTIATION ,
@@ -2936,10 +2939,11 @@ static PyTypeObject _PyLegacyBranchEventHandler_Type = {
2936
2939
2937
2940
2938
2941
static PyObject *
2939
- branch_handler (
2940
- _PyLegacyBranchEventHandler * self , PyObject * const * args ,
2942
+ branch_handler_vectorcall (
2943
+ PyObject * op , PyObject * const * args ,
2941
2944
size_t nargsf , PyObject * kwnames
2942
2945
) {
2946
+ _PyLegacyBranchEventHandler * self = _PyLegacyBranchEventHandler_CAST (op );
2943
2947
// Find the other instrumented instruction and remove tool
2944
2948
// The spec (PEP 669) allows spurious events after a DISABLE,
2945
2949
// so a best effort is good enough.
@@ -3000,7 +3004,7 @@ static PyObject *make_branch_handler(int tool_id, PyObject *handler, bool right)
3000
3004
if (callback == NULL ) {
3001
3005
return NULL ;
3002
3006
}
3003
- callback -> vectorcall = ( vectorcallfunc ) branch_handler ;
3007
+ callback -> vectorcall = branch_handler_vectorcall ;
3004
3008
callback -> handler = Py_NewRef (handler );
3005
3009
callback -> right = right ;
3006
3010
callback -> tool_id = tool_id ;
@@ -3062,6 +3066,8 @@ typedef struct {
3062
3066
int bi_offset ;
3063
3067
} branchesiterator ;
3064
3068
3069
+ #define branchesiterator_CAST (op ) ((branchesiterator *)(op))
3070
+
3065
3071
static PyObject *
3066
3072
int_triple (int a , int b , int c ) {
3067
3073
PyObject * obja = PyLong_FromLong (a );
@@ -3088,8 +3094,9 @@ int_triple(int a, int b, int c) {
3088
3094
}
3089
3095
3090
3096
static PyObject *
3091
- branchesiter_next (branchesiterator * bi )
3097
+ branchesiter_next (PyObject * op )
3092
3098
{
3099
+ branchesiterator * bi = branchesiterator_CAST (op );
3093
3100
int offset = bi -> bi_offset ;
3094
3101
int oparg = 0 ;
3095
3102
while (offset < Py_SIZE (bi -> bi_code )) {
@@ -3130,8 +3137,9 @@ branchesiter_next(branchesiterator *bi)
3130
3137
}
3131
3138
3132
3139
static void
3133
- branchesiter_dealloc (branchesiterator * bi )
3140
+ branchesiter_dealloc (PyObject * op )
3134
3141
{
3142
+ branchesiterator * bi = branchesiterator_CAST (op );
3135
3143
Py_DECREF (bi -> bi_code );
3136
3144
PyObject_Free (bi );
3137
3145
}
@@ -3142,10 +3150,10 @@ static PyTypeObject _PyBranchesIterator = {
3142
3150
sizeof (branchesiterator ), /* tp_basicsize */
3143
3151
0 , /* tp_itemsize */
3144
3152
/* methods */
3145
- .tp_dealloc = ( destructor ) branchesiter_dealloc ,
3153
+ .tp_dealloc = branchesiter_dealloc ,
3146
3154
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE ,
3147
3155
.tp_iter = PyObject_SelfIter ,
3148
- .tp_iternext = ( iternextfunc ) branchesiter_next ,
3156
+ .tp_iternext = branchesiter_next ,
3149
3157
.tp_free = PyObject_Del ,
3150
3158
};
3151
3159
0 commit comments