sv_binutils: integrate c_typedef into base metaclass
authorDmitry Selyutin <dmitry.selyutin@3mdeb.com>
Tue, 19 Apr 2022 22:46:15 +0000 (22:46 +0000)
committerDmitry Selyutin <dmitry.selyutin@3mdeb.com>
Tue, 19 Apr 2022 22:46:15 +0000 (22:46 +0000)
src/openpower/sv/sv_binutils.py

index 6b0a9776f682729209e5f458ca02741b9de45680..bae6aa205d91d4c5e33d6d21963e4e4fced7dc11 100644 (file)
@@ -33,6 +33,16 @@ def indent(strings):
 
 
 class CTypeMeta(type):
+    def __new__(metacls, name, bases, attrs, typedef=None):
+        cls = super().__new__(metacls, name, bases, attrs)
+        cls.__typedef = typedef
+
+        return cls
+
+    @property
+    def c_typedef(cls):
+        return cls.__typedef
+
     @_abc.abstractmethod
     def c_decl(cls):
         pass
@@ -145,16 +155,6 @@ class Struct(CType, metaclass=StructMeta):
 
 
 class IntegerMeta(CTypeMeta):
-    def __new__(metacls, name, bases, attrs, typedef=None):
-        cls = super().__new__(metacls, name, bases, attrs)
-        cls.__typedef = typedef
-
-        return cls
-
-    @property
-    def c_typedef(cls):
-        return cls.__typedef
-
     def c_decl(cls):
         yield "#include <stdint.h>"