parent
dacbd9dfb0
commit
00699f7c41
|
@ -118,7 +118,7 @@ class EnumMeta(ShapeCastable, py_enum.EnumMeta):
|
||||||
# replacement for `enum.Enum`.
|
# replacement for `enum.Enum`.
|
||||||
return Shape._cast_plain_enum(cls)
|
return Shape._cast_plain_enum(cls)
|
||||||
|
|
||||||
def __call__(cls, value):
|
def __call__(cls, value, *args, **kwargs):
|
||||||
# :class:`py_enum.Enum` uses ``__call__()`` for type casting: ``E(x)`` returns
|
# :class:`py_enum.Enum` uses ``__call__()`` for type casting: ``E(x)`` returns
|
||||||
# the enumeration member whose value equals ``x``. In this case, ``x`` must be a concrete
|
# the enumeration member whose value equals ``x``. In this case, ``x`` must be a concrete
|
||||||
# value.
|
# value.
|
||||||
|
@ -130,7 +130,7 @@ class EnumMeta(ShapeCastable, py_enum.EnumMeta):
|
||||||
# comparisons with enum members of the wrong type.
|
# comparisons with enum members of the wrong type.
|
||||||
if isinstance(value, Value):
|
if isinstance(value, Value):
|
||||||
return value
|
return value
|
||||||
return super().__call__(value)
|
return super().__call__(value, *args, **kwargs)
|
||||||
|
|
||||||
def const(cls, init):
|
def const(cls, init):
|
||||||
# Same considerations apply as above.
|
# Same considerations apply as above.
|
||||||
|
|
|
@ -116,3 +116,6 @@ class EnumTestCase(FHDLTestCase):
|
||||||
r"shape used in bit vector context; define the enumeration by inheriting from "
|
r"shape used in bit vector context; define the enumeration by inheriting from "
|
||||||
r"the class in amaranth\.lib\.enum and specifying the 'shape=' keyword argument$"):
|
r"the class in amaranth\.lib\.enum and specifying the 'shape=' keyword argument$"):
|
||||||
Cat(EnumA.A)
|
Cat(EnumA.A)
|
||||||
|
|
||||||
|
def test_functional(self):
|
||||||
|
Enum("FOO", ["BAR", "BAZ"])
|
||||||
|
|
Loading…
Reference in a new issue