Skip to content

Commit 3ca85e8

Browse files
committed
Simplify wrapper
1 parent e62d687 commit 3ca85e8

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

riscvmodel/isa.py

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -662,26 +662,17 @@ def isa(mnemonic: str,
662662
:return: Wrapper class that overwrites the actual definition and contains static data
663663
"""
664664
def wrapper(wrapped):
665-
"""Get wrapper"""
666-
class WrappedClass(wrapped): # pylint: disable=too-few-public-methods
667-
"""Generic wrapper class"""
668-
669-
wrapped.field_opcode = wrapped.field_opcode._replace(value=opcode)
670-
671-
wrapped.mnemonic = mnemonic
672-
wrapped.variant = variant
665+
wrapped.field_opcode = wrapped.field_opcode._replace(value=opcode)
673666

674-
for field in kwargs:
675-
fid = "field_"+field
676-
assert fid in dir(wrapped), "Invalid field {} for {}".format(fid, wrapped.__name__)
677-
setattr(wrapped, fid, getattr(wrapped, fid)._replace(value=kwargs[field]))
667+
wrapped.mnemonic = mnemonic
668+
wrapped.variant = variant
678669

679-
WrappedClass.__name__ = wrapped.__name__
680-
WrappedClass.__module__ = wrapped.__module__
681-
WrappedClass.__qualname__ = wrapped.__qualname__
682-
WrappedClass.__doc__ = wrapped.__doc__
683-
return WrappedClass
670+
for field in kwargs:
671+
fid = "field_"+field
672+
assert fid in dir(wrapped), "Invalid field {} for {}".format(fid, wrapped.__name__)
673+
setattr(wrapped, fid, getattr(wrapped, fid)._replace(value=kwargs[field]))
684674

675+
return wrapped
685676
return wrapper
686677

687678

0 commit comments

Comments
 (0)