MCPcopy Create free account
hub / github.com/apple/coremltools / PYBIND11_MODULE

Function PYBIND11_MODULE

deps/pybind11/tests/pybind11_tests.cpp:78–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76}
77
78PYBIND11_MODULE(pybind11_tests, m, py::mod_gil_not_used()) {
79 m.doc() = "pybind11 test module";
80
81 // Intentionally kept minimal to not create a maintenance chore
82 // ("just enough" to be conclusive).
83#if defined(__VERSION__)
84 m.attr("compiler_info") = __VERSION__;
85#elif defined(_MSC_FULL_VER)
86 m.attr("compiler_info") = "MSVC " PYBIND11_TOSTRING(_MSC_FULL_VER);
87#else
88 m.attr("compiler_info") = py::none();
89#endif
90 m.attr("cpp_std") = cpp_std();
91 m.attr("PYBIND11_INTERNALS_ID") = PYBIND11_INTERNALS_ID;
92 // Free threaded Python uses UINT32_MAX for immortal objects.
93 m.attr("PYBIND11_REFCNT_IMMORTAL") = UINT32_MAX;
94 m.attr("PYBIND11_SIMPLE_GIL_MANAGEMENT") =
95#if defined(PYBIND11_SIMPLE_GIL_MANAGEMENT)
96 true;
97#else
98 false;
99#endif
100 m.attr("PYBIND11_NUMPY_1_ONLY") =
101#if defined(PYBIND11_NUMPY_1_ONLY)
102 true;
103#else
104 false;
105#endif
106
107 bind_ConstructorStats(m);
108
109#if defined(PYBIND11_DETAILED_ERROR_MESSAGES)
110 m.attr("detailed_error_messages_enabled") = true;
111#else
112 m.attr("detailed_error_messages_enabled") = false;
113#endif
114
115 py::class_<UserType>(m, "UserType", "A `py::class_` type for testing")
116 .def(py::init<>())
117 .def(py::init<int>())
118 .def("get_value", &UserType::value, "Get value using a method")
119 .def("set_value", &UserType::set, "Set value using a method")
120 .def_property("value", &UserType::value, &UserType::set, "Get/set value using a property")
121 .def("__repr__", [](const UserType &u) { return "UserType({})"_s.format(u.value()); });
122
123 py::class_<IncType, UserType>(m, "IncType")
124 .def(py::init<>())
125 .def(py::init<int>())
126 .def("__repr__", [](const IncType &u) { return "IncType({})"_s.format(u.value()); });
127
128 for (const auto &initializer : initializers()) {
129 initializer(m);
130 }
131}

Callers

nothing calls this directly

Calls 7

noneClass · 0.85
cpp_stdFunction · 0.85
bind_ConstructorStatsFunction · 0.85
attrMethod · 0.80
docMethod · 0.45
formatMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected