Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib.wiring: Add path argument to Component constructor #1517

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions amaranth/lib/wiring.py
Original file line number Diff line number Diff line change
Expand Up @@ -1648,6 +1648,9 @@ def __init__(self, data_width):
constructor creates attributes corresponding to all of the members defined in the signature.
If an attribute with the same name as that of a member already exists, an error is raied.

By default all members defined in the signature are created with a :py:`path` of :py:`()`.
This can be overwritten using the :py:`path` keyword argument of the superclass constructor.

Raises
------
:exc:`TypeError`
Expand All @@ -1658,7 +1661,7 @@ def __init__(self, data_width):
If a name conflict is detected between two variable annotations, or between a member
and an existing attribute.
"""
def __init__(self, signature=None, *, src_loc_at=0):
def __init__(self, signature=None, *, path=(), src_loc_at=0):
cls = type(self)
members = {}
for base in reversed(cls.mro()[:cls.mro().index(Component)]):
Expand Down Expand Up @@ -1692,7 +1695,7 @@ def __init__(self, signature=None, *, src_loc_at=0):
if hasattr(self, name):
raise NameError(f"Cannot initialize attribute for signature member {name!r} "
f"because an attribute with the same name already exists")
self.__dict__.update(signature.members.create(path=(), src_loc_at=src_loc_at + 1))
self.__dict__.update(signature.members.create(path=path, src_loc_at=src_loc_at + 1))

@property
def signature(self):
Expand Down
Loading