From c562ef0920f4b6f0813ad30acb2191f82c80b2af Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Mon, 25 Apr 2022 20:15:41 +0000 Subject: [PATCH] sv_binutils: comment about enum aliases --- src/openpower/sv/sv_binutils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/openpower/sv/sv_binutils.py b/src/openpower/sv/sv_binutils.py index 5684145c..a3c61958 100644 --- a/src/openpower/sv/sv_binutils.py +++ b/src/openpower/sv/sv_binutils.py @@ -119,6 +119,7 @@ class Void(CType, typedef="void"): class EnumMeta(_enum.EnumMeta, CTypeMeta): def __call__(metacls, name, entries, tag=None, **kwargs): if isinstance(entries, type) and issubclass(entries, _enum.Enum): + # Use __members__, not __iter__, otherwise aliases are lost. entries = dict(entries.__members__) if isinstance(entries, dict): entries = tuple(entries.items()) @@ -172,6 +173,7 @@ class Constant(CType, _enum.Enum, metaclass=EnumMeta): @classmethod def c_decl(cls): yield f"/* {cls.c_tag.upper()} constants */" + # Use __members__, not __iter__, otherwise aliases are lost. for (key, item) in cls.__members__.items(): key = f"{cls.c_tag.upper()}_{key.upper()}" value = f"0x{item.value:08x}U" @@ -316,6 +318,7 @@ class FieldsMappingMeta(EnumMeta): def __iter__(cls): prefix = f"svp64_{cls.__enum.__name__}" + # Use __members__, not __iter__, otherwise aliases are lost. for (name, value) in cls.__enum.__members__.items(): yield (f"{prefix}_{name}".upper(), value) -- 2.30.2