summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rondeau <tom@trondeau.com>2014-06-27 15:09:56 -0400
committerTom Rondeau <tom@trondeau.com>2014-06-28 13:58:57 -0400
commit3d8a19b55a15a285d5a95d1e786cb93e26cb4f3a (patch)
tree6e76b706bfe46b0af9b59f43465b8a2125042700
parent34b04e3f9a1e9f20d1011a23192b97ea9b7e6b04 (diff)
runtime: mods for pmt's NIL.
-rw-r--r--gnuradio-runtime/include/pmt/pmt.h3
-rw-r--r--gnuradio-runtime/lib/pmt/pmt.cc9
-rw-r--r--gnuradio-runtime/python/pmt/__init__.py5
-rw-r--r--gnuradio-runtime/python/pmt/pmt_to_python.py11
-rw-r--r--gnuradio-runtime/swig/pmt_swig.i6
5 files changed, 24 insertions, 10 deletions
diff --git a/gnuradio-runtime/include/pmt/pmt.h b/gnuradio-runtime/include/pmt/pmt.h
index 5929975a29..3e17571b23 100644
--- a/gnuradio-runtime/include/pmt/pmt.h
+++ b/gnuradio-runtime/include/pmt/pmt.h
@@ -249,7 +249,8 @@ PMT_API std::complex<double> to_complex(pmt_t z);
* ------------------------------------------------------------------------
*/
-extern PMT_API const pmt_t PMT_NIL; //< the empty list
+#define PMT_NIL get_PMT_NIL()
+PMT_API pmt_t get_PMT_NIL();
//! Return true if \p x is the empty list, otherwise return false.
PMT_API bool is_null(const pmt_t& x);
diff --git a/gnuradio-runtime/lib/pmt/pmt.cc b/gnuradio-runtime/lib/pmt/pmt.cc
index 8315100ab3..082b98a80d 100644
--- a/gnuradio-runtime/lib/pmt/pmt.cc
+++ b/gnuradio-runtime/lib/pmt/pmt.cc
@@ -160,9 +160,14 @@ _any(pmt_t x)
const pmt_t PMT_T = pmt_t(new pmt_bool()); // singleton
const pmt_t PMT_F = pmt_t(new pmt_bool()); // singleton
-const pmt_t PMT_NIL = pmt_t(new pmt_null()); // singleton
const pmt_t PMT_EOF = cons(PMT_NIL, PMT_NIL); // singleton
+pmt_t get_PMT_NIL()
+{
+ static pmt_t NIL = pmt_t(new pmt_null());
+ return NIL;
+}
+
////////////////////////////////////////////////////////////////////////////
// Booleans
////////////////////////////////////////////////////////////////////////////
@@ -1388,7 +1393,7 @@ list_has(pmt_t list, const pmt_t& item)
pmt_t right = cdr(list);
if(equal(left,item))
return true;
- return list_has(right, item);
+ return list_has(right, item);
} else {
if(is_null(list))
return false;
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))
-
diff --git a/gnuradio-runtime/swig/pmt_swig.i b/gnuradio-runtime/swig/pmt_swig.i
index 5ea612b5b8..e54b544977 100644
--- a/gnuradio-runtime/swig/pmt_swig.i
+++ b/gnuradio-runtime/swig/pmt_swig.i
@@ -83,9 +83,11 @@ namespace pmt{
extern const pmt_t PMT_T;
extern const pmt_t PMT_F;
- extern const pmt_t PMT_NIL;
extern const pmt_t PMT_EOF;
+ pmt_t get_PMT_NIL();
+ #define PMT_NIL get_PMT_NIL()
+
bool is_bool(pmt_t obj);
bool is_true(pmt_t obj);
bool is_false(pmt_t obj);
@@ -219,7 +221,7 @@ namespace pmt{
void c64vector_set(pmt_t v, size_t k, std::complex<double> x);
%apply size_t & INOUT { size_t &len };
- const void *uniform_vector_elements(pmt_t v, size_t &len);
+ const void *uniform_vector_elements(pmt_t v, size_t &len);
const std::vector<uint8_t> u8vector_elements(pmt_t v);
const std::vector<int8_t> s8vector_elements(pmt_t v);