Spaces:
Running
Running
/* Method object interface */ | |
extern "C" { | |
/* This is about the type 'builtin_function_or_method', | |
not Python methods in user-defined classes. See classobject.h | |
for the latter. */ | |
PyAPI_DATA(PyTypeObject) PyCFunction_Type; | |
typedef PyObject *(*PyCFunction)(PyObject *, PyObject *); | |
typedef PyObject *(*_PyCFunctionFast) (PyObject *, PyObject *const *, Py_ssize_t); | |
typedef PyObject *(*PyCFunctionWithKeywords)(PyObject *, PyObject *, | |
PyObject *); | |
typedef PyObject *(*_PyCFunctionFastWithKeywords) (PyObject *, | |
PyObject *const *, Py_ssize_t, | |
PyObject *); | |
typedef PyObject *(*PyCMethod)(PyObject *, PyTypeObject *, PyObject *const *, | |
size_t, PyObject *); | |
PyAPI_FUNC(PyCFunction) PyCFunction_GetFunction(PyObject *); | |
PyAPI_FUNC(PyObject *) PyCFunction_GetSelf(PyObject *); | |
PyAPI_FUNC(int) PyCFunction_GetFlags(PyObject *); | |
Py_DEPRECATED(3.9) PyAPI_FUNC(PyObject *) PyCFunction_Call(PyObject *, PyObject *, PyObject *); | |
struct PyMethodDef { | |
const char *ml_name; /* The name of the built-in function/method */ | |
PyCFunction ml_meth; /* The C function that implements it */ | |
int ml_flags; /* Combination of METH_xxx flags, which mostly | |
describe the args expected by the C func */ | |
const char *ml_doc; /* The __doc__ attribute, or NULL */ | |
}; | |
typedef struct PyMethodDef PyMethodDef; | |
/* PyCFunction_New is declared as a function for stable ABI (declaration is | |
* needed for e.g. GCC with -fvisibility=hidden), but redefined as a macro | |
* that calls PyCFunction_NewEx. */ | |
PyAPI_FUNC(PyObject *) PyCFunction_New(PyMethodDef *, PyObject *); | |
/* PyCFunction_NewEx is similar: on 3.9+, this calls PyCMethod_New. */ | |
PyAPI_FUNC(PyObject *) PyCFunction_NewEx(PyMethodDef *, PyObject *, | |
PyObject *); | |
PyAPI_FUNC(PyObject *) PyCMethod_New(PyMethodDef *, PyObject *, | |
PyObject *, PyTypeObject *); | |
/* Flag passed to newmethodobject */ | |
/* #define METH_OLDARGS 0x0000 -- unsupported now */ | |
/* METH_NOARGS and METH_O must not be combined with the flags above. */ | |
/* METH_CLASS and METH_STATIC are a little different; these control | |
the construction of methods for a class. These cannot be used for | |
functions in modules. */ | |
/* METH_COEXIST allows a method to be entered even though a slot has | |
already filled the entry. When defined, the flag allows a separate | |
method, "__contains__" for example, to coexist with a defined | |
slot like sq_contains. */ | |
/* This bit is preserved for Stackless Python */ | |
/* METH_METHOD means the function stores an | |
* additional reference to the class that defines it; | |
* both self and class are passed to it. | |
* It uses PyCMethodObject instead of PyCFunctionObject. | |
* May not be combined with METH_NOARGS, METH_O, METH_CLASS or METH_STATIC. | |
*/ | |
} | |