MCPcopy Create free account
hub / github.com/pybind/pybind11 / TEST_SUBMODULE

Function TEST_SUBMODULE

tests/test_class_sh_trampoline_shared_from_this.cpp:111–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109using namespace pybind11_tests::class_sh_trampoline_shared_from_this;
110
111TEST_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}

Callers

nothing calls this directly

Calls 1

initFunction · 0.85

Tested by

no test coverage detected