base-stats,python: Update PyBind11 ScalarInfo fields to readonly
This change keeps the ScalarInfo class consistent with the other Info
classes exposed via PyBind11.
Change-Id: I4d420d509e4654de844e75f58aeaaf67109775d3
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/41693
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
diff --git a/src/python/pybind11/stats.cc b/src/python/pybind11/stats.cc
index e6912e2..1e6773f 100644
--- a/src/python/pybind11/stats.cc
+++ b/src/python/pybind11/stats.cc
@@ -149,9 +149,15 @@
py::class_<Stats::ScalarInfo, Stats::Info,
std::unique_ptr<Stats::ScalarInfo, py::nodelete>>(
m, "ScalarInfo")
- .def("value", &Stats::ScalarInfo::value)
- .def("result", &Stats::ScalarInfo::result)
- .def("total", &Stats::ScalarInfo::total)
+ .def_property_readonly("value", [](const Stats::ScalarInfo &info) {
+ return info.value();
+ })
+ .def_property_readonly("result", [](const Stats::ScalarInfo &info) {
+ return info.result();
+ })
+ .def_property_readonly("total", [](const Stats::ScalarInfo &info) {
+ return info.total();
+ })
;
py::class_<Stats::VectorInfo, Stats::Info,