codekingpro/portable-devtools
115k
1/* Former class object interface -- now only bound methods are here */2 3/* Revealing some structures (not for general use) */4 5#ifndef Py_LIMITED_API6#ifndef Py_CLASSOBJECT_H7#define Py_CLASSOBJECT_H8#ifdef __cplusplus9extern "C" {10#endif11 12typedef struct {13 PyObject_HEAD14 PyObject *im_func; /* The callable object implementing the method */15 PyObject *im_self; /* The instance it is bound to */16 PyObject *im_weakreflist; /* List of weak references */17 vectorcallfunc vectorcall;18} PyMethodObject;19 20PyAPI_DATA(PyTypeObject) PyMethod_Type;21 22#define PyMethod_Check(op) Py_IS_TYPE((op), &PyMethod_Type)23 24PyAPI_FUNC(PyObject *) PyMethod_New(PyObject *, PyObject *);25 26PyAPI_FUNC(PyObject *) PyMethod_Function(PyObject *);27PyAPI_FUNC(PyObject *) PyMethod_Self(PyObject *);28 29#define _PyMethod_CAST(meth) \30 (assert(PyMethod_Check(meth)), _Py_CAST(PyMethodObject*, meth))31 32/* Static inline functions for direct access to these values.33 Type checks are *not* done, so use with care. */34static inline PyObject* PyMethod_GET_FUNCTION(PyObject *meth) {35 return _PyMethod_CAST(meth)->im_func;36}37#define PyMethod_GET_FUNCTION(meth) PyMethod_GET_FUNCTION(_PyObject_CAST(meth))38 39static inline PyObject* PyMethod_GET_SELF(PyObject *meth) {40 return _PyMethod_CAST(meth)->im_self;41}42#define PyMethod_GET_SELF(meth) PyMethod_GET_SELF(_PyObject_CAST(meth))43 44typedef struct {45 PyObject_HEAD46 PyObject *func;47} PyInstanceMethodObject;48 49PyAPI_DATA(PyTypeObject) PyInstanceMethod_Type;50 51#define PyInstanceMethod_Check(op) Py_IS_TYPE((op), &PyInstanceMethod_Type)52 53PyAPI_FUNC(PyObject *) PyInstanceMethod_New(PyObject *);54PyAPI_FUNC(PyObject *) PyInstanceMethod_Function(PyObject *);55 56#define _PyInstanceMethod_CAST(meth) \57 (assert(PyInstanceMethod_Check(meth)), \58 _Py_CAST(PyInstanceMethodObject*, meth))59 60/* Static inline function for direct access to these values.61 Type checks are *not* done, so use with care. */62static inline PyObject* PyInstanceMethod_GET_FUNCTION(PyObject *meth) {63 return _PyInstanceMethod_CAST(meth)->func;64}65#define PyInstanceMethod_GET_FUNCTION(meth) PyInstanceMethod_GET_FUNCTION(_PyObject_CAST(meth))66 67#ifdef __cplusplus68}69#endif70#endif // !Py_CLASSOBJECT_H71#endif // !Py_LIMITED_API72 