Wraps a class derived from pybind11::object and ensures that the GIL is acquired when the PyObject is destroyed. For any other operation on this wrapper, the GIL still needs to be acquired manually before!
More...
|
| | PyObject () |
| | Constructs an empty PyObject.
|
| |
| | PyObject (const T &Object) |
| | Copy-constructs a PyObject from Object.
|
| |
| | ~PyObject () |
| | Removes the owned pybind11::object after locking the GIL.
|
| |
| PyObject & | operator= (const T &Object) |
| | Locks the GIL, removes the owned object and copy-assigns from Object.
|
| |
| auto & | Get () const noexcept |
| | Returns the wrapped pybind11::object.
|
| |
| auto & | Get () noexcept |
| | Returns the wrapped pybind11::object. noexcept
|
| |
| void | Reset () |
| | Removes the owned pybind11::object after locking the GIL.
|
| |
| template<typename... ArgTs> |
| py::object | operator() (ArgTs &&...Args) const |
| | Calls the wrapped object if it is not nullptr and if the wrapped object is not pybind11::none.
|
| |
template<typename T, std::enable_if_t< std::is_base_of_v< py::object, T >, int > = 0>
class Util::PyObject< T, >
Wraps a class derived from pybind11::object and ensures that the GIL is acquired when the PyObject is destroyed. For any other operation on this wrapper, the GIL still needs to be acquired manually before!
- Template Parameters
-
| T | Type derived from pybind11::object |
Definition at line 66 of file PyUtil.h.
template<typename T , std::enable_if_t< std::is_base_of_v< py::object, T >, int > = 0>
template<typename... ArgTs>
Calls the wrapped object if it is not nullptr and if the wrapped object is not pybind11::none.
- Template Parameters
-
| ...ArgTs | Types of the perfectly forward arguments |
- Parameters
-
| ...Args | Arguments to perfectly forward to the wrapped object's call. |
- Returns
- Return value of the call of type derived from pybind11::object or pybind11::none if the call did not happen.
Definition at line 128 of file PyUtil.h.
template<typename T , std::enable_if_t< std::is_base_of_v< py::object, T >, int > = 0>
Removes the owned pybind11::object after locking the GIL.
This PyObject instance does not own an object after this operation.
Definition at line 113 of file PyUtil.h.