pybind11: move to PYBIND11_MODULE to get rid of deprecation warnings

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2020-08-28 01:00:00 +00:00
parent 1c3403d9c3
commit ad53aa82f9

View File

@@ -18,8 +18,8 @@ struct ClassTestDerived : ClassTest {
namespace py = pybind11; namespace py = pybind11;
PYBIND11_PLUGIN(class_test) { PYBIND11_MODULE(class_test, m) {
py::module m("my_module", "pybind11 example plugin"); m.doc() = "pybind11 example plugin";
py::class_<ClassTest>(m, "ClassTest") py::class_<ClassTest>(m, "ClassTest")
.def(py::init<const std::string &>()) .def(py::init<const std::string &>())
.def("setName", &ClassTest::setName) .def("setName", &ClassTest::setName)
@@ -29,5 +29,4 @@ PYBIND11_PLUGIN(class_test) {
.def(py::init<const std::string &, const std::string &>()) .def(py::init<const std::string &, const std::string &>())
.def("getName2", &ClassTestDerived::getName2) .def("getName2", &ClassTestDerived::getName2)
.def_readwrite("name", &ClassTestDerived::name); .def_readwrite("name", &ClassTestDerived::name);
return m.ptr();
} }