From: Martin Quinson Date: Mon, 20 Nov 2023 20:15:44 +0000 (+0100) Subject: Don't use export_values() in pybind11 enums, as it should X-Git-Tag: v3.35~11 X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/5cf887dc8aa736a1cace3f41c49bdd30a5c63333 Don't use export_values() in pybind11 enums, as it should --- diff --git a/ChangeLog b/ChangeLog index 915012c79a..1ef61d16df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -60,6 +60,9 @@ Python: - Comm::waitall/waitany/testany() are gone. Please use ActivitySet() instead. - Comm::waitallfor() is gone too. Its semantic was unclear on timeout anyway. - Io::waitany() and waitanyfor() are gone. Please use ActivitySet() instead. + - Do not export the values of enums. So you need to write e.g. SharingPolicy.LINEAR + while it should have been possible to write LINEAR alone before. This is the advised + behavior for modern C++ code. C API: - Introduce sg_activity_set_t and deprecate wait_all/wait_any/test_any for diff --git a/src/bindings/python/simgrid_python.cpp b/src/bindings/python/simgrid_python.cpp index 7cac37dac4..8dd178a1ab 100644 --- a/src/bindings/python/simgrid_python.cpp +++ b/src/bindings/python/simgrid_python.cpp @@ -452,8 +452,7 @@ PYBIND11_MODULE(simgrid, m) py::enum_(host, "SharingPolicy") .value("NONLINEAR", simgrid::s4u::Host::SharingPolicy::NONLINEAR) - .value("LINEAR", simgrid::s4u::Host::SharingPolicy::LINEAR) - .export_values(); + .value("LINEAR", simgrid::s4u::Host::SharingPolicy::LINEAR); /* Class Disk */ py::class_> disk( @@ -476,13 +475,11 @@ PYBIND11_MODULE(simgrid, m) "Textual representation of the Disk"); py::enum_(disk, "SharingPolicy") .value("NONLINEAR", simgrid::s4u::Disk::SharingPolicy::NONLINEAR) - .value("LINEAR", simgrid::s4u::Disk::SharingPolicy::LINEAR) - .export_values(); + .value("LINEAR", simgrid::s4u::Disk::SharingPolicy::LINEAR); py::enum_(disk, "Operation") .value("READ", simgrid::s4u::Disk::Operation::READ) .value("WRITE", simgrid::s4u::Disk::Operation::WRITE) - .value("READWRITE", simgrid::s4u::Disk::Operation::READWRITE) - .export_values(); + .value("READWRITE", simgrid::s4u::Disk::Operation::READWRITE); /* Class NetPoint */ py::class_> @@ -578,8 +575,7 @@ PYBIND11_MODULE(simgrid, m) .value("WIFI", Link::SharingPolicy::WIFI) .value("SPLITDUPLEX", Link::SharingPolicy::SPLITDUPLEX) .value("SHARED", Link::SharingPolicy::SHARED) - .value("FATPIPE", Link::SharingPolicy::FATPIPE) - .export_values(); + .value("FATPIPE", Link::SharingPolicy::FATPIPE); /* Class LinkInRoute */ py::class_ linkinroute(m, "LinkInRoute", "Abstraction to add link in routes"); @@ -588,8 +584,7 @@ PYBIND11_MODULE(simgrid, m) py::enum_(linkinroute, "Direction") .value("UP", simgrid::s4u::LinkInRoute::Direction::UP) .value("DOWN", simgrid::s4u::LinkInRoute::Direction::DOWN) - .value("NONE", simgrid::s4u::LinkInRoute::Direction::NONE) - .export_values(); + .value("NONE", simgrid::s4u::LinkInRoute::Direction::NONE); /* Class Split-Duplex Link */ py::class_>(