31 static std::list<std::function<void(py::module_ &)>> inits;
39 auto m = parent.def_submodule(submodule_name);
45 py::class_<ConstructorStats>(m,
"ConstructorStats")
55 py::return_value_policy::reference_internal)
59 .def_static(
"detail_reg_inst", []() {
61 return py::detail::get_internals().registered_instances.size();
67#if defined(PYBIND11_CPP20)
69#elif defined(PYBIND11_CPP17)
71#elif defined(PYBIND11_CPP14)
79 m.doc() =
"pybind11 test module";
83#if defined(_MSC_FULL_VER)
85#elif defined(__VERSION__)
86 m.attr(
"compiler_info") = __VERSION__;
88 m.attr(
"compiler_info") = py::none();
92 m.attr(
"PYBIND11_SIMPLE_GIL_MANAGEMENT") =
93#if defined(PYBIND11_SIMPLE_GIL_MANAGEMENT)
101#if defined(PYBIND11_DETAILED_ERROR_MESSAGES)
102 m.attr(
"detailed_error_messages_enabled") =
true;
104 m.attr(
"detailed_error_messages_enabled") =
false;
107 py::class_<UserType>(m,
"UserType",
"A `py::class_` type for testing")
109 .def(py::init<int>())
111 .def(
"set_value", &
UserType::set,
"Set value using a method")
113 .def(
"__repr__", [](
const UserType &u) {
return "UserType({})"_s.format(u.
value()); });
115 py::class_<IncType, UserType>(m,
"IncType")
117 .def(py::init<int>())
118 .def(
"__repr__", [](
const IncType &u) {
return "IncType({})"_s.format(u.
value()); });
int default_constructions
static ConstructorStats & get()
Like UserType, but increments value on copy for quick reference vs. copy tests.
A user-defined type which is exported and can be used by any test.
test_initializer(Initializer init)
#define PYBIND11_TOSTRING(x)
#define PYBIND11_MODULE(name, variable)
\rst This macro creates the entry point that will be invoked when the Python interpreter imports an e...
#define PYBIND11_INTERNALS_ID
detail::initimpl::constructor< Args... > init()
Binds an existing constructor taking arguments Args...
std::list< std::function< void(py::module_ &)> > & initializers()
void bind_ConstructorStats(py::module_ &m)
std::list< std::function< void(py::module_ &)> > & initializers()