Provides a publicly visible, but minimal, re-implementation of py::object
so that a public type can be used with drake::Value<T>
, while still maintaining the revelant semantics with its generic implementation (#13207).
This should only be used in place of py::object
for public APIs that rely on RTTI (e.g. typeid
). See implementation of class object
in pybind11/include/pybind11/pytypes.h.
#include <drake/bindings/pydrake/common/cpp_param_pybind.h>
Public Member Functions | |
Object () | |
~Object () | |
Decrements reference count (if pointing to a real object). More... | |
Object (::PyObject *ptr) | |
Constructs from raw pointer, incrementing the reference count. More... | |
Object (const Object &other) | |
Constructs from another Object, incrementing the reference count. More... | |
Object (Object &&other) | |
Steals object (and reference count) from another Object. More... | |
Object & | operator= (const Object &other) |
Copies object reference and increments reference count. More... | |
Object & | operator= (Object &&other) |
Steals object (and reference count) from another Object. More... | |
::PyObject * | ptr () const |
Accesses raw PyObject pointer (no reference counting). More... | |
template<typename T > | |
T | to_pyobject () const |
Converts to a pybind11 Python type, using py::reinterpret_borrow. More... | |
Object | Clone () const |
Provides a deep copy of the referred-to object. More... | |
Static Public Member Functions | |
template<typename T > | |
static Object | from_pyobject (const T &h) |
Converts from a pybind11 Python type, using py::reinterpret_borrow. More... | |
Object | ( | ) |
~Object | ( | ) |
Decrements reference count (if pointing to a real object).
|
explicit |
Constructs from raw pointer, incrementing the reference count.
py::reinterpret_borrow<>
semantics. Constructs from another Object, incrementing the reference count.
Object Clone | ( | ) | const |
Provides a deep copy of the referred-to object.
|
static |
Converts from a pybind11 Python type, using py::reinterpret_borrow.
::PyObject* ptr | ( | ) | const |
Accesses raw PyObject pointer (no reference counting).
T to_pyobject | ( | ) | const |
Converts to a pybind11 Python type, using py::reinterpret_borrow.