summaryrefslogtreecommitdiff
path: root/gruel/src/lib/pmt/pmt_serialize.cc
diff options
context:
space:
mode:
authorTim O'Shea2012-06-20 11:58:40 -0400
committerTim O'Shea2012-06-20 11:58:40 -0400
commite42a6889a2966d8e9fd4e6b2b1bb3dd28c9794c9 (patch)
treece38ab679f29287954bf06675b7bd04d8f41b809 /gruel/src/lib/pmt/pmt_serialize.cc
parentd4843d2c9750bbf7b40e77b80936a08bcf39c1d1 (diff)
downloadgnuradio-e42a6889a2966d8e9fd4e6b2b1bb3dd28c9794c9.tar.gz
gnuradio-e42a6889a2966d8e9fd4e6b2b1bb3dd28c9794c9.tar.bz2
gnuradio-e42a6889a2966d8e9fd4e6b2b1bb3dd28c9794c9.zip
1. handle pmt serialize and deserialize for tuples
2. fix offset checking in pmt_annotator_raw
Diffstat (limited to 'gruel/src/lib/pmt/pmt_serialize.cc')
-rw-r--r--gruel/src/lib/pmt/pmt_serialize.cc41
1 files changed, 41 insertions, 0 deletions
diff --git a/gruel/src/lib/pmt/pmt_serialize.cc b/gruel/src/lib/pmt/pmt_serialize.cc
index 05140bb42..8c9dd12b3 100644
--- a/gruel/src/lib/pmt/pmt_serialize.cc
+++ b/gruel/src/lib/pmt/pmt_serialize.cc
@@ -24,6 +24,7 @@
#endif
#include <vector>
#include <gruel/pmt.h>
+#include <iostream>
#include "pmt_int.h"
#include "gruel/pmt_serial_tags.h"
@@ -213,6 +214,28 @@ deserialize_untagged_f64(double *ip, std::streambuf &sb)
return t != std::streambuf::traits_type::eof();
}
+static bool
+deserialize_tuple(pmt_t *tuple, std::streambuf &sb)
+{
+ std::cout << "deserialize_tuple\n";
+ uint32_t nitems;
+ bool ok = deserialize_untagged_u32(&nitems, sb);
+ pmt_t list(PMT_NIL);
+ std::cout << "nitems: " << nitems << "\n";
+ for(uint32_t i=0; i<nitems; i++){
+ std::cout << "deserialize_tuple :: recursive call to pmt_deserialize\n";
+ pmt_t item = pmt_deserialize( sb );
+ pmt_print(item);
+ if(pmt_eq(list, PMT_NIL)){
+ list = pmt_list1(item);
+ } else {
+ list = pmt_list_add(list, item);
+ }
+ }
+ (*tuple) = pmt_to_tuple(list);
+ return ok;
+}
+
/*
* Write portable byte-serial representation of \p obj to \p sb
@@ -300,6 +323,16 @@ pmt_serialize(pmt_t obj, std::streambuf &sb)
if (pmt_is_dict(obj))
throw pmt_notimplemented("pmt_serialize (dict)", obj);
+ if (pmt_is_tuple(obj)){
+ size_t tuple_len = pmt::pmt_length(obj);
+ ok = serialize_untagged_u8(PST_COMPLEX, sb);
+ ok &= serialize_untagged_u32(tuple_len, sb);
+ for(size_t i=0; i<tuple_len; i++){
+ ok &= pmt_serialize(pmt_tuple_ref(obj, i), sb);
+ }
+ return ok;
+ }
+ //throw pmt_notimplemented("pmt_serialize (tuple)", obj);
throw pmt_notimplemented("pmt_serialize (?)", obj);
}
@@ -369,6 +402,14 @@ pmt_deserialize(std::streambuf &sb)
goto error;
return pmt_make_rectangular( r,i );
}
+
+ case PST_TUPLE:
+ {
+ pmt_t tuple;
+ if(!deserialize_tuple(&tuple, sb));
+ goto error;
+ return tuple;
+ }
case PST_VECTOR:
case PST_DICT: