Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-11-19 09:50:40

0001 #ifndef Py_CPYTHON_ABSTRACTOBJECT_H
0002 #  error "this header file must not be included directly"
0003 #endif
0004 
0005 /* === Object Protocol ================================================== */
0006 
0007 /* Like PyObject_CallMethod(), but expect a _Py_Identifier*
0008    as the method name. */
0009 PyAPI_FUNC(PyObject*) _PyObject_CallMethodId(
0010     PyObject *obj,
0011     _Py_Identifier *name,
0012     const char *format, ...);
0013 
0014 /* Convert keyword arguments from the FASTCALL (stack: C array, kwnames: tuple)
0015    format to a Python dictionary ("kwargs" dict).
0016 
0017    The type of kwnames keys is not checked. The final function getting
0018    arguments is responsible to check if all keys are strings, for example using
0019    PyArg_ParseTupleAndKeywords() or PyArg_ValidateKeywordArguments().
0020 
0021    Duplicate keys are merged using the last value. If duplicate keys must raise
0022    an exception, the caller is responsible to implement an explicit keys on
0023    kwnames. */
0024 PyAPI_FUNC(PyObject*) _PyStack_AsDict(PyObject *const *values, PyObject *kwnames);
0025 
0026 
0027 /* === Vectorcall protocol (PEP 590) ============================= */
0028 
0029 // PyVectorcall_NARGS() is exported as a function for the stable ABI.
0030 // Here (when we are not using the stable ABI), the name is overridden to
0031 // call a static inline function for best performance.
0032 static inline Py_ssize_t
0033 _PyVectorcall_NARGS(size_t n)
0034 {
0035     return n & ~PY_VECTORCALL_ARGUMENTS_OFFSET;
0036 }
0037 #define PyVectorcall_NARGS(n) _PyVectorcall_NARGS(n)
0038 
0039 PyAPI_FUNC(vectorcallfunc) PyVectorcall_Function(PyObject *callable);
0040 
0041 // Backwards compatibility aliases (PEP 590) for API that was provisional
0042 // in Python 3.8
0043 #define _PyObject_Vectorcall PyObject_Vectorcall
0044 #define _PyObject_VectorcallMethod PyObject_VectorcallMethod
0045 #define _PyObject_FastCallDict PyObject_VectorcallDict
0046 #define _PyVectorcall_Function PyVectorcall_Function
0047 #define _PyObject_CallOneArg PyObject_CallOneArg
0048 #define _PyObject_CallMethodNoArgs PyObject_CallMethodNoArgs
0049 #define _PyObject_CallMethodOneArg PyObject_CallMethodOneArg
0050 
0051 /* Same as PyObject_Vectorcall except that keyword arguments are passed as
0052    dict, which may be NULL if there are no keyword arguments. */
0053 PyAPI_FUNC(PyObject *) PyObject_VectorcallDict(
0054     PyObject *callable,
0055     PyObject *const *args,
0056     size_t nargsf,
0057     PyObject *kwargs);
0058 
0059 PyAPI_FUNC(PyObject *) PyObject_CallOneArg(PyObject *func, PyObject *arg);
0060 
0061 static inline PyObject *
0062 PyObject_CallMethodNoArgs(PyObject *self, PyObject *name)
0063 {
0064     size_t nargsf = 1 | PY_VECTORCALL_ARGUMENTS_OFFSET;
0065     return PyObject_VectorcallMethod(name, &self, nargsf, _Py_NULL);
0066 }
0067 
0068 static inline PyObject *
0069 PyObject_CallMethodOneArg(PyObject *self, PyObject *name, PyObject *arg)
0070 {
0071     PyObject *args[2] = {self, arg};
0072     size_t nargsf = 2 | PY_VECTORCALL_ARGUMENTS_OFFSET;
0073     assert(arg != NULL);
0074     return PyObject_VectorcallMethod(name, args, nargsf, _Py_NULL);
0075 }
0076 
0077 /* Guess the size of object 'o' using len(o) or o.__length_hint__().
0078    If neither of those return a non-negative value, then return the default
0079    value.  If one of the calls fails, this function returns -1. */
0080 PyAPI_FUNC(Py_ssize_t) PyObject_LengthHint(PyObject *o, Py_ssize_t);
0081 
0082 /* === Sequence protocol ================================================ */
0083 
0084 /* Assume tp_as_sequence and sq_item exist and that 'i' does not
0085    need to be corrected for a negative index. */
0086 #define PySequence_ITEM(o, i)\
0087     ( Py_TYPE(o)->tp_as_sequence->sq_item((o), (i)) )