7#if PY_VERSION_HEX >= 0x03000000
9#define PyMethod_GET_CLASS( meth ) Py_None
16#pragma GCC diagnostic push
17#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
42 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES |
44 (
char*)
"PyROOT float object for pass by reference",
69#if PY_VERSION_HEX >= 0x02030000
72#if PY_VERSION_HEX >= 0x02060000
75#if PY_VERSION_HEX >= 0x03040000
78#if PY_VERSION_HEX >= 0x03080000
80#if PY_VERSION_HEX < 0x03090000
108 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES |
110 (
char*)
"PyROOT long object for pass by reference",
135#if PY_VERSION_HEX >= 0x02030000
138#if PY_VERSION_HEX >= 0x02060000
141#if PY_VERSION_HEX >= 0x03040000
144#if PY_VERSION_HEX >= 0x03080000
146#if PY_VERSION_HEX < 0x03090000
155#ifndef PyMethod_MAXFREELIST
156#define PyMethod_MAXFREELIST 256
160#
if PY_VERSION_HEX < 0x03000000
168 if ( ! PyCallable_Check( func ) ) {
169 PyErr_Format( PyExc_SystemError,
170 "%s:%d: bad argument to internal function",
171 __FILE__, __LINE__ );
177 free_list = (PyMethodObject*)( im->im_self );
186 im->im_weakreflist = NULL;
191#if PY_VERSION_HEX < 0x03000000
192 Py_XINCREF( pyclass );
193 im->im_class = pyclass;
195 PyObject_GC_Track( im );
205 PyObject_GC_UnTrack( im );
207 if ( im->im_weakreflist != NULL )
208 PyObject_ClearWeakRefs( (
PyObject*) im );
210 Py_DECREF( im->im_func );
211 Py_XDECREF( im->im_self );
212#if PY_VERSION_HEX < 0x03000000
213 Py_XDECREF( im->im_class );
233 PyObject* self = PyMethod_GET_SELF( meth );
239 PyObject* pyclass = PyMethod_GET_CLASS( meth );
240 if ( 1 <= argc && PyObject_IsInstance( PyTuple_GET_ITEM( args, 0 ), pyclass ) == 1 ) {
241 self = PyTuple_GET_ITEM( args, 0 );
243 PyObject* newArgs = PyTuple_New( argc - 1 );
244 for (
int i = 1; i < argc; ++i ) {
245 PyObject*
v = PyTuple_GET_ITEM( args, i );
247 PyTuple_SET_ITEM( newArgs, i-1,
v );
253 return PyMethod_Type.tp_call( meth, args, kw );
258 PyCFunctionObject* func = (PyCFunctionObject*)PyMethod_GET_FUNCTION( meth );
276 if ( PyMethod_GET_SELF( meth ) != NULL
277#
if PY_VERSION_HEX < 0x03000000
278 || ( PyMethod_GET_CLASS( meth ) != NULL &&
279 ! PyObject_IsSubclass( pyclass, PyMethod_GET_CLASS(meth) ) )
286 if ( obj == Py_None )
295 (
char*)
"ROOT.InstanceMethod",
314 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES |
316 (
char*)
"PyROOT custom instance method (internal)",
341#
if PY_VERSION_HEX >= 0x02030000
344#
if PY_VERSION_HEX >= 0x02060000
347#
if PY_VERSION_HEX >= 0x03040000
350#
if PY_VERSION_HEX >= 0x03080000
352#
if PY_VERSION_HEX < 0x03090000
358#if !defined(_MSC_VER)
359#pragma GCC diagnostic pop
#define PyVarObject_HEAD_INIT(type, size)
#define PyMethod_MAXFREELIST
typedef void((*Func_t)())
static PyObject * im_call(PyObject *meth, PyObject *args, PyObject *kw)
The mapping from a method to a function involves reshuffling of self back into the list of arguments.
static PyMethodObject * free_list
static void im_dealloc(PyMethodObject *im)
from instancemethod, but with custom type (at issue is that instancemethod is not meant to be derived...
static PyObject * im_descr_get(PyObject *meth, PyObject *obj, PyObject *pyclass)
from instancemethod: don't rebind an already bound method, or an unbound method of a class that's not...
PyTypeObject TCustomInstanceMethod_Type
PyTypeObject TCustomInt_Type
PyTypeObject TCustomFloat_Type
Custom builtins, detectable by type, for pass by ref.
PyObject * TCustomInstanceMethod_New(PyObject *func, PyObject *self, PyObject *pyclass)