PageRenderTime 33ms CodeModel.GetById 22ms app.highlight 9ms RepoModel.GetById 0ms app.codeStats 0ms

/python3/include/python3.9/methodobject.h

https://gitlab.com/Alioth-Project/clang-r445002
C Header | 110 lines | 63 code | 25 blank | 22 comment | 2 complexity | bbf63d5b676c05c658805ba163513296 MD5 | raw file
  1
  2/* Method object interface */
  3
  4#ifndef Py_METHODOBJECT_H
  5#define Py_METHODOBJECT_H
  6#ifdef __cplusplus
  7extern "C" {
  8#endif
  9
 10/* This is about the type 'builtin_function_or_method',
 11   not Python methods in user-defined classes.  See classobject.h
 12   for the latter. */
 13
 14PyAPI_DATA(PyTypeObject) PyCFunction_Type;
 15
 16#define PyCFunction_CheckExact(op) Py_IS_TYPE(op, &PyCFunction_Type)
 17#define PyCFunction_Check(op) PyObject_TypeCheck(op, &PyCFunction_Type)
 18
 19typedef PyObject *(*PyCFunction)(PyObject *, PyObject *);
 20typedef PyObject *(*_PyCFunctionFast) (PyObject *, PyObject *const *, Py_ssize_t);
 21typedef PyObject *(*PyCFunctionWithKeywords)(PyObject *, PyObject *,
 22                                             PyObject *);
 23typedef PyObject *(*_PyCFunctionFastWithKeywords) (PyObject *,
 24                                                   PyObject *const *, Py_ssize_t,
 25                                                   PyObject *);
 26typedef PyObject *(*PyCMethod)(PyObject *, PyTypeObject *, PyObject *const *,
 27                               size_t, PyObject *);
 28
 29PyAPI_FUNC(PyCFunction) PyCFunction_GetFunction(PyObject *);
 30PyAPI_FUNC(PyObject *) PyCFunction_GetSelf(PyObject *);
 31PyAPI_FUNC(int) PyCFunction_GetFlags(PyObject *);
 32
 33Py_DEPRECATED(3.9) PyAPI_FUNC(PyObject *) PyCFunction_Call(PyObject *, PyObject *, PyObject *);
 34
 35struct PyMethodDef {
 36    const char  *ml_name;   /* The name of the built-in function/method */
 37    PyCFunction ml_meth;    /* The C function that implements it */
 38    int         ml_flags;   /* Combination of METH_xxx flags, which mostly
 39                               describe the args expected by the C func */
 40    const char  *ml_doc;    /* The __doc__ attribute, or NULL */
 41};
 42typedef struct PyMethodDef PyMethodDef;
 43
 44#define PyCFunction_New(ML, SELF) PyCFunction_NewEx((ML), (SELF), NULL)
 45PyAPI_FUNC(PyObject *) PyCFunction_NewEx(PyMethodDef *, PyObject *,
 46                                         PyObject *);
 47
 48#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03090000
 49#define PyCFunction_NewEx(ML, SELF, MOD) PyCMethod_New((ML), (SELF), (MOD), NULL)
 50PyAPI_FUNC(PyObject *) PyCMethod_New(PyMethodDef *, PyObject *,
 51                                     PyObject *, PyTypeObject *);
 52#endif
 53
 54
 55/* Flag passed to newmethodobject */
 56/* #define METH_OLDARGS  0x0000   -- unsupported now */
 57#define METH_VARARGS  0x0001
 58#define METH_KEYWORDS 0x0002
 59/* METH_NOARGS and METH_O must not be combined with the flags above. */
 60#define METH_NOARGS   0x0004
 61#define METH_O        0x0008
 62
 63/* METH_CLASS and METH_STATIC are a little different; these control
 64   the construction of methods for a class.  These cannot be used for
 65   functions in modules. */
 66#define METH_CLASS    0x0010
 67#define METH_STATIC   0x0020
 68
 69/* METH_COEXIST allows a method to be entered even though a slot has
 70   already filled the entry.  When defined, the flag allows a separate
 71   method, "__contains__" for example, to coexist with a defined
 72   slot like sq_contains. */
 73
 74#define METH_COEXIST   0x0040
 75
 76#ifndef Py_LIMITED_API
 77#define METH_FASTCALL  0x0080
 78#endif
 79
 80/* This bit is preserved for Stackless Python */
 81#ifdef STACKLESS
 82#define METH_STACKLESS 0x0100
 83#else
 84#define METH_STACKLESS 0x0000
 85#endif
 86
 87/* METH_METHOD means the function stores an
 88 * additional reference to the class that defines it;
 89 * both self and class are passed to it.
 90 * It uses PyCMethodObject instead of PyCFunctionObject.
 91 * May not be combined with METH_NOARGS, METH_O, METH_CLASS or METH_STATIC.
 92 */
 93
 94#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03090000
 95#define METH_METHOD 0x0200
 96#endif
 97
 98
 99#ifndef Py_LIMITED_API
100
101#define Py_CPYTHON_METHODOBJECT_H
102#include  "cpython/methodobject.h"
103#undef Py_CPYTHON_METHODOBJECT_H
104
105#endif
106
107#ifdef __cplusplus
108}
109#endif
110#endif /* !Py_METHODOBJECT_H */