Merged r11452:11459 from jcorgan/pmt-gruel into trunk. Trunk passes distcheck.
authorjcorgan <jcorgan@221aa14e-8319-0410-a670-987f0aec2ac5>
Mon, 20 Jul 2009 03:47:14 +0000 (03:47 +0000)
committerjcorgan <jcorgan@221aa14e-8319-0410-a670-987f0aec2ac5>
Mon, 20 Jul 2009 03:47:14 +0000 (03:47 +0000)
* Merges libpmt into libgruel

* Modifies libmblock to use libgruel

gruel::pmt_t will be the fundamental msg content for the new message passing
implemention for 3.3.

git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@11460 221aa14e-8319-0410-a670-987f0aec2ac5

101 files changed:
Makefile.common
config/Makefile.am
config/grc_gruel.m4
config/grc_pmt.m4 [deleted file]
configure.ac
debian/control
debian/libpmt-dev.install [deleted file]
debian/libpmt.install [deleted file]
gruel/src/Makefile.am
gruel/src/include/gruel/Makefile.am
gruel/src/include/gruel/pmt.h [new file with mode: 0644]
gruel/src/include/gruel/pmt_pool.h [new file with mode: 0644]
gruel/src/lib/Makefile.am
gruel/src/lib/generate_unv.py [new file with mode: 0755]
gruel/src/lib/pmt.cc [new file with mode: 0644]
gruel/src/lib/pmt_int.h [new file with mode: 0644]
gruel/src/lib/pmt_io.cc [new file with mode: 0644]
gruel/src/lib/pmt_pool.cc [new file with mode: 0644]
gruel/src/lib/pmt_serialize.cc [new file with mode: 0644]
gruel/src/lib/qa_pmt.cc [new file with mode: 0644]
gruel/src/lib/qa_pmt.h [new file with mode: 0644]
gruel/src/lib/qa_pmt_prims.cc [new file with mode: 0644]
gruel/src/lib/qa_pmt_prims.h [new file with mode: 0644]
gruel/src/lib/test_pmt.cc [new file with mode: 0644]
gruel/src/lib/unv_qa_template.cc.t [new file with mode: 0644]
gruel/src/lib/unv_template.cc.t [new file with mode: 0644]
gruel/src/lib/unv_template.h.t [new file with mode: 0644]
gruel/src/scheme/Makefile.am [new file with mode: 0644]
gruel/src/scheme/gnuradio/Makefile.am [new file with mode: 0644]
gruel/src/scheme/gnuradio/gen-serial-tags.scm [new file with mode: 0755]
gruel/src/scheme/gnuradio/macros-etc.scm [new file with mode: 0644]
gruel/src/scheme/gnuradio/pmt-serial-tags.scm [new file with mode: 0644]
gruel/src/scheme/gnuradio/pmt-serialize.scm [new file with mode: 0644]
mblock/src/include/mblock/class_registry.h
mblock/src/include/mblock/common.h
mblock/src/include/mblock/mblock.h
mblock/src/include/mblock/message.h
mblock/src/include/mblock/msg_accepter.h
mblock/src/include/mblock/port.h
mblock/src/include/mblock/protocol_class.h
mblock/src/include/mblock/runtime.h
mblock/src/lib/Makefile.am
mblock/src/lib/benchmark_send.cc
mblock/src/lib/mb_endpoint.cc
mblock/src/lib/mb_endpoint.h
mblock/src/lib/mb_mblock.cc
mblock/src/lib/mb_mblock_impl.cc
mblock/src/lib/mb_mblock_impl.h
mblock/src/lib/mb_message.cc
mblock/src/lib/mb_msg_accepter_msgq.cc
mblock/src/lib/mb_msg_accepter_msgq.h
mblock/src/lib/mb_msg_accepter_smp.cc
mblock/src/lib/mb_msg_accepter_smp.h
mblock/src/lib/mb_port.cc
mblock/src/lib/mb_port_simple.cc
mblock/src/lib/mb_port_simple.h
mblock/src/lib/mb_protocol_class.cc
mblock/src/lib/mb_runtime_base.cc
mblock/src/lib/mb_runtime_base.h
mblock/src/lib/mb_runtime_nop.cc
mblock/src/lib/mb_runtime_nop.h
mblock/src/lib/mb_runtime_thread_per_block.cc
mblock/src/lib/mb_runtime_thread_per_block.h
mblock/src/lib/mb_timer_queue.cc
mblock/src/lib/mb_timer_queue.h
mblock/src/lib/mb_worker.cc
mblock/src/lib/mb_worker.h
mblock/src/lib/qa_bitset.cc
mblock/src/lib/qa_disconnect.cc
mblock/src/lib/qa_mblock_prims.cc
mblock/src/lib/qa_mblock_send.cc
mblock/src/lib/qa_mblock_sys.cc
mblock/src/lib/qa_timeouts.cc
pmt/Makefile.am [deleted file]
pmt/README [deleted file]
pmt/doc/Makefile.am [deleted file]
pmt/pmt.pc.in [deleted file]
pmt/src/Makefile.am [deleted file]
pmt/src/lib/Makefile.am [deleted file]
pmt/src/lib/generate_unv.py [deleted file]
pmt/src/lib/pmt.cc [deleted file]
pmt/src/lib/pmt.h [deleted file]
pmt/src/lib/pmt_int.h [deleted file]
pmt/src/lib/pmt_io.cc [deleted file]
pmt/src/lib/pmt_pool.cc [deleted file]
pmt/src/lib/pmt_pool.h [deleted file]
pmt/src/lib/pmt_serialize.cc [deleted file]
pmt/src/lib/qa_pmt.cc [deleted file]
pmt/src/lib/qa_pmt.h [deleted file]
pmt/src/lib/qa_pmt_prims.cc [deleted file]
pmt/src/lib/qa_pmt_prims.h [deleted file]
pmt/src/lib/test_pmt.cc [deleted file]
pmt/src/lib/unv_qa_template.cc.t [deleted file]
pmt/src/lib/unv_template.cc.t [deleted file]
pmt/src/lib/unv_template.h.t [deleted file]
pmt/src/scheme/Makefile.am [deleted file]
pmt/src/scheme/gnuradio/Makefile.am [deleted file]
pmt/src/scheme/gnuradio/gen-serial-tags.scm [deleted file]
pmt/src/scheme/gnuradio/macros-etc.scm [deleted file]
pmt/src/scheme/gnuradio/pmt-serial-tags.scm [deleted file]
pmt/src/scheme/gnuradio/pmt-serialize.scm [deleted file]

index 138045353c109c7a2752b385cf88974867ddcf88..3f82d9f64422d4820e842f335cd82b99ccd26bef 100644 (file)
@@ -104,7 +104,7 @@ GCELL_EMBEDSPU_LIBTOOL = @abs_top_srcdir@/gcell/lib/runtime/gcell-embedspu-libto
 # using AM_PATH_PROG, but now here have to add a -f to be like GNU make
 RM=$(RM_PROG) -f
 
-RUN_GUILE = GUILE_LOAD_PATH="@abs_top_srcdir@/pmt/src/scheme:@abs_top_srcdir@/mblock/src/scheme" @GUILE@ -e main -s
+RUN_GUILE = GUILE_LOAD_PATH="@abs_top_srcdir@/gruel/src/scheme:@abs_top_srcdir@/mblock/src/scheme" @GUILE@ -e main -s
 COMPILE_MBH = $(RUN_GUILE) $(top_srcdir)/mblock/src/scheme/gnuradio/compile-mbh.scm
 
 # Base directory for example applications
index 881a64d8a62082273362848a6c66d5fb0e02226d..b921ec5100dd892dc88174b2fb4dfbd8fe18e03a 100644 (file)
@@ -1,5 +1,5 @@
 #
-# Copyright 2001,2006,2008 Free Software Foundation, Inc.
+# Copyright 2001,2006,2008,2009 Free Software Foundation, Inc.
 # 
 # This file is part of GNU Radio
 # 
@@ -74,7 +74,6 @@ m4macros = \
        gr_check_mc4020.m4 \
        gr_check_shm_open.m4 \
        gr_check_usrp.m4 \
-       grc_pmt.m4 \
        grc_usrp.m4 \
        grc_usrp2.m4 \
        grc_gr_msdd6000.m4 \
index 73e41be5f54ca76ba764c2b38ff1f8fd25e56f85..01d44feab8ac47fddee18a91f9a88e8205d1b52e 100644 (file)
@@ -1,4 +1,4 @@
-dnl Copyright 2001,2002,2003,2004,2005,2006,2008 Free Software Foundation, Inc.
+dnl Copyright 2001,2002,2003,2004,2005,2006,2008,2009 Free Software Foundation, Inc.
 dnl 
 dnl This file is part of GNU Radio
 dnl 
@@ -42,6 +42,8 @@ AC_DEFUN([GRC_GRUEL],[
         gruel/src/include/gruel/Makefile \
        gruel/src/include/gruel/inet.h \
         gruel/src/lib/Makefile \
+       gruel/src/scheme/Makefile \
+       gruel/src/scheme/gnuradio/Makefile \
     ])
 
     dnl Allow creating autoconf independent header files for bytesex routines
diff --git a/config/grc_pmt.m4 b/config/grc_pmt.m4
deleted file mode 100644 (file)
index 680acc9..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-dnl Copyright 2001,2002,2003,2004,2005,2006,2008,2009 Free Software Foundation, Inc.
-dnl 
-dnl This file is part of GNU Radio
-dnl 
-dnl GNU Radio is free software; you can redistribute it and/or modify
-dnl it under the terms of the GNU General Public License as published by
-dnl the Free Software Foundation; either version 3, or (at your option)
-dnl any later version.
-dnl 
-dnl GNU Radio is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-dnl GNU General Public License for more details.
-dnl 
-dnl You should have received a copy of the GNU General Public License
-dnl along with GNU Radio; see the file COPYING.  If not, write to
-dnl the Free Software Foundation, Inc., 51 Franklin Street,
-dnl Boston, MA 02110-1301, USA.
-
-AC_DEFUN([GRC_PMT],[
-    GRC_ENABLE(pmt)
-    GRC_WITH(pmt)
-
-    dnl If execution gets to here, $passed will be:
-    dnl   with : if the --with code didn't error out
-    dnl   yes  : if the --enable code passed muster and all dependencies are met
-    dnl   no   : otherwise
-    if test $passed = yes; then
-       dnl Don't do pmt if guile not available
-       GRC_CHECK_GUILE(pmt)
-    fi
-    if test $passed != with; then
-       dnl how and where to find INCLUDES and LA
-       pmt_INCLUDES="-I\${abs_top_srcdir}/pmt/src/lib"
-        pmt_LA="\${abs_top_builddir}/pmt/src/lib/libpmt.la"
-    fi
-
-    AC_CONFIG_FILES([\
-        pmt/Makefile \
-        pmt/pmt.pc \
-        pmt/doc/Makefile \
-        pmt/src/Makefile \
-        pmt/src/lib/Makefile \
-        pmt/src/scheme/Makefile \
-        pmt/src/scheme/gnuradio/Makefile \
-    ])
-
-    GRC_BUILD_CONDITIONAL(pmt,[
-        dnl run_tests is created from run_tests.in.  Make it executable.
-       dnl AC_CONFIG_COMMANDS([run_tests_pmt], [chmod +x pmt/src/python/run_tests])
-    ])
-])
index 92de3e95ef090e85d698534c2bc76b631d64653a..25b1830277ba115f811d7c780e671ff41883d741 100644 (file)
@@ -335,8 +335,7 @@ GRC_GRUEL                       dnl must come first
 GRC_OMNITHREAD                 dnl must come before gnuradio-core and mblock
 GRC_GCELL
 GRC_GNURADIO_CORE
-GRC_PMT
-GRC_MBLOCK                     dnl this must come after GRC_PMT
+GRC_MBLOCK                     dnl this must come after GRC_GRUEL
 GRC_USRP
 GRC_USRP2
 GRC_GR_USRP                    dnl this must come after GRC_USRP
index 1f08f470aaaf1ec31322bb2a5235c29a36ae0e2b..9cfd66a6bbe7b13af03c6f8c4915bc3afa535ce4 100644 (file)
@@ -7,7 +7,7 @@ Section: comm
 Priority: optional
 Maintainer: Johnathan Corgan <jcorgan@corganenterprises.com>
 Build-Conflicts: automake1.8, automake1.9
-Build-Depends: debhelper (>= 5.0.38), build-essential, python-central (>=0.5.6), automake, libtool, pkg-config, python-dev (>=2.6), python-dev (<2.7), swig, fftw3-dev | libfftw3-dev, libcppunit-dev, libboost1.37-dev | libboost1.35-dev, libgsl0-dev, guile-1.8, libasound2-dev, python-wxgtk2.8, python-numpy, doxygen, xmlto, sdcc-nf, libusb-dev, libjack-dev, portaudio19-dev, libsdl1.2-dev, python-cheetah, python-lxml, python-gtk2, libqt4-dev, libqwt5-qt4-dev, libqwtplot3d-qt4-dev, libblas-dev, texlive-latex-base
+Build-Depends: debhelper (>= 5.0.38), build-essential, python-central (>=0.5.6), automake, libtool, pkg-config, python-dev (>=2.6), python-dev (<2.7), swig, fftw3-dev | libfftw3-dev, libcppunit-dev, libboost1.37-dev, libgsl0-dev, guile-1.8, libasound2-dev, python-wxgtk2.8, python-numpy, doxygen, xmlto, sdcc-nf, libusb-dev, libjack-dev, portaudio19-dev, libsdl1.2-dev, python-cheetah, python-lxml, python-gtk2, libqt4-dev, libqwt5-qt4-dev, libqwtplot3d-qt4-dev, libblas-dev, texlive-latex-base
 Standards-Version: 3.7.2
 XS-Python-Version: =2.6
 
@@ -19,6 +19,8 @@ Package: libgruel
 Section: libs
 Architecture: any
 Depends: ${shlibs:Depends}
+Replaces: libpmt
+Conflicts: libpmt
 Description: GNU Radio Utility Etcetera Library
  This package implements a variety of low-level utility
  routines for GNU Radio.
@@ -26,7 +28,9 @@ Description: GNU Radio Utility Etcetera Library
 Package: libgruel-dev
 Section: libdevel
 Architecture: any
-Depends: libgruel (= ${binary:Version})
+Depends: libgruel (= ${binary:Version}), libboost1.37-dev, guile-1.8
+Replaces: libpmt-dev
+Conflicts: libpmt-dev
 Description: GNU Radio Utility Etcetera Library
  This package implements a variety of low-level utility
  routines for GNU Radio.
@@ -55,30 +59,6 @@ Description: GNU Radio Omnithreads Abstraction Library
  .
  This package contains header files needed by developers.
 
-Package: libpmt
-Section: libs
-Architecture: any
-Replaces: libpmt0c2a
-Conflicts: libpmt0c2a
-Depends: libgnuradio-omnithread (= ${binary:Version}), ${shlibs:Depends}
-Description: GNU Radio Polymorphic Type Library
- This package implements polymorphic types.  These are similar 
- to lisp or Python data objects, and implement transparent
- reference counting using the boost shared_ptr templates.
-
-Package: libpmt-dev
-Section: libdevel
-Architecture: any
-Replaces: libpmt0-dev
-Conflicts: libpmt0-dev
-Depends: libpmt (= ${binary:Version}), libboost-thread1.37-dev
-Description: GNU Radio Polymorphic Type Library
- This package implements polymorphic types.  These are similar 
- to lisp or Python data objects, and implement transparent
- reference counting using the boost shared_ptr templates.
- .
- This package contains header files needed by developers.
-
 ################################################################################
 # C++ M-Block library packages                                                 #
 ################################################################################
@@ -88,7 +68,7 @@ Section: libs
 Architecture: any
 Replaces: libmblock0c2a
 Conflicts: libmblock0c2a
-Depends: libpmt (= ${binary:Version}), libgnuradio-omnithread (= ${binary:Version}), ${shlibs:Depends}, guile-1.8
+Depends: libpmt (= ${binary:Version}), libgnuradio-omnithread (= ${binary:Version}), libgruel (= ${binary:Version}), ${shlibs:Depends}
 Description: GNU Radio Message Block Library 
  This package provides the GNU Radio message block library. 
 
@@ -97,7 +77,7 @@ Section: libdevel
 Architecture: any
 Replaces: libmblock0-dev
 Conflicts: libmblock0-dev
-Depends: libmblock (= ${binary:Version}), libgnuradio-omnithread-dev (= ${binary:Version}), libpmt-dev (= ${binary:Version})
+Depends: libmblock (= ${binary:Version}), libgnuradio-omnithread-dev (= ${binary:Version}), libgruel-dev (= ${binary:Version})
 Description: GNU Radio Message Block Library
  This package provides the GNU Radio message block library.
  .
diff --git a/debian/libpmt-dev.install b/debian/libpmt-dev.install
deleted file mode 100644 (file)
index 8b30e6e..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-usr/include/pmt.h
-usr/include/pmt_pool.h
-usr/include/pmt_serial_tags.h
-usr/lib/libpmt.so
-usr/lib/pkgconfig/pmt.pc
diff --git a/debian/libpmt.install b/debian/libpmt.install
deleted file mode 100644 (file)
index c6f0ba6..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-usr/lib/libpmt.la
-usr/lib/libpmt.so.*
index 90c0f88bdd2b142b1a6be8732498f502be80c2ad..71bdd85732b0878a8193cddbb315b581b3b041f0 100644 (file)
@@ -19,4 +19,5 @@
 # Boston, MA 02110-1301, USA.
 # 
 
-SUBDIRS = include lib
+SUBDIRS = lib include scheme
+
index 648d53e2050d37cd2e9d9906035a65eb475adb34..d7354b87172c69eb5e2f939d327ace0b87ec8d6d 100644 (file)
@@ -1,5 +1,5 @@
 #
-# Copyright 2008 Free Software Foundation, Inc.
+# Copyright 2008,2009 Free Software Foundation, Inc.
 # 
 # This file is part of GNU Radio
 # 
@@ -28,6 +28,9 @@ gruelincludedir = $(prefix)/include/gruel
 
 gruelinclude_HEADERS = \
        $(BUILT_SOURCES) \
+       pmt.h \
+       pmt_pool.h \
+       pmt_serial_tags.h \
        realtime.h \
        sys_pri.h \
        thread_body_wrapper.h \
diff --git a/gruel/src/include/gruel/pmt.h b/gruel/src/include/gruel/pmt.h
new file mode 100644 (file)
index 0000000..6dc4508
--- /dev/null
@@ -0,0 +1,682 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006,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 GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_PMT_H
+#define INCLUDED_PMT_H
+
+#include <boost/shared_ptr.hpp>
+#include <boost/any.hpp>
+#include <complex>
+#include <string>
+#include <stdint.h>
+#include <iosfwd>
+#include <stdexcept>
+
+/*!
+ * This file defines a polymorphic type and the operations on it.
+ *
+ * It draws heavily on the idea of scheme and lisp data types.
+ * The interface parallels that in Guile 1.8, with the notable
+ * exception that these objects are transparently reference counted.
+ */
+
+namespace gruel {
+
+/*!
+ * \brief base class of all pmt types
+ */
+class pmt_base;
+/*!
+ * \brief typedef for shared pointer (transparent reference counting).
+ * See http://www.boost.org/libs/smart_ptr/smart_ptr.htm
+ */
+typedef boost::shared_ptr<pmt_base> pmt_t;
+
+
+class pmt_exception : public std::logic_error
+{
+public:
+  pmt_exception(const std::string &msg, pmt_t obj);
+};
+
+class pmt_wrong_type : public pmt_exception
+{
+public:
+  pmt_wrong_type(const std::string &msg, pmt_t obj);
+};
+
+class pmt_out_of_range : public pmt_exception
+{
+public:
+  pmt_out_of_range(const std::string &msg, pmt_t obj);
+};
+
+class pmt_notimplemented : public pmt_exception
+{
+public:
+  pmt_notimplemented(const std::string &msg, pmt_t obj);
+};
+
+/*
+ * ------------------------------------------------------------------------
+ * Booleans.  Two constants, #t and #f.
+ *
+ * In predicates, anything that is not #f is considered true.
+ * I.e., there is a single false value, #f.
+ * ------------------------------------------------------------------------
+ */
+extern const pmt_t PMT_T;      //< \#t : boolean true constant
+extern const pmt_t PMT_F;      //< \#f : boolean false constant
+
+//! Return true if obj is \#t or \#f, else return false.
+bool pmt_is_bool(pmt_t obj);
+
+//! Return false if obj is \#f, else return true.
+bool pmt_is_true(pmt_t obj);
+
+//! Return true if obj is \#f, else return true.
+bool pmt_is_false(pmt_t obj);
+
+//! Return \#f is val is false, else return \#t.
+pmt_t pmt_from_bool(bool val);
+
+//! Return true if val is PMT_T, return false when val is PMT_F, 
+// else raise wrong_type exception.
+bool pmt_to_bool(pmt_t val);
+
+/*
+ * ------------------------------------------------------------------------
+ *                            Symbols
+ * ------------------------------------------------------------------------
+ */
+
+//! Return true if obj is a symbol, else false.
+bool pmt_is_symbol(const pmt_t& obj);
+
+//! Return the symbol whose name is \p s.
+pmt_t pmt_string_to_symbol(const std::string &s);
+
+//! Alias for pmt_string_to_symbol
+pmt_t pmt_intern(const std::string &s);
+
+
+/*!
+ * If \p is a symbol, return the name of the symbol as a string.
+ * Otherwise, raise the wrong_type exception.
+ */
+const std::string pmt_symbol_to_string(const pmt_t& sym);
+
+/*
+ * ------------------------------------------------------------------------
+ *           Numbers: we support integer, real and complex
+ * ------------------------------------------------------------------------
+ */
+
+//! Return true if obj is any kind of number, else false.
+bool pmt_is_number(pmt_t obj);
+
+/*
+ * ------------------------------------------------------------------------
+ *                            Integers
+ * ------------------------------------------------------------------------
+ */
+
+//! Return true if \p x is an integer number, else false
+bool pmt_is_integer(pmt_t x);
+
+//! Return the pmt value that represents the integer \p x.
+pmt_t pmt_from_long(long x);
+
+/*!
+ * \brief Convert pmt to long if possible.
+ *
+ * When \p x represents an exact integer that fits in a long,
+ * return that integer.  Else raise an exception, either wrong_type
+ * when x is not an exact integer, or out_of_range when it doesn't fit.
+ */
+long pmt_to_long(pmt_t x);
+
+/*
+ * ------------------------------------------------------------------------
+ *                             Reals
+ * ------------------------------------------------------------------------
+ */
+
+/*
+ * \brief Return true if \p obj is a real number, else false.
+ */
+bool pmt_is_real(pmt_t obj);
+
+//! Return the pmt value that represents double \p x.
+pmt_t pmt_from_double(double x);
+
+/*!
+ * \brief Convert pmt to double if possible.
+ *
+ * Returns the number closest to \p val that is representable
+ * as a double.  The argument \p val must be a real or integer, otherwise
+ * a wrong_type exception is raised.
+ */
+double pmt_to_double(pmt_t x);
+
+/*
+ * ------------------------------------------------------------------------
+ *                            Complex
+ * ------------------------------------------------------------------------
+ */
+
+/*!
+ * \brief return true if \p obj is a complex number, false otherwise.
+ */
+bool pmt_is_complex(pmt_t obj);
+
+//! Return a complex number constructed of the given real and imaginary parts.
+pmt_t pmt_make_rectangular(double re, double im);
+
+/*!
+ * If \p z is complex, real or integer, return the closest complex<double>.
+ * Otherwise, raise the wrong_type exception.
+ */
+std::complex<double> pmt_to_complex(pmt_t z);
+
+/*
+ * ------------------------------------------------------------------------
+ *                             Pairs
+ * ------------------------------------------------------------------------
+ */
+
+extern const pmt_t PMT_NIL;    //< the empty list
+
+//! Return true if \p x is the empty list, otherwise return false.
+bool pmt_is_null(const pmt_t& x);
+
+//! Return true if \p obj is a pair, else false.
+bool pmt_is_pair(const pmt_t& obj);
+
+//! Return a newly allocated pair whose car is \p x and whose cdr is \p y.
+pmt_t pmt_cons(const pmt_t& x, const pmt_t& y);
+
+//! If \p pair is a pair, return the car of the \p pair, otherwise raise wrong_type.
+pmt_t pmt_car(const pmt_t& pair);
+
+//! If \p pair is a pair, return the cdr of the \p pair, otherwise raise wrong_type.
+pmt_t pmt_cdr(const pmt_t& pair);
+
+//! Stores \p value in the car field of \p pair.
+void pmt_set_car(pmt_t pair, pmt_t value);
+
+//! Stores \p value in the cdr field of \p pair.
+void pmt_set_cdr(pmt_t pair, pmt_t value);
+
+pmt_t pmt_caar(pmt_t pair);
+pmt_t pmt_cadr(pmt_t pair);
+pmt_t pmt_cdar(pmt_t pair);
+pmt_t pmt_cddr(pmt_t pair);
+pmt_t pmt_caddr(pmt_t pair);
+pmt_t pmt_cadddr(pmt_t pair);
+
+/*
+ * ------------------------------------------------------------------------
+ *                            Vectors
+ *
+ * These vectors can hold any kind of objects.  Indexing is zero based.
+ * ------------------------------------------------------------------------
+ */
+
+//! Return true if \p x is a vector, othewise false.
+bool pmt_is_vector(pmt_t x);
+
+//! Make a vector of length \p k, with initial values set to \p fill
+pmt_t pmt_make_vector(size_t k, pmt_t fill);
+
+/*!
+ * Return the contents of position \p k of \p vector.
+ * \p k must be a valid index of \p vector.
+ */
+pmt_t pmt_vector_ref(pmt_t vector, size_t k);
+
+//! Store \p obj in position \p k.
+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);
+
+/*!
+ * <pre>
+ * ------------------------------------------------------------------------
+ *                    Uniform Numeric Vectors
+ *
+ * A uniform numeric vector is a vector whose elements are all of single
+ * numeric type.  pmt offers uniform numeric vectors for signed and
+ * unsigned 8-bit, 16-bit, 32-bit, and 64-bit integers, two sizes of
+ * floating point values, and complex floating-point numbers of these
+ * two sizes.  Indexing is zero based.
+ *
+ * The names of the functions include these tags in their names:
+ *
+ *    u8  unsigned 8-bit integers
+ *    s8  signed 8-bit integers
+ *   u16  unsigned 16-bit integers
+ *   s16  signed 16-bit integers
+ *   u32  unsigned 32-bit integers
+ *   s32  signed 32-bit integers
+ *   u64  unsigned 64-bit integers
+ *   s64  signed 64-bit integers
+ *   f32  the C++ type float
+ *   f64  the C++ type double
+ *   c32  the C++ type complex<float>
+ *   c64  the C++ type complex<double>
+ * ------------------------------------------------------------------------
+ * </pre>
+ */
+
+//! true if \p x is any kind of uniform numeric vector
+bool pmt_is_uniform_vector(pmt_t x);  
+
+bool pmt_is_u8vector(pmt_t x);
+bool pmt_is_s8vector(pmt_t x);
+bool pmt_is_u16vector(pmt_t x);
+bool pmt_is_s16vector(pmt_t x);
+bool pmt_is_u32vector(pmt_t x);
+bool pmt_is_s32vector(pmt_t x);
+bool pmt_is_u64vector(pmt_t x);
+bool pmt_is_s64vector(pmt_t x);
+bool pmt_is_f32vector(pmt_t x);
+bool pmt_is_f64vector(pmt_t x);
+bool pmt_is_c32vector(pmt_t x);
+bool pmt_is_c64vector(pmt_t x);
+
+pmt_t pmt_make_u8vector(size_t k, uint8_t fill);
+pmt_t pmt_make_s8vector(size_t k, int8_t fill);
+pmt_t pmt_make_u16vector(size_t k, uint16_t fill);
+pmt_t pmt_make_s16vector(size_t k, int16_t fill);
+pmt_t pmt_make_u32vector(size_t k, uint32_t fill);
+pmt_t pmt_make_s32vector(size_t k, int32_t fill);
+pmt_t pmt_make_u64vector(size_t k, uint64_t fill);
+pmt_t pmt_make_s64vector(size_t k, int64_t fill);
+pmt_t pmt_make_f32vector(size_t k, float fill);
+pmt_t pmt_make_f64vector(size_t k, double fill);
+pmt_t pmt_make_c32vector(size_t k, std::complex<float> fill);
+pmt_t pmt_make_c64vector(size_t k, std::complex<double> fill);
+
+pmt_t pmt_init_u8vector(size_t k, const uint8_t *data);
+pmt_t pmt_init_s8vector(size_t k, const int8_t *data);
+pmt_t pmt_init_u16vector(size_t k, const uint16_t *data);
+pmt_t pmt_init_s16vector(size_t k, const int16_t *data);
+pmt_t pmt_init_u32vector(size_t k, const uint32_t *data);
+pmt_t pmt_init_s32vector(size_t k, const int32_t *data);
+pmt_t pmt_init_u64vector(size_t k, const uint64_t *data);
+pmt_t pmt_init_s64vector(size_t k, const int64_t *data);
+pmt_t pmt_init_f32vector(size_t k, const float *data);
+pmt_t pmt_init_f64vector(size_t k, const double *data);
+pmt_t pmt_init_c32vector(size_t k, const std::complex<float> *data);
+pmt_t pmt_init_c64vector(size_t k, const std::complex<double> *data);
+
+uint8_t  pmt_u8vector_ref(pmt_t v, size_t k);
+int8_t   pmt_s8vector_ref(pmt_t v, size_t k);
+uint16_t pmt_u16vector_ref(pmt_t v, size_t k);
+int16_t  pmt_s16vector_ref(pmt_t v, size_t k);
+uint32_t pmt_u32vector_ref(pmt_t v, size_t k);
+int32_t  pmt_s32vector_ref(pmt_t v, size_t k);
+uint64_t pmt_u64vector_ref(pmt_t v, size_t k);
+int64_t  pmt_s64vector_ref(pmt_t v, size_t k);
+float    pmt_f32vector_ref(pmt_t v, size_t k);
+double   pmt_f64vector_ref(pmt_t v, size_t k);
+std::complex<float>  pmt_c32vector_ref(pmt_t v, size_t k);
+std::complex<double> pmt_c64vector_ref(pmt_t v, size_t k);
+
+void pmt_u8vector_set(pmt_t v, size_t k, uint8_t x);  //< v[k] = x
+void pmt_s8vector_set(pmt_t v, size_t k, int8_t x);
+void pmt_u16vector_set(pmt_t v, size_t k, uint16_t x);
+void pmt_s16vector_set(pmt_t v, size_t k, int16_t x);
+void pmt_u32vector_set(pmt_t v, size_t k, uint32_t x);
+void pmt_s32vector_set(pmt_t v, size_t k, int32_t x);
+void pmt_u64vector_set(pmt_t v, size_t k, uint64_t x);
+void pmt_s64vector_set(pmt_t v, size_t k, int64_t x);
+void pmt_f32vector_set(pmt_t v, size_t k, float x);
+void pmt_f64vector_set(pmt_t v, size_t k, double x);
+void pmt_c32vector_set(pmt_t v, size_t k, std::complex<float> x);
+void pmt_c64vector_set(pmt_t v, size_t k, std::complex<double> x);
+
+// Return const pointers to the elements
+
+const void *pmt_uniform_vector_elements(pmt_t v, size_t &len);  //< works with any; len is in bytes
+
+const uint8_t  *pmt_u8vector_elements(pmt_t v, size_t &len);  //< len is in elements
+const int8_t   *pmt_s8vector_elements(pmt_t v, size_t &len);  //< len is in elements
+const uint16_t *pmt_u16vector_elements(pmt_t v, size_t &len); //< len is in elements
+const int16_t  *pmt_s16vector_elements(pmt_t v, size_t &len); //< len is in elements
+const uint32_t *pmt_u32vector_elements(pmt_t v, size_t &len); //< len is in elements
+const int32_t  *pmt_s32vector_elements(pmt_t v, size_t &len); //< len is in elements
+const uint64_t *pmt_u64vector_elements(pmt_t v, size_t &len); //< len is in elements
+const int64_t  *pmt_s64vector_elements(pmt_t v, size_t &len); //< len is in elements
+const float    *pmt_f32vector_elements(pmt_t v, size_t &len); //< len is in elements
+const double   *pmt_f64vector_elements(pmt_t v, size_t &len); //< len is in elements
+const std::complex<float>  *pmt_c32vector_elements(pmt_t v, size_t &len); //< len is in elements
+const std::complex<double> *pmt_c64vector_elements(pmt_t v, size_t &len); //< len is in elements
+
+// Return non-const pointers to the elements
+
+void *pmt_uniform_vector_writable_elements(pmt_t v, size_t &len);  //< works with any; len is in bytes
+
+uint8_t  *pmt_u8vector_writable_elements(pmt_t v, size_t &len);  //< len is in elements
+int8_t   *pmt_s8vector_writable_elements(pmt_t v, size_t &len);  //< len is in elements
+uint16_t *pmt_u16vector_writable_elements(pmt_t v, size_t &len); //< len is in elements
+int16_t  *pmt_s16vector_writable_elements(pmt_t v, size_t &len); //< len is in elements
+uint32_t *pmt_u32vector_writable_elements(pmt_t v, size_t &len); //< len is in elements
+int32_t  *pmt_s32vector_writable_elements(pmt_t v, size_t &len); //< len is in elements
+uint64_t *pmt_u64vector_writable_elements(pmt_t v, size_t &len); //< len is in elements
+int64_t  *pmt_s64vector_writable_elements(pmt_t v, size_t &len); //< len is in elements
+float    *pmt_f32vector_writable_elements(pmt_t v, size_t &len); //< len is in elements
+double   *pmt_f64vector_writable_elements(pmt_t v, size_t &len); //< len is in elements
+std::complex<float>  *pmt_c32vector_writable_elements(pmt_t v, size_t &len); //< len is in elements
+std::complex<double> *pmt_c64vector_writable_elements(pmt_t v, size_t &len); //< len is in elements
+
+/*
+ * ------------------------------------------------------------------------
+ *        Dictionary (a.k.a associative array, hash, map)
+ * ------------------------------------------------------------------------
+ */
+
+//! Return true if \p obj is a dictionary
+bool pmt_is_dict(pmt_t obj);
+
+//! make an empty dictionary
+pmt_t pmt_make_dict();
+
+//! dict[key] = value
+void  pmt_dict_set(pmt_t dict, pmt_t key, pmt_t value);
+
+//! Return true if \p key exists in \p dict
+bool  pmt_dict_has_key(pmt_t dict, pmt_t key);
+
+//! If \p key exists in \p dict, return associated value; otherwise return \p not_found.
+pmt_t pmt_dict_ref(pmt_t dict, pmt_t key, pmt_t not_found);
+
+//! Return list of (key . value) pairs
+pmt_t pmt_dict_items(pmt_t dict);
+
+//! Return list of keys
+pmt_t pmt_dict_keys(pmt_t dict);
+
+//! Return list of values
+pmt_t pmt_dict_values(pmt_t dict);
+
+/*
+ * ------------------------------------------------------------------------
+ *   Any (wraps boost::any -- can be used to wrap pretty much anything)
+ *
+ * Cannot be serialized or used across process boundaries.
+ * See http://www.boost.org/doc/html/any.html
+ * ------------------------------------------------------------------------
+ */
+
+//! Return true if \p obj is an any
+bool pmt_is_any(pmt_t obj);
+
+//! make an any
+pmt_t pmt_make_any(const boost::any &any);
+
+//! Return underlying boost::any
+boost::any pmt_any_ref(pmt_t obj);
+
+//! Store \p any in \p obj
+void pmt_any_set(pmt_t obj, const boost::any &any);
+
+
+/*
+ * ------------------------------------------------------------------------
+ *                       General functions
+ * ------------------------------------------------------------------------
+ */
+
+//! Return true if x and y are the same object; otherwise return false.
+bool pmt_eq(const pmt_t& x, const pmt_t& y);
+
+/*!
+ * \brief Return true if x and y should normally be regarded as the same object, else false.
+ *
+ * <pre>
+ * eqv returns true if:
+ *   x and y are the same object.
+ *   x and y are both \#t or both \#f.
+ *   x and y are both symbols and their names are the same.
+ *   x and y are both numbers, and are numerically equal.
+ *   x and y are both the empty list (nil).
+ *   x and y are pairs or vectors that denote same location in store.
+ * </pre>
+ */
+bool pmt_eqv(const pmt_t& x, const pmt_t& y);
+
+/*!
+ * pmt_equal recursively compares the contents of pairs and vectors,
+ * applying pmt_eqv on other objects such as numbers and symbols.  
+ * pmt_equal may fail to terminate if its arguments are circular data
+ * structures.
+ */
+bool pmt_equal(const pmt_t& x, const pmt_t& y);
+
+
+//! Return the number of elements in v
+size_t pmt_length(const pmt_t& v);
+
+/*!
+ * \brief Find the first pair in \p alist whose car field is \p obj
+ *  and return that pair.
+ *
+ * \p alist (for "association list") must be a list of pairs.  If no pair
+ * in \p alist has \p obj as its car then \#f is returned.
+ * Uses pmt_eq to compare \p obj with car fields of the pairs in \p alist.
+ */
+pmt_t pmt_assq(pmt_t obj, pmt_t alist);
+
+/*!
+ * \brief Find the first pair in \p alist whose car field is \p obj
+ *  and return that pair.
+ *
+ * \p alist (for "association list") must be a list of pairs.  If no pair
+ * in \p alist has \p obj as its car then \#f is returned.
+ * Uses pmt_eqv to compare \p obj with car fields of the pairs in \p alist.
+ */
+pmt_t pmt_assv(pmt_t obj, pmt_t alist);
+
+/*!
+ * \brief Find the first pair in \p alist whose car field is \p obj
+ *  and return that pair.
+ *
+ * \p alist (for "association list") must be a list of pairs.  If no pair
+ * in \p alist has \p obj as its car then \#f is returned.
+ * Uses pmt_equal to compare \p obj with car fields of the pairs in \p alist.
+ */
+pmt_t pmt_assoc(pmt_t obj, pmt_t alist);
+
+/*!
+ * \brief Apply \p proc element-wise to the elements of list and returns
+ * a list of the results, in order.
+ *
+ * \p list must be a list.  The dynamic order in which \p proc is
+ * applied to the elements of \p list is unspecified.
+ */
+pmt_t pmt_map(pmt_t proc(const pmt_t&), pmt_t list);
+
+/*!
+ * \brief reverse \p list.
+ *
+ * \p list must be a proper list.
+ */
+pmt_t pmt_reverse(pmt_t list);
+
+/*!
+ * \brief destructively reverse \p list.
+ *
+ * \p list must be a proper list.
+ */
+pmt_t pmt_reverse_x(pmt_t list);
+
+/*!
+ * \brief (acons x y a) == (cons (cons x y) a)
+ */
+inline static pmt_t
+pmt_acons(pmt_t x, pmt_t y, pmt_t a)
+{
+  return pmt_cons(pmt_cons(x, y), a);
+}
+
+/*!
+ * \brief locates \p nth element of \n list where the car is the 'zeroth' element.
+ */
+pmt_t pmt_nth(size_t n, pmt_t list);
+
+/*!
+ * \brief returns the tail of \p list that would be obtained by calling
+ * cdr \p n times in succession.
+ */
+pmt_t pmt_nthcdr(size_t n, pmt_t list);
+
+/*!
+ * \brief Return the first sublist of \p list whose car is \p obj.
+ * If \p obj does not occur in \p list, then \#f is returned.
+ * pmt_memq use pmt_eq to compare \p obj with the elements of \p list.
+ */
+pmt_t pmt_memq(pmt_t obj, pmt_t list);
+
+/*!
+ * \brief Return the first sublist of \p list whose car is \p obj.
+ * If \p obj does not occur in \p list, then \#f is returned.
+ * pmt_memv use pmt_eqv to compare \p obj with the elements of \p list.
+ */
+pmt_t pmt_memv(pmt_t obj, pmt_t list);
+
+/*!
+ * \brief Return the first sublist of \p list whose car is \p obj.
+ * If \p obj does not occur in \p list, then \#f is returned.
+ * pmt_member use pmt_equal to compare \p obj with the elements of \p list.
+ */
+pmt_t pmt_member(pmt_t obj, pmt_t list);
+
+/*!
+ * \brief Return true if every element of \p list1 appears in \p list2, and false otherwise.
+ * Comparisons are done with pmt_eqv.
+ */
+bool pmt_subsetp(pmt_t list1, pmt_t list2);
+
+/*!
+ * \brief Return a list of length 1 containing \p x1
+ */
+pmt_t pmt_list1(const pmt_t& x1);
+
+/*!
+ * \brief Return a list of length 2 containing \p x1, \p x2
+ */
+pmt_t pmt_list2(const pmt_t& x1, const pmt_t& x2);
+
+/*!
+ * \brief Return a list of length 3 containing \p x1, \p x2, \p x3
+ */
+pmt_t pmt_list3(const pmt_t& x1, const pmt_t& x2, const pmt_t& x3);
+
+/*!
+ * \brief Return a list of length 4 containing \p x1, \p x2, \p x3, \p x4
+ */
+pmt_t pmt_list4(const pmt_t& x1, const pmt_t& x2, const pmt_t& x3, const pmt_t& x4);
+
+/*!
+ * \brief Return a list of length 5 containing \p x1, \p x2, \p x3, \p x4, \p x5
+ */
+pmt_t pmt_list5(const pmt_t& x1, const pmt_t& x2, const pmt_t& x3, const pmt_t& x4, const pmt_t& x5);
+
+/*!
+ * \brief Return a list of length 6 containing \p x1, \p x2, \p x3, \p x4, \p
+ * x5, \p x6
+ */
+pmt_t pmt_list6(const pmt_t& x1, const pmt_t& x2, const pmt_t& x3, const pmt_t& x4, const pmt_t& x5, const pmt_t& x6);
+
+/*!
+ * \brief Return \p list with \p item added to it.
+ */
+pmt_t pmt_list_add(pmt_t list, const pmt_t& item);
+
+
+/*
+ * ------------------------------------------------------------------------
+ *                          read / write
+ * ------------------------------------------------------------------------
+ */
+extern const pmt_t PMT_EOF;    //< The end of file object
+
+//! return true if obj is the EOF object, otherwise return false.
+bool pmt_is_eof_object(pmt_t obj);
+
+/*!
+ * read converts external representations of pmt objects into the
+ * objects themselves.  Read returns the next object parsable from
+ * the given input port, updating port to point to the first
+ * character past the end of the external representation of the
+ * object.
+ *
+ * If an end of file is encountered in the input before any
+ * characters are found that can begin an object, then an end of file
+ * object is returned.   The port remains open, and further attempts
+ * to read will also return an end of file object.  If an end of file
+ * is encountered after the beginning of an object's external
+ * representation, but the external representation is incomplete and
+ * therefore not parsable, an error is signaled.
+ */
+pmt_t pmt_read(std::istream &port);
+
+/*!
+ * Write a written representation of \p obj to the given \p port.
+ */
+void pmt_write(pmt_t obj, std::ostream &port);
+
+/*!
+ * Return a string representation of \p obj.
+ * This is the same output as would be generated by pmt_write.
+ */
+std::string pmt_write_string(pmt_t obj);
+
+
+std::ostream& operator<<(std::ostream &os, pmt_t obj);
+
+
+/*
+ * ------------------------------------------------------------------------
+ *                   portable byte stream representation
+ * ------------------------------------------------------------------------
+ */
+/*!
+ * \brief Write portable byte-serial representation of \p obj to \p sink
+ */
+bool pmt_serialize(pmt_t obj, std::streambuf &sink);
+
+/*!
+ * \brief Create obj from portable byte-serial representation
+ */
+pmt_t pmt_deserialize(std::streambuf &source);
+
+
+void pmt_dump_sizeof();        // debugging
+
+} /* namespace gruel */
+
+#endif /* INCLUDED_PMT_H */
diff --git a/gruel/src/include/gruel/pmt_pool.h b/gruel/src/include/gruel/pmt_pool.h
new file mode 100644 (file)
index 0000000..18b498f
--- /dev/null
@@ -0,0 +1,72 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007,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_PMT_POOL_H
+#define INCLUDED_PMT_POOL_H
+
+#include <cstddef>
+#include <vector>
+#include <boost/thread.hpp>
+
+namespace gruel {
+
+/*!
+ * \brief very simple thread-safe fixed-size allocation pool
+ *
+ * FIXME may want to go to global allocation with per-thread free list.
+ * This would eliminate virtually all lock contention.
+ */
+class pmt_pool {
+
+  struct item {
+    struct item        *d_next;
+  };
+  
+  typedef boost::unique_lock<boost::mutex>  scoped_lock;
+  mutable boost::mutex                 d_mutex;
+  boost::condition_variable    d_cond;
+  
+  size_t             d_itemsize;
+  size_t             d_alignment;
+  size_t             d_allocation_size;
+  size_t             d_max_items;
+  size_t             d_n_items;
+  item              *d_freelist;
+  std::vector<char *> d_allocations;
+
+public:
+  /*!
+   * \param itemsize size in bytes of the items to be allocated.
+   * \param alignment alignment in bytes of all objects to be allocated (must be power-of-2).
+   * \param allocation_size number of bytes to allocate at a time from the underlying allocator.
+   * \param max_items is the maximum number of items to allocate.  If this number is exceeded,
+   *         the allocate blocks.  0 implies no limit.
+   */
+  pmt_pool(size_t itemsize, size_t alignment = 16,
+          size_t allocation_size = 4096, size_t max_items = 0);
+  ~pmt_pool();
+
+  void *malloc();
+  void free(void *p);
+};
+
+} /* namespace gruel */
+
+#endif /* INCLUDED_PMT_POOL_H */
index c2a008e48ac56cf160155583a223914541dc78a8..2a968d25f2a6c661a315db3d2dc6bc663e614b19 100644 (file)
@@ -1,5 +1,5 @@
 #
-# Copyright 2008 Free Software Foundation, Inc.
+# Copyright 2008,2009 Free Software Foundation, Inc.
 # 
 # This file is part of GNU Radio
 # 
 
 include $(top_srcdir)/Makefile.common
 
-AM_CPPFLAGS = $(DEFINES) $(BOOST_CPPFLAGS) $(GRUEL_INCLUDES) $(WITH_INCLUDES)
+AM_CPPFLAGS = $(DEFINES) $(BOOST_CPPFLAGS) $(CPPUNIT_INCLUDES) $(GRUEL_INCLUDES) $(WITH_INCLUDES)
+
+TESTS = test_pmt
 
 lib_LTLIBRARIES = libgruel.la
 
 # magic flags
 libgruel_la_LDFLAGS = $(NO_UNDEFINED) $(BOOST_LDFLAGS) -version-info 0:0:0
 
+# ----------------------------------------------------------------
+# these scripts generate code
+
+code_generator =                       \
+       generate_unv.py                 \
+       unv_template.h.t                \
+       unv_template.cc.t               \
+       unv_qa_template.cc.t            
+
+GENERATED_H =                          \
+       pmt_unv_int.h                   \
+       qa_pmt_unv.h                    
+
+GENERATED_CC =                         \
+       pmt_unv.cc                      \
+       qa_pmt_unv.cc                   
+
+python_built_sources = $(GENERATED_H) $(GENERATED_CC)
+
+PMT_SERIAL_TAGS_H = $(abs_top_builddir)/gruel/src/include/gruel/pmt_serial_tags.h
+BUILT_SOURCES = $(python_built_sources) $(PMT_SERIAL_TAGS_H)
+
+EXTRA_DIST = $(code_generator)
+
+# ----------------------------------------------------------------
+
 # These are the source files that go into the gruel shared library
-libgruel_la_SOURCES = \
-       realtime.cc \
-       sys_pri.cc \
-       thread_body_wrapper.cc \
+libgruel_la_SOURCES =                  \
+       pmt.cc                          \
+       pmt_io.cc                       \
+       pmt_pool.cc                     \
+       pmt_serialize.cc                \
+       pmt_unv.cc                      \
+       realtime.cc                     \
+       sys_pri.cc                      \
+       thread_body_wrapper.cc          \
        thread_group.cc
 
-libgruel_la_LIBADD = \
-       $(BOOST_THREAD_LIB)
+libgruel_la_LIBADD =                   \
+       $(BOOST_THREAD_LIB)             \
+       -lstdc++
+
+noinst_HEADERS = \
+       $(GENERATED_H)                  \
+       pmt_int.h                       \
+       qa_pmt.h                        \
+       qa_pmt_prims.h
+
+# Build the qa code into its own library
+
+noinst_LTLIBRARIES = libpmt-qa.la
+
+libpmt_qa_la_SOURCES =                 \
+       qa_pmt.cc                       \
+       qa_pmt_prims.cc                 \
+       qa_pmt_unv.cc                   
+
+# magic flags
+libpmt_qa_la_LDFLAGS = $(NO_UNDEFINED) -avoid version
+
+libpmt_qa_la_LIBADD =                  \
+       libgruel.la                     \
+       $(CPPUNIT_LIBS)                 \
+       -lstdc++                        
+
+noinst_PROGRAMS        =                       \
+       test_pmt
+
+
+LIBGRUEL = libgruel.la
+LIBPMTQA = libpmt-qa.la $(LIBGRUEL)
+
+test_pmt_SOURCES = test_pmt.cc
+test_pmt_LDADD   = $(LIBPMTQA)
+
+# Do creation and inclusion of other Makefiles last
+
+# common way for generating sources from templates when using
+# BUILT_SOURCES, using parallel build protection.
+gen_sources = $(python_built_sources)
+gen_sources_deps = $(core_generator)
+par_gen_command = PYTHONPATH=$(top_srcdir)/gruel/src/lib srcdir=$(srcdir) $(PYTHON) $(srcdir)/generate_unv.py
+include $(top_srcdir)/Makefile.par.gen
 
-noinst_HEADERS =
+# Rule to create the build header file using GUILE
+# Doesn't need parallel protections because there is a single target
+$(PMT_SERIAL_TAGS_H): $(srcdir)/../scheme/gnuradio/gen-serial-tags.scm $(srcdir)/../scheme/gnuradio/pmt-serial-tags.scm
+       $(RUN_GUILE) $(srcdir)/../scheme/gnuradio/gen-serial-tags.scm $(srcdir)/../scheme/gnuradio/pmt-serial-tags.scm $(PMT_SERIAL_TAGS_H)
diff --git a/gruel/src/lib/generate_unv.py b/gruel/src/lib/generate_unv.py
new file mode 100755 (executable)
index 0000000..3a7305b
--- /dev/null
@@ -0,0 +1,190 @@
+#!/usr/bin/env python
+#
+# Copyright 2006 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 GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+# 
+
+"""
+Generate code for uniform numeric vectors
+"""
+
+import re, os, os.path
+
+
+unv_types = (
+    ('u8', 'uint8_t'),
+    ('s8', 'int8_t'),
+    ('u16', 'uint16_t'),
+    ('s16', 'int16_t'),
+    ('u32', 'uint32_t'),
+    ('s32', 'int32_t'),
+    ('u64', 'uint64_t'),
+    ('s64', 'int64_t'),
+    ('f32', 'float'),
+    ('f64', 'double'),
+    ('c32', 'std::complex<float>'),
+    ('c64', 'std::complex<double>')
+    )
+
+header = """\
+/* -*- c++ -*- */
+/*
+ * Copyright 2006,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 GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+"""
+
+guard_tail = """
+#endif
+"""
+
+includes = """
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <vector>
+#include <gruel/pmt.h>
+#include "pmt_int.h"
+"""
+
+qa_includes = """
+#include <qa_pmt_unv.h>
+#include <cppunit/TestAssert.h>
+#include <gruel/pmt.h>
+#include <stdio.h>
+
+using namespace gruel;
+"""
+
+
+# set srcdir to the directory that contains Makefile.am
+try:
+    srcdir = os.environ['srcdir']
+except KeyError, e:
+    srcdir = "."
+srcdir = srcdir + '/'
+
+
+def open_src (name, mode):
+    global srcdir
+    return open(os.path.join (srcdir, name), mode)
+
+
+def guard_name(filename):
+    return 'INCLUDED_' + re.sub('\.', '_', filename.upper())
+
+def guard_head(filename):
+    guard = guard_name(filename)
+    return """
+#ifndef %s
+#define %s
+""" % (guard, guard)
+
+
+def do_substitution (d, input, out_file):
+    def repl (match_obj):
+        key = match_obj.group (1)
+        # print key
+        return d[key]
+    
+    out = re.sub (r"@([a-zA-Z0-9_]+)@", repl, input)
+    out_file.write (out)
+
+
+def generate_h():
+    template = open_src('unv_template.h.t', 'r').read()
+    output_filename = 'pmt_unv_int.h'
+    output = open(output_filename, 'w')
+    output.write(header)
+    output.write(guard_head(output_filename))
+    for tag, typ in unv_types:
+        d = { 'TAG' : tag, 'TYPE' : typ }
+        do_substitution(d, template, output)
+    output.write(guard_tail)
+
+def generate_cc():
+    template = open_src('unv_template.cc.t', 'r').read()
+    output = open('pmt_unv.cc', 'w')
+    output.write(header)
+    output.write(includes)
+    for tag, typ in unv_types:
+        d = { 'TAG' : tag, 'TYPE' : typ }
+        do_substitution(d, template, output)
+
+
+def generate_qa_h():
+    output_filename = 'qa_pmt_unv.h'
+    output = open(output_filename, 'w')
+    output.write(header)
+    output.write(guard_head(output_filename))
+
+    output.write('''
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/TestCase.h>
+
+class qa_pmt_unv : public CppUnit::TestCase {
+
+  CPPUNIT_TEST_SUITE(qa_pmt_unv);
+''')
+    for tag, typ in unv_types:
+        output.write('  CPPUNIT_TEST(test_%svector);\n' % (tag,))
+    output.write('''\
+  CPPUNIT_TEST_SUITE_END();
+
+ private:
+''')     
+    for tag, typ in unv_types:
+        output.write('  void test_%svector();\n' % (tag,))
+    output.write('};\n')
+    output.write(guard_tail)
+
+def generate_qa_cc():
+    template = open_src('unv_qa_template.cc.t', 'r').read()
+    output = open('qa_pmt_unv.cc', 'w')
+    output.write(header)
+    output.write(qa_includes)
+    for tag, typ in unv_types:
+        d = { 'TAG' : tag, 'TYPE' : typ }
+        do_substitution(d, template, output)
+    
+
+def main():
+    generate_h()
+    generate_cc()
+    generate_qa_h()
+    generate_qa_cc()
+
+if __name__ == '__main__':
+    main()
diff --git a/gruel/src/lib/pmt.cc b/gruel/src/lib/pmt.cc
new file mode 100644 (file)
index 0000000..8e0c016
--- /dev/null
@@ -0,0 +1,1041 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006 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 GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <vector>
+#include <gruel/pmt.h>
+#include "pmt_int.h"
+#include <stdio.h>
+#include <gruel/pmt_pool.h>
+#include <string.h>
+
+namespace gruel {
+
+static const int CACHE_LINE_SIZE = 64;         // good guess
+
+# if (PMT_LOCAL_ALLOCATOR)
+
+static pmt_pool global_pmt_pool(sizeof(pmt_pair), CACHE_LINE_SIZE);
+
+void *
+pmt_base::operator new(size_t size)
+{
+  void *p = global_pmt_pool.malloc();
+
+  // fprintf(stderr, "pmt_base::new p = %p\n", p);
+  assert((reinterpret_cast<intptr_t>(p) & (CACHE_LINE_SIZE - 1)) == 0);
+  return p;
+}
+
+void
+pmt_base::operator delete(void *p, size_t size)
+{
+  global_pmt_pool.free(p);
+}
+
+#endif
+
+
+pmt_base::~pmt_base()
+{
+  // nop -- out of line virtual destructor
+}
+
+////////////////////////////////////////////////////////////////////////////
+//                         Exceptions
+////////////////////////////////////////////////////////////////////////////
+
+pmt_exception::pmt_exception(const std::string &msg, pmt_t obj)
+  : logic_error(msg + ": " + pmt_write_string(obj))
+{
+}
+
+pmt_wrong_type::pmt_wrong_type(const std::string &msg, pmt_t obj)
+  : pmt_exception(msg + ": wrong_type ", obj)
+{
+}
+
+pmt_out_of_range::pmt_out_of_range(const std::string &msg, pmt_t obj)
+  : pmt_exception(msg + ": out of range ", obj)
+{
+}
+
+pmt_notimplemented::pmt_notimplemented(const std::string &msg, pmt_t obj)
+  : pmt_exception(msg + ": notimplemented ", obj)
+{
+}
+
+////////////////////////////////////////////////////////////////////////////
+//                          Dynamic Casts
+////////////////////////////////////////////////////////////////////////////
+
+static pmt_symbol *
+_symbol(pmt_t x)
+{
+  return dynamic_cast<pmt_symbol*>(x.get());
+}
+
+static pmt_integer *
+_integer(pmt_t x)
+{
+  return dynamic_cast<pmt_integer*>(x.get());
+}
+
+static pmt_real *
+_real(pmt_t x)
+{
+  return dynamic_cast<pmt_real*>(x.get());
+}
+
+static pmt_complex *
+_complex(pmt_t x)
+{
+  return dynamic_cast<pmt_complex*>(x.get());
+}
+
+static pmt_pair *
+_pair(pmt_t x)
+{
+  return dynamic_cast<pmt_pair*>(x.get());
+}
+
+static pmt_vector *
+_vector(pmt_t x)
+{
+  return dynamic_cast<pmt_vector*>(x.get());
+}
+
+static pmt_uniform_vector *
+_uniform_vector(pmt_t x)
+{
+  return dynamic_cast<pmt_uniform_vector*>(x.get());
+}
+
+static pmt_dict *
+_dict(pmt_t x)
+{
+  return dynamic_cast<pmt_dict*>(x.get());
+}
+
+static pmt_any *
+_any(pmt_t x)
+{
+  return dynamic_cast<pmt_any*>(x.get());
+}
+
+////////////////////////////////////////////////////////////////////////////
+//                           Globals
+////////////////////////////////////////////////////////////////////////////
+
+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 = pmt_cons(PMT_NIL, PMT_NIL);      // singleton
+
+////////////////////////////////////////////////////////////////////////////
+//                           Booleans
+////////////////////////////////////////////////////////////////////////////
+
+pmt_bool::pmt_bool(){}
+
+bool
+pmt_is_true(pmt_t obj)
+{
+  return obj != PMT_F;
+}
+
+bool
+pmt_is_false(pmt_t obj)
+{
+  return obj == PMT_F;
+}
+
+bool
+pmt_is_bool(pmt_t obj)
+{
+  return obj->is_bool();
+}
+
+pmt_t
+pmt_from_bool(bool val)
+{
+  return val ? PMT_T : PMT_F;
+}
+
+bool
+pmt_to_bool(pmt_t val)
+{
+  if (val == PMT_T)
+    return true;
+  if (val == PMT_F)
+    return false;
+  throw pmt_wrong_type("pmt_to_bool", val);
+}
+
+////////////////////////////////////////////////////////////////////////////
+//                             Symbols
+////////////////////////////////////////////////////////////////////////////
+
+static const unsigned int SYMBOL_HASH_TABLE_SIZE = 701;
+static std::vector<pmt_t> s_symbol_hash_table(SYMBOL_HASH_TABLE_SIZE);
+
+pmt_symbol::pmt_symbol(const std::string &name) : d_name(name){}
+
+
+static unsigned int
+hash_string(const std::string &s)
+{
+  unsigned int h = 0;
+  unsigned int g = 0;
+
+  for (std::string::const_iterator p = s.begin(); p != s.end(); ++p){
+    h = (h << 4) + (*p & 0xff);
+    g = h & 0xf0000000;
+    if (g){
+      h = h ^ (g >> 24);
+      h = h ^ g;
+    }
+  }
+  return h;
+}
+
+bool 
+pmt_is_symbol(const pmt_t& obj)
+{
+  return obj->is_symbol();
+}
+
+pmt_t 
+pmt_string_to_symbol(const std::string &name)
+{
+  unsigned hash = hash_string(name) % SYMBOL_HASH_TABLE_SIZE;
+
+  // Does a symbol with this name already exist?
+  for (pmt_t sym = s_symbol_hash_table[hash]; sym; sym = _symbol(sym)->next()){
+    if (name == _symbol(sym)->name())
+      return sym;              // Yes.  Return it
+  }
+
+  // Nope.  Make a new one.
+  pmt_t sym = pmt_t(new pmt_symbol(name));
+  _symbol(sym)->set_next(s_symbol_hash_table[hash]);
+  s_symbol_hash_table[hash] = sym;
+  return sym;
+}
+
+// alias...
+pmt_t
+pmt_intern(const std::string &name)
+{
+  return pmt_string_to_symbol(name);
+}
+
+const std::string
+pmt_symbol_to_string(const pmt_t& sym)
+{
+  if (!sym->is_symbol())
+    throw pmt_wrong_type("pmt_symbol_to_string", sym);
+
+  return _symbol(sym)->name();
+}
+
+
+
+////////////////////////////////////////////////////////////////////////////
+//                             Number
+////////////////////////////////////////////////////////////////////////////
+
+bool
+pmt_is_number(pmt_t x)
+{
+  return x->is_number();
+}
+
+////////////////////////////////////////////////////////////////////////////
+//                             Integer
+////////////////////////////////////////////////////////////////////////////
+
+pmt_integer::pmt_integer(long value) : d_value(value) {}
+
+bool
+pmt_is_integer(pmt_t x)
+{
+  return x->is_integer();
+}
+
+
+pmt_t
+pmt_from_long(long x)
+{
+  return pmt_t(new pmt_integer(x));
+}
+
+long
+pmt_to_long(pmt_t x)
+{
+  pmt_integer* i = dynamic_cast<pmt_integer*>(x.get());
+  if ( i )
+    return i->value();
+
+  throw pmt_wrong_type("pmt_to_long", x);
+}
+
+////////////////////////////////////////////////////////////////////////////
+//                              Real
+////////////////////////////////////////////////////////////////////////////
+
+pmt_real::pmt_real(double value) : d_value(value) {}
+
+bool 
+pmt_is_real(pmt_t x)
+{
+  return x->is_real();
+}
+
+pmt_t
+pmt_from_double(double x)
+{
+  return pmt_t(new pmt_real(x));
+}
+
+double
+pmt_to_double(pmt_t x)
+{
+  if (x->is_real())
+    return _real(x)->value();
+  if (x->is_integer())
+    return _integer(x)->value();
+
+  throw pmt_wrong_type("pmt_to_double", x);
+}
+
+////////////////////////////////////////////////////////////////////////////
+//                              Complex
+////////////////////////////////////////////////////////////////////////////
+
+pmt_complex::pmt_complex(std::complex<double> value) : d_value(value) {}
+
+bool 
+pmt_is_complex(pmt_t x)
+{
+  return x->is_complex();
+}
+
+pmt_t
+pmt_make_rectangular(double re, double im)
+{
+  return pmt_t(new pmt_complex(std::complex<double>(re, im)));
+}
+
+std::complex<double>
+pmt_to_complex(pmt_t x)
+{
+  if (x->is_complex())
+    return _complex(x)->value();
+  if (x->is_real())
+    return _real(x)->value();
+  if (x->is_integer())
+    return _integer(x)->value();
+
+  throw pmt_wrong_type("pmt_to_complex", x);
+}
+
+////////////////////////////////////////////////////////////////////////////
+//                              Pairs
+////////////////////////////////////////////////////////////////////////////
+
+pmt_null::pmt_null() {}
+pmt_pair::pmt_pair(const pmt_t& car, const pmt_t& cdr) : d_car(car), d_cdr(cdr) {}
+
+bool
+pmt_is_null(const pmt_t& x)
+{
+  return x == PMT_NIL;
+}
+
+bool
+pmt_is_pair(const pmt_t& obj)
+{
+  return obj->is_pair();
+}
+
+pmt_t
+pmt_cons(const pmt_t& x, const pmt_t& y)
+{
+  return pmt_t(new pmt_pair(x, y));
+}
+
+pmt_t
+pmt_car(const pmt_t& pair)
+{
+  pmt_pair* p = dynamic_cast<pmt_pair*>(pair.get());
+  if ( p )
+    return p->car();
+  
+  throw pmt_wrong_type("pmt_car", pair);
+}
+
+pmt_t
+pmt_cdr(const pmt_t& pair)
+{
+  pmt_pair* p = dynamic_cast<pmt_pair*>(pair.get());
+  if ( p )
+    return p->cdr();
+  
+  throw pmt_wrong_type("pmt_cdr", pair);
+}
+
+void
+pmt_set_car(pmt_t pair, pmt_t obj)
+{
+  if (pair->is_pair())
+    _pair(pair)->set_car(obj);
+  else
+    throw pmt_wrong_type("pmt_set_car", pair);
+}
+
+void
+pmt_set_cdr(pmt_t pair, pmt_t obj)
+{
+  if (pair->is_pair())
+    _pair(pair)->set_cdr(obj);
+  else
+    throw pmt_wrong_type("pmt_set_cdr", pair);
+}
+
+////////////////////////////////////////////////////////////////////////////
+//                             Vectors
+////////////////////////////////////////////////////////////////////////////
+
+pmt_vector::pmt_vector(size_t len, pmt_t fill)
+  : d_v(len)
+{
+  for (size_t i = 0; i < len; i++)
+    d_v[i] = fill;
+}
+
+pmt_t
+pmt_vector::ref(size_t k) const
+{
+  if (k >= length())
+    throw pmt_out_of_range("pmt_vector_ref", pmt_from_long(k));
+  return d_v[k];
+}
+
+void
+pmt_vector::set(size_t k, pmt_t obj)
+{
+  if (k >= length())
+    throw pmt_out_of_range("pmt_vector_set", pmt_from_long(k));
+  d_v[k] = obj;
+}
+
+void
+pmt_vector::fill(pmt_t obj)
+{
+  for (size_t i = 0; i < length(); i++)
+    d_v[i] = obj;
+}
+
+bool
+pmt_is_vector(pmt_t obj)
+{
+  return obj->is_vector();
+}
+
+pmt_t
+pmt_make_vector(size_t k, pmt_t fill)
+{
+  return pmt_t(new pmt_vector(k, fill));
+}
+
+pmt_t
+pmt_vector_ref(pmt_t vector, size_t k)
+{
+  if (!vector->is_vector())
+    throw pmt_wrong_type("pmt_vector_ref", vector);
+  return _vector(vector)->ref(k);
+}
+
+void
+pmt_vector_set(pmt_t vector, size_t k, pmt_t obj)
+{
+  if (!vector->is_vector())
+    throw pmt_wrong_type("pmt_vector_set", vector);
+  _vector(vector)->set(k, obj);
+}
+
+void
+pmt_vector_fill(pmt_t vector, pmt_t obj)
+{
+  if (!vector->is_vector())
+    throw pmt_wrong_type("pmt_vector_set", vector);
+  _vector(vector)->fill(obj);
+}
+
+////////////////////////////////////////////////////////////////////////////
+//                       Uniform Numeric Vectors
+////////////////////////////////////////////////////////////////////////////
+
+bool
+pmt_is_uniform_vector(pmt_t x)
+{
+  return x->is_uniform_vector();
+}
+
+const void *
+pmt_uniform_vector_elements(pmt_t vector, size_t &len)
+{
+  if (!vector->is_uniform_vector())
+    throw pmt_wrong_type("pmt_uniform_vector_elements", vector);
+  return _uniform_vector(vector)->uniform_elements(len);
+}
+
+void *
+pmt_uniform_vector_writable_elements(pmt_t vector, size_t &len)
+{
+  if (!vector->is_uniform_vector())
+    throw pmt_wrong_type("pmt_uniform_vector_writable_elements", vector);
+  return _uniform_vector(vector)->uniform_writable_elements(len);
+}
+
+////////////////////////////////////////////////////////////////////////////
+//                            Dictionaries
+////////////////////////////////////////////////////////////////////////////
+
+pmt_dict::pmt_dict()
+  : d_alist(PMT_NIL)
+{
+}
+
+void
+pmt_dict::set(pmt_t key, pmt_t value)
+{
+  pmt_t        p = pmt_assv(key, d_alist);     // look for (key . value) pair
+  if (pmt_is_pair(p)){                 // found existing pair...
+    pmt_set_cdr(p, value);             // overrwrite cdr with new value
+  }
+  else {                               // not in the dict
+    d_alist = pmt_cons(pmt_cons(key, value), d_alist); // add new (key . value) pair
+  }
+}
+
+pmt_t
+pmt_dict::ref(pmt_t key, pmt_t not_found) const
+{
+  pmt_t        p = pmt_assv(key, d_alist);     // look for (key . value) pair
+  if (pmt_is_pair(p))
+    return pmt_cdr(p);
+  else
+    return not_found;
+}
+
+bool
+pmt_dict::has_key(pmt_t key) const
+{
+  return pmt_is_pair(pmt_assv(key, d_alist));
+}
+
+pmt_t
+pmt_dict::items() const
+{
+  return d_alist;
+}
+
+pmt_t
+pmt_dict::keys() const
+{
+  return pmt_map(pmt_car, d_alist);
+}
+
+pmt_t
+pmt_dict::values() const
+{
+  return pmt_map(pmt_cdr, d_alist);
+}
+
+bool
+pmt_is_dict(pmt_t obj)
+{
+  return obj->is_dict();
+}
+
+pmt_t
+pmt_make_dict()
+{
+  return pmt_t(new pmt_dict());
+}
+
+void
+pmt_dict_set(pmt_t dict, pmt_t key, pmt_t value)
+{
+  pmt_dict* d = _dict(dict);
+  if (!d)
+    throw pmt_wrong_type("pmt_dict_set", dict);
+
+  d->set(key, value);
+}
+
+bool
+pmt_dict_has_key(pmt_t dict, pmt_t key)
+{
+  pmt_dict* d = _dict(dict);
+  if (!d)
+    throw pmt_wrong_type("pmt_dict_has_key", dict);
+
+  return d->has_key(key);
+}
+
+pmt_t
+pmt_dict_ref(pmt_t dict, pmt_t key, pmt_t not_found)
+{
+  pmt_dict* d = _dict(dict);
+  if (!d)
+    throw pmt_wrong_type("pmt_dict_ref", dict);
+
+  return d->ref(key, not_found);
+}
+
+pmt_t
+pmt_dict_items(pmt_t dict)
+{
+  if (!dict->is_dict())
+    throw pmt_wrong_type("pmt_dict_items", dict);
+
+  return _dict(dict)->items();
+}
+
+pmt_t
+pmt_dict_keys(pmt_t dict)
+{
+  if (!dict->is_dict())
+    throw pmt_wrong_type("pmt_dict_keys", dict);
+
+  return _dict(dict)->keys();
+}
+
+pmt_t
+pmt_dict_values(pmt_t dict)
+{
+  if (!dict->is_dict())
+    throw pmt_wrong_type("pmt_dict_values", dict);
+
+  return _dict(dict)->values();
+}
+
+////////////////////////////////////////////////////////////////////////////
+//                                 Any
+////////////////////////////////////////////////////////////////////////////
+
+pmt_any::pmt_any(const boost::any &any) : d_any(any) {}
+
+bool
+pmt_is_any(pmt_t obj)
+{
+  return obj->is_any();
+}
+
+pmt_t
+pmt_make_any(const boost::any &any)
+{
+  return pmt_t(new pmt_any(any));
+}
+
+boost::any
+pmt_any_ref(pmt_t obj)
+{
+  if (!obj->is_any())
+    throw pmt_wrong_type("pmt_any_ref", obj);
+  return _any(obj)->ref();
+}
+
+void
+pmt_any_set(pmt_t obj, const boost::any &any)
+{
+  if (!obj->is_any())
+    throw pmt_wrong_type("pmt_any_set", obj);
+  _any(obj)->set(any);
+}
+
+////////////////////////////////////////////////////////////////////////////
+//                          General Functions
+////////////////////////////////////////////////////////////////////////////
+
+bool
+pmt_eq(const pmt_t& x, const pmt_t& y)
+{
+  return x == y;
+}
+
+bool
+pmt_eqv(const pmt_t& x, const pmt_t& y)
+{
+  if (x == y)
+    return true;
+
+  if (x->is_integer() && y->is_integer())
+    return _integer(x)->value() == _integer(y)->value();
+
+  if (x->is_real() && y->is_real())
+    return _real(x)->value() == _real(y)->value();
+
+  if (x->is_complex() && y->is_complex())
+    return _complex(x)->value() == _complex(y)->value();
+
+  return false;
+}
+
+bool
+pmt_equal(const pmt_t& x, const pmt_t& y)
+{
+  if (pmt_eqv(x, y))
+    return true;
+
+  if (x->is_pair() && y->is_pair())
+    return pmt_equal(pmt_car(x), pmt_car(y)) && pmt_equal(pmt_cdr(x), pmt_cdr(y));
+
+  if (x->is_vector() && y->is_vector()){
+    pmt_vector *xv = _vector(x);
+    pmt_vector *yv = _vector(y);
+    if (xv->length() != yv->length())
+      return false;
+
+    for (unsigned i = 0; i < xv->length(); i++)
+      if (!pmt_equal(xv->_ref(i), yv->_ref(i)))
+       return false;
+
+    return true;
+  }
+
+  if (x->is_uniform_vector() && y->is_uniform_vector()){
+    pmt_uniform_vector *xv = _uniform_vector(x);
+    pmt_uniform_vector *yv = _uniform_vector(y);
+    if (xv->length() != yv->length())
+      return false;
+
+    size_t len_x, len_y;
+    if (memcmp(xv->uniform_elements(len_x),
+              yv->uniform_elements(len_y),
+              len_x) == 0)
+      return true;
+
+    return true;
+  }
+
+  // FIXME add other cases here...
+
+  return false;
+}
+
+size_t
+pmt_length(const pmt_t& x)
+{
+  if (x->is_vector())
+    return _vector(x)->length();
+
+  if (x->is_uniform_vector())
+    return _uniform_vector(x)->length();
+
+  if (x->is_null()) return 0;
+
+  if (x->is_pair()) {
+    size_t length=1;
+       pmt_t it = pmt_cdr(x);
+    while (pmt_is_pair(it)){
+      length++;
+      it = pmt_cdr(it);
+    }
+    if (pmt_is_null(it))
+      return length;
+
+    // not a proper list
+    throw pmt_wrong_type("pmt_length", x);
+  }
+
+  // FIXME dictionary length (number of entries)
+
+  throw pmt_wrong_type("pmt_length", x);
+}
+
+pmt_t
+pmt_assq(pmt_t obj, pmt_t alist)
+{
+  while (pmt_is_pair(alist)){
+    pmt_t p = pmt_car(alist);
+    if (!pmt_is_pair(p))       // malformed alist
+      return PMT_F;
+
+    if (pmt_eq(obj, pmt_car(p)))
+      return p;
+
+    alist = pmt_cdr(alist);
+  }
+  return PMT_F;
+}
+
+pmt_t
+pmt_assv(pmt_t obj, pmt_t alist)
+{
+  while (pmt_is_pair(alist)){
+    pmt_t p = pmt_car(alist);
+    if (!pmt_is_pair(p))       // malformed alist
+      return PMT_F;
+
+    if (pmt_eqv(obj, pmt_car(p)))
+      return p;
+
+    alist = pmt_cdr(alist);
+  }
+  return PMT_F;
+}
+
+pmt_t
+pmt_assoc(pmt_t obj, pmt_t alist)
+{
+  while (pmt_is_pair(alist)){
+    pmt_t p = pmt_car(alist);
+    if (!pmt_is_pair(p))       // malformed alist
+      return PMT_F;
+
+    if (pmt_equal(obj, pmt_car(p)))
+      return p;
+
+    alist = pmt_cdr(alist);
+  }
+  return PMT_F;
+}
+
+pmt_t
+pmt_map(pmt_t proc(const pmt_t&), pmt_t list)
+{
+  pmt_t r = PMT_NIL;
+
+  while(pmt_is_pair(list)){
+    r = pmt_cons(proc(pmt_car(list)), r);
+    list = pmt_cdr(list);
+  }
+
+  return pmt_reverse_x(r);
+}
+
+pmt_t
+pmt_reverse(pmt_t listx)
+{
+  pmt_t list = listx;
+  pmt_t r = PMT_NIL;
+
+  while(pmt_is_pair(list)){
+    r = pmt_cons(pmt_car(list), r);
+    list = pmt_cdr(list);
+  }
+  if (pmt_is_null(list))
+    return r;
+  else
+    throw pmt_wrong_type("pmt_reverse", listx);
+}
+
+pmt_t
+pmt_reverse_x(pmt_t list)
+{
+  // FIXME do it destructively
+  return pmt_reverse(list);
+}
+
+pmt_t
+pmt_nth(size_t n, pmt_t list)
+{
+  pmt_t t = pmt_nthcdr(n, list);
+  if (pmt_is_pair(t))
+    return pmt_car(t);
+  else
+    return PMT_NIL;
+}
+
+pmt_t
+pmt_nthcdr(size_t n, pmt_t list)
+{
+  if (!(pmt_is_pair(list) || pmt_is_null(list)))
+    throw pmt_wrong_type("pmt_nthcdr", list);
+    
+  while (n > 0){
+    if (pmt_is_pair(list)){
+      list = pmt_cdr(list);
+      n--;
+      continue;
+    }
+    if (pmt_is_null(list))
+      return PMT_NIL;
+    else
+      throw pmt_wrong_type("pmt_nthcdr: not a LIST", list);
+  }
+  return list;
+}
+
+pmt_t
+pmt_memq(pmt_t obj, pmt_t list)
+{
+  while (pmt_is_pair(list)){
+    if (pmt_eq(obj, pmt_car(list)))
+      return list;
+    list = pmt_cdr(list);
+  }
+  return PMT_F;
+}
+
+pmt_t
+pmt_memv(pmt_t obj, pmt_t list)
+{
+  while (pmt_is_pair(list)){
+    if (pmt_eqv(obj, pmt_car(list)))
+      return list;
+    list = pmt_cdr(list);
+  }
+  return PMT_F;
+}
+
+pmt_t
+pmt_member(pmt_t obj, pmt_t list)
+{
+  while (pmt_is_pair(list)){
+    if (pmt_equal(obj, pmt_car(list)))
+      return list;
+    list = pmt_cdr(list);
+  }
+  return PMT_F;
+}
+
+bool
+pmt_subsetp(pmt_t list1, pmt_t list2)
+{
+  while (pmt_is_pair(list1)){
+    pmt_t p = pmt_car(list1);
+    if (pmt_is_false(pmt_memv(p, list2)))
+      return false;
+    list1 = pmt_cdr(list1);
+  }
+  return true;
+}
+
+pmt_t
+pmt_list1(const pmt_t& x1)
+{
+  return pmt_cons(x1, PMT_NIL);
+}
+
+pmt_t
+pmt_list2(const pmt_t& x1, const pmt_t& x2)
+{
+  return pmt_cons(x1, pmt_cons(x2, PMT_NIL));
+}
+
+pmt_t
+pmt_list3(const pmt_t& x1, const pmt_t& x2, const pmt_t& x3)
+{
+  return pmt_cons(x1, pmt_cons(x2, pmt_cons(x3, PMT_NIL)));
+}
+
+pmt_t
+pmt_list4(const pmt_t& x1, const pmt_t& x2, const pmt_t& x3, const pmt_t& x4)
+{
+  return pmt_cons(x1, pmt_cons(x2, pmt_cons(x3, pmt_cons(x4, PMT_NIL))));
+}
+
+pmt_t
+pmt_list5(const pmt_t& x1, const pmt_t& x2, const pmt_t& x3, const pmt_t& x4, const pmt_t& x5)
+{
+  return pmt_cons(x1, pmt_cons(x2, pmt_cons(x3, pmt_cons(x4, pmt_cons(x5, PMT_NIL)))));
+}
+
+pmt_t
+pmt_list6(const pmt_t& x1, const pmt_t& x2, const pmt_t& x3, const pmt_t& x4, const pmt_t& x5, const pmt_t& x6)
+{
+  return pmt_cons(x1, pmt_cons(x2, pmt_cons(x3, pmt_cons(x4, pmt_cons(x5, pmt_cons(x6, PMT_NIL))))));
+}
+
+pmt_t
+pmt_list_add(pmt_t list, const pmt_t& item)
+{
+  return pmt_reverse(pmt_cons(item, pmt_reverse(list)));
+}
+
+pmt_t
+pmt_caar(pmt_t pair)
+{
+  return (pmt_car(pmt_car(pair)));
+}
+
+pmt_t
+pmt_cadr(pmt_t pair)
+{
+  return pmt_car(pmt_cdr(pair));
+}
+
+pmt_t
+pmt_cdar(pmt_t pair)
+{
+  return pmt_cdr(pmt_car(pair));
+}
+
+pmt_t
+pmt_cddr(pmt_t pair)
+{
+  return pmt_cdr(pmt_cdr(pair));
+}
+
+pmt_t
+pmt_caddr(pmt_t pair)
+{
+  return pmt_car(pmt_cdr(pmt_cdr(pair)));
+}
+
+pmt_t
+pmt_cadddr(pmt_t pair)
+{
+  return pmt_car(pmt_cdr(pmt_cdr(pmt_cdr(pair))));
+}
+  
+bool
+pmt_is_eof_object(pmt_t obj)
+{
+  return pmt_eq(obj, PMT_EOF);
+}
+
+void
+pmt_dump_sizeof()
+{
+  printf("sizeof(pmt_t)              = %3zd\n", sizeof(pmt_t));
+  printf("sizeof(pmt_base)           = %3zd\n", sizeof(pmt_base));
+  printf("sizeof(pmt_bool)           = %3zd\n", sizeof(pmt_bool));
+  printf("sizeof(pmt_symbol)         = %3zd\n", sizeof(pmt_symbol));
+  printf("sizeof(pmt_integer)        = %3zd\n", sizeof(pmt_integer));
+  printf("sizeof(pmt_real)           = %3zd\n", sizeof(pmt_real));
+  printf("sizeof(pmt_complex)        = %3zd\n", sizeof(pmt_complex));
+  printf("sizeof(pmt_null)           = %3zd\n", sizeof(pmt_null));
+  printf("sizeof(pmt_pair)           = %3zd\n", sizeof(pmt_pair));
+  printf("sizeof(pmt_vector)         = %3zd\n", sizeof(pmt_vector));
+  printf("sizeof(pmt_dict)           = %3zd\n", sizeof(pmt_dict));
+  printf("sizeof(pmt_uniform_vector) = %3zd\n", sizeof(pmt_uniform_vector));
+}
+
+} /* namespace gruel */
diff --git a/gruel/src/lib/pmt_int.h b/gruel/src/lib/pmt_int.h
new file mode 100644 (file)
index 0000000..03f0e55
--- /dev/null
@@ -0,0 +1,227 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006,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 GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+#ifndef INCLUDED_PMT_INT_H
+#define INCLUDED_PMT_INT_H
+
+#include <gruel/pmt.h>
+#include <boost/utility.hpp>
+
+/*
+ * EVERYTHING IN THIS FILE IS PRIVATE TO THE IMPLEMENTATION!
+ *
+ * See pmt.h for the public interface
+ */
+
+#define PMT_LOCAL_ALLOCATOR 0          // define to 0 or 1
+namespace gruel {
+
+class pmt_base : boost::noncopyable {
+protected:
+  pmt_base(){};
+  virtual ~pmt_base();
+
+public:
+  virtual bool is_bool()    const { return false; }
+  virtual bool is_symbol()  const { return false; }
+  virtual bool is_number()  const { return false; }
+  virtual bool is_integer() const { return false; }
+  virtual bool is_real()    const { return false; }
+  virtual bool is_complex() const { return false; }
+  virtual bool is_null()    const { return false; }
+  virtual bool is_pair()    const { return false; }
+  virtual bool is_vector()  const { return false; }
+  virtual bool is_dict()    const { return false; }
+  virtual bool is_any()     const { return false; }
+
+  virtual bool is_uniform_vector() const { return false; }
+  virtual bool is_u8vector()  const { return false; }
+  virtual bool is_s8vector()  const { return false; }
+  virtual bool is_u16vector() const { return false; }
+  virtual bool is_s16vector() const { return false; }
+  virtual bool is_u32vector() const { return false; }
+  virtual bool is_s32vector() const { return false; }
+  virtual bool is_u64vector() const { return false; }
+  virtual bool is_s64vector() const { return false; }
+  virtual bool is_f32vector() const { return false; }
+  virtual bool is_f64vector() const { return false; }
+  virtual bool is_c32vector() const { return false; }
+  virtual bool is_c64vector() const { return false; }
+
+# if (PMT_LOCAL_ALLOCATOR)
+  void *operator new(size_t);
+  void operator delete(void *, size_t);
+#endif
+};
+
+class pmt_bool : public pmt_base
+{
+public:
+  pmt_bool();
+  //~pmt_bool(){}
+
+  bool is_bool() const { return true; }
+};
+
+
+class pmt_symbol : public pmt_base
+{
+  std::string  d_name;
+  pmt_t                d_next;
+  
+public:
+  pmt_symbol(const std::string &name);
+  //~pmt_symbol(){}
+
+  bool is_symbol() const { return true; }
+  const std::string name() { return d_name; }
+
+  pmt_t next() { return d_next; }              // symbol table link
+  void set_next(pmt_t next) { d_next = next; }
+};
+
+class pmt_integer : public pmt_base
+{
+  long         d_value;
+
+public:
+  pmt_integer(long value);
+  //~pmt_integer(){}
+
+  bool is_number()  const { return true; }
+  bool is_integer() const { return true; }
+  long value() const { return d_value; }
+};
+
+class pmt_real : public pmt_base
+{
+  double       d_value;
+
+public:
+  pmt_real(double value);
+  //~pmt_real(){}
+
+  bool is_number()  const { return true; }
+  bool is_real() const { return true; }
+  double value() const { return d_value; }
+};
+
+class pmt_complex : public pmt_base
+{
+  std::complex<double> d_value;
+
+public:
+  pmt_complex(std::complex<double> value);
+  //~pmt_complex(){}
+
+  bool is_number()  const { return true; }
+  bool is_complex() const { return true; }
+  std::complex<double> value() const { return d_value; }
+};
+
+class pmt_null  : public pmt_base
+{
+public:
+  pmt_null();
+  //~pmt_null(){}
+
+  bool is_null() const { return true; }
+};
+
+class pmt_pair : public pmt_base
+{
+  pmt_t                d_car;
+  pmt_t                d_cdr;
+
+public:
+  pmt_pair(const pmt_t& car, const pmt_t& cdr);
+  //~pmt_pair(){};
+
+  bool is_pair() const { return true; }
+  pmt_t car() const { return d_car; }
+  pmt_t cdr() const { return d_cdr; }
+
+  void set_car(pmt_t car) { d_car = car; }
+  void set_cdr(pmt_t cdr) { d_cdr = cdr; }
+};
+
+class pmt_vector : public pmt_base
+{
+  std::vector<pmt_t>   d_v;
+
+public:
+  pmt_vector(size_t len, pmt_t fill);
+  //~pmt_vector();
+
+  bool is_vector() const { return true; }
+  pmt_t ref(size_t k) const;
+  void  set(size_t k, pmt_t obj);
+  void  fill(pmt_t fill);
+  size_t length() const { return d_v.size(); }
+
+  pmt_t _ref(size_t k) const { return d_v[k]; }
+};
+
+class pmt_dict : public pmt_base
+{
+  pmt_t                d_alist;        // list of (key . value) pairs
+
+public:
+  pmt_dict();
+  //~pmt_dict();
+
+  bool  is_dict() const { return true; }
+  void  set(pmt_t key, pmt_t value);
+  pmt_t ref(pmt_t key, pmt_t default_value) const;
+  bool  has_key(pmt_t key) const;
+  pmt_t items() const;
+  pmt_t keys() const;
+  pmt_t values() const;
+};
+
+class pmt_any : public pmt_base
+{
+  boost::any   d_any;
+
+public:
+  pmt_any(const boost::any &any);
+  //~pmt_any();
+
+  bool is_any() const { return true; }
+  const boost::any &ref() const { return d_any; }
+  void  set(const boost::any &any) { d_any = any; }
+};
+
+
+class pmt_uniform_vector : public pmt_base
+{
+public:
+  bool is_uniform_vector() const { return true; }
+  virtual const void *uniform_elements(size_t &len) = 0;
+  virtual void *uniform_writable_elements(size_t &len) = 0;
+  virtual size_t length() const = 0;
+};
+
+#include "pmt_unv_int.h"
+
+} /* namespace gruel */
+
+#endif /* INCLUDED_PMT_INT_H */
diff --git a/gruel/src/lib/pmt_io.cc b/gruel/src/lib/pmt_io.cc
new file mode 100644 (file)
index 0000000..e10ea78
--- /dev/null
@@ -0,0 +1,141 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006,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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <vector>
+#include <gruel/pmt.h>
+#include "pmt_int.h"
+#include <sstream>
+
+namespace gruel {
+
+static void
+pmt_write_list_tail(pmt_t obj, std::ostream &port)
+{
+  pmt_write(pmt_car(obj), port); // write the car
+  obj = pmt_cdr(obj);           // step to cdr
+
+  if (pmt_is_null(obj))                 // ()
+    port << ")";
+
+  else if (pmt_is_pair(obj)){   // normal list
+    port << " ";
+    pmt_write_list_tail(obj, port);
+  }
+  else {                        // dotted pair
+    port << " . ";
+    pmt_write(obj, port);
+    port << ")";
+  }
+}
+
+void
+pmt_write(pmt_t obj, std::ostream &port)
+{
+  if (pmt_is_bool(obj)){
+    if (pmt_is_true(obj))
+      port << "#t";
+    else
+      port << "#f";
+  }
+  else if (pmt_is_symbol(obj)){
+    port << pmt_symbol_to_string(obj);
+  }
+  else if (pmt_is_number(obj)){
+    if (pmt_is_integer(obj))
+      port << pmt_to_long(obj);
+    else if (pmt_is_real(obj))
+      port << pmt_to_double(obj);
+    else if (pmt_is_complex(obj)){
+      std::complex<double> c = pmt_to_complex(obj);
+      port << c.real() << '+' << c.imag() << 'i';
+    }
+    else
+      goto error;
+  }
+  else if (pmt_is_null(obj)){
+    port << "()";
+  }
+  else if (pmt_is_pair(obj)){
+    port << "(";
+    pmt_write_list_tail(obj, port);
+  }
+  else if (pmt_is_dict(obj)){
+    // FIXME
+    // port << "#<dict " << obj << ">";
+    port << "#<dict>";
+  }
+  else if (pmt_is_vector(obj)){
+    // FIXME
+    // port << "#<vector " << obj << ">";
+    port << "#<vector>";
+  }
+  else if (pmt_is_uniform_vector(obj)){
+    // FIXME
+    // port << "#<uniform-vector " << obj << ">";
+    port << "#<uniform-vector>";
+  }
+  else {
+  error:
+    // FIXME
+    // port << "#<" << obj << ">";
+    port << "#<unknown>";
+  }
+}
+
+std::ostream& operator<<(std::ostream &os, pmt_t obj)
+{
+  pmt_write(obj, os);
+  return os;
+}
+
+std::string 
+pmt_write_string(pmt_t obj)
+{
+  std::ostringstream s;
+  s << obj;
+  return s.str();
+}
+
+pmt_t
+pmt_read(std::istream &port)
+{
+  throw pmt_notimplemented("notimplemented: pmt_read", PMT_NIL);
+}
+
+void
+pmt_serialize(pmt_t obj, std::ostream &sink)
+{
+  throw pmt_notimplemented("notimplemented: pmt_serialize", obj);
+}
+
+/*!
+ * \brief Create obj from portable byte-serial representation
+ */
+pmt_t 
+pmt_deserialize(std::istream &source)
+{
+  throw pmt_notimplemented("notimplemented: pmt_deserialize", PMT_NIL);
+}
+
+} /* namespace gruel */
diff --git a/gruel/src/lib/pmt_pool.cc b/gruel/src/lib/pmt_pool.cc
new file mode 100644 (file)
index 0000000..79a22ea
--- /dev/null
@@ -0,0 +1,112 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007,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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <gruel/pmt_pool.h>
+#include <algorithm>
+#include <stdint.h>
+
+namespace gruel {
+
+static inline size_t
+ROUNDUP(size_t x, size_t stride)
+{
+  return ((((x) + (stride) - 1)/(stride)) * (stride));
+}
+
+pmt_pool::pmt_pool(size_t itemsize, size_t alignment,
+                  size_t allocation_size, size_t max_items)
+  : d_itemsize(ROUNDUP(itemsize, alignment)),
+    d_alignment(alignment),
+    d_allocation_size(std::max(allocation_size, 16 * itemsize)),
+    d_max_items(max_items), d_n_items(0),
+    d_freelist(0)
+{
+}
+
+pmt_pool::~pmt_pool()
+{
+  for (unsigned int i = 0; i < d_allocations.size(); i++){
+    delete [] d_allocations[i];
+  }
+}
+
+void *
+pmt_pool::malloc()
+{
+  scoped_lock guard(d_mutex);
+  item *p;
+
+  if (d_max_items != 0){
+    while (d_n_items >= d_max_items)
+      d_cond.wait(guard);
+  }
+
+  if (d_freelist){     // got something?
+    p = d_freelist;
+    d_freelist = p->d_next;
+    d_n_items++;
+    return p;
+  }
+
+  // allocate a new chunk
+  char *alloc = new char[d_allocation_size + d_alignment - 1];
+  d_allocations.push_back(alloc);
+
+  // get the alignment we require
+  char *start = (char *)(((uintptr_t)alloc + d_alignment-1) & -d_alignment);
+  char *end = alloc + d_allocation_size + d_alignment - 1;
+  size_t n = (end - start) / d_itemsize;
+
+  // link the new items onto the free list.
+  p = (item *) start;
+  for (size_t i = 0; i < n; i++){
+    p->d_next = d_freelist;
+    d_freelist = p;
+    p = (item *)((char *) p + d_itemsize);
+  }
+
+  // now return the first one
+  p = d_freelist;
+  d_freelist = p->d_next;
+  d_n_items++;
+  return p;
+}
+
+void
+pmt_pool::free(void *foo)
+{
+  if (!foo)
+    return;
+
+  scoped_lock guard(d_mutex);
+
+  item *p = (item *) foo;
+  p->d_next = d_freelist;
+  d_freelist = p;
+  d_n_items--;
+  if (d_max_items != 0)
+    d_cond.notify_one();
+}
+
+} /* namespace gruel */
diff --git a/gruel/src/lib/pmt_serialize.cc b/gruel/src/lib/pmt_serialize.cc
new file mode 100644 (file)
index 0000000..b7193e8
--- /dev/null
@@ -0,0 +1,357 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007,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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <vector>
+#include <gruel/pmt.h>
+#include "pmt_int.h"
+#include "gruel/pmt_serial_tags.h"
+
+namespace gruel {
+
+static pmt_t parse_pair(std::streambuf &sb);
+
+// ----------------------------------------------------------------
+// output primitives
+// ----------------------------------------------------------------
+
+static bool
+serialize_untagged_u8(unsigned int i, std::streambuf &sb)
+{
+  return sb.sputc((i >> 0) & 0xff) != std::streambuf::traits_type::eof();
+}
+
+// always writes big-endian
+static bool
+serialize_untagged_u16(unsigned int i, std::streambuf &sb)
+{
+  sb.sputc((i >> 8) & 0xff);
+  return sb.sputc((i >> 0) & 0xff) != std::streambuf::traits_type::eof();
+}
+
+// always writes big-endian
+static bool
+serialize_untagged_u32(unsigned int i, std::streambuf &sb)
+{
+  sb.sputc((i >> 24) & 0xff);
+  sb.sputc((i >> 16) & 0xff);
+  sb.sputc((i >>  8) & 0xff);
+  return sb.sputc((i >> 0) & 0xff) != std::streambuf::traits_type::eof();
+}
+
+#if 0
+// always writes big-endian
+static bool
+serialize_untagged_u64(uint64_t i, std::streambuf &sb)
+{
+  sb.sputc((i >> 56) & 0xff);
+  sb.sputc((i >> 48) & 0xff);
+  sb.sputc((i >> 40) & 0xff);
+  sb.sputc((i >> 32) & 0xff);
+  sb.sputc((i >> 24) & 0xff);
+  sb.sputc((i >> 16) & 0xff);
+  sb.sputc((i >>  8) & 0xff);
+  return sb.sputc((i >> 0) & 0xff) != std::streambuf::traits_type::eof();
+}
+#endif
+
+// ----------------------------------------------------------------
+// input primitives
+// ----------------------------------------------------------------
+
+
+// always reads big-endian
+static bool
+deserialize_untagged_u8(uint8_t *ip, std::streambuf &sb)
+{
+  std::streambuf::traits_type::int_type  t;
+  int i;
+
+  t = sb.sbumpc();
+  i = t & 0xff;
+
+  *ip = i;
+  return t != std::streambuf::traits_type::eof();
+}
+
+// always reads big-endian
+static bool
+deserialize_untagged_u16(uint16_t *ip, std::streambuf &sb)
+{
+  std::streambuf::traits_type::int_type  t;
+  int i;
+
+  t = sb.sbumpc();
+  i = t & 0xff;
+
+  t = sb.sbumpc();
+  i = (i << 8) | (t & 0xff);
+
+  *ip = i;
+  return t != std::streambuf::traits_type::eof();
+}
+
+// always reads big-endian
+static bool
+deserialize_untagged_u32(uint32_t *ip, std::streambuf &sb)
+{
+  std::streambuf::traits_type::int_type  t;
+  int i;
+
+  t = sb.sbumpc();
+  i = t & 0xff;
+
+  t = sb.sbumpc();
+  i = (i << 8) | (t & 0xff);
+  t = sb.sbumpc();
+  i = (i << 8) | (t & 0xff);
+  t = sb.sbumpc();
+  i = (i << 8) | (t & 0xff);
+
+  *ip = i;
+  return t != std::streambuf::traits_type::eof();
+}
+
+#if 0
+// always reads big-endian
+static bool
+deserialize_untagged_u64(uint64_t *ip, std::streambuf &sb)
+{
+  std::streambuf::traits_type::int_type  t;
+  uint64_t i;
+
+  t = sb.sbumpc();
+  i = t & 0xff;
+
+  t = sb.sbumpc();
+  i = (i << 8) | (t & 0xff);
+  t = sb.sbumpc();
+  i = (i << 8) | (t & 0xff);
+  t = sb.sbumpc();
+  i = (i << 8) | (t & 0xff);
+  t = sb.sbumpc();
+  i = (i << 8) | (t & 0xff);
+  t = sb.sbumpc();
+  i = (i << 8) | (t & 0xff);
+  t = sb.sbumpc();
+  i = (i << 8) | (t & 0xff);
+  t = sb.sbumpc();
+  i = (i << 8) | (t & 0xff);
+
+  *ip = i;
+  return t != std::streambuf::traits_type::eof();
+}
+#endif
+
+/*
+ * Write portable byte-serial representation of \p obj to \p sb
+ *
+ * N.B., Circular structures cause infinite recursion.
+ */
+bool
+pmt_serialize(pmt_t obj, std::streambuf &sb)
+{
+  bool ok = true;
+
+ tail_recursion:
+
+  if (pmt_is_bool(obj)){
+    if (pmt_eq(obj, PMT_T))
+      return serialize_untagged_u8(PST_TRUE, sb);
+    else
+      return serialize_untagged_u8(PST_FALSE, sb);
+  }
+  
+  if (pmt_is_null(obj))
+    return serialize_untagged_u8(PST_NULL, sb);
+
+  if (pmt_is_symbol(obj)){
+    const std::string s = pmt_symbol_to_string(obj);
+    size_t len = s.size();
+    ok = serialize_untagged_u8(PST_SYMBOL, sb);
+    ok &= serialize_untagged_u16(len, sb);
+    for (size_t i = 0; i < len; i++)
+      ok &= serialize_untagged_u8(s[i], sb);
+    return ok;
+  }
+
+  if (pmt_is_pair(obj)){
+    ok = serialize_untagged_u8(PST_PAIR, sb);
+    ok &= pmt_serialize(pmt_car(obj), sb);
+    if (!ok)
+      return false;
+    obj = pmt_cdr(obj);
+    goto tail_recursion;
+  }
+
+  if (pmt_is_number(obj)){
+
+    if (pmt_is_integer(obj)){
+      long i = pmt_to_long(obj);
+      if (sizeof(long) > 4){
+       if (i < -2147483647 || i > 2147483647)
+         throw pmt_notimplemented("pmt_serialize (64-bit integers)", obj);
+      }
+      ok = serialize_untagged_u8(PST_INT32, sb);
+      ok &= serialize_untagged_u32(i, sb);
+      return ok;
+    }
+
+    if (pmt_is_real(obj))
+      throw pmt_notimplemented("pmt_serialize (real)", obj);
+
+    if (pmt_is_complex(obj))
+      throw pmt_notimplemented("pmt_serialize (complex)", obj);
+  }
+
+  if (pmt_is_vector(obj))
+    throw pmt_notimplemented("pmt_serialize (vector)", obj);
+
+  if (pmt_is_uniform_vector(obj))
+    throw pmt_notimplemented("pmt_serialize (uniform-vector)", obj);
+    
+  if (pmt_is_dict(obj))
+    throw pmt_notimplemented("pmt_serialize (dict)", obj);
+    
+
+  throw pmt_notimplemented("pmt_serialize (?)", obj);
+}
+
+/*
+ * Create obj from portable byte-serial representation
+ *
+ * Returns next obj from streambuf, or PMT_EOF at end of file.
+ * Throws exception on malformed input.
+ */
+pmt_t
+pmt_deserialize(std::streambuf &sb)
+{
+  uint8_t      tag;
+  //uint8_t    u8;
+  uint16_t     u16;
+  uint32_t     u32;
+  //uint32_t   u64;
+  static char   tmpbuf[1024];
+
+  if (!deserialize_untagged_u8(&tag, sb))
+    return PMT_EOF;
+
+  switch (tag){
+  case PST_TRUE:
+    return PMT_T;
+    
+  case PST_FALSE:
+    return PMT_F;
+
+  case PST_NULL:
+    return PMT_NIL;
+
+  case PST_SYMBOL:
+    if (!deserialize_untagged_u16(&u16, sb))
+      goto error;
+    if (u16 > sizeof(tmpbuf))
+      throw pmt_notimplemented("pmt_deserialize: very long symbol",
+                              PMT_F);
+    if (sb.sgetn(tmpbuf, u16) != u16)
+      goto error;
+    return pmt_intern(std::string(tmpbuf, u16));
+
+  case PST_INT32:
+    if (!deserialize_untagged_u32(&u32, sb))
+      goto error;
+    return pmt_from_long((int32_t) u32);
+
+  case PST_PAIR:
+    return parse_pair(sb);
+
+  case PST_DOUBLE:
+  case PST_COMPLEX:
+  case PST_VECTOR:
+  case PST_DICT:
+  case PST_UNIFORM_VECTOR:
+  case PST_COMMENT:
+    throw pmt_notimplemented("pmt_deserialize: tag value = ",
+                            pmt_from_long(tag));
+    
+  default:
+    throw pmt_exception("pmt_deserialize: malformed input stream, tag value = ",
+                       pmt_from_long(tag));
+  }
+
+ error:
+  throw pmt_exception("pmt_deserialize: malformed input stream", PMT_F);
+}
+
+/*
+ * This is a mostly non-recursive implementation that allows us to
+ * deserialize very long lists w/o exhausting the evaluation stack.
+ *
+ * On entry we've already eaten the PST_PAIR tag.
+ */
+pmt_t
+parse_pair(std::streambuf &sb)
+{
+  uint8_t tag;
+  pmt_t        val, expr, lastnptr, nptr;
+
+  //
+  // Keep appending nodes until we get a non-PAIR cdr.
+  //
+  lastnptr = PMT_NIL;
+  while (1){
+    expr = pmt_deserialize(sb);                // read the car
+
+    nptr = pmt_cons(expr, PMT_NIL);    // build new cell
+    if (pmt_is_null(lastnptr))
+      val = nptr;
+    else
+      pmt_set_cdr(lastnptr, nptr);
+    lastnptr = nptr;
+
+    if (!deserialize_untagged_u8(&tag, sb))  // get tag of cdr
+      throw pmt_exception("pmt_deserialize: malformed input stream", PMT_F);
+
+    if (tag == PST_PAIR)
+      continue;                        // keep on looping...
+
+    if (tag == PST_NULL){
+      expr = PMT_NIL;
+      break;
+    }
+
+    //
+    // default: push tag back and use pmt_deserialize to get the cdr
+    //
+    sb.sungetc();
+    expr = pmt_deserialize(sb);
+    break;
+  }
+
+  //
+  // At this point, expr contains the value of the final cdr in the list.
+  //
+  pmt_set_cdr(lastnptr, expr);
+  return val;
+}
+
+} /* namespace gruel */
diff --git a/gruel/src/lib/qa_pmt.cc b/gruel/src/lib/qa_pmt.cc
new file mode 100644 (file)
index 0000000..250befa
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2006 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 GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+/*
+ * This class gathers together all the test cases for pmt into
+ * a single test suite.  As you create new test cases, add them here.
+ */
+
+#include <qa_pmt.h>
+#include <qa_pmt_prims.h>
+#include <qa_pmt_unv.h>
+
+CppUnit::TestSuite *
+qa_pmt::suite ()
+{
+  CppUnit::TestSuite   *s = new CppUnit::TestSuite ("pmt");
+
+  s->addTest (qa_pmt_prims::suite ());
+  s->addTest (qa_pmt_unv::suite ());
+  
+  return s;
+}
diff --git a/gruel/src/lib/qa_pmt.h b/gruel/src/lib/qa_pmt.h
new file mode 100644 (file)
index 0000000..43a6dbf
--- /dev/null
@@ -0,0 +1,36 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006 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 GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_QA_PMT_H
+#define INCLUDED_QA_PMT_H
+
+#include <cppunit/TestSuite.h>
+
+//! collect all the tests for pmt
+
+class qa_pmt {
+ public:
+  //! return suite of tests for all of pmt
+  static CppUnit::TestSuite *suite ();
+};
+
+#endif /* INCLUDED_QA_PMT_H */
diff --git a/gruel/src/lib/qa_pmt_prims.cc b/gruel/src/lib/qa_pmt_prims.cc
new file mode 100644 (file)
index 0000000..ac93f80
--- /dev/null
@@ -0,0 +1,438 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006,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 GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <qa_pmt_prims.h>
+#include <cppunit/TestAssert.h>
+#include <gruel/pmt.h>
+#include <stdio.h>
+#include <sstream>
+
+using namespace gruel;
+
+void
+qa_pmt_prims::test_symbols()
+{
+  CPPUNIT_ASSERT(!pmt_is_symbol(PMT_T));
+  CPPUNIT_ASSERT(!pmt_is_symbol(PMT_F));
+  CPPUNIT_ASSERT_THROW(pmt_symbol_to_string(PMT_F), pmt_wrong_type);
+
+  pmt_t sym1 = pmt_string_to_symbol("test");
+  CPPUNIT_ASSERT(pmt_is_symbol(sym1));
+  CPPUNIT_ASSERT_EQUAL(std::string("test"), pmt_symbol_to_string(sym1));
+  CPPUNIT_ASSERT(pmt_is_true(sym1));
+  CPPUNIT_ASSERT(!pmt_is_false(sym1));
+
+  pmt_t sym2 = pmt_string_to_symbol("foo");
+  pmt_t sym3 = pmt_string_to_symbol("test");
+  CPPUNIT_ASSERT_EQUAL(sym1, sym3);
+  CPPUNIT_ASSERT(sym1 != sym2);
+  CPPUNIT_ASSERT(sym1 == sym3);
+
+  static const int N = 2048;
+  std::vector<pmt_t> v1(N);
+  std::vector<pmt_t> v2(N);
+
+  // generate a bunch of symbols
+  for (int i = 0; i < N; i++){
+    char buf[100];
+    snprintf(buf, sizeof(buf), "test-%d", i);
+    v1[i] = pmt_string_to_symbol(buf);
+  }
+
+  // confirm that they are all unique
+  for (int i = 0; i < N; i++)
+    for (int j = i + 1; j < N; j++)
+      CPPUNIT_ASSERT(v1[i] != v1[j]);
+
+  // generate the same symbols again
+  for (int i = 0; i < N; i++){
+    char buf[100];
+    snprintf(buf, sizeof(buf), "test-%d", i);
+    v2[i] = pmt_string_to_symbol(buf);
+  }
+
+  // confirm that we get the same ones back
+  for (int i = 0; i < N; i++)
+    CPPUNIT_ASSERT(v1[i] == v2[i]);
+}
+
+void
+qa_pmt_prims::test_booleans()
+{
+  pmt_t sym = pmt_string_to_symbol("test");
+  CPPUNIT_ASSERT(pmt_is_bool(PMT_T));
+  CPPUNIT_ASSERT(pmt_is_bool(PMT_F));
+  CPPUNIT_ASSERT(!pmt_is_bool(sym));
+  CPPUNIT_ASSERT_EQUAL(pmt_from_bool(false), PMT_F);
+  CPPUNIT_ASSERT_EQUAL(pmt_from_bool(true), PMT_T);
+  CPPUNIT_ASSERT_EQUAL(false, pmt_to_bool(PMT_F));
+  CPPUNIT_ASSERT_EQUAL(true, pmt_to_bool(PMT_T));
+  CPPUNIT_ASSERT_THROW(pmt_to_bool(sym), pmt_wrong_type);
+}
+
+void
+qa_pmt_prims::test_integers()
+{
+  pmt_t p1 = pmt_from_long(1);
+  pmt_t m1 = pmt_from_long(-1);
+  CPPUNIT_ASSERT(!pmt_is_integer(PMT_T));
+  CPPUNIT_ASSERT(pmt_is_integer(p1));
+  CPPUNIT_ASSERT(pmt_is_integer(m1));
+  CPPUNIT_ASSERT_THROW(pmt_to_long(PMT_T), pmt_wrong_type);
+  CPPUNIT_ASSERT_EQUAL(-1L, pmt_to_long(m1));
+  CPPUNIT_ASSERT_EQUAL(1L, pmt_to_long(p1));
+}
+
+void
+qa_pmt_prims::test_reals()
+{
+  pmt_t p1 = pmt_from_double(1);
+  pmt_t m1 = pmt_from_double(-1);
+  CPPUNIT_ASSERT(!pmt_is_real(PMT_T));
+  CPPUNIT_ASSERT(pmt_is_real(p1));
+  CPPUNIT_ASSERT(pmt_is_real(m1));
+  CPPUNIT_ASSERT_THROW(pmt_to_double(PMT_T), pmt_wrong_type);
+  CPPUNIT_ASSERT_EQUAL(-1.0, pmt_to_double(m1));
+  CPPUNIT_ASSERT_EQUAL(1.0, pmt_to_double(p1));
+  CPPUNIT_ASSERT_EQUAL(1.0, pmt_to_double(pmt_from_long(1)));
+}
+
+void
+qa_pmt_prims::test_complexes()
+{
+  pmt_t p1 = pmt_make_rectangular(2, -3);
+  pmt_t m1 = pmt_make_rectangular(-3, 2);
+  CPPUNIT_ASSERT(!pmt_is_complex(PMT_T));
+  CPPUNIT_ASSERT(pmt_is_complex(p1));
+  CPPUNIT_ASSERT(pmt_is_complex(m1));
+  CPPUNIT_ASSERT_THROW(pmt_to_complex(PMT_T), pmt_wrong_type);
+  CPPUNIT_ASSERT_EQUAL(std::complex<double>(2, -3), pmt_to_complex(p1));
+  CPPUNIT_ASSERT_EQUAL(std::complex<double>(-3, 2), pmt_to_complex(m1));
+  CPPUNIT_ASSERT_EQUAL(std::complex<double>(1.0, 0), pmt_to_complex(pmt_from_long(1)));
+  CPPUNIT_ASSERT_EQUAL(std::complex<double>(1.0, 0), pmt_to_complex(pmt_from_double(1.0)));
+}
+
+void
+qa_pmt_prims::test_pairs()
+{
+  CPPUNIT_ASSERT(pmt_is_null(PMT_NIL));
+  CPPUNIT_ASSERT(!pmt_is_pair(PMT_NIL));
+  pmt_t s1 = pmt_string_to_symbol("s1");
+  pmt_t s2 = pmt_string_to_symbol("s2");
+  pmt_t s3 = pmt_string_to_symbol("s3");
+
+
+  CPPUNIT_ASSERT_EQUAL((size_t)0, pmt_length(PMT_NIL));
+  CPPUNIT_ASSERT_THROW(pmt_length(s1), pmt_wrong_type);
+  CPPUNIT_ASSERT_THROW(pmt_length(pmt_from_double(42)), pmt_wrong_type);
+
+  pmt_t c1 = pmt_cons(s1, PMT_NIL);
+  CPPUNIT_ASSERT(pmt_is_pair(c1));
+  CPPUNIT_ASSERT(!pmt_is_pair(s1));
+  CPPUNIT_ASSERT_EQUAL(s1, pmt_car(c1));
+  CPPUNIT_ASSERT_EQUAL(PMT_NIL, pmt_cdr(c1));
+  CPPUNIT_ASSERT_EQUAL((size_t) 1, pmt_length(c1));
+
+  pmt_t c3 = pmt_cons(s3, PMT_NIL);
+  pmt_t c2 = pmt_cons(s2, c3);
+  pmt_set_cdr(c1, c2);
+  CPPUNIT_ASSERT_EQUAL(c2, pmt_cdr(c1));
+  pmt_set_car(c1, s3);
+  CPPUNIT_ASSERT_EQUAL(s3, pmt_car(c1));
+  CPPUNIT_ASSERT_EQUAL((size_t)1, pmt_length(c3));
+  CPPUNIT_ASSERT_EQUAL((size_t)2, pmt_length(c2));
+  
+  CPPUNIT_ASSERT_THROW(pmt_cdr(PMT_NIL), pmt_wrong_type);
+  CPPUNIT_ASSERT_THROW(pmt_car(PMT_NIL), pmt_wrong_type);
+  CPPUNIT_ASSERT_THROW(pmt_set_car(s1, PMT_NIL), pmt_wrong_type);
+  CPPUNIT_ASSERT_THROW(pmt_set_cdr(s1, PMT_NIL), pmt_wrong_type);
+}
+
+void
+qa_pmt_prims::test_vectors()
+{
+  static const size_t N = 3;
+  pmt_t v1 = pmt_make_vector(N, PMT_NIL);
+  CPPUNIT_ASSERT_EQUAL(N, pmt_length(v1));
+  pmt_t s0 = pmt_string_to_symbol("s0");
+  pmt_t s1 = pmt_string_to_symbol("s1");
+  pmt_t s2 = pmt_string_to_symbol("s2");
+
+  pmt_vector_set(v1, 0, s0);
+  pmt_vector_set(v1, 1, s1);
+  pmt_vector_set(v1, 2, s2);
+
+  CPPUNIT_ASSERT_EQUAL(s0, pmt_vector_ref(v1, 0));
+  CPPUNIT_ASSERT_EQUAL(s1, pmt_vector_ref(v1, 1));
+  CPPUNIT_ASSERT_EQUAL(s2, pmt_vector_ref(v1, 2));
+
+  CPPUNIT_ASSERT_THROW(pmt_vector_ref(v1, N), pmt_out_of_range);
+  CPPUNIT_ASSERT_THROW(pmt_vector_set(v1, N, PMT_NIL), pmt_out_of_range);
+
+  pmt_vector_fill(v1, s0);
+  for (size_t i = 0; i < N; i++)
+    CPPUNIT_ASSERT_EQUAL(s0, pmt_vector_ref(v1, i));
+}
+
+void
+qa_pmt_prims::test_equivalence()
+{
+  pmt_t s0 = pmt_string_to_symbol("s0");
+  pmt_t s1 = pmt_string_to_symbol("s1");
+  pmt_t s2 = pmt_string_to_symbol("s2");
+  pmt_t list0 = pmt_cons(s0, pmt_cons(s1, pmt_cons(s2, PMT_NIL)));
+  pmt_t list1 = pmt_cons(s0, pmt_cons(s1, pmt_cons(s2, PMT_NIL)));
+  pmt_t i0 = pmt_from_long(42);
+  pmt_t i1 = pmt_from_long(42);
+  pmt_t r0 = pmt_from_double(42);
+  pmt_t r1 = pmt_from_double(42);
+  pmt_t r2 = pmt_from_double(43);
+
+  CPPUNIT_ASSERT(pmt_eq(s0, s0));
+  CPPUNIT_ASSERT(!pmt_eq(s0, s1));
+  CPPUNIT_ASSERT(pmt_eqv(s0, s0));
+  CPPUNIT_ASSERT(!pmt_eqv(s0, s1));
+
+  CPPUNIT_ASSERT(pmt_eqv(i0, i1));
+  CPPUNIT_ASSERT(pmt_eqv(r0, r1));
+  CPPUNIT_ASSERT(!pmt_eqv(r0, r2));
+  CPPUNIT_ASSERT(!pmt_eqv(i0, r0));
+
+  CPPUNIT_ASSERT(!pmt_eq(list0, list1));
+  CPPUNIT_ASSERT(!pmt_eqv(list0, list1));
+  CPPUNIT_ASSERT(pmt_equal(list0, list1));
+
+  pmt_t v0 = pmt_make_vector(3, s0);
+  pmt_t v1 = pmt_make_vector(3, s0);
+  pmt_t v2 = pmt_make_vector(4, s0);
+  CPPUNIT_ASSERT(!pmt_eqv(v0, v1));
+  CPPUNIT_ASSERT(pmt_equal(v0, v1));
+  CPPUNIT_ASSERT(!pmt_equal(v0, v2));
+
+  pmt_vector_set(v0, 0, list0);
+  pmt_vector_set(v0, 1, list0);
+  pmt_vector_set(v1, 0, list1);
+  pmt_vector_set(v1, 1, list1);
+  CPPUNIT_ASSERT(pmt_equal(v0, v1));
+}
+
+void
+qa_pmt_prims::test_misc()
+{
+  pmt_t k0 = pmt_string_to_symbol("k0");
+  pmt_t k1 = pmt_string_to_symbol("k1");
+  pmt_t k2 = pmt_string_to_symbol("k2");
+  pmt_t k3 = pmt_string_to_symbol("k3");
+  pmt_t v0 = pmt_string_to_symbol("v0");
+  pmt_t v1 = pmt_string_to_symbol("v1");
+  pmt_t v2 = pmt_string_to_symbol("v2");
+  pmt_t p0 = pmt_cons(k0, v0);
+  pmt_t p1 = pmt_cons(k1, v1);
+  pmt_t p2 = pmt_cons(k2, v2);
+  
+  pmt_t alist = pmt_cons(p0, pmt_cons(p1, pmt_cons(p2, PMT_NIL)));
+  CPPUNIT_ASSERT(pmt_eq(p1, pmt_assv(k1, alist)));
+  CPPUNIT_ASSERT(pmt_eq(PMT_F, pmt_assv(k3, alist)));
+  
+  pmt_t keys = pmt_cons(k0, pmt_cons(k1, pmt_cons(k2, PMT_NIL)));
+  pmt_t vals = pmt_cons(v0, pmt_cons(v1, pmt_cons(v2, PMT_NIL)));
+  CPPUNIT_ASSERT(pmt_equal(keys, pmt_map(pmt_car, alist)));
+  CPPUNIT_ASSERT(pmt_equal(vals, pmt_map(pmt_cdr, alist)));
+}
+
+void
+qa_pmt_prims::test_dict()
+{
+  pmt_t dict = pmt_make_dict();
+  CPPUNIT_ASSERT(pmt_is_dict(dict));
+
+  pmt_t k0 = pmt_string_to_symbol("k0");
+  pmt_t k1 = pmt_string_to_symbol("k1");
+  pmt_t k2 = pmt_string_to_symbol("k2");
+  pmt_t k3 = pmt_string_to_symbol("k3");
+  pmt_t v0 = pmt_string_to_symbol("v0");
+  pmt_t v1 = pmt_string_to_symbol("v1");
+  pmt_t v2 = pmt_string_to_symbol("v2");
+  pmt_t v3 = pmt_string_to_symbol("v3");
+  pmt_t not_found = pmt_cons(PMT_NIL, PMT_NIL);
+  
+  CPPUNIT_ASSERT(!pmt_dict_has_key(dict, k0));
+  pmt_dict_set(dict, k0, v0);
+  CPPUNIT_ASSERT(pmt_dict_has_key(dict, k0));
+  CPPUNIT_ASSERT(pmt_eqv(pmt_dict_ref(dict, k0, not_found), v0));
+  CPPUNIT_ASSERT(pmt_eqv(pmt_dict_ref(dict, k1, not_found), not_found));
+  pmt_dict_set(dict, k1, v1);
+  pmt_dict_set(dict, k2, v2);
+  CPPUNIT_ASSERT(pmt_eqv(pmt_dict_ref(dict, k1, not_found), v1));
+  pmt_dict_set(dict, k1, v3);
+  CPPUNIT_ASSERT(pmt_eqv(pmt_dict_ref(dict, k1, not_found), v3));
+
+  pmt_t keys = pmt_cons(k2, pmt_cons(k1, pmt_cons(k0, PMT_NIL)));
+  pmt_t vals = pmt_cons(v2, pmt_cons(v3, pmt_cons(v0, PMT_NIL)));
+  CPPUNIT_ASSERT(pmt_equal(keys, pmt_dict_keys(dict)));
+  CPPUNIT_ASSERT(pmt_equal(vals, pmt_dict_values(dict)));
+}
+
+void
+qa_pmt_prims::test_io()
+{
+  pmt_t k0 = pmt_string_to_symbol("k0");
+  pmt_t k1 = pmt_string_to_symbol("k1");
+  pmt_t k2 = pmt_string_to_symbol("k2");
+  pmt_t k3 = pmt_string_to_symbol("k3");
+
+  CPPUNIT_ASSERT_EQUAL(std::string("k0"), pmt_write_string(k0));
+}
+
+void
+qa_pmt_prims::test_lists()
+{
+  pmt_t s0 = pmt_intern("s0");
+  pmt_t s1 = pmt_intern("s1");
+  pmt_t s2 = pmt_intern("s2");
+  pmt_t s3 = pmt_intern("s3");
+
+  pmt_t l1 = pmt_list4(s0, s1, s2, s3);
+  pmt_t l2 = pmt_list3(s0, s1, s2);
+  pmt_t l3 = pmt_list_add(l2, s3);
+  CPPUNIT_ASSERT(pmt_equal(l1, l3));
+}
+
+// ------------------------------------------------------------------------
+
+// class foo is used in test_any below.
+// It can't be declared in the scope of test_any because of template
+// namespace problems.
+
+class foo {
+public:
+  double       d_double;
+  int          d_int;
+  foo(double d=0, int i=0) : d_double(d), d_int(i) {}
+};
+
+bool operator==(const foo &a, const foo &b)
+{
+  return a.d_double == b.d_double && a.d_int == b.d_int;
+}
+
+std::ostream& operator<<(std::ostream &os, const foo obj)
+{
+  os << "<foo: " << obj.d_double << ", " << obj.d_int << ">";
+  return os;
+}
+
+void
+qa_pmt_prims::test_any()
+{
+  boost::any a0;
+  boost::any a1;
+  boost::any a2;
+
+  a0 = std::string("Hello!");
+  a1 = 42;
+  a2 = foo(3.250, 21);
+
+  pmt_t p0 = pmt_make_any(a0);
+  pmt_t p1 = pmt_make_any(a1);
+  pmt_t p2 = pmt_make_any(a2);
+
+  CPPUNIT_ASSERT_EQUAL(std::string("Hello!"),
+                      boost::any_cast<std::string>(pmt_any_ref(p0)));
+
+  CPPUNIT_ASSERT_EQUAL(42,
+                      boost::any_cast<int>(pmt_any_ref(p1)));
+
+  CPPUNIT_ASSERT_EQUAL(foo(3.250, 21),
+                      boost::any_cast<foo>(pmt_any_ref(p2)));
+}
+
+// ------------------------------------------------------------------------
+
+void
+qa_pmt_prims::test_serialize()
+{
+  std::stringbuf sb;           // fake channel
+  pmt_t a = pmt_intern("a");
+  pmt_t b = pmt_intern("b");
+  pmt_t c = pmt_intern("c");
+
+  sb.str("");                  // reset channel to empty
+
+  // write stuff to channel
+
+  pmt_serialize(PMT_NIL, sb);
+  pmt_serialize(pmt_intern("foobarvia"), sb);
+  pmt_serialize(pmt_from_long(123456789), sb);
+  pmt_serialize(pmt_from_long(-123456789), sb);
+  pmt_serialize(pmt_cons(PMT_NIL, PMT_NIL), sb);
+  pmt_serialize(pmt_cons(a, b), sb);
+  pmt_serialize(pmt_list1(a), sb);
+  pmt_serialize(pmt_list2(a, b), sb);
+  pmt_serialize(pmt_list3(a, b, c), sb);
+  pmt_serialize(pmt_list3(a, pmt_list3(c, b, a), c), sb);
+  pmt_serialize(PMT_T, sb);
+  pmt_serialize(PMT_F, sb);
+
+  // read it back
+
+  CPPUNIT_ASSERT(pmt_equal(pmt_deserialize(sb), PMT_NIL));
+  CPPUNIT_ASSERT(pmt_equal(pmt_deserialize(sb), pmt_intern("foobarvia")));
+  CPPUNIT_ASSERT(pmt_equal(pmt_deserialize(sb), pmt_from_long(123456789)));
+  CPPUNIT_ASSERT(pmt_equal(pmt_deserialize(sb), pmt_from_long(-123456789)));
+  CPPUNIT_ASSERT(pmt_equal(pmt_deserialize(sb), pmt_cons(PMT_NIL, PMT_NIL)));
+  CPPUNIT_ASSERT(pmt_equal(pmt_deserialize(sb), pmt_cons(a, b)));
+  CPPUNIT_ASSERT(pmt_equal(pmt_deserialize(sb), pmt_list1(a)));
+  CPPUNIT_ASSERT(pmt_equal(pmt_deserialize(sb), pmt_list2(a, b)));
+  CPPUNIT_ASSERT(pmt_equal(pmt_deserialize(sb), pmt_list3(a, b, c)));
+  CPPUNIT_ASSERT(pmt_equal(pmt_deserialize(sb), pmt_list3(a, pmt_list3(c, b, a), c)));
+  CPPUNIT_ASSERT(pmt_equal(pmt_deserialize(sb), PMT_T));
+  CPPUNIT_ASSERT(pmt_equal(pmt_deserialize(sb), PMT_F));
+
+  CPPUNIT_ASSERT(pmt_equal(pmt_deserialize(sb), PMT_EOF));     // last item
+
+
+  // FIXME add tests for real, complex, vector, uniform-vector, dict
+  // FIXME add tests for malformed input too.
+
+}
+
+void
+qa_pmt_prims::test_sets()
+{
+  pmt_t s1 = pmt_intern("s1");
+  pmt_t s2 = pmt_intern("s2");
+  pmt_t s3 = pmt_intern("s3");
+
+  pmt_t l1 = pmt_list1(s1);
+  pmt_t l2 = pmt_list2(s2,s3);
+  pmt_t l3 = pmt_list3(s1,s2,s3);
+
+  CPPUNIT_ASSERT(pmt_is_pair(pmt_memq(s1,l1)));
+  CPPUNIT_ASSERT(pmt_is_false(pmt_memq(s3,l1)));
+
+  CPPUNIT_ASSERT(pmt_subsetp(l1,l3));
+  CPPUNIT_ASSERT(pmt_subsetp(l2,l3));
+  CPPUNIT_ASSERT(!pmt_subsetp(l1,l2));
+  CPPUNIT_ASSERT(!pmt_subsetp(l2,l1));
+  CPPUNIT_ASSERT(!pmt_subsetp(l3,l2));
+}
diff --git a/gruel/src/lib/qa_pmt_prims.h b/gruel/src/lib/qa_pmt_prims.h
new file mode 100644 (file)
index 0000000..effb3a0
--- /dev/null
@@ -0,0 +1,67 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006 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 GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+#ifndef INCLUDED_QA_PMT_PRIMS_H
+#define INCLUDED_QA_PMT_PRIMS_H
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/TestCase.h>
+
+class qa_pmt_prims : public CppUnit::TestCase {
+
+  CPPUNIT_TEST_SUITE(qa_pmt_prims);
+  CPPUNIT_TEST(test_symbols);
+  CPPUNIT_TEST(test_booleans);
+  CPPUNIT_TEST(test_integers);
+  CPPUNIT_TEST(test_reals);
+  CPPUNIT_TEST(test_complexes);
+  CPPUNIT_TEST(test_pairs);
+  CPPUNIT_TEST(test_vectors);
+  CPPUNIT_TEST(test_equivalence);
+  CPPUNIT_TEST(test_misc);
+  CPPUNIT_TEST(test_dict);
+  CPPUNIT_TEST(test_any);
+  CPPUNIT_TEST(test_io);
+  CPPUNIT_TEST(test_lists);
+  CPPUNIT_TEST(test_serialize);
+  CPPUNIT_TEST(test_sets);
+  CPPUNIT_TEST_SUITE_END();
+
+ private:
+  void test_symbols();
+  void test_booleans();
+  void test_integers();
+  void test_reals();
+  void test_complexes();
+  void test_pairs();
+  void test_vectors();
+  void test_equivalence();
+  void test_misc();
+  void test_dict();
+  void test_any();
+  void test_io();
+  void test_lists();
+  void test_serialize();
+  void test_sets();
+};
+
+#endif /* INCLUDED_QA_PMT_PRIMS_H */
+
diff --git a/gruel/src/lib/test_pmt.cc b/gruel/src/lib/test_pmt.cc
new file mode 100644 (file)
index 0000000..034785f
--- /dev/null
@@ -0,0 +1,37 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006 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 GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <cppunit/TextTestRunner.h>
+#include <qa_pmt.h>
+
+int 
+main(int argc, char **argv)
+{
+  
+  CppUnit::TextTestRunner      runner;
+
+  runner.addTest(qa_pmt::suite ());
+  
+  bool was_successful = runner.run("", false);
+
+  return was_successful ? 0 : 1;
+}
diff --git a/gruel/src/lib/unv_qa_template.cc.t b/gruel/src/lib/unv_qa_template.cc.t
new file mode 100644 (file)
index 0000000..1e2c8e8
--- /dev/null
@@ -0,0 +1,35 @@
+void
+qa_pmt_unv::test_@TAG@vector()
+{
+  static const size_t N = 3;
+  pmt_t v1 = pmt_make_@TAG@vector(N, 0);
+  CPPUNIT_ASSERT_EQUAL(N, pmt_length(v1));
+  @TYPE@ s0 = @TYPE@(10);
+  @TYPE@ s1 = @TYPE@(20);
+  @TYPE@ s2 = @TYPE@(30);
+
+  pmt_@TAG@vector_set(v1, 0, s0);
+  pmt_@TAG@vector_set(v1, 1, s1);
+  pmt_@TAG@vector_set(v1, 2, s2);
+
+  CPPUNIT_ASSERT_EQUAL(s0, pmt_@TAG@vector_ref(v1, 0));
+  CPPUNIT_ASSERT_EQUAL(s1, pmt_@TAG@vector_ref(v1, 1));
+  CPPUNIT_ASSERT_EQUAL(s2, pmt_@TAG@vector_ref(v1, 2));
+
+  CPPUNIT_ASSERT_THROW(pmt_@TAG@vector_ref(v1, N), pmt_out_of_range);
+  CPPUNIT_ASSERT_THROW(pmt_@TAG@vector_set(v1, N, @TYPE@(0)), pmt_out_of_range);
+
+  size_t       len;
+  const @TYPE@ *rd = pmt_@TAG@vector_elements(v1, len);
+  CPPUNIT_ASSERT_EQUAL(len, N);
+  CPPUNIT_ASSERT_EQUAL(s0, rd[0]);
+  CPPUNIT_ASSERT_EQUAL(s1, rd[1]);
+  CPPUNIT_ASSERT_EQUAL(s2, rd[2]);
+
+  @TYPE@ *wr = pmt_@TAG@vector_writable_elements(v1, len);
+  CPPUNIT_ASSERT_EQUAL(len, N);
+  wr[0] = @TYPE@(0);
+  CPPUNIT_ASSERT_EQUAL(@TYPE@(0), wr[0]);
+  CPPUNIT_ASSERT_EQUAL(s1, wr[1]);
+  CPPUNIT_ASSERT_EQUAL(s2, wr[2]);
+}
diff --git a/gruel/src/lib/unv_template.cc.t b/gruel/src/lib/unv_template.cc.t
new file mode 100644 (file)
index 0000000..b19e32d
--- /dev/null
@@ -0,0 +1,122 @@
+////////////////////////////////////////////////////////////////////////////
+//                           pmt_@TAG@vector
+////////////////////////////////////////////////////////////////////////////
+
+namespace gruel {
+
+static pmt_@TAG@vector *
+_@TAG@vector(pmt_t x)
+{
+  return dynamic_cast<pmt_@TAG@vector*>(x.get());
+}
+
+
+pmt_@TAG@vector::pmt_@TAG@vector(size_t k, @TYPE@ fill)
+  : d_v(k)
+{
+  for (size_t i = 0; i < k; i++)
+    d_v[i] = fill;
+}
+
+pmt_@TAG@vector::pmt_@TAG@vector(size_t k, const @TYPE@ *data)
+  : d_v(k)
+{
+  for (size_t i = 0; i < k; i++)
+    d_v[i] = data[i];
+}
+
+@TYPE@
+pmt_@TAG@vector::ref(size_t k) const
+{
+  if (k >= length())
+    throw pmt_out_of_range("pmt_@TAG@vector_ref", pmt_from_long(k));
+  return d_v[k];
+}
+
+void 
+pmt_@TAG@vector::set(size_t k, @TYPE@ x)
+{
+  if (k >= length())
+    throw pmt_out_of_range("pmt_@TAG@vector_set", pmt_from_long(k));
+  d_v[k] = x;
+}
+
+const @TYPE@ *
+pmt_@TAG@vector::elements(size_t &len)
+{
+  len = length();
+  return &d_v[0];
+}
+
+@TYPE@ *
+pmt_@TAG@vector::writable_elements(size_t &len)
+{
+  len = length();
+  return &d_v[0];
+}
+
+const void*
+pmt_@TAG@vector::uniform_elements(size_t &len)
+{
+  len = length() * sizeof(@TYPE@);
+  return &d_v[0];
+}
+
+void*
+pmt_@TAG@vector::uniform_writable_elements(size_t &len)
+{
+  len = length() * sizeof(@TYPE@);
+  return &d_v[0];
+}
+
+bool
+pmt_is_@TAG@vector(pmt_t obj)
+{
+  return obj->is_@TAG@vector();
+}
+
+pmt_t
+pmt_make_@TAG@vector(size_t k, @TYPE@ fill)
+{
+  return pmt_t(new pmt_@TAG@vector(k, fill));
+}
+
+pmt_t
+pmt_init_@TAG@vector(size_t k, const @TYPE@ *data)
+{
+  return pmt_t(new pmt_@TAG@vector(k, data));
+}
+
+@TYPE@
+pmt_@TAG@vector_ref(pmt_t vector, size_t k)
+{
+  if (!vector->is_@TAG@vector())
+    throw pmt_wrong_type("pmt_@TAG@vector_ref", vector);
+  return _@TAG@vector(vector)->ref(k);
+}
+
+void
+pmt_@TAG@vector_set(pmt_t vector, size_t k, @TYPE@ obj)
+{
+  if (!vector->is_@TAG@vector())
+    throw pmt_wrong_type("pmt_@TAG@vector_set", vector);
+  _@TAG@vector(vector)->set(k, obj);
+}
+
+const @TYPE@ *
+pmt_@TAG@vector_elements(pmt_t vector, size_t &len)
+{
+  if (!vector->is_@TAG@vector())
+    throw pmt_wrong_type("pmt_@TAG@vector_elements", vector);
+  return _@TAG@vector(vector)->elements(len);
+}
+
+@TYPE@ *
+pmt_@TAG@vector_writable_elements(pmt_t vector, size_t &len)
+{
+  if (!vector->is_@TAG@vector())
+    throw pmt_wrong_type("pmt_@TAG@vector_writable_elements", vector);
+  return _@TAG@vector(vector)->writable_elements(len);
+}
+
+} /* namespace gruel */
diff --git a/gruel/src/lib/unv_template.h.t b/gruel/src/lib/unv_template.h.t
new file mode 100644 (file)
index 0000000..83ba0be
--- /dev/null
@@ -0,0 +1,23 @@
+
+////////////////////////////////////////////////////////////////////////////
+//                           pmt_@TAG@vector
+////////////////////////////////////////////////////////////////////////////
+
+class pmt_@TAG@vector : public pmt_uniform_vector
+{
+  std::vector< @TYPE@ >        d_v;
+
+public:
+  pmt_@TAG@vector(size_t k, @TYPE@ fill);
+  pmt_@TAG@vector(size_t k, const @TYPE@ *data);
+  // ~pmt_@TAG@vector();
+
+  bool is_@TAG@vector() const { return true; }
+  size_t length() const { return d_v.size(); }
+  @TYPE@ ref(size_t k) const;
+  void set(size_t k, @TYPE@ x);
+  const @TYPE@ *elements(size_t &len);
+  @TYPE@ *writable_elements(size_t &len);
+  const void *uniform_elements(size_t &len);
+  void *uniform_writable_elements(size_t &len);
+};
diff --git a/gruel/src/scheme/Makefile.am b/gruel/src/scheme/Makefile.am
new file mode 100644 (file)
index 0000000..4980063
--- /dev/null
@@ -0,0 +1,21 @@
+#
+# Copyright 2007 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.
+#
+
+SUBDIRS = gnuradio
diff --git a/gruel/src/scheme/gnuradio/Makefile.am b/gruel/src/scheme/gnuradio/Makefile.am
new file mode 100644 (file)
index 0000000..0ce01f6
--- /dev/null
@@ -0,0 +1,31 @@
+#
+# Copyright 2007,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.
+#
+
+#pkgdatadir = $(datadir)/gnuradio
+
+EXTRA_DIST =                           \
+       gen-serial-tags.scm
+
+# really scheme source files
+dist_pkgdata_DATA =                    \
+       pmt-serial-tags.scm             \
+       pmt-serialize.scm               \
+       macros-etc.scm
+
diff --git a/gruel/src/scheme/gnuradio/gen-serial-tags.scm b/gruel/src/scheme/gnuradio/gen-serial-tags.scm
new file mode 100755 (executable)
index 0000000..7b90872
--- /dev/null
@@ -0,0 +1,118 @@
+#!/usr/bin/guile \
+-e main -s
+!#
+;;; -*-scheme-*-
+;;;
+;;; Copyright 2007 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.
+;;;
+
+(use-modules (ice-9 format))
+
+(defmacro when (pred . body)
+  `(if ,pred (begin ,@body) #f))
+
+;; ----------------------------------------------------------------
+
+(define (main args)
+
+  (define (usage)
+    (format 0
+           "usage: ~a <pmt-serial-tags.scm> <pmt_serial_tags.h>~%"
+           (car args)))
+
+  (when (not (= (length args) 3))
+       (usage)
+       (format 0 "args: ~s~%" args)
+       (exit 1))
+      
+  (let ((i-file (open-input-file (cadr args)))
+       (h-file (open-output-file (caddr args))))
+
+      (write-header-comment h-file "// ")
+      (display "#ifndef INCLUDED_PMT_SERIAL_TAGS_H\n" h-file)
+      (display "#define INCLUDED_PMT_SERIAL_TAGS_H\n" h-file)
+      (newline h-file)
+      (display "enum pst_tags {\n" h-file)
+
+      (for-each-in-file i-file
+       (lambda (form)
+        (let* ((name (cadr form))
+               (c-name (string-upcase (c-ify name)))
+               (value (caddr form)))
+          ;;(format h-file   "static const int ~a\t= 0x~x;~%" c-name value)
+          (format h-file   "  ~a\t= 0x~x,~%" c-name value))))
+
+      (display "};\n" h-file)
+      (display "#endif\n" h-file)))
+
+(define (c-ify name)
+  (list->string (map (lambda (c)
+                      (if (eqv? c #\-) #\_ c))
+                    (string->list (symbol->string name)))))
+
+
+(define (write-header-comment o-port prefix)
+  (for-each (lambda (comment)
+             (format o-port "~a~a~%" prefix comment))
+           header-comment))
+
+(define header-comment
+  '(
+    ""
+    "Copyright 2007 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."
+    ""
+    ""
+    "THIS FILE IS MACHINE GENERATED FROM pmt-serial-tags.scm. DO NOT EDIT BY HAND."
+    "See pmt-serial-tags.scm for additional commentary."
+    ""))
+
+
+
+(define (for-each-in-file file f)
+  (let ((port (if (port? file)
+                 file
+                 (open-input-file file))))
+    (letrec
+     ((loop
+       (lambda (port form)
+        (cond ((eof-object? form)
+               (when (not (eq? port file))
+                     (close-input-port port))
+               #t)
+              (else
+               (f form)
+               (set! form #f)          ; for GC
+               (loop port (read port)))))))
+     (loop port (read port)))))
diff --git a/gruel/src/scheme/gnuradio/macros-etc.scm b/gruel/src/scheme/gnuradio/macros-etc.scm
new file mode 100644 (file)
index 0000000..ac2a4a3
--- /dev/null
@@ -0,0 +1,50 @@
+;;; -*- scheme -*-
+;;;
+;;; Copyright 2007 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.
+;;;
+
+(define-module (gnuradio macros-etc)
+  :export (atom? when unless for-each-in-file))
+
+(define (atom? obj)
+  (not (pair? obj)))
+
+(defmacro when (pred . body)
+  `(if ,pred (begin ,@body) #f))
+
+(defmacro unless (pred . body)
+  `(if (not ,pred) (begin ,@body) #f))
+
+
+(define (for-each-in-file file f)
+  (let ((port (if (port? file)
+                 file
+                 (open-input-file file))))
+    (letrec
+     ((loop
+       (lambda (port form)
+        (cond ((eof-object? form)
+               (when (not (eq? port file))
+                     (close-input-port port))
+               #t)
+              (else
+               (f form)
+               (set! form #f)          ; for GC
+               (loop port (read port)))))))
+     (loop port (read port)))))
diff --git a/gruel/src/scheme/gnuradio/pmt-serial-tags.scm b/gruel/src/scheme/gnuradio/pmt-serial-tags.scm
new file mode 100644 (file)
index 0000000..646a751
--- /dev/null
@@ -0,0 +1,75 @@
+;;; -*-scheme-*-
+;;;
+;;; Copyright 2007 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 (define 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.
+;;;
+
+;;; definitions of tag values used for marshalling pmt data
+
+(define pst-true               #x00)
+(define pst-false              #x01)
+(define pst-symbol             #x02)   ; untagged-int16 n; followed by n bytes of symbol name
+(define pst-int32              #x03)
+(define pst-double             #x04)
+(define pst-complex            #x05)   ; complex<double>: real, imag
+(define pst-null               #x06)
+(define pst-pair               #x07)   ; followed by two objects
+(define pst-vector             #x08)   ; untagged-int32 n; followed by n objects
+(define pst-dict               #x09)   ; untagged-int32 n; followed by n key/value tuples
+
+(define pst-uniform-vector     #x0a)
+
+;; u8, s8, u16, s16, u32, s32, u64, s64, f32, f64, c32, c64
+;;
+;;   untagged-uint8  tag
+;;   untagged-uint8  uvi (define uniform vector info, see below)
+;;   untagged-int32  n-items
+;;   untagged-uint8  npad
+;;   npad bytes of zeros to align binary data
+;;   n-items binary numeric items
+;;
+;; uvi:
+;; +-+-+-+-+-+-+-+-+
+;; |B|   subtype   |
+;; +-+-+-+-+-+-+-+-+
+;;
+;; B == 0, numeric data is little-endian.
+;; B == 1, numeric data is big-endian.
+
+    (define uvi-endian-mask     #x80)
+    (define uvi-subtype-mask    #x7f)
+
+    (define uvi-little-endian   #x00)
+    (define uvi-big-endian      #x80)
+
+    (define uvi-u8             #x00)
+    (define uvi-s8             #x01)
+    (define uvi-u16            #x02)
+    (define uvi-s16            #x03)
+    (define uvi-u32            #x04)
+    (define uvi-s32            #x05)
+    (define uvi-u64            #x06)
+    (define uvi-s64            #x07)
+    (define uvi-f32            #x08)
+    (define uvi-f64            #x09)
+    (define uvi-c32            #x0a)
+    (define uvi-c64            #x0b)
+
+
+(define pst-comment            #x3b)   ; ascii ';'
+(define pst-comment-end                #x0a)   ; ascii '\n'
diff --git a/gruel/src/scheme/gnuradio/pmt-serialize.scm b/gruel/src/scheme/gnuradio/pmt-serialize.scm
new file mode 100644 (file)
index 0000000..c1d32d7
--- /dev/null
@@ -0,0 +1,48 @@
+;;;
+;;; Copyright 2007 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.
+;;;
+
+;;; An implementation of pmt_serialize in scheme.
+;;; Currently handles only symbols and pairs.  They're all we need for now.
+
+(define-module (gnuradio pmt-serialize)
+  :export (pmt-serialize))
+
+(load-from-path "gnuradio/pmt-serial-tags")
+
+(define (pmt-serialize obj put-byte)
+  (define (put-u16 x)
+    (put-byte (logand (ash x -8) #xff))
+    (put-byte (logand x #xff)))
+    
+  (cond ((null? obj)
+        (put-byte pst-null))
+       ((symbol? obj)
+        (let* ((sym-as-bytes (map char->integer (string->list (symbol->string obj))))
+               (len (length sym-as-bytes)))
+          (put-byte pst-symbol)
+          (put-u16 len)
+          (for-each put-byte sym-as-bytes)))
+       
+       ((pair? obj)
+        (put-byte pst-pair)
+        (pmt-serialize (car obj) put-byte)
+        (pmt-serialize (cdr obj) put-byte))
+       (else
+        (throw 'not-implemented "pmt-serialize" obj))))
index b94a7cbc192ffaa15dcdac8cfcbf20b2da52eaa0..8528b887589e859a731f3970dd4ac322e84c436f 100644 (file)
@@ -26,7 +26,7 @@
 //! conceptually, pointer to constructor
 typedef mb_mblock_sptr (*mb_mblock_maker_t)(mb_runtime *runtime,
                                            const std::string &instance_name,
-                                           pmt_t user_arg);
+                                           gruel::pmt_t user_arg);
 
 /*
  * \brief Maintain mapping between mblock class_name and factory (maker)
@@ -40,7 +40,7 @@ public:
 template<class mblock>
 mb_mblock_sptr mb_mblock_maker(mb_runtime *runtime,
                               const std::string &instance_name,
-                              pmt_t user_arg)
+                              gruel::pmt_t user_arg)
 {
   return mb_mblock_sptr(new mblock(runtime, instance_name, user_arg));
 }
index 2507d053ea08eb2c137f0c6ed11cabd3a7f71958..054b9987ebc8c7e31686f99b5eb14ba61980b2ad 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2006,2007,2008 Free Software Foundation, Inc.
+ * Copyright 2006,2007,2008,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -21,7 +21,7 @@
 #ifndef INCLUDED_MB_COMMON_H
 #define INCLUDED_MB_COMMON_H
 
-#include <pmt.h>
+#include <gruel/pmt.h>
 #include <vector>
 #include <stdexcept>
 #include <boost/utility.hpp>
index bbc40f1ef59a898558d6115f864c8e10bee82487..92b0b3284423e7dbcab0e58031af87f1fad8b62b 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2006,2008 Free Software Foundation, Inc.
+ * Copyright 2006,2008,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -72,7 +72,7 @@ protected:
    * \param user_arg argument passed by user to constructor
    *        (ignored by the mb_mblock base class)
    */
-  mb_mblock(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg);
+  mb_mblock(mb_runtime *runtime, const std::string &instance_name, gruel::pmt_t user_arg);
 
 public:
   /*!
@@ -128,7 +128,7 @@ protected:
   void
   define_component(const std::string &component_name,
                   const std::string &class_name,
-                  pmt_t user_arg = PMT_NIL);
+                  gruel::pmt_t user_arg = gruel::PMT_NIL);
 
   /*!
    * \brief connect endpoint_1 to endpoint_2
@@ -217,7 +217,7 @@ protected:
    *
    * runtime->run(...) returns when all blocks have called exit.
    */
-  void shutdown_all(pmt_t result);
+  void shutdown_all(gruel::pmt_t result);
 
   /*!
    * \brief main event dispatching loop
@@ -259,8 +259,8 @@ public:
    *
    * To cancel a pending timeout, call cancel_timeout.
    */
-  pmt_t
-  schedule_one_shot_timeout(const mb_time &abs_time, pmt_t user_data);
+  gruel::pmt_t
+  schedule_one_shot_timeout(const mb_time &abs_time, gruel::pmt_t user_data);
 
   /*!
    * \brief Schedule a periodic timeout.
@@ -281,10 +281,10 @@ public:
    *
    * To cancel a pending timeout, call cancel_timeout.
    */
-  pmt_t
+  gruel::pmt_t
   schedule_periodic_timeout(const mb_time &first_abs_time,
                            const mb_time &delta_time,
-                           pmt_t user_data);
+                           gruel::pmt_t user_data);
 
   /*!
    * \brief Attempt to cancel a pending timeout.
@@ -296,7 +296,7 @@ public:
    *
    * \param handle returned from schedule_one_shot_timeout or schedule_periodic_timeout.
    */
-  void cancel_timeout(pmt_t handle);
+  void cancel_timeout(gruel::pmt_t handle);
 
   /*!
    * \brief Perform a pre-order depth-first traversal of the hierarchy.
index 8fbee2ff08ec0c9def43c69caf49b4e58042114e..443684fd636e7b5459979efcddf41eb4b335040f 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2006,2007,2008 Free Software Foundation, Inc.
+ * Copyright 2006,2007,2008,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -38,37 +38,37 @@ typedef boost::shared_ptr<mb_message> mb_message_sptr;
  * \param priority     urgency
  */
 mb_message_sptr
-mb_make_message(pmt_t signal,
-               pmt_t data = PMT_NIL,
-               pmt_t metadata = PMT_NIL,
+mb_make_message(gruel::pmt_t signal,
+               gruel::pmt_t data = gruel::PMT_NIL,
+               gruel::pmt_t metadata = gruel::PMT_NIL,
                mb_pri_t priority = MB_PRI_DEFAULT);
 
 class mb_message {
   mb_message_sptr d_next;              // link field for msg queue
-  pmt_t                  d_signal;
-  pmt_t                  d_data;
-  pmt_t                  d_metadata;
+  gruel::pmt_t   d_signal;
+  gruel::pmt_t   d_data;
+  gruel::pmt_t   d_metadata;
   mb_pri_t       d_priority;
-  pmt_t                  d_port_id;            // name of port msg was rcvd on (symbol)
+  gruel::pmt_t   d_port_id;            // name of port msg was rcvd on (symbol)
 
   friend class mb_msg_queue;
 
   friend mb_message_sptr
-  mb_make_message(pmt_t signal, pmt_t data, pmt_t metadata, mb_pri_t priority);
+  mb_make_message(gruel::pmt_t signal, gruel::pmt_t data, gruel::pmt_t metadata, mb_pri_t priority);
 
   // private constructor
-  mb_message(pmt_t signal, pmt_t data, pmt_t metadata, mb_pri_t priority);
+  mb_message(gruel::pmt_t signal, gruel::pmt_t data, gruel::pmt_t metadata, mb_pri_t priority);
 
 public:
   ~mb_message();
 
-  pmt_t signal() const { return d_signal; }
-  pmt_t data() const { return d_data; }
-  pmt_t metadata() const { return d_metadata; }
+  gruel::pmt_t signal() const { return d_signal; }
+  gruel::pmt_t data() const { return d_data; }
+  gruel::pmt_t metadata() const { return d_metadata; }
   mb_pri_t priority() const { return d_priority; }
-  pmt_t port_id() const { return d_port_id; }
+  gruel::pmt_t port_id() const { return d_port_id; }
 
-  void set_port_id(pmt_t port_id){ d_port_id = port_id; }
+  void set_port_id(gruel::pmt_t port_id){ d_port_id = port_id; }
 
 #if (MB_MESSAGE_LOCAL_ALLOCATOR)
   void *operator new(size_t);
index 69be13111b1b42206b249b08cd09d433d5b5b318..7ce1705a641e369791cc0058df3861216311cde4 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2007,2008 Free Software Foundation, Inc.
+ * Copyright 2007,2008,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -42,7 +42,7 @@ public:
   mb_msg_accepter(){};
   virtual ~mb_msg_accepter();
 
-  virtual void operator()(pmt_t signal, pmt_t data, pmt_t metadata, mb_pri_t priority) = 0;
+  virtual void operator()(gruel::pmt_t signal, gruel::pmt_t data, gruel::pmt_t metadata, mb_pri_t priority) = 0;
 };
 
 #endif /* INCLUDED_MB_MSG_ACCEPTER_H */
index 782bb1285a98b93a7bfc9e08d354ad2ee62b6d76..02d81d67b0b461d8df9f01045c858b17a00c8abc 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2006,2008 Free Software Foundation, Inc.
+ * Copyright 2006,2008,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -40,8 +40,8 @@ public:
 private:
 
   std::string          d_port_name;
-  pmt_t                        d_port_symbol;          // the port_name as a pmt symbol
-  pmt_t                        d_protocol_class;
+  gruel::pmt_t         d_port_symbol;          // the port_name as a gruel::pmt symbol
+  gruel::pmt_t         d_protocol_class;
   bool                 d_conjugated;
   port_type_t          d_port_type;
 
@@ -59,13 +59,13 @@ protected:
 
 public:
   std::string  port_name() const { return d_port_name; }
-  pmt_t                port_symbol() const { return d_port_symbol; }
-  pmt_t                protocol_class() const { return d_protocol_class; }
+  gruel::pmt_t port_symbol() const { return d_port_symbol; }
+  gruel::pmt_t protocol_class() const { return d_protocol_class; }
   bool          conjugated() const { return d_conjugated; }
   port_type_t  port_type() const { return d_port_type; }
 
-  pmt_t                incoming_message_set() const;
-  pmt_t                outgoing_message_set() const;
+  gruel::pmt_t         incoming_message_set() const;
+  gruel::pmt_t         outgoing_message_set() const;
 
   virtual ~mb_port();
 
@@ -78,9 +78,9 @@ public:
    * \param priority   the urgency at which the message is sent
    */
   virtual void
-  send(pmt_t signal,
-       pmt_t data = PMT_F,
-       pmt_t metadata = PMT_F,
+  send(gruel::pmt_t signal,
+       gruel::pmt_t data = gruel::PMT_F,
+       gruel::pmt_t metadata = gruel::PMT_F,
        mb_pri_t priority = MB_PRI_DEFAULT) = 0;
 
   /*
index 33c5d7116d047d08f5b333ce1dce4cb99598d7e0..4267a912e6463558730927a67ef6e77d2f26a167 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2006,2008 Free Software Foundation, Inc.
+ * Copyright 2006,2008,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
  * \param incoming     incoming message set (list of symbols)
  * \param outgoing     outgoing message set (list of symbols)
  */
-pmt_t mb_make_protocol_class(pmt_t name, pmt_t incoming, pmt_t outgoing);
+gruel::pmt_t mb_make_protocol_class(gruel::pmt_t name, gruel::pmt_t incoming, gruel::pmt_t outgoing);
 
 // Accessors
-pmt_t mb_protocol_class_name(pmt_t pc);                //< return name of protocol class
-pmt_t mb_protocol_class_incoming(pmt_t pc);    //< return incoming message set
-pmt_t mb_protocol_class_outgoing(pmt_t pc);    //< return outgoing message set
+gruel::pmt_t mb_protocol_class_name(gruel::pmt_t pc);          //< return name of protocol class
+gruel::pmt_t mb_protocol_class_incoming(gruel::pmt_t pc);      //< return incoming message set
+gruel::pmt_t mb_protocol_class_outgoing(gruel::pmt_t pc);      //< return outgoing message set
 
-pmt_t mb_protocol_class_lookup(pmt_t name);    //< lookup an existing protocol class by name
+gruel::pmt_t mb_protocol_class_lookup(gruel::pmt_t name);      //< lookup an existing protocol class by name
 
 
 /*!
index 866875715f06764b63ffc33b6a226402a0585da8..69f49a40f0c12b43a102b870e83da16381524164 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2006,2008 Free Software Foundation, Inc.
+ * Copyright 2006,2008,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -59,8 +59,8 @@ public:
    */
   virtual bool run(const std::string &instance_name,
                   const std::string &class_name,
-                  pmt_t user_arg,
-                  pmt_t *result = 0) = 0;
+                  gruel::pmt_t user_arg,
+                  gruel::pmt_t *result = 0) = 0;
 
   // QA only...
   mb_mblock_sptr top() { return d_top; }
index 81079f032a480e3db5178638aa055a04b861bc9c..dbdfcdd9d5538bb7ff5dd57895b62d95203b5605 100644 (file)
@@ -21,7 +21,7 @@
 
 include $(top_srcdir)/Makefile.common
 
-AM_CPPFLAGS = $(DEFINES) $(OMNITHREAD_INCLUDES) $(PMT_INCLUDES) \
+AM_CPPFLAGS = $(DEFINES) $(OMNITHREAD_INCLUDES) $(GRUEL_INCLUDES) \
        $(BOOST_CPPFLAGS) $(CPPUNIT_INCLUDES) $(WITH_INCLUDES) \
        $(MBLOCK_INCLUDES)
 
@@ -73,7 +73,7 @@ libmblock_la_LDFLAGS = $(NO_UNDEFINED)
 # link the library against the c++ standard library
 libmblock_la_LIBADD =                  \
        $(OMNITHREAD_LA)                \
-       $(PMT_LA)                       \
+       $(GRUEL_LA)                     \
        -lstdc++                        
 
 noinst_HEADERS =                       \
index fe873a69a10f9b1eaa4210600d413ec5dc57a062..7055e7851c55ccd8e15cbd0079885a243f014c1c 100644 (file)
@@ -22,6 +22,8 @@
 #include <mblock/runtime.h>
 #include <iostream>
 
+using namespace gruel;
+
 int
 main(int argc, char **argv)
 {
index 80e05f50bf41975ef6b0a6de9dc5b3b8c1fe0248..883ab3604bb0ce48a980cb196e292e617003fe48 100644 (file)
@@ -30,7 +30,7 @@ mb_endpoint::inside_of_relay_port_p() const
   return d_port->port_type() == mb_port::RELAY && d_component_name == "self";
 }
 
-pmt_t
+gruel::pmt_t
 mb_endpoint::incoming_message_set() const
 {
   if (inside_of_relay_port_p())                        // swap incoming and outgoing
@@ -39,7 +39,7 @@ mb_endpoint::incoming_message_set() const
     return port()->incoming_message_set();
 }
 
-pmt_t
+gruel::pmt_t
 mb_endpoint::outgoing_message_set() const
 {
   if (inside_of_relay_port_p())                        // swap incoming and outgoing
index aae376a5d5d612b3082c76721c19ded0909873c9..96ff0de40a95a585435ad9ffd75b191138b21958 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2006,2008 Free Software Foundation, Inc.
+ * Copyright 2006,2008,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -51,8 +51,8 @@ public:
   //! Does this endpoint represent the inside of a relay port
   bool inside_of_relay_port_p() const;
 
-  pmt_t        incoming_message_set() const;
-  pmt_t        outgoing_message_set() const;
+  gruel::pmt_t incoming_message_set() const;
+  gruel::pmt_t outgoing_message_set() const;
 };
 
 #endif /* INCLUDED_MB_ENDPOINT_H */
index b2f763623cb370aa01df41fae10c63ea706615b3..77216ccb6eb4b0670a59ed2da67a4c637c089ef8 100644 (file)
@@ -30,8 +30,8 @@
 #include <iostream>
 
 
-static pmt_t s_sys_port = pmt_intern("%sys-port");
-static pmt_t s_halt = pmt_intern("%halt");
+static gruel::pmt_t s_sys_port = gruel::pmt_intern("%sys-port");
+static gruel::pmt_t s_halt = gruel::pmt_intern("%halt");
 
 mb_visitor::~mb_visitor()
 {
@@ -41,7 +41,7 @@ mb_visitor::~mb_visitor()
 
 mb_mblock::mb_mblock(mb_runtime *runtime,
                     const std::string &instance_name,
-                    pmt_t user_arg)
+                    gruel::pmt_t user_arg)
   : d_impl(mb_mblock_impl_sptr(
               new mb_mblock_impl(dynamic_cast<mb_runtime_base*>(runtime),
                                  this, instance_name)))
@@ -82,7 +82,7 @@ mb_mblock::main_loop()
        handle_message(msg);
       }
     }
-    catch (pmt_exception e){
+    catch (gruel::pmt_exception e){
       std::cerr << "\nmb_mblock::main_loop: ignored pmt_exception: "
                << e.what()
                << "\nin mblock instance \"" << instance_name()
@@ -112,7 +112,7 @@ mb_mblock::define_port(const std::string &port_name_string,
 void
 mb_mblock::define_component(const std::string &component_name,
                            const std::string &class_name,
-                           pmt_t user_arg)
+                           gruel::pmt_t user_arg)
                
 {
   d_impl->define_component(component_name, class_name, user_arg);
@@ -196,23 +196,23 @@ mb_mblock::exit()
 }
 
 void
-mb_mblock::shutdown_all(pmt_t result)
+mb_mblock::shutdown_all(gruel::pmt_t result)
 {
   d_impl->runtime()->request_shutdown(result);
 }
 
-pmt_t
-mb_mblock::schedule_one_shot_timeout(const mb_time &abs_time, pmt_t user_data)
+gruel::pmt_t
+mb_mblock::schedule_one_shot_timeout(const mb_time &abs_time, gruel::pmt_t user_data)
 {
   mb_msg_accepter_sptr accepter = impl()->make_accepter(s_sys_port);
   return d_impl->runtime()->schedule_one_shot_timeout(abs_time, user_data,
                                                      accepter);
 }
 
-pmt_t
+gruel::pmt_t
 mb_mblock::schedule_periodic_timeout(const mb_time &first_abs_time,
                                     const mb_time &delta_time,
-                                    pmt_t user_data)
+                                    gruel::pmt_t user_data)
 {
   mb_msg_accepter_sptr accepter = impl()->make_accepter(s_sys_port);
   return d_impl->runtime()->schedule_periodic_timeout(first_abs_time,
@@ -222,7 +222,7 @@ mb_mblock::schedule_periodic_timeout(const mb_time &first_abs_time,
 }
 
 void
-mb_mblock::cancel_timeout(pmt_t handle)
+mb_mblock::cancel_timeout(gruel::pmt_t handle)
 {
   d_impl->runtime()->cancel_timeout(handle);
 }
index e11b0089834a6ddec9d5dd5ad24640aff5a35d45..b57ac5d0033e1b106be9a2078b68daee78a1d207 100644 (file)
@@ -34,7 +34,7 @@
 #include <iostream>
 
 
-static pmt_t s_self = pmt_intern("self");
+static gruel::pmt_t s_self = gruel::pmt_intern("self");
 
 ////////////////////////////////////////////////////////////////////////
 
@@ -87,7 +87,7 @@ mb_mblock_impl::define_port(const std::string &port_name,
 void
 mb_mblock_impl::define_component(const std::string &name,
                                 const std::string &class_name,
-                                pmt_t user_arg)
+                                gruel::pmt_t user_arg)
 {
   {
     mbi_runtime_lock   l(this);
@@ -226,11 +226,11 @@ bool
 mb_mblock_impl::endpoints_are_compatible(const mb_endpoint &ep0,
                                         const mb_endpoint &ep1)
 {
-  pmt_t p0_outgoing = ep0.outgoing_message_set();
-  pmt_t p0_incoming = ep0.incoming_message_set();
+  gruel::pmt_t p0_outgoing = ep0.outgoing_message_set();
+  gruel::pmt_t p0_incoming = ep0.incoming_message_set();
 
-  pmt_t p1_outgoing = ep1.outgoing_message_set();
-  pmt_t p1_incoming = ep1.incoming_message_set();
+  gruel::pmt_t p1_outgoing = ep1.outgoing_message_set();
+  gruel::pmt_t p1_incoming = ep1.incoming_message_set();
 
   return (pmt_subsetp(p0_outgoing, p1_incoming)
          && pmt_subsetp(p1_outgoing, p0_incoming));
@@ -251,7 +251,7 @@ mb_mblock_impl::walk_tree(mb_visitor *visitor)
 }
 
 mb_msg_accepter_sptr
-mb_mblock_impl::make_accepter(pmt_t port_name)
+mb_mblock_impl::make_accepter(gruel::pmt_t port_name)
 {
   // FIXME this should probably use some kind of configurable factory
   mb_msg_accepter *ma =
index 99145791246374e98cb0cb9fc9ff362868c979bb..fa982cbabc50d1fa74e5d8e7f011bc012e72c52f 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2006,2007,2008 Free Software Foundation, Inc.
+ * Copyright 2006,2007,2008,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -87,7 +87,7 @@ public:
   void
   define_component(const std::string &component_name,
                   const std::string &class_name,
-                  pmt_t user_arg);
+                  gruel::pmt_t user_arg);
 
   /*!
    * \brief connect endpoint_1 to endpoint_2
@@ -148,7 +148,7 @@ public:
   walk_tree(mb_visitor *visitor);
   
   mb_msg_accepter_sptr
-  make_accepter(pmt_t port_name);
+  make_accepter(gruel::pmt_t port_name);
 
   mb_msg_queue &
   msgq() { return d_msgq; }
@@ -196,9 +196,9 @@ public:
    * Our implementation methods
    */
 private:
-  //bool port_is_defined(pmt_t name);
+  //bool port_is_defined(gruel::pmt_t name);
   bool port_is_defined(const std::string &name);
-  //bool comp_is_defined(pmt_t name);
+  //bool comp_is_defined(gruel::pmt_t name);
   bool comp_is_defined(const std::string &name);
 
   mb_endpoint 
index 664e369fa5f512d2120ffa5db6657fabd2bb13b7..729ff078f13534aa41f67c6929978a9cc128ee89 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2006,2008 Free Software Foundation, Inc.
+ * Copyright 2006,2008,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -24,7 +24,7 @@
 #endif
 #include <mblock/message.h>
 #include <stdio.h>
-#include <pmt_pool.h>
+#include <gruel/pmt_pool.h>
 
 static const int CACHE_LINE_SIZE = 64; // good guess
 static const int MAX_MESSAGES =  1024; // KLUDGE max number of messages in sys
@@ -54,14 +54,14 @@ mb_message::operator delete(void *p, size_t size)
 
 
 mb_message_sptr
-mb_make_message(pmt_t signal, pmt_t data, pmt_t metadata, mb_pri_t priority)
+mb_make_message(gruel::pmt_t signal, gruel::pmt_t data, gruel::pmt_t metadata, mb_pri_t priority)
 {
   return mb_message_sptr(new mb_message(signal, data, metadata, priority));
 }
 
-mb_message::mb_message(pmt_t signal, pmt_t data, pmt_t metadata, mb_pri_t priority)
+mb_message::mb_message(gruel::pmt_t signal, gruel::pmt_t data, gruel::pmt_t metadata, mb_pri_t priority)
   : d_signal(signal), d_data(data), d_metadata(metadata), d_priority(priority),
-    d_port_id(PMT_NIL)
+    d_port_id(gruel::PMT_NIL)
 {
 }
 
index fb97914e5b76bec779179cc26bbbdb3f14ab8b0a..e13ec5aa43f2495e7abdde63689daaf9ee5641c4 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2007,2008 Free Software Foundation, Inc.
+ * Copyright 2007,2008,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -25,7 +25,7 @@
 #include <mb_msg_accepter_msgq.h>
 #include <mblock/message.h>
 
-pmt_t s_sys_port = pmt_intern("%sys-port");
+gruel::pmt_t s_sys_port = gruel::pmt_intern("%sys-port");
 
 mb_msg_accepter_msgq::mb_msg_accepter_msgq(mb_msg_queue *msgq)
   : d_msgq(msgq)
@@ -37,8 +37,8 @@ mb_msg_accepter_msgq::~mb_msg_accepter_msgq()
 }
 
 void
-mb_msg_accepter_msgq::operator()(pmt_t signal, pmt_t data,
-                                pmt_t metadata, mb_pri_t priority)
+mb_msg_accepter_msgq::operator()(gruel::pmt_t signal, gruel::pmt_t data,
+                                gruel::pmt_t metadata, mb_pri_t priority)
 {
   mb_message_sptr msg = mb_make_message(signal, data, metadata, priority);
   msg->set_port_id(s_sys_port);
index 6c743bb4ba0084aa50e8f3a9036672f7bc7cf08c..e196d49b0a56d82ff1c1013d8e6cddcee2a6d9d7 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2007,2008 Free Software Foundation, Inc.
+ * Copyright 2007,2008,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -33,7 +33,7 @@ class mb_msg_accepter_msgq : public mb_msg_accepter {
 public:
   mb_msg_accepter_msgq(mb_msg_queue *msgq);
   ~mb_msg_accepter_msgq();
-  void operator()(pmt_t signal, pmt_t data, pmt_t metadata, mb_pri_t priority);
+  void operator()(gruel::pmt_t signal, gruel::pmt_t data, gruel::pmt_t metadata, mb_pri_t priority);
 };
 
 #endif /* INCLUDED_MB_MSG_ACCEPTER_MSGQ_H */
index 3b392a8c1b9c9ebaa9258d495b00c97f3bad0116..5d2872b05ade26c23c6d13fabbf1c936ab770eb9 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2007,2008 Free Software Foundation, Inc.
+ * Copyright 2007,2008,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -28,7 +28,7 @@
 #include <mb_mblock_impl.h>
 #include <mblock/message.h>
 
-mb_msg_accepter_smp::mb_msg_accepter_smp(mb_mblock_sptr mblock, pmt_t port_name)
+mb_msg_accepter_smp::mb_msg_accepter_smp(mb_mblock_sptr mblock, gruel::pmt_t port_name)
   : d_mb(mblock), d_port_name(port_name)
 {
 }
@@ -39,8 +39,8 @@ mb_msg_accepter_smp::~mb_msg_accepter_smp()
 }
 
 void
-mb_msg_accepter_smp::operator()(pmt_t signal, pmt_t data,
-                               pmt_t metadata, mb_pri_t priority)
+mb_msg_accepter_smp::operator()(gruel::pmt_t signal, gruel::pmt_t data,
+                               gruel::pmt_t metadata, mb_pri_t priority)
 {
   mb_message_sptr msg = mb_make_message(signal, data, metadata, priority);
   msg->set_port_id(d_port_name);
index 0e0cd7c643ee96f165126b523041dc27d94dfbc5..4e190410bdf1c2192fa36a93bb503420e495cbac 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2007 Free Software Foundation, Inc.
+ * Copyright 2007,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
 class mb_msg_accepter_smp : public mb_msg_accepter
 {
   mb_mblock_sptr       d_mb;
-  pmt_t                        d_port_name;
+  gruel::pmt_t         d_port_name;
   
 public:
-  mb_msg_accepter_smp(mb_mblock_sptr mblock, pmt_t port_name);
+  mb_msg_accepter_smp(mb_mblock_sptr mblock, gruel::pmt_t port_name);
   ~mb_msg_accepter_smp();
 
-  void operator()(pmt_t signal, pmt_t data, pmt_t metadata, mb_pri_t priority);
+  void operator()(gruel::pmt_t signal, gruel::pmt_t data, gruel::pmt_t metadata, mb_pri_t priority);
 };
 
 
index a13f49f2c6cf1ecad96b3e7ba9b952673dc0f979..abf909fd339e7004b6629b2799e1ec0127b2310e 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2006,2008 Free Software Foundation, Inc.
+ * Copyright 2006,2008,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -31,11 +31,11 @@ mb_port::mb_port(mb_mblock *mblock,
                 const std::string &protocol_class_name,
                 bool conjugated,
                 mb_port::port_type_t port_type)
-  : d_port_name(port_name), d_port_symbol(pmt_intern(port_name)),
+  : d_port_name(port_name), d_port_symbol(gruel::pmt_intern(port_name)),
     d_conjugated(conjugated), d_port_type(port_type),
     d_mblock(mblock)
 {
-  pmt_t pc = mb_protocol_class_lookup(pmt_intern(protocol_class_name));
+  gruel::pmt_t pc = mb_protocol_class_lookup(gruel::pmt_intern(protocol_class_name));
   if (pmt_is_null(pc)){
     throw std::runtime_error("mb_port: unknown protocol class '"
                             + protocol_class_name + "'");
@@ -48,7 +48,7 @@ mb_port::~mb_port()
   // nop
 }
 
-pmt_t
+gruel::pmt_t
 mb_port::incoming_message_set() const
 {
   if (!conjugated())
@@ -57,7 +57,7 @@ mb_port::incoming_message_set() const
     return mb_protocol_class_outgoing(protocol_class());
 }
 
-pmt_t
+gruel::pmt_t
 mb_port::outgoing_message_set() const
 {
   if (!conjugated())
index 1b4b35cbf11b4415a00463472d24ef8146898962..3005932f13bf15482b693e6a602e68dacf238c1f 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2007,2008 Free Software Foundation, Inc.
+ * Copyright 2007,2008,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -48,7 +48,7 @@ mb_port_simple::~mb_port_simple()
 }
 
 void
-mb_port_simple::send(pmt_t signal, pmt_t data, pmt_t metadata, mb_pri_t priority)
+mb_port_simple::send(gruel::pmt_t signal, gruel::pmt_t data, gruel::pmt_t metadata, mb_pri_t priority)
 {
   if (port_type() == mb_port::RELAY)  // Can't send directly to a RELAY port
     throw mbe_invalid_port_type(mblock(), mblock()->instance_name(), port_name());
index 87b7654b0ddc4cff4d1eb22057c64c8e0c11ba42..a2136ed0aaad6bc989e1ebd22d566f50df97e5e8 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2007,2008 Free Software Foundation, Inc.
+ * Copyright 2007,2008,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -56,9 +56,9 @@ public:
    * \param priority   the urgency at which the message is sent
    */
   void
-  send(pmt_t signal,
-       pmt_t data = PMT_NIL,
-       pmt_t metadata = PMT_NIL,
+  send(gruel::pmt_t signal,
+       gruel::pmt_t data = gruel::PMT_NIL,
+       gruel::pmt_t metadata = gruel::PMT_NIL,
        mb_pri_t priority = MB_PRI_DEFAULT);
 
   /*
index f076909e1ce8c0661ac38803ae78584a67f7deb2..6492c15516057e46525a03508bc011320c4cb1ad 100644 (file)
 #include <mblock/protocol_class.h>
 #include <iostream>
 
-static pmt_t s_ALL_PROTOCOL_CLASSES = PMT_NIL;
+static gruel::pmt_t s_ALL_PROTOCOL_CLASSES = gruel::PMT_NIL;
 
-pmt_t 
-mb_make_protocol_class(pmt_t name, pmt_t incoming, pmt_t outgoing)
+gruel::pmt_t 
+mb_make_protocol_class(gruel::pmt_t name, gruel::pmt_t incoming, gruel::pmt_t outgoing)
 {
   // (protocol-class <name> <incoming> <outgoing>)
 
-  if (!pmt_is_symbol(name))
-    throw pmt_wrong_type("mb_make_protocol_class: NAME must be symbol", name);
-  if (!(pmt_is_pair(incoming) || pmt_is_null(incoming)))
-    throw pmt_wrong_type("mb_make_protocol_class: INCOMING must be a list", name);
-  if (!(pmt_is_pair(outgoing) || pmt_is_null(outgoing)))
-    throw pmt_wrong_type("mb_make_protocol_class: OUTGOING must be a list", name);
+  if (!gruel::pmt_is_symbol(name))
+    throw gruel::pmt_wrong_type("mb_make_protocol_class: NAME must be symbol", name);
+  if (!(gruel::pmt_is_pair(incoming) || gruel::pmt_is_null(incoming)))
+    throw gruel::pmt_wrong_type("mb_make_protocol_class: INCOMING must be a list", name);
+  if (!(gruel::pmt_is_pair(outgoing) || gruel::pmt_is_null(outgoing)))
+    throw gruel::pmt_wrong_type("mb_make_protocol_class: OUTGOING must be a list", name);
 
-  pmt_t t = pmt_cons(pmt_intern("protocol-class"),
-                    pmt_cons(name,
-                             pmt_cons(incoming,
-                                      pmt_cons(outgoing, PMT_NIL))));
+  gruel::pmt_t t = gruel::pmt_cons(gruel::pmt_intern("protocol-class"),
+                    gruel::pmt_cons(name,
+                             gruel::pmt_cons(incoming,
+                                      gruel::pmt_cons(outgoing, gruel::PMT_NIL))));
 
   // Remember this protocol class.
-  s_ALL_PROTOCOL_CLASSES = pmt_cons(t, s_ALL_PROTOCOL_CLASSES);
+  s_ALL_PROTOCOL_CLASSES = gruel::pmt_cons(t, s_ALL_PROTOCOL_CLASSES);
   return t;
 }
 
-pmt_t
-mb_protocol_class_name(pmt_t pc)
+gruel::pmt_t
+mb_protocol_class_name(gruel::pmt_t pc)
 {
-  return pmt_nth(1, pc);
+  return gruel::pmt_nth(1, pc);
 }
 
-pmt_t
-mb_protocol_class_incoming(pmt_t pc)
+gruel::pmt_t
+mb_protocol_class_incoming(gruel::pmt_t pc)
 {
-  return pmt_nth(2, pc);
+  return gruel::pmt_nth(2, pc);
 }
 
-pmt_t
-mb_protocol_class_outgoing(pmt_t pc)
+gruel::pmt_t
+mb_protocol_class_outgoing(gruel::pmt_t pc)
 {
-  return pmt_nth(3, pc);
+  return gruel::pmt_nth(3, pc);
 }
 
-pmt_t
-mb_protocol_class_lookup(pmt_t name)
+gruel::pmt_t
+mb_protocol_class_lookup(gruel::pmt_t name)
 {
-  pmt_t lst = s_ALL_PROTOCOL_CLASSES;
+  gruel::pmt_t lst = s_ALL_PROTOCOL_CLASSES;
 
-  while (pmt_is_pair(lst)){
-    if (pmt_eq(name, mb_protocol_class_name(pmt_car(lst))))
-      return pmt_car(lst);
-    lst = pmt_cdr(lst);
+  while (gruel::pmt_is_pair(lst)){
+    if (gruel::pmt_eq(name, mb_protocol_class_name(gruel::pmt_car(lst))))
+      return gruel::pmt_car(lst);
+    lst = gruel::pmt_cdr(lst);
   }
 
-  return PMT_NIL;
+  return gruel::PMT_NIL;
 }
 
 mb_protocol_class_init::mb_protocol_class_init(const char *data, size_t len)
@@ -88,18 +88,18 @@ mb_protocol_class_init::mb_protocol_class_init(const char *data, size_t len)
   sb.str(std::string(data, len));
 
   while (1){
-    pmt_t obj = pmt_deserialize(sb);
+    gruel::pmt_t obj = gruel::pmt_deserialize(sb);
 
     if (0){
-      pmt_write(obj, std::cout);
+      gruel::pmt_write(obj, std::cout);
       std::cout << std::endl;
     }
 
-    if (pmt_is_eof_object(obj))
+    if (gruel::pmt_is_eof_object(obj))
       return;
 
-    mb_make_protocol_class(pmt_nth(0, obj),   // protocol-class name
-                          pmt_nth(1, obj),   // list of incoming msg names
-                          pmt_nth(2, obj));  // list of outgoing msg names
+    mb_make_protocol_class(gruel::pmt_nth(0, obj),   // protocol-class name
+                          gruel::pmt_nth(1, obj),   // list of incoming msg names
+                          gruel::pmt_nth(2, obj));  // list of outgoing msg names
   }
 }
index 1dea4d46ecfb3392b4c054f9ee73318e6155ad66..872cf336e6f9db1c781c8f3e82a865d6792d770a 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2007,2008 Free Software Foundation, Inc.
+ * Copyright 2007,2008,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
  */
 
 void
-mb_runtime_base::request_shutdown(pmt_t result)
+mb_runtime_base::request_shutdown(gruel::pmt_t result)
 {
 }
 
-pmt_t
+gruel::pmt_t
 mb_runtime_base::schedule_one_shot_timeout(const mb_time &abs_time,
-                                          pmt_t user_data,
+                                          gruel::pmt_t user_data,
                                           mb_msg_accepter_sptr accepter)
 {
-  return PMT_F;
+  return gruel::PMT_F;
 }
 
-pmt_t
+gruel::pmt_t
 mb_runtime_base::schedule_periodic_timeout(const mb_time &first_abs_time,
                                           const mb_time &delta_time,
-                                          pmt_t user_data,
+                                          gruel::pmt_t user_data,
                                           mb_msg_accepter_sptr accepter)
 {
-  return PMT_F;
+  return gruel::PMT_F;
 }
 
 void
-mb_runtime_base::cancel_timeout(pmt_t handle)
+mb_runtime_base::cancel_timeout(gruel::pmt_t handle)
 {
 }
 
index 98b5f3e0a8a15e2cc2e87ce417399fdb2f0d8c28..d5ec29c21ea81b96010b9969478c719cfc811db5 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2007 Free Software Foundation, Inc.
+ * Copyright 2007,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -50,24 +50,24 @@ public:
    */
   inline void unlock() { d_brl.unlock(); }
 
-  virtual void request_shutdown(pmt_t result);
+  virtual void request_shutdown(gruel::pmt_t result);
 
   virtual mb_mblock_sptr
   create_component(const std::string &instance_name,
                   const std::string &class_name,
-                  pmt_t user_arg) = 0;
+                  gruel::pmt_t user_arg) = 0;
 
-  virtual pmt_t
-  schedule_one_shot_timeout(const mb_time &abs_time, pmt_t user_data,
+  virtual gruel::pmt_t
+  schedule_one_shot_timeout(const mb_time &abs_time, gruel::pmt_t user_data,
                            mb_msg_accepter_sptr accepter);
 
-  virtual pmt_t
+  virtual gruel::pmt_t
   schedule_periodic_timeout(const mb_time &first_abs_time,
                            const mb_time &delta_time,
-                           pmt_t user_data,
+                           gruel::pmt_t user_data,
                            mb_msg_accepter_sptr accepter);
   virtual void
-  cancel_timeout(pmt_t handle);
+  cancel_timeout(gruel::pmt_t handle);
 
   mb_msg_accepter_sptr
   accepter() { return d_accepter; }
index 603d5addb101ac40c9e8986f6413e8e1f7e950a2..3ea6d093b60e2f559fa65a2d0328bbfa9ce38cdc 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2007,2008 Free Software Foundation, Inc.
+ * Copyright 2007,2008,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -48,7 +48,7 @@ mb_runtime_nop::~mb_runtime_nop()
 bool
 mb_runtime_nop::run(const std::string &instance_name,
                    const std::string &class_name,
-                   pmt_t user_arg, pmt_t *result)
+                   gruel::pmt_t user_arg, gruel::pmt_t *result)
 {
   class initial_visitor : public mb_visitor
   {
@@ -63,7 +63,7 @@ mb_runtime_nop::run(const std::string &instance_name,
   initial_visitor visitor;
 
   if (result)
-    *result = PMT_T;
+    *result = gruel::PMT_T;
 
   d_top = create_component(instance_name, class_name, user_arg);
   d_top->walk_tree(&visitor);
@@ -74,7 +74,7 @@ mb_runtime_nop::run(const std::string &instance_name,
 mb_mblock_sptr
 mb_runtime_nop::create_component(const std::string &instance_name,
                                 const std::string &class_name,
-                                pmt_t user_arg)
+                                gruel::pmt_t user_arg)
 {
   mb_mblock_maker_t maker;
   if (!mb_class_registry::lookup_maker(class_name, &maker))
index 9d1f574d7b7c24a27ae8f7a264e766455d96e667..a57d0b604b950e0246148509fa13033dadbc26be 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2007 Free Software Foundation, Inc.
+ * Copyright 2007,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -39,14 +39,14 @@ public:
 
   bool run(const std::string &instance_name,
           const std::string &class_name,
-          pmt_t user_arg,
-          pmt_t *result);
+          gruel::pmt_t user_arg,
+          gruel::pmt_t *result);
 
 protected:
   mb_mblock_sptr
   create_component(const std::string &instance_name,
                   const std::string &class_name,
-                  pmt_t user_arg);
+                  gruel::pmt_t user_arg);
 };
 
 #endif /* INCLUDED_MB_RUNTIME_NOP_H */
index ed292ee7c9438b96daea7ff85d7f4c3ee0f90a1f..f92b98f765535eefc52981f8ba94dbde94995b4a 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2007,2008 Free Software Foundation, Inc.
+ * Copyright 2007,2008,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
 #include <mb_msg_accepter_msgq.h>
 
 
-static pmt_t s_halt = pmt_intern("%halt");
-static pmt_t s_sys_port = pmt_intern("%sys-port");
-static pmt_t s_shutdown = pmt_intern("%shutdown");
-static pmt_t s_request_shutdown = pmt_intern("%request-shutdown");
-static pmt_t s_worker_state_changed = pmt_intern("%worker-state-changed");
-static pmt_t s_timeout = pmt_intern("%timeout");
-static pmt_t s_request_timeout = pmt_intern("%request-timeout");
-static pmt_t s_cancel_timeout = pmt_intern("%cancel-timeout");
-static pmt_t s_send_halt = pmt_intern("send-halt");
-static pmt_t s_exit_now = pmt_intern("exit-now");
+static gruel::pmt_t s_halt = gruel::pmt_intern("%halt");
+static gruel::pmt_t s_sys_port = gruel::pmt_intern("%sys-port");
+static gruel::pmt_t s_shutdown = gruel::pmt_intern("%shutdown");
+static gruel::pmt_t s_request_shutdown = gruel::pmt_intern("%request-shutdown");
+static gruel::pmt_t s_worker_state_changed = gruel::pmt_intern("%worker-state-changed");
+static gruel::pmt_t s_timeout = gruel::pmt_intern("%timeout");
+static gruel::pmt_t s_request_timeout = gruel::pmt_intern("%request-timeout");
+static gruel::pmt_t s_cancel_timeout = gruel::pmt_intern("%cancel-timeout");
+static gruel::pmt_t s_send_halt = gruel::pmt_intern("send-halt");
+static gruel::pmt_t s_exit_now = gruel::pmt_intern("exit-now");
 
 static void
-send_sys_msg(mb_msg_queue &msgq, pmt_t signal,
-            pmt_t data = PMT_F, pmt_t metadata = PMT_F,
+send_sys_msg(mb_msg_queue &msgq, gruel::pmt_t signal,
+            gruel::pmt_t data = gruel::PMT_F, gruel::pmt_t metadata = gruel::PMT_F,
             mb_pri_t priority = MB_PRI_BEST)
 {
   mb_message_sptr msg = mb_make_message(signal, data, metadata, priority);
@@ -57,7 +57,7 @@ send_sys_msg(mb_msg_queue &msgq, pmt_t signal,
 
 mb_runtime_thread_per_block::mb_runtime_thread_per_block()
   : d_shutdown_in_progress(false),
-    d_shutdown_result(PMT_T)
+    d_shutdown_result(gruel::PMT_T)
 {
   d_accepter = mb_msg_accepter_sptr(new mb_msg_accepter_msgq(&d_msgq));
 }
@@ -72,22 +72,22 @@ mb_runtime_thread_per_block::~mb_runtime_thread_per_block()
 }
 
 void
-mb_runtime_thread_per_block::request_shutdown(pmt_t result)
+mb_runtime_thread_per_block::request_shutdown(gruel::pmt_t result)
 {
-  (*accepter())(s_request_shutdown, result, PMT_F, MB_PRI_BEST);
+  (*accepter())(s_request_shutdown, result, gruel::PMT_F, MB_PRI_BEST);
 }
 
 bool
 mb_runtime_thread_per_block::run(const std::string &instance_name,
                                 const std::string &class_name,
-                                pmt_t user_arg, pmt_t *result)
+                                gruel::pmt_t user_arg, gruel::pmt_t *result)
 {
   if (result)          // set it to something now, in case we throw
-    *result = PMT_F;
+    *result = gruel::PMT_F;
   
   // reset the shutdown state
   d_shutdown_in_progress = false;
-  d_shutdown_result = PMT_T;
+  d_shutdown_result = gruel::PMT_T;
 
   assert(d_workers.empty());
 
@@ -144,15 +144,15 @@ mb_runtime_thread_per_block::run_loop()
       }
     }
 
-    pmt_t signal = msg->signal();
+    gruel::pmt_t signal = msg->signal();
 
-    if (pmt_eq(signal, s_worker_state_changed)){       // %worker-state-changed
+    if (gruel::pmt_eq(signal, s_worker_state_changed)){        // %worker-state-changed
       omni_mutex_lock l1(d_workers_mutex);
       reap_dead_workers();
       if (d_workers.empty())   // no work left to do...
        return;
     }
-    else if (pmt_eq(signal, s_request_shutdown)){      // %request-shutdown
+    else if (gruel::pmt_eq(signal, s_request_shutdown)){       // %request-shutdown
       if (!d_shutdown_in_progress){
        d_shutdown_in_progress = true;
        d_shutdown_result = msg->data();
@@ -162,23 +162,23 @@ mb_runtime_thread_per_block::run_loop()
        send_all_sys_msg(s_shutdown);
       }
     }
-    else if (pmt_eq(signal, s_request_timeout)){       // %request-timeout
+    else if (gruel::pmt_eq(signal, s_request_timeout)){        // %request-timeout
       mb_timeout_sptr to =
-       boost::any_cast<mb_timeout_sptr>(pmt_any_ref(msg->data()));
+       boost::any_cast<mb_timeout_sptr>(gruel::pmt_any_ref(msg->data()));
       d_timer_queue.push(to);
     }
-    else if (pmt_eq(signal, s_cancel_timeout)){                // %cancel-timeout
+    else if (gruel::pmt_eq(signal, s_cancel_timeout)){         // %cancel-timeout
       d_timer_queue.cancel(msg->data());
     }
-    else if (pmt_eq(signal, s_timeout)
-            && pmt_eq(msg->data(), s_send_halt)){      // %timeout, send-halt
+    else if (gruel::pmt_eq(signal, s_timeout)
+            && gruel::pmt_eq(msg->data(), s_send_halt)){       // %timeout, send-halt
 
       // schedule another timeout for ourselves...
       schedule_one_shot_timeout(mb_time::time(0.100), s_exit_now, d_accepter);
       send_all_sys_msg(s_halt);
     }
-    else if (pmt_eq(signal, s_timeout)
-            && pmt_eq(msg->data(), s_exit_now)){       // %timeout, exit-now
+    else if (gruel::pmt_eq(signal, s_timeout)
+            && gruel::pmt_eq(msg->data(), s_exit_now)){        // %timeout, exit-now
 
       // We only get here if we've sent all workers %shutdown followed
       // by %halt, and one or more of them is still alive.  They must
@@ -234,7 +234,7 @@ mb_runtime_thread_per_block::reap_dead_workers()
 mb_mblock_sptr
 mb_runtime_thread_per_block::create_component(const std::string &instance_name,
                                              const std::string &class_name,
-                                             pmt_t user_arg)
+                                             gruel::pmt_t user_arg)
 {
   mb_mblock_maker_t maker;
   if (!mb_class_registry::lookup_maker(class_name, &maker))
@@ -293,9 +293,9 @@ mb_runtime_thread_per_block::create_component(const std::string &instance_name,
 }
 
 void
-mb_runtime_thread_per_block::send_all_sys_msg(pmt_t signal,
-                                             pmt_t data,
-                                             pmt_t metadata,
+mb_runtime_thread_per_block::send_all_sys_msg(gruel::pmt_t signal,
+                                             gruel::pmt_t data,
+                                             gruel::pmt_t metadata,
                                              mb_pri_t priority)
 {
   omni_mutex_lock l1(d_workers_mutex);
@@ -310,14 +310,14 @@ mb_runtime_thread_per_block::send_all_sys_msg(pmt_t signal,
 // Can be invoked from any thread.
 // Sends a message to the runtime.
 //
-pmt_t
+gruel::pmt_t
 mb_runtime_thread_per_block::schedule_one_shot_timeout
   (const mb_time &abs_time,
-   pmt_t user_data,
+   gruel::pmt_t user_data,
    mb_msg_accepter_sptr accepter)
 {
   mb_timeout_sptr to(new mb_timeout(abs_time, user_data, accepter));
-  (*d_accepter)(s_request_timeout, pmt_make_any(to), PMT_F, MB_PRI_BEST);
+  (*d_accepter)(s_request_timeout, gruel::pmt_make_any(to), gruel::PMT_F, MB_PRI_BEST);
   return to->handle();
 }
 
@@ -325,16 +325,16 @@ mb_runtime_thread_per_block::schedule_one_shot_timeout
 // Can be invoked from any thread.
 // Sends a message to the runtime.
 //
-pmt_t
+gruel::pmt_t
 mb_runtime_thread_per_block::schedule_periodic_timeout
   (const mb_time &first_abs_time,
    const mb_time &delta_time,
-   pmt_t user_data,
+   gruel::pmt_t user_data,
    mb_msg_accepter_sptr accepter)
 {
   mb_timeout_sptr to(new mb_timeout(first_abs_time, delta_time,
                                    user_data, accepter));
-  (*d_accepter)(s_request_timeout, pmt_make_any(to), PMT_F, MB_PRI_BEST);
+  (*d_accepter)(s_request_timeout, gruel::pmt_make_any(to), gruel::PMT_F, MB_PRI_BEST);
   return to->handle();
 }
 
@@ -343,7 +343,7 @@ mb_runtime_thread_per_block::schedule_periodic_timeout
 // Sends a message to the runtime.
 //
 void
-mb_runtime_thread_per_block::cancel_timeout(pmt_t handle)
+mb_runtime_thread_per_block::cancel_timeout(gruel::pmt_t handle)
 {
-  (*d_accepter)(s_cancel_timeout, handle, PMT_F, MB_PRI_BEST);
+  (*d_accepter)(s_cancel_timeout, handle, gruel::PMT_F, MB_PRI_BEST);
 }
index 185ed32b5b74342192521e70e8620dd5a9a84625..b448667862150220b5f6cccc94af572938cc5e6b 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2007 Free Software Foundation, Inc.
+ * Copyright 2007,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -38,7 +38,7 @@ public:
   omni_mutex                 d_workers_mutex;  // hold while manipulating d_workers
   std::vector<mb_worker*>     d_workers;
   bool                       d_shutdown_in_progress;
-  pmt_t                              d_shutdown_result;
+  gruel::pmt_t               d_shutdown_result;
   mb_msg_queue               d_msgq;
   mb_timer_queue             d_timer_queue;
 
@@ -49,35 +49,35 @@ public:
 
   bool run(const std::string &instance_name,
           const std::string &class_name,
-          pmt_t user_arg,
-          pmt_t *result);
+          gruel::pmt_t user_arg,
+          gruel::pmt_t *result);
 
-  void request_shutdown(pmt_t result);
+  void request_shutdown(gruel::pmt_t result);
 
 protected:
   mb_mblock_sptr
   create_component(const std::string &instance_name,
                   const std::string &class_name,
-                  pmt_t user_arg);
+                  gruel::pmt_t user_arg);
 
-  pmt_t
-  schedule_one_shot_timeout(const mb_time &abs_time, pmt_t user_data,
+  gruel::pmt_t
+  schedule_one_shot_timeout(const mb_time &abs_time, gruel::pmt_t user_data,
                            mb_msg_accepter_sptr accepter);
 
-  pmt_t
+  gruel::pmt_t
   schedule_periodic_timeout(const mb_time &first_abs_time,
                            const mb_time &delta_time,
-                           pmt_t user_data,
+                           gruel::pmt_t user_data,
                            mb_msg_accepter_sptr accepter);
   void
-  cancel_timeout(pmt_t handle);
+  cancel_timeout(gruel::pmt_t handle);
 
 private:
   void reap_dead_workers();
   void run_loop();
 
-  void send_all_sys_msg(pmt_t signal, pmt_t data = PMT_F,
-                       pmt_t metadata = PMT_F,
+  void send_all_sys_msg(gruel::pmt_t signal, gruel::pmt_t data = gruel::PMT_F,
+                       gruel::pmt_t metadata = gruel::PMT_F,
                        mb_pri_t priority = MB_PRI_BEST);
 };
 
index 1293e8a4cc3f18dcab454c12f8211333f0eaf336..dbdcc4ce128f4e71c9dcafeebd61221d5f6053a6 100644 (file)
 #endif
 #include <mb_timer_queue.h>
 
-static pmt_t
+static gruel::pmt_t
 make_handle()
 {
   static long counter = 0;
-  pmt_t n = pmt_from_long(counter++);
-  return pmt_list1(n);         // guaranteed to be a unique object
+  gruel::pmt_t n = gruel::pmt_from_long(counter++);
+  return gruel::pmt_list1(n);          // guaranteed to be a unique object
 }
 
 // one-shot constructor
 mb_timeout::mb_timeout(const mb_time &abs_time,
-                      pmt_t user_data, mb_msg_accepter_sptr accepter)
+                      gruel::pmt_t user_data, mb_msg_accepter_sptr accepter)
   : d_when(abs_time), d_is_periodic(false),
     d_user_data(user_data), d_handle(make_handle()), d_accepter(accepter)
 {
@@ -42,19 +42,19 @@ mb_timeout::mb_timeout(const mb_time &abs_time,
 
 // periodic constructor
 mb_timeout::mb_timeout(const mb_time &first_abs_time, const mb_time &delta_time,
-                      pmt_t user_data, mb_msg_accepter_sptr accepter)
+                      gruel::pmt_t user_data, mb_msg_accepter_sptr accepter)
   : d_when(first_abs_time), d_delta(delta_time), d_is_periodic(true),
     d_user_data(user_data), d_handle(make_handle()), d_accepter(accepter)
 {
 }
 
 void
-mb_timer_queue::cancel(pmt_t handle)
+mb_timer_queue::cancel(gruel::pmt_t handle)
 {
   container_type::iterator it;
 
   for (it = c.begin(); it != c.end();){
-    if (pmt_equal((*it)->handle(), handle))
+    if (gruel::pmt_equal((*it)->handle(), handle))
       it = c.erase(it);
     else
       ++it;
index e8b8e1b641d5a6ce2737b0cfe6b936b789da93dd..8dcf533836d4d20bd77cf7e4ef23df6717c565cc 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2007,2008 Free Software Foundation, Inc.
+ * Copyright 2007,2008,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -25,7 +25,7 @@
 #include <mblock/time.h>
 #include <vector>
 #include <queue>
-#include <pmt.h>
+#include <gruel/pmt.h>
 #include <mblock/msg_accepter.h>
 
 class mb_timeout {
@@ -33,19 +33,19 @@ public:
   mb_time              d_when;         // absolute time to fire timeout
   mb_time              d_delta;        // if periodic, delta_t to next timeout
   bool                 d_is_periodic;  // true iff this is a periodic timeout
-  pmt_t                        d_user_data;    // data from %timeout msg
-  pmt_t                        d_handle;       // handle for cancellation
+  gruel::pmt_t         d_user_data;    // data from %timeout msg
+  gruel::pmt_t         d_handle;       // handle for cancellation
   mb_msg_accepter_sptr d_accepter;     // where to send the message
 
   // one-shot constructor
   mb_timeout(const mb_time &abs_time,
-            pmt_t user_data, mb_msg_accepter_sptr accepter);
+            gruel::pmt_t user_data, mb_msg_accepter_sptr accepter);
 
   // periodic constructor
   mb_timeout(const mb_time &first_abs_time, const mb_time &delta_time,
-            pmt_t user_data, mb_msg_accepter_sptr accepter);
+            gruel::pmt_t user_data, mb_msg_accepter_sptr accepter);
 
-  pmt_t handle() const { return d_handle; }
+  gruel::pmt_t handle() const { return d_handle; }
 };
 
 typedef boost::shared_ptr<mb_timeout> mb_timeout_sptr;
@@ -67,7 +67,7 @@ class mb_timer_queue : public std::priority_queue<mb_timeout_sptr,
                                                  timeout_later>
 {
 public:
-  void cancel(pmt_t handle);
+  void cancel(gruel::pmt_t handle);
 };
 
 #endif /* INCLUDED_MB_TIMER_QUEUE_H */
index 3b984875ff7c0950d213bcad491380d8f306d003..a553198ea9847e3e4e683f43dc974248c2e70347 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2007,2008 Free Software Foundation, Inc.
+ * Copyright 2007,2008,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
 #define VERBOSE 0              // define to 0 or 1
 
 
-static pmt_t s_worker_state_changed = pmt_intern("%worker-state-changed");
+static gruel::pmt_t s_worker_state_changed = gruel::pmt_intern("%worker-state-changed");
 
 
 mb_worker::mb_worker(mb_runtime_thread_per_block *runtime,
                     mb_mblock_maker_t maker,
                     const std::string &instance_name,
-                    pmt_t user_arg)
+                    gruel::pmt_t user_arg)
   : omni_thread((void *) 0, PRIORITY_NORMAL),
     d_runtime(runtime), d_maker(maker),
     d_instance_name(instance_name), d_user_arg(user_arg),
@@ -95,7 +95,7 @@ mb_worker::set_state(worker_state_t state)
   }
 
   // send msg to runtime, telling it something changed.
-  (*d_runtime->accepter())(s_worker_state_changed, PMT_F, PMT_F, MB_PRI_BEST);
+  (*d_runtime->accepter())(s_worker_state_changed, gruel::PMT_F, gruel::PMT_F, MB_PRI_BEST);
 }
 
 void *
index 59d12545ca7a7fa5a0c7ace9a38d86a6eb3cda4a..0bd2fcaeb15cf925ab2c86102df2f062a579001a 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2007,2008 Free Software Foundation, Inc.
+ * Copyright 2007,2008,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -62,7 +62,7 @@ public:
   mb_runtime_thread_per_block  *d_runtime;
   mb_mblock_maker_t            d_maker;
   std::string                  d_instance_name;
-  pmt_t                                d_user_arg;
+  gruel::pmt_t                 d_user_arg;
 
   mb_mblock_sptr               d_mblock;       //< holds pointer to created mblock
 
@@ -80,7 +80,7 @@ public:
   mb_worker(mb_runtime_thread_per_block *runtime,
            mb_mblock_maker_t maker,
            const std::string &instance_name,
-           pmt_t user_arg);
+           gruel::pmt_t user_arg);
 
   // ~mb_worker();
 
index 0ed78d9f9ae9c21d3693cc8dfbf01c33951d63ab..1b4725123692fd43258c6fb801c18e5f670a4d11 100644 (file)
@@ -31,6 +31,8 @@
 #include <sstream>
 #include <bitset>
 
+using namespace gruel;
+
 static pmt_t s_in = pmt_intern("in");
 static pmt_t s_out = pmt_intern("out");
 static pmt_t s_data = pmt_intern("data");
index 3f44bb5f42025d2a67ae87266a7d5fa47ed3d04c..09bdf2e6ae5af43799bc79aeca8d0e7a488c83ff 100644 (file)
@@ -31,6 +31,8 @@
 #include <sstream>
 #include <bitset>
 
+using namespace gruel;
+
 static pmt_t s_in = pmt_intern("in");
 static pmt_t s_out = pmt_intern("out");
 static pmt_t s_data = pmt_intern("data");
index 2eed3afde3979771bf195b3301c4cf805a3fc297..6e0d5531305370c14d25f74e811afaa3f7a89282 100644 (file)
@@ -37,6 +37,8 @@
 #include <mblock/class_registry.h>
 #include <stdio.h>
 
+using namespace gruel;
+
 static pmt_t s_cs = pmt_intern("cs");
 static pmt_t s_debug = pmt_intern("debug");
 static pmt_t s_in = pmt_intern("in");
index 114dbdc4eb8721ba1acc6936dcfa6b4077b599dc..e9c91499a24f4a22dd1486a34ee9221cae147fec 100644 (file)
@@ -38,6 +38,8 @@
 #include <mblock/class_registry.h>
 #include <stdio.h>
 
+using namespace gruel;
+
 static pmt_t s_data    = pmt_intern("data");
 static pmt_t s_status  = pmt_intern("status");
 static pmt_t s_control = pmt_intern("control");
index 58e48f715fbea71ccfb2d7820e45da2311cc322e..e8ff780ac3b89964c64e5ea3cb29508688b114f0 100644 (file)
@@ -40,6 +40,7 @@
 #include <string.h>
 #include <iostream>
 
+using namespace gruel;
 
 static pmt_t s_data    = pmt_intern("data");
 static pmt_t s_status  = pmt_intern("status");
index 2505635c1ded396e7e52f109c7f1f00fab87dce4..39761c0b1558b12d2d650da970a21e1a03540bc4 100644 (file)
@@ -34,6 +34,7 @@
 #include <string.h>
 #include <iostream>
 
+using namespace gruel;
 
 static pmt_t s_timeout = pmt_intern("%timeout");
 static pmt_t s_done = pmt_intern("done");
diff --git a/pmt/Makefile.am b/pmt/Makefile.am
deleted file mode 100644 (file)
index 758eb1d..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# Copyright 2004,2008 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 GNU Radio; see the file COPYING.  If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-# 
-
-include $(top_srcdir)/Makefile.common
-
-EXTRA_DIST = pmt.pc.in
-
-SUBDIRS = src
-DIST_SUBDIRS = src doc
-
-pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = pmt.pc
diff --git a/pmt/README b/pmt/README
deleted file mode 100644 (file)
index 59a1f4a..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# Copyright 2006 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 GNU Radio; see the file COPYING.  If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-# 
-
-This directory hierarchy contains an implementation of 
-polymorphic types.  These are similar to lisp or python data objects,
-and implement transparent reference counting using the boost shared_ptr
-templates.
-
diff --git a/pmt/doc/Makefile.am b/pmt/doc/Makefile.am
deleted file mode 100644 (file)
index a806b25..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-#
-# Copyright 2004,2005,2006 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 GNU Radio; see the file COPYING.  If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-# 
-
-TARGETS = 
-
-
-# To avoid build problems for folks who don't have xmlto installed, we
-# don't build the docs by default.
-
-# html: $(TARGETS)
-all: $(TARGETS)
-
-
-EXTRA_DIST =                           
-
-BUILT_XML_FILES =                      
-
-
-# ----------------------------------------------------------------
-
-clean:
-       -rm -f $(TARGETS) $(BUILT_XML_FILES)
-
-# This is non-portable pattern rule.
-#%.html : %.xml
-#      xmlto html-nochunks $<
diff --git a/pmt/pmt.pc.in b/pmt/pmt.pc.in
deleted file mode 100644 (file)
index b2f86ea..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-
-Name: pmt
-Description: The GNU Radio Polymorphic Type library
-Requires: 
-Version: @VERSION@
-Libs: -L${libdir} -lpmt
-Cflags: -I${includedir}
diff --git a/pmt/src/Makefile.am b/pmt/src/Makefile.am
deleted file mode 100644 (file)
index 8ce9b3d..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#
-# Copyright 2006,2007 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 GNU Radio; see the file COPYING.  If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-# 
-
-SUBDIRS = lib scheme
diff --git a/pmt/src/lib/Makefile.am b/pmt/src/lib/Makefile.am
deleted file mode 100644 (file)
index a510f4e..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-#
-# Copyright 2006,2008,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 GNU Radio; see the file COPYING.  If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-# 
-
-include $(top_srcdir)/Makefile.common
-
-AM_CPPFLAGS = $(DEFINES) $(BOOST_CPPFLAGS) \
-       $(CPPUNIT_INCLUDES) $(WITH_INCLUDES)
-
-TESTS = test_pmt
-
-lib_LTLIBRARIES = libpmt.la libpmt-qa.la
-
-# ----------------------------------------------------------------
-# these scripts generate code
-
-code_generator =                       \
-       generate_unv.py                 \
-       unv_template.h.t                \
-       unv_template.cc.t               \
-       unv_qa_template.cc.t            
-
-GENERATED_H =                          \
-       pmt_unv_int.h                   \
-       qa_pmt_unv.h                    
-
-GENERATED_CC =                         \
-       pmt_unv.cc                      \
-       qa_pmt_unv.cc                   
-
-python_built_sources = $(GENERATED_H) $(GENERATED_I) $(GENERATED_CC)
-
-BUILT_SOURCES = $(python_built_sources) pmt_serial_tags.h
-
-# ----------------------------------------------------------------
-
-EXTRA_DIST =                           \
-       $(code_generator)
-
-# These are the source files that go into the pmt shared library
-libpmt_la_SOURCES =                    \
-       pmt.cc                          \
-       pmt_io.cc                       \
-       pmt_pool.cc                     \
-       pmt_serialize.cc                \
-       pmt_unv.cc                      
-
-# magic flags
-libpmt_la_LDFLAGS = $(NO_UNDEFINED) $(BOOST_LDFLAGS)
-
-# link the library against the c++ standard library
-libpmt_la_LIBADD =                     \
-       $(BOOST_THREAD_LIB)             \
-       -lstdc++                        
-
-include_HEADERS =                      \
-       pmt.h                           \
-       pmt_pool.h                      \
-       pmt_serial_tags.h               
-
-noinst_HEADERS =                       \
-       $(GENERATED_H)                  \
-       pmt_int.h                       \
-       qa_pmt.h                        \
-       qa_pmt_prims.h                  
-
-
-# Build the qa code into its own library
-
-libpmt_qa_la_SOURCES =                 \
-       qa_pmt.cc                       \
-       qa_pmt_prims.cc                 \
-       qa_pmt_unv.cc                   
-
-# magic flags
-libpmt_qa_la_LDFLAGS = $(NO_UNDEFINED) -avoid version
-
-libpmt_qa_la_LIBADD =                  \
-       libpmt.la                       \
-       $(CPPUNIT_LIBS)                 \
-       -lstdc++                        
-
-
-noinst_PROGRAMS        =                       \
-       test_pmt
-
-
-LIBPMT   = libpmt.la
-LIBPMTQA = libpmt-qa.la $(LIBPMT)
-
-test_pmt_SOURCES = test_pmt.cc
-test_pmt_LDADD   = $(LIBPMTQA)
-
-# Do creation and inclusion of other Makefiles last
-
-# common way for generating sources from templates when using
-# BUILT_SOURCES, using parallel build protection.
-gen_sources = $(python_built_sources)
-gen_sources_deps = $(core_generator)
-par_gen_command = PYTHONPATH=$(top_srcdir)/pmt/src/lib srcdir=$(srcdir) $(PYTHON) $(srcdir)/generate_unv.py
-include $(top_srcdir)/Makefile.par.gen
-
-# Rule to create the build header file using GUILE
-# Doesn't need parallel protections because there is a single target
-pmt_serial_tags.h: $(srcdir)/../scheme/gnuradio/gen-serial-tags.scm $(srcdir)/../scheme/gnuradio/pmt-serial-tags.scm
-       $(RUN_GUILE) $(srcdir)/../scheme/gnuradio/gen-serial-tags.scm $(srcdir)/../scheme/gnuradio/pmt-serial-tags.scm pmt_serial_tags.h
diff --git a/pmt/src/lib/generate_unv.py b/pmt/src/lib/generate_unv.py
deleted file mode 100755 (executable)
index 2abafa4..0000000
+++ /dev/null
@@ -1,190 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2006 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 GNU Radio; see the file COPYING.  If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-# 
-
-"""
-Generate code for uniform numeric vectors
-"""
-
-import re, os, os.path
-
-
-unv_types = (
-    ('u8', 'uint8_t'),
-    ('s8', 'int8_t'),
-    ('u16', 'uint16_t'),
-    ('s16', 'int16_t'),
-    ('u32', 'uint32_t'),
-    ('s32', 'int32_t'),
-    ('u64', 'uint64_t'),
-    ('s64', 'int64_t'),
-    ('f32', 'float'),
-    ('f64', 'double'),
-    ('c32', 'std::complex<float>'),
-    ('c64', 'std::complex<double>')
-    )
-
-header = """\
-/* -*- c++ -*- */
-/*
- * Copyright 2006 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 GNU Radio; see the file COPYING.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-"""
-
-guard_tail = """
-#endif
-"""
-
-includes = """
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <vector>
-#include <pmt.h>
-#include "pmt_int.h"
-
-"""
-
-qa_includes = """
-#include <qa_pmt_unv.h>
-#include <cppunit/TestAssert.h>
-#include <pmt.h>
-#include <stdio.h>
-
-"""
-
-
-# set srcdir to the directory that contains Makefile.am
-try:
-    srcdir = os.environ['srcdir']
-except KeyError, e:
-    srcdir = "."
-srcdir = srcdir + '/'
-
-
-def open_src (name, mode):
-    global srcdir
-    return open(os.path.join (srcdir, name), mode)
-
-
-def guard_name(filename):
-    return 'INCLUDED_' + re.sub('\.', '_', filename.upper())
-
-def guard_head(filename):
-    guard = guard_name(filename)
-    return """
-#ifndef %s
-#define %s
-""" % (guard, guard)
-
-
-def do_substitution (d, input, out_file):
-    def repl (match_obj):
-        key = match_obj.group (1)
-        # print key
-        return d[key]
-    
-    out = re.sub (r"@([a-zA-Z0-9_]+)@", repl, input)
-    out_file.write (out)
-
-
-def generate_h():
-    template = open_src('unv_template.h.t', 'r').read()
-    output_filename = 'pmt_unv_int.h'
-    output = open(output_filename, 'w')
-    output.write(header)
-    output.write(guard_head(output_filename))
-    for tag, typ in unv_types:
-        d = { 'TAG' : tag, 'TYPE' : typ }
-        do_substitution(d, template, output)
-    output.write(guard_tail)
-
-def generate_cc():
-    template = open_src('unv_template.cc.t', 'r').read()
-    output = open('pmt_unv.cc', 'w')
-    output.write(header)
-    output.write(includes)
-    for tag, typ in unv_types:
-        d = { 'TAG' : tag, 'TYPE' : typ }
-        do_substitution(d, template, output)
-
-
-def generate_qa_h():
-    output_filename = 'qa_pmt_unv.h'
-    output = open(output_filename, 'w')
-    output.write(header)
-    output.write(guard_head(output_filename))
-
-    output.write('''
-#include <cppunit/extensions/HelperMacros.h>
-#include <cppunit/TestCase.h>
-
-class qa_pmt_unv : public CppUnit::TestCase {
-
-  CPPUNIT_TEST_SUITE(qa_pmt_unv);
-''')
-    for tag, typ in unv_types:
-        output.write('  CPPUNIT_TEST(test_%svector);\n' % (tag,))
-    output.write('''\
-  CPPUNIT_TEST_SUITE_END();
-
- private:
-''')     
-    for tag, typ in unv_types:
-        output.write('  void test_%svector();\n' % (tag,))
-    output.write('};\n')
-    output.write(guard_tail)
-
-def generate_qa_cc():
-    template = open_src('unv_qa_template.cc.t', 'r').read()
-    output = open('qa_pmt_unv.cc', 'w')
-    output.write(header)
-    output.write(qa_includes)
-    for tag, typ in unv_types:
-        d = { 'TAG' : tag, 'TYPE' : typ }
-        do_substitution(d, template, output)
-    
-
-def main():
-    generate_h()
-    generate_cc()
-    generate_qa_h()
-    generate_qa_cc()
-
-if __name__ == '__main__':
-    main()
diff --git a/pmt/src/lib/pmt.cc b/pmt/src/lib/pmt.cc
deleted file mode 100644 (file)
index b403c23..0000000
+++ /dev/null
@@ -1,1037 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2006 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 GNU Radio; see the file COPYING.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <vector>
-#include <pmt.h>
-#include "pmt_int.h"
-#include <stdio.h>
-#include <pmt_pool.h>
-#include <string.h>
-
-static const int CACHE_LINE_SIZE = 64;         // good guess
-
-# if (PMT_LOCAL_ALLOCATOR)
-
-static pmt_pool global_pmt_pool(sizeof(pmt_pair), CACHE_LINE_SIZE);
-
-void *
-pmt_base::operator new(size_t size)
-{
-  void *p = global_pmt_pool.malloc();
-
-  // fprintf(stderr, "pmt_base::new p = %p\n", p);
-  assert((reinterpret_cast<intptr_t>(p) & (CACHE_LINE_SIZE - 1)) == 0);
-  return p;
-}
-
-void
-pmt_base::operator delete(void *p, size_t size)
-{
-  global_pmt_pool.free(p);
-}
-
-#endif
-
-
-pmt_base::~pmt_base()
-{
-  // nop -- out of line virtual destructor
-}
-
-////////////////////////////////////////////////////////////////////////////
-//                         Exceptions
-////////////////////////////////////////////////////////////////////////////
-
-pmt_exception::pmt_exception(const std::string &msg, pmt_t obj)
-  : logic_error(msg + ": " + pmt_write_string(obj))
-{
-}
-
-pmt_wrong_type::pmt_wrong_type(const std::string &msg, pmt_t obj)
-  : pmt_exception(msg + ": wrong_type ", obj)
-{
-}
-
-pmt_out_of_range::pmt_out_of_range(const std::string &msg, pmt_t obj)
-  : pmt_exception(msg + ": out of range ", obj)
-{
-}
-
-pmt_notimplemented::pmt_notimplemented(const std::string &msg, pmt_t obj)
-  : pmt_exception(msg + ": notimplemented ", obj)
-{
-}
-
-////////////////////////////////////////////////////////////////////////////
-//                          Dynamic Casts
-////////////////////////////////////////////////////////////////////////////
-
-static pmt_symbol *
-_symbol(pmt_t x)
-{
-  return dynamic_cast<pmt_symbol*>(x.get());
-}
-
-static pmt_integer *
-_integer(pmt_t x)
-{
-  return dynamic_cast<pmt_integer*>(x.get());
-}
-
-static pmt_real *
-_real(pmt_t x)
-{
-  return dynamic_cast<pmt_real*>(x.get());
-}
-
-static pmt_complex *
-_complex(pmt_t x)
-{
-  return dynamic_cast<pmt_complex*>(x.get());
-}
-
-static pmt_pair *
-_pair(pmt_t x)
-{
-  return dynamic_cast<pmt_pair*>(x.get());
-}
-
-static pmt_vector *
-_vector(pmt_t x)
-{
-  return dynamic_cast<pmt_vector*>(x.get());
-}
-
-static pmt_uniform_vector *
-_uniform_vector(pmt_t x)
-{
-  return dynamic_cast<pmt_uniform_vector*>(x.get());
-}
-
-static pmt_dict *
-_dict(pmt_t x)
-{
-  return dynamic_cast<pmt_dict*>(x.get());
-}
-
-static pmt_any *
-_any(pmt_t x)
-{
-  return dynamic_cast<pmt_any*>(x.get());
-}
-
-////////////////////////////////////////////////////////////////////////////
-//                           Globals
-////////////////////////////////////////////////////////////////////////////
-
-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 = pmt_cons(PMT_NIL, PMT_NIL);      // singleton
-
-////////////////////////////////////////////////////////////////////////////
-//                           Booleans
-////////////////////////////////////////////////////////////////////////////
-
-pmt_bool::pmt_bool(){}
-
-bool
-pmt_is_true(pmt_t obj)
-{
-  return obj != PMT_F;
-}
-
-bool
-pmt_is_false(pmt_t obj)
-{
-  return obj == PMT_F;
-}
-
-bool
-pmt_is_bool(pmt_t obj)
-{
-  return obj->is_bool();
-}
-
-pmt_t
-pmt_from_bool(bool val)
-{
-  return val ? PMT_T : PMT_F;
-}
-
-bool
-pmt_to_bool(pmt_t val)
-{
-  if (val == PMT_T)
-    return true;
-  if (val == PMT_F)
-    return false;
-  throw pmt_wrong_type("pmt_to_bool", val);
-}
-
-////////////////////////////////////////////////////////////////////////////
-//                             Symbols
-////////////////////////////////////////////////////////////////////////////
-
-static const unsigned int SYMBOL_HASH_TABLE_SIZE = 701;
-static std::vector<pmt_t> s_symbol_hash_table(SYMBOL_HASH_TABLE_SIZE);
-
-pmt_symbol::pmt_symbol(const std::string &name) : d_name(name){}
-
-
-static unsigned int
-hash_string(const std::string &s)
-{
-  unsigned int h = 0;
-  unsigned int g = 0;
-
-  for (std::string::const_iterator p = s.begin(); p != s.end(); ++p){
-    h = (h << 4) + (*p & 0xff);
-    g = h & 0xf0000000;
-    if (g){
-      h = h ^ (g >> 24);
-      h = h ^ g;
-    }
-  }
-  return h;
-}
-
-bool 
-pmt_is_symbol(const pmt_t& obj)
-{
-  return obj->is_symbol();
-}
-
-pmt_t 
-pmt_string_to_symbol(const std::string &name)
-{
-  unsigned hash = hash_string(name) % SYMBOL_HASH_TABLE_SIZE;
-
-  // Does a symbol with this name already exist?
-  for (pmt_t sym = s_symbol_hash_table[hash]; sym; sym = _symbol(sym)->next()){
-    if (name == _symbol(sym)->name())
-      return sym;              // Yes.  Return it
-  }
-
-  // Nope.  Make a new one.
-  pmt_t sym = pmt_t(new pmt_symbol(name));
-  _symbol(sym)->set_next(s_symbol_hash_table[hash]);
-  s_symbol_hash_table[hash] = sym;
-  return sym;
-}
-
-// alias...
-pmt_t
-pmt_intern(const std::string &name)
-{
-  return pmt_string_to_symbol(name);
-}
-
-const std::string
-pmt_symbol_to_string(const pmt_t& sym)
-{
-  if (!sym->is_symbol())
-    throw pmt_wrong_type("pmt_symbol_to_string", sym);
-
-  return _symbol(sym)->name();
-}
-
-
-
-////////////////////////////////////////////////////////////////////////////
-//                             Number
-////////////////////////////////////////////////////////////////////////////
-
-bool
-pmt_is_number(pmt_t x)
-{
-  return x->is_number();
-}
-
-////////////////////////////////////////////////////////////////////////////
-//                             Integer
-////////////////////////////////////////////////////////////////////////////
-
-pmt_integer::pmt_integer(long value) : d_value(value) {}
-
-bool
-pmt_is_integer(pmt_t x)
-{
-  return x->is_integer();
-}
-
-
-pmt_t
-pmt_from_long(long x)
-{
-  return pmt_t(new pmt_integer(x));
-}
-
-long
-pmt_to_long(pmt_t x)
-{
-  pmt_integer* i = dynamic_cast<pmt_integer*>(x.get());
-  if ( i )
-    return i->value();
-
-  throw pmt_wrong_type("pmt_to_long", x);
-}
-
-////////////////////////////////////////////////////////////////////////////
-//                              Real
-////////////////////////////////////////////////////////////////////////////
-
-pmt_real::pmt_real(double value) : d_value(value) {}
-
-bool 
-pmt_is_real(pmt_t x)
-{
-  return x->is_real();
-}
-
-pmt_t
-pmt_from_double(double x)
-{
-  return pmt_t(new pmt_real(x));
-}
-
-double
-pmt_to_double(pmt_t x)
-{
-  if (x->is_real())
-    return _real(x)->value();
-  if (x->is_integer())
-    return _integer(x)->value();
-
-  throw pmt_wrong_type("pmt_to_double", x);
-}
-
-////////////////////////////////////////////////////////////////////////////
-//                              Complex
-////////////////////////////////////////////////////////////////////////////
-
-pmt_complex::pmt_complex(std::complex<double> value) : d_value(value) {}
-
-bool 
-pmt_is_complex(pmt_t x)
-{
-  return x->is_complex();
-}
-
-pmt_t
-pmt_make_rectangular(double re, double im)
-{
-  return pmt_t(new pmt_complex(std::complex<double>(re, im)));
-}
-
-std::complex<double>
-pmt_to_complex(pmt_t x)
-{
-  if (x->is_complex())
-    return _complex(x)->value();
-  if (x->is_real())
-    return _real(x)->value();
-  if (x->is_integer())
-    return _integer(x)->value();
-
-  throw pmt_wrong_type("pmt_to_complex", x);
-}
-
-////////////////////////////////////////////////////////////////////////////
-//                              Pairs
-////////////////////////////////////////////////////////////////////////////
-
-pmt_null::pmt_null() {}
-pmt_pair::pmt_pair(const pmt_t& car, const pmt_t& cdr) : d_car(car), d_cdr(cdr) {}
-
-bool
-pmt_is_null(const pmt_t& x)
-{
-  return x == PMT_NIL;
-}
-
-bool
-pmt_is_pair(const pmt_t& obj)
-{
-  return obj->is_pair();
-}
-
-pmt_t
-pmt_cons(const pmt_t& x, const pmt_t& y)
-{
-  return pmt_t(new pmt_pair(x, y));
-}
-
-pmt_t
-pmt_car(const pmt_t& pair)
-{
-  pmt_pair* p = dynamic_cast<pmt_pair*>(pair.get());
-  if ( p )
-    return p->car();
-  
-  throw pmt_wrong_type("pmt_car", pair);
-}
-
-pmt_t
-pmt_cdr(const pmt_t& pair)
-{
-  pmt_pair* p = dynamic_cast<pmt_pair*>(pair.get());
-  if ( p )
-    return p->cdr();
-  
-  throw pmt_wrong_type("pmt_cdr", pair);
-}
-
-void
-pmt_set_car(pmt_t pair, pmt_t obj)
-{
-  if (pair->is_pair())
-    _pair(pair)->set_car(obj);
-  else
-    throw pmt_wrong_type("pmt_set_car", pair);
-}
-
-void
-pmt_set_cdr(pmt_t pair, pmt_t obj)
-{
-  if (pair->is_pair())
-    _pair(pair)->set_cdr(obj);
-  else
-    throw pmt_wrong_type("pmt_set_cdr", pair);
-}
-
-////////////////////////////////////////////////////////////////////////////
-//                             Vectors
-////////////////////////////////////////////////////////////////////////////
-
-pmt_vector::pmt_vector(size_t len, pmt_t fill)
-  : d_v(len)
-{
-  for (size_t i = 0; i < len; i++)
-    d_v[i] = fill;
-}
-
-pmt_t
-pmt_vector::ref(size_t k) const
-{
-  if (k >= length())
-    throw pmt_out_of_range("pmt_vector_ref", pmt_from_long(k));
-  return d_v[k];
-}
-
-void
-pmt_vector::set(size_t k, pmt_t obj)
-{
-  if (k >= length())
-    throw pmt_out_of_range("pmt_vector_set", pmt_from_long(k));
-  d_v[k] = obj;
-}
-
-void
-pmt_vector::fill(pmt_t obj)
-{
-  for (size_t i = 0; i < length(); i++)
-    d_v[i] = obj;
-}
-
-bool
-pmt_is_vector(pmt_t obj)
-{
-  return obj->is_vector();
-}
-
-pmt_t
-pmt_make_vector(size_t k, pmt_t fill)
-{
-  return pmt_t(new pmt_vector(k, fill));
-}
-
-pmt_t
-pmt_vector_ref(pmt_t vector, size_t k)
-{
-  if (!vector->is_vector())
-    throw pmt_wrong_type("pmt_vector_ref", vector);
-  return _vector(vector)->ref(k);
-}
-
-void
-pmt_vector_set(pmt_t vector, size_t k, pmt_t obj)
-{
-  if (!vector->is_vector())
-    throw pmt_wrong_type("pmt_vector_set", vector);
-  _vector(vector)->set(k, obj);
-}
-
-void
-pmt_vector_fill(pmt_t vector, pmt_t obj)
-{
-  if (!vector->is_vector())
-    throw pmt_wrong_type("pmt_vector_set", vector);
-  _vector(vector)->fill(obj);
-}
-
-////////////////////////////////////////////////////////////////////////////
-//                       Uniform Numeric Vectors
-////////////////////////////////////////////////////////////////////////////
-
-bool
-pmt_is_uniform_vector(pmt_t x)
-{
-  return x->is_uniform_vector();
-}
-
-const void *
-pmt_uniform_vector_elements(pmt_t vector, size_t &len)
-{
-  if (!vector->is_uniform_vector())
-    throw pmt_wrong_type("pmt_uniform_vector_elements", vector);
-  return _uniform_vector(vector)->uniform_elements(len);
-}
-
-void *
-pmt_uniform_vector_writable_elements(pmt_t vector, size_t &len)
-{
-  if (!vector->is_uniform_vector())
-    throw pmt_wrong_type("pmt_uniform_vector_writable_elements", vector);
-  return _uniform_vector(vector)->uniform_writable_elements(len);
-}
-
-////////////////////////////////////////////////////////////////////////////
-//                            Dictionaries
-////////////////////////////////////////////////////////////////////////////
-
-pmt_dict::pmt_dict()
-  : d_alist(PMT_NIL)
-{
-}
-
-void
-pmt_dict::set(pmt_t key, pmt_t value)
-{
-  pmt_t        p = pmt_assv(key, d_alist);     // look for (key . value) pair
-  if (pmt_is_pair(p)){                 // found existing pair...
-    pmt_set_cdr(p, value);             // overrwrite cdr with new value
-  }
-  else {                               // not in the dict
-    d_alist = pmt_cons(pmt_cons(key, value), d_alist); // add new (key . value) pair
-  }
-}
-
-pmt_t
-pmt_dict::ref(pmt_t key, pmt_t not_found) const
-{
-  pmt_t        p = pmt_assv(key, d_alist);     // look for (key . value) pair
-  if (pmt_is_pair(p))
-    return pmt_cdr(p);
-  else
-    return not_found;
-}
-
-bool
-pmt_dict::has_key(pmt_t key) const
-{
-  return pmt_is_pair(pmt_assv(key, d_alist));
-}
-
-pmt_t
-pmt_dict::items() const
-{
-  return d_alist;
-}
-
-pmt_t
-pmt_dict::keys() const
-{
-  return pmt_map(pmt_car, d_alist);
-}
-
-pmt_t
-pmt_dict::values() const
-{
-  return pmt_map(pmt_cdr, d_alist);
-}
-
-bool
-pmt_is_dict(pmt_t obj)
-{
-  return obj->is_dict();
-}
-
-pmt_t
-pmt_make_dict()
-{
-  return pmt_t(new pmt_dict());
-}
-
-void
-pmt_dict_set(pmt_t dict, pmt_t key, pmt_t value)
-{
-  pmt_dict* d = _dict(dict);
-  if (!d)
-    throw pmt_wrong_type("pmt_dict_set", dict);
-
-  d->set(key, value);
-}
-
-bool
-pmt_dict_has_key(pmt_t dict, pmt_t key)
-{
-  pmt_dict* d = _dict(dict);
-  if (!d)
-    throw pmt_wrong_type("pmt_dict_has_key", dict);
-
-  return d->has_key(key);
-}
-
-pmt_t
-pmt_dict_ref(pmt_t dict, pmt_t key, pmt_t not_found)
-{
-  pmt_dict* d = _dict(dict);
-  if (!d)
-    throw pmt_wrong_type("pmt_dict_ref", dict);
-
-  return d->ref(key, not_found);
-}
-
-pmt_t
-pmt_dict_items(pmt_t dict)
-{
-  if (!dict->is_dict())
-    throw pmt_wrong_type("pmt_dict_items", dict);
-
-  return _dict(dict)->items();
-}
-
-pmt_t
-pmt_dict_keys(pmt_t dict)
-{
-  if (!dict->is_dict())
-    throw pmt_wrong_type("pmt_dict_keys", dict);
-
-  return _dict(dict)->keys();
-}
-
-pmt_t
-pmt_dict_values(pmt_t dict)
-{
-  if (!dict->is_dict())
-    throw pmt_wrong_type("pmt_dict_values", dict);
-
-  return _dict(dict)->values();
-}
-
-////////////////////////////////////////////////////////////////////////////
-//                                 Any
-////////////////////////////////////////////////////////////////////////////
-
-pmt_any::pmt_any(const boost::any &any) : d_any(any) {}
-
-bool
-pmt_is_any(pmt_t obj)
-{
-  return obj->is_any();
-}
-
-pmt_t
-pmt_make_any(const boost::any &any)
-{
-  return pmt_t(new pmt_any(any));
-}
-
-boost::any
-pmt_any_ref(pmt_t obj)
-{
-  if (!obj->is_any())
-    throw pmt_wrong_type("pmt_any_ref", obj);
-  return _any(obj)->ref();
-}
-
-void
-pmt_any_set(pmt_t obj, const boost::any &any)
-{
-  if (!obj->is_any())
-    throw pmt_wrong_type("pmt_any_set", obj);
-  _any(obj)->set(any);
-}
-
-////////////////////////////////////////////////////////////////////////////
-//                          General Functions
-////////////////////////////////////////////////////////////////////////////
-
-bool
-pmt_eq(const pmt_t& x, const pmt_t& y)
-{
-  return x == y;
-}
-
-bool
-pmt_eqv(const pmt_t& x, const pmt_t& y)
-{
-  if (x == y)
-    return true;
-
-  if (x->is_integer() && y->is_integer())
-    return _integer(x)->value() == _integer(y)->value();
-
-  if (x->is_real() && y->is_real())
-    return _real(x)->value() == _real(y)->value();
-
-  if (x->is_complex() && y->is_complex())
-    return _complex(x)->value() == _complex(y)->value();
-
-  return false;
-}
-
-bool
-pmt_equal(const pmt_t& x, const pmt_t& y)
-{
-  if (pmt_eqv(x, y))
-    return true;
-
-  if (x->is_pair() && y->is_pair())
-    return pmt_equal(pmt_car(x), pmt_car(y)) && pmt_equal(pmt_cdr(x), pmt_cdr(y));
-
-  if (x->is_vector() && y->is_vector()){
-    pmt_vector *xv = _vector(x);
-    pmt_vector *yv = _vector(y);
-    if (xv->length() != yv->length())
-      return false;
-
-    for (unsigned i = 0; i < xv->length(); i++)
-      if (!pmt_equal(xv->_ref(i), yv->_ref(i)))
-       return false;
-
-    return true;
-  }
-
-  if (x->is_uniform_vector() && y->is_uniform_vector()){
-    pmt_uniform_vector *xv = _uniform_vector(x);
-    pmt_uniform_vector *yv = _uniform_vector(y);
-    if (xv->length() != yv->length())
-      return false;
-
-    size_t len_x, len_y;
-    if (memcmp(xv->uniform_elements(len_x),
-              yv->uniform_elements(len_y),
-              len_x) == 0)
-      return true;
-
-    return true;
-  }
-
-  // FIXME add other cases here...
-
-  return false;
-}
-
-size_t
-pmt_length(const pmt_t& x)
-{
-  if (x->is_vector())
-    return _vector(x)->length();
-
-  if (x->is_uniform_vector())
-    return _uniform_vector(x)->length();
-
-  if (x->is_null()) return 0;
-
-  if (x->is_pair()) {
-    size_t length=1;
-       pmt_t it = pmt_cdr(x);
-    while (pmt_is_pair(it)){
-      length++;
-      it = pmt_cdr(it);
-    }
-    if (pmt_is_null(it))
-      return length;
-
-    // not a proper list
-    throw pmt_wrong_type("pmt_length", x);
-  }
-
-  // FIXME dictionary length (number of entries)
-
-  throw pmt_wrong_type("pmt_length", x);
-}
-
-pmt_t
-pmt_assq(pmt_t obj, pmt_t alist)
-{
-  while (pmt_is_pair(alist)){
-    pmt_t p = pmt_car(alist);
-    if (!pmt_is_pair(p))       // malformed alist
-      return PMT_F;
-
-    if (pmt_eq(obj, pmt_car(p)))
-      return p;
-
-    alist = pmt_cdr(alist);
-  }
-  return PMT_F;
-}
-
-pmt_t
-pmt_assv(pmt_t obj, pmt_t alist)
-{
-  while (pmt_is_pair(alist)){
-    pmt_t p = pmt_car(alist);
-    if (!pmt_is_pair(p))       // malformed alist
-      return PMT_F;
-
-    if (pmt_eqv(obj, pmt_car(p)))
-      return p;
-
-    alist = pmt_cdr(alist);
-  }
-  return PMT_F;
-}
-
-pmt_t
-pmt_assoc(pmt_t obj, pmt_t alist)
-{
-  while (pmt_is_pair(alist)){
-    pmt_t p = pmt_car(alist);
-    if (!pmt_is_pair(p))       // malformed alist
-      return PMT_F;
-
-    if (pmt_equal(obj, pmt_car(p)))
-      return p;
-
-    alist = pmt_cdr(alist);
-  }
-  return PMT_F;
-}
-
-pmt_t
-pmt_map(pmt_t proc(const pmt_t&), pmt_t list)
-{
-  pmt_t r = PMT_NIL;
-
-  while(pmt_is_pair(list)){
-    r = pmt_cons(proc(pmt_car(list)), r);
-    list = pmt_cdr(list);
-  }
-
-  return pmt_reverse_x(r);
-}
-
-pmt_t
-pmt_reverse(pmt_t listx)
-{
-  pmt_t list = listx;
-  pmt_t r = PMT_NIL;
-
-  while(pmt_is_pair(list)){
-    r = pmt_cons(pmt_car(list), r);
-    list = pmt_cdr(list);
-  }
-  if (pmt_is_null(list))
-    return r;
-  else
-    throw pmt_wrong_type("pmt_reverse", listx);
-}
-
-pmt_t
-pmt_reverse_x(pmt_t list)
-{
-  // FIXME do it destructively
-  return pmt_reverse(list);
-}
-
-pmt_t
-pmt_nth(size_t n, pmt_t list)
-{
-  pmt_t t = pmt_nthcdr(n, list);
-  if (pmt_is_pair(t))
-    return pmt_car(t);
-  else
-    return PMT_NIL;
-}
-
-pmt_t
-pmt_nthcdr(size_t n, pmt_t list)
-{
-  if (!(pmt_is_pair(list) || pmt_is_null(list)))
-    throw pmt_wrong_type("pmt_nthcdr", list);
-    
-  while (n > 0){
-    if (pmt_is_pair(list)){
-      list = pmt_cdr(list);
-      n--;
-      continue;
-    }
-    if (pmt_is_null(list))
-      return PMT_NIL;
-    else
-      throw pmt_wrong_type("pmt_nthcdr: not a LIST", list);
-  }
-  return list;
-}
-
-pmt_t
-pmt_memq(pmt_t obj, pmt_t list)
-{
-  while (pmt_is_pair(list)){
-    if (pmt_eq(obj, pmt_car(list)))
-      return list;
-    list = pmt_cdr(list);
-  }
-  return PMT_F;
-}
-
-pmt_t
-pmt_memv(pmt_t obj, pmt_t list)
-{
-  while (pmt_is_pair(list)){
-    if (pmt_eqv(obj, pmt_car(list)))
-      return list;
-    list = pmt_cdr(list);
-  }
-  return PMT_F;
-}
-
-pmt_t
-pmt_member(pmt_t obj, pmt_t list)
-{
-  while (pmt_is_pair(list)){
-    if (pmt_equal(obj, pmt_car(list)))
-      return list;
-    list = pmt_cdr(list);
-  }
-  return PMT_F;
-}
-
-bool
-pmt_subsetp(pmt_t list1, pmt_t list2)
-{
-  while (pmt_is_pair(list1)){
-    pmt_t p = pmt_car(list1);
-    if (pmt_is_false(pmt_memv(p, list2)))
-      return false;
-    list1 = pmt_cdr(list1);
-  }
-  return true;
-}
-
-pmt_t
-pmt_list1(const pmt_t& x1)
-{
-  return pmt_cons(x1, PMT_NIL);
-}
-
-pmt_t
-pmt_list2(const pmt_t& x1, const pmt_t& x2)
-{
-  return pmt_cons(x1, pmt_cons(x2, PMT_NIL));
-}
-
-pmt_t
-pmt_list3(const pmt_t& x1, const pmt_t& x2, const pmt_t& x3)
-{
-  return pmt_cons(x1, pmt_cons(x2, pmt_cons(x3, PMT_NIL)));
-}
-
-pmt_t
-pmt_list4(const pmt_t& x1, const pmt_t& x2, const pmt_t& x3, const pmt_t& x4)
-{
-  return pmt_cons(x1, pmt_cons(x2, pmt_cons(x3, pmt_cons(x4, PMT_NIL))));
-}
-
-pmt_t
-pmt_list5(const pmt_t& x1, const pmt_t& x2, const pmt_t& x3, const pmt_t& x4, const pmt_t& x5)
-{
-  return pmt_cons(x1, pmt_cons(x2, pmt_cons(x3, pmt_cons(x4, pmt_cons(x5, PMT_NIL)))));
-}
-
-pmt_t
-pmt_list6(const pmt_t& x1, const pmt_t& x2, const pmt_t& x3, const pmt_t& x4, const pmt_t& x5, const pmt_t& x6)
-{
-  return pmt_cons(x1, pmt_cons(x2, pmt_cons(x3, pmt_cons(x4, pmt_cons(x5, pmt_cons(x6, PMT_NIL))))));
-}
-
-pmt_t
-pmt_list_add(pmt_t list, const pmt_t& item)
-{
-  return pmt_reverse(pmt_cons(item, pmt_reverse(list)));
-}
-
-pmt_t
-pmt_caar(pmt_t pair)
-{
-  return (pmt_car(pmt_car(pair)));
-}
-
-pmt_t
-pmt_cadr(pmt_t pair)
-{
-  return pmt_car(pmt_cdr(pair));
-}
-
-pmt_t
-pmt_cdar(pmt_t pair)
-{
-  return pmt_cdr(pmt_car(pair));
-}
-
-pmt_t
-pmt_cddr(pmt_t pair)
-{
-  return pmt_cdr(pmt_cdr(pair));
-}
-
-pmt_t
-pmt_caddr(pmt_t pair)
-{
-  return pmt_car(pmt_cdr(pmt_cdr(pair)));
-}
-
-pmt_t
-pmt_cadddr(pmt_t pair)
-{
-  return pmt_car(pmt_cdr(pmt_cdr(pmt_cdr(pair))));
-}
-  
-bool
-pmt_is_eof_object(pmt_t obj)
-{
-  return pmt_eq(obj, PMT_EOF);
-}
-
-void
-pmt_dump_sizeof()
-{
-  printf("sizeof(pmt_t)              = %3zd\n", sizeof(pmt_t));
-  printf("sizeof(pmt_base)           = %3zd\n", sizeof(pmt_base));
-  printf("sizeof(pmt_bool)           = %3zd\n", sizeof(pmt_bool));
-  printf("sizeof(pmt_symbol)         = %3zd\n", sizeof(pmt_symbol));
-  printf("sizeof(pmt_integer)        = %3zd\n", sizeof(pmt_integer));
-  printf("sizeof(pmt_real)           = %3zd\n", sizeof(pmt_real));
-  printf("sizeof(pmt_complex)        = %3zd\n", sizeof(pmt_complex));
-  printf("sizeof(pmt_null)           = %3zd\n", sizeof(pmt_null));
-  printf("sizeof(pmt_pair)           = %3zd\n", sizeof(pmt_pair));
-  printf("sizeof(pmt_vector)         = %3zd\n", sizeof(pmt_vector));
-  printf("sizeof(pmt_dict)           = %3zd\n", sizeof(pmt_dict));
-  printf("sizeof(pmt_uniform_vector) = %3zd\n", sizeof(pmt_uniform_vector));
-}
diff --git a/pmt/src/lib/pmt.h b/pmt/src/lib/pmt.h
deleted file mode 100644 (file)
index 24963fe..0000000
+++ /dev/null
@@ -1,678 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2006,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 GNU Radio; see the file COPYING.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef INCLUDED_PMT_H
-#define INCLUDED_PMT_H
-
-#include <boost/shared_ptr.hpp>
-#include <boost/any.hpp>
-#include <complex>
-#include <string>
-#include <stdint.h>
-#include <iosfwd>
-#include <stdexcept>
-
-/*!
- * This file defines a polymorphic type and the operations on it.
- *
- * It draws heavily on the idea of scheme and lisp data types.
- * The interface parallels that in Guile 1.8, with the notable
- * exception that these objects are transparently reference counted.
- */
-
-/*!
- * \brief base class of all pmt types
- */
-class pmt_base;
-
-/*!
- * \brief typedef for shared pointer (transparent reference counting).
- * See http://www.boost.org/libs/smart_ptr/smart_ptr.htm
- */
-typedef boost::shared_ptr<pmt_base> pmt_t;
-
-
-class pmt_exception : public std::logic_error
-{
-public:
-  pmt_exception(const std::string &msg, pmt_t obj);
-};
-
-class pmt_wrong_type : public pmt_exception
-{
-public:
-  pmt_wrong_type(const std::string &msg, pmt_t obj);
-};
-
-class pmt_out_of_range : public pmt_exception
-{
-public:
-  pmt_out_of_range(const std::string &msg, pmt_t obj);
-};
-
-class pmt_notimplemented : public pmt_exception
-{
-public:
-  pmt_notimplemented(const std::string &msg, pmt_t obj);
-};
-
-/*
- * ------------------------------------------------------------------------
- * Booleans.  Two constants, #t and #f.
- *
- * In predicates, anything that is not #f is considered true.
- * I.e., there is a single false value, #f.
- * ------------------------------------------------------------------------
- */
-extern const pmt_t PMT_T;      //< \#t : boolean true constant
-extern const pmt_t PMT_F;      //< \#f : boolean false constant
-
-//! Return true if obj is \#t or \#f, else return false.
-bool pmt_is_bool(pmt_t obj);
-
-//! Return false if obj is \#f, else return true.
-bool pmt_is_true(pmt_t obj);
-
-//! Return true if obj is \#f, else return true.
-bool pmt_is_false(pmt_t obj);
-
-//! Return \#f is val is false, else return \#t.
-pmt_t pmt_from_bool(bool val);
-
-//! Return true if val is PMT_T, return false when val is PMT_F, 
-// else raise wrong_type exception.
-bool pmt_to_bool(pmt_t val);
-
-/*
- * ------------------------------------------------------------------------
- *                            Symbols
- * ------------------------------------------------------------------------
- */
-
-//! Return true if obj is a symbol, else false.
-bool pmt_is_symbol(const pmt_t& obj);
-
-//! Return the symbol whose name is \p s.
-pmt_t pmt_string_to_symbol(const std::string &s);
-
-//! Alias for pmt_string_to_symbol
-pmt_t pmt_intern(const std::string &s);
-
-
-/*!
- * If \p is a symbol, return the name of the symbol as a string.
- * Otherwise, raise the wrong_type exception.
- */
-const std::string pmt_symbol_to_string(const pmt_t& sym);
-
-/*
- * ------------------------------------------------------------------------
- *           Numbers: we support integer, real and complex
- * ------------------------------------------------------------------------
- */
-
-//! Return true if obj is any kind of number, else false.
-bool pmt_is_number(pmt_t obj);
-
-/*
- * ------------------------------------------------------------------------
- *                            Integers
- * ------------------------------------------------------------------------
- */
-
-//! Return true if \p x is an integer number, else false
-bool pmt_is_integer(pmt_t x);
-
-//! Return the pmt value that represents the integer \p x.
-pmt_t pmt_from_long(long x);
-
-/*!
- * \brief Convert pmt to long if possible.
- *
- * When \p x represents an exact integer that fits in a long,
- * return that integer.  Else raise an exception, either wrong_type
- * when x is not an exact integer, or out_of_range when it doesn't fit.
- */
-long pmt_to_long(pmt_t x);
-
-/*
- * ------------------------------------------------------------------------
- *                             Reals
- * ------------------------------------------------------------------------
- */
-
-/*
- * \brief Return true if \p obj is a real number, else false.
- */
-bool pmt_is_real(pmt_t obj);
-
-//! Return the pmt value that represents double \p x.
-pmt_t pmt_from_double(double x);
-
-/*!
- * \brief Convert pmt to double if possible.
- *
- * Returns the number closest to \p val that is representable
- * as a double.  The argument \p val must be a real or integer, otherwise
- * a wrong_type exception is raised.
- */
-double pmt_to_double(pmt_t x);
-
-/*
- * ------------------------------------------------------------------------
- *                            Complex
- * ------------------------------------------------------------------------
- */
-
-/*!
- * \brief return true if \p obj is a complex number, false otherwise.
- */
-bool pmt_is_complex(pmt_t obj);
-
-//! Return a complex number constructed of the given real and imaginary parts.
-pmt_t pmt_make_rectangular(double re, double im);
-
-/*!
- * If \p z is complex, real or integer, return the closest complex<double>.
- * Otherwise, raise the wrong_type exception.
- */
-std::complex<double> pmt_to_complex(pmt_t z);
-
-/*
- * ------------------------------------------------------------------------
- *                             Pairs
- * ------------------------------------------------------------------------
- */
-
-extern const pmt_t PMT_NIL;    //< the empty list
-
-//! Return true if \p x is the empty list, otherwise return false.
-bool pmt_is_null(const pmt_t& x);
-
-//! Return true if \p obj is a pair, else false.
-bool pmt_is_pair(const pmt_t& obj);
-
-//! Return a newly allocated pair whose car is \p x and whose cdr is \p y.
-pmt_t pmt_cons(const pmt_t& x, const pmt_t& y);
-
-//! If \p pair is a pair, return the car of the \p pair, otherwise raise wrong_type.
-pmt_t pmt_car(const pmt_t& pair);
-
-//! If \p pair is a pair, return the cdr of the \p pair, otherwise raise wrong_type.
-pmt_t pmt_cdr(const pmt_t& pair);
-
-//! Stores \p value in the car field of \p pair.
-void pmt_set_car(pmt_t pair, pmt_t value);
-
-//! Stores \p value in the cdr field of \p pair.
-void pmt_set_cdr(pmt_t pair, pmt_t value);
-
-pmt_t pmt_caar(pmt_t pair);
-pmt_t pmt_cadr(pmt_t pair);
-pmt_t pmt_cdar(pmt_t pair);
-pmt_t pmt_cddr(pmt_t pair);
-pmt_t pmt_caddr(pmt_t pair);
-pmt_t pmt_cadddr(pmt_t pair);
-
-/*
- * ------------------------------------------------------------------------
- *                            Vectors
- *
- * These vectors can hold any kind of objects.  Indexing is zero based.
- * ------------------------------------------------------------------------
- */
-
-//! Return true if \p x is a vector, othewise false.
-bool pmt_is_vector(pmt_t x);
-
-//! Make a vector of length \p k, with initial values set to \p fill
-pmt_t pmt_make_vector(size_t k, pmt_t fill);
-
-/*!
- * Return the contents of position \p k of \p vector.
- * \p k must be a valid index of \p vector.
- */
-pmt_t pmt_vector_ref(pmt_t vector, size_t k);
-
-//! Store \p obj in position \p k.
-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);
-
-/*!
- * <pre>
- * ------------------------------------------------------------------------
- *                    Uniform Numeric Vectors
- *
- * A uniform numeric vector is a vector whose elements are all of single
- * numeric type.  pmt offers uniform numeric vectors for signed and
- * unsigned 8-bit, 16-bit, 32-bit, and 64-bit integers, two sizes of
- * floating point values, and complex floating-point numbers of these
- * two sizes.  Indexing is zero based.
- *
- * The names of the functions include these tags in their names:
- *
- *    u8  unsigned 8-bit integers
- *    s8  signed 8-bit integers
- *   u16  unsigned 16-bit integers
- *   s16  signed 16-bit integers
- *   u32  unsigned 32-bit integers
- *   s32  signed 32-bit integers
- *   u64  unsigned 64-bit integers
- *   s64  signed 64-bit integers
- *   f32  the C++ type float
- *   f64  the C++ type double
- *   c32  the C++ type complex<float>
- *   c64  the C++ type complex<double>
- * ------------------------------------------------------------------------
- * </pre>
- */
-
-//! true if \p x is any kind of uniform numeric vector
-bool pmt_is_uniform_vector(pmt_t x);  
-
-bool pmt_is_u8vector(pmt_t x);
-bool pmt_is_s8vector(pmt_t x);
-bool pmt_is_u16vector(pmt_t x);
-bool pmt_is_s16vector(pmt_t x);
-bool pmt_is_u32vector(pmt_t x);
-bool pmt_is_s32vector(pmt_t x);
-bool pmt_is_u64vector(pmt_t x);
-bool pmt_is_s64vector(pmt_t x);
-bool pmt_is_f32vector(pmt_t x);
-bool pmt_is_f64vector(pmt_t x);
-bool pmt_is_c32vector(pmt_t x);
-bool pmt_is_c64vector(pmt_t x);
-
-pmt_t pmt_make_u8vector(size_t k, uint8_t fill);
-pmt_t pmt_make_s8vector(size_t k, int8_t fill);
-pmt_t pmt_make_u16vector(size_t k, uint16_t fill);
-pmt_t pmt_make_s16vector(size_t k, int16_t fill);
-pmt_t pmt_make_u32vector(size_t k, uint32_t fill);
-pmt_t pmt_make_s32vector(size_t k, int32_t fill);
-pmt_t pmt_make_u64vector(size_t k, uint64_t fill);
-pmt_t pmt_make_s64vector(size_t k, int64_t fill);
-pmt_t pmt_make_f32vector(size_t k, float fill);
-pmt_t pmt_make_f64vector(size_t k, double fill);
-pmt_t pmt_make_c32vector(size_t k, std::complex<float> fill);
-pmt_t pmt_make_c64vector(size_t k, std::complex<double> fill);
-
-pmt_t pmt_init_u8vector(size_t k, const uint8_t *data);
-pmt_t pmt_init_s8vector(size_t k, const int8_t *data);
-pmt_t pmt_init_u16vector(size_t k, const uint16_t *data);
-pmt_t pmt_init_s16vector(size_t k, const int16_t *data);
-pmt_t pmt_init_u32vector(size_t k, const uint32_t *data);
-pmt_t pmt_init_s32vector(size_t k, const int32_t *data);
-pmt_t pmt_init_u64vector(size_t k, const uint64_t *data);
-pmt_t pmt_init_s64vector(size_t k, const int64_t *data);
-pmt_t pmt_init_f32vector(size_t k, const float *data);
-pmt_t pmt_init_f64vector(size_t k, const double *data);
-pmt_t pmt_init_c32vector(size_t k, const std::complex<float> *data);
-pmt_t pmt_init_c64vector(size_t k, const std::complex<double> *data);
-
-uint8_t  pmt_u8vector_ref(pmt_t v, size_t k);
-int8_t   pmt_s8vector_ref(pmt_t v, size_t k);
-uint16_t pmt_u16vector_ref(pmt_t v, size_t k);
-int16_t  pmt_s16vector_ref(pmt_t v, size_t k);
-uint32_t pmt_u32vector_ref(pmt_t v, size_t k);
-int32_t  pmt_s32vector_ref(pmt_t v, size_t k);
-uint64_t pmt_u64vector_ref(pmt_t v, size_t k);
-int64_t  pmt_s64vector_ref(pmt_t v, size_t k);
-float    pmt_f32vector_ref(pmt_t v, size_t k);
-double   pmt_f64vector_ref(pmt_t v, size_t k);
-std::complex<float>  pmt_c32vector_ref(pmt_t v, size_t k);
-std::complex<double> pmt_c64vector_ref(pmt_t v, size_t k);
-
-void pmt_u8vector_set(pmt_t v, size_t k, uint8_t x);  //< v[k] = x
-void pmt_s8vector_set(pmt_t v, size_t k, int8_t x);
-void pmt_u16vector_set(pmt_t v, size_t k, uint16_t x);
-void pmt_s16vector_set(pmt_t v, size_t k, int16_t x);
-void pmt_u32vector_set(pmt_t v, size_t k, uint32_t x);
-void pmt_s32vector_set(pmt_t v, size_t k, int32_t x);
-void pmt_u64vector_set(pmt_t v, size_t k, uint64_t x);
-void pmt_s64vector_set(pmt_t v, size_t k, int64_t x);
-void pmt_f32vector_set(pmt_t v, size_t k, float x);
-void pmt_f64vector_set(pmt_t v, size_t k, double x);
-void pmt_c32vector_set(pmt_t v, size_t k, std::complex<float> x);
-void pmt_c64vector_set(pmt_t v, size_t k, std::complex<double> x);
-
-// Return const pointers to the elements
-
-const void *pmt_uniform_vector_elements(pmt_t v, size_t &len);  //< works with any; len is in bytes
-
-const uint8_t  *pmt_u8vector_elements(pmt_t v, size_t &len);  //< len is in elements
-const int8_t   *pmt_s8vector_elements(pmt_t v, size_t &len);  //< len is in elements
-const uint16_t *pmt_u16vector_elements(pmt_t v, size_t &len); //< len is in elements
-const int16_t  *pmt_s16vector_elements(pmt_t v, size_t &len); //< len is in elements
-const uint32_t *pmt_u32vector_elements(pmt_t v, size_t &len); //< len is in elements
-const int32_t  *pmt_s32vector_elements(pmt_t v, size_t &len); //< len is in elements
-const uint64_t *pmt_u64vector_elements(pmt_t v, size_t &len); //< len is in elements
-const int64_t  *pmt_s64vector_elements(pmt_t v, size_t &len); //< len is in elements
-const float    *pmt_f32vector_elements(pmt_t v, size_t &len); //< len is in elements
-const double   *pmt_f64vector_elements(pmt_t v, size_t &len); //< len is in elements
-const std::complex<float>  *pmt_c32vector_elements(pmt_t v, size_t &len); //< len is in elements
-const std::complex<double> *pmt_c64vector_elements(pmt_t v, size_t &len); //< len is in elements
-
-// Return non-const pointers to the elements
-
-void *pmt_uniform_vector_writable_elements(pmt_t v, size_t &len);  //< works with any; len is in bytes
-
-uint8_t  *pmt_u8vector_writable_elements(pmt_t v, size_t &len);  //< len is in elements
-int8_t   *pmt_s8vector_writable_elements(pmt_t v, size_t &len);  //< len is in elements
-uint16_t *pmt_u16vector_writable_elements(pmt_t v, size_t &len); //< len is in elements
-int16_t  *pmt_s16vector_writable_elements(pmt_t v, size_t &len); //< len is in elements
-uint32_t *pmt_u32vector_writable_elements(pmt_t v, size_t &len); //< len is in elements
-int32_t  *pmt_s32vector_writable_elements(pmt_t v, size_t &len); //< len is in elements
-uint64_t *pmt_u64vector_writable_elements(pmt_t v, size_t &len); //< len is in elements
-int64_t  *pmt_s64vector_writable_elements(pmt_t v, size_t &len); //< len is in elements
-float    *pmt_f32vector_writable_elements(pmt_t v, size_t &len); //< len is in elements
-double   *pmt_f64vector_writable_elements(pmt_t v, size_t &len); //< len is in elements
-std::complex<float>  *pmt_c32vector_writable_elements(pmt_t v, size_t &len); //< len is in elements
-std::complex<double> *pmt_c64vector_writable_elements(pmt_t v, size_t &len); //< len is in elements
-
-/*
- * ------------------------------------------------------------------------
- *        Dictionary (a.k.a associative array, hash, map)
- * ------------------------------------------------------------------------
- */
-
-//! Return true if \p obj is a dictionary
-bool pmt_is_dict(pmt_t obj);
-
-//! make an empty dictionary
-pmt_t pmt_make_dict();
-
-//! dict[key] = value
-void  pmt_dict_set(pmt_t dict, pmt_t key, pmt_t value);
-
-//! Return true if \p key exists in \p dict
-bool  pmt_dict_has_key(pmt_t dict, pmt_t key);
-
-//! If \p key exists in \p dict, return associated value; otherwise return \p not_found.
-pmt_t pmt_dict_ref(pmt_t dict, pmt_t key, pmt_t not_found);
-
-//! Return list of (key . value) pairs
-pmt_t pmt_dict_items(pmt_t dict);
-
-//! Return list of keys
-pmt_t pmt_dict_keys(pmt_t dict);
-
-//! Return list of values
-pmt_t pmt_dict_values(pmt_t dict);
-
-/*
- * ------------------------------------------------------------------------
- *   Any (wraps boost::any -- can be used to wrap pretty much anything)
- *
- * Cannot be serialized or used across process boundaries.
- * See http://www.boost.org/doc/html/any.html
- * ------------------------------------------------------------------------
- */
-
-//! Return true if \p obj is an any
-bool pmt_is_any(pmt_t obj);
-
-//! make an any
-pmt_t pmt_make_any(const boost::any &any);
-
-//! Return underlying boost::any
-boost::any pmt_any_ref(pmt_t obj);
-
-//! Store \p any in \p obj
-void pmt_any_set(pmt_t obj, const boost::any &any);
-
-
-/*
- * ------------------------------------------------------------------------
- *                       General functions
- * ------------------------------------------------------------------------
- */
-
-//! Return true if x and y are the same object; otherwise return false.
-bool pmt_eq(const pmt_t& x, const pmt_t& y);
-
-/*!
- * \brief Return true if x and y should normally be regarded as the same object, else false.
- *
- * <pre>
- * eqv returns true if:
- *   x and y are the same object.
- *   x and y are both \#t or both \#f.
- *   x and y are both symbols and their names are the same.
- *   x and y are both numbers, and are numerically equal.
- *   x and y are both the empty list (nil).
- *   x and y are pairs or vectors that denote same location in store.
- * </pre>
- */
-bool pmt_eqv(const pmt_t& x, const pmt_t& y);
-
-/*!
- * pmt_equal recursively compares the contents of pairs and vectors,
- * applying pmt_eqv on other objects such as numbers and symbols.  
- * pmt_equal may fail to terminate if its arguments are circular data
- * structures.
- */
-bool pmt_equal(const pmt_t& x, const pmt_t& y);
-
-
-//! Return the number of elements in v
-size_t pmt_length(const pmt_t& v);
-
-/*!
- * \brief Find the first pair in \p alist whose car field is \p obj
- *  and return that pair.
- *
- * \p alist (for "association list") must be a list of pairs.  If no pair
- * in \p alist has \p obj as its car then \#f is returned.
- * Uses pmt_eq to compare \p obj with car fields of the pairs in \p alist.
- */
-pmt_t pmt_assq(pmt_t obj, pmt_t alist);
-
-/*!
- * \brief Find the first pair in \p alist whose car field is \p obj
- *  and return that pair.
- *
- * \p alist (for "association list") must be a list of pairs.  If no pair
- * in \p alist has \p obj as its car then \#f is returned.
- * Uses pmt_eqv to compare \p obj with car fields of the pairs in \p alist.
- */
-pmt_t pmt_assv(pmt_t obj, pmt_t alist);
-
-/*!
- * \brief Find the first pair in \p alist whose car field is \p obj
- *  and return that pair.
- *
- * \p alist (for "association list") must be a list of pairs.  If no pair
- * in \p alist has \p obj as its car then \#f is returned.
- * Uses pmt_equal to compare \p obj with car fields of the pairs in \p alist.
- */
-pmt_t pmt_assoc(pmt_t obj, pmt_t alist);
-
-/*!
- * \brief Apply \p proc element-wise to the elements of list and returns
- * a list of the results, in order.
- *
- * \p list must be a list.  The dynamic order in which \p proc is
- * applied to the elements of \p list is unspecified.
- */
-pmt_t pmt_map(pmt_t proc(const pmt_t&), pmt_t list);
-
-/*!
- * \brief reverse \p list.
- *
- * \p list must be a proper list.
- */
-pmt_t pmt_reverse(pmt_t list);
-
-/*!
- * \brief destructively reverse \p list.
- *
- * \p list must be a proper list.
- */
-pmt_t pmt_reverse_x(pmt_t list);
-
-/*!
- * \brief (acons x y a) == (cons (cons x y) a)
- */
-inline static pmt_t
-pmt_acons(pmt_t x, pmt_t y, pmt_t a)
-{
-  return pmt_cons(pmt_cons(x, y), a);
-}
-
-/*!
- * \brief locates \p nth element of \n list where the car is the 'zeroth' element.
- */
-pmt_t pmt_nth(size_t n, pmt_t list);
-
-/*!
- * \brief returns the tail of \p list that would be obtained by calling
- * cdr \p n times in succession.
- */
-pmt_t pmt_nthcdr(size_t n, pmt_t list);
-
-/*!
- * \brief Return the first sublist of \p list whose car is \p obj.
- * If \p obj does not occur in \p list, then \#f is returned.
- * pmt_memq use pmt_eq to compare \p obj with the elements of \p list.
- */
-pmt_t pmt_memq(pmt_t obj, pmt_t list);
-
-/*!
- * \brief Return the first sublist of \p list whose car is \p obj.
- * If \p obj does not occur in \p list, then \#f is returned.
- * pmt_memv use pmt_eqv to compare \p obj with the elements of \p list.
- */
-pmt_t pmt_memv(pmt_t obj, pmt_t list);
-
-/*!
- * \brief Return the first sublist of \p list whose car is \p obj.
- * If \p obj does not occur in \p list, then \#f is returned.
- * pmt_member use pmt_equal to compare \p obj with the elements of \p list.
- */
-pmt_t pmt_member(pmt_t obj, pmt_t list);
-
-/*!
- * \brief Return true if every element of \p list1 appears in \p list2, and false otherwise.
- * Comparisons are done with pmt_eqv.
- */
-bool pmt_subsetp(pmt_t list1, pmt_t list2);
-
-/*!
- * \brief Return a list of length 1 containing \p x1
- */
-pmt_t pmt_list1(const pmt_t& x1);
-
-/*!
- * \brief Return a list of length 2 containing \p x1, \p x2
- */
-pmt_t pmt_list2(const pmt_t& x1, const pmt_t& x2);
-
-/*!
- * \brief Return a list of length 3 containing \p x1, \p x2, \p x3
- */
-pmt_t pmt_list3(const pmt_t& x1, const pmt_t& x2, const pmt_t& x3);
-
-/*!
- * \brief Return a list of length 4 containing \p x1, \p x2, \p x3, \p x4
- */
-pmt_t pmt_list4(const pmt_t& x1, const pmt_t& x2, const pmt_t& x3, const pmt_t& x4);
-
-/*!
- * \brief Return a list of length 5 containing \p x1, \p x2, \p x3, \p x4, \p x5
- */
-pmt_t pmt_list5(const pmt_t& x1, const pmt_t& x2, const pmt_t& x3, const pmt_t& x4, const pmt_t& x5);
-
-/*!
- * \brief Return a list of length 6 containing \p x1, \p x2, \p x3, \p x4, \p
- * x5, \p x6
- */
-pmt_t pmt_list6(const pmt_t& x1, const pmt_t& x2, const pmt_t& x3, const pmt_t& x4, const pmt_t& x5, const pmt_t& x6);
-
-/*!
- * \brief Return \p list with \p item added to it.
- */
-pmt_t pmt_list_add(pmt_t list, const pmt_t& item);
-
-
-/*
- * ------------------------------------------------------------------------
- *                          read / write
- * ------------------------------------------------------------------------
- */
-extern const pmt_t PMT_EOF;    //< The end of file object
-
-//! return true if obj is the EOF object, otherwise return false.
-bool pmt_is_eof_object(pmt_t obj);
-
-/*!
- * read converts external representations of pmt objects into the
- * objects themselves.  Read returns the next object parsable from
- * the given input port, updating port to point to the first
- * character past the end of the external representation of the
- * object.
- *
- * If an end of file is encountered in the input before any
- * characters are found that can begin an object, then an end of file
- * object is returned.   The port remains open, and further attempts
- * to read will also return an end of file object.  If an end of file
- * is encountered after the beginning of an object's external
- * representation, but the external representation is incomplete and
- * therefore not parsable, an error is signaled.
- */
-pmt_t pmt_read(std::istream &port);
-
-/*!
- * Write a written representation of \p obj to the given \p port.
- */
-void pmt_write(pmt_t obj, std::ostream &port);
-
-/*!
- * Return a string representation of \p obj.
- * This is the same output as would be generated by pmt_write.
- */
-std::string pmt_write_string(pmt_t obj);
-
-
-std::ostream& operator<<(std::ostream &os, pmt_t obj);
-
-
-/*
- * ------------------------------------------------------------------------
- *                   portable byte stream representation
- * ------------------------------------------------------------------------
- */
-/*!
- * \brief Write portable byte-serial representation of \p obj to \p sink
- */
-bool pmt_serialize(pmt_t obj, std::streambuf &sink);
-
-/*!
- * \brief Create obj from portable byte-serial representation
- */
-pmt_t pmt_deserialize(std::streambuf &source);
-
-
-void pmt_dump_sizeof();        // debugging
-
-#endif /* INCLUDED_PMT_H */
diff --git a/pmt/src/lib/pmt_int.h b/pmt/src/lib/pmt_int.h
deleted file mode 100644 (file)
index a973d30..0000000
+++ /dev/null
@@ -1,224 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2006 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 GNU Radio; see the file COPYING.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-#ifndef INCLUDED_PMT_INT_H
-#define INCLUDED_PMT_INT_H
-
-#include <pmt.h>
-#include <boost/utility.hpp>
-
-/*
- * EVERYTHING IN THIS FILE IS PRIVATE TO THE IMPLEMENTATION!
- *
- * See pmt.h for the public interface
- */
-
-#define PMT_LOCAL_ALLOCATOR 0          // define to 0 or 1
-
-class pmt_base : boost::noncopyable {
-protected:
-  pmt_base(){};
-  virtual ~pmt_base();
-
-public:
-  virtual bool is_bool()    const { return false; }
-  virtual bool is_symbol()  const { return false; }
-  virtual bool is_number()  const { return false; }
-  virtual bool is_integer() const { return false; }
-  virtual bool is_real()    const { return false; }
-  virtual bool is_complex() const { return false; }
-  virtual bool is_null()    const { return false; }
-  virtual bool is_pair()    const { return false; }
-  virtual bool is_vector()  const { return false; }
-  virtual bool is_dict()    const { return false; }
-  virtual bool is_any()     const { return false; }
-
-  virtual bool is_uniform_vector() const { return false; }
-  virtual bool is_u8vector()  const { return false; }
-  virtual bool is_s8vector()  const { return false; }
-  virtual bool is_u16vector() const { return false; }
-  virtual bool is_s16vector() const { return false; }
-  virtual bool is_u32vector() const { return false; }
-  virtual bool is_s32vector() const { return false; }
-  virtual bool is_u64vector() const { return false; }
-  virtual bool is_s64vector() const { return false; }
-  virtual bool is_f32vector() const { return false; }
-  virtual bool is_f64vector() const { return false; }
-  virtual bool is_c32vector() const { return false; }
-  virtual bool is_c64vector() const { return false; }
-
-# if (PMT_LOCAL_ALLOCATOR)
-  void *operator new(size_t);
-  void operator delete(void *, size_t);
-#endif
-};
-
-class pmt_bool : public pmt_base
-{
-public:
-  pmt_bool();
-  //~pmt_bool(){}
-
-  bool is_bool() const { return true; }
-};
-
-
-class pmt_symbol : public pmt_base
-{
-  std::string  d_name;
-  pmt_t                d_next;
-  
-public:
-  pmt_symbol(const std::string &name);
-  //~pmt_symbol(){}
-
-  bool is_symbol() const { return true; }
-  const std::string name() { return d_name; }
-
-  pmt_t next() { return d_next; }              // symbol table link
-  void set_next(pmt_t next) { d_next = next; }
-};
-
-class pmt_integer : public pmt_base
-{
-  long         d_value;
-
-public:
-  pmt_integer(long value);
-  //~pmt_integer(){}
-
-  bool is_number()  const { return true; }
-  bool is_integer() const { return true; }
-  long value() const { return d_value; }
-};
-
-class pmt_real : public pmt_base
-{
-  double       d_value;
-
-public:
-  pmt_real(double value);
-  //~pmt_real(){}
-
-  bool is_number()  const { return true; }
-  bool is_real() const { return true; }
-  double value() const { return d_value; }
-};
-
-class pmt_complex : public pmt_base
-{
-  std::complex<double> d_value;
-
-public:
-  pmt_complex(std::complex<double> value);
-  //~pmt_complex(){}
-
-  bool is_number()  const { return true; }
-  bool is_complex() const { return true; }
-  std::complex<double> value() const { return d_value; }
-};
-
-class pmt_null  : public pmt_base
-{
-public:
-  pmt_null();
-  //~pmt_null(){}
-
-  bool is_null() const { return true; }
-};
-
-class pmt_pair : public pmt_base
-{
-  pmt_t                d_car;
-  pmt_t                d_cdr;
-
-public:
-  pmt_pair(const pmt_t& car, const pmt_t& cdr);
-  //~pmt_pair(){};
-
-  bool is_pair() const { return true; }
-  pmt_t car() const { return d_car; }
-  pmt_t cdr() const { return d_cdr; }
-
-  void set_car(pmt_t car) { d_car = car; }
-  void set_cdr(pmt_t cdr) { d_cdr = cdr; }
-};
-
-class pmt_vector : public pmt_base
-{
-  std::vector<pmt_t>   d_v;
-
-public:
-  pmt_vector(size_t len, pmt_t fill);
-  //~pmt_vector();
-
-  bool is_vector() const { return true; }
-  pmt_t ref(size_t k) const;
-  void  set(size_t k, pmt_t obj);
-  void  fill(pmt_t fill);
-  size_t length() const { return d_v.size(); }
-
-  pmt_t _ref(size_t k) const { return d_v[k]; }
-};
-
-class pmt_dict : public pmt_base
-{
-  pmt_t                d_alist;        // list of (key . value) pairs
-
-public:
-  pmt_dict();
-  //~pmt_dict();
-
-  bool  is_dict() const { return true; }
-  void  set(pmt_t key, pmt_t value);
-  pmt_t ref(pmt_t key, pmt_t default_value) const;
-  bool  has_key(pmt_t key) const;
-  pmt_t items() const;
-  pmt_t keys() const;
-  pmt_t values() const;
-};
-
-class pmt_any : public pmt_base
-{
-  boost::any   d_any;
-
-public:
-  pmt_any(const boost::any &any);
-  //~pmt_any();
-
-  bool is_any() const { return true; }
-  const boost::any &ref() const { return d_any; }
-  void  set(const boost::any &any) { d_any = any; }
-};
-
-
-class pmt_uniform_vector : public pmt_base
-{
-public:
-  bool is_uniform_vector() const { return true; }
-  virtual const void *uniform_elements(size_t &len) = 0;
-  virtual void *uniform_writable_elements(size_t &len) = 0;
-  virtual size_t length() const = 0;
-};
-
-#include "pmt_unv_int.h"
-
-#endif /* INCLUDED_PMT_INT_H */
diff --git a/pmt/src/lib/pmt_io.cc b/pmt/src/lib/pmt_io.cc
deleted file mode 100644 (file)
index 3bbf430..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2006 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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <vector>
-#include <pmt.h>
-#include "pmt_int.h"
-#include <sstream>
-
-static void
-pmt_write_list_tail(pmt_t obj, std::ostream &port)
-{
-  pmt_write(pmt_car(obj), port); // write the car
-  obj = pmt_cdr(obj);           // step to cdr
-
-  if (pmt_is_null(obj))                 // ()
-    port << ")";
-
-  else if (pmt_is_pair(obj)){   // normal list
-    port << " ";
-    pmt_write_list_tail(obj, port);
-  }
-  else {                        // dotted pair
-    port << " . ";
-    pmt_write(obj, port);
-    port << ")";
-  }
-}
-
-void
-pmt_write(pmt_t obj, std::ostream &port)
-{
-  if (pmt_is_bool(obj)){
-    if (pmt_is_true(obj))
-      port << "#t";
-    else
-      port << "#f";
-  }
-  else if (pmt_is_symbol(obj)){
-    port << pmt_symbol_to_string(obj);
-  }
-  else if (pmt_is_number(obj)){
-    if (pmt_is_integer(obj))
-      port << pmt_to_long(obj);
-    else if (pmt_is_real(obj))
-      port << pmt_to_double(obj);
-    else if (pmt_is_complex(obj)){
-      std::complex<double> c = pmt_to_complex(obj);
-      port << c.real() << '+' << c.imag() << 'i';
-    }
-    else
-      goto error;
-  }
-  else if (pmt_is_null(obj)){
-    port << "()";
-  }
-  else if (pmt_is_pair(obj)){
-    port << "(";
-    pmt_write_list_tail(obj, port);
-  }
-  else if (pmt_is_dict(obj)){
-    // FIXME
-    // port << "#<dict " << obj << ">";
-    port << "#<dict>";
-  }
-  else if (pmt_is_vector(obj)){
-    // FIXME
-    // port << "#<vector " << obj << ">";
-    port << "#<vector>";
-  }
-  else if (pmt_is_uniform_vector(obj)){
-    // FIXME
-    // port << "#<uniform-vector " << obj << ">";
-    port << "#<uniform-vector>";
-  }
-  else {
-  error:
-    // FIXME
-    // port << "#<" << obj << ">";
-    port << "#<unknown>";
-  }
-}
-
-std::ostream& operator<<(std::ostream &os, pmt_t obj)
-{
-  pmt_write(obj, os);
-  return os;
-}
-
-std::string 
-pmt_write_string(pmt_t obj)
-{
-  std::ostringstream s;
-  s << obj;
-  return s.str();
-}
-
-pmt_t
-pmt_read(std::istream &port)
-{
-  throw pmt_notimplemented("notimplemented: pmt_read", PMT_NIL);
-}
-
-void
-pmt_serialize(pmt_t obj, std::ostream &sink)
-{
-  throw pmt_notimplemented("notimplemented: pmt_serialize", obj);
-}
-
-/*!
- * \brief Create obj from portable byte-serial representation
- */
-pmt_t 
-pmt_deserialize(std::istream &source)
-{
-  throw pmt_notimplemented("notimplemented: pmt_deserialize", PMT_NIL);
-}
-
diff --git a/pmt/src/lib/pmt_pool.cc b/pmt/src/lib/pmt_pool.cc
deleted file mode 100644 (file)
index 05a7f59..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <pmt_pool.h>
-#include <algorithm>
-#include <stdint.h>
-
-static inline size_t
-ROUNDUP(size_t x, size_t stride)
-{
-  return ((((x) + (stride) - 1)/(stride)) * (stride));
-}
-
-pmt_pool::pmt_pool(size_t itemsize, size_t alignment,
-                  size_t allocation_size, size_t max_items)
-  : d_itemsize(ROUNDUP(itemsize, alignment)),
-    d_alignment(alignment),
-    d_allocation_size(std::max(allocation_size, 16 * itemsize)),
-    d_max_items(max_items), d_n_items(0),
-    d_freelist(0)
-{
-}
-
-pmt_pool::~pmt_pool()
-{
-  for (unsigned int i = 0; i < d_allocations.size(); i++){
-    delete [] d_allocations[i];
-  }
-}
-
-void *
-pmt_pool::malloc()
-{
-  scoped_lock guard(d_mutex);
-  item *p;
-
-  if (d_max_items != 0){
-    while (d_n_items >= d_max_items)
-      d_cond.wait(guard);
-  }
-
-  if (d_freelist){     // got something?
-    p = d_freelist;
-    d_freelist = p->d_next;
-    d_n_items++;
-    return p;
-  }
-
-  // allocate a new chunk
-  char *alloc = new char[d_allocation_size + d_alignment - 1];
-  d_allocations.push_back(alloc);
-
-  // get the alignment we require
-  char *start = (char *)(((uintptr_t)alloc + d_alignment-1) & -d_alignment);
-  char *end = alloc + d_allocation_size + d_alignment - 1;
-  size_t n = (end - start) / d_itemsize;
-
-  // link the new items onto the free list.
-  p = (item *) start;
-  for (size_t i = 0; i < n; i++){
-    p->d_next = d_freelist;
-    d_freelist = p;
-    p = (item *)((char *) p + d_itemsize);
-  }
-
-  // now return the first one
-  p = d_freelist;
-  d_freelist = p->d_next;
-  d_n_items++;
-  return p;
-}
-
-void
-pmt_pool::free(void *foo)
-{
-  if (!foo)
-    return;
-
-  scoped_lock guard(d_mutex);
-
-  item *p = (item *) foo;
-  p->d_next = d_freelist;
-  d_freelist = p;
-  d_n_items--;
-  if (d_max_items != 0)
-    d_cond.notify_one();
-}
diff --git a/pmt/src/lib/pmt_pool.h b/pmt/src/lib/pmt_pool.h
deleted file mode 100644 (file)
index 8004a65..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,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_PMT_POOL_H
-#define INCLUDED_PMT_POOL_H
-
-#include <cstddef>
-#include <vector>
-#include <boost/thread.hpp>
-
-/*!
- * \brief very simple thread-safe fixed-size allocation pool
- *
- * FIXME may want to go to global allocation with per-thread free list.
- * This would eliminate virtually all lock contention.
- */
-class pmt_pool {
-
-  struct item {
-    struct item        *d_next;
-  };
-  
-  typedef boost::unique_lock<boost::mutex>  scoped_lock;
-  mutable boost::mutex                 d_mutex;
-  boost::condition_variable    d_cond;
-  
-  size_t             d_itemsize;
-  size_t             d_alignment;
-  size_t             d_allocation_size;
-  size_t             d_max_items;
-  size_t             d_n_items;
-  item              *d_freelist;
-  std::vector<char *> d_allocations;
-
-public:
-  /*!
-   * \param itemsize size in bytes of the items to be allocated.
-   * \param alignment alignment in bytes of all objects to be allocated (must be power-of-2).
-   * \param allocation_size number of bytes to allocate at a time from the underlying allocator.
-   * \param max_items is the maximum number of items to allocate.  If this number is exceeded,
-   *         the allocate blocks.  0 implies no limit.
-   */
-  pmt_pool(size_t itemsize, size_t alignment = 16,
-          size_t allocation_size = 4096, size_t max_items = 0);
-  ~pmt_pool();
-
-  void *malloc();
-  void free(void *p);
-};
-
-#endif /* INCLUDED_PMT_POOL_H */
diff --git a/pmt/src/lib/pmt_serialize.cc b/pmt/src/lib/pmt_serialize.cc
deleted file mode 100644 (file)
index 1f1b57c..0000000
+++ /dev/null
@@ -1,353 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <vector>
-#include <pmt.h>
-#include "pmt_int.h"
-#include "pmt_serial_tags.h"
-
-static pmt_t parse_pair(std::streambuf &sb);
-
-// ----------------------------------------------------------------
-// output primitives
-// ----------------------------------------------------------------
-
-static bool
-serialize_untagged_u8(unsigned int i, std::streambuf &sb)
-{
-  return sb.sputc((i >> 0) & 0xff) != std::streambuf::traits_type::eof();
-}
-
-// always writes big-endian
-static bool
-serialize_untagged_u16(unsigned int i, std::streambuf &sb)
-{
-  sb.sputc((i >> 8) & 0xff);
-  return sb.sputc((i >> 0) & 0xff) != std::streambuf::traits_type::eof();
-}
-
-// always writes big-endian
-static bool
-serialize_untagged_u32(unsigned int i, std::streambuf &sb)
-{
-  sb.sputc((i >> 24) & 0xff);
-  sb.sputc((i >> 16) & 0xff);
-  sb.sputc((i >>  8) & 0xff);
-  return sb.sputc((i >> 0) & 0xff) != std::streambuf::traits_type::eof();
-}
-
-#if 0
-// always writes big-endian
-static bool
-serialize_untagged_u64(uint64_t i, std::streambuf &sb)
-{
-  sb.sputc((i >> 56) & 0xff);
-  sb.sputc((i >> 48) & 0xff);
-  sb.sputc((i >> 40) & 0xff);
-  sb.sputc((i >> 32) & 0xff);
-  sb.sputc((i >> 24) & 0xff);
-  sb.sputc((i >> 16) & 0xff);
-  sb.sputc((i >>  8) & 0xff);
-  return sb.sputc((i >> 0) & 0xff) != std::streambuf::traits_type::eof();
-}
-#endif
-
-// ----------------------------------------------------------------
-// input primitives
-// ----------------------------------------------------------------
-
-
-// always reads big-endian
-static bool
-deserialize_untagged_u8(uint8_t *ip, std::streambuf &sb)
-{
-  std::streambuf::traits_type::int_type  t;
-  int i;
-
-  t = sb.sbumpc();
-  i = t & 0xff;
-
-  *ip = i;
-  return t != std::streambuf::traits_type::eof();
-}
-
-// always reads big-endian
-static bool
-deserialize_untagged_u16(uint16_t *ip, std::streambuf &sb)
-{
-  std::streambuf::traits_type::int_type  t;
-  int i;
-
-  t = sb.sbumpc();
-  i = t & 0xff;
-
-  t = sb.sbumpc();
-  i = (i << 8) | (t & 0xff);
-
-  *ip = i;
-  return t != std::streambuf::traits_type::eof();
-}
-
-// always reads big-endian
-static bool
-deserialize_untagged_u32(uint32_t *ip, std::streambuf &sb)
-{
-  std::streambuf::traits_type::int_type  t;
-  int i;
-
-  t = sb.sbumpc();
-  i = t & 0xff;
-
-  t = sb.sbumpc();
-  i = (i << 8) | (t & 0xff);
-  t = sb.sbumpc();
-  i = (i << 8) | (t & 0xff);
-  t = sb.sbumpc();
-  i = (i << 8) | (t & 0xff);
-
-  *ip = i;
-  return t != std::streambuf::traits_type::eof();
-}
-
-#if 0
-// always reads big-endian
-static bool
-deserialize_untagged_u64(uint64_t *ip, std::streambuf &sb)
-{
-  std::streambuf::traits_type::int_type  t;
-  uint64_t i;
-
-  t = sb.sbumpc();
-  i = t & 0xff;
-
-  t = sb.sbumpc();
-  i = (i << 8) | (t & 0xff);
-  t = sb.sbumpc();
-  i = (i << 8) | (t & 0xff);
-  t = sb.sbumpc();
-  i = (i << 8) | (t & 0xff);
-  t = sb.sbumpc();
-  i = (i << 8) | (t & 0xff);
-  t = sb.sbumpc();
-  i = (i << 8) | (t & 0xff);
-  t = sb.sbumpc();
-  i = (i << 8) | (t & 0xff);
-  t = sb.sbumpc();
-  i = (i << 8) | (t & 0xff);
-
-  *ip = i;
-  return t != std::streambuf::traits_type::eof();
-}
-#endif
-
-/*
- * Write portable byte-serial representation of \p obj to \p sb
- *
- * N.B., Circular structures cause infinite recursion.
- */
-bool
-pmt_serialize(pmt_t obj, std::streambuf &sb)
-{
-  bool ok = true;
-
- tail_recursion:
-
-  if (pmt_is_bool(obj)){
-    if (pmt_eq(obj, PMT_T))
-      return serialize_untagged_u8(PST_TRUE, sb);
-    else
-      return serialize_untagged_u8(PST_FALSE, sb);
-  }
-  
-  if (pmt_is_null(obj))
-    return serialize_untagged_u8(PST_NULL, sb);
-
-  if (pmt_is_symbol(obj)){
-    const std::string s = pmt_symbol_to_string(obj);
-    size_t len = s.size();
-    ok = serialize_untagged_u8(PST_SYMBOL, sb);
-    ok &= serialize_untagged_u16(len, sb);
-    for (size_t i = 0; i < len; i++)
-      ok &= serialize_untagged_u8(s[i], sb);
-    return ok;
-  }
-
-  if (pmt_is_pair(obj)){
-    ok = serialize_untagged_u8(PST_PAIR, sb);
-    ok &= pmt_serialize(pmt_car(obj), sb);
-    if (!ok)
-      return false;
-    obj = pmt_cdr(obj);
-    goto tail_recursion;
-  }
-
-  if (pmt_is_number(obj)){
-
-    if (pmt_is_integer(obj)){
-      long i = pmt_to_long(obj);
-      if (sizeof(long) > 4){
-       if (i < -2147483647 || i > 2147483647)
-         throw pmt_notimplemented("pmt_serialize (64-bit integers)", obj);
-      }
-      ok = serialize_untagged_u8(PST_INT32, sb);
-      ok &= serialize_untagged_u32(i, sb);
-      return ok;
-    }
-
-    if (pmt_is_real(obj))
-      throw pmt_notimplemented("pmt_serialize (real)", obj);
-
-    if (pmt_is_complex(obj))
-      throw pmt_notimplemented("pmt_serialize (complex)", obj);
-  }
-
-  if (pmt_is_vector(obj))
-    throw pmt_notimplemented("pmt_serialize (vector)", obj);
-
-  if (pmt_is_uniform_vector(obj))
-    throw pmt_notimplemented("pmt_serialize (uniform-vector)", obj);
-    
-  if (pmt_is_dict(obj))
-    throw pmt_notimplemented("pmt_serialize (dict)", obj);
-    
-
-  throw pmt_notimplemented("pmt_serialize (?)", obj);
-}
-
-/*
- * Create obj from portable byte-serial representation
- *
- * Returns next obj from streambuf, or PMT_EOF at end of file.
- * Throws exception on malformed input.
- */
-pmt_t
-pmt_deserialize(std::streambuf &sb)
-{
-  uint8_t      tag;
-  //uint8_t    u8;
-  uint16_t     u16;
-  uint32_t     u32;
-  //uint32_t   u64;
-  static char   tmpbuf[1024];
-
-  if (!deserialize_untagged_u8(&tag, sb))
-    return PMT_EOF;
-
-  switch (tag){
-  case PST_TRUE:
-    return PMT_T;
-    
-  case PST_FALSE:
-    return PMT_F;
-
-  case PST_NULL:
-    return PMT_NIL;
-
-  case PST_SYMBOL:
-    if (!deserialize_untagged_u16(&u16, sb))
-      goto error;
-    if (u16 > sizeof(tmpbuf))
-      throw pmt_notimplemented("pmt_deserialize: very long symbol",
-                              PMT_F);
-    if (sb.sgetn(tmpbuf, u16) != u16)
-      goto error;
-    return pmt_intern(std::string(tmpbuf, u16));
-
-  case PST_INT32:
-    if (!deserialize_untagged_u32(&u32, sb))
-      goto error;
-    return pmt_from_long((int32_t) u32);
-
-  case PST_PAIR:
-    return parse_pair(sb);
-
-  case PST_DOUBLE:
-  case PST_COMPLEX:
-  case PST_VECTOR:
-  case PST_DICT:
-  case PST_UNIFORM_VECTOR:
-  case PST_COMMENT:
-    throw pmt_notimplemented("pmt_deserialize: tag value = ",
-                            pmt_from_long(tag));
-    
-  default:
-    throw pmt_exception("pmt_deserialize: malformed input stream, tag value = ",
-                       pmt_from_long(tag));
-  }
-
- error:
-  throw pmt_exception("pmt_deserialize: malformed input stream", PMT_F);
-}
-
-/*
- * This is a mostly non-recursive implementation that allows us to
- * deserialize very long lists w/o exhausting the evaluation stack.
- *
- * On entry we've already eaten the PST_PAIR tag.
- */
-pmt_t
-parse_pair(std::streambuf &sb)
-{
-  uint8_t tag;
-  pmt_t        val, expr, lastnptr, nptr;
-
-  //
-  // Keep appending nodes until we get a non-PAIR cdr.
-  //
-  lastnptr = PMT_NIL;
-  while (1){
-    expr = pmt_deserialize(sb);                // read the car
-
-    nptr = pmt_cons(expr, PMT_NIL);    // build new cell
-    if (pmt_is_null(lastnptr))
-      val = nptr;
-    else
-      pmt_set_cdr(lastnptr, nptr);
-    lastnptr = nptr;
-
-    if (!deserialize_untagged_u8(&tag, sb))  // get tag of cdr
-      throw pmt_exception("pmt_deserialize: malformed input stream", PMT_F);
-
-    if (tag == PST_PAIR)
-      continue;                        // keep on looping...
-
-    if (tag == PST_NULL){
-      expr = PMT_NIL;
-      break;
-    }
-
-    //
-    // default: push tag back and use pmt_deserialize to get the cdr
-    //
-    sb.sungetc();
-    expr = pmt_deserialize(sb);
-    break;
-  }
-
-  //
-  // At this point, expr contains the value of the final cdr in the list.
-  //
-  pmt_set_cdr(lastnptr, expr);
-  return val;
-}
diff --git a/pmt/src/lib/qa_pmt.cc b/pmt/src/lib/qa_pmt.cc
deleted file mode 100644 (file)
index 250befa..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2006 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 GNU Radio; see the file COPYING.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-/*
- * This class gathers together all the test cases for pmt into
- * a single test suite.  As you create new test cases, add them here.
- */
-
-#include <qa_pmt.h>
-#include <qa_pmt_prims.h>
-#include <qa_pmt_unv.h>
-
-CppUnit::TestSuite *
-qa_pmt::suite ()
-{
-  CppUnit::TestSuite   *s = new CppUnit::TestSuite ("pmt");
-
-  s->addTest (qa_pmt_prims::suite ());
-  s->addTest (qa_pmt_unv::suite ());
-  
-  return s;
-}
diff --git a/pmt/src/lib/qa_pmt.h b/pmt/src/lib/qa_pmt.h
deleted file mode 100644 (file)
index 43a6dbf..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2006 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 GNU Radio; see the file COPYING.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef INCLUDED_QA_PMT_H
-#define INCLUDED_QA_PMT_H
-
-#include <cppunit/TestSuite.h>
-
-//! collect all the tests for pmt
-
-class qa_pmt {
- public:
-  //! return suite of tests for all of pmt
-  static CppUnit::TestSuite *suite ();
-};
-
-#endif /* INCLUDED_QA_PMT_H */
diff --git a/pmt/src/lib/qa_pmt_prims.cc b/pmt/src/lib/qa_pmt_prims.cc
deleted file mode 100644 (file)
index 39cf9ce..0000000
+++ /dev/null
@@ -1,436 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2006 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 GNU Radio; see the file COPYING.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#include <qa_pmt_prims.h>
-#include <cppunit/TestAssert.h>
-#include <pmt.h>
-#include <stdio.h>
-#include <sstream>
-
-void
-qa_pmt_prims::test_symbols()
-{
-  CPPUNIT_ASSERT(!pmt_is_symbol(PMT_T));
-  CPPUNIT_ASSERT(!pmt_is_symbol(PMT_F));
-  CPPUNIT_ASSERT_THROW(pmt_symbol_to_string(PMT_F), pmt_wrong_type);
-
-  pmt_t sym1 = pmt_string_to_symbol("test");
-  CPPUNIT_ASSERT(pmt_is_symbol(sym1));
-  CPPUNIT_ASSERT_EQUAL(std::string("test"), pmt_symbol_to_string(sym1));
-  CPPUNIT_ASSERT(pmt_is_true(sym1));
-  CPPUNIT_ASSERT(!pmt_is_false(sym1));
-
-  pmt_t sym2 = pmt_string_to_symbol("foo");
-  pmt_t sym3 = pmt_string_to_symbol("test");
-  CPPUNIT_ASSERT_EQUAL(sym1, sym3);
-  CPPUNIT_ASSERT(sym1 != sym2);
-  CPPUNIT_ASSERT(sym1 == sym3);
-
-  static const int N = 2048;
-  std::vector<pmt_t> v1(N);
-  std::vector<pmt_t> v2(N);
-
-  // generate a bunch of symbols
-  for (int i = 0; i < N; i++){
-    char buf[100];
-    snprintf(buf, sizeof(buf), "test-%d", i);
-    v1[i] = pmt_string_to_symbol(buf);
-  }
-
-  // confirm that they are all unique
-  for (int i = 0; i < N; i++)
-    for (int j = i + 1; j < N; j++)
-      CPPUNIT_ASSERT(v1[i] != v1[j]);
-
-  // generate the same symbols again
-  for (int i = 0; i < N; i++){
-    char buf[100];
-    snprintf(buf, sizeof(buf), "test-%d", i);
-    v2[i] = pmt_string_to_symbol(buf);
-  }
-
-  // confirm that we get the same ones back
-  for (int i = 0; i < N; i++)
-    CPPUNIT_ASSERT(v1[i] == v2[i]);
-}
-
-void
-qa_pmt_prims::test_booleans()
-{
-  pmt_t sym = pmt_string_to_symbol("test");
-  CPPUNIT_ASSERT(pmt_is_bool(PMT_T));
-  CPPUNIT_ASSERT(pmt_is_bool(PMT_F));
-  CPPUNIT_ASSERT(!pmt_is_bool(sym));
-  CPPUNIT_ASSERT_EQUAL(pmt_from_bool(false), PMT_F);
-  CPPUNIT_ASSERT_EQUAL(pmt_from_bool(true), PMT_T);
-  CPPUNIT_ASSERT_EQUAL(false, pmt_to_bool(PMT_F));
-  CPPUNIT_ASSERT_EQUAL(true, pmt_to_bool(PMT_T));
-  CPPUNIT_ASSERT_THROW(pmt_to_bool(sym), pmt_wrong_type);
-}
-
-void
-qa_pmt_prims::test_integers()
-{
-  pmt_t p1 = pmt_from_long(1);
-  pmt_t m1 = pmt_from_long(-1);
-  CPPUNIT_ASSERT(!pmt_is_integer(PMT_T));
-  CPPUNIT_ASSERT(pmt_is_integer(p1));
-  CPPUNIT_ASSERT(pmt_is_integer(m1));
-  CPPUNIT_ASSERT_THROW(pmt_to_long(PMT_T), pmt_wrong_type);
-  CPPUNIT_ASSERT_EQUAL(-1L, pmt_to_long(m1));
-  CPPUNIT_ASSERT_EQUAL(1L, pmt_to_long(p1));
-}
-
-void
-qa_pmt_prims::test_reals()
-{
-  pmt_t p1 = pmt_from_double(1);
-  pmt_t m1 = pmt_from_double(-1);
-  CPPUNIT_ASSERT(!pmt_is_real(PMT_T));
-  CPPUNIT_ASSERT(pmt_is_real(p1));
-  CPPUNIT_ASSERT(pmt_is_real(m1));
-  CPPUNIT_ASSERT_THROW(pmt_to_double(PMT_T), pmt_wrong_type);
-  CPPUNIT_ASSERT_EQUAL(-1.0, pmt_to_double(m1));
-  CPPUNIT_ASSERT_EQUAL(1.0, pmt_to_double(p1));
-  CPPUNIT_ASSERT_EQUAL(1.0, pmt_to_double(pmt_from_long(1)));
-}
-
-void
-qa_pmt_prims::test_complexes()
-{
-  pmt_t p1 = pmt_make_rectangular(2, -3);
-  pmt_t m1 = pmt_make_rectangular(-3, 2);
-  CPPUNIT_ASSERT(!pmt_is_complex(PMT_T));
-  CPPUNIT_ASSERT(pmt_is_complex(p1));
-  CPPUNIT_ASSERT(pmt_is_complex(m1));
-  CPPUNIT_ASSERT_THROW(pmt_to_complex(PMT_T), pmt_wrong_type);
-  CPPUNIT_ASSERT_EQUAL(std::complex<double>(2, -3), pmt_to_complex(p1));
-  CPPUNIT_ASSERT_EQUAL(std::complex<double>(-3, 2), pmt_to_complex(m1));
-  CPPUNIT_ASSERT_EQUAL(std::complex<double>(1.0, 0), pmt_to_complex(pmt_from_long(1)));
-  CPPUNIT_ASSERT_EQUAL(std::complex<double>(1.0, 0), pmt_to_complex(pmt_from_double(1.0)));
-}
-
-void
-qa_pmt_prims::test_pairs()
-{
-  CPPUNIT_ASSERT(pmt_is_null(PMT_NIL));
-  CPPUNIT_ASSERT(!pmt_is_pair(PMT_NIL));
-  pmt_t s1 = pmt_string_to_symbol("s1");
-  pmt_t s2 = pmt_string_to_symbol("s2");
-  pmt_t s3 = pmt_string_to_symbol("s3");
-
-
-  CPPUNIT_ASSERT_EQUAL((size_t)0, pmt_length(PMT_NIL));
-  CPPUNIT_ASSERT_THROW(pmt_length(s1), pmt_wrong_type);
-  CPPUNIT_ASSERT_THROW(pmt_length(pmt_from_double(42)), pmt_wrong_type);
-
-  pmt_t c1 = pmt_cons(s1, PMT_NIL);
-  CPPUNIT_ASSERT(pmt_is_pair(c1));
-  CPPUNIT_ASSERT(!pmt_is_pair(s1));
-  CPPUNIT_ASSERT_EQUAL(s1, pmt_car(c1));
-  CPPUNIT_ASSERT_EQUAL(PMT_NIL, pmt_cdr(c1));
-  CPPUNIT_ASSERT_EQUAL((size_t) 1, pmt_length(c1));
-
-  pmt_t c3 = pmt_cons(s3, PMT_NIL);
-  pmt_t c2 = pmt_cons(s2, c3);
-  pmt_set_cdr(c1, c2);
-  CPPUNIT_ASSERT_EQUAL(c2, pmt_cdr(c1));
-  pmt_set_car(c1, s3);
-  CPPUNIT_ASSERT_EQUAL(s3, pmt_car(c1));
-  CPPUNIT_ASSERT_EQUAL((size_t)1, pmt_length(c3));
-  CPPUNIT_ASSERT_EQUAL((size_t)2, pmt_length(c2));
-  
-  CPPUNIT_ASSERT_THROW(pmt_cdr(PMT_NIL), pmt_wrong_type);
-  CPPUNIT_ASSERT_THROW(pmt_car(PMT_NIL), pmt_wrong_type);
-  CPPUNIT_ASSERT_THROW(pmt_set_car(s1, PMT_NIL), pmt_wrong_type);
-  CPPUNIT_ASSERT_THROW(pmt_set_cdr(s1, PMT_NIL), pmt_wrong_type);
-}
-
-void
-qa_pmt_prims::test_vectors()
-{
-  static const size_t N = 3;
-  pmt_t v1 = pmt_make_vector(N, PMT_NIL);
-  CPPUNIT_ASSERT_EQUAL(N, pmt_length(v1));
-  pmt_t s0 = pmt_string_to_symbol("s0");
-  pmt_t s1 = pmt_string_to_symbol("s1");
-  pmt_t s2 = pmt_string_to_symbol("s2");
-
-  pmt_vector_set(v1, 0, s0);
-  pmt_vector_set(v1, 1, s1);
-  pmt_vector_set(v1, 2, s2);
-
-  CPPUNIT_ASSERT_EQUAL(s0, pmt_vector_ref(v1, 0));
-  CPPUNIT_ASSERT_EQUAL(s1, pmt_vector_ref(v1, 1));
-  CPPUNIT_ASSERT_EQUAL(s2, pmt_vector_ref(v1, 2));
-
-  CPPUNIT_ASSERT_THROW(pmt_vector_ref(v1, N), pmt_out_of_range);
-  CPPUNIT_ASSERT_THROW(pmt_vector_set(v1, N, PMT_NIL), pmt_out_of_range);
-
-  pmt_vector_fill(v1, s0);
-  for (size_t i = 0; i < N; i++)
-    CPPUNIT_ASSERT_EQUAL(s0, pmt_vector_ref(v1, i));
-}
-
-void
-qa_pmt_prims::test_equivalence()
-{
-  pmt_t s0 = pmt_string_to_symbol("s0");
-  pmt_t s1 = pmt_string_to_symbol("s1");
-  pmt_t s2 = pmt_string_to_symbol("s2");
-  pmt_t list0 = pmt_cons(s0, pmt_cons(s1, pmt_cons(s2, PMT_NIL)));
-  pmt_t list1 = pmt_cons(s0, pmt_cons(s1, pmt_cons(s2, PMT_NIL)));
-  pmt_t i0 = pmt_from_long(42);
-  pmt_t i1 = pmt_from_long(42);
-  pmt_t r0 = pmt_from_double(42);
-  pmt_t r1 = pmt_from_double(42);
-  pmt_t r2 = pmt_from_double(43);
-
-  CPPUNIT_ASSERT(pmt_eq(s0, s0));
-  CPPUNIT_ASSERT(!pmt_eq(s0, s1));
-  CPPUNIT_ASSERT(pmt_eqv(s0, s0));
-  CPPUNIT_ASSERT(!pmt_eqv(s0, s1));
-
-  CPPUNIT_ASSERT(pmt_eqv(i0, i1));
-  CPPUNIT_ASSERT(pmt_eqv(r0, r1));
-  CPPUNIT_ASSERT(!pmt_eqv(r0, r2));
-  CPPUNIT_ASSERT(!pmt_eqv(i0, r0));
-
-  CPPUNIT_ASSERT(!pmt_eq(list0, list1));
-  CPPUNIT_ASSERT(!pmt_eqv(list0, list1));
-  CPPUNIT_ASSERT(pmt_equal(list0, list1));
-
-  pmt_t v0 = pmt_make_vector(3, s0);
-  pmt_t v1 = pmt_make_vector(3, s0);
-  pmt_t v2 = pmt_make_vector(4, s0);
-  CPPUNIT_ASSERT(!pmt_eqv(v0, v1));
-  CPPUNIT_ASSERT(pmt_equal(v0, v1));
-  CPPUNIT_ASSERT(!pmt_equal(v0, v2));
-
-  pmt_vector_set(v0, 0, list0);
-  pmt_vector_set(v0, 1, list0);
-  pmt_vector_set(v1, 0, list1);
-  pmt_vector_set(v1, 1, list1);
-  CPPUNIT_ASSERT(pmt_equal(v0, v1));
-}
-
-void
-qa_pmt_prims::test_misc()
-{
-  pmt_t k0 = pmt_string_to_symbol("k0");
-  pmt_t k1 = pmt_string_to_symbol("k1");
-  pmt_t k2 = pmt_string_to_symbol("k2");
-  pmt_t k3 = pmt_string_to_symbol("k3");
-  pmt_t v0 = pmt_string_to_symbol("v0");
-  pmt_t v1 = pmt_string_to_symbol("v1");
-  pmt_t v2 = pmt_string_to_symbol("v2");
-  pmt_t p0 = pmt_cons(k0, v0);
-  pmt_t p1 = pmt_cons(k1, v1);
-  pmt_t p2 = pmt_cons(k2, v2);
-  
-  pmt_t alist = pmt_cons(p0, pmt_cons(p1, pmt_cons(p2, PMT_NIL)));
-  CPPUNIT_ASSERT(pmt_eq(p1, pmt_assv(k1, alist)));
-  CPPUNIT_ASSERT(pmt_eq(PMT_F, pmt_assv(k3, alist)));
-  
-  pmt_t keys = pmt_cons(k0, pmt_cons(k1, pmt_cons(k2, PMT_NIL)));
-  pmt_t vals = pmt_cons(v0, pmt_cons(v1, pmt_cons(v2, PMT_NIL)));
-  CPPUNIT_ASSERT(pmt_equal(keys, pmt_map(pmt_car, alist)));
-  CPPUNIT_ASSERT(pmt_equal(vals, pmt_map(pmt_cdr, alist)));
-}
-
-void
-qa_pmt_prims::test_dict()
-{
-  pmt_t dict = pmt_make_dict();
-  CPPUNIT_ASSERT(pmt_is_dict(dict));
-
-  pmt_t k0 = pmt_string_to_symbol("k0");
-  pmt_t k1 = pmt_string_to_symbol("k1");
-  pmt_t k2 = pmt_string_to_symbol("k2");
-  pmt_t k3 = pmt_string_to_symbol("k3");
-  pmt_t v0 = pmt_string_to_symbol("v0");
-  pmt_t v1 = pmt_string_to_symbol("v1");
-  pmt_t v2 = pmt_string_to_symbol("v2");
-  pmt_t v3 = pmt_string_to_symbol("v3");
-  pmt_t not_found = pmt_cons(PMT_NIL, PMT_NIL);
-  
-  CPPUNIT_ASSERT(!pmt_dict_has_key(dict, k0));
-  pmt_dict_set(dict, k0, v0);
-  CPPUNIT_ASSERT(pmt_dict_has_key(dict, k0));
-  CPPUNIT_ASSERT(pmt_eqv(pmt_dict_ref(dict, k0, not_found), v0));
-  CPPUNIT_ASSERT(pmt_eqv(pmt_dict_ref(dict, k1, not_found), not_found));
-  pmt_dict_set(dict, k1, v1);
-  pmt_dict_set(dict, k2, v2);
-  CPPUNIT_ASSERT(pmt_eqv(pmt_dict_ref(dict, k1, not_found), v1));
-  pmt_dict_set(dict, k1, v3);
-  CPPUNIT_ASSERT(pmt_eqv(pmt_dict_ref(dict, k1, not_found), v3));
-
-  pmt_t keys = pmt_cons(k2, pmt_cons(k1, pmt_cons(k0, PMT_NIL)));
-  pmt_t vals = pmt_cons(v2, pmt_cons(v3, pmt_cons(v0, PMT_NIL)));
-  CPPUNIT_ASSERT(pmt_equal(keys, pmt_dict_keys(dict)));
-  CPPUNIT_ASSERT(pmt_equal(vals, pmt_dict_values(dict)));
-}
-
-void
-qa_pmt_prims::test_io()
-{
-  pmt_t k0 = pmt_string_to_symbol("k0");
-  pmt_t k1 = pmt_string_to_symbol("k1");
-  pmt_t k2 = pmt_string_to_symbol("k2");
-  pmt_t k3 = pmt_string_to_symbol("k3");
-
-  CPPUNIT_ASSERT_EQUAL(std::string("k0"), pmt_write_string(k0));
-}
-
-void
-qa_pmt_prims::test_lists()
-{
-  pmt_t s0 = pmt_intern("s0");
-  pmt_t s1 = pmt_intern("s1");
-  pmt_t s2 = pmt_intern("s2");
-  pmt_t s3 = pmt_intern("s3");
-
-  pmt_t l1 = pmt_list4(s0, s1, s2, s3);
-  pmt_t l2 = pmt_list3(s0, s1, s2);
-  pmt_t l3 = pmt_list_add(l2, s3);
-  CPPUNIT_ASSERT(pmt_equal(l1, l3));
-}
-
-// ------------------------------------------------------------------------
-
-// class foo is used in test_any below.
-// It can't be declared in the scope of test_any because of template
-// namespace problems.
-
-class foo {
-public:
-  double       d_double;
-  int          d_int;
-  foo(double d=0, int i=0) : d_double(d), d_int(i) {}
-};
-
-bool operator==(const foo &a, const foo &b)
-{
-  return a.d_double == b.d_double && a.d_int == b.d_int;
-}
-
-std::ostream& operator<<(std::ostream &os, const foo obj)
-{
-  os << "<foo: " << obj.d_double << ", " << obj.d_int << ">";
-  return os;
-}
-
-void
-qa_pmt_prims::test_any()
-{
-  boost::any a0;
-  boost::any a1;
-  boost::any a2;
-
-  a0 = std::string("Hello!");
-  a1 = 42;
-  a2 = foo(3.250, 21);
-
-  pmt_t p0 = pmt_make_any(a0);
-  pmt_t p1 = pmt_make_any(a1);
-  pmt_t p2 = pmt_make_any(a2);
-
-  CPPUNIT_ASSERT_EQUAL(std::string("Hello!"),
-                      boost::any_cast<std::string>(pmt_any_ref(p0)));
-
-  CPPUNIT_ASSERT_EQUAL(42,
-                      boost::any_cast<int>(pmt_any_ref(p1)));
-
-  CPPUNIT_ASSERT_EQUAL(foo(3.250, 21),
-                      boost::any_cast<foo>(pmt_any_ref(p2)));
-}
-
-// ------------------------------------------------------------------------
-
-void
-qa_pmt_prims::test_serialize()
-{
-  std::stringbuf sb;           // fake channel
-  pmt_t a = pmt_intern("a");
-  pmt_t b = pmt_intern("b");
-  pmt_t c = pmt_intern("c");
-
-  sb.str("");                  // reset channel to empty
-
-  // write stuff to channel
-
-  pmt_serialize(PMT_NIL, sb);
-  pmt_serialize(pmt_intern("foobarvia"), sb);
-  pmt_serialize(pmt_from_long(123456789), sb);
-  pmt_serialize(pmt_from_long(-123456789), sb);
-  pmt_serialize(pmt_cons(PMT_NIL, PMT_NIL), sb);
-  pmt_serialize(pmt_cons(a, b), sb);
-  pmt_serialize(pmt_list1(a), sb);
-  pmt_serialize(pmt_list2(a, b), sb);
-  pmt_serialize(pmt_list3(a, b, c), sb);
-  pmt_serialize(pmt_list3(a, pmt_list3(c, b, a), c), sb);
-  pmt_serialize(PMT_T, sb);
-  pmt_serialize(PMT_F, sb);
-
-  // read it back
-
-  CPPUNIT_ASSERT(pmt_equal(pmt_deserialize(sb), PMT_NIL));
-  CPPUNIT_ASSERT(pmt_equal(pmt_deserialize(sb), pmt_intern("foobarvia")));
-  CPPUNIT_ASSERT(pmt_equal(pmt_deserialize(sb), pmt_from_long(123456789)));
-  CPPUNIT_ASSERT(pmt_equal(pmt_deserialize(sb), pmt_from_long(-123456789)));
-  CPPUNIT_ASSERT(pmt_equal(pmt_deserialize(sb), pmt_cons(PMT_NIL, PMT_NIL)));
-  CPPUNIT_ASSERT(pmt_equal(pmt_deserialize(sb), pmt_cons(a, b)));
-  CPPUNIT_ASSERT(pmt_equal(pmt_deserialize(sb), pmt_list1(a)));
-  CPPUNIT_ASSERT(pmt_equal(pmt_deserialize(sb), pmt_list2(a, b)));
-  CPPUNIT_ASSERT(pmt_equal(pmt_deserialize(sb), pmt_list3(a, b, c)));
-  CPPUNIT_ASSERT(pmt_equal(pmt_deserialize(sb), pmt_list3(a, pmt_list3(c, b, a), c)));
-  CPPUNIT_ASSERT(pmt_equal(pmt_deserialize(sb), PMT_T));
-  CPPUNIT_ASSERT(pmt_equal(pmt_deserialize(sb), PMT_F));
-
-  CPPUNIT_ASSERT(pmt_equal(pmt_deserialize(sb), PMT_EOF));     // last item
-
-
-  // FIXME add tests for real, complex, vector, uniform-vector, dict
-  // FIXME add tests for malformed input too.
-
-}
-
-void
-qa_pmt_prims::test_sets()
-{
-  pmt_t s1 = pmt_intern("s1");
-  pmt_t s2 = pmt_intern("s2");
-  pmt_t s3 = pmt_intern("s3");
-
-  pmt_t l1 = pmt_list1(s1);
-  pmt_t l2 = pmt_list2(s2,s3);
-  pmt_t l3 = pmt_list3(s1,s2,s3);
-
-  CPPUNIT_ASSERT(pmt_is_pair(pmt_memq(s1,l1)));
-  CPPUNIT_ASSERT(pmt_is_false(pmt_memq(s3,l1)));
-
-  CPPUNIT_ASSERT(pmt_subsetp(l1,l3));
-  CPPUNIT_ASSERT(pmt_subsetp(l2,l3));
-  CPPUNIT_ASSERT(!pmt_subsetp(l1,l2));
-  CPPUNIT_ASSERT(!pmt_subsetp(l2,l1));
-  CPPUNIT_ASSERT(!pmt_subsetp(l3,l2));
-}
diff --git a/pmt/src/lib/qa_pmt_prims.h b/pmt/src/lib/qa_pmt_prims.h
deleted file mode 100644 (file)
index effb3a0..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2006 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 GNU Radio; see the file COPYING.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-#ifndef INCLUDED_QA_PMT_PRIMS_H
-#define INCLUDED_QA_PMT_PRIMS_H
-
-#include <cppunit/extensions/HelperMacros.h>
-#include <cppunit/TestCase.h>
-
-class qa_pmt_prims : public CppUnit::TestCase {
-
-  CPPUNIT_TEST_SUITE(qa_pmt_prims);
-  CPPUNIT_TEST(test_symbols);
-  CPPUNIT_TEST(test_booleans);
-  CPPUNIT_TEST(test_integers);
-  CPPUNIT_TEST(test_reals);
-  CPPUNIT_TEST(test_complexes);
-  CPPUNIT_TEST(test_pairs);
-  CPPUNIT_TEST(test_vectors);
-  CPPUNIT_TEST(test_equivalence);
-  CPPUNIT_TEST(test_misc);
-  CPPUNIT_TEST(test_dict);
-  CPPUNIT_TEST(test_any);
-  CPPUNIT_TEST(test_io);
-  CPPUNIT_TEST(test_lists);
-  CPPUNIT_TEST(test_serialize);
-  CPPUNIT_TEST(test_sets);
-  CPPUNIT_TEST_SUITE_END();
-
- private:
-  void test_symbols();
-  void test_booleans();
-  void test_integers();
-  void test_reals();
-  void test_complexes();
-  void test_pairs();
-  void test_vectors();
-  void test_equivalence();
-  void test_misc();
-  void test_dict();
-  void test_any();
-  void test_io();
-  void test_lists();
-  void test_serialize();
-  void test_sets();
-};
-
-#endif /* INCLUDED_QA_PMT_PRIMS_H */
-
diff --git a/pmt/src/lib/test_pmt.cc b/pmt/src/lib/test_pmt.cc
deleted file mode 100644 (file)
index 034785f..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2006 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 GNU Radio; see the file COPYING.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#include <cppunit/TextTestRunner.h>
-#include <qa_pmt.h>
-
-int 
-main(int argc, char **argv)
-{
-  
-  CppUnit::TextTestRunner      runner;
-
-  runner.addTest(qa_pmt::suite ());
-  
-  bool was_successful = runner.run("", false);
-
-  return was_successful ? 0 : 1;
-}
diff --git a/pmt/src/lib/unv_qa_template.cc.t b/pmt/src/lib/unv_qa_template.cc.t
deleted file mode 100644 (file)
index 1e2c8e8..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-void
-qa_pmt_unv::test_@TAG@vector()
-{
-  static const size_t N = 3;
-  pmt_t v1 = pmt_make_@TAG@vector(N, 0);
-  CPPUNIT_ASSERT_EQUAL(N, pmt_length(v1));
-  @TYPE@ s0 = @TYPE@(10);
-  @TYPE@ s1 = @TYPE@(20);
-  @TYPE@ s2 = @TYPE@(30);
-
-  pmt_@TAG@vector_set(v1, 0, s0);
-  pmt_@TAG@vector_set(v1, 1, s1);
-  pmt_@TAG@vector_set(v1, 2, s2);
-
-  CPPUNIT_ASSERT_EQUAL(s0, pmt_@TAG@vector_ref(v1, 0));
-  CPPUNIT_ASSERT_EQUAL(s1, pmt_@TAG@vector_ref(v1, 1));
-  CPPUNIT_ASSERT_EQUAL(s2, pmt_@TAG@vector_ref(v1, 2));
-
-  CPPUNIT_ASSERT_THROW(pmt_@TAG@vector_ref(v1, N), pmt_out_of_range);
-  CPPUNIT_ASSERT_THROW(pmt_@TAG@vector_set(v1, N, @TYPE@(0)), pmt_out_of_range);
-
-  size_t       len;
-  const @TYPE@ *rd = pmt_@TAG@vector_elements(v1, len);
-  CPPUNIT_ASSERT_EQUAL(len, N);
-  CPPUNIT_ASSERT_EQUAL(s0, rd[0]);
-  CPPUNIT_ASSERT_EQUAL(s1, rd[1]);
-  CPPUNIT_ASSERT_EQUAL(s2, rd[2]);
-
-  @TYPE@ *wr = pmt_@TAG@vector_writable_elements(v1, len);
-  CPPUNIT_ASSERT_EQUAL(len, N);
-  wr[0] = @TYPE@(0);
-  CPPUNIT_ASSERT_EQUAL(@TYPE@(0), wr[0]);
-  CPPUNIT_ASSERT_EQUAL(s1, wr[1]);
-  CPPUNIT_ASSERT_EQUAL(s2, wr[2]);
-}
diff --git a/pmt/src/lib/unv_template.cc.t b/pmt/src/lib/unv_template.cc.t
deleted file mode 100644 (file)
index 1e86cae..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-////////////////////////////////////////////////////////////////////////////
-//                           pmt_@TAG@vector
-////////////////////////////////////////////////////////////////////////////
-
-static pmt_@TAG@vector *
-_@TAG@vector(pmt_t x)
-{
-  return dynamic_cast<pmt_@TAG@vector*>(x.get());
-}
-
-
-pmt_@TAG@vector::pmt_@TAG@vector(size_t k, @TYPE@ fill)
-  : d_v(k)
-{
-  for (size_t i = 0; i < k; i++)
-    d_v[i] = fill;
-}
-
-pmt_@TAG@vector::pmt_@TAG@vector(size_t k, const @TYPE@ *data)
-  : d_v(k)
-{
-  for (size_t i = 0; i < k; i++)
-    d_v[i] = data[i];
-}
-
-@TYPE@
-pmt_@TAG@vector::ref(size_t k) const
-{
-  if (k >= length())
-    throw pmt_out_of_range("pmt_@TAG@vector_ref", pmt_from_long(k));
-  return d_v[k];
-}
-
-void 
-pmt_@TAG@vector::set(size_t k, @TYPE@ x)
-{
-  if (k >= length())
-    throw pmt_out_of_range("pmt_@TAG@vector_set", pmt_from_long(k));
-  d_v[k] = x;
-}
-
-const @TYPE@ *
-pmt_@TAG@vector::elements(size_t &len)
-{
-  len = length();
-  return &d_v[0];
-}
-
-@TYPE@ *
-pmt_@TAG@vector::writable_elements(size_t &len)
-{
-  len = length();
-  return &d_v[0];
-}
-
-const void*
-pmt_@TAG@vector::uniform_elements(size_t &len)
-{
-  len = length() * sizeof(@TYPE@);
-  return &d_v[0];
-}
-
-void*
-pmt_@TAG@vector::uniform_writable_elements(size_t &len)
-{
-  len = length() * sizeof(@TYPE@);
-  return &d_v[0];
-}
-
-bool
-pmt_is_@TAG@vector(pmt_t obj)
-{
-  return obj->is_@TAG@vector();
-}
-
-pmt_t
-pmt_make_@TAG@vector(size_t k, @TYPE@ fill)
-{
-  return pmt_t(new pmt_@TAG@vector(k, fill));
-}
-
-pmt_t
-pmt_init_@TAG@vector(size_t k, const @TYPE@ *data)
-{
-  return pmt_t(new pmt_@TAG@vector(k, data));
-}
-
-@TYPE@
-pmt_@TAG@vector_ref(pmt_t vector, size_t k)
-{
-  if (!vector->is_@TAG@vector())
-    throw pmt_wrong_type("pmt_@TAG@vector_ref", vector);
-  return _@TAG@vector(vector)->ref(k);
-}
-
-void
-pmt_@TAG@vector_set(pmt_t vector, size_t k, @TYPE@ obj)
-{
-  if (!vector->is_@TAG@vector())
-    throw pmt_wrong_type("pmt_@TAG@vector_set", vector);
-  _@TAG@vector(vector)->set(k, obj);
-}
-
-const @TYPE@ *
-pmt_@TAG@vector_elements(pmt_t vector, size_t &len)
-{
-  if (!vector->is_@TAG@vector())
-    throw pmt_wrong_type("pmt_@TAG@vector_elements", vector);
-  return _@TAG@vector(vector)->elements(len);
-}
-
-@TYPE@ *
-pmt_@TAG@vector_writable_elements(pmt_t vector, size_t &len)
-{
-  if (!vector->is_@TAG@vector())
-    throw pmt_wrong_type("pmt_@TAG@vector_writable_elements", vector);
-  return _@TAG@vector(vector)->writable_elements(len);
-}
diff --git a/pmt/src/lib/unv_template.h.t b/pmt/src/lib/unv_template.h.t
deleted file mode 100644 (file)
index 83ba0be..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-
-////////////////////////////////////////////////////////////////////////////
-//                           pmt_@TAG@vector
-////////////////////////////////////////////////////////////////////////////
-
-class pmt_@TAG@vector : public pmt_uniform_vector
-{
-  std::vector< @TYPE@ >        d_v;
-
-public:
-  pmt_@TAG@vector(size_t k, @TYPE@ fill);
-  pmt_@TAG@vector(size_t k, const @TYPE@ *data);
-  // ~pmt_@TAG@vector();
-
-  bool is_@TAG@vector() const { return true; }
-  size_t length() const { return d_v.size(); }
-  @TYPE@ ref(size_t k) const;
-  void set(size_t k, @TYPE@ x);
-  const @TYPE@ *elements(size_t &len);
-  @TYPE@ *writable_elements(size_t &len);
-  const void *uniform_elements(size_t &len);
-  void *uniform_writable_elements(size_t &len);
-};
diff --git a/pmt/src/scheme/Makefile.am b/pmt/src/scheme/Makefile.am
deleted file mode 100644 (file)
index 4980063..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Copyright 2007 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.
-#
-
-SUBDIRS = gnuradio
diff --git a/pmt/src/scheme/gnuradio/Makefile.am b/pmt/src/scheme/gnuradio/Makefile.am
deleted file mode 100644 (file)
index 0ce01f6..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# Copyright 2007,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.
-#
-
-#pkgdatadir = $(datadir)/gnuradio
-
-EXTRA_DIST =                           \
-       gen-serial-tags.scm
-
-# really scheme source files
-dist_pkgdata_DATA =                    \
-       pmt-serial-tags.scm             \
-       pmt-serialize.scm               \
-       macros-etc.scm
-
diff --git a/pmt/src/scheme/gnuradio/gen-serial-tags.scm b/pmt/src/scheme/gnuradio/gen-serial-tags.scm
deleted file mode 100755 (executable)
index 7b90872..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-#!/usr/bin/guile \
--e main -s
-!#
-;;; -*-scheme-*-
-;;;
-;;; Copyright 2007 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.
-;;;
-
-(use-modules (ice-9 format))
-
-(defmacro when (pred . body)
-  `(if ,pred (begin ,@body) #f))
-
-;; ----------------------------------------------------------------
-
-(define (main args)
-
-  (define (usage)
-    (format 0
-           "usage: ~a <pmt-serial-tags.scm> <pmt_serial_tags.h>~%"
-           (car args)))
-
-  (when (not (= (length args) 3))
-       (usage)
-       (format 0 "args: ~s~%" args)
-       (exit 1))
-      
-  (let ((i-file (open-input-file (cadr args)))
-       (h-file (open-output-file (caddr args))))
-
-      (write-header-comment h-file "// ")
-      (display "#ifndef INCLUDED_PMT_SERIAL_TAGS_H\n" h-file)
-      (display "#define INCLUDED_PMT_SERIAL_TAGS_H\n" h-file)
-      (newline h-file)
-      (display "enum pst_tags {\n" h-file)
-
-      (for-each-in-file i-file
-       (lambda (form)
-        (let* ((name (cadr form))
-               (c-name (string-upcase (c-ify name)))
-               (value (caddr form)))
-          ;;(format h-file   "static const int ~a\t= 0x~x;~%" c-name value)
-          (format h-file   "  ~a\t= 0x~x,~%" c-name value))))
-
-      (display "};\n" h-file)
-      (display "#endif\n" h-file)))
-
-(define (c-ify name)
-  (list->string (map (lambda (c)
-                      (if (eqv? c #\-) #\_ c))
-                    (string->list (symbol->string name)))))
-
-
-(define (write-header-comment o-port prefix)
-  (for-each (lambda (comment)
-             (format o-port "~a~a~%" prefix comment))
-           header-comment))
-
-(define header-comment
-  '(
-    ""
-    "Copyright 2007 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."
-    ""
-    ""
-    "THIS FILE IS MACHINE GENERATED FROM pmt-serial-tags.scm. DO NOT EDIT BY HAND."
-    "See pmt-serial-tags.scm for additional commentary."
-    ""))
-
-
-
-(define (for-each-in-file file f)
-  (let ((port (if (port? file)
-                 file
-                 (open-input-file file))))
-    (letrec
-     ((loop
-       (lambda (port form)
-        (cond ((eof-object? form)
-               (when (not (eq? port file))
-                     (close-input-port port))
-               #t)
-              (else
-               (f form)
-               (set! form #f)          ; for GC
-               (loop port (read port)))))))
-     (loop port (read port)))))
diff --git a/pmt/src/scheme/gnuradio/macros-etc.scm b/pmt/src/scheme/gnuradio/macros-etc.scm
deleted file mode 100644 (file)
index ac2a4a3..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-;;; -*- scheme -*-
-;;;
-;;; Copyright 2007 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.
-;;;
-
-(define-module (gnuradio macros-etc)
-  :export (atom? when unless for-each-in-file))
-
-(define (atom? obj)
-  (not (pair? obj)))
-
-(defmacro when (pred . body)
-  `(if ,pred (begin ,@body) #f))
-
-(defmacro unless (pred . body)
-  `(if (not ,pred) (begin ,@body) #f))
-
-
-(define (for-each-in-file file f)
-  (let ((port (if (port? file)
-                 file
-                 (open-input-file file))))
-    (letrec
-     ((loop
-       (lambda (port form)
-        (cond ((eof-object? form)
-               (when (not (eq? port file))
-                     (close-input-port port))
-               #t)
-              (else
-               (f form)
-               (set! form #f)          ; for GC
-               (loop port (read port)))))))
-     (loop port (read port)))))
diff --git a/pmt/src/scheme/gnuradio/pmt-serial-tags.scm b/pmt/src/scheme/gnuradio/pmt-serial-tags.scm
deleted file mode 100644 (file)
index 646a751..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-;;; -*-scheme-*-
-;;;
-;;; Copyright 2007 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 (define 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.
-;;;
-
-;;; definitions of tag values used for marshalling pmt data
-
-(define pst-true               #x00)
-(define pst-false              #x01)
-(define pst-symbol             #x02)   ; untagged-int16 n; followed by n bytes of symbol name
-(define pst-int32              #x03)
-(define pst-double             #x04)
-(define pst-complex            #x05)   ; complex<double>: real, imag
-(define pst-null               #x06)
-(define pst-pair               #x07)   ; followed by two objects
-(define pst-vector             #x08)   ; untagged-int32 n; followed by n objects
-(define pst-dict               #x09)   ; untagged-int32 n; followed by n key/value tuples
-
-(define pst-uniform-vector     #x0a)
-
-;; u8, s8, u16, s16, u32, s32, u64, s64, f32, f64, c32, c64
-;;
-;;   untagged-uint8  tag
-;;   untagged-uint8  uvi (define uniform vector info, see below)
-;;   untagged-int32  n-items
-;;   untagged-uint8  npad
-;;   npad bytes of zeros to align binary data
-;;   n-items binary numeric items
-;;
-;; uvi:
-;; +-+-+-+-+-+-+-+-+
-;; |B|   subtype   |
-;; +-+-+-+-+-+-+-+-+
-;;
-;; B == 0, numeric data is little-endian.
-;; B == 1, numeric data is big-endian.
-
-    (define uvi-endian-mask     #x80)
-    (define uvi-subtype-mask    #x7f)
-
-    (define uvi-little-endian   #x00)
-    (define uvi-big-endian      #x80)
-
-    (define uvi-u8             #x00)
-    (define uvi-s8             #x01)
-    (define uvi-u16            #x02)
-    (define uvi-s16            #x03)
-    (define uvi-u32            #x04)
-    (define uvi-s32            #x05)
-    (define uvi-u64            #x06)
-    (define uvi-s64            #x07)
-    (define uvi-f32            #x08)
-    (define uvi-f64            #x09)
-    (define uvi-c32            #x0a)
-    (define uvi-c64            #x0b)
-
-
-(define pst-comment            #x3b)   ; ascii ';'
-(define pst-comment-end                #x0a)   ; ascii '\n'
diff --git a/pmt/src/scheme/gnuradio/pmt-serialize.scm b/pmt/src/scheme/gnuradio/pmt-serialize.scm
deleted file mode 100644 (file)
index c1d32d7..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-;;;
-;;; Copyright 2007 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.
-;;;
-
-;;; An implementation of pmt_serialize in scheme.
-;;; Currently handles only symbols and pairs.  They're all we need for now.
-
-(define-module (gnuradio pmt-serialize)
-  :export (pmt-serialize))
-
-(load-from-path "gnuradio/pmt-serial-tags")
-
-(define (pmt-serialize obj put-byte)
-  (define (put-u16 x)
-    (put-byte (logand (ash x -8) #xff))
-    (put-byte (logand x #xff)))
-    
-  (cond ((null? obj)
-        (put-byte pst-null))
-       ((symbol? obj)
-        (let* ((sym-as-bytes (map char->integer (string->list (symbol->string obj))))
-               (len (length sym-as-bytes)))
-          (put-byte pst-symbol)
-          (put-u16 len)
-          (for-each put-byte sym-as-bytes)))
-       
-       ((pair? obj)
-        (put-byte pst-pair)
-        (pmt-serialize (car obj) put-byte)
-        (pmt-serialize (cdr obj) put-byte))
-       (else
-        (throw 'not-implemented "pmt-serialize" obj))))