sv_binutils: introduce Enum c_name property
authorDmitry Selyutin <dmitry.selyutin@3mdeb.com>
Wed, 20 Apr 2022 11:45:30 +0000 (11:45 +0000)
committerDmitry Selyutin <dmitry.selyutin@3mdeb.com>
Wed, 20 Apr 2022 12:26:43 +0000 (12:26 +0000)
src/openpower/sv/sv_binutils.py

index 736699634ab1384578be5901a22c5a178b86c2f6..9d9ce41c7e69f5a1a9d788cf7a03641d629c9fdd 100644 (file)
@@ -123,6 +123,10 @@ class EnumMeta(_enum.EnumMeta, CTypeMeta):
 
 
 class Enum(CType, _enum.Enum, metaclass=EnumMeta):
+    @property
+    def c_name(self):
+        return f"{self.__class__.c_tag.upper()}_{self.name.upper()}"
+
     @classmethod
     def c_decl(cls):
         yield f"{cls.c_typedef} {{"
@@ -131,7 +135,7 @@ class Enum(CType, _enum.Enum, metaclass=EnumMeta):
         yield f"}};"
 
     def c_value(self, prefix="", suffix=""):
-        yield f"{prefix}{self.__class__.c_tag.upper()}_{self.name.upper()}{suffix}"
+        yield f"{prefix}{self.c_name}{suffix}"
 
 
 In1Sel = Enum("In1Sel", _In1Sel)