2021-01-25 07:06:33 +00:00
|
|
|
// Identical to class_sh_module_local_1.cpp, except 1 replaced with 2.
|
2021-01-24 23:27:32 +00:00
|
|
|
#include <pybind11/pybind11.h>
|
2021-01-25 06:15:58 +00:00
|
|
|
#include <pybind11/smart_holder.h>
|
2021-01-23 04:05:22 +00:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace pybind11_tests {
|
2021-01-25 07:06:33 +00:00
|
|
|
namespace class_sh_module_local {
|
2021-01-23 04:05:22 +00:00
|
|
|
|
2021-01-23 16:49:48 +00:00
|
|
|
struct atyp { // Short for "any type".
|
|
|
|
std::string mtxt;
|
2021-01-23 04:05:22 +00:00
|
|
|
};
|
|
|
|
|
2021-01-23 16:49:48 +00:00
|
|
|
std::string get_mtxt(const atyp &obj) { return obj.mtxt; }
|
2021-01-23 04:05:22 +00:00
|
|
|
|
2021-01-25 07:06:33 +00:00
|
|
|
} // namespace class_sh_module_local
|
2021-01-23 04:05:22 +00:00
|
|
|
} // namespace pybind11_tests
|
|
|
|
|
2021-01-25 07:06:33 +00:00
|
|
|
PYBIND11_SMART_HOLDER_TYPE_CASTERS(pybind11_tests::class_sh_module_local::atyp)
|
2021-01-23 04:05:22 +00:00
|
|
|
|
2021-01-25 07:06:33 +00:00
|
|
|
PYBIND11_MODULE(class_sh_module_local_2, m) {
|
2021-01-23 04:05:22 +00:00
|
|
|
namespace py = pybind11;
|
2021-01-25 07:06:33 +00:00
|
|
|
using namespace pybind11_tests::class_sh_module_local;
|
2021-01-23 04:05:22 +00:00
|
|
|
|
2021-01-24 23:27:32 +00:00
|
|
|
py::class_<atyp, py::smart_holder>(m, "atyp", py::module_local())
|
2021-01-23 16:49:48 +00:00
|
|
|
.def(py::init([](const std::string &mtxt) {
|
|
|
|
atyp obj;
|
|
|
|
obj.mtxt = mtxt;
|
2021-01-23 04:05:22 +00:00
|
|
|
return obj;
|
|
|
|
}))
|
2021-01-23 16:49:48 +00:00
|
|
|
.def("tag", [](const atyp &) { return 2; });
|
2021-01-23 04:05:22 +00:00
|
|
|
|
2021-01-23 16:49:48 +00:00
|
|
|
m.def("get_mtxt", get_mtxt);
|
2021-01-23 04:05:22 +00:00
|
|
|
}
|