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

Function TEST_SUBMODULE

tests/test_methods_and_attributes.cpp:335–788  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

333} // namespace pybind11_tests
334
335TEST_SUBMODULE(methods_and_attributes, m) {
336 // test_methods_and_attributes
337 py::class_<ExampleMandA> emna(m, "ExampleMandA");
338 emna.def(py::init<>())
339 .def(py::init<int>())
340 .def(py::init<std::string &&>())
341 .def(py::init<const ExampleMandA &>())
342 .def("add1", &ExampleMandA::add1)
343 .def("add2", &ExampleMandA::add2)
344 .def("add3", &ExampleMandA::add3)
345 .def("add4", &ExampleMandA::add4)
346 .def("add5", &ExampleMandA::add5)
347 .def("add6", &ExampleMandA::add6)
348 .def("add7", &ExampleMandA::add7)
349 .def("add8", &ExampleMandA::add8)
350 .def("add9", &ExampleMandA::add9)
351 .def("add10", &ExampleMandA::add10)
352 .def("consume_str", &ExampleMandA::consume_str)
353 .def("self1", &ExampleMandA::self1)
354 .def("self2", &ExampleMandA::self2)
355 .def("self3", &ExampleMandA::self3)
356 .def("self4", &ExampleMandA::self4)
357 .def("self5", &ExampleMandA::self5)
358 .def("internal1", &ExampleMandA::internal1)
359 .def("internal2", &ExampleMandA::internal2)
360 .def("internal3", &ExampleMandA::internal3)
361 .def("internal4", &ExampleMandA::internal4)
362 .def("internal5", &ExampleMandA::internal5)
363#if defined(PYBIND11_OVERLOAD_CAST)
364 .def("overloaded", py::overload_cast<>(&ExampleMandA::overloaded))
365 .def("overloaded", py::overload_cast<int>(&ExampleMandA::overloaded))
366 .def("overloaded", py::overload_cast<int, float>(&ExampleMandA::overloaded))
367 .def("overloaded", py::overload_cast<float, int>(&ExampleMandA::overloaded))
368 .def("overloaded", py::overload_cast<int, int>(&ExampleMandA::overloaded))
369 .def("overloaded", py::overload_cast<float, float>(&ExampleMandA::overloaded))
370 .def("overloaded_float", py::overload_cast<float, float>(&ExampleMandA::overloaded))
371 .def("overloaded_const", py::overload_cast<int>(&ExampleMandA::overloaded, py::const_))
372 .def("overloaded_const",
373 py::overload_cast<int, float>(&ExampleMandA::overloaded, py::const_))
374 .def("overloaded_const",
375 py::overload_cast<float, int>(&ExampleMandA::overloaded, py::const_))
376 .def("overloaded_const",
377 py::overload_cast<int, int>(&ExampleMandA::overloaded, py::const_))
378 .def("overloaded_const",
379 py::overload_cast<float, float>(&ExampleMandA::overloaded, py::const_))
380#else
381 // Use both the traditional static_cast method and the C++11 compatible overload_cast_
382 .def("overloaded", overload_cast_<>()(&ExampleMandA::overloaded))
383 .def("overloaded", overload_cast_<int>()(&ExampleMandA::overloaded))
384 .def("overloaded", overload_cast_<int, float>()(&ExampleMandA::overloaded))
385 .def("overloaded", static_cast<py::str (ExampleMandA::*)(float, int)>(&ExampleMandA::overloaded))
386 .def("overloaded", static_cast<py::str (ExampleMandA::*)(int, int)>(&ExampleMandA::overloaded))
387 .def("overloaded", static_cast<py::str (ExampleMandA::*)(float, float)>(&ExampleMandA::overloaded))
388 .def("overloaded_float", overload_cast_<float, float>()(&ExampleMandA::overloaded))
389 .def("overloaded_const", overload_cast_<int >()(&ExampleMandA::overloaded, py::const_))
390 .def("overloaded_const", overload_cast_<int, float>()(&ExampleMandA::overloaded, py::const_))
391 .def("overloaded_const", static_cast<py::str (ExampleMandA::*)(float, int) const>(&ExampleMandA::overloaded))
392 .def("overloaded_const", static_cast<py::str (ExampleMandA::*)(int, int) const>(&ExampleMandA::overloaded))

Callers

nothing calls this directly

Calls 15

strClass · 0.85
importFunction · 0.85
pos_onlyClass · 0.85
fFunction · 0.85
cpp_functionClass · 0.85
UserTypeClass · 0.85
metaclassFunction · 0.85
dynamic_attrClass · 0.85
initFunction · 0.85
UnregisteredTypeClass · 0.85
kw_onlyClass · 0.85
add_bindingsFunction · 0.85

Tested by

no test coverage detected