python: Remove unnecessary exports from pybind enums
authorNikos Nikoleris <nikos.nikoleris@arm.com>
Mon, 24 Feb 2020 17:00:09 +0000 (19:00 +0200)
committerNikos Nikoleris <nikos.nikoleris@arm.com>
Mon, 2 Mar 2020 08:01:07 +0000 (08:01 +0000)
According to pybind documentation [1], enum entries use
.export_values() to export the enum entries into the parent
scope. However, strongly typed C++11 class enums are in their own
scope and therefore do not need to be exported.

[1]: https://pybind11.readthedocs.io/en/stable/classes.html#enume
rations-and-internal-types

Change-Id: I6181306b530d59eaedcb3daf9cab0a03d01d56f4
Signed-off-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/25709
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Gabe Black <gabeblack@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/python/m5/params.py

index 6033096faaa4c045036edb6eeb73c8d896e498c7..3593f95bbc3f9e7453840398121ca25c3f5b62b2 100644 (file)
@@ -1433,7 +1433,8 @@ module_init(py::module &m_internal)
         for val in cls.vals:
             code('.value("${val}", ${wrapper_name}::${val})')
         code('.value("Num_${name}", ${wrapper_name}::Num_${enum_name})')
-        code('.export_values()')
+        if not cls.is_class:
+            code('.export_values()')
         code(';')
         code.dedent()