114 Value *operator()(Value &v) {
return &v; };
115 Value *operator()(Value *v) {
return v; };
118 Value *get_ptr() {
return std::visit(PtrGetter(),
m_held); }
121 template <
typename... Args>
123 :
m_held(Value(
boost::python::objects::do_unforward(
124 std::forward<Args>(args), 0)...)) {
125 boost::python::detail::initialize_wrapper(self, get_ptr());
129 void *holds(boost::python::type_info dst_t,
bool) {
130 if (
void *wrapped = holds_wrapped(dst_t, get_ptr(), get_ptr()))
133 boost::python::type_info src_t = boost::python::type_id<Value>();
134 return src_t == dst_t ? get_ptr()
135 :
boost::python::objects::find_static_type(
136 get_ptr(), src_t, dst_t);
140 inline void *holds_wrapped(boost::python::type_info dst_t,
141 boost::python::wrapper<T> *, T *p) {
142 return boost::python::type_id<T>() == dst_t ? p : 0;
145 inline void *holds_wrapped(boost::python::type_info, ...) {
return 0; }
190 bp::wrapper<Base>::operator=(o);
197 void deepcopy_owner() {
199 if (PyObject *owner_ptr = bp::detail::wrapper_base_::get_owner(*
this)) {
200 bp::object copy = bp::import(
"copy");
201 bp::object deepcopy = copy.attr(
"deepcopy");
206 bp::object owner{bp::handle<>(bp::borrowed(owner_ptr))};
212 copied_owner = deepcopy(owner);
213 PyObject *copied_owner_ptr = copied_owner.ptr();
222 bp::objects::instance<> *inst =
223 ((bp::objects::instance<> *)copied_owner_ptr);
227 std::ostringstream error_msg;
228 error_msg <<
"OwningNonOwningHolder should be setup for "
229 << boost::core::demangle(
typeid(
PyBase).name()) <<
" type"
231 throw std::logic_error(error_msg.str());
235 bp::detail::initialize_wrapper(copied_owner_ptr,
this);
240 bp::object copied_owner;
281struct to_python_indirect<
xyz::polymorphic<T, A> &, MakeHolder>
282 : proxsuite::nlp::python::internal::ToPythonIndirectPoly<
283 xyz::polymorphic<T, A> &, MakeHolder> {};
286struct to_python_indirect<const
xyz::polymorphic<T, A> &, MakeHolder>
287 : proxsuite::nlp::python::internal::ToPythonIndirectPoly<
288 const xyz::polymorphic<T, A> &, MakeHolder> {};