22 return std::make_shared<MyVirtualData>(*
this);
33 printf(
"Created MyVirtualData with address %p\n", (
void *)
d.get());
40 printf(
"Created MyVirtualData with address %p\n", (
void *)
d.get());
46 throw std::runtime_error(
"Called C++ virtual function.");
52 if (bp::override fo = this->get_override(
"doSomethingPtr")) {
67 if (bp::override fo = this->get_override(
"doSomethingRef")) {
75 if (bp::override fo = this->get_override(
"createData")) {
76 bp::object result = fo().as<bp::object>();
77 return bp::extract<shared_ptr<MyVirtualData> >(result);
112 auto *dter = std::get_deleter<bp::converter::shared_ptr_deleter>(
d);
113 if (dter != 0) printf(
"> input shared_ptr has a deleter\n");
118 shared_ptr<MyVirtualData>
copy_shared(
const shared_ptr<MyVirtualData> &
d) {
119 auto *dter = std::get_deleter<bp::converter::shared_ptr_deleter>(
d);
120 if (dter != 0) printf(
"> input shared_ptr has a deleter\n");
126 "MyVirtualClass should be polymorphic!");
128 "MyVirtualData should be polymorphic!");
130 bp::class_<VirtualClassWrapper, boost::noncopyable>(
131 "MyVirtualClass", bp::init<>(bp::args(
"self")))
133 bp::args(
"self",
"data"))
135 bp::args(
"self",
"data"))
139 bp::register_ptr_to_python<shared_ptr<MyVirtualData> >();
143 bp::class_<DataWrapper, boost::noncopyable>(
"MyVirtualData", bp::no_init)
144 .def(bp::init<MyVirtualClass const &>(bp::args(
"self",
"model")));
149 bp::def(
"iden_ref",
iden_ref, bp::return_internal_reference<>());
150 bp::def(
"iden_shared",
iden_shared, bp::return_internal_reference<>());