HAL  v4.5.0-124-g47ab54673
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
hal::python_bindings_detail Namespace Reference

Functions

template<typename T >
py::handle existing_wrapper (const T *object)
 
py::handle owner_of (py::handle object)
 
void keep_owner_alive (py::detail::function_call &call, py::handle value, py::handle receiver)
 

Function Documentation

◆ existing_wrapper()

template<typename T >
py::handle hal::python_bindings_detail::existing_wrapper ( const T *  object)

Get the Python wrapper of an object, without ever creating one.

Returns
The wrapper if the object has one, an empty handle otherwise.

Definition at line 141 of file python_bindings.h.

References hal::T, and type.

Referenced by owner_of().

◆ keep_owner_alive()

void hal::python_bindings_detail::keep_owner_alive ( py::detail::function_call &  call,
py::handle  value,
py::handle  receiver 
)
inline

Keep the owner of a returned object alive for as long as Python refers to the object.

Applies to each element of a returned container. The container itself cannot be linked to anything, as a Python list is not a pybind11 type and has no slot to hold a reference in. This is also why the work cannot be left to py::keep_alive, which fails on a container.

Definition at line 203 of file python_bindings.h.

References owner_of().

Referenced by pybind11::detail::process_attribute< hal::borrowed >::postcall().

◆ owner_of()

py::handle hal::python_bindings_detail::owner_of ( py::handle  object)
inline

Get the object that has to outlive the given one.

Returns
The owner if it has a wrapper already, an empty handle otherwise.

Definition at line 163 of file python_bindings.h.

References existing_wrapper(), and hal::gate_library_manager::get_gate_library().

Referenced by keep_owner_alive().