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

Function TEST_SUBMODULE

tests/test_class_sh_disowning_mi.cpp:49–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47} // namespace pybind11_tests
48
49TEST_SUBMODULE(class_sh_disowning_mi, m) {
50 using namespace pybind11_tests::class_sh_disowning_mi;
51
52 py::classh<B>(m, "B")
53 .def(py::init<>())
54 .def_readonly("val_b", &D::val_b)
55 .def("b", [](B *self) { return self; })
56 .def("get", [](const B &self) { return self.val_b; });
57
58 py::classh<C0, B>(m, "C0")
59 .def(py::init<>())
60 .def_readonly("val_c0", &D::val_c0)
61 .def("c0", [](C0 *self) { return self; })
62 .def("get", [](const C0 &self) { return self.val_b * 100 + self.val_c0; });
63
64 py::classh<C1, B>(m, "C1")
65 .def(py::init<>())
66 .def_readonly("val_c1", &D::val_c1)
67 .def("c1", [](C1 *self) { return self; })
68 .def("get", [](const C1 &self) { return self.val_b * 100 + self.val_c1; });
69
70 py::classh<D, C0, C1>(m, "D")
71 .def(py::init<>())
72 .def_readonly("val_d", &D::val_d)
73 .def("d", [](D *self) { return self; })
74 .def("get", [](const D &self) {
75 return self.val_b * 1000000 + self.val_c0 * 10000 + self.val_c1 * 100 + self.val_d;
76 });
77
78 m.def("disown_b", disown_b);
79
80 // test_multiple_inheritance_python
81 py::classh<Base1>(m, "Base1").def(py::init<int>()).def("foo", &Base1::foo);
82 py::classh<Base2>(m, "Base2").def(py::init<int>()).def("bar", &Base2::bar);
83 m.def("disown_base1", disown_base1);
84 m.def("disown_base2", disown_base2);
85}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected