Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Include/call.h file #7909

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Include/Python.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
#include "odictobject.h"
#include "enumobject.h"
#include "setobject.h"
#include "call.h"
#include "methodobject.h"
#include "moduleobject.h"
#include "funcobject.h"
Expand Down
230 changes: 0 additions & 230 deletions Include/abstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,236 +135,6 @@ extern "C" {
This function always succeeds. */


#ifdef PY_SSIZE_T_CLEAN
# define PyObject_CallFunction _PyObject_CallFunction_SizeT
# define PyObject_CallMethod _PyObject_CallMethod_SizeT
# ifndef Py_LIMITED_API
# define _PyObject_CallMethodId _PyObject_CallMethodId_SizeT
# endif /* !Py_LIMITED_API */
#endif


/* Call a callable Python object 'callable' with arguments given by the
tuple 'args' and keywords arguments given by the dictionary 'kwargs'.

'args' must not be *NULL*, use an empty tuple if no arguments are
needed. If no named arguments are needed, 'kwargs' can be NULL.

This is the equivalent of the Python expression:
callable(*args, **kwargs). */
PyAPI_FUNC(PyObject *) PyObject_Call(PyObject *callable,
PyObject *args, PyObject *kwargs);

#ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject*) _PyStack_AsTuple(
PyObject *const *stack,
Py_ssize_t nargs);

PyAPI_FUNC(PyObject*) _PyStack_AsTupleSlice(
PyObject *const *stack,
Py_ssize_t nargs,
Py_ssize_t start,
Py_ssize_t end);

/* Convert keyword arguments from the FASTCALL (stack: C array, kwnames: tuple)
format to a Python dictionary ("kwargs" dict).

The type of kwnames keys is not checked. The final function getting
arguments is responsible to check if all keys are strings, for example using
PyArg_ParseTupleAndKeywords() or PyArg_ValidateKeywordArguments().

Duplicate keys are merged using the last value. If duplicate keys must raise
an exception, the caller is responsible to implement an explicit keys on
kwnames. */
PyAPI_FUNC(PyObject *) _PyStack_AsDict(
PyObject *const *values,
PyObject *kwnames);

/* Convert (args, nargs, kwargs: dict) into a (stack, nargs, kwnames: tuple).

Return 0 on success, raise an exception and return -1 on error.

Write the new stack into *p_stack. If *p_stack is differen than args, it
must be released by PyMem_Free().

The stack uses borrowed references.

The type of keyword keys is not checked, these checks should be done
later (ex: _PyArg_ParseStackAndKeywords). */
PyAPI_FUNC(int) _PyStack_UnpackDict(
PyObject *const *args,
Py_ssize_t nargs,
PyObject *kwargs,
PyObject *const **p_stack,
PyObject **p_kwnames);

/* Suggested size (number of positional arguments) for arrays of PyObject*
allocated on a C stack to avoid allocating memory on the heap memory. Such
array is used to pass positional arguments to call functions of the
_PyObject_FastCall() family.

The size is chosen to not abuse the C stack and so limit the risk of stack
overflow. The size is also chosen to allow using the small stack for most
function calls of the Python standard library. On 64-bit CPU, it allocates
40 bytes on the stack. */
#define _PY_FASTCALL_SMALL_STACK 5

/* Return 1 if callable supports FASTCALL calling convention for positional
arguments: see _PyObject_FastCallDict() and _PyObject_FastCallKeywords() */
PyAPI_FUNC(int) _PyObject_HasFastCall(PyObject *callable);

/* Call the callable object 'callable' with the "fast call" calling convention:
args is a C array for positional arguments (nargs is the number of
positional arguments), kwargs is a dictionary for keyword arguments.

If nargs is equal to zero, args can be NULL. kwargs can be NULL.
nargs must be greater or equal to zero.

Return the result on success. Raise an exception on return NULL on
error. */
PyAPI_FUNC(PyObject *) _PyObject_FastCallDict(
PyObject *callable,
PyObject *const *args,
Py_ssize_t nargs,
PyObject *kwargs);

/* Call the callable object 'callable' with the "fast call" calling convention:
args is a C array for positional arguments followed by values of
keyword arguments. Keys of keyword arguments are stored as a tuple
of strings in kwnames. nargs is the number of positional parameters at
the beginning of stack. The size of kwnames gives the number of keyword
values in the stack after positional arguments.

kwnames must only contains str strings, no subclass, and all keys must
be unique.

If nargs is equal to zero and there is no keyword argument (kwnames is
NULL or its size is zero), args can be NULL.

Return the result on success. Raise an exception and return NULL on
error. */
PyAPI_FUNC(PyObject *) _PyObject_FastCallKeywords(
PyObject *callable,
PyObject *const *args,
Py_ssize_t nargs,
PyObject *kwnames);

#define _PyObject_FastCall(func, args, nargs) \
_PyObject_FastCallDict((func), (args), (nargs), NULL)

#define _PyObject_CallNoArg(func) \
_PyObject_FastCallDict((func), NULL, 0, NULL)

PyAPI_FUNC(PyObject *) _PyObject_Call_Prepend(
PyObject *callable,
PyObject *obj,
PyObject *args,
PyObject *kwargs);

PyAPI_FUNC(PyObject *) _PyObject_FastCall_Prepend(
PyObject *callable,
PyObject *obj,
PyObject *const *args,
Py_ssize_t nargs);

PyAPI_FUNC(PyObject *) _Py_CheckFunctionResult(PyObject *callable,
PyObject *result,
const char *where);
#endif /* Py_LIMITED_API */


/* Call a callable Python object 'callable', with arguments given by the
tuple 'args'. If no arguments are needed, then 'args' can be *NULL*.

Returns the result of the call on success, or *NULL* on failure.

This is the equivalent of the Python expression:
callable(*args). */
PyAPI_FUNC(PyObject *) PyObject_CallObject(PyObject *callable,
PyObject *args);

/* Call a callable Python object, callable, with a variable number of C
arguments. The C arguments are described using a mkvalue-style format
string.

The format may be NULL, indicating that no arguments are provided.

Returns the result of the call on success, or NULL on failure.

This is the equivalent of the Python expression:
callable(arg1, arg2, ...). */
PyAPI_FUNC(PyObject *) PyObject_CallFunction(PyObject *callable,
const char *format, ...);

/* Call the method named 'name' of object 'obj' with a variable number of
C arguments. The C arguments are described by a mkvalue format string.

The format can be NULL, indicating that no arguments are provided.

Returns the result of the call on success, or NULL on failure.

This is the equivalent of the Python expression:
obj.name(arg1, arg2, ...). */
PyAPI_FUNC(PyObject *) PyObject_CallMethod(PyObject *obj,
const char *name,
const char *format, ...);

#ifndef Py_LIMITED_API
/* Like PyObject_CallMethod(), but expect a _Py_Identifier*
as the method name. */
PyAPI_FUNC(PyObject *) _PyObject_CallMethodId(PyObject *obj,
_Py_Identifier *name,
const char *format, ...);
#endif /* !Py_LIMITED_API */

PyAPI_FUNC(PyObject *) _PyObject_CallFunction_SizeT(PyObject *callable,
const char *format,
...);

PyAPI_FUNC(PyObject *) _PyObject_CallMethod_SizeT(PyObject *obj,
const char *name,
const char *format,
...);

#ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject *) _PyObject_CallMethodId_SizeT(PyObject *obj,
_Py_Identifier *name,
const char *format,
...);
#endif /* !Py_LIMITED_API */

/* Call a callable Python object 'callable' with a variable number of C
arguments. The C arguments are provided as PyObject* values, terminated
by a NULL.

Returns the result of the call on success, or NULL on failure.

This is the equivalent of the Python expression:
callable(arg1, arg2, ...). */
PyAPI_FUNC(PyObject *) PyObject_CallFunctionObjArgs(PyObject *callable,
...);

/* Call the method named 'name' of object 'obj' with a variable number of
C arguments. The C arguments are provided as PyObject* values, terminated
by NULL.

Returns the result of the call on success, or NULL on failure.

This is the equivalent of the Python expression: obj.name(*args). */

PyAPI_FUNC(PyObject *) PyObject_CallMethodObjArgs(
PyObject *obj,
PyObject *name,
...);

#ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject *) _PyObject_CallMethodIdObjArgs(
PyObject *obj,
struct _Py_Identifier *name,
...);
#endif /* !Py_LIMITED_API */


/* Implemented elsewhere:

Py_hash_t PyObject_Hash(PyObject *o);
Expand Down
Loading