HPy Object¶
-
HPy
HPy_Type
(HPyContext *ctx, HPy obj)¶
[source] Returns the type of the given object
obj
.On failure, raises
SystemError
and returnsHPy_NULL
. This is equivalent to the Python expression``type(obj)``.- Parameters
ctx – The execution context.
obj – a Python object (must not be
HPy_NULL
)
- Returns
The type of
obj
orHPy_NULL
in case of errors.
-
int
HPy_TypeCheck
(HPyContext *ctx, HPy obj, HPy type)¶
[source] Checks if
ob
is an instance oftype
or any subtype oftype
.- Parameters
ctx – The execution context.
obj – a Python object (must not be
HPy_NULL
)type – A Python type object. This argument must not be
HPy_NULL
and must be a type (i.e. it must inherit from Pythontype
). If this is not the case, the behavior is undefined (verification of the argument is only done in debug mode).
- Returns
Non-zero if object
obj
is an instance of typetype
or an instance of a subtype oftype
, and0
otherwise.
-
int
HPy_SetCallFunction
(HPyContext *ctx, HPy h, HPyCallFunction *func)¶
[source] Set the call function for the given object.
By defining slot
HPy_tp_call
for some type, instances of this type will be callable objects. The specified call function will be used by default for every instance. This should account for the most common case (every instance of an object uses the same call function) but to still provide the necessary flexibility, functionHPy_SetCallFunction
allows to set different (maybe specialized) call functions for each instance. This must be done in the constructor of an object.A more detailed description on how to use that function can be found in section Calling Protocol.
- Parameters
ctx – The execution context.
h – A handle to an object implementing the call protocol, i.e., the object’s type must have slot
HPy_tp_call
. Otherwise, aTypeError
will be raised. This argument must not beHPy_NULL
.def – A pointer to the call function definition to set (must not be
NULL
). The definition is usually created usingHPyDef_CALL_FUNCTION
- Returns
0
in case of success and-1
in case of an error.