From 713629cce8d571570bc5f0f0db67c5a96d5ee071 Mon Sep 17 00:00:00 2001
From: Marcus Müller <marcus.mueller@ettus.com>
Date: Tue, 6 Mar 2018 12:41:09 +0100
Subject: runtime: make py_io_signature iterable, hashable

This allows GRC to iterate the output signatures of epy blocks after
switching over to py_io_signature.

Fixes #1666.
---
 gnuradio-runtime/python/gnuradio/gr/gateway.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

(limited to 'gnuradio-runtime/python/gnuradio/gr/gateway.py')

diff --git a/gnuradio-runtime/python/gnuradio/gr/gateway.py b/gnuradio-runtime/python/gnuradio/gr/gateway.py
index 8f4b930fd2..4498729825 100644
--- a/gnuradio-runtime/python/gnuradio/gr/gateway.py
+++ b/gnuradio-runtime/python/gnuradio/gr/gateway.py
@@ -101,7 +101,7 @@ class py_io_signature(object):
         """
         self.__min_ports = min_ports
         self.__max_ports = max_ports
-        self.__types = map(numpy.dtype, type_list)
+        self.__types = tuple( numpy.dtype(t) for t in type_list )
 
     def gr_io_signature(self):
         """
@@ -124,6 +124,15 @@ class py_io_signature(object):
             return self.__types[:nports]
         return self.__types + [self.__types[-1]]*(nports-ntypes)
 
+    def __iter__(self):
+        """
+        Return the iterator over the maximum ports type list.
+        """
+        return iter(self.port_types(self.__max_ports))
+
+    def __hash__(self):
+        return hash((self.__min_ports, self.__max_ports, self.__types))
+
 ########################################################################
 # The guts that make this into a gr block
 ########################################################################
-- 
cgit v1.2.3