From f69811ad202abbd4cb1e18e35b36fd0c74e09d16 Mon Sep 17 00:00:00 2001 From: "Bobby R. Bruce" Date: Thu, 18 Feb 2021 13:31:22 -0800 Subject: [PATCH] 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 Maintainer: Jason Lowe-Power Tested-by: kokoro --- src/python/pybind11/stats.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/python/pybind11/stats.cc b/src/python/pybind11/stats.cc index e6912e2ff6..1e6773f04a 100644 --- a/src/python/pybind11/stats.cc +++ b/src/python/pybind11/stats.cc @@ -149,9 +149,15 @@ pybind_init_stats(py::module_ &m_native) py::class_>( 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_