Issue #1587: Added instancemethod wrapper for PyCFunctions. The Python C API

has gained a new type *PyInstanceMethod_Type* and the functions
*PyInstanceMethod_Check(o)*, *PyInstanceMethod_New(func)* and
*PyInstanceMethod_Function(im)*.
This commit is contained in:
Christian Heimes 2007-12-11 19:56:40 +00:00
parent fc5aa9d0bc
commit a3534a6ff5
4 changed files with 312 additions and 7 deletions

View file

@ -31,6 +31,24 @@ PyAPI_FUNC(PyObject *) PyMethod_Self(PyObject *);
#define PyMethod_GET_SELF(meth) \
(((PyMethodObject *)meth) -> im_self)
typedef struct {
PyObject_HEAD
PyObject *func;
} PyInstanceMethodObject;
PyAPI_DATA(PyTypeObject) PyInstanceMethod_Type;
#define PyInstanceMethod_Check(op) ((op)->ob_type == &PyInstanceMethod_Type)
PyAPI_FUNC(PyObject *) PyInstanceMethod_New(PyObject *);
PyAPI_FUNC(PyObject *) PyInstanceMethod_Function(PyObject *);
/* Macros for direct access to these values. Type checks are *not*
done, so use with care. */
#define PyInstanceMethod_GET_FUNCTION(meth) \
(((PyInstanceMethodObject *)meth) -> func)
#ifdef __cplusplus
}
#endif