commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 02/05: Support vector types in embedded Pyt


From: git
Subject: [Commit-gnuradio] [gnuradio] 02/05: Support vector types in embedded Python blocks.
Date: Sun, 27 Nov 2016 22:41:16 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch master
in repository gnuradio.

commit bebfb49c465c1854888ba37edb841cec213da533
Author: Clayton Smith <address@hidden>
Date:   Tue Nov 22 21:55:05 2016 -0500

    Support vector types in embedded Python blocks.
---
 grc/core/Block.py              | 5 ++++-
 grc/core/utils/epy_block_io.py | 8 ++++----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/grc/core/Block.py b/grc/core/Block.py
index 7371424..f8179b1 100644
--- a/grc/core/Block.py
+++ b/grc/core/Block.py
@@ -462,10 +462,11 @@ class Block(Element):
             iter_ports = iter(ports)
             ports_new = []
             port_current = next(iter_ports, None)
-            for key, port_type in port_specs:
+            for key, port_type, vlen in port_specs:
                 reuse_port = (
                     port_current is not None and
                     port_current.get_type() == port_type and
+                    port_current.get_vlen() == vlen and
                     (key.isdigit() or port_current.get_key() == key)
                 )
                 if reuse_port:
@@ -476,6 +477,8 @@ class Block(Element):
                     if port_type == 'message':
                         n['name'] = key
                         n['optional'] = '1'
+                    if vlen > 1:
+                        n['vlen'] = str(vlen)
                     port = platform.Port(block=self, n=n, dir=direction)
                 ports_new.append(port)
             # replace old port list with new one
diff --git a/grc/core/utils/epy_block_io.py b/grc/core/utils/epy_block_io.py
index 4eb4d6d..53a1bb3 100644
--- a/grc/core/utils/epy_block_io.py
+++ b/grc/core/utils/epy_block_io.py
@@ -17,14 +17,15 @@ BlockIO = collections.namedtuple('BlockIO', 'name cls 
params sinks sources doc c
 def _ports(sigs, msgs):
     ports = list()
     for i, dtype in enumerate(sigs):
-        port_type = TYPE_MAP.get(dtype.name, None)
+        port_type = TYPE_MAP.get(dtype.base.name, None)
         if not port_type:
             raise ValueError("Can't map {0!r} to GRC port type".format(dtype))
-        ports.append((str(i), port_type))
+        vlen = dtype.shape[0] if len(dtype.shape) > 0 else 1
+        ports.append((str(i), port_type, vlen))
     for msg_key in msgs:
         if msg_key == 'system':
             continue
-        ports.append((msg_key, 'message'))
+        ports.append((msg_key, 'message', None))
     return ports
 
 
@@ -122,4 +123,3 @@ class blk(gr.sync_block):
     """
     from pprint import pprint
     pprint(dict(extract(blk_code)._asdict()))
-



reply via email to

[Prev in Thread] Current Thread [Next in Thread]