diff options
author | Jeff Long <willcode4@gmail.com> | 2021-04-09 19:52:51 -0400 |
---|---|---|
committer | mormj <34754695+mormj@users.noreply.github.com> | 2021-04-10 09:49:44 -0400 |
commit | 222462c77a695c1ba28ee8fc535a43979c0cff2d (patch) | |
tree | 806f64166676cc6e603f65c88aa18fdc4538923b /grc | |
parent | d44ee73deeaab86a7cc5820ef62688f291331b88 (diff) |
grc: match data type aliases as well as types
Signed-off-by: Jeff Long <willcode4@gmail.com>
Diffstat (limited to 'grc')
-rw-r--r-- | grc/core/Connection.py | 3 | ||||
-rw-r--r-- | grc/core/Constants.py | 16 |
2 files changed, 18 insertions, 1 deletions
diff --git a/grc/core/Connection.py b/grc/core/Connection.py index 6fd78a41f1..718dd69e71 100644 --- a/grc/core/Connection.py +++ b/grc/core/Connection.py @@ -8,6 +8,7 @@ SPDX-License-Identifier: GPL-2.0-or-later from .base import Element +from .Constants import ALIAS_OF from .utils.descriptors import lazy_property @@ -92,7 +93,7 @@ class Connection(Element): source_dtype = self.source_port.dtype sink_dtype = self.sink_port.dtype - if source_dtype != sink_dtype: + if source_dtype != sink_dtype and source_dtype != ALIAS_OF.get(sink_dtype): self.add_error_message('Source IO type "{}" does not match sink IO type "{}".'.format(source_dtype, sink_dtype)) source_size = self.source_port.item_size diff --git a/grc/core/Constants.py b/grc/core/Constants.py index b5b7c270cf..65b4ac2ab1 100644 --- a/grc/core/Constants.py +++ b/grc/core/Constants.py @@ -115,5 +115,21 @@ ALIAS_TYPES = { 'bits': (1, GRC_COLOR_PURPLE_A100), } +ALIAS_OF = { + 'complex': 'fc32', + 'float': 'f32', + 'int': 's32', + 'short': 's16', + 'byte': 's8', + 'bits': 'bit', + + 'fc32': 'complex', + 'f32': 'float', + 's32': 'int', + 's16': 'short', + 's8': 'byte', + 'bit': 'bits', +} + TYPE_TO_SIZEOF = {key: sizeof for name, key, sizeof, color in CORE_TYPES} TYPE_TO_SIZEOF.update((key, sizeof) for key, (sizeof, _) in ALIAS_TYPES.items()) |