HPy Object¶
-
HPy
HPy_Type(HPyContext *ctx, HPy obj)¶
[source] Returns the type of the given object
obj.On failure, raises
SystemErrorand 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
objorHPy_NULLin case of errors.
-
int
HPy_TypeCheck(HPyContext *ctx, HPy obj, HPy type)¶
[source] Checks if
obis an instance oftypeor 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_NULLand 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
objis an instance of typetypeor an instance of a subtype oftype, and0otherwise.
-
int
HPy_SetCallFunction(HPyContext *ctx, HPy h, HPyCallFunction *func)¶
[source] Set the call function for the given object.
By defining slot
HPy_tp_callfor 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_SetCallFunctionallows 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, aTypeErrorwill 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
0in case of success and-1in case of an error.