| 109 | using namespace pybind11_tests::class_sh_trampoline_shared_from_this; |
| 110 | |
| 111 | TEST_SUBMODULE(class_sh_trampoline_shared_from_this, m) { |
| 112 | py::classh<Sft, SftTrampoline>(m, "Sft") |
| 113 | .def(py::init<const std::string &>()) |
| 114 | .def(py::init([](const std::string &history, int) { |
| 115 | return std::make_shared<SftTrampoline>(history); |
| 116 | })) |
| 117 | .def_readonly("history", &Sft::history) |
| 118 | // This leads to multiple entries in registered_instances: |
| 119 | .def(py::init([](const std::shared_ptr<Sft> &existing) { return existing; })); |
| 120 | |
| 121 | py::classh<SftSharedPtrStash>(m, "SftSharedPtrStash") |
| 122 | .def(py::init<int>()) |
| 123 | .def("Clear", &SftSharedPtrStash::Clear) |
| 124 | .def("Add", &SftSharedPtrStash::Add) |
| 125 | .def("AddSharedFromThis", &SftSharedPtrStash::AddSharedFromThis) |
| 126 | .def("history", &SftSharedPtrStash::history) |
| 127 | .def("use_count", &SftSharedPtrStash::use_count); |
| 128 | |
| 129 | m.def("use_count", use_count); |
| 130 | m.def("pass_shared_ptr", pass_shared_ptr); |
| 131 | m.def("pass_unique_ptr_cref", pass_unique_ptr_cref); |
| 132 | m.def("pass_unique_ptr_rref", pass_unique_ptr_rref); |
| 133 | m.def("make_pure_cpp_sft_raw_ptr", make_pure_cpp_sft_raw_ptr); |
| 134 | m.def("make_pure_cpp_sft_unq_ptr", make_pure_cpp_sft_unq_ptr); |
| 135 | m.def("make_pure_cpp_sft_shd_ptr", make_pure_cpp_sft_shd_ptr); |
| 136 | m.def("pass_through_shd_ptr", pass_through_shd_ptr); |
| 137 | } |