int tool_id;
} _PyLegacyBranchEventHandler;
+#define _PyLegacyBranchEventHandler_CAST(op) ((_PyLegacyBranchEventHandler *)(op))
+
static void
-dealloc_branch_handler(_PyLegacyBranchEventHandler *self)
+dealloc_branch_handler(PyObject *op)
{
+ _PyLegacyBranchEventHandler *self = _PyLegacyBranchEventHandler_CAST(op);
Py_CLEAR(self->handler);
- PyObject_Free((PyObject *)self);
+ PyObject_Free(self);
}
static PyTypeObject _PyLegacyBranchEventHandler_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"sys.monitoring.branch_event_handler",
sizeof(_PyLegacyBranchEventHandler),
- .tp_dealloc = (destructor)dealloc_branch_handler,
+ .tp_dealloc = dealloc_branch_handler,
.tp_vectorcall_offset = offsetof(_PyLegacyBranchEventHandler, vectorcall),
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE |
Py_TPFLAGS_HAVE_VECTORCALL | Py_TPFLAGS_DISALLOW_INSTANTIATION,
static PyObject *
-branch_handler(
- _PyLegacyBranchEventHandler *self, PyObject *const *args,
+branch_handler_vectorcall(
+ PyObject *op, PyObject *const *args,
size_t nargsf, PyObject *kwnames
) {
+ _PyLegacyBranchEventHandler *self = _PyLegacyBranchEventHandler_CAST(op);
// Find the other instrumented instruction and remove tool
// The spec (PEP 669) allows spurious events after a DISABLE,
// so a best effort is good enough.
if (callback == NULL) {
return NULL;
}
- callback->vectorcall = (vectorcallfunc)branch_handler;
+ callback->vectorcall = branch_handler_vectorcall;
callback->handler = Py_NewRef(handler);
callback->right = right;
callback->tool_id = tool_id;
int bi_offset;
} branchesiterator;
+#define branchesiterator_CAST(op) ((branchesiterator *)(op))
+
static PyObject *
int_triple(int a, int b, int c) {
PyObject *obja = PyLong_FromLong(a);
}
static PyObject *
-branchesiter_next(branchesiterator *bi)
+branchesiter_next(PyObject *op)
{
+ branchesiterator *bi = branchesiterator_CAST(op);
int offset = bi->bi_offset;
int oparg = 0;
while (offset < Py_SIZE(bi->bi_code)) {
}
static void
-branchesiter_dealloc(branchesiterator *bi)
+branchesiter_dealloc(PyObject *op)
{
+ branchesiterator *bi = branchesiterator_CAST(op);
Py_DECREF(bi->bi_code);
PyObject_Free(bi);
}
sizeof(branchesiterator), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
- .tp_dealloc = (destructor)branchesiter_dealloc,
+ .tp_dealloc = branchesiter_dealloc,
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
.tp_iter = PyObject_SelfIter,
- .tp_iternext = (iternextfunc)branchesiter_next,
+ .tp_iternext = branchesiter_next,
.tp_free = PyObject_Del,
};