summaryrefslogtreecommitdiff
path: root/gruel
diff options
context:
space:
mode:
authorJohnathan Corgan2009-08-26 16:48:36 -0700
committerJohnathan Corgan2009-08-26 16:48:36 -0700
commit20e87ef0575d6bf09ab19fa1d025dbe71eec27fb (patch)
tree931c373077f156fe667464d9136d00df68f06604 /gruel
parent23fb5e602d48f6924e70b363bf9480fd41b928b0 (diff)
parentcafcd00720877d099262e78ac623a13118574233 (diff)
downloadgnuradio-20e87ef0575d6bf09ab19fa1d025dbe71eec27fb.tar.gz
gnuradio-20e87ef0575d6bf09ab19fa1d025dbe71eec27fb.tar.bz2
gnuradio-20e87ef0575d6bf09ab19fa1d025dbe71eec27fb.zip
Merge msg-passing from http://gnuradio.org/git/eb.git
* Add shorthand for making tuples. * Add blobs and shorthand pmt pseudo-constructors. * gruel::send can now send to a pmt. * Add top-level msg_passing.h include file. * QA code now works. * Add pmt type that wraps a gruel::msg_accepter.
Diffstat (limited to 'gruel')
-rw-r--r--gruel/src/include/gruel/Makefile.am3
-rw-r--r--gruel/src/include/gruel/msg_accepter.h3
-rw-r--r--gruel/src/include/gruel/msg_passing.h111
-rw-r--r--gruel/src/include/gruel/pmt.h49
-rw-r--r--gruel/src/include/gruel/pmt_sugar.h165
-rw-r--r--gruel/src/include/gruel/send.h49
-rw-r--r--gruel/src/lib/Makefile.am13
-rw-r--r--gruel/src/lib/pmt/Makefile.am9
-rw-r--r--gruel/src/lib/pmt/pmt.cc70
-rw-r--r--gruel/src/lib/pmt/qa_pmt_prims.cc56
-rw-r--r--gruel/src/lib/pmt/qa_pmt_prims.h4
-rw-r--r--gruel/src/lib/test_gruel.cc (renamed from gruel/src/lib/pmt/test_pmt.cc)4
12 files changed, 472 insertions, 64 deletions
diff --git a/gruel/src/include/gruel/Makefile.am b/gruel/src/include/gruel/Makefile.am
index 9f50cb619..67dd12995 100644
--- a/gruel/src/include/gruel/Makefile.am
+++ b/gruel/src/include/gruel/Makefile.am
@@ -31,11 +31,12 @@ gruelinclude_HEADERS = \
msg_accepter.h \
msg_accepter_msgq.h \
msg_queue.h \
+ msg_passing.h \
pmt.h \
pmt_pool.h \
pmt_serial_tags.h \
+ pmt_sugar.h \
realtime.h \
- send.h \
sys_pri.h \
thread_body_wrapper.h \
thread_group.h \
diff --git a/gruel/src/include/gruel/msg_accepter.h b/gruel/src/include/gruel/msg_accepter.h
index 3afd6dde0..70ac846f5 100644
--- a/gruel/src/include/gruel/msg_accepter.h
+++ b/gruel/src/include/gruel/msg_accepter.h
@@ -22,6 +22,7 @@
#define INCLUDED_GRUEL_MSG_ACCEPTER_H
#include <gruel/pmt.h>
+#include <boost/shared_ptr.hpp>
namespace gruel {
@@ -44,6 +45,8 @@ namespace gruel {
virtual void post(pmt::pmt_t msg) = 0;
};
+ typedef boost::shared_ptr<msg_accepter> msg_accepter_sptr;
+
} /* namespace gruel */
#endif /* INCLUDED_GRUEL_MSG_ACCEPTER_H */
diff --git a/gruel/src/include/gruel/msg_passing.h b/gruel/src/include/gruel/msg_passing.h
new file mode 100644
index 000000000..ebbeca815
--- /dev/null
+++ b/gruel/src/include/gruel/msg_passing.h
@@ -0,0 +1,111 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2009 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_GRUEL_MSG_PASSING_H
+#define INCLUDED_GRUEL_MSG_PASSING_H
+
+/*!
+ * \brief Include this header to use the message passing features
+ */
+
+#include <gruel/pmt.h>
+#include <gruel/msg_accepter.h>
+
+
+namespace gruel {
+
+ /*!
+ * \brief send message to msg_accepter
+ *
+ * \param accepter is the target of the send.
+ * \param msg is the message to send. It's usually a pmt tuple.
+ *
+ * Sending a message is an asynchronous operation. The \p send
+ * call will not wait for the message either to arrive at the
+ * destination or to be received.
+ *
+ * \returns msg
+ */
+ static inline pmt::pmt_t
+ send(msg_accepter_sptr accepter, const pmt::pmt_t &msg)
+ {
+ accepter->post(msg);
+ return msg;
+ }
+
+ /*!
+ * \brief send message to msg_accepter
+ *
+ * \param accepter is the target of the send.
+ * \param msg is the message to send. It's usually a pmt tuple.
+ *
+ * Sending a message is an asynchronous operation. The \p send
+ * call will not wait for the message either to arrive at the
+ * destination or to be received.
+ *
+ * \returns msg
+ */
+ static inline pmt::pmt_t
+ send(msg_accepter *accepter, const pmt::pmt_t &msg)
+ {
+ accepter->post(msg);
+ return msg;
+ }
+
+ /*!
+ * \brief send message to msg_accepter
+ *
+ * \param accepter is the target of the send.
+ * \param msg is the message to send. It's usually a pmt tuple.
+ *
+ * Sending a message is an asynchronous operation. The \p send
+ * call will not wait for the message either to arrive at the
+ * destination or to be received.
+ *
+ * \returns msg
+ */
+ static inline pmt::pmt_t
+ send(msg_accepter &accepter, const pmt::pmt_t &msg)
+ {
+ accepter.post(msg);
+ return msg;
+ }
+
+ /*!
+ * \brief send message to msg_accepter
+ *
+ * \param accepter is the target of the send. precond: pmt_is_msg_accepter(accepter)
+ * \param msg is the message to send. It's usually a pmt tuple.
+ *
+ * Sending a message is an asynchronous operation. The \p send
+ * call will not wait for the message either to arrive at the
+ * destination or to be received.
+ *
+ * \returns msg
+ */
+ static inline pmt::pmt_t
+ send(pmt::pmt_t accepter, const pmt::pmt_t &msg)
+ {
+ return send(pmt_msg_accepter_ref(accepter), msg);
+ }
+
+} /* namespace gruel */
+
+#endif /* INCLUDED_GRUEL_MSG_PASSING_H */
diff --git a/gruel/src/include/gruel/pmt.h b/gruel/src/include/gruel/pmt.h
index 240359301..3188aad1d 100644
--- a/gruel/src/include/gruel/pmt.h
+++ b/gruel/src/include/gruel/pmt.h
@@ -24,6 +24,7 @@
#define INCLUDED_PMT_H
#include <boost/intrusive_ptr.hpp>
+#include <boost/shared_ptr.hpp>
#include <boost/any.hpp>
#include <complex>
#include <string>
@@ -31,6 +32,10 @@
#include <iosfwd>
#include <stdexcept>
+namespace gruel {
+ class msg_accepter;
+};
+
/*!
* This file defines a polymorphic type and the operations on it.
*
@@ -299,6 +304,33 @@ void pmt_vector_set(pmt_t vector, size_t k, pmt_t obj);
//! Store \p fill in every position of \p vector
void pmt_vector_fill(pmt_t vector, pmt_t fill);
+/*
+ * ------------------------------------------------------------------------
+ * Binary Large Objects (BLOBs)
+ *
+ * Handy for passing around uninterpreted chunks of memory.
+ * ------------------------------------------------------------------------
+ */
+
+//! Return true if \p x is a blob, othewise false.
+bool pmt_is_blob(pmt_t x);
+
+/*!
+ * \brief Make a blob given a pointer and length in bytes
+ *
+ * \param buf is the pointer to data to use to create blob
+ * \param len is the size of the data in bytes.
+ *
+ * The data is copied into the blob.
+ */
+pmt_t pmt_make_blob(const void *buf, size_t len);
+
+//! Return a pointer to the blob's data
+const void *pmt_blob_data(pmt_t blob);
+
+//! Return the blob's length in bytes
+size_t pmt_blob_length(pmt_t blob);
+
/*!
* <pre>
* ------------------------------------------------------------------------
@@ -484,6 +516,20 @@ void pmt_any_set(pmt_t obj, const boost::any &any);
/*
* ------------------------------------------------------------------------
+ * msg_accepter -- pmt representation of gruel::msg_accepter
+ * ------------------------------------------------------------------------
+ */
+//! Return true if \p obj is a msg_accepter
+bool pmt_is_msg_accepter(const pmt_t &obj);
+
+//! make a msg_accepter
+pmt_t pmt_make_msg_accepter(boost::shared_ptr<gruel::msg_accepter> ma);
+
+//! Return underlying msg_accepter
+boost::shared_ptr<gruel::msg_accepter> pmt_msg_accepter_ref(const pmt_t &obj);
+
+/*
+ * ------------------------------------------------------------------------
* General functions
* ------------------------------------------------------------------------
*/
@@ -717,4 +763,7 @@ void pmt_dump_sizeof(); // debugging
} /* namespace pmt */
+
+#include <gruel/pmt_sugar.h>
+
#endif /* INCLUDED_PMT_H */
diff --git a/gruel/src/include/gruel/pmt_sugar.h b/gruel/src/include/gruel/pmt_sugar.h
new file mode 100644
index 000000000..92bcb5fe5
--- /dev/null
+++ b/gruel/src/include/gruel/pmt_sugar.h
@@ -0,0 +1,165 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2009 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_GRUEL_PMT_SUGAR_H
+#define INCLUDED_GRUEL_PMT_SUGAR_H
+
+/*!
+ * This file is included by pmt.h and contains pseudo-constructor
+ * shorthand for making pmt objects
+ */
+
+namespace pmt {
+
+ //! Make pmt symbol
+ static inline pmt_t
+ mp(const std::string &s)
+ {
+ return pmt_string_to_symbol(s);
+ }
+
+ //! Make pmt symbol
+ static inline pmt_t
+ mp(const char *s)
+ {
+ return pmt_string_to_symbol(s);
+ }
+
+ //! Make pmt long
+ static inline pmt_t
+ mp(long x){
+ return pmt_from_long(x);
+ }
+
+ //! Make pmt long
+ static inline pmt_t
+ mp(int x){
+ return pmt_from_long(x);
+ }
+
+ //! Make pmt double
+ static inline pmt_t
+ mp(double x){
+ return pmt_from_double(x);
+ }
+
+ //! Make pmt complex
+ static inline pmt_t
+ mp(std::complex<double> z)
+ {
+ return pmt_make_rectangular(z.real(), z.imag());
+ }
+
+ //! Make pmt complex
+ static inline pmt_t
+ mp(std::complex<float> z)
+ {
+ return pmt_make_rectangular(z.real(), z.imag());
+ }
+
+ //! Make pmt msg_accepter
+ static inline pmt_t
+ mp(boost::shared_ptr<gruel::msg_accepter> ma)
+ {
+ return pmt_make_msg_accepter(ma);
+ }
+
+ //! Make pmt Binary Large Object (BLOB)
+ static inline pmt_t
+ mp(const void *data, size_t len_in_bytes)
+ {
+ return pmt_make_blob(data, len_in_bytes);
+ }
+
+ //! Make tuple
+ static inline pmt_t
+ mp(const pmt_t &e0)
+ {
+ return pmt_make_tuple(e0);
+ }
+
+ //! Make tuple
+ static inline pmt_t
+ mp(const pmt_t &e0, const pmt_t &e1)
+ {
+ return pmt_make_tuple(e0, e1);
+ }
+
+ //! Make tuple
+ static inline pmt_t
+ mp(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2)
+ {
+ return pmt_make_tuple(e0, e1, e2);
+ }
+
+ //! Make tuple
+ static inline pmt_t
+ mp(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3)
+ {
+ return pmt_make_tuple(e0, e1, e2, e3);
+ }
+
+ //! Make tuple
+ static inline pmt_t
+ mp(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4)
+ {
+ return pmt_make_tuple(e0, e1, e2, e3, e4);
+ }
+
+ //! Make tuple
+ static inline pmt_t
+ mp(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5)
+ {
+ return pmt_make_tuple(e0, e1, e2, e3, e4, e5);
+ }
+
+ //! Make tuple
+ static inline pmt_t
+ mp(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5, const pmt_t &e6)
+ {
+ return pmt_make_tuple(e0, e1, e2, e3, e4, e5, e6);
+ }
+
+ //! Make tuple
+ static inline pmt_t
+ mp(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5, const pmt_t &e6, const pmt_t &e7)
+ {
+ return pmt_make_tuple(e0, e1, e2, e3, e4, e5, e6, e7);
+ }
+
+ //! Make tuple
+ static inline pmt_t
+ mp(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5, const pmt_t &e6, const pmt_t &e7, const pmt_t &e8)
+ {
+ return pmt_make_tuple(e0, e1, e2, e3, e4, e5, e6, e7, e8);
+ }
+
+ //! Make tuple
+ static inline pmt_t
+ mp(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5, const pmt_t &e6, const pmt_t &e7, const pmt_t &e8, const pmt_t &e9)
+ {
+ return pmt_make_tuple(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9);
+ }
+
+
+} /* namespace pmt */
+
+
+#endif /* INCLUDED_GRUEL_PMT_SUGAR_H */
diff --git a/gruel/src/include/gruel/send.h b/gruel/src/include/gruel/send.h
deleted file mode 100644
index 292017d45..000000000
--- a/gruel/src/include/gruel/send.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2009 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#ifndef INCLUDED_GRUEL_SEND_H
-#define INCLUDED_GRUEL_SEND_H
-
-#include <gruel/msg_accepter.h>
-
-namespace gruel {
-
-
- /*!
- * \brief send \p msg to \p msg_accepter
- *
- * Sending a message is an asynchronous operation. The \p send
- * call will not wait for the message either to arrive at the
- * destination or to be received.
- *
- * \returns msg
- */
- static inline pmt::pmt_t
- send(msg_accepter &acc, pmt::pmt_t msg)
- {
- return acc.post(msg);
- }
-
-
-
-} /* namespace gruel */
-
-
-#endif /* INCLUDED_SEND_H */
diff --git a/gruel/src/lib/Makefile.am b/gruel/src/lib/Makefile.am
index 6dfb6787c..9afa0d292 100644
--- a/gruel/src/lib/Makefile.am
+++ b/gruel/src/lib/Makefile.am
@@ -25,6 +25,12 @@ SUBDIRS = pmt msg
AM_CPPFLAGS = $(DEFINES) $(BOOST_CPPFLAGS) $(CPPUNIT_INCLUDES) $(GRUEL_INCLUDES) $(WITH_INCLUDES)
+
+TESTS = test_gruel
+
+noinst_PROGRAMS = test_gruel
+
+
lib_LTLIBRARIES = libgruel.la
# magic flags
@@ -47,3 +53,10 @@ libgruel_la_LIBADD = \
$(PMT_LIB) \
$(MSG_LIB) \
-lstdc++
+
+
+# ----------------------------------------------------------------
+
+test_gruel_SOURCES = test_gruel.cc
+test_gruel_LDADD = libgruel.la pmt/libpmt-qa.la
+
diff --git a/gruel/src/lib/pmt/Makefile.am b/gruel/src/lib/pmt/Makefile.am
index 2b710a598..8750cbdf8 100644
--- a/gruel/src/lib/pmt/Makefile.am
+++ b/gruel/src/lib/pmt/Makefile.am
@@ -23,7 +23,6 @@ include $(top_srcdir)/Makefile.common
AM_CPPFLAGS = $(DEFINES) $(BOOST_CPPFLAGS) $(CPPUNIT_INCLUDES) $(GRUEL_INCLUDES) $(WITH_INCLUDES)
-TESTS = test_pmt
noinst_LTLIBRARIES = libpmt.la
@@ -90,14 +89,6 @@ libpmt_qa_la_LIBADD = \
$(CPPUNIT_LIBS) \
-lstdc++
-noinst_PROGRAMS = \
- test_pmt
-
-
-LIBPMTQA = libpmt-qa.la
-
-test_pmt_SOURCES = test_pmt.cc
-test_pmt_LDADD = $(LIBPMTQA)
# Do creation and inclusion of other Makefiles last
diff --git a/gruel/src/lib/pmt/pmt.cc b/gruel/src/lib/pmt/pmt.cc
index f0e3c30a2..e50e21838 100644
--- a/gruel/src/lib/pmt/pmt.cc
+++ b/gruel/src/lib/pmt/pmt.cc
@@ -26,8 +26,9 @@
#include <vector>
#include <gruel/pmt.h>
#include "pmt_int.h"
-#include <stdio.h>
+#include <gruel/msg_accepter.h>
#include <gruel/pmt_pool.h>
+#include <stdio.h>
#include <string.h>
namespace pmt {
@@ -882,6 +883,73 @@ pmt_any_set(pmt_t obj, const boost::any &any)
}
////////////////////////////////////////////////////////////////////////////
+// msg_accepter -- built from "any"
+////////////////////////////////////////////////////////////////////////////
+
+bool
+pmt_is_msg_accepter(const pmt_t &obj)
+{
+ if (!pmt_is_any(obj))
+ return false;
+
+ boost::any r = pmt_any_ref(obj);
+ return boost::any_cast<gruel::msg_accepter_sptr>(&r) != 0;
+}
+
+//! make a msg_accepter
+pmt_t
+pmt_make_msg_accepter(gruel::msg_accepter_sptr ma)
+{
+ return pmt_make_any(ma);
+}
+
+//! Return underlying msg_accepter
+gruel::msg_accepter_sptr
+pmt_msg_accepter_ref(const pmt_t &obj)
+{
+ try {
+ return boost::any_cast<gruel::msg_accepter_sptr>(pmt_any_ref(obj));
+ }
+ catch (boost::bad_any_cast &e){
+ throw pmt_wrong_type("pmt_msg_accepter_ref", obj);
+ }
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+// Binary Large Object -- currently a u8vector
+////////////////////////////////////////////////////////////////////////////
+
+bool
+pmt_is_blob(pmt_t x)
+{
+ // return pmt_is_u8vector(x);
+ return pmt_is_uniform_vector(x);
+}
+
+pmt_t
+pmt_make_blob(const void *buf, size_t len_in_bytes)
+{
+ return pmt_init_u8vector(len_in_bytes, (const uint8_t *) buf);
+}
+
+const void *
+pmt_blob_data(pmt_t blob)
+{
+ size_t len;
+ return pmt_uniform_vector_elements(blob, len);
+}
+
+size_t
+pmt_blob_length(pmt_t blob)
+{
+ size_t len;
+ pmt_uniform_vector_elements(blob, len);
+ return len;
+}
+
+
+////////////////////////////////////////////////////////////////////////////
// General Functions
////////////////////////////////////////////////////////////////////////////
diff --git a/gruel/src/lib/pmt/qa_pmt_prims.cc b/gruel/src/lib/pmt/qa_pmt_prims.cc
index 899674bbb..59d9e14d3 100644
--- a/gruel/src/lib/pmt/qa_pmt_prims.cc
+++ b/gruel/src/lib/pmt/qa_pmt_prims.cc
@@ -22,8 +22,9 @@
#include <qa_pmt_prims.h>
#include <cppunit/TestAssert.h>
-#include <gruel/pmt.h>
-#include <stdio.h>
+#include <gruel/msg_passing.h>
+#include <cstdio>
+#include <cstring>
#include <sstream>
using namespace pmt;
@@ -453,6 +454,41 @@ qa_pmt_prims::test_any()
// ------------------------------------------------------------------------
+class qa_pmt_msg_accepter_nop : public gruel::msg_accepter {
+public:
+ qa_pmt_msg_accepter_nop(){};
+ ~qa_pmt_msg_accepter_nop();
+ void post(pmt_t){};
+};
+
+qa_pmt_msg_accepter_nop::~qa_pmt_msg_accepter_nop(){}
+
+void
+qa_pmt_prims::test_msg_accepter()
+{
+ pmt_t sym = pmt_intern("my-symbol");
+
+ boost::any a0;
+ a0 = std::string("Hello!");
+ pmt_t p0 = pmt_make_any(a0);
+
+ gruel::msg_accepter_sptr ma0 = gruel::msg_accepter_sptr(new qa_pmt_msg_accepter_nop());
+ pmt_t p1 = pmt_make_msg_accepter(ma0);
+
+ CPPUNIT_ASSERT_EQUAL(ma0.get(), pmt_msg_accepter_ref(p1).get());
+
+ CPPUNIT_ASSERT_THROW(pmt_msg_accepter_ref(sym), pmt_wrong_type);
+ CPPUNIT_ASSERT_THROW(pmt_msg_accepter_ref(p0), pmt_wrong_type);
+
+ // just confirm interfaces on send are OK
+ gruel::send(ma0.get(), sym);
+ gruel::send(ma0, sym);
+ gruel::send(p1, sym);
+
+}
+
+// ------------------------------------------------------------------------
+
void
qa_pmt_prims::test_serialize()
{
@@ -522,3 +558,19 @@ qa_pmt_prims::test_sets()
CPPUNIT_ASSERT(!pmt_subsetp(l3,l2));
}
+void
+qa_pmt_prims::test_sugar()
+{
+ CPPUNIT_ASSERT(pmt_is_symbol(mp("my-symbol")));
+ CPPUNIT_ASSERT_EQUAL((long) 10, pmt_to_long(mp(10)));
+ CPPUNIT_ASSERT_EQUAL((double) 1e6, pmt_to_double(mp(1e6)));
+ CPPUNIT_ASSERT_EQUAL(std::complex<double>(2, 3),
+ pmt_to_complex(mp(std::complex<double>(2, 3))));
+
+ int buf[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ pmt_t blob = mp(buf, sizeof(buf));
+ const void *data = pmt_blob_data(blob);
+ size_t nbytes = pmt_blob_length(blob);
+ CPPUNIT_ASSERT_EQUAL(sizeof(buf), nbytes);
+ CPPUNIT_ASSERT(memcmp(buf, data, nbytes) == 0);
+}
diff --git a/gruel/src/lib/pmt/qa_pmt_prims.h b/gruel/src/lib/pmt/qa_pmt_prims.h
index 2fe473c43..29ba02f11 100644
--- a/gruel/src/lib/pmt/qa_pmt_prims.h
+++ b/gruel/src/lib/pmt/qa_pmt_prims.h
@@ -40,10 +40,12 @@ class qa_pmt_prims : public CppUnit::TestCase {
CPPUNIT_TEST(test_misc);
CPPUNIT_TEST(test_dict);
CPPUNIT_TEST(test_any);
+ CPPUNIT_TEST(test_msg_accepter);
CPPUNIT_TEST(test_io);
CPPUNIT_TEST(test_lists);
CPPUNIT_TEST(test_serialize);
CPPUNIT_TEST(test_sets);
+ CPPUNIT_TEST(test_sugar);
CPPUNIT_TEST_SUITE_END();
private:
@@ -59,10 +61,12 @@ class qa_pmt_prims : public CppUnit::TestCase {
void test_misc();
void test_dict();
void test_any();
+ void test_msg_accepter();
void test_io();
void test_lists();
void test_serialize();
void test_sets();
+ void test_sugar();
};
#endif /* INCLUDED_QA_PMT_PRIMS_H */
diff --git a/gruel/src/lib/pmt/test_pmt.cc b/gruel/src/lib/test_gruel.cc
index 034785f4e..669303447 100644
--- a/gruel/src/lib/pmt/test_pmt.cc
+++ b/gruel/src/lib/test_gruel.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2006 Free Software Foundation, Inc.
+ * Copyright 2006,2009 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -21,7 +21,7 @@
*/
#include <cppunit/TextTestRunner.h>
-#include <qa_pmt.h>
+#include "pmt/qa_pmt.h"
int
main(int argc, char **argv)