python: Expand Enum param type to be more Enum-like
This extends gem5's version of python enums to support an equal operator and the hash operator so we can compare two instances of enums and add these to sets/dicts/etc. Change-Id: I4a785bf9570a54254ada1db684379ee77e67b192 Signed-off-by: Jason Lowe-Power <jason@lowepower.com>
This commit is contained in:
committed by
Bobby R. Bruce
parent
0d16c92341
commit
c0f67f7388
@@ -1636,6 +1636,13 @@ class Enum(ParamValue, metaclass=MetaEnum):
|
||||
def __str__(self):
|
||||
return self.value
|
||||
|
||||
def __eq__(self, __o: object) -> bool:
|
||||
"""Checks if two enum values are the same."""
|
||||
return type(self) == type(__o) and self.value == __o.value
|
||||
|
||||
def __hash__(self):
|
||||
return hash(self.value)
|
||||
|
||||
|
||||
# This param will generate a scoped c++ enum and its python bindings.
|
||||
class ScopedEnum(Enum):
|
||||
|
||||
Reference in New Issue
Block a user