sv_binutils: comment about enum aliases
authorDmitry Selyutin <dmitry.selyutin@3mdeb.com>
Mon, 25 Apr 2022 20:15:41 +0000 (20:15 +0000)
committerDmitry Selyutin <dmitry.selyutin@3mdeb.com>
Mon, 25 Apr 2022 20:15:41 +0000 (20:15 +0000)
src/openpower/sv/sv_binutils.py

index 5684145c993eb84f51ffb706c2a2a042e94c78b8..a3c61958ce837f865ef3ca33b87a9454bfca1558 100644 (file)
@@ -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)