From a611da7044175fede5f8ecfe13a055f5680fd3f9 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Mon, 14 Mar 2011 19:33:03 -0400 Subject: gruel: SWIGing Gruel into Python to access PMTs. --- gruel/src/swig/Makefile.am | 71 ++++ gruel/src/swig/Makefile.swig.gen | 115 ++++++ gruel/src/swig/__init__.py | 0 gruel/src/swig/pmt.i | 759 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 945 insertions(+) create mode 100644 gruel/src/swig/Makefile.am create mode 100644 gruel/src/swig/Makefile.swig.gen create mode 100644 gruel/src/swig/__init__.py create mode 100644 gruel/src/swig/pmt.i (limited to 'gruel/src/swig') diff --git a/gruel/src/swig/Makefile.am b/gruel/src/swig/Makefile.am new file mode 100644 index 000000000..c6e9246e5 --- /dev/null +++ b/gruel/src/swig/Makefile.am @@ -0,0 +1,71 @@ +# +# Copyright 2001,2003,2004,2005,2006,2007,2008,2009,2010 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 +include $(top_srcdir)/Makefile.swig + +AM_CPPFLAGS = -I$(srcdir) $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) \ + $(WITH_INCLUDES) + +TOP_SWIG_IFILES = \ + pmt.i + + +# SWIG headers get installed in ${prefix}/include/gnuradio/swig +swiginclude_HEADERS = \ + pmt.i + +# SWIG headers that get installed in ${prefix}/include/gnuradio/swig/... +nobase_swiginclude_HEADERS = + + +# special install for this top-level Python script which includes all +# of the split Python libraries. +ourpythondir = $(pythondir)/gruel +ourpython_PYTHON = \ + pmt.py \ + __init__.py + +# ---------------------------------------------------------------- +# FIXME As of swig 1.3.31, this still seems to be required... +# gnuradio_swig_bug_workaround.h : gnuradio_core_runtime.py $(srcdir)/gen-swig-bug-fix +# $(PYTHON) $(srcdir)/gen-swig-bug-fix python/gnuradio_core_runtime.cc $@ + +EXTRA_DIST += gen-swig-bug-fix + +# C/C++ headers get installed in ${prefix}/include/gnuradio +#grinclude_HEADERS = gnuradio_swig_bug_workaround.h +grinclude_HEADERS = + + +# Install so that they end up available as: +# import gnuradio.gr +# This ends up at: +# ${prefix}/lib/python${python_version}/site-packages/gnuradio/gr +pmt_pythondir_category = gruel + +# additional libraries for linking with each SWIG-generated library +pmt_la_swig_libadd = $(GRUEL_LA) + +SWIG_GUILE_FLAGS += -DIN_GNURADIO_CORE + + + diff --git a/gruel/src/swig/Makefile.swig.gen b/gruel/src/swig/Makefile.swig.gen new file mode 100644 index 000000000..9b4f62f77 --- /dev/null +++ b/gruel/src/swig/Makefile.swig.gen @@ -0,0 +1,115 @@ +# -*- Makefile -*- +# +# Copyright 2009 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +# Makefile.swig.gen for gnuradio_core_runtime.i + +## Default install locations for these files: +## +## Default location for the Python directory is: +## ${prefix}/lib/python${python_version}/site-packages/[category]/gnuradio_core_runtime +## Default location for the Python exec directory is: +## ${exec_prefix}/lib/python${python_version}/site-packages/[category]/gnuradio_core_runtime +## +## The following can be overloaded to change the install location, but +## this has to be done in the including Makefile.am -before- +## Makefile.swig is included. + +pmt_pythondir_category ?= gruel/pmt +pmt_pylibdir_category ?= $(pmt_pythondir_category) +pmt_pythondir = $(pythondir)/$(pmt_pythondir_category) +pmt_pylibdir = $(pyexecdir)/$(pmt_pylibdir_category) + +# The .so libraries for the guile modules get installed whereever guile +# is installed, usually /usr/lib/guile/gnuradio/ +# FIXME: determince whether these should be installed with gnuradio. +pmt_scmlibdir = $(libdir) + +# The scm files for the guile modules get installed where ever guile +# is installed, usually /usr/share/guile/site/gnuradio_core_runtime +# FIXME: determince whether these should be installed with gnuradio. +pmt_scmdir = $(guiledir) + +## SWIG headers are always installed into the same directory. + +pmt_swigincludedir = $(swigincludedir) + +## This is a template file for a "generated" Makefile addition (in +## this case, "Makefile.swig.gen"). By including the top-level +## Makefile.swig, this file will be used to generate the SWIG +## dependencies. Assign the variable TOP_SWIG_FILES to be the list of +## SWIG .i files to generated wrappings for; there can be more than 1 +## so long as the names are unique (no sorting is done on the +## TOP_SWIG_FILES list). This file explicitly assumes that a SWIG .i +## file will generate .cc, .py, and possibly .h files -- meaning that +## all of these files will have the same base name (that provided for +## the SWIG .i file). +## +## This code is setup to ensure parallel MAKE ("-j" or "-jN") does the +## right thing. For more info, see < +## http://sources.redhat.com/automake/automake.html#Multiple-Outputs > + +## Other cleaned files: dependency files generated by SWIG or this Makefile + +MOSTLYCLEANFILES += $(DEPDIR)/*.S* + +## Various SWIG variables. These can be overloaded in the including +## Makefile.am by setting the variable value there, then including +## Makefile.swig . + +pmt_swiginclude_HEADERS = \ + pmt.i \ + $(pmt_swiginclude_headers) + +if PYTHON +pmt_pylib_LTLIBRARIES = \ + _pmt.la + +_pmt_la_SOURCES = \ + python/pmt.cc \ + $(pmt_la_swig_sources) + +pmt_python_PYTHON = \ + pmt.py \ + $(pmt_python) + +_pmt_la_LIBADD = \ + $(STD_SWIG_LA_LIB_ADD) \ + $(pmt_la_swig_libadd) + +_pmt_la_LDFLAGS = \ + $(STD_SWIG_LA_LD_FLAGS) \ + $(pmt_la_swig_ldflags) + +_pmt_la_CXXFLAGS = \ + $(STD_SWIG_CXX_FLAGS) \ + -I$(top_builddir) \ + $(pmt_la_swig_cxxflags) + +python/pmt.cc: pmt.py +pmt.py: pmt.i + +# Include the python dependencies for this file +-include python/pmt.d + +endif # end of if python + + diff --git a/gruel/src/swig/__init__.py b/gruel/src/swig/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/gruel/src/swig/pmt.i b/gruel/src/swig/pmt.i new file mode 100644 index 000000000..e5f9ba0a2 --- /dev/null +++ b/gruel/src/swig/pmt.i @@ -0,0 +1,759 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2009,2010 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. + */ + +%module pmt +%include "std_string.i" +%include "stdint.i" +%{ +#include +#include +#include +#include +#include +#include +#include +#include +#include +using namespace pmt; +%} + + + +/* + * ------------------------------------------------------------------------ + * 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; +extern const pmt_t PMT_F; + +//! 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); + +/* + * ------------------------------------------------------------------------ + * uint64_t + * ------------------------------------------------------------------------ + */ + +//! Return true if \p x is an uint64 number, else false +bool pmt_is_uint64(pmt_t x); + +//! Return the pmt value that represents the uint64 \p x. +pmt_t pmt_from_uint64(uint64_t x); + +/*! + * \brief Convert pmt to uint64 if possible. + * + * When \p x represents an exact integer that fits in a uint64, + * return that uint64. Else raise an exception, either wrong_type + * when x is not an exact uint64, or out_of_range when it doesn't fit. + */ +uint64_t pmt_to_uint64(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. + * Otherwise, raise the wrong_type exception. + */ +std::complex 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); + +/* + * ------------------------------------------------------------------------ + * Tuples + * + * Store a fixed number of objects. Tuples are not modifiable, and thus + * are excellent for use as messages. Indexing is zero based. + * Access time to an element is O(1). + * ------------------------------------------------------------------------ + */ + +//! Return true if \p x is a tuple, othewise false. +bool pmt_is_tuple(pmt_t x); + +pmt_t pmt_make_tuple(); +pmt_t pmt_make_tuple(const pmt_t &e0); +pmt_t pmt_make_tuple(const pmt_t &e0, const pmt_t &e1); +pmt_t pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2); +pmt_t pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3); +pmt_t pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4); +pmt_t pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5); +pmt_t pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5, const pmt_t &e6); +pmt_t pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5, const pmt_t &e6, const pmt_t &e7); +pmt_t pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5, const pmt_t &e6, const pmt_t &e7, const pmt_t &e8); +pmt_t pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5, const pmt_t &e6, const pmt_t &e7, const pmt_t &e8, const pmt_t &e9); + +/*! + * If \p x is a vector or proper list, return a tuple containing the elements of x + */ +pmt_t pmt_to_tuple(const pmt_t &x); + +/*! + * Return the contents of position \p k of \p tuple. + * \p k must be a valid index of \p tuple. + */ +pmt_t pmt_tuple_ref(const pmt_t &tuple, size_t k); + +/* + * ------------------------------------------------------------------------ + * 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); + +/* + * ------------------------------------------------------------------------ + * Binary Large Objects (BLOBs) + * + * Handy for passing around uninterpreted chunks of memory. + * ------------------------------------------------------------------------ + */ + +//! Return true if \p x is a blob, othewise false. +bool pmt_is_blob(pmt_t x); + +/*! + * \brief Make a blob given a pointer and length in bytes + * + * \param buf is the pointer to data to use to create blob + * \param len is the size of the data in bytes. + * + * The data is copied into the blob. + */ +pmt_t pmt_make_blob(const void *buf, size_t len); + +//! Return a pointer to the blob's data +const void *pmt_blob_data(pmt_t blob); + +//! Return the blob's length in bytes +size_t pmt_blob_length(pmt_t blob); + +/*! + *
+ * ------------------------------------------------------------------------
+ *		       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
+ *   c64  the C++ type complex
+ * ------------------------------------------------------------------------
+ * 
+ */ + +//! 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 fill); +pmt_t pmt_make_c64vector(size_t k, std::complex 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_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 *data); +pmt_t pmt_init_c64vector(size_t k, const std::complex *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 pmt_c32vector_ref(pmt_t v, size_t k); +std::complex 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 x); +void pmt_c64vector_set(pmt_t v, size_t k, std::complex 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 *pmt_c32vector_elements(pmt_t v, size_t &len); //< len is in elements +const std::complex *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 *pmt_c32vector_writable_elements(pmt_t v, size_t &len); //< len is in elements +std::complex *pmt_c64vector_writable_elements(pmt_t v, size_t &len); //< len is in elements + +/* + * ------------------------------------------------------------------------ + * Dictionary (a.k.a associative array, hash, map) + * + * This is a functional data structure that is persistent. Updating a + * functional data structure does not destroy the existing version, but + * rather creates a new version that coexists with the old. + * ------------------------------------------------------------------------ + */ + +//! Return true if \p obj is a dictionary +bool pmt_is_dict(const pmt_t &obj); + +//! Make an empty dictionary +pmt_t pmt_make_dict(); + +//! Return a new dictionary with \p key associated with \p value. +pmt_t pmt_dict_add(const pmt_t &dict, const pmt_t &key, const pmt_t &value); + +//! Return a new dictionary with \p key removed. +pmt_t pmt_dict_delete(const pmt_t &dict, const pmt_t &key); + +//! Return true if \p key exists in \p dict +bool pmt_dict_has_key(const pmt_t &dict, const pmt_t &key); + +//! If \p key exists in \p dict, return associated value; otherwise return \p not_found. +pmt_t pmt_dict_ref(const pmt_t &dict, const pmt_t &key, const pmt_t ¬_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); + + +/* + * ------------------------------------------------------------------------ + * msg_accepter -- pmt representation of gruel::msg_accepter + * ------------------------------------------------------------------------ + */ +//! Return true if \p obj is a msg_accepter +bool pmt_is_msg_accepter(const pmt_t &obj); + +//! make a msg_accepter +pmt_t pmt_make_msg_accepter(boost::shared_ptr ma); + +//! Return underlying msg_accepter +boost::shared_ptr pmt_msg_accepter_ref(const pmt_t &obj); + +/* + * ------------------------------------------------------------------------ + * 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. + * + *
+ * 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.
+ * 
+ */ +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); + + +/*! + * \brief Write pmt string representation to stdout. + */ +void pmt_print(pmt_t v); + + +/* + * ------------------------------------------------------------------------ + * 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 + +/*! + * \brief Provide a simple string generating interface to pmt's serialize function + */ +std::string pmt_serialize_str(pmt_t obj); + +/*! + * \brief Provide a simple string generating interface to pmt's deserialize function + */ +pmt_t pmt_deserialize_str(std::string str); + + + + -- cgit From ee849707c09335f4c682151044a0e65321f7939d Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Mon, 14 Mar 2011 21:00:13 -0400 Subject: gruel: fixing structure. Passes make check. --- gruel/src/swig/Makefile.am | 60 ++-- gruel/src/swig/Makefile.swig.gen | 54 +-- gruel/src/swig/pmt.i | 759 --------------------------------------- gruel/src/swig/pmt_swig.i | 755 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 804 insertions(+), 824 deletions(-) delete mode 100644 gruel/src/swig/pmt.i create mode 100644 gruel/src/swig/pmt_swig.i (limited to 'gruel/src/swig') diff --git a/gruel/src/swig/Makefile.am b/gruel/src/swig/Makefile.am index c6e9246e5..294045567 100644 --- a/gruel/src/swig/Makefile.am +++ b/gruel/src/swig/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2001,2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc. +# Copyright 2011 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,50 +22,34 @@ include $(top_srcdir)/Makefile.common include $(top_srcdir)/Makefile.swig -AM_CPPFLAGS = -I$(srcdir) $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) \ - $(WITH_INCLUDES) - -TOP_SWIG_IFILES = \ - pmt.i - - -# SWIG headers get installed in ${prefix}/include/gnuradio/swig -swiginclude_HEADERS = \ - pmt.i - -# SWIG headers that get installed in ${prefix}/include/gnuradio/swig/... -nobase_swiginclude_HEADERS = +TESTS = +AM_CPPFLAGS = \ + -I$(top_srcdir)/gruel/src/lib \ + $(STD_DEFINES_AND_INCLUDES) \ + $(PYTHON_CPPFLAGS) \ + $(WITH_INCLUDES) -# special install for this top-level Python script which includes all -# of the split Python libraries. -ourpythondir = $(pythondir)/gruel -ourpython_PYTHON = \ - pmt.py \ - __init__.py - -# ---------------------------------------------------------------- -# FIXME As of swig 1.3.31, this still seems to be required... -# gnuradio_swig_bug_workaround.h : gnuradio_core_runtime.py $(srcdir)/gen-swig-bug-fix -# $(PYTHON) $(srcdir)/gen-swig-bug-fix python/gnuradio_core_runtime.cc $@ - -EXTRA_DIST += gen-swig-bug-fix - -# C/C++ headers get installed in ${prefix}/include/gnuradio -#grinclude_HEADERS = gnuradio_swig_bug_workaround.h -grinclude_HEADERS = +TOP_SWIG_IFILES = \ + pmt_swig.i +############################## +# SWIG interface and library +TOP_SWIG_IFILES = \ + pmt_swig.i # Install so that they end up available as: -# import gnuradio.gr +# import gruel.pmt # This ends up at: -# ${prefix}/lib/python${python_version}/site-packages/gnuradio/gr -pmt_pythondir_category = gruel - -# additional libraries for linking with each SWIG-generated library -pmt_la_swig_libadd = $(GRUEL_LA) +# ${prefix}/lib/python${python_version}/site-packages/gruel/pmt +pmt_swig_pythondir_category = \ + gruel/pmt -SWIG_GUILE_FLAGS += -DIN_GNURADIO_CORE +# additional libraries for linking with the SWIG-generated library +pmt_swig_la_swig_libadd = \ + $(abs_top_builddir)/gruel/src/lib/pmt/libpmt.la +# additional SWIG files to be installed +pmt_swig_swiginclude_headers = diff --git a/gruel/src/swig/Makefile.swig.gen b/gruel/src/swig/Makefile.swig.gen index 9b4f62f77..c6a2fb956 100644 --- a/gruel/src/swig/Makefile.swig.gen +++ b/gruel/src/swig/Makefile.swig.gen @@ -33,24 +33,24 @@ ## this has to be done in the including Makefile.am -before- ## Makefile.swig is included. -pmt_pythondir_category ?= gruel/pmt -pmt_pylibdir_category ?= $(pmt_pythondir_category) -pmt_pythondir = $(pythondir)/$(pmt_pythondir_category) -pmt_pylibdir = $(pyexecdir)/$(pmt_pylibdir_category) +pmt_swig_pythondir_category ?= gruel/pmt_swig +pmt_swig_pylibdir_category ?= $(pmt_swig_pythondir_category) +pmt_swig_pythondir = $(pythondir)/$(pmt_swig_pythondir_category) +pmt_swig_pylibdir = $(pyexecdir)/$(pmt_swig_pylibdir_category) # The .so libraries for the guile modules get installed whereever guile # is installed, usually /usr/lib/guile/gnuradio/ # FIXME: determince whether these should be installed with gnuradio. -pmt_scmlibdir = $(libdir) +pmt_swig_scmlibdir = $(libdir) # The scm files for the guile modules get installed where ever guile # is installed, usually /usr/share/guile/site/gnuradio_core_runtime # FIXME: determince whether these should be installed with gnuradio. -pmt_scmdir = $(guiledir) +pmt_swig_scmdir = $(guiledir) ## SWIG headers are always installed into the same directory. -pmt_swigincludedir = $(swigincludedir) +pmt_swig_swigincludedir = $(swigincludedir) ## This is a template file for a "generated" Makefile addition (in ## this case, "Makefile.swig.gen"). By including the top-level @@ -75,40 +75,40 @@ MOSTLYCLEANFILES += $(DEPDIR)/*.S* ## Makefile.am by setting the variable value there, then including ## Makefile.swig . -pmt_swiginclude_HEADERS = \ - pmt.i \ - $(pmt_swiginclude_headers) +pmt_swig_swiginclude_HEADERS = \ + pmt_swig.i \ + $(pmt_swig_swiginclude_headers) if PYTHON -pmt_pylib_LTLIBRARIES = \ - _pmt.la +pmt_swig_pylib_LTLIBRARIES = \ + _pmt_swig.la -_pmt_la_SOURCES = \ - python/pmt.cc \ - $(pmt_la_swig_sources) +_pmt_swig_la_SOURCES = \ + python/pmt_swig.cc \ + $(pmt_swig_la_swig_sources) -pmt_python_PYTHON = \ - pmt.py \ - $(pmt_python) +pmt_swig_python_PYTHON = \ + pmt_swig.py \ + $(pmt_swig_python) -_pmt_la_LIBADD = \ +_pmt_swig_la_LIBADD = \ $(STD_SWIG_LA_LIB_ADD) \ - $(pmt_la_swig_libadd) + $(pmt_swig_la_swig_libadd) -_pmt_la_LDFLAGS = \ +_pmt_swig_la_LDFLAGS = \ $(STD_SWIG_LA_LD_FLAGS) \ - $(pmt_la_swig_ldflags) + $(pmt_swig_la_swig_ldflags) -_pmt_la_CXXFLAGS = \ +_pmt_swig_la_CXXFLAGS = \ $(STD_SWIG_CXX_FLAGS) \ -I$(top_builddir) \ - $(pmt_la_swig_cxxflags) + $(pmt_swig_la_swig_cxxflags) -python/pmt.cc: pmt.py -pmt.py: pmt.i +python/pmt_swig.cc: pmt_swig.py +pmt_swig.py: pmt_swig.i # Include the python dependencies for this file --include python/pmt.d +-include python/pmt_swig.d endif # end of if python diff --git a/gruel/src/swig/pmt.i b/gruel/src/swig/pmt.i deleted file mode 100644 index e5f9ba0a2..000000000 --- a/gruel/src/swig/pmt.i +++ /dev/null @@ -1,759 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2009,2010 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. - */ - -%module pmt -%include "std_string.i" -%include "stdint.i" -%{ -#include -#include -#include -#include -#include -#include -#include -#include -#include -using namespace pmt; -%} - - - -/* - * ------------------------------------------------------------------------ - * 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; -extern const pmt_t PMT_F; - -//! 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); - -/* - * ------------------------------------------------------------------------ - * uint64_t - * ------------------------------------------------------------------------ - */ - -//! Return true if \p x is an uint64 number, else false -bool pmt_is_uint64(pmt_t x); - -//! Return the pmt value that represents the uint64 \p x. -pmt_t pmt_from_uint64(uint64_t x); - -/*! - * \brief Convert pmt to uint64 if possible. - * - * When \p x represents an exact integer that fits in a uint64, - * return that uint64. Else raise an exception, either wrong_type - * when x is not an exact uint64, or out_of_range when it doesn't fit. - */ -uint64_t pmt_to_uint64(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. - * Otherwise, raise the wrong_type exception. - */ -std::complex 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); - -/* - * ------------------------------------------------------------------------ - * Tuples - * - * Store a fixed number of objects. Tuples are not modifiable, and thus - * are excellent for use as messages. Indexing is zero based. - * Access time to an element is O(1). - * ------------------------------------------------------------------------ - */ - -//! Return true if \p x is a tuple, othewise false. -bool pmt_is_tuple(pmt_t x); - -pmt_t pmt_make_tuple(); -pmt_t pmt_make_tuple(const pmt_t &e0); -pmt_t pmt_make_tuple(const pmt_t &e0, const pmt_t &e1); -pmt_t pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2); -pmt_t pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3); -pmt_t pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4); -pmt_t pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5); -pmt_t pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5, const pmt_t &e6); -pmt_t pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5, const pmt_t &e6, const pmt_t &e7); -pmt_t pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5, const pmt_t &e6, const pmt_t &e7, const pmt_t &e8); -pmt_t pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5, const pmt_t &e6, const pmt_t &e7, const pmt_t &e8, const pmt_t &e9); - -/*! - * If \p x is a vector or proper list, return a tuple containing the elements of x - */ -pmt_t pmt_to_tuple(const pmt_t &x); - -/*! - * Return the contents of position \p k of \p tuple. - * \p k must be a valid index of \p tuple. - */ -pmt_t pmt_tuple_ref(const pmt_t &tuple, size_t k); - -/* - * ------------------------------------------------------------------------ - * 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); - -/* - * ------------------------------------------------------------------------ - * Binary Large Objects (BLOBs) - * - * Handy for passing around uninterpreted chunks of memory. - * ------------------------------------------------------------------------ - */ - -//! Return true if \p x is a blob, othewise false. -bool pmt_is_blob(pmt_t x); - -/*! - * \brief Make a blob given a pointer and length in bytes - * - * \param buf is the pointer to data to use to create blob - * \param len is the size of the data in bytes. - * - * The data is copied into the blob. - */ -pmt_t pmt_make_blob(const void *buf, size_t len); - -//! Return a pointer to the blob's data -const void *pmt_blob_data(pmt_t blob); - -//! Return the blob's length in bytes -size_t pmt_blob_length(pmt_t blob); - -/*! - *
- * ------------------------------------------------------------------------
- *		       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
- *   c64  the C++ type complex
- * ------------------------------------------------------------------------
- * 
- */ - -//! 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 fill); -pmt_t pmt_make_c64vector(size_t k, std::complex 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_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 *data); -pmt_t pmt_init_c64vector(size_t k, const std::complex *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 pmt_c32vector_ref(pmt_t v, size_t k); -std::complex 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 x); -void pmt_c64vector_set(pmt_t v, size_t k, std::complex 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 *pmt_c32vector_elements(pmt_t v, size_t &len); //< len is in elements -const std::complex *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 *pmt_c32vector_writable_elements(pmt_t v, size_t &len); //< len is in elements -std::complex *pmt_c64vector_writable_elements(pmt_t v, size_t &len); //< len is in elements - -/* - * ------------------------------------------------------------------------ - * Dictionary (a.k.a associative array, hash, map) - * - * This is a functional data structure that is persistent. Updating a - * functional data structure does not destroy the existing version, but - * rather creates a new version that coexists with the old. - * ------------------------------------------------------------------------ - */ - -//! Return true if \p obj is a dictionary -bool pmt_is_dict(const pmt_t &obj); - -//! Make an empty dictionary -pmt_t pmt_make_dict(); - -//! Return a new dictionary with \p key associated with \p value. -pmt_t pmt_dict_add(const pmt_t &dict, const pmt_t &key, const pmt_t &value); - -//! Return a new dictionary with \p key removed. -pmt_t pmt_dict_delete(const pmt_t &dict, const pmt_t &key); - -//! Return true if \p key exists in \p dict -bool pmt_dict_has_key(const pmt_t &dict, const pmt_t &key); - -//! If \p key exists in \p dict, return associated value; otherwise return \p not_found. -pmt_t pmt_dict_ref(const pmt_t &dict, const pmt_t &key, const pmt_t ¬_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); - - -/* - * ------------------------------------------------------------------------ - * msg_accepter -- pmt representation of gruel::msg_accepter - * ------------------------------------------------------------------------ - */ -//! Return true if \p obj is a msg_accepter -bool pmt_is_msg_accepter(const pmt_t &obj); - -//! make a msg_accepter -pmt_t pmt_make_msg_accepter(boost::shared_ptr ma); - -//! Return underlying msg_accepter -boost::shared_ptr pmt_msg_accepter_ref(const pmt_t &obj); - -/* - * ------------------------------------------------------------------------ - * 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. - * - *
- * 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.
- * 
- */ -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); - - -/*! - * \brief Write pmt string representation to stdout. - */ -void pmt_print(pmt_t v); - - -/* - * ------------------------------------------------------------------------ - * 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 - -/*! - * \brief Provide a simple string generating interface to pmt's serialize function - */ -std::string pmt_serialize_str(pmt_t obj); - -/*! - * \brief Provide a simple string generating interface to pmt's deserialize function - */ -pmt_t pmt_deserialize_str(std::string str); - - - - diff --git a/gruel/src/swig/pmt_swig.i b/gruel/src/swig/pmt_swig.i new file mode 100644 index 000000000..54b50660d --- /dev/null +++ b/gruel/src/swig/pmt_swig.i @@ -0,0 +1,755 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011 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. + */ + +%module pmt +%include "std_string.i" +%include "stdint.i" +%{ +#include +#include +#include +#include +#include +#include +#include +#include +#include +using namespace pmt; +%} + + + +/* + * ------------------------------------------------------------------------ + * 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; +extern const pmt_t PMT_F; + +//! 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); + +/* + * ------------------------------------------------------------------------ + * uint64_t + * ------------------------------------------------------------------------ + */ + +//! Return true if \p x is an uint64 number, else false +bool pmt_is_uint64(pmt_t x); + +//! Return the pmt value that represents the uint64 \p x. +pmt_t pmt_from_uint64(uint64_t x); + +/*! + * \brief Convert pmt to uint64 if possible. + * + * When \p x represents an exact integer that fits in a uint64, + * return that uint64. Else raise an exception, either wrong_type + * when x is not an exact uint64, or out_of_range when it doesn't fit. + */ +uint64_t pmt_to_uint64(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. + * Otherwise, raise the wrong_type exception. + */ +std::complex 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); + +/* + * ------------------------------------------------------------------------ + * Tuples + * + * Store a fixed number of objects. Tuples are not modifiable, and thus + * are excellent for use as messages. Indexing is zero based. + * Access time to an element is O(1). + * ------------------------------------------------------------------------ + */ + +//! Return true if \p x is a tuple, othewise false. +bool pmt_is_tuple(pmt_t x); + +pmt_t pmt_make_tuple(); +pmt_t pmt_make_tuple(const pmt_t &e0); +pmt_t pmt_make_tuple(const pmt_t &e0, const pmt_t &e1); +pmt_t pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2); +pmt_t pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3); +pmt_t pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4); +pmt_t pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5); +pmt_t pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5, const pmt_t &e6); +pmt_t pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5, const pmt_t &e6, const pmt_t &e7); +pmt_t pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5, const pmt_t &e6, const pmt_t &e7, const pmt_t &e8); +pmt_t pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5, const pmt_t &e6, const pmt_t &e7, const pmt_t &e8, const pmt_t &e9); + +/*! + * If \p x is a vector or proper list, return a tuple containing the elements of x + */ +pmt_t pmt_to_tuple(const pmt_t &x); + +/*! + * Return the contents of position \p k of \p tuple. + * \p k must be a valid index of \p tuple. + */ +pmt_t pmt_tuple_ref(const pmt_t &tuple, size_t k); + +/* + * ------------------------------------------------------------------------ + * 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); + +/* + * ------------------------------------------------------------------------ + * Binary Large Objects (BLOBs) + * + * Handy for passing around uninterpreted chunks of memory. + * ------------------------------------------------------------------------ + */ + +//! Return true if \p x is a blob, othewise false. +bool pmt_is_blob(pmt_t x); + +/*! + * \brief Make a blob given a pointer and length in bytes + * + * \param buf is the pointer to data to use to create blob + * \param len is the size of the data in bytes. + * + * The data is copied into the blob. + */ +pmt_t pmt_make_blob(const void *buf, size_t len); + +//! Return a pointer to the blob's data +const void *pmt_blob_data(pmt_t blob); + +//! Return the blob's length in bytes +size_t pmt_blob_length(pmt_t blob); + +/*! + *
+ * ------------------------------------------------------------------------
+ *		       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
+ *   c64  the C++ type complex
+ * ------------------------------------------------------------------------
+ * 
+ */ + +//! 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 fill); +pmt_t pmt_make_c64vector(size_t k, std::complex 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_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 *data); +pmt_t pmt_init_c64vector(size_t k, const std::complex *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 pmt_c32vector_ref(pmt_t v, size_t k); +std::complex 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 x); +void pmt_c64vector_set(pmt_t v, size_t k, std::complex 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 *pmt_c32vector_elements(pmt_t v, size_t &len); //< len is in elements +const std::complex *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 *pmt_c32vector_writable_elements(pmt_t v, size_t &len); //< len is in elements +std::complex *pmt_c64vector_writable_elements(pmt_t v, size_t &len); //< len is in elements + +/* + * ------------------------------------------------------------------------ + * Dictionary (a.k.a associative array, hash, map) + * + * This is a functional data structure that is persistent. Updating a + * functional data structure does not destroy the existing version, but + * rather creates a new version that coexists with the old. + * ------------------------------------------------------------------------ + */ + +//! Return true if \p obj is a dictionary +bool pmt_is_dict(const pmt_t &obj); + +//! Make an empty dictionary +pmt_t pmt_make_dict(); + +//! Return a new dictionary with \p key associated with \p value. +pmt_t pmt_dict_add(const pmt_t &dict, const pmt_t &key, const pmt_t &value); + +//! Return a new dictionary with \p key removed. +pmt_t pmt_dict_delete(const pmt_t &dict, const pmt_t &key); + +//! Return true if \p key exists in \p dict +bool pmt_dict_has_key(const pmt_t &dict, const pmt_t &key); + +//! If \p key exists in \p dict, return associated value; otherwise return \p not_found. +pmt_t pmt_dict_ref(const pmt_t &dict, const pmt_t &key, const pmt_t ¬_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); + + +/* + * ------------------------------------------------------------------------ + * msg_accepter -- pmt representation of gruel::msg_accepter + * ------------------------------------------------------------------------ + */ +//! Return true if \p obj is a msg_accepter +bool pmt_is_msg_accepter(const pmt_t &obj); + +//! make a msg_accepter +pmt_t pmt_make_msg_accepter(boost::shared_ptr ma); + +//! Return underlying msg_accepter +boost::shared_ptr pmt_msg_accepter_ref(const pmt_t &obj); + +/* + * ------------------------------------------------------------------------ + * 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. + * + *
+ * 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.
+ * 
+ */ +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); + + +/*! + * \brief Write pmt string representation to stdout. + */ +void pmt_print(pmt_t v); + + +/* + * ------------------------------------------------------------------------ + * 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 + +/*! + * \brief Provide a simple string generating interface to pmt's serialize function + */ +std::string pmt_serialize_str(pmt_t obj); + +/*! + * \brief Provide a simple string generating interface to pmt's deserialize function + */ +pmt_t pmt_deserialize_str(std::string str); -- cgit From eb3a4fe528452415eb877b2b76e1006fc47bc655 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Tue, 15 Mar 2011 12:30:27 -0400 Subject: gruel: fixed swig interface file to dereference pmt_t. --- gruel/src/swig/pmt_swig.i | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gruel/src/swig') diff --git a/gruel/src/swig/pmt_swig.i b/gruel/src/swig/pmt_swig.i index 54b50660d..6435e03cc 100644 --- a/gruel/src/swig/pmt_swig.i +++ b/gruel/src/swig/pmt_swig.i @@ -36,7 +36,12 @@ using namespace pmt; %} +// Template intrusive_ptr for Swig to avoid dereferencing issues +class pmt_base; +%import +%template(swig_int_ptr) boost::intrusive_ptr; +typedef boost::intrusive_ptr pmt_t; /* * ------------------------------------------------------------------------ -- cgit From 1d70ed2bd928d52a383e688949cc7f747dd584fa Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Tue, 15 Mar 2011 21:04:24 -0700 Subject: gruel: added missing ignores --- gruel/src/swig/.gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 gruel/src/swig/.gitignore (limited to 'gruel/src/swig') diff --git a/gruel/src/swig/.gitignore b/gruel/src/swig/.gitignore new file mode 100644 index 000000000..b336cc7ce --- /dev/null +++ b/gruel/src/swig/.gitignore @@ -0,0 +1,2 @@ +/Makefile +/Makefile.in -- cgit From dd97932abfd35e60e9374f202aa6c69afcfb35ca Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sat, 26 Mar 2011 18:06:56 -0400 Subject: gruel: using a copy of swig's intrusive_ptr.i to support the PMT wrapping. --- gruel/src/swig/Makefile.am | 7 +-- gruel/src/swig/gr_intrusive_ptr.i | 102 ++++++++++++++++++++++++++++++++++++++ gruel/src/swig/pmt_swig.i | 3 +- 3 files changed, 106 insertions(+), 6 deletions(-) create mode 100644 gruel/src/swig/gr_intrusive_ptr.i (limited to 'gruel/src/swig') diff --git a/gruel/src/swig/Makefile.am b/gruel/src/swig/Makefile.am index 294045567..3261e47c2 100644 --- a/gruel/src/swig/Makefile.am +++ b/gruel/src/swig/Makefile.am @@ -30,9 +30,6 @@ AM_CPPFLAGS = \ $(PYTHON_CPPFLAGS) \ $(WITH_INCLUDES) -TOP_SWIG_IFILES = \ - pmt_swig.i - ############################## # SWIG interface and library TOP_SWIG_IFILES = \ @@ -50,6 +47,6 @@ pmt_swig_la_swig_libadd = \ $(abs_top_builddir)/gruel/src/lib/pmt/libpmt.la # additional SWIG files to be installed -pmt_swig_swiginclude_headers = - +pmt_swig_swiginclude_headers = \ + gr_intrusive_ptr.i diff --git a/gruel/src/swig/gr_intrusive_ptr.i b/gruel/src/swig/gr_intrusive_ptr.i new file mode 100644 index 000000000..eef5bc84d --- /dev/null +++ b/gruel/src/swig/gr_intrusive_ptr.i @@ -0,0 +1,102 @@ +// This file was borrowed from the SWIG project to allow use to +// wrap PMTs that use intrusive pointers. This is only necessary +// to support backwards compatability with older distributions of +// Linux that do not natively support a new enough version of SWIG. +// We do this to prevent having to update our dependency on a new +// SWIG. Eventually, the need for this should go away. + +// Allow for different namespaces for shared_ptr / intrusive_ptr - they could be boost or std or std::tr1 +// For example for std::tr1, use: +// #define SWIG_SHARED_PTR_NAMESPACE std +// #define SWIG_SHARED_PTR_SUBNAMESPACE tr1 +// #define SWIG_INTRUSIVE_PTR_NAMESPACE boost +// #define SWIG_INTRUSIVE_PTR_SUBNAMESPACE + +#if !defined(SWIG_INTRUSIVE_PTR_NAMESPACE) +# define SWIG_INTRUSIVE_PTR_NAMESPACE boost +#endif + +#if defined(SWIG_INTRUSIVE_PTR_SUBNAMESPACE) +# define SWIG_INTRUSIVE_PTR_QNAMESPACE SWIG_INTRUSIVE_PTR_NAMESPACE::SWIG_INTRUSIVE_PTR_SUBNAMESPACE +#else +# define SWIG_INTRUSIVE_PTR_QNAMESPACE SWIG_INTRUSIVE_PTR_NAMESPACE +#endif + +namespace SWIG_INTRUSIVE_PTR_NAMESPACE { +#if defined(SWIG_INTRUSIVE_PTR_SUBNAMESPACE) + namespace SWIG_INTRUSIVE_PTR_SUBNAMESPACE { +#endif + template class intrusive_ptr { + }; +#if defined(SWIG_INTRUSIVE_PTR_SUBNAMESPACE) + } +#endif +} + +%fragment("SWIG_intrusive_deleter", "header") { +template struct SWIG_intrusive_deleter { + void operator()(T *p) { + if (p) + intrusive_ptr_release(p); + } +}; +} + +%fragment("SWIG_null_deleter", "header") { +struct SWIG_null_deleter { + void operator() (void const *) const { + } +}; +%#define SWIG_NO_NULL_DELETER_0 , SWIG_null_deleter() +%#define SWIG_NO_NULL_DELETER_1 +} + +// Main user macro for defining intrusive_ptr typemaps for both const and non-const pointer types +// For plain classes, do not use for derived classes +%define SWIG_INTRUSIVE_PTR(PROXYCLASS, TYPE...) +SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, , TYPE) +SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, const, TYPE) +%enddef + +// Main user macro for defining intrusive_ptr typemaps for both const and non-const pointer types +// For derived classes +%define SWIG_INTRUSIVE_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE...) +SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, , TYPE) +SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, const, TYPE) +%types(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > = SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >) %{ + *newmemory = SWIG_CAST_NEW_MEMORY; + return (void *) new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >(*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *)$from); + %} +%extend TYPE { + static SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE > SWIGSharedPtrUpcast(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast) { + return swigSharedPtrUpcast; + } +} +%enddef + +// Extra user macro for including classes in intrusive_ptr typemaps for both const and non-const pointer types +// This caters for classes which cannot be wrapped by intrusive_ptrs but are still part of the class hierarchy +// For plain classes, do not use for derived classes +%define SWIG_INTRUSIVE_PTR_NO_WRAP(PROXYCLASS, TYPE...) +SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, , TYPE) +SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, const, TYPE) +%enddef + +// Extra user macro for including classes in intrusive_ptr typemaps for both const and non-const pointer types +// This caters for classes which cannot be wrapped by intrusive_ptrs but are still part of the class hierarchy +// For derived classes +%define SWIG_INTRUSIVE_PTR_DERIVED_NO_WRAP(PROXYCLASS, BASECLASSTYPE, TYPE...) +SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, , TYPE) +SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, const, TYPE) +%types(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > = SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >) %{ + *newmemory = SWIG_CAST_NEW_MEMORY; + return (void *) new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >(*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *)$from); +%} +%extend TYPE { + static SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE > SWIGSharedPtrUpcast(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast) { + return swigSharedPtrUpcast; + } +} +%enddef + + diff --git a/gruel/src/swig/pmt_swig.i b/gruel/src/swig/pmt_swig.i index 6435e03cc..3b0eb45c8 100644 --- a/gruel/src/swig/pmt_swig.i +++ b/gruel/src/swig/pmt_swig.i @@ -38,7 +38,8 @@ using namespace pmt; // Template intrusive_ptr for Swig to avoid dereferencing issues class pmt_base; -%import +//%import +%import %template(swig_int_ptr) boost::intrusive_ptr; typedef boost::intrusive_ptr pmt_t; -- cgit From bdd0bd405c2ea645395917c1abb91c964210c4d9 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 8 May 2011 17:04:32 +0100 Subject: build: committing updated Makefile.swig.gen files. --- gruel/src/swig/Makefile.swig.gen | 42 ++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) (limited to 'gruel/src/swig') diff --git a/gruel/src/swig/Makefile.swig.gen b/gruel/src/swig/Makefile.swig.gen index c6a2fb956..97aff8104 100644 --- a/gruel/src/swig/Makefile.swig.gen +++ b/gruel/src/swig/Makefile.swig.gen @@ -20,20 +20,20 @@ # Boston, MA 02110-1301, USA. # -# Makefile.swig.gen for gnuradio_core_runtime.i +# Makefile.swig.gen for pmt_swig.i ## Default install locations for these files: ## ## Default location for the Python directory is: -## ${prefix}/lib/python${python_version}/site-packages/[category]/gnuradio_core_runtime +## ${prefix}/lib/python${python_version}/site-packages/[category]/pmt_swig ## Default location for the Python exec directory is: -## ${exec_prefix}/lib/python${python_version}/site-packages/[category]/gnuradio_core_runtime +## ${exec_prefix}/lib/python${python_version}/site-packages/[category]/pmt_swig ## ## The following can be overloaded to change the install location, but ## this has to be done in the including Makefile.am -before- ## Makefile.swig is included. -pmt_swig_pythondir_category ?= gruel/pmt_swig +pmt_swig_pythondir_category ?= gnuradio/pmt_swig pmt_swig_pylibdir_category ?= $(pmt_swig_pythondir_category) pmt_swig_pythondir = $(pythondir)/$(pmt_swig_pythondir_category) pmt_swig_pylibdir = $(pyexecdir)/$(pmt_swig_pylibdir_category) @@ -44,7 +44,7 @@ pmt_swig_pylibdir = $(pyexecdir)/$(pmt_swig_pylibdir_category) pmt_swig_scmlibdir = $(libdir) # The scm files for the guile modules get installed where ever guile -# is installed, usually /usr/share/guile/site/gnuradio_core_runtime +# is installed, usually /usr/share/guile/site/pmt_swig # FIXME: determince whether these should be installed with gnuradio. pmt_swig_scmdir = $(guiledir) @@ -105,11 +105,41 @@ _pmt_swig_la_CXXFLAGS = \ $(pmt_swig_la_swig_cxxflags) python/pmt_swig.cc: pmt_swig.py -pmt_swig.py: pmt_swig.i +pmt_swig.py: pmt_swig.i # Include the python dependencies for this file -include python/pmt_swig.d endif # end of if python +if GUILE + +pmt_swig_scmlib_LTLIBRARIES = \ + libguile-gnuradio-pmt_swig.la +libguile_gnuradio_pmt_swig_la_SOURCES = \ + guile/pmt_swig.cc \ + $(pmt_swig_la_swig_sources) +nobase_pmt_swig_scm_DATA = \ + gnuradio/pmt_swig.scm \ + gnuradio/pmt_swig-primitive.scm +libguile_gnuradio_pmt_swig_la_LIBADD = \ + $(STD_SWIG_LA_LIB_ADD) \ + $(pmt_swig_la_swig_libadd) +libguile_gnuradio_pmt_swig_la_LDFLAGS = \ + $(STD_SWIG_LA_LD_FLAGS) \ + $(pmt_swig_la_swig_ldflags) +libguile_gnuradio_pmt_swig_la_CXXFLAGS = \ + $(STD_SWIG_CXX_FLAGS) \ + -I$(top_builddir) \ + $(pmt_swig_la_swig_cxxflags) + +guile/pmt_swig.cc: gnuradio/pmt_swig.scm +gnuradio/pmt_swig.scm: pmt_swig.i +gnuradio/pmt_swig-primitive.scm: gnuradio/pmt_swig.scm + +# Include the guile dependencies for this file +-include guile/pmt_swig.d + +endif # end of GUILE + -- cgit From f6fedf278c08fb0083808c6baf42ba2972a43ef1 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 3 Jul 2011 11:35:55 -0700 Subject: gr: added to the .gitignores to various components for in-tree builds --- gruel/src/swig/.gitignore | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gruel/src/swig') diff --git a/gruel/src/swig/.gitignore b/gruel/src/swig/.gitignore index b336cc7ce..f99fdb19b 100644 --- a/gruel/src/swig/.gitignore +++ b/gruel/src/swig/.gitignore @@ -1,2 +1,4 @@ /Makefile /Makefile.in +/python +/pmt_swig.py -- cgit From accb9f2fe8fd8f6a1e114adac5b15304b0e0012d Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 20 Jul 2011 19:04:32 -0700 Subject: gr: squashed cmakelists.txt into one commit --- gruel/src/swig/CMakeLists.txt | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 gruel/src/swig/CMakeLists.txt (limited to 'gruel/src/swig') diff --git a/gruel/src/swig/CMakeLists.txt b/gruel/src/swig/CMakeLists.txt new file mode 100644 index 000000000..05f875451 --- /dev/null +++ b/gruel/src/swig/CMakeLists.txt @@ -0,0 +1,41 @@ +# Copyright 2011 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. + +######################################################################## +# Setup swig generation +######################################################################## +INCLUDE(GrPython) +INCLUDE(GrSwig) + +SET(GR_SWIG_INCLUDE_DIRS ${GRUEL_INCLUDE_DIRS}) +SET(GR_SWIG_LIBRARIES gruel) + +GR_SWIG_MAKE(pmt_swig pmt_swig.i) + +GR_SWIG_INSTALL( + TARGETS pmt_swig + DESTINATION ${GR_PYTHON_DIR}/gruel/pmt + COMPONENT "gruel_python" +) + +INSTALL( + FILES gr_intrusive_ptr.i + DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig + COMPONENT "gruel_swig" +) -- cgit From 4aa4411f2a3f184760ff5f534eec015f557f80c9 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 24 Sep 2011 20:38:19 -0700 Subject: gruel: added missing pmt swig install rule --- gruel/src/swig/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gruel/src/swig') diff --git a/gruel/src/swig/CMakeLists.txt b/gruel/src/swig/CMakeLists.txt index 05f875451..5b256a793 100644 --- a/gruel/src/swig/CMakeLists.txt +++ b/gruel/src/swig/CMakeLists.txt @@ -35,7 +35,7 @@ GR_SWIG_INSTALL( ) INSTALL( - FILES gr_intrusive_ptr.i + FILES gr_intrusive_ptr.i pmt_swig.i DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig COMPONENT "gruel_swig" ) -- cgit From 5b1c7b73d0cb2dbbf944c3be670a7f2d74547e0f Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 26 Sep 2011 21:22:13 -0700 Subject: swig: language independent exception handler --- gruel/src/swig/pmt_swig.i | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'gruel/src/swig') diff --git a/gruel/src/swig/pmt_swig.i b/gruel/src/swig/pmt_swig.i index 3b0eb45c8..34c7d4b7c 100644 --- a/gruel/src/swig/pmt_swig.i +++ b/gruel/src/swig/pmt_swig.i @@ -36,6 +36,24 @@ using namespace pmt; %} +//////////////////////////////////////////////////////////////////////// +// Language independent exception handler +//////////////////////////////////////////////////////////////////////// +%include exception.i + +%exception { + try { + $action + } + catch(std::exception &e) { + SWIG_exception(SWIG_RuntimeError, e.what()); + } + catch(...) { + SWIG_exception(SWIG_RuntimeError, "Unknown exception"); + } + +} + // Template intrusive_ptr for Swig to avoid dereferencing issues class pmt_base; //%import -- cgit From 71c0f14a46f85027b95f2f5f6d3d219cc9e3783e Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 8 Oct 2011 17:11:12 -0700 Subject: gr: the CMakeLists.txt took a chill pill --- gruel/src/swig/CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'gruel/src/swig') diff --git a/gruel/src/swig/CMakeLists.txt b/gruel/src/swig/CMakeLists.txt index 5b256a793..c2769ae27 100644 --- a/gruel/src/swig/CMakeLists.txt +++ b/gruel/src/swig/CMakeLists.txt @@ -20,11 +20,11 @@ ######################################################################## # Setup swig generation ######################################################################## -INCLUDE(GrPython) -INCLUDE(GrSwig) +include(GrPython) +include(GrSwig) -SET(GR_SWIG_INCLUDE_DIRS ${GRUEL_INCLUDE_DIRS}) -SET(GR_SWIG_LIBRARIES gruel) +set(GR_SWIG_INCLUDE_DIRS ${GRUEL_INCLUDE_DIRS}) +set(GR_SWIG_LIBRARIES gruel) GR_SWIG_MAKE(pmt_swig pmt_swig.i) @@ -34,7 +34,7 @@ GR_SWIG_INSTALL( COMPONENT "gruel_python" ) -INSTALL( +install( FILES gr_intrusive_ptr.i pmt_swig.i DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig COMPONENT "gruel_swig" -- cgit From 7b1c5abe410470d25e49d0dadd265c430aaca1ec Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 20 Oct 2011 22:36:24 -0700 Subject: pmt: fix #446 by putting pmt swig into namespace --- gruel/src/swig/pmt_swig.i | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'gruel/src/swig') diff --git a/gruel/src/swig/pmt_swig.i b/gruel/src/swig/pmt_swig.i index 34c7d4b7c..276d232a4 100644 --- a/gruel/src/swig/pmt_swig.i +++ b/gruel/src/swig/pmt_swig.i @@ -20,7 +20,6 @@ * Boston, MA 02110-1301, USA. */ -%module pmt %include "std_string.i" %include "stdint.i" %{ @@ -33,7 +32,6 @@ #include #include #include -using namespace pmt; %} //////////////////////////////////////////////////////////////////////// @@ -55,10 +53,14 @@ using namespace pmt; } // Template intrusive_ptr for Swig to avoid dereferencing issues -class pmt_base; +namespace pmt{ + class pmt_base; +} //%import %import -%template(swig_int_ptr) boost::intrusive_ptr; +%template(swig_int_ptr) boost::intrusive_ptr; + +namespace pmt{ typedef boost::intrusive_ptr pmt_t; @@ -777,3 +779,5 @@ std::string pmt_serialize_str(pmt_t obj); * \brief Provide a simple string generating interface to pmt's deserialize function */ pmt_t pmt_deserialize_str(std::string str); + +} //namespace pmt -- cgit From 2f48e2a60e76072e5436dde860cd602c3882ce5c Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sat, 3 Dec 2011 12:13:23 -0500 Subject: docs: adding Python docstrings to gruel/pmt in cmake; dummy file make for autotools to build. --- gruel/src/swig/CMakeLists.txt | 3 +++ gruel/src/swig/Makefile.am | 12 ++++++++++++ gruel/src/swig/pmt_swig.i | 11 +++++++++++ 3 files changed, 26 insertions(+) (limited to 'gruel/src/swig') diff --git a/gruel/src/swig/CMakeLists.txt b/gruel/src/swig/CMakeLists.txt index c2769ae27..c9651eb3f 100644 --- a/gruel/src/swig/CMakeLists.txt +++ b/gruel/src/swig/CMakeLists.txt @@ -26,6 +26,9 @@ include(GrSwig) set(GR_SWIG_INCLUDE_DIRS ${GRUEL_INCLUDE_DIRS}) set(GR_SWIG_LIBRARIES gruel) +set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/pmt_swig_doc.i) +set(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../include/gruel ${CMAKE_CURRENT_BINARY_DIR}/../include/gruel) + GR_SWIG_MAKE(pmt_swig pmt_swig.i) GR_SWIG_INSTALL( diff --git a/gruel/src/swig/Makefile.am b/gruel/src/swig/Makefile.am index 3261e47c2..bf43e01fa 100644 --- a/gruel/src/swig/Makefile.am +++ b/gruel/src/swig/Makefile.am @@ -35,6 +35,18 @@ AM_CPPFLAGS = \ TOP_SWIG_IFILES = \ pmt_swig.i +TOP_SWIG_DOC_IFILES = \ + pmt_swig_doc.i + +BUILT_SOURCES += \ + $(TOP_SWIG_DOC_IFILES) + +$(TOP_SWIG_DOC_IFILES): + `echo "" > $@` + +install-data-local: + cp -p $(TOP_SWIG_DOC_IFILES) $(swigincludedir) + # Install so that they end up available as: # import gruel.pmt # This ends up at: diff --git a/gruel/src/swig/pmt_swig.i b/gruel/src/swig/pmt_swig.i index 276d232a4..afc80433a 100644 --- a/gruel/src/swig/pmt_swig.i +++ b/gruel/src/swig/pmt_swig.i @@ -34,6 +34,9 @@ #include %} +//load generated python docstrings +%include "pmt_swig_doc.i" + //////////////////////////////////////////////////////////////////////// // Language independent exception handler //////////////////////////////////////////////////////////////////////// @@ -52,6 +55,14 @@ } +/*! + * \brief this is a test function. + * + * this is only a test. + */ +bool test_pmt_is_symbol(void); + + // Template intrusive_ptr for Swig to avoid dereferencing issues namespace pmt{ class pmt_base; -- cgit From f536b394f20ef88b426bf4bb6e9b69f6efb9847e Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 4 Dec 2011 11:12:51 -0500 Subject: docs: install gruel swig docs and other swig files into include/gruel/swig instead of include/gnuradio/swig. --- gruel/src/swig/CMakeLists.txt | 1 + gruel/src/swig/Makefile.am | 10 ++++++---- gruel/src/swig/Makefile.swig.gen | 2 +- gruel/src/swig/pmt_swig.i | 8 -------- 4 files changed, 8 insertions(+), 13 deletions(-) (limited to 'gruel/src/swig') diff --git a/gruel/src/swig/CMakeLists.txt b/gruel/src/swig/CMakeLists.txt index c9651eb3f..7d69ee549 100644 --- a/gruel/src/swig/CMakeLists.txt +++ b/gruel/src/swig/CMakeLists.txt @@ -39,6 +39,7 @@ GR_SWIG_INSTALL( install( FILES gr_intrusive_ptr.i pmt_swig.i + ${CMAKE_CURRENT_BINARY_DIR}/pmt_swig_doc.i DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig COMPONENT "gruel_swig" ) diff --git a/gruel/src/swig/Makefile.am b/gruel/src/swig/Makefile.am index bf43e01fa..9953d5566 100644 --- a/gruel/src/swig/Makefile.am +++ b/gruel/src/swig/Makefile.am @@ -33,6 +33,7 @@ AM_CPPFLAGS = \ ############################## # SWIG interface and library TOP_SWIG_IFILES = \ + pmt_swig_doc.i \ pmt_swig.i TOP_SWIG_DOC_IFILES = \ @@ -41,12 +42,12 @@ TOP_SWIG_DOC_IFILES = \ BUILT_SOURCES += \ $(TOP_SWIG_DOC_IFILES) +EXTRA_DIST += \ + $(TOP_SWIG_DOC_IFILES) + $(TOP_SWIG_DOC_IFILES): `echo "" > $@` -install-data-local: - cp -p $(TOP_SWIG_DOC_IFILES) $(swigincludedir) - # Install so that they end up available as: # import gruel.pmt # This ends up at: @@ -60,5 +61,6 @@ pmt_swig_la_swig_libadd = \ # additional SWIG files to be installed pmt_swig_swiginclude_headers = \ - gr_intrusive_ptr.i + gr_intrusive_ptr.i \ + $(TOP_SWIG_DOC_IFILES) diff --git a/gruel/src/swig/Makefile.swig.gen b/gruel/src/swig/Makefile.swig.gen index 97aff8104..0abba0299 100644 --- a/gruel/src/swig/Makefile.swig.gen +++ b/gruel/src/swig/Makefile.swig.gen @@ -50,7 +50,7 @@ pmt_swig_scmdir = $(guiledir) ## SWIG headers are always installed into the same directory. -pmt_swig_swigincludedir = $(swigincludedir) +pmt_swig_swigincludedir = $(gruelswigincludedir) ## This is a template file for a "generated" Makefile addition (in ## this case, "Makefile.swig.gen"). By including the top-level diff --git a/gruel/src/swig/pmt_swig.i b/gruel/src/swig/pmt_swig.i index afc80433a..0c937edfc 100644 --- a/gruel/src/swig/pmt_swig.i +++ b/gruel/src/swig/pmt_swig.i @@ -55,14 +55,6 @@ } -/*! - * \brief this is a test function. - * - * this is only a test. - */ -bool test_pmt_is_symbol(void); - - // Template intrusive_ptr for Swig to avoid dereferencing issues namespace pmt{ class pmt_base; -- cgit From 00420d32081d8252bb37142b2be19a8a7c4dc4c4 Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Thu, 8 Dec 2011 13:48:48 -0800 Subject: Removed autotools, gr-waveform, some cleanup Nick Foster owes Nick Corgan a six-pack of beer! --- gruel/src/swig/.gitignore | 4 --- gruel/src/swig/Makefile.am | 66 ---------------------------------------------- 2 files changed, 70 deletions(-) delete mode 100644 gruel/src/swig/.gitignore delete mode 100644 gruel/src/swig/Makefile.am (limited to 'gruel/src/swig') diff --git a/gruel/src/swig/.gitignore b/gruel/src/swig/.gitignore deleted file mode 100644 index f99fdb19b..000000000 --- a/gruel/src/swig/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -/Makefile -/Makefile.in -/python -/pmt_swig.py diff --git a/gruel/src/swig/Makefile.am b/gruel/src/swig/Makefile.am deleted file mode 100644 index 9953d5566..000000000 --- a/gruel/src/swig/Makefile.am +++ /dev/null @@ -1,66 +0,0 @@ -# -# Copyright 2011 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 -include $(top_srcdir)/Makefile.swig - -TESTS = - -AM_CPPFLAGS = \ - -I$(top_srcdir)/gruel/src/lib \ - $(STD_DEFINES_AND_INCLUDES) \ - $(PYTHON_CPPFLAGS) \ - $(WITH_INCLUDES) - -############################## -# SWIG interface and library -TOP_SWIG_IFILES = \ - pmt_swig_doc.i \ - pmt_swig.i - -TOP_SWIG_DOC_IFILES = \ - pmt_swig_doc.i - -BUILT_SOURCES += \ - $(TOP_SWIG_DOC_IFILES) - -EXTRA_DIST += \ - $(TOP_SWIG_DOC_IFILES) - -$(TOP_SWIG_DOC_IFILES): - `echo "" > $@` - -# Install so that they end up available as: -# import gruel.pmt -# This ends up at: -# ${prefix}/lib/python${python_version}/site-packages/gruel/pmt -pmt_swig_pythondir_category = \ - gruel/pmt - -# additional libraries for linking with the SWIG-generated library -pmt_swig_la_swig_libadd = \ - $(abs_top_builddir)/gruel/src/lib/pmt/libpmt.la - -# additional SWIG files to be installed -pmt_swig_swiginclude_headers = \ - gr_intrusive_ptr.i \ - $(TOP_SWIG_DOC_IFILES) - -- cgit From f9a07338b9c7c0af19d64d24c47eaa9f7fe1ba38 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 16 Mar 2012 13:09:23 -0700 Subject: gruel: created common swig include file This work taken from gruel_work_squashed Common swig file includes: * Language independent exception handler * Wrapper for python calls that may block Benefits: * More common swig code, less copy pasta * Wrapper for blocking python calls handles the case where the call throws, python is not left in a bad state --- gruel/src/swig/CMakeLists.txt | 2 +- gruel/src/swig/Makefile.am | 1 + gruel/src/swig/gruel_common.i | 66 +++++++++++++++++++++++++++++++++++++++++++ gruel/src/swig/pmt_swig.i | 17 ++--------- 4 files changed, 70 insertions(+), 16 deletions(-) create mode 100644 gruel/src/swig/gruel_common.i (limited to 'gruel/src/swig') diff --git a/gruel/src/swig/CMakeLists.txt b/gruel/src/swig/CMakeLists.txt index 7d69ee549..6f636fc3f 100644 --- a/gruel/src/swig/CMakeLists.txt +++ b/gruel/src/swig/CMakeLists.txt @@ -38,7 +38,7 @@ GR_SWIG_INSTALL( ) install( - FILES gr_intrusive_ptr.i pmt_swig.i + FILES gr_intrusive_ptr.i pmt_swig.i gruel_common.i ${CMAKE_CURRENT_BINARY_DIR}/pmt_swig_doc.i DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig COMPONENT "gruel_swig" diff --git a/gruel/src/swig/Makefile.am b/gruel/src/swig/Makefile.am index 9953d5566..ce0a32513 100644 --- a/gruel/src/swig/Makefile.am +++ b/gruel/src/swig/Makefile.am @@ -61,6 +61,7 @@ pmt_swig_la_swig_libadd = \ # additional SWIG files to be installed pmt_swig_swiginclude_headers = \ + gruel_common.i \ gr_intrusive_ptr.i \ $(TOP_SWIG_DOC_IFILES) diff --git a/gruel/src/swig/gruel_common.i b/gruel/src/swig/gruel_common.i new file mode 100644 index 000000000..e4261cbfa --- /dev/null +++ b/gruel/src/swig/gruel_common.i @@ -0,0 +1,66 @@ +/* + * Copyright 2011 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 GRUEL_COMMON_I +#define GRUEL_COMMON_I + +//////////////////////////////////////////////////////////////////////// +// Language independent exception handler +//////////////////////////////////////////////////////////////////////// +%include exception.i + +%exception { + try { + $action + } + catch(std::exception &e) { + SWIG_exception(SWIG_RuntimeError, e.what()); + } + catch(...) { + SWIG_exception(SWIG_RuntimeError, "Unknown exception"); + } + +} + +//////////////////////////////////////////////////////////////////////// +// Wrapper for python calls that may block +//////////////////////////////////////////////////////////////////////// + +/*! + * Use GR_PYTHON_BLOCKING_CODE when calling code that blocks. + * + * The try/catch is to save us from boost::thread::interrupt: + * If a thread from the scheduler (or any other boost thread) + * is blocking the routine and throws an interrupt exception. + */ +%{ + +#define GR_PYTHON_BLOCKING_CODE(code) { \ + PyThreadState *_save; \ + _save = PyEval_SaveThread(); \ + try{code} \ + catch(...){PyEval_RestoreThread(_save); throw;} \ + PyEval_RestoreThread(_save); \ +} + +%} + +#endif /*GRUEL_COMMON_I*/ diff --git a/gruel/src/swig/pmt_swig.i b/gruel/src/swig/pmt_swig.i index 0c937edfc..954501863 100644 --- a/gruel/src/swig/pmt_swig.i +++ b/gruel/src/swig/pmt_swig.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2011 Free Software Foundation, Inc. + * Copyright 2011-2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -34,26 +34,13 @@ #include %} +%include "gruel_common.i" //load generated python docstrings %include "pmt_swig_doc.i" //////////////////////////////////////////////////////////////////////// // Language independent exception handler //////////////////////////////////////////////////////////////////////// -%include exception.i - -%exception { - try { - $action - } - catch(std::exception &e) { - SWIG_exception(SWIG_RuntimeError, e.what()); - } - catch(...) { - SWIG_exception(SWIG_RuntimeError, "Unknown exception"); - } - -} // Template intrusive_ptr for Swig to avoid dereferencing issues namespace pmt{ -- cgit From 2bf64459036916258dcf3269cec47904fdeba8f6 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 1 Apr 2012 16:13:42 -0400 Subject: Removes all references to guile and scheme, which are no longer needed. The remaining pmt_serial_tags.scm is parsed by Python already. Future modifications could change this format to not confuse the point. --- gruel/src/swig/Makefile.swig.gen | 145 --------------------------------------- 1 file changed, 145 deletions(-) delete mode 100644 gruel/src/swig/Makefile.swig.gen (limited to 'gruel/src/swig') diff --git a/gruel/src/swig/Makefile.swig.gen b/gruel/src/swig/Makefile.swig.gen deleted file mode 100644 index 0abba0299..000000000 --- a/gruel/src/swig/Makefile.swig.gen +++ /dev/null @@ -1,145 +0,0 @@ -# -*- Makefile -*- -# -# Copyright 2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -# Makefile.swig.gen for pmt_swig.i - -## Default install locations for these files: -## -## Default location for the Python directory is: -## ${prefix}/lib/python${python_version}/site-packages/[category]/pmt_swig -## Default location for the Python exec directory is: -## ${exec_prefix}/lib/python${python_version}/site-packages/[category]/pmt_swig -## -## The following can be overloaded to change the install location, but -## this has to be done in the including Makefile.am -before- -## Makefile.swig is included. - -pmt_swig_pythondir_category ?= gnuradio/pmt_swig -pmt_swig_pylibdir_category ?= $(pmt_swig_pythondir_category) -pmt_swig_pythondir = $(pythondir)/$(pmt_swig_pythondir_category) -pmt_swig_pylibdir = $(pyexecdir)/$(pmt_swig_pylibdir_category) - -# The .so libraries for the guile modules get installed whereever guile -# is installed, usually /usr/lib/guile/gnuradio/ -# FIXME: determince whether these should be installed with gnuradio. -pmt_swig_scmlibdir = $(libdir) - -# The scm files for the guile modules get installed where ever guile -# is installed, usually /usr/share/guile/site/pmt_swig -# FIXME: determince whether these should be installed with gnuradio. -pmt_swig_scmdir = $(guiledir) - -## SWIG headers are always installed into the same directory. - -pmt_swig_swigincludedir = $(gruelswigincludedir) - -## This is a template file for a "generated" Makefile addition (in -## this case, "Makefile.swig.gen"). By including the top-level -## Makefile.swig, this file will be used to generate the SWIG -## dependencies. Assign the variable TOP_SWIG_FILES to be the list of -## SWIG .i files to generated wrappings for; there can be more than 1 -## so long as the names are unique (no sorting is done on the -## TOP_SWIG_FILES list). This file explicitly assumes that a SWIG .i -## file will generate .cc, .py, and possibly .h files -- meaning that -## all of these files will have the same base name (that provided for -## the SWIG .i file). -## -## This code is setup to ensure parallel MAKE ("-j" or "-jN") does the -## right thing. For more info, see < -## http://sources.redhat.com/automake/automake.html#Multiple-Outputs > - -## Other cleaned files: dependency files generated by SWIG or this Makefile - -MOSTLYCLEANFILES += $(DEPDIR)/*.S* - -## Various SWIG variables. These can be overloaded in the including -## Makefile.am by setting the variable value there, then including -## Makefile.swig . - -pmt_swig_swiginclude_HEADERS = \ - pmt_swig.i \ - $(pmt_swig_swiginclude_headers) - -if PYTHON -pmt_swig_pylib_LTLIBRARIES = \ - _pmt_swig.la - -_pmt_swig_la_SOURCES = \ - python/pmt_swig.cc \ - $(pmt_swig_la_swig_sources) - -pmt_swig_python_PYTHON = \ - pmt_swig.py \ - $(pmt_swig_python) - -_pmt_swig_la_LIBADD = \ - $(STD_SWIG_LA_LIB_ADD) \ - $(pmt_swig_la_swig_libadd) - -_pmt_swig_la_LDFLAGS = \ - $(STD_SWIG_LA_LD_FLAGS) \ - $(pmt_swig_la_swig_ldflags) - -_pmt_swig_la_CXXFLAGS = \ - $(STD_SWIG_CXX_FLAGS) \ - -I$(top_builddir) \ - $(pmt_swig_la_swig_cxxflags) - -python/pmt_swig.cc: pmt_swig.py -pmt_swig.py: pmt_swig.i - -# Include the python dependencies for this file --include python/pmt_swig.d - -endif # end of if python - -if GUILE - -pmt_swig_scmlib_LTLIBRARIES = \ - libguile-gnuradio-pmt_swig.la -libguile_gnuradio_pmt_swig_la_SOURCES = \ - guile/pmt_swig.cc \ - $(pmt_swig_la_swig_sources) -nobase_pmt_swig_scm_DATA = \ - gnuradio/pmt_swig.scm \ - gnuradio/pmt_swig-primitive.scm -libguile_gnuradio_pmt_swig_la_LIBADD = \ - $(STD_SWIG_LA_LIB_ADD) \ - $(pmt_swig_la_swig_libadd) -libguile_gnuradio_pmt_swig_la_LDFLAGS = \ - $(STD_SWIG_LA_LD_FLAGS) \ - $(pmt_swig_la_swig_ldflags) -libguile_gnuradio_pmt_swig_la_CXXFLAGS = \ - $(STD_SWIG_CXX_FLAGS) \ - -I$(top_builddir) \ - $(pmt_swig_la_swig_cxxflags) - -guile/pmt_swig.cc: gnuradio/pmt_swig.scm -gnuradio/pmt_swig.scm: pmt_swig.i -gnuradio/pmt_swig-primitive.scm: gnuradio/pmt_swig.scm - -# Include the guile dependencies for this file --include guile/pmt_swig.d - -endif # end of GUILE - - -- cgit From aaa98c095a85724a8782a28717162c1d30d865c2 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sat, 7 Apr 2012 20:03:25 -0400 Subject: gruel and howto: install gruel .i files in gruel dest. Howto will use that dir during build. howto under both cmake and autotools can be built off cmake or autotools gnuradio builds. --- gruel/src/swig/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gruel/src/swig') diff --git a/gruel/src/swig/CMakeLists.txt b/gruel/src/swig/CMakeLists.txt index 7d69ee549..8b4defc20 100644 --- a/gruel/src/swig/CMakeLists.txt +++ b/gruel/src/swig/CMakeLists.txt @@ -40,6 +40,6 @@ GR_SWIG_INSTALL( install( FILES gr_intrusive_ptr.i pmt_swig.i ${CMAKE_CURRENT_BINARY_DIR}/pmt_swig_doc.i - DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig + DESTINATION ${GR_INCLUDE_DIR}/gruel/swig COMPONENT "gruel_swig" ) -- cgit From f919f9dcbb54a08e6e26d6c229ce92fb784fa1b2 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Fri, 13 Apr 2012 18:36:53 -0400 Subject: Removed whitespace and added dtools/bin/remove-whitespace as a tool to do this in the future. The sed script was provided by Moritz Fischer. --- gruel/src/swig/gr_intrusive_ptr.i | 6 +++--- gruel/src/swig/gruel_common.i | 8 ++++---- gruel/src/swig/pmt_swig.i | 14 +++++++------- 3 files changed, 14 insertions(+), 14 deletions(-) (limited to 'gruel/src/swig') diff --git a/gruel/src/swig/gr_intrusive_ptr.i b/gruel/src/swig/gr_intrusive_ptr.i index eef5bc84d..40c438d00 100644 --- a/gruel/src/swig/gr_intrusive_ptr.i +++ b/gruel/src/swig/gr_intrusive_ptr.i @@ -1,4 +1,4 @@ -// This file was borrowed from the SWIG project to allow use to +// This file was borrowed from the SWIG project to allow use to // wrap PMTs that use intrusive pointers. This is only necessary // to support backwards compatability with older distributions of // Linux that do not natively support a new enough version of SWIG. @@ -10,7 +10,7 @@ // #define SWIG_SHARED_PTR_NAMESPACE std // #define SWIG_SHARED_PTR_SUBNAMESPACE tr1 // #define SWIG_INTRUSIVE_PTR_NAMESPACE boost -// #define SWIG_INTRUSIVE_PTR_SUBNAMESPACE +// #define SWIG_INTRUSIVE_PTR_SUBNAMESPACE #if !defined(SWIG_INTRUSIVE_PTR_NAMESPACE) # define SWIG_INTRUSIVE_PTR_NAMESPACE boost @@ -36,7 +36,7 @@ namespace SWIG_INTRUSIVE_PTR_NAMESPACE { %fragment("SWIG_intrusive_deleter", "header") { template struct SWIG_intrusive_deleter { void operator()(T *p) { - if (p) + if (p) intrusive_ptr_release(p); } }; diff --git a/gruel/src/swig/gruel_common.i b/gruel/src/swig/gruel_common.i index e4261cbfa..3a4d841d6 100644 --- a/gruel/src/swig/gruel_common.i +++ b/gruel/src/swig/gruel_common.i @@ -1,18 +1,18 @@ /* * Copyright 2011 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, diff --git a/gruel/src/swig/pmt_swig.i b/gruel/src/swig/pmt_swig.i index 954501863..45cfceadc 100644 --- a/gruel/src/swig/pmt_swig.i +++ b/gruel/src/swig/pmt_swig.i @@ -1,19 +1,19 @@ /* -*- c++ -*- */ /* * Copyright 2011-2012 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, @@ -77,7 +77,7 @@ 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, +//! 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); @@ -352,7 +352,7 @@ size_t pmt_blob_length(pmt_t blob); */ //! true if \p x is any kind of uniform numeric vector -bool pmt_is_uniform_vector(pmt_t x); +bool pmt_is_uniform_vector(pmt_t x); bool pmt_is_u8vector(pmt_t x); bool pmt_is_s8vector(pmt_t x); @@ -550,7 +550,7 @@ 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. + * applying pmt_eqv on other objects such as numbers and symbols. * pmt_equal may fail to terminate if its arguments are circular data * structures. */ -- cgit From 056d3006d07c11c4bfba9ac5c2f82111be55dd35 Mon Sep 17 00:00:00 2001 From: Nicholas Corgan Date: Fri, 22 Jun 2012 11:19:58 -0700 Subject: gruel: got rid of inet.h and adjusted only file that depended on it --- gruel/src/swig/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gruel/src/swig') diff --git a/gruel/src/swig/CMakeLists.txt b/gruel/src/swig/CMakeLists.txt index f9d1758ec..a0f84c832 100644 --- a/gruel/src/swig/CMakeLists.txt +++ b/gruel/src/swig/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2011 Free Software Foundation, Inc. +# Copyright 2011-2012 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -23,7 +23,7 @@ include(GrPython) include(GrSwig) -set(GR_SWIG_INCLUDE_DIRS ${GRUEL_INCLUDE_DIRS}) +set(GR_SWIG_INCLUDE_DIRS ${GRUEL_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR}) set(GR_SWIG_LIBRARIES gruel) set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/pmt_swig_doc.i) -- cgit From 76258270f53da9a7b6bdeed0b38dde735956012e Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Tue, 3 Jul 2012 14:21:05 -0700 Subject: swig: added additional swig dependencies gruel/core pmt swig gen depends upon the generated header core depends upon pmt swig custom target Conflicts: gruel/src/swig/CMakeLists.txt --- gruel/src/swig/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'gruel/src/swig') diff --git a/gruel/src/swig/CMakeLists.txt b/gruel/src/swig/CMakeLists.txt index f9d1758ec..968622587 100644 --- a/gruel/src/swig/CMakeLists.txt +++ b/gruel/src/swig/CMakeLists.txt @@ -23,7 +23,8 @@ include(GrPython) include(GrSwig) -set(GR_SWIG_INCLUDE_DIRS ${GRUEL_INCLUDE_DIRS}) +set(GR_SWIG_TARGET_DEPS pmt_generated) +set(GR_SWIG_INCLUDE_DIRS ${GRUEL_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR}) set(GR_SWIG_LIBRARIES gruel) set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/pmt_swig_doc.i) @@ -43,3 +44,5 @@ install( DESTINATION ${GR_INCLUDE_DIR}/gruel/swig COMPONENT "gruel_swig" ) + +add_custom_target(pmt_swig DEPENDS ${SWIG_MODULE_pmt_swig_REAL_NAME}) -- cgit From d6bcc93a6965b9f2fd226a5bb05b051e95cd625d Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Wed, 28 Nov 2012 20:06:49 -0800 Subject: build: set Boost_INCLUDE_DIRS for components (mostly for OSX and Windows). --- gruel/src/swig/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gruel/src/swig') diff --git a/gruel/src/swig/CMakeLists.txt b/gruel/src/swig/CMakeLists.txt index 332d5866f..a5e3f9399 100644 --- a/gruel/src/swig/CMakeLists.txt +++ b/gruel/src/swig/CMakeLists.txt @@ -24,7 +24,7 @@ include(GrPython) include(GrSwig) set(GR_SWIG_TARGET_DEPS pmt_generated) -set(GR_SWIG_INCLUDE_DIRS ${GRUEL_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR}) +set(GR_SWIG_INCLUDE_DIRS ${GRUEL_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR} ${Boost_INCLUDE_DIRS}) set(GR_SWIG_LIBRARIES gruel) set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/pmt_swig_doc.i) -- cgit From 92cfb0240005675f4e7a55a81552f4c7a5128cd8 Mon Sep 17 00:00:00 2001 From: Tim O'Shea Date: Wed, 28 Nov 2012 15:15:58 -0800 Subject: core: adding msg_connect, updating msg interface, adding symbolic block names --- gruel/src/swig/pmt_swig.i | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'gruel/src/swig') diff --git a/gruel/src/swig/pmt_swig.i b/gruel/src/swig/pmt_swig.i index 45cfceadc..d46143424 100644 --- a/gruel/src/swig/pmt_swig.i +++ b/gruel/src/swig/pmt_swig.i @@ -696,6 +696,10 @@ pmt_t pmt_list6(const pmt_t& x1, const pmt_t& x2, const pmt_t& x3, const pmt_t& */ pmt_t pmt_list_add(pmt_t list, const pmt_t& item); +/*! + * \brief Return \p list with \p item removed + */ +pmt_t pmt_list_rm(pmt_t list, const pmt_t& item); /* * ------------------------------------------------------------------------ -- cgit From 52ca5e2765b7a4532d26502b5b76b7c85c5019d7 Mon Sep 17 00:00:00 2001 From: Tim O'Shea Date: Fri, 7 Dec 2012 09:28:41 -0800 Subject: core: added gr_tuntap_pdu, gr_socket_pdu, and msg passing enhancements --- gruel/src/swig/pmt_swig.i | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gruel/src/swig') diff --git a/gruel/src/swig/pmt_swig.i b/gruel/src/swig/pmt_swig.i index d46143424..b1628c998 100644 --- a/gruel/src/swig/pmt_swig.i +++ b/gruel/src/swig/pmt_swig.i @@ -701,6 +701,11 @@ pmt_t pmt_list_add(pmt_t list, const pmt_t& item); */ pmt_t pmt_list_rm(pmt_t list, const pmt_t& item); +/*! + * \brief Return bool of \p list contains \p item + */ +bool pmt_list_has(pmt_t list, const pmt_t& item); + /* * ------------------------------------------------------------------------ * read / write -- cgit From ecd62ef7b948d9ab14817a8df205373284362f0e Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Thu, 13 Dec 2012 18:08:14 -0500 Subject: gruel: allow us to use pmt_init_Xvector methods in python. --- gruel/src/swig/pmt_swig.i | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) (limited to 'gruel/src/swig') diff --git a/gruel/src/swig/pmt_swig.i b/gruel/src/swig/pmt_swig.i index b1628c998..67dda5c3f 100644 --- a/gruel/src/swig/pmt_swig.i +++ b/gruel/src/swig/pmt_swig.i @@ -38,6 +38,27 @@ //load generated python docstrings %include "pmt_swig_doc.i" +%include +%include +%include + +namespace std { + %template() vector; + %template() vector; + %template() vector; + %template() vector; + %template() vector; + %template() vector; + %template() vector; + %template() vector; + %template() vector; + %template() vector; + %template() vector; + %template() vector; + %template() vector< complex >; + %template() vector< complex >; +}; + //////////////////////////////////////////////////////////////////////// // Language independent exception handler //////////////////////////////////////////////////////////////////////// @@ -380,16 +401,17 @@ pmt_t pmt_make_f64vector(size_t k, double fill); pmt_t pmt_make_c32vector(size_t k, std::complex fill); pmt_t pmt_make_c64vector(size_t k, std::complex 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_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 *data); -pmt_t pmt_init_c64vector(size_t k, const std::complex *data); + +pmt_t pmt_init_u8vector(size_t k, const std::vector &data); +pmt_t pmt_init_s8vector(size_t k, const std::vector &data); +pmt_t pmt_init_u16vector(size_t k, const std::vector &data); +pmt_t pmt_init_s16vector(size_t k, const std::vector &data); +pmt_t pmt_init_u32vector(size_t k, const std::vector &data); +pmt_t pmt_init_s32vector(size_t k, const std::vector &data); +pmt_t pmt_init_f32vector(size_t k, const std::vector &data); +pmt_t pmt_init_f64vector(size_t k, const std::vector &data); +pmt_t pmt_init_c32vector(size_t k, const std::vector< std::complex > &data); +pmt_t pmt_init_c64vector(size_t k, const std::vector< std::complex > &data); uint8_t pmt_u8vector_ref(pmt_t v, size_t k); int8_t pmt_s8vector_ref(pmt_t v, size_t k); -- cgit From 8e8ed231cd2469e1a39c5ae6af23ac9b29264af7 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Fri, 14 Dec 2012 16:00:27 -0500 Subject: gruel: Enabling serialize/deserialize for PMT vectors. --- gruel/src/swig/pmt_swig.i | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'gruel/src/swig') diff --git a/gruel/src/swig/pmt_swig.i b/gruel/src/swig/pmt_swig.i index 67dda5c3f..b65857167 100644 --- a/gruel/src/swig/pmt_swig.i +++ b/gruel/src/swig/pmt_swig.i @@ -55,8 +55,8 @@ namespace std { %template() vector; %template() vector; %template() vector; - %template() vector< complex >; - %template() vector< complex >; + %template() vector< std::complex >; + %template() vector< std::complex >; }; //////////////////////////////////////////////////////////////////////// @@ -410,8 +410,8 @@ pmt_t pmt_init_u32vector(size_t k, const std::vector &data); pmt_t pmt_init_s32vector(size_t k, const std::vector &data); pmt_t pmt_init_f32vector(size_t k, const std::vector &data); pmt_t pmt_init_f64vector(size_t k, const std::vector &data); -pmt_t pmt_init_c32vector(size_t k, const std::vector< std::complex > &data); -pmt_t pmt_init_c64vector(size_t k, const std::vector< std::complex > &data); +pmt_t pmt_init_c32vector(size_t k, const std::vector > &data); +pmt_t pmt_init_c64vector(size_t k, const std::vector > &data); uint8_t pmt_u8vector_ref(pmt_t v, size_t k); int8_t pmt_s8vector_ref(pmt_t v, size_t k); -- cgit From eff53a185e1c25fc54768f480e1be1a02bba699e Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Wed, 19 Dec 2012 18:03:49 -0500 Subject: gruel: pmt_Xvector_elements can be used in Python to return a Python tuple. --- gruel/src/swig/pmt_swig.i | 48 +++++++++++++++++------------------------------ 1 file changed, 17 insertions(+), 31 deletions(-) (limited to 'gruel/src/swig') diff --git a/gruel/src/swig/pmt_swig.i b/gruel/src/swig/pmt_swig.i index b65857167..1541e6f4f 100644 --- a/gruel/src/swig/pmt_swig.i +++ b/gruel/src/swig/pmt_swig.i @@ -441,37 +441,23 @@ void pmt_c64vector_set(pmt_t v, size_t k, std::complex 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 *pmt_c32vector_elements(pmt_t v, size_t &len); //< len is in elements -const std::complex *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 *pmt_c32vector_writable_elements(pmt_t v, size_t &len); //< len is in elements -std::complex *pmt_c64vector_writable_elements(pmt_t v, size_t &len); //< len is in elements +%apply size_t & INOUT { size_t &len }; + +// works with any; len is in bytes +// Returns an opaque Python type +const void *pmt_uniform_vector_elements(pmt_t v, size_t &len); + +// Returns a Python tuple +const std::vector pmt_u8vector_elements(pmt_t v); +const std::vector pmt_s8vector_elements(pmt_t v); +const std::vector pmt_u16vector_elements(pmt_t v); +const std::vector pmt_s16vector_elements(pmt_t v); +const std::vector pmt_u32vector_elements(pmt_t v); +const std::vector pmt_s32vector_elements(pmt_t v); +const std::vector pmt_f32vector_elements(pmt_t v); +const std::vector pmt_f64vector_elements(pmt_t v); +const std::vector > pmt_c32vector_elements(pmt_t v); +const std::vector > pmt_c64vector_elements(pmt_t v); /* * ------------------------------------------------------------------------ -- cgit From b60396ab638534aff05fa5b0c8b8c0b334b4e58e Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Thu, 20 Dec 2012 11:54:22 -0500 Subject: gruel: adding a 'pmt_from_complex' call (more clear than pmt_make_rectangular). --- gruel/src/swig/pmt_swig.i | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gruel/src/swig') diff --git a/gruel/src/swig/pmt_swig.i b/gruel/src/swig/pmt_swig.i index 1541e6f4f..84f48b099 100644 --- a/gruel/src/swig/pmt_swig.i +++ b/gruel/src/swig/pmt_swig.i @@ -212,6 +212,8 @@ 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); +pmt_t pmt_from_complex(const std::complex &z); + /*! * If \p z is complex, real or integer, return the closest complex. * Otherwise, raise the wrong_type exception. -- cgit From baaf2b6cf06f464a710c3f36db4c9275dd915d92 Mon Sep 17 00:00:00 2001 From: Michael L Dickens Date: Thu, 3 Jan 2013 10:30:33 -0500 Subject: Reorder SWIG_INCLUDE_DIRS --- gruel/src/swig/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'gruel/src/swig') diff --git a/gruel/src/swig/CMakeLists.txt b/gruel/src/swig/CMakeLists.txt index a5e3f9399..aeceaa605 100644 --- a/gruel/src/swig/CMakeLists.txt +++ b/gruel/src/swig/CMakeLists.txt @@ -24,7 +24,11 @@ include(GrPython) include(GrSwig) set(GR_SWIG_TARGET_DEPS pmt_generated) -set(GR_SWIG_INCLUDE_DIRS ${GRUEL_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR} ${Boost_INCLUDE_DIRS}) +set(GR_SWIG_INCLUDE_DIRS + ${CMAKE_CURRENT_BINARY_DIR} + ${GRUEL_INCLUDE_DIRS} + ${Boost_INCLUDE_DIRS} +) set(GR_SWIG_LIBRARIES gruel) set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/pmt_swig_doc.i) -- cgit From dbd4f93ee7d67a93bdf59a138dc8fc7df443a136 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 14 Apr 2013 22:10:58 -0700 Subject: gruel: added include guards for gr_intrusive_ptr.i --- gruel/src/swig/gr_intrusive_ptr.i | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'gruel/src/swig') diff --git a/gruel/src/swig/gr_intrusive_ptr.i b/gruel/src/swig/gr_intrusive_ptr.i index 40c438d00..dc6004f44 100644 --- a/gruel/src/swig/gr_intrusive_ptr.i +++ b/gruel/src/swig/gr_intrusive_ptr.i @@ -1,3 +1,5 @@ +#ifndef SWIG_INTRUSIVE_PTR_NAMESPACE + // This file was borrowed from the SWIG project to allow use to // wrap PMTs that use intrusive pointers. This is only necessary // to support backwards compatability with older distributions of @@ -99,4 +101,4 @@ SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, const, TYPE) } %enddef - +#endif //SWIG_INTRUSIVE_PTR_NAMESPACE -- cgit