HPy Call API¶
-
HPy
HPy_Call
(HPyContext *ctx, HPy callable, const HPy *args, size_t nargs, HPy kwnames)¶
[source] Call a Python object.
- Parameters
ctx – The execution context.
callable – A handle to the Python object to call (must not be
HPy_NULL
).args – A pointer to an array of positional and keyword arguments. This argument must not be
NULL
ifnargs > 0
orHPy_Length(ctx, kwnames) > 0
.nargs – The number of positional arguments in
args
.kwnames – A handle to the tuple of keyword argument names (may be
HPy_NULL
). The values of the keyword arguments are also passed inargs
appended to the positional arguments. Argumentnargs
does not include the keyword argument count.
- Returns
The result of the call on success, or
HPy_NULL
in case of an error.
-
HPy
HPy_CallMethod
(HPyContext *ctx, HPy name, const HPy *args, size_t nargs, HPy kwnames)¶
[source] Call a method of a Python object.
- Parameters
ctx – The execution context.
name – A handle to the name (a Unicode object) of the method. Must not be
HPy_NULL
.args – A pointer to an array of the arguments. The receiver is
args[0]
, and the positional and keyword arguments are starting atargs[1]
. This argument must not beNULL
since a receiver is always required.nargs – The number of positional arguments in
args
including the receiver atargs[0]
(therefore,nargs
must be at least1
).kwnames – A handle to the tuple of keyword argument names (may be
HPy_NULL
). The values of the keyword arguments are also passed inargs
appended to the positional arguments. Argumentnargs
does not include the keyword argument count.
- Returns
The result of the call on success, or
HPy_NULL
in case of an error.
-
HPy
HPy_CallTupleDict
(HPyContext *ctx, HPy callable, HPy args, HPy kw)¶
[source] Call a Python object.
- Parameters
ctx – The execution context.
callable – A handle to the Python object to call (must not be
HPy_NULL
).args – A handle to a tuple containing the positional arguments (must not be
HPy_NULL
but can, of course, be empty).kw – A handle to a Python dictionary containing the keyword arguments (may be
HPy_NULL
).
- Returns
The result of the call on success, or
HPy_NULL
in case of an error.