From: Dmitry Selyutin Date: Tue, 19 Apr 2022 22:46:15 +0000 (+0000) Subject: sv_binutils: integrate c_typedef into base metaclass X-Git-Tag: sv_maxu_works-initial~483 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=de3ef10fa54afb6f4006ccfb204db4d9ebcf5145;p=openpower-isa.git sv_binutils: integrate c_typedef into base metaclass --- diff --git a/src/openpower/sv/sv_binutils.py b/src/openpower/sv/sv_binutils.py index 6b0a9776..bae6aa20 100644 --- a/src/openpower/sv/sv_binutils.py +++ b/src/openpower/sv/sv_binutils.py @@ -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 "