diff options
author | Tom Rondeau <tom@trondeau.com> | 2014-06-27 15:09:56 -0400 |
---|---|---|
committer | Tom Rondeau <tom@trondeau.com> | 2014-06-28 13:58:57 -0400 |
commit | 3d8a19b55a15a285d5a95d1e786cb93e26cb4f3a (patch) | |
tree | 6e76b706bfe46b0af9b59f43465b8a2125042700 /gnuradio-runtime/python/pmt | |
parent | 34b04e3f9a1e9f20d1011a23192b97ea9b7e6b04 (diff) |
runtime: mods for pmt's NIL.
Diffstat (limited to 'gnuradio-runtime/python/pmt')
-rw-r--r-- | gnuradio-runtime/python/pmt/__init__.py | 5 | ||||
-rw-r--r-- | gnuradio-runtime/python/pmt/pmt_to_python.py | 11 |
2 files changed, 11 insertions, 5 deletions
diff --git a/gnuradio-runtime/python/pmt/__init__.py b/gnuradio-runtime/python/pmt/__init__.py index 00940e4cc1..1c7db73322 100644 --- a/gnuradio-runtime/python/pmt/__init__.py +++ b/gnuradio-runtime/python/pmt/__init__.py @@ -48,6 +48,9 @@ except ImportError: __path__.append(os.path.join(dirname, "..", "..", "swig")) from pmt_swig import * +# due to changes in the PMT_NIL singleton for static builds, we force +# this into Python here. +PMT_NIL = get_PMT_NIL() + from pmt_to_python import pmt_to_python as to_python from pmt_to_python import python_to_pmt as to_pmt - diff --git a/gnuradio-runtime/python/pmt/pmt_to_python.py b/gnuradio-runtime/python/pmt/pmt_to_python.py index 8973b886e6..e08b7265de 100644 --- a/gnuradio-runtime/python/pmt/pmt_to_python.py +++ b/gnuradio-runtime/python/pmt/pmt_to_python.py @@ -21,6 +21,10 @@ try: import pmt_swig as pmt except: import pmt import numpy +# SWIG isn't taking in the #define PMT_NIL; +# getting the singleton locally. +PMT_NIL = pmt.get_PMT_NIL() + #define missing def pmt_to_tuple(p): elems = list() @@ -41,7 +45,7 @@ def pmt_to_vector(p): return v def pmt_from_vector(p): - v = pmt.make_vector(len(p), pmt.PMT_NIL) + v = pmt.make_vector(len(p), PMT_NIL) for i, elem in enumerate(p): pmt.vector_set(v, i, python_to_pmt(elem)) return v @@ -99,7 +103,7 @@ def uvector_to_numpy(uvector): raise ValueError("unsupported uvector data type for conversion to numpy array %s"%(uvector)) type_mappings = ( #python type, check pmt type, to python, from python - (None, pmt.is_null, lambda x: None, lambda x: pmt.PMT_NIL), + (None, pmt.is_null, lambda x: None, lambda x: PMT_NIL), (bool, pmt.is_bool, pmt.to_bool, pmt.from_bool), (str, pmt.is_symbol, pmt.symbol_to_string, pmt.string_to_symbol), (unicode, lambda x: False, None, lambda x: pmt.string_to_symbol(x.encode('utf-8'))), @@ -116,7 +120,7 @@ type_mappings = ( #python type, check pmt type, to python, from python def pmt_to_python(p): for python_type, pmt_check, to_python, from_python in type_mappings: - if pmt_check(p): + if pmt_check(p): try: return to_python(p) except: @@ -129,4 +133,3 @@ def python_to_pmt(p): if p == None: return from_python(p) elif isinstance(p, python_type): return from_python(p) raise ValueError("can't convert %s type to pmt (%s)"%(type(p),p)) - |