Skip to content

Commit 9995ec2

Browse files
committed
Added namespace for ConcurrentBlockStatement.
1 parent 81d10b4 commit 9995ec2

1 file changed

Lines changed: 25 additions & 2 deletions

File tree

pyVHDLModel/Concurrent.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,9 @@ def __init__(
331331

332332
@export
333333
class ConcurrentBlockStatement(ConcurrentStatement, BlockStatementMixin, LabeledEntityMixin, ConcurrentDeclarationRegionMixin, ConcurrentStatementsMixin, DocumentedEntityMixin, AllowBlackboxMixin):
334-
_portItems: List[PortInterfaceItemMixin]
334+
_portItems: List[PortInterfaceItemMixin]
335+
336+
_namespace: Namespace
335337

336338
def __init__(
337339
self,
@@ -344,6 +346,11 @@ def __init__(
344346
parent: Nullable[ModelEntity] = None
345347
) -> None:
346348
super().__init__(label, parent)
349+
350+
self._namespace = Namespace(self._normalizedLabel)
351+
if parent is not None:
352+
self._namespace.ParentNamespace = parent._namespace
353+
347354
BlockStatementMixin.__init__(self)
348355
LabeledEntityMixin.__init__(self, label)
349356
ConcurrentDeclarationRegionMixin.__init__(self, declaredItems)
@@ -356,7 +363,13 @@ def __init__(
356363
if portItems is not None:
357364
for item in portItems:
358365
self._portItems.append(item)
359-
item._parent = self
366+
item.Parent = self
367+
368+
@ConcurrentStatement.Parent.setter
369+
def Parent(self, parent: ModelEntity) -> None:
370+
ConcurrentStatement.Parent.fset(self, parent)
371+
372+
self._namespace.ParentNamespace = parent._namespace
360373

361374
@property
362375
def PortItems(self) -> List[PortInterfaceItemMixin]:
@@ -397,6 +410,14 @@ def __init__(
397410
self._normalizedAlternativeLabel = alternativeLabel.lower() if alternativeLabel is not None else None
398411

399412
self._namespace = Namespace(self._normalizedAlternativeLabel)
413+
if parent is not None:
414+
self._namespace.ParentNamespace = parent._namespace
415+
416+
@ModelEntity.Parent.setter
417+
def Parent(self, parent: ModelEntity) -> None:
418+
ModelEntity.Parent.fset(self, parent)
419+
420+
self._namespace.ParentNamespace = parent._namespace
400421

401422
@property
402423
def AlternativeLabel(self) -> Nullable[str]:
@@ -528,6 +549,8 @@ def __init__(
528549
super().__init__(label, parent)
529550
AllowBlackboxMixin.__init__(self, allowBlackbox)
530551

552+
# TODO: Why not handover self?
553+
# This allows access to Label and NormalizedLabel, also to create a full instance path in case a lookup goes wrong.
531554
self._namespace = Namespace(self._normalizedLabel)
532555
if parent is not None:
533556
self._namespace.ParentNamespace = parent._namespace

0 commit comments

Comments
 (0)