| #ifndef Py_CPYTHON_ABSTRACTOBJECT_H |
| # error "this header file must not be included directly" |
| #endif |
|
|
| |
|
|
| #ifdef PY_SSIZE_T_CLEAN |
| # define _PyObject_CallMethodId _PyObject_CallMethodId_SizeT |
| #endif |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| PyAPI_FUNC(PyObject *) _PyStack_AsDict( |
| PyObject *const *values, |
| PyObject *kwnames); |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| #define _PY_FASTCALL_SMALL_STACK 5 |
|
|
| PyAPI_FUNC(PyObject *) _Py_CheckFunctionResult( |
| PyThreadState *tstate, |
| PyObject *callable, |
| PyObject *result, |
| const char *where); |
|
|
| |
|
|
| |
| |
| |
| PyAPI_FUNC(PyObject *) _PyObject_MakeTpCall( |
| PyThreadState *tstate, |
| PyObject *callable, |
| PyObject *const *args, Py_ssize_t nargs, |
| PyObject *keywords); |
|
|
| #define PY_VECTORCALL_ARGUMENTS_OFFSET ((size_t)1 << (8 * sizeof(size_t) - 1)) |
|
|
| static inline Py_ssize_t |
| PyVectorcall_NARGS(size_t n) |
| { |
| return n & ~PY_VECTORCALL_ARGUMENTS_OFFSET; |
| } |
|
|
| static inline vectorcallfunc |
| PyVectorcall_Function(PyObject *callable) |
| { |
| PyTypeObject *tp; |
| Py_ssize_t offset; |
| vectorcallfunc ptr; |
|
|
| assert(callable != NULL); |
| tp = Py_TYPE(callable); |
| if (!PyType_HasFeature(tp, Py_TPFLAGS_HAVE_VECTORCALL)) { |
| return NULL; |
| } |
| assert(PyCallable_Check(callable)); |
| offset = tp->tp_vectorcall_offset; |
| assert(offset > 0); |
| memcpy(&ptr, (char *) callable + offset, sizeof(ptr)); |
| return ptr; |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| static inline PyObject * |
| _PyObject_VectorcallTstate(PyThreadState *tstate, PyObject *callable, |
| PyObject *const *args, size_t nargsf, |
| PyObject *kwnames) |
| { |
| vectorcallfunc func; |
| PyObject *res; |
|
|
| assert(kwnames == NULL || PyTuple_Check(kwnames)); |
| assert(args != NULL || PyVectorcall_NARGS(nargsf) == 0); |
|
|
| func = PyVectorcall_Function(callable); |
| if (func == NULL) { |
| Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); |
| return _PyObject_MakeTpCall(tstate, callable, args, nargs, kwnames); |
| } |
| res = func(callable, args, nargsf, kwnames); |
| return _Py_CheckFunctionResult(tstate, callable, res, NULL); |
| } |
|
|
| static inline PyObject * |
| PyObject_Vectorcall(PyObject *callable, PyObject *const *args, |
| size_t nargsf, PyObject *kwnames) |
| { |
| PyThreadState *tstate = PyThreadState_Get(); |
| return _PyObject_VectorcallTstate(tstate, callable, |
| args, nargsf, kwnames); |
| } |
|
|
| |
| #define _PyObject_Vectorcall PyObject_Vectorcall |
| #define _PyObject_VectorcallMethod PyObject_VectorcallMethod |
| #define _PyObject_FastCallDict PyObject_VectorcallDict |
| #define _PyVectorcall_Function PyVectorcall_Function |
| #define _PyObject_CallOneArg PyObject_CallOneArg |
| #define _PyObject_CallMethodNoArgs PyObject_CallMethodNoArgs |
| #define _PyObject_CallMethodOneArg PyObject_CallMethodOneArg |
|
|
| |
| |
| PyAPI_FUNC(PyObject *) PyObject_VectorcallDict( |
| PyObject *callable, |
| PyObject *const *args, |
| size_t nargsf, |
| PyObject *kwargs); |
|
|
| |
| |
| PyAPI_FUNC(PyObject *) PyVectorcall_Call(PyObject *callable, PyObject *tuple, PyObject *dict); |
|
|
| static inline PyObject * |
| _PyObject_FastCallTstate(PyThreadState *tstate, PyObject *func, PyObject *const *args, Py_ssize_t nargs) |
| { |
| return _PyObject_VectorcallTstate(tstate, func, args, (size_t)nargs, NULL); |
| } |
|
|
| |
| static inline PyObject * |
| _PyObject_FastCall(PyObject *func, PyObject *const *args, Py_ssize_t nargs) |
| { |
| PyThreadState *tstate = PyThreadState_Get(); |
| return _PyObject_FastCallTstate(tstate, func, args, nargs); |
| } |
|
|
| |
| |
| |
| static inline PyObject * |
| _PyObject_CallNoArg(PyObject *func) { |
| PyThreadState *tstate = PyThreadState_Get(); |
| return _PyObject_VectorcallTstate(tstate, func, NULL, 0, NULL); |
| } |
|
|
| static inline PyObject * |
| PyObject_CallOneArg(PyObject *func, PyObject *arg) |
| { |
| PyObject *_args[2]; |
| PyObject **args; |
| PyThreadState *tstate; |
| size_t nargsf; |
|
|
| assert(arg != NULL); |
| args = _args + 1; |
| args[0] = arg; |
| tstate = PyThreadState_Get(); |
| nargsf = 1 | PY_VECTORCALL_ARGUMENTS_OFFSET; |
| return _PyObject_VectorcallTstate(tstate, func, args, nargsf, NULL); |
| } |
|
|
| PyAPI_FUNC(PyObject *) PyObject_VectorcallMethod( |
| PyObject *name, PyObject *const *args, |
| size_t nargsf, PyObject *kwnames); |
|
|
| static inline PyObject * |
| PyObject_CallMethodNoArgs(PyObject *self, PyObject *name) |
| { |
| return PyObject_VectorcallMethod(name, &self, |
| 1 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); |
| } |
|
|
| static inline PyObject * |
| PyObject_CallMethodOneArg(PyObject *self, PyObject *name, PyObject *arg) |
| { |
| PyObject *args[2] = {self, arg}; |
|
|
| assert(arg != NULL); |
| return PyObject_VectorcallMethod(name, args, |
| 2 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); |
| } |
|
|
| |
| |
| PyAPI_FUNC(PyObject *) _PyObject_CallMethodId(PyObject *obj, |
| _Py_Identifier *name, |
| const char *format, ...); |
|
|
| PyAPI_FUNC(PyObject *) _PyObject_CallMethodId_SizeT(PyObject *obj, |
| _Py_Identifier *name, |
| const char *format, |
| ...); |
|
|
| PyAPI_FUNC(PyObject *) _PyObject_CallMethodIdObjArgs( |
| PyObject *obj, |
| struct _Py_Identifier *name, |
| ...); |
|
|
| static inline PyObject * |
| _PyObject_VectorcallMethodId( |
| _Py_Identifier *name, PyObject *const *args, |
| size_t nargsf, PyObject *kwnames) |
| { |
| PyObject *oname = _PyUnicode_FromId(name); |
| if (!oname) { |
| return NULL; |
| } |
| return PyObject_VectorcallMethod(oname, args, nargsf, kwnames); |
| } |
|
|
| static inline PyObject * |
| _PyObject_CallMethodIdNoArgs(PyObject *self, _Py_Identifier *name) |
| { |
| return _PyObject_VectorcallMethodId(name, &self, |
| 1 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); |
| } |
|
|
| static inline PyObject * |
| _PyObject_CallMethodIdOneArg(PyObject *self, _Py_Identifier *name, PyObject *arg) |
| { |
| PyObject *args[2] = {self, arg}; |
|
|
| assert(arg != NULL); |
| return _PyObject_VectorcallMethodId(name, args, |
| 2 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); |
| } |
|
|
| PyAPI_FUNC(int) _PyObject_HasLen(PyObject *o); |
|
|
| |
| |
| |
| PyAPI_FUNC(Py_ssize_t) PyObject_LengthHint(PyObject *o, Py_ssize_t); |
|
|
| |
|
|
| |
| PyAPI_FUNC(int) PyObject_CheckBuffer(PyObject *obj); |
|
|
| |
| |
| |
| |
| |
| PyAPI_FUNC(int) PyObject_GetBuffer(PyObject *obj, Py_buffer *view, |
| int flags); |
|
|
| |
| |
| PyAPI_FUNC(void *) PyBuffer_GetPointer(Py_buffer *view, Py_ssize_t *indices); |
|
|
| |
| |
| PyAPI_FUNC(Py_ssize_t) PyBuffer_SizeFromFormat(const char *format); |
|
|
| |
| PyAPI_FUNC(int) PyBuffer_ToContiguous(void *buf, Py_buffer *view, |
| Py_ssize_t len, char order); |
|
|
| PyAPI_FUNC(int) PyBuffer_FromContiguous(Py_buffer *view, void *buf, |
| Py_ssize_t len, char order); |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| PyAPI_FUNC(int) PyObject_CopyData(PyObject *dest, PyObject *src); |
|
|
| |
| PyAPI_FUNC(int) PyBuffer_IsContiguous(const Py_buffer *view, char fort); |
|
|
| |
| |
| |
| |
| PyAPI_FUNC(void) PyBuffer_FillContiguousStrides(int ndims, |
| Py_ssize_t *shape, |
| Py_ssize_t *strides, |
| int itemsize, |
| char fort); |
|
|
| |
| |
| |
| |
| |
| PyAPI_FUNC(int) PyBuffer_FillInfo(Py_buffer *view, PyObject *o, void *buf, |
| Py_ssize_t len, int readonly, |
| int flags); |
|
|
| |
| PyAPI_FUNC(void) PyBuffer_Release(Py_buffer *view); |
|
|
| |
|
|
| |
| |
| #define PySequence_ITEM(o, i)\ |
| ( Py_TYPE(o)->tp_as_sequence->sq_item(o, i) ) |
|
|
| #define PY_ITERSEARCH_COUNT 1 |
| #define PY_ITERSEARCH_INDEX 2 |
| #define PY_ITERSEARCH_CONTAINS 3 |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| PyAPI_FUNC(Py_ssize_t) _PySequence_IterSearch(PyObject *seq, |
| PyObject *obj, int operation); |
|
|
| |
|
|
| PyAPI_FUNC(int) _PyObject_RealIsInstance(PyObject *inst, PyObject *cls); |
|
|
| PyAPI_FUNC(int) _PyObject_RealIsSubclass(PyObject *derived, PyObject *cls); |
|
|
| PyAPI_FUNC(char *const *) _PySequence_BytesToCharpArray(PyObject* self); |
|
|
| PyAPI_FUNC(void) _Py_FreeCharPArray(char *const array[]); |
|
|
| |
| PyAPI_FUNC(void) _Py_add_one_to_index_F(int nd, Py_ssize_t *index, |
| const Py_ssize_t *shape); |
| PyAPI_FUNC(void) _Py_add_one_to_index_C(int nd, Py_ssize_t *index, |
| const Py_ssize_t *shape); |
|
|
| |
| PyAPI_FUNC(int) _Py_convert_optional_to_ssize_t(PyObject *, void *); |
|
|
| |
| PyAPI_FUNC(PyObject *) _PyNumber_Index(PyObject *o); |
|
|