Lines Matching refs:py

58     py::str overloaded()             { return "()"; }
59 py::str overloaded(int) { return "(int)"; }
60 py::str overloaded(int, float) { return "(int, float)"; }
61 py::str overloaded(float, int) { return "(float, int)"; }
62 py::str overloaded(int, int) { return "(int, int)"; }
63 py::str overloaded(float, float) { return "(float, float)"; }
64 py::str overloaded(int) const { return "(int) const"; }
65 py::str overloaded(int, float) const { return "(int, float) const"; }
66 py::str overloaded(float, int) const { return "(float, int) const"; }
67 py::str overloaded(int, int) const { return "(int, int) const"; }
68 py::str overloaded(float, float) const { return "(float, float) const"; }
70 static py::str overloaded(float) { return "static float"; }
108 // py::arg/py::arg_v testing: these arguments just record their argument when invoked
152 return py::none().release();
173 return py::bool_(true).release();
178 // Test None-allowed py::arg argument policy
212 py::class_<ExampleMandA> emna(m, "ExampleMandA");
213 emna.def(py::init<>())
214 .def(py::init<int>())
215 .def(py::init<const ExampleMandA&>())
237 .def("overloaded", py::overload_cast<>(&ExampleMandA::overloaded))
238 .def("overloaded", py::overload_cast<int>(&ExampleMandA::overloaded))
239 .def("overloaded", py::overload_cast<int, float>(&ExampleMandA::overloaded))
240 .def("overloaded", py::overload_cast<float, int>(&ExampleMandA::overloaded))
241 .def("overloaded", py::overload_cast<int, int>(&ExampleMandA::overloaded))
242 .def("overloaded", py::overload_cast<float, float>(&ExampleMandA::overloaded))
243 .def("overloaded_float", py::overload_cast<float, float>(&ExampleMandA::overloaded))
244 .def("overloaded_const", py::overload_cast<int >(&ExampleMandA::overloaded, py::const_))
245 .def("overloaded_const", py::overload_cast<int, float>(&ExampleMandA::overloaded, py::const_))
246 .def("overloaded_const", py::overload_cast<float, int>(&ExampleMandA::overloaded, py::const_))
247 .def("overloaded_const", py::overload_cast<int, int>(&ExampleMandA::overloaded, py::const_))
248 .def("overloaded_const", py::overload_cast<float, float>(&ExampleMandA::overloaded, py::const_))
254 .def("overloaded", static_cast<py::str (ExampleMandA::*)(float, int)>(&ExampleMandA::overloaded))
255 .def("overloaded", static_cast<py::str (ExampleMandA::*)(int, int)>(&ExampleMandA::overloaded))
256 .def("overloaded", static_cast<py::str (ExampleMandA::*)(float, float)>(&ExampleMandA::overloaded))
258 .def("overloaded_const", overload_cast_<int >()(&ExampleMandA::overloaded, py::const_))
259 .def("overloaded_const", overload_cast_<int, float>()(&ExampleMandA::overloaded, py::const_))
260 .def("overloaded_const", static_cast<py::str (ExampleMandA::*)(float, int) const>(&ExampleMandA::overloaded))
261 .def("overloaded_const", static_cast<py::str (ExampleMandA::*)(int, int) const>(&ExampleMandA::overloaded))
262 .def("overloaded_const", static_cast<py::str (ExampleMandA::*)(float, float) const>(&ExampleMandA::overloaded))
267 auto emna = py::reinterpret_borrow<py::class_<ExampleMandA>>(py::module::import("pybind11_tests.methods_and_attributes").attr("ExampleMandA"));
268 emna.def ("overload_mixed1", static_cast<py::str (ExampleMandA::*)(int, int)>(&ExampleMandA::overloaded))
269 .def_static("overload_mixed1", static_cast<py::str ( *)(float )>(&ExampleMandA::overloaded));
272 auto emna = py::reinterpret_borrow<py::class_<ExampleMandA>>(py::module::import("pybind11_tests.methods_and_attributes").attr("ExampleMandA"));
273 emna.def_static("overload_mixed2", static_cast<py::str ( *)(float )>(&ExampleMandA::overloaded))
274 .def ("overload_mixed2", static_cast<py::str (ExampleMandA::*)(int, int)>(&ExampleMandA::overloaded));
284 py::class_<TestProperties>(m, "TestProperties")
285 .def(py::init<>())
297 [](py::object, int v) { TestProperties::static_value = v; })
299 [](py::object) { return TestProperties::static_get(); })
301 [](py::object, int v) { return TestProperties::static_set(v); })
303 [](py::object) { return TestProperties::static_get(); },
304 [](py::object, int v) { TestProperties::static_set(v); })
306 [](py::object cls) { return cls; },
307 [](py::object cls, py::function f) { f(cls); });
309 py::class_<TestPropertiesOverride, TestProperties>(m, "TestPropertiesOverride")
310 .def(py::init<>())
314 auto static_get1 = [](py::object) -> const UserType & { return TestPropRVP::sv1; };
315 auto static_get2 = [](py::object) -> const UserType & { return TestPropRVP::sv2; };
316 auto static_set1 = [](py::object, int v) { TestPropRVP::sv1.set(v); };
317 auto static_set2 = [](py::object, int v) { TestPropRVP::sv2.set(v); };
318 auto rvp_copy = py::return_value_policy::copy;
321 py::class_<TestPropRVP>(m, "TestPropRVP")
322 .def(py::init<>())
325 .def_property_readonly("ro_func", py::cpp_function(&TestPropRVP::get2, rvp_copy))
328 .def_property("rw_func", py::cpp_function(&TestPropRVP::get2, rvp_copy), &TestPropRVP::set2)
331 .def_property_readonly_static("static_ro_func", py::cpp_function(static_get2, rvp_copy))
334 .def_property_static("static_rw_func", py::cpp_function(static_get2, rvp_copy), static_set2)
337 .def_property_readonly_static("static_rvalue", [](py::object) { return UserType(1); });
341 py::class_<MetaclassOverride>(m, "MetaclassOverride", py::metaclass((PyObject *) &PyType_Type))
342 .def_property_readonly_static("readonly", [](py::object) { return 1; });
351 py::class_<DynamicClass>(m, "DynamicClass", py::dynamic_attr())
352 .def(py::init());
355 py::class_<CppDerivedDynamicClass, DynamicClass>(m, "CppDerivedDynamicClass")
356 .def(py::init());
372 py::class_<ArgInspector>(m, "ArgInspector")
373 .def(py::init<>())
374 .def("f", &ArgInspector::f, py::arg(), py::arg() = ArgAlwaysConverts())
375 .def("g", &ArgInspector::g, "a"_a.noconvert(), "b"_a, "c"_a.noconvert()=13, "d"_a=ArgInspector2(), py::arg() = ArgAlwaysConverts())
376 .def_static("h", &ArgInspector::h, py::arg().noconvert(), py::arg() = ArgAlwaysConverts())
379 py::arg().noconvert(false), py::arg_v(nullptr, ArgInspector1()).noconvert(true), py::arg() = ArgAlwaysConverts());
381 m.def("floats_preferred", [](double f) { return 0.5 * f; }, py::arg("f"));
382 m.def("floats_only", [](double f) { return 0.5 * f; }, py::arg("f").noconvert());
383 m.def("ints_preferred", [](int i) { return i / 2; }, py::arg("i"));
384 m.def("ints_only", [](int i) { return i / 2; }, py::arg("i").noconvert());
394 auto m = py::module::import("pybind11_tests");
395 m.def("should_fail", [](int, UnregisteredType) {}, py::arg(), py::arg("a") = UnregisteredType());
398 auto m = py::module::import("pybind11_tests");
399 m.def("should_fail", [](int, UnregisteredType) {}, py::arg(), py::arg() = UnregisteredType());
403 py::class_<NoneTester, std::shared_ptr<NoneTester>>(m, "NoneTester")
404 .def(py::init<>());
405 m.def("no_none1", &none1, py::arg().none(false));
406 m.def("no_none2", &none2, py::arg().none(false));
407 m.def("no_none3", &none3, py::arg().none(false));
408 m.def("no_none4", &none4, py::arg().none(false));
409 m.def("no_none5", &none5, py::arg().none(false));
411 m.def("ok_none2", &none2, py::arg().none(true));
413 m.def("ok_none4", &none4, py::arg().none(true));
418 py::class_<StrIssue>(m, "StrIssue")
419 .def(py::init<int>())
420 .def(py::init<>())
431 py::class_<RegisteredDerived>(m, "RegisteredDerived")
432 .def(py::init<>())
446 using Adapted = decltype(py::method_adaptor<RegisteredDerived>(&RegisteredDerived::do_nothing));
456 py::return_value_policy::take_ownership); // Takes ownership: destroy when finished
458 py::return_value_policy::take_ownership); // Likewise (const doesn't inhibit destruction)
459 m.def("destruction_tester_cstats", &ConstructorStats::get<DestructionTester>, py::return_value_policy::reference);