diff options
Diffstat (limited to 'gnuradio-runtime/swig')
37 files changed, 1014 insertions, 987 deletions
diff --git a/gnuradio-runtime/swig/CMakeLists.txt b/gnuradio-runtime/swig/CMakeLists.txt index 3bff08383f..b2fcb180b2 100644 --- a/gnuradio-runtime/swig/CMakeLists.txt +++ b/gnuradio-runtime/swig/CMakeLists.txt @@ -90,38 +90,32 @@ GR_SWIG_INSTALL( install( FILES gnuradio_swig_bug_workaround.h + runtime_swig.i complex_vec_test.i gnuradio.i - gr_basic_block.i - gr_block_detail.i - gr_block.i - gr_buffer.i - gr_constants.i + basic_block.i + constants.i gr_ctrlport.i - gr_dispatcher.i - gr_error_handler.i - gr_feval.i - gr_hier_block2.i - gr_io_signature.i + dispatcher.i + error_handler.i + feval.i + hier_block2.i + io_signature.i + message.i + msg_handler.i + msg_queue.i + prefs.i + realtime.i + single_threaded_scheduler.i + tagged_stream_block.i + tags.i + top_block.i + block_gateway.i gr_logger.i - gr_message.i - gr_msg_handler.i - gr_msg_queue.i - gr_prefs.i - gr_realtime.i gr_shared_ptr.i - gr_single_threaded_scheduler.i gr_swig_block_magic.i - gr_sync_block.i - gr_sync_decimator.i - gr_sync_interpolator.i - gr_tagged_stream_block.i - gr_tags.i - gr_top_block.i gr_types.i gr_extras.i - runtime_block_gateway.i - runtime_swig.i gr_intrusive_ptr.i pmt_swig.i ${CMAKE_CURRENT_BINARY_DIR}/runtime_swig_doc.i diff --git a/gnuradio-runtime/swig/gr_basic_block.i b/gnuradio-runtime/swig/basic_block.i index 2e703278c5..f4ed86aefc 100644 --- a/gnuradio-runtime/swig/gr_basic_block.i +++ b/gnuradio-runtime/swig/basic_block.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006,2010 Free Software Foundation, Inc. + * Copyright 2006,2010,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,44 +20,46 @@ * Boston, MA 02110-1301, USA. */ -class gr_basic_block; -typedef boost::shared_ptr<gr_basic_block> gr_basic_block_sptr; -%template(gr_basic_block_sptr) boost::shared_ptr<gr_basic_block>; +class gr::basic_block; +typedef boost::shared_ptr<gr::basic_block> gr::basic_block_sptr; +%template(basic_block_sptr) boost::shared_ptr<gr::basic_block>; %include "pmt_swig.i" -using namespace pmt; // support vectors of these... namespace std { - %template(x_vector_gr_basic_block_sptr) vector<gr_basic_block_sptr>; + %template(x_vector_basic_block_sptr) vector<gr::basic_block_sptr>; }; -class gr_basic_block -{ -protected: - gr_basic_block(); +namespace gr { -public: - virtual ~gr_basic_block(); + class gr::basic_block + { + protected: + basic_block(); + + public: + virtual ~basic_block(); std::string name() const; std::string symbol_name() const; - gr_io_signature_sptr input_signature() const; - gr_io_signature_sptr output_signature() const; + gr::io_signature::sptr input_signature() const; + gr::io_signature::sptr output_signature() const; long unique_id() const; - gr_basic_block_sptr to_basic_block(); - bool check_topology (int ninputs, int noutputs); + gr::basic_block_sptr to_basic_block(); + bool check_topology(int ninputs, int noutputs); std::string alias(); void set_block_alias(std::string name); - void _post(pmt_t which_port, pmt_t msg); - pmt_t message_ports_in(); - pmt_t message_ports_out(); -}; + void _post(pmt::pmt_t which_port, pmt::pmt_t msg); + pmt::pmt_t message_ports_in(); + pmt::pmt_t message_ports_out(); + }; -%rename(block_ncurrently_allocated) gr_basic_block_ncurrently_allocated; -long gr_basic_block_ncurrently_allocated(); + %rename(block_ncurrently_allocated) basic_block_ncurrently_allocated; + long basic_block_ncurrently_allocated(); +} #ifdef SWIGPYTHON %pythoncode %{ -gr_basic_block_sptr.__repr__ = lambda self: "<gr_basic_block %s (%d)>" % (self.name(), self.unique_id ()) +basic_block_sptr.__repr__ = lambda self: "<basic_block %s (%d)>" % (self.name(), self.unique_id ()) %} #endif diff --git a/gnuradio-runtime/swig/gr_block.i b/gnuradio-runtime/swig/block.i index a53489f9a2..f697089185 100644 --- a/gnuradio-runtime/swig/gr_block.i +++ b/gnuradio-runtime/swig/block.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2010 Free Software Foundation, Inc. + * Copyright 2004,2010,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,26 +20,27 @@ * Boston, MA 02110-1301, USA. */ -%include <gr_basic_block.i> +%include <basic_block.i> -class gr_block; -typedef boost::shared_ptr<gr_block> gr_block_sptr; -%template(gr_block_sptr) boost::shared_ptr<gr_block>; +class gr::block; +typedef boost::shared_ptr<gr::block> gr::block_sptr; +%template(block_sptr) boost::shared_ptr<gr::block>; // support vectors of these... namespace std { - %template(x_vector_gr_block_sptr) vector<gr_block_sptr>; + %template(x_vector_block_sptr) vector<gr::block_sptr>; }; -class gr_block : public gr_basic_block { +class gr::block : public gr::basic_block +{ protected: - gr_block (const std::string &name, - gr_io_signature_sptr input_signature, - gr_io_signature_sptr output_signature); + block (const std::string &name, + gr::io_signature::sptr input_signature, + gr::io_signature::sptr output_signature); public: - virtual ~gr_block (); + virtual ~block (); unsigned history () const; @@ -88,6 +89,6 @@ class gr_block : public gr_basic_block { std::vector<int> processor_affinity(); // internal use - gr_block_detail_sptr detail () const { return d_detail; } - void set_detail (gr_block_detail_sptr detail) { d_detail = detail; } + //block_detail_sptr detail () const { return d_detail; } + //void set_detail (block_detail_sptr detail) { d_detail = detail; } }; diff --git a/gnuradio-runtime/swig/block_detail.i b/gnuradio-runtime/swig/block_detail.i new file mode 100644 index 0000000000..a43e02bc6a --- /dev/null +++ b/gnuradio-runtime/swig/block_detail.i @@ -0,0 +1,56 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2013 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. + */ + +class gr::block_detail; +typedef boost::shared_ptr<gr::block_detail> gr::block_detail_sptr; +%template(block_detail_sptr) boost::shared_ptr<gr::block_detail>; +%rename(block_detail) gr::make_block_detail; +%ignore gr::block_detail; + +gr::block_detail_sptr gr:: +gr::make_block_detail(unsigned int ninputs, unsigned int noutputs); + +namespace gr { + + class gr::block_detail { + public: + + ~block_detail (); + + int ninputs() const; + int noutputs() const; + bool sink_p() const; + bool source_p() const; + + void set_input(unsigned int which, gr::buffer_reader_sptr reader); + gr::buffer_reader_sptr input(unsigned int which); + + void set_output(unsigned int which, gr::buffer_sptr buffer); + gr::buffer_sptr output(unsigned int which); + + private: + block_detail(unsigned int ninputs, unsigned int noutputs); + }; + + %rename(block_detail_ncurrently_allocated) block_detail_ncurrently_allocated; + long block_detail_ncurrently_allocated(); +} diff --git a/gnuradio-runtime/swig/runtime_block_gateway.i b/gnuradio-runtime/swig/block_gateway.i index 52d4194dee..95207a80a2 100644 --- a/gnuradio-runtime/swig/runtime_block_gateway.i +++ b/gnuradio-runtime/swig/block_gateway.i @@ -24,8 +24,8 @@ // standard includes //////////////////////////////////////////////////////////////////////// %include <gnuradio.i> -%include <gr_tags.i> -%include <gr_feval.i> +%include <tags.i> +%include <feval.i> %template(void_start_vector_t) std::vector<void *>; @@ -33,11 +33,17 @@ // block headers //////////////////////////////////////////////////////////////////////// %{ -#include <runtime_block_gateway.h> +#include <gnuradio/block_gateway.h> %} //////////////////////////////////////////////////////////////////////// // block magic //////////////////////////////////////////////////////////////////////// -GR_SWIG_BLOCK_MAGIC(runtime, block_gateway); -%include <runtime_block_gateway.h> +%include <gnuradio/block_gateway.h> + +%template(block_gateway_sptr) boost::shared_ptr<gr::block_gateway>; +%pythoncode %{ +block_gateway_sptr.__repr__ = lambda self: "<block_gateway>" +block_gateway = block_gateway.make; +%} + diff --git a/gnuradio-runtime/swig/buffer.i b/gnuradio-runtime/swig/buffer.i new file mode 100644 index 0000000000..44bd4887a8 --- /dev/null +++ b/gnuradio-runtime/swig/buffer.i @@ -0,0 +1,67 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2013 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. + */ + +class gr::buffer; +typedef boost::shared_ptr<gr::buffer> gr::buffer_sptr; +%template(buffer_sptr) boost::shared_ptr<gr::buffer>; +%rename(buffer) gr::make_buffer; +%ignore gr::buffer; + +gr::buffer_sptr +gr::make_buffer (int nitems, size_t sizeof_item, gr::block_sptr link); + +class gr::buffer_reader; +typedef boost::shared_ptr<gr::buffer_reader> gr::buffer_reader_sptr; +%template(buffer_reader_sptr) boost::shared_ptr<gr::buffer_reader>; +%ignore gr::buffer_reader; + +%rename(buffer_add_reader) gr::buffer_add_reader; +gr::buffer_reader_sptr +gr::buffer_add_reader (gr::buffer_sptr buf, int nzero_preload, gr::block_sptr link); + +namespace gr { + + class gr::buffer + { + public: + ~buffer(); + + private: + buffer(int nitems, size_t sizeof_item, gr::block_sptr link); + }; + + class gr::buffer_reader + { + public: + ~buffer_reader(); + + private: + friend class buffer; + buffer_reader(gr::buffer_sptr buffer, unsigned int read_index, gr::block_sptr link); + }; + + %rename(buffer_ncurrently_allocated) buffer_ncurrently_allocated; + long buffer_ncurrently_allocated(); + + %rename(buffer_reader_ncurrently_allocated) buffer_reader_ncurrently_allocated; + long buffer_reader_ncurrently_allocated(); +} diff --git a/gnuradio-runtime/swig/constants.i b/gnuradio-runtime/swig/constants.i new file mode 100644 index 0000000000..ebc6a93515 --- /dev/null +++ b/gnuradio-runtime/swig/constants.i @@ -0,0 +1,13 @@ +/* -*- c++ -*- */ + +%rename(prefix) gr::prefix; +%rename(sysconfdir) gr::sysconfdir; +%rename(prefsdir) gr::prefsdir; +%rename(build_date) gr::build_date; +%rename(version) gr::version; + +const std::string gr::prefix(); +const std::string gr::sysconfdir(); +const std::string gr::prefsdir(); +const std::string gr::build_date(); +const std::string gr::version(); diff --git a/gnuradio-runtime/swig/gr_dispatcher.i b/gnuradio-runtime/swig/dispatcher.i index 28737cd317..4a039c61e3 100644 --- a/gnuradio-runtime/swig/gr_dispatcher.i +++ b/gnuradio-runtime/swig/dispatcher.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005 Free Software Foundation, Inc. + * Copyright 2005,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,36 +20,37 @@ * Boston, MA 02110-1301, USA. */ -class gr_dispatcher; -typedef boost::shared_ptr<gr_dispatcher> gr_dispatcher_sptr; -%template(gr_dispatcher_sptr) boost::shared_ptr<gr_dispatcher>; +class gr::dispatcher; +typedef boost::shared_ptr<gr::dispatcher> gr::dispatcher_sptr; +%template(dispatcher_sptr) boost::shared_ptr<gr::dispatcher>; -%rename(dispatcher) gr_make_dispatcher; -gr_dispatcher_sptr gr_make_dispatcher(); +%rename(dispatcher) gr::make_dispatcher; +gr::dispatcher_sptr gr::make_dispatcher(); -%rename(dispatcher_singleton) gr_dispatcher_singleton; -gr_dispatcher_sptr gr_dispatcher_singleton(); +%rename(dispatcher_singleton) gr::dispatcher_singleton; +gr::dispatcher_sptr gr::dispatcher_singleton(); /*! * \brief invoke callbacks based on select. * - * \sa gr_select_handler + * \sa gr::select_handler */ -class gr_dispatcher +class gr::dispatcher { - gr_dispatcher(); + dispatcher(); public: - ~gr_dispatcher(); + ~dispatcher(); /*! * \brief Event dispatching loop. * - * Enter a polling loop that only terminates after all gr_select_handlers - * have been removed. \p timeout sets the timeout parameter to the select() + * Enter a polling loop that only terminates after all gr::select_handlers + * have been removed. \p timeout sets the timeout parameter to the select() * call, measured in seconds. * * \param timeout maximum number of seconds to block in select. */ void loop(double timeout=10); }; + diff --git a/gnuradio-runtime/swig/gr_error_handler.i b/gnuradio-runtime/swig/error_handler.i index 072394a727..8174128fa2 100644 --- a/gnuradio-runtime/swig/gr_error_handler.i +++ b/gnuradio-runtime/swig/error_handler.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005 Free Software Foundation, Inc. + * Copyright 2005,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,10 +20,10 @@ * Boston, MA 02110-1301, USA. */ -%rename(error_handler) gr_error_handler; -%rename(file_error_handler) gr_file_error_handler; +%rename(error_handler) gr::error_handler; +%rename(file_error_handler) gr::file_error_handler; -class gr_error_handler { +class gr::error_handler { public: enum seriousness { ERR_DEBUG = 0x00000000, @@ -33,14 +33,14 @@ public: ERR_FATAL = 0x00040000 }; - gr_error_handler() {} - virtual ~gr_error_handler(); + error_handler() {} + virtual ~error_handler(); - static gr_error_handler *default_handler(); - static gr_error_handler *silent_handler(); + static gr::error_handler *default_handler(); + static gr::error_handler *silent_handler(); static bool has_default_handler(); - static void set_default_handler(gr_error_handler *errh); + static void set_default_handler(gr::error_handler *errh); virtual int nwarnings() const = 0; virtual int nerrors() const = 0; @@ -49,21 +49,21 @@ public: void verror_text(seriousness s, const std::string &text); }; -%ignore gr_base_error_handler; -class gr_base_error_handler : public gr_error_handler { +%ignore gr::base_error_handler; +class gr::base_error_handler : public gr::error_handler { int d_nwarnings; int d_nerrors; public: - gr_base_error_handler() : d_nwarnings(0), d_nerrors(0) {} + base_error_handler() : d_nwarnings(0), d_nerrors(0) {} int nwarnings() const { return d_nwarnings; } int nerrors() const { return d_nerrors; } void reset_counts() { d_nwarnings = d_nerrors = 0; } void count_error(seriousness s); }; -class gr_file_error_handler : public gr_base_error_handler { +class gr::file_error_handler : public gr::base_error_handler { public: - gr_file_error_handler(int file_descriptor); - ~gr_file_error_handler(); + file_error_handler(int file_descriptor); + ~file_error_handler(); }; diff --git a/gnuradio-runtime/swig/feval.i b/gnuradio-runtime/swig/feval.i new file mode 100644 index 0000000000..f773346b1b --- /dev/null +++ b/gnuradio-runtime/swig/feval.i @@ -0,0 +1,243 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2010,2013 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. + */ + + +/* + * N.B., this is a _very_ non-standard SWIG .i file + * + * It contains a bunch of magic that is required to ensure that when + * these classes are used as base classes for python code, + * everything works when calling back from C++ into Python. + * + * The gist of the problem is that our C++ code is usually not holding + * the Python Global Interpreter Lock (GIL). Thus if we invoke a + * "director" method from C++, we'll end up in Python not holding the + * GIL. Disaster (SIGSEGV) will result. To avoid this we insert a + * "shim" that grabs and releases the GIL. + * + * If you don't understand SWIG "directors" or the Python GIL, + * don't bother trying to understand what's going on in here. + * + * [We could eliminate a bunch of this hair by requiring SWIG 1.3.29 + * or later and some additional magic declarations, but many systems + * aren't shipping that version yet. Thus we kludge...] + */ + +// Directors are only supported in Python, Java and C# +#ifdef SWIGPYTHON + +%import "pmt_swig.i" + + // Enable SWIG directors for these classes +%feature("director") gr::py_feval_dd; +%feature("director") gr::py_feval_cc; +%feature("director") gr::py_feval_ll; +%feature("director") gr::py_feval; +%feature("director") gr::py_feval_p; + +%feature("nodirector") gr::py_feval_dd::calleval; +%feature("nodirector") gr::py_feval_cc::calleval; +%feature("nodirector") gr::py_feval_ll::calleval; +%feature("nodirector") gr::py_feval::calleval; +%feature("nodirector") gr::py_feval_p::calleval; + +//%exception { +// try { $action } +// catch (Swig::DirectorException &e) { std::cerr << e.getMessage(); SWIG_fail; } +//} + +%{ + +// class that ensures we acquire and release the Python GIL + +class ensure_py_gil_state { + PyGILState_STATE d_gstate; +public: + ensure_py_gil_state() { d_gstate = PyGILState_Ensure(); } + ~ensure_py_gil_state() { PyGILState_Release(d_gstate); } +}; + +%} + +%ignore gr::feval_dd; +%ignore gr::feval_cc; +%ignore gr::feval_ll; +%ignore gr::feval; +%ignore gr::feval_p; + +namespace gr { +/* + * These are the real C++ base classes, however we don't want these exposed. + */ + class gr::feval_dd + { + protected: + virtual double eval(double x); + + public: + feval_dd() {} + virtual ~feval_dd(); + + virtual double calleval(double x); + }; + //%rename(feval_dd) gr::feval_dd; + + class gr::feval_cc + { + protected: + virtual gr_complex eval(gr_complex x); + + public: + feval_cc() {} + virtual ~feval_cc(); + + virtual gr_complex calleval(gr_complex x); + }; + //%rename(feval_cc) gr::feval_cc; + + class gr::feval_ll + { + protected: + virtual long eval(long x); + + public: + feval_ll() {} + virtual ~feval_ll(); + + virtual long calleval(long x); + }; + //%rename(feval_ll) gr::feval_ll; + + class gr::feval + { + protected: + virtual void eval(); + + public: + feval() {} + virtual ~feval(); + + virtual void calleval(); + }; + //%rename(feval) gr::feval; + + class gr::feval_p + { + protected: + virtual void eval(pmt::pmt_t x); + + public: + feval_p() {} + virtual ~feval_p(); + + virtual void calleval(pmt::pmt_t x); + }; + //%rename(feval_p) gr::feval_p; +} + +/* + * These are the ones to derive from in Python. They have the magic shim + * that ensures that we're holding the Python GIL when we enter Python land... + */ + +namespace gr { + %rename(feval_dd) py_feval_dd; + %rename(feval_cc) py_feval_cc; + %rename(feval_ll) py_feval_ll; + %rename(feval) py_feval; + %rename(feval_p) py_feval_p; +} + +%inline %{ +#include <pmt/pmt.h> + + namespace gr { + + class py_feval_dd : public gr::feval_dd + { + public: + double calleval(double x) + { + ensure_py_gil_state _lock; + return eval(x); + } + }; + + class py_feval_cc : public gr::feval_cc + { + public: + gr_complex calleval(gr_complex x) + { + ensure_py_gil_state _lock; + return eval(x); + } + }; + + class py_feval_ll : public gr::feval_ll + { + public: + long calleval(long x) + { + ensure_py_gil_state _lock; + return eval(x); + } + }; + + class py_feval : public gr::feval + { + public: + void calleval() + { + ensure_py_gil_state _lock; + eval(); + } + }; + + class py_feval_p : public gr::feval_p + { + public: + void calleval(pmt::pmt_t x) + { + ensure_py_gil_state _lock; + eval(x); + } + }; + } +%} + +namespace gr { + // examples / test cases + + %rename(feval_dd_example) gr::feval_dd_example; + double gr::feval_dd_example(gr::feval_dd *f, double x); + + %rename(feval_cc_example) gr::feval_cc_example; + gr_complex gr::feval_cc_example(gr::feval_cc *f, gr_complex x); + + %rename(feval_ll_example) gr::feval_ll_example; + long gr::feval_ll_example(gr::feval_ll *f, long x); + + %rename(feval_example) gr::feval_example; + void gr::feval_example(gr::feval *f); +} + +#endif // SWIGPYTHON diff --git a/gnuradio-runtime/swig/gnuradio_swig_bug_workaround.h b/gnuradio-runtime/swig/gnuradio_swig_bug_workaround.h index 1994f06609..ad9168ce9e 100644 --- a/gnuradio-runtime/swig/gnuradio_swig_bug_workaround.h +++ b/gnuradio-runtime/swig/gnuradio_swig_bug_workaround.h @@ -29,17 +29,17 @@ * %import "gnuradio.i" */ -class gr_base_error_handler; -class gr_basic_block; -class gr_block; -class gr_error_handler; -class gr_file_error_handler; -class gr_hier_block2; -class gr_msg_handler; -class gr_msg_queue; -class gr_sync_block; -class gr_sync_decimator; -class gr_sync_interpolator; -class gr_top_block; +class base_error_handler; +class basic_block; +class block; +class error_handler; +class file_error_handler; +class hier_block2; +class msg_handler; +class msg_queue; +class sync_block; +class sync_decimator; +class sync_interpolator; +class top_block; #endif /* INCLUDED_GNURADIO_SWIG_BUG_WORKAROUND_H */ diff --git a/gnuradio-runtime/swig/gr_block_detail.i b/gnuradio-runtime/swig/gr_block_detail.i deleted file mode 100644 index 74ff463604..0000000000 --- a/gnuradio-runtime/swig/gr_block_detail.i +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 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. - */ - -class gr_block_detail; -typedef boost::shared_ptr<gr_block_detail> gr_block_detail_sptr; -%template(gr_block_detail_sptr) boost::shared_ptr<gr_block_detail>; -%rename(block_detail) gr_make_block_detail; -%ignore gr_block_detail; - -gr_block_detail_sptr gr_make_block_detail (unsigned int ninputs, unsigned int noutputs); - -class gr_block_detail { - public: - - ~gr_block_detail (); - - int ninputs () const { return d_ninputs; } - int noutputs () const { return d_noutputs; } - bool sink_p () const { return d_noutputs == 0; } - bool source_p () const { return d_ninputs == 0; } - - void set_input (unsigned int which, gr_buffer_reader_sptr reader); - gr_buffer_reader_sptr input (unsigned int which) - { - if (which >= d_ninputs) - throw std::invalid_argument ("gr_block_detail::input"); - return d_input[which]; - } - - void set_output (unsigned int which, gr_buffer_sptr buffer); - gr_buffer_sptr output (unsigned int which) - { - if (which >= d_noutputs) - throw std::invalid_argument ("gr_block_detail::output"); - return d_output[which]; - } - - // ---------------------------------------------------------------------------- - - private: - gr_block_detail (unsigned int ninputs, unsigned int noutputs); - -}; - - -%rename(block_detail_ncurrently_allocated) gr_block_detail_ncurrently_allocated; -long gr_block_detail_ncurrently_allocated (); diff --git a/gnuradio-runtime/swig/gr_buffer.i b/gnuradio-runtime/swig/gr_buffer.i deleted file mode 100644 index 390a94e050..0000000000 --- a/gnuradio-runtime/swig/gr_buffer.i +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 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. - */ - -class gr_buffer; -typedef boost::shared_ptr<gr_buffer> gr_buffer_sptr; -%template(gr_buffer_sptr) boost::shared_ptr<gr_buffer>; -%rename(buffer) gr_make_buffer; -%ignore gr_buffer; - -gr_buffer_sptr gr_make_buffer (int nitems, size_t sizeof_item, gr_block_sptr link); - -class gr_buffer { - public: - ~gr_buffer (); - - private: - gr_buffer (int nitems, size_t sizeof_item, gr_block_sptr link); -}; - - -class gr_buffer_reader; -typedef boost::shared_ptr<gr_buffer_reader> gr_buffer_reader_sptr; -%template(gr_buffer_reader_sptr) boost::shared_ptr<gr_buffer_reader>; -%ignore gr_buffer_reader; - -%rename(buffer_add_reader) gr_buffer_add_reader; -gr_buffer_reader_sptr gr_buffer_add_reader (gr_buffer_sptr buf, int nzero_preload, gr_block_sptr link); - -class gr_buffer_reader { - public: - ~gr_buffer_reader (); - - private: - friend class gr_buffer; - gr_buffer_reader (gr_buffer_sptr buffer, unsigned int read_index, gr_block_sptr link); -}; - - -%rename(buffer_ncurrently_allocated) gr_buffer_ncurrently_allocated; -long gr_buffer_ncurrently_allocated (); - -%rename(buffer_reader_ncurrently_allocated) gr_buffer_reader_ncurrently_allocated; -long gr_buffer_reader_ncurrently_allocated (); - diff --git a/gnuradio-runtime/swig/gr_constants.i b/gnuradio-runtime/swig/gr_constants.i deleted file mode 100644 index a5aef14925..0000000000 --- a/gnuradio-runtime/swig/gr_constants.i +++ /dev/null @@ -1,13 +0,0 @@ -/* -*- c++ -*- */ - -%rename(prefix) gr_prefix; -%rename(sysconfdir) gr_sysconfdir; -%rename(prefsdir) gr_prefsdir; -%rename(build_date) gr_build_date; -%rename(version) gr_version; - -const std::string gr_prefix(); -const std::string gr_sysconfdir(); -const std::string gr_prefsdir(); -const std::string gr_build_date(); -const std::string gr_version(); diff --git a/gnuradio-runtime/swig/gr_ctrlport.i b/gnuradio-runtime/swig/gr_ctrlport.i index fa3ae845d7..ac05c05ee5 100644 --- a/gnuradio-runtime/swig/gr_ctrlport.i +++ b/gnuradio-runtime/swig/gr_ctrlport.i @@ -53,14 +53,14 @@ enum KnobType { }; %{ -#include <rpcserver_booter_base.h> -#include <rpcserver_booter_aggregator.h> -#include <pycallback_object.h> +#include <gnuradio/rpcserver_booter_base.h> +#include <gnuradio/rpcserver_booter_aggregator.h> +#include <gnuradio/pycallback_object.h> %} -%include <rpcserver_booter_base.h> -%include <rpcserver_booter_aggregator.h> -%include <pycallback_object.h> +%include <gnuradio/rpcserver_booter_base.h> +%include <gnuradio/rpcserver_booter_aggregator.h> +%include <gnuradio/pycallback_object.h> // Declare this class here but without the nested templated class // inside (replaces include of rpcmanager.h) diff --git a/gnuradio-runtime/swig/gr_feval.i b/gnuradio-runtime/swig/gr_feval.i deleted file mode 100644 index e3b8696fa6..0000000000 --- a/gnuradio-runtime/swig/gr_feval.i +++ /dev/null @@ -1,233 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,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. - */ - - -/* - * N.B., this is a _very_ non-standard SWIG .i file - * - * It contains a bunch of magic that is required to ensure that when - * these classes are used as base classes for python code, - * everything works when calling back from C++ into Python. - * - * The gist of the problem is that our C++ code is usually not holding - * the Python Global Interpreter Lock (GIL). Thus if we invoke a - * "director" method from C++, we'll end up in Python not holding the - * GIL. Disaster (SIGSEGV) will result. To avoid this we insert a - * "shim" that grabs and releases the GIL. - * - * If you don't understand SWIG "directors" or the Python GIL, - * don't bother trying to understand what's going on in here. - * - * [We could eliminate a bunch of this hair by requiring SWIG 1.3.29 - * or later and some additional magic declarations, but many systems - * aren't shipping that version yet. Thus we kludge...] - */ - - -// Directors are only supported in Python, Java and C# -#ifdef SWIGPYTHON -%include "pmt_swig.i" -using namespace pmt; - -// Enable SWIG directors for these classes -%feature("director") gr_py_feval_dd; -%feature("director") gr_py_feval_cc; -%feature("director") gr_py_feval_ll; -%feature("director") gr_py_feval; -%feature("director") gr_py_feval_p; - -%feature("nodirector") gr_py_feval_dd::calleval; -%feature("nodirector") gr_py_feval_cc::calleval; -%feature("nodirector") gr_py_feval_ll::calleval; -%feature("nodirector") gr_py_feval::calleval; -%feature("nodirector") gr_py_feval_p::calleval; - - -%rename(feval_dd) gr_py_feval_dd; -%rename(feval_cc) gr_py_feval_cc; -%rename(feval_ll) gr_py_feval_ll; -%rename(feval) gr_py_feval; -%rename(feval_p) gr_py_feval_p; - -//%exception { -// try { $action } -// catch (Swig::DirectorException &e) { std::cerr << e.getMessage(); SWIG_fail; } -//} - -%{ - -// class that ensures we acquire and release the Python GIL - -class ensure_py_gil_state { - PyGILState_STATE d_gstate; -public: - ensure_py_gil_state() { d_gstate = PyGILState_Ensure(); } - ~ensure_py_gil_state() { PyGILState_Release(d_gstate); } -}; - -%} - -/* - * These are the real C++ base classes, however we don't want these exposed. - */ -%ignore gr_feval_dd; -class gr_feval_dd -{ -protected: - virtual double eval(double x); - -public: - gr_feval_dd() {} - virtual ~gr_feval_dd(); - - virtual double calleval(double x); -}; - -%ignore gr_feval_cc; -class gr_feval_cc -{ -protected: - virtual gr_complex eval(gr_complex x); - -public: - gr_feval_cc() {} - virtual ~gr_feval_cc(); - - virtual gr_complex calleval(gr_complex x); -}; - -%ignore gr_feval_ll; -class gr_feval_ll -{ -protected: - virtual long eval(long x); - -public: - gr_feval_ll() {} - virtual ~gr_feval_ll(); - - virtual long calleval(long x); -}; - -%ignore gr_feval; -class gr_feval -{ -protected: - virtual void eval(); - -public: - gr_feval() {} - virtual ~gr_feval(); - - virtual void calleval(); -}; - -%ignore gr_feval_p; -class gr_feval_p -{ -protected: - virtual void eval(pmt_t x); - -public: - gr_feval_p() {} - virtual ~gr_feval_p(); - - virtual void calleval(pmt_t x); -}; - -/* - * These are the ones to derive from in Python. They have the magic shim - * that ensures that we're holding the Python GIL when we enter Python land... - */ - -%inline %{ -#include <pmt/pmt.h> - -class gr_py_feval_dd : public gr_feval_dd -{ - public: - double calleval(double x) - { - ensure_py_gil_state _lock; - return eval(x); - } -}; - -class gr_py_feval_cc : public gr_feval_cc -{ - public: - gr_complex calleval(gr_complex x) - { - ensure_py_gil_state _lock; - return eval(x); - } -}; - -class gr_py_feval_ll : public gr_feval_ll -{ - public: - long calleval(long x) - { - ensure_py_gil_state _lock; - return eval(x); - } -}; - -class gr_py_feval : public gr_feval -{ - public: - void calleval() - { - ensure_py_gil_state _lock; - eval(); - } -}; - -class gr_py_feval_p : public gr_feval_p -{ - public: - void calleval(pmt::pmt_t x) - { - ensure_py_gil_state _lock; - eval(x); - } -}; - -%} - - - -// examples / test cases - -%rename(feval_dd_example) gr_feval_dd_example; -double gr_feval_dd_example(gr_feval_dd *f, double x); - -%rename(feval_cc_example) gr_feval_cc_example; -gr_complex gr_feval_cc_example(gr_feval_cc *f, gr_complex x); - -%rename(feval_ll_example) gr_feval_ll_example; -long gr_feval_ll_example(gr_feval_ll *f, long x); - -%rename(feval_example) gr_feval_example; -void gr_feval_example(gr_feval *f); - -#endif // SWIGPYTHON diff --git a/gnuradio-runtime/swig/gr_hier_block2.i b/gnuradio-runtime/swig/gr_hier_block2.i deleted file mode 100644 index a857394ca7..0000000000 --- a/gnuradio-runtime/swig/gr_hier_block2.i +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2006,2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -%include <gr_basic_block.i> - -class gr_hier_block2; -typedef boost::shared_ptr<gr_hier_block2> gr_hier_block2_sptr; -%template(gr_hier_block2_sptr) boost::shared_ptr<gr_hier_block2>; - -// Hack to have a Python shim implementation of gr.hier_block2 -// that instantiates one of these and passes through calls -%rename(hier_block2_swig) gr_make_hier_block2; -gr_hier_block2_sptr gr_make_hier_block2(const std::string name, - gr_io_signature_sptr input_signature, - gr_io_signature_sptr output_signature) - throw (std::runtime_error); - -// Rename connect and disconnect so that we can more easily build a -// better interface in scripting land. -%rename(primitive_connect) gr_hier_block2::connect; -%rename(primitive_disconnect) gr_hier_block2::disconnect; -%rename(primitive_msg_connect) gr_hier_block2::msg_connect; -%rename(primitive_msg_disconnect) gr_hier_block2::msg_disconnect; -%rename(primitive_message_port_register_hier_in) gr_hier_block2::message_port_register_hier_in; -%rename(primitive_message_port_register_hier_out) gr_hier_block2::message_port_register_hier_out; - -class gr_hier_block2 : public gr_basic_block -{ -private: - gr_hier_block2(const std::string name, - gr_io_signature_sptr input_signature, - gr_io_signature_sptr output_signature); - -public: - ~gr_hier_block2 (); - - void connect(gr_basic_block_sptr block) - throw (std::invalid_argument); - void connect(gr_basic_block_sptr src, int src_port, - gr_basic_block_sptr dst, int dst_port) - throw (std::invalid_argument); - void msg_connect(gr_basic_block_sptr src, pmt::pmt_t srcport, - gr_basic_block_sptr dst, pmt::pmt_t dstport) - throw (std::runtime_error); - void msg_connect(gr_basic_block_sptr src, std::string srcport, - gr_basic_block_sptr dst, std::string dstport) - throw (std::runtime_error); - void msg_disconnect(gr_basic_block_sptr src, pmt::pmt_t srcport, - gr_basic_block_sptr dst, pmt::pmt_t dstport) - throw (std::runtime_error); - void msg_disconnect(gr_basic_block_sptr src, std::string srcport, - gr_basic_block_sptr dst, std::string dstport) - throw (std::runtime_error); - - void disconnect(gr_basic_block_sptr block) - throw (std::invalid_argument); - void disconnect(gr_basic_block_sptr src, int src_port, - gr_basic_block_sptr dst, int dst_port) - throw (std::invalid_argument); - void disconnect_all(); - void lock(); - void unlock(); - - void message_port_register_hier_in(pmt::pmt_t port_id); - void message_port_register_hier_out(pmt::pmt_t port_id); - - - gr_hier_block2_sptr to_hier_block2(); // Needed for Python type coercion -}; diff --git a/gnuradio-runtime/swig/gr_io_signature.i b/gnuradio-runtime/swig/gr_io_signature.i deleted file mode 100644 index fe1707e410..0000000000 --- a/gnuradio-runtime/swig/gr_io_signature.i +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005,2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -class gr_io_signature; -typedef boost::shared_ptr<gr_io_signature> gr_io_signature_sptr; -%template(gr_io_signature_sptr) boost::shared_ptr<gr_io_signature>; - -%rename(io_signature) gr_make_io_signature; -%rename(io_signature2) gr_make_io_signature2; -%rename(io_signature3) gr_make_io_signature3; -%rename(io_signaturev) gr_make_io_signaturev; - - -gr_io_signature_sptr -gr_make_io_signature(int min_streams, int max_streams, - int sizeof_stream_item); - -gr_io_signature_sptr -gr_make_io_signature2(int min_streams, int max_streams, - int sizeof_stream_item1, - int sizeof_stream_item2 - ); -gr_io_signature_sptr -gr_make_io_signature3(int min_streams, int max_streams, - int sizeof_stream_item1, - int sizeof_stream_item2, - int sizeof_stream_item3 - ); -gr_io_signature_sptr -gr_make_io_signaturev(int min_streams, int max_streams, - const std::vector<int> &sizeof_stream_items); - - -class gr_io_signature { - gr_io_signature (int min_streams, int max_streams, int sizeof_stream_item); - - friend gr_io_signature_sptr - gr_make_io_signaturev(int min_streams, - int max_streams, - const std::vector<int> &sizeof_stream_item); - - public: - - // disabled. Suspected bug in SWIG 1.3.24 - // static const int IO_INFINITE = -1; - - ~gr_io_signature (); - - int min_streams () const { return d_min_streams; } - int max_streams () const { return d_max_streams; } - int sizeof_stream_item (int index) const; - std::vector<int> sizeof_stream_items() const; -}; - diff --git a/gnuradio-runtime/swig/gr_logger.i b/gnuradio-runtime/swig/gr_logger.i index b43bff5a89..d87ee01b44 100644 --- a/gnuradio-runtime/swig/gr_logger.i +++ b/gnuradio-runtime/swig/gr_logger.i @@ -41,39 +41,43 @@ %{ // The .h files -#include <gr_logger.h> +#include <gnuradio/logger.h> %} -%rename(logger) gr_logger; -%rename(logger_config) gr_logger_config; -%rename(logger_get_names) gr_logger_get_logger_names; -%rename(logger_reset_config) gr_logger_reset_config; +%rename(logger) gr::logger; +%rename(logger_config) gr::logger_config; +%rename(logger_get_names) gr::logger_get_logger_names; +%rename(logger_reset_config) gr::logger_reset_config; +namespace gr { -void gr_logger_config(const std::string config_filename,unsigned int watch_period = 0); -std::vector<std::string> gr_logger_get_logger_names(void); -void gr_logger_reset_config(void); + void logger_config(const std::string config_filename, unsigned int watch_period = 0); + std::vector<std::string> logger_get_logger_names(void); + void logger_reset_config(void); -class gr_logger -{ - public: - gr_logger(std::string logger_name); - void set_level(std::string level){GR_LOG_SET_LEVEL(d_logger,level);} - void get_level(std::string &level){GR_LOG_GET_LEVEL(d_logger,level);} - void debug(std::string msg){GR_LOG_DEBUG(d_logger,msg);}; - void info(std::string msg){GR_LOG_INFO(d_logger,msg);}; - void notice(std::string msg){GR_LOG_NOTICE(d_logger,msg);}; - void warn(std::string msg){GR_LOG_WARN(d_logger,msg);}; - void error(std::string msg){GR_LOG_ERROR(d_logger,msg);}; - void crit(std::string msg){GR_LOG_CRIT(d_logger,msg);}; - void alert(std::string msg){GR_LOG_ALERT(d_logger,msg);}; - void fatal(std::string msg){GR_LOG_FATAL(d_logger,msg);}; - void emerg(std::string msg){GR_LOG_EMERG(d_logger,msg);}; - void errorIF(bool cond,std::string msg){GR_LOG_ERRORIF(d_logger,cond,msg);}; - void log_assert(bool cond,std::string msg){GR_LOG_ASSERT(d_logger,cond,msg);}; + class logger + { + public: + logger(std::string logger_name); + void set_level(std::string level){LOG_SET_LEVEL(d_logger,level);} + void get_level(std::string &level){LOG_GET_LEVEL(d_logger,level);} + void debug(std::string msg){LOG_DEBUG(d_logger,msg);}; + void info(std::string msg){LOG_INFO(d_logger,msg);}; + void notice(std::string msg){LOG_NOTICE(d_logger,msg);}; + void warn(std::string msg){LOG_WARN(d_logger,msg);}; + void error(std::string msg){LOG_ERROR(d_logger,msg);}; + void crit(std::string msg){LOG_CRIT(d_logger,msg);}; + void alert(std::string msg){LOG_ALERT(d_logger,msg);}; + void fatal(std::string msg){LOG_FATAL(d_logger,msg);}; + void emerg(std::string msg){LOG_EMERG(d_logger,msg);}; + void errorIF(bool cond,std::string msg){LOG_ERRORIF(d_logger,cond,msg);}; + void log_assert(bool cond,std::string msg){LOG_ASSERT(d_logger,cond,msg);}; void add_console_appender(std::string target,std::string pattern); void add_file_appender(std::string filename,bool append,std::string pattern); - void add_rollingfile_appender(std::string filename,size_t filesize,int bkup_index,bool append,mode_t mode,std::string pattern); -}; + void add_rollingfile_appender(std::string filename, size_t filesize, + int bkup_index, bool append, mode_t mode, + std::string pattern); + }; +} /* namespace gr */ diff --git a/gnuradio-runtime/swig/gr_message.i b/gnuradio-runtime/swig/gr_message.i deleted file mode 100644 index 356bba5b58..0000000000 --- a/gnuradio-runtime/swig/gr_message.i +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 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. - */ - -class gr_message; -typedef boost::shared_ptr<gr_message> gr_message_sptr; -%template(gr_message_sptr) boost::shared_ptr<gr_message>; - -%rename(message_from_string) gr_make_message_from_string; -gr_message_sptr -gr_make_message_from_string(const std::string s, long type = 0, double arg1 = 0, double arg2 = 0); - -%rename(message) gr_make_message; -gr_message_sptr -gr_make_message(long type = 0, double arg1 = 0, double arg2 = 0, size_t length = 0); - -/*! - * \brief Message. - * - * The ideas and method names for adjustable message length were - * lifted from the click modular router "Packet" class. - */ -class gr_message { - gr_message (long type, double arg1, double arg2, size_t length); - - unsigned char *buf_data() const { return d_buf_start; } - size_t buf_len() const { return d_buf_end - d_buf_start; } - -public: - ~gr_message (); - - long type() const { return d_type; } - double arg1() const { return d_arg1; } - double arg2() const { return d_arg2; } - - void set_type(long type) { d_type = type; } - void set_arg1(double arg1) { d_arg1 = arg1; } - void set_arg2(double arg2) { d_arg2 = arg2; } - - size_t length() const; - std::string to_string() const; - -}; - -%rename(message_ncurrently_allocated) gr_message_ncurrently_allocated; -long gr_message_ncurrently_allocated(); - diff --git a/gnuradio-runtime/swig/gr_msg_queue.i b/gnuradio-runtime/swig/gr_msg_queue.i deleted file mode 100644 index 65cbe782b9..0000000000 --- a/gnuradio-runtime/swig/gr_msg_queue.i +++ /dev/null @@ -1,107 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2009,2010,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. - */ - -class gr_msg_queue; -typedef boost::shared_ptr<gr_msg_queue> gr_msg_queue_sptr; -%template(gr_msg_queue_sptr) boost::shared_ptr<gr_msg_queue>; - -%rename(msg_queue) gr_make_msg_queue; -gr_msg_queue_sptr gr_make_msg_queue(unsigned limit=0); - -/*! - * \brief thread-safe message queue - */ -%ignore gr_msg_queue; -class gr_msg_queue : public gr_msg_handler { -public: - gr_msg_queue(unsigned int limit); - ~gr_msg_queue(); - - //! Generic msg_handler method: insert the message. - //void handle(gr_message_sptr msg) { insert_tail (msg); } - - /*! - * \brief Insert message at tail of queue. - * \param msg message - * - * Block if queue if full. - */ - //void insert_tail(gr_message_sptr msg); - - /*! - * \brief Delete message from head of queue and return it. - * Block if no message is available. - */ - //gr_message_sptr delete_head(); - - /*! - * \brief If there's a message in the q, delete it and return it. - * If no message is available, return 0. - */ - gr_message_sptr delete_head_nowait(); - - //! is the queue empty? - bool empty_p() const; - - //! is the queue full? - bool full_p() const; - - //! return number of messages in queue - unsigned int count() const; - - //! Delete all messages from the queue - void flush(); -}; - -/* - * The following kludge-o-rama releases the Python global interpreter - * lock around these potentially blocking calls. We don't want - * libgnuradio-core to be dependent on Python, thus we create these - * functions that serve as replacements for the normal C++ delete_head - * and insert_tail methods. The %pythoncode smashes these new C++ - * functions into the gr.msg_queue wrapper class, so that everything - * appears normal. (An evil laugh is heard in the distance...) - */ -#ifdef SWIGPYTHON -%inline %{ - gr_message_sptr gr_py_msg_queue__delete_head(gr_msg_queue_sptr q) { - gr_message_sptr msg; - GR_PYTHON_BLOCKING_CODE( - msg = q->delete_head(); - ) - return msg; - } - - void gr_py_msg_queue__insert_tail(gr_msg_queue_sptr q, gr_message_sptr msg) { - GR_PYTHON_BLOCKING_CODE( - q->insert_tail(msg); - ) - } -%} - -// smash in new python delete_head and insert_tail methods... -%pythoncode %{ -gr_msg_queue_sptr.delete_head = gr_py_msg_queue__delete_head -gr_msg_queue_sptr.insert_tail = gr_py_msg_queue__insert_tail -gr_msg_queue_sptr.handle = gr_py_msg_queue__insert_tail -%} -#endif // SWIGPYTHON diff --git a/gnuradio-runtime/swig/gr_types.i b/gnuradio-runtime/swig/gr_types.i index b9bf3ba80b..65577bf35b 100644 --- a/gnuradio-runtime/swig/gr_types.i +++ b/gnuradio-runtime/swig/gr_types.i @@ -30,7 +30,7 @@ #include <string> #include <stddef.h> // size_t #include <stdint.h> -#include <gr_types.h> +#include <gnuradio/types.h> %} %include <std_complex.i> diff --git a/gnuradio-runtime/swig/hier_block2.i b/gnuradio-runtime/swig/hier_block2.i new file mode 100644 index 0000000000..b455e02a7e --- /dev/null +++ b/gnuradio-runtime/swig/hier_block2.i @@ -0,0 +1,92 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005-2007,2013 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 <basic_block.i> + +class gr::hier_block2; +typedef boost::shared_ptr<gr::hier_block2> gr::hier_block2_sptr; +%template(hier_block2_sptr) boost::shared_ptr<gr::hier_block2>; + +namespace gr { + // Hack to have a Python shim implementation of gr.hier_block2 + // that instantiates one of these and passes through calls + %rename(hier_block2_swig) make_hier_block2; + gr::hier_block2_sptr + make_hier_block2(const std::string name, + gr::io_signature::sptr input_signature, + gr::io_signature::sptr output_signature) + throw (std::runtime_error); +} + +// Rename connect and disconnect so that we can more easily build a +// better interface in scripting land. +%rename(primitive_connect) gr::hier_block2::connect; +%rename(primitive_disconnect) gr::hier_block2::disconnect; +%rename(primitive_msg_connect) gr::hier_block2::msg_connect; +%rename(primitive_msg_disconnect) gr::hier_block2::msg_disconnect; +%rename(primitive_message_port_register_hier_in) gr::hier_block2::message_port_register_hier_in; +%rename(primitive_message_port_register_hier_out) gr::hier_block2::message_port_register_hier_out; + +namespace gr { + class hier_block2 : public gr::basic_block + { + private: + hier_block2(const std::string name, + gr::io_signature::sptr input_signature, + gr::io_signature::sptr output_signature); + + public: + ~hier_block2 (); + + void connect(gr::basic_block_sptr block) + throw (std::invalid_argument); + void connect(gr::basic_block_sptr src, int src_port, + gr::basic_block_sptr dst, int dst_port) + throw (std::invalid_argument); + void msg_connect(gr::basic_block_sptr src, pmt::pmt_t srcport, + gr::basic_block_sptr dst, pmt::pmt_t dstport) + throw (std::runtime_error); + void msg_connect(gr::basic_block_sptr src, std::string srcport, + gr::basic_block_sptr dst, std::string dstport) + throw (std::runtime_error); + void msg_disconnect(gr::basic_block_sptr src, pmt::pmt_t srcport, + gr::basic_block_sptr dst, pmt::pmt_t dstport) + throw (std::runtime_error); + void msg_disconnect(gr::basic_block_sptr src, std::string srcport, + gr::basic_block_sptr dst, std::string dstport) + throw (std::runtime_error); + + void disconnect(gr::basic_block_sptr block) + throw (std::invalid_argument); + void disconnect(gr::basic_block_sptr src, int src_port, + gr::basic_block_sptr dst, int dst_port) + throw (std::invalid_argument); + void disconnect_all(); + void lock(); + void unlock(); + + void message_port_register_hier_in(pmt::pmt_t port_id); + void message_port_register_hier_out(pmt::pmt_t port_id); + + gr::hier_block2_sptr to_hier_block2(); // Needed for Python type coercion + }; +} diff --git a/gnuradio-runtime/swig/io_signature.i b/gnuradio-runtime/swig/io_signature.i new file mode 100644 index 0000000000..53cde17bff --- /dev/null +++ b/gnuradio-runtime/swig/io_signature.i @@ -0,0 +1,69 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2005,2007,2013 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. + */ + +namespace gr { + + class GR_RUNTIME_API io_signature + { + io_signature(int min_streams, int max_streams, + const std::vector<int> &sizeof_stream_items); + + public: + typedef boost::shared_ptr<io_signature> sptr; + + // Avoids a swig warning, otherwise we could just + // #include <gnuradio/io_signature.h> instead of redoing this + // #entire class + //static const int IO_INFINITE = -1; + + ~io_signature(); + + + static sptr make(int min_streams, int max_streams, + int sizeof_stream_item); + static sptr make2(int min_streams, int max_streams, + int sizeof_stream_item1, + int sizeof_stream_item2); + static sptr make3(int min_streams, int max_streams, + int sizeof_stream_item1, + int sizeof_stream_item2, + int sizeof_stream_item3); + static sptr makev(int min_streams, int max_streams, + const std::vector<int> &sizeof_stream_items); + + int min_streams() const { return d_min_streams; } + int max_streams() const { return d_max_streams; } + int sizeof_stream_item(int index) const; + std::vector<int> sizeof_stream_items() const; + }; + +} /* namespace gr */ + + +%template(io_signature_sptr) boost::shared_ptr<gr::io_signature>; +%pythoncode %{ +io_signature_sptr.__repr__ = lambda self: "<io_signature: %d, %d>" % (self.min_streams(), self.max_streams()) +io_signaturev = io_signature.makev; +io_signature3 = io_signature.make3; +io_signature2 = io_signature.make2; +io_signature = io_signature.make; +%} diff --git a/gnuradio-runtime/swig/message.i b/gnuradio-runtime/swig/message.i new file mode 100644 index 0000000000..ac13c40641 --- /dev/null +++ b/gnuradio-runtime/swig/message.i @@ -0,0 +1,70 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2013 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. + */ + +namespace gr { + + /*! + * \brief Message. + * + * The ideas and method names for adjustable message length were + * lifted from the click modular router "Packet" class. + */ + class message + { + public: + typedef boost::shared_ptr<message> sptr; + + private: + message(long type, double arg1, double arg2, size_t length); + + unsigned char *buf_data() const; + size_t buf_len() const; + + public: + static sptr make(long type = 0, double arg1 = 0, double arg2 = 0, size_t length = 0); + + static sptr make_from_string(const std::string s, long type = 0, + double arg1 = 0, double arg2 = 0); + + ~message(); + + long type() const; + double arg1() const; + double arg2() const; + + void set_type(long type); + void set_arg1(double arg1); + void set_arg2(double arg2); + + size_t length() const; + std::string to_string() const; + }; + + %rename(message_ncurrently_allocated) message_ncurrently_allocated; + long message_ncurrently_allocated(); +} + +%template(message_sptr) boost::shared_ptr<gr::message>; +%pythoncode %{ +message_from_string = message.make_from_string +message = message.make +%} diff --git a/gnuradio-runtime/swig/gr_msg_handler.i b/gnuradio-runtime/swig/msg_handler.i index f493dac1b2..6869152889 100644 --- a/gnuradio-runtime/swig/gr_msg_handler.i +++ b/gnuradio-runtime/swig/msg_handler.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005 Free Software Foundation, Inc. + * Copyright 2005,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -23,10 +23,11 @@ /*! * \brief abstract class of message handlers */ -class gr_msg_handler { +class gr::msg_handler +{ public: - virtual ~gr_msg_handler () = 0; + virtual ~msg_handler () = 0; //! handle \p msg - virtual void handle (gr_message_sptr msg) = 0; + virtual void handle(gr::message::sptr msg) = 0; }; diff --git a/gnuradio-runtime/swig/msg_queue.i b/gnuradio-runtime/swig/msg_queue.i new file mode 100644 index 0000000000..59dff158ce --- /dev/null +++ b/gnuradio-runtime/swig/msg_queue.i @@ -0,0 +1,108 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2009-2011,2013 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. + */ + +namespace gr { + /*! + * \brief thread-safe message queue + */ + class msg_queue : public gr::msg_handler + { + public: + typedef boost::shared_ptr<msg_queue> sptr; + + static sptr make(unsigned int limit=0); + + msg_queue(unsigned int limit); + ~msg_queue(); + + //! Generic msg_handler method: insert the message. + //void handle(gr::message::sptr msg) { insert_tail (msg); } + + /*! + * \brief Insert message at tail of queue. + * \param msg message + * + * Block if queue if full. + */ + //void insert_tail(gr::message::sptr msg); + + /*! + * \brief Delete message from head of queue and return it. + * Block if no message is available. + */ + //gr::message::sptr delete_head(); + + /*! + * \brief If there's a message in the q, delete it and return it. + * If no message is available, return 0. + */ + gr::message::sptr delete_head_nowait(); + + //! is the queue empty? + bool empty_p() const; + + //! is the queue full? + bool full_p() const; + + //! return number of messages in queue + unsigned int count() const; + + //! Delete all messages from the queue + void flush(); + }; +} + +/* + * The following kludge-o-rama releases the Python global interpreter + * lock around these potentially blocking calls. We don't want + * libgnuradio-core to be dependent on Python, thus we create these + * functions that serve as replacements for the normal C++ delete_head + * and insert_tail methods. The %pythoncode smashes these new C++ + * functions into the gr.msg_queue wrapper class, so that everything + * appears normal. (An evil laugh is heard in the distance...) + */ +#ifdef SWIGPYTHON +%inline %{ + gr::message::sptr py_msg_queue__delete_head(gr::msg_queue::sptr q) { + gr::message::sptr msg; + GR_PYTHON_BLOCKING_CODE( + msg = q->delete_head(); + ) + return msg; + } + + void py_msg_queue__insert_tail(gr::msg_queue::sptr q, gr::message::sptr msg) { + GR_PYTHON_BLOCKING_CODE( + q->insert_tail(msg); + ) + } +%} + +// smash in new python delete_head and insert_tail methods... +%template(msg_queue_sptr) boost::shared_ptr<gr::msg_queue>; +%pythoncode %{ +msg_queue_sptr.delete_head = py_msg_queue__delete_head +msg_queue_sptr.insert_tail = py_msg_queue__insert_tail +msg_queue_sptr.handle = py_msg_queue__insert_tail +msg_queue = msg_queue.make +%} +#endif // SWIGPYTHON diff --git a/gnuradio-runtime/swig/gr_prefs.i b/gnuradio-runtime/swig/prefs.i index c8c4242002..f56c7910ee 100644 --- a/gnuradio-runtime/swig/gr_prefs.i +++ b/gnuradio-runtime/swig/prefs.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,13 +20,13 @@ * Boston, MA 02110-1301, USA. */ -class gr_prefs +class gr::prefs { public: - static gr_prefs *singleton(); - static void set_singleton(gr_prefs *p); + static gr::prefs *singleton(); + static void set_singleton(gr::prefs *p); - virtual ~gr_prefs(); + virtual ~prefs(); std::string to_string(); diff --git a/gnuradio-runtime/swig/gr_realtime.i b/gnuradio-runtime/swig/realtime.i index 4d5c2b856f..d408249a19 100644 --- a/gnuradio-runtime/swig/gr_realtime.i +++ b/gnuradio-runtime/swig/realtime.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008 Free Software Foundation, Inc. + * Copyright 2008,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,25 +20,26 @@ * Boston, MA 02110-1301, USA. */ -%rename(enable_realtime_scheduling) gr_enable_realtime_scheduling; +%rename(enable_realtime_scheduling) gr::enable_realtime_scheduling; -// NOTE: This is duplicated from gnuradio-runtime/include/gr_realtime.h, +// NOTE: This is duplicated from gnuradio-runtime/include/realtime.h, // and must be kept in sync with it. This is the least evil workaround // for allowing 3rd party code builds to work when GNU Radio is // installed from binary packages into the standard system directories. -// Otherwise, they can't find #include <gr_realtime.h>, since +// Otherwise, they can't find #include <realtime.h>, since // pkg-config strips -I/usr/include from the --cflags path. namespace gr { + namespace impl { - typedef enum { - RT_OK = 0, - RT_NOT_IMPLEMENTED, - RT_NO_PRIVS, - RT_OTHER_ERROR - } rt_status_t; - + typedef enum { + RT_OK = 0, + RT_NOT_IMPLEMENTED, + RT_NO_PRIVS, + RT_OTHER_ERROR + } rt_status_t; + } } -typedef gr::rt_status_t gr_rt_status_t; -gr_rt_status_t gr_enable_realtime_scheduling(); +typedef gr::rt_status_t rt_status_t; +rt_status_t gr::enable_realtime_scheduling(); diff --git a/gnuradio-runtime/swig/runtime_swig.i b/gnuradio-runtime/swig/runtime_swig.i index ae3d1d7dcb..163d4748ec 100644 --- a/gnuradio-runtime/swig/runtime_swig.i +++ b/gnuradio-runtime/swig/runtime_swig.i @@ -33,29 +33,34 @@ %include "gnuradio.i" // the common stuff %{ -#include <gr_endianness.h> -#include <gr_block.h> -#include <gr_block_detail.h> -#include <gr_buffer.h> -#include <gr_constants.h> -#include <gr_dispatcher.h> -#include <gr_error_handler.h> -#include <gr_feval.h> -#include <gr_hier_block2.h> -#include <gr_io_signature.h> -#include <gr_message.h> -#include <gr_msg_handler.h> -#include <gr_msg_queue.h> -#include <gr_prefs.h> -#include <gr_realtime.h> -#include <gr_runtime_types.h> -#include <gr_single_threaded_scheduler.h> -#include <gr_sync_block.h> -#include <gr_sync_decimator.h> -#include <gr_sync_interpolator.h> -#include <gr_tagged_stream_block.h> -#include <gr_tags.h> -#include <gr_top_block.h> +#include <gnuradio/runtime_types.h> +%} + +%include <gnuradio/runtime_types.h> + +%{ +#include <gnuradio/block.h> +#include <gnuradio/block_detail.h> +#include <gnuradio/buffer.h> +#include <gnuradio/constants.h> +#include <gnuradio/dispatcher.h> +#include <gnuradio/endianness.h> +#include <gnuradio/error_handler.h> +#include <gnuradio/feval.h> +#include <gnuradio/hier_block2.h> +#include <gnuradio/io_signature.h> +#include <gnuradio/message.h> +#include <gnuradio/msg_handler.h> +#include <gnuradio/msg_queue.h> +#include <gnuradio/prefs.h> +#include <gnuradio/realtime.h> +#include <gnuradio/single_threaded_scheduler.h> +#include <gnuradio/sync_block.h> +#include <gnuradio/sync_decimator.h> +#include <gnuradio/sync_interpolator.h> +#include <gnuradio/tags.h> +#include <gnuradio/tagged_stream_block.h> +#include <gnuradio/top_block.h> %} %constant int sizeof_char = sizeof(char); @@ -65,30 +70,30 @@ %constant int sizeof_double = sizeof(double); %constant int sizeof_gr_complex = sizeof(gr_complex); -%include <gr_endianness.h> -%include <gr_basic_block.i> -%include <gr_block.i> -%include <gr_block_detail.i> -%include <gr_buffer.i> -%include <gr_constants.i> -%include <gr_dispatcher.i> -%include <gr_error_handler.i> -%include <gr_feval.i> -%include <gr_hier_block2.i> -%include <gr_io_signature.i> -%include <gr_message.i> -%include <gr_msg_handler.i> -%include <gr_msg_queue.i> -%include <gr_prefs.i> -%include <gr_realtime.i> -%include <gr_single_threaded_scheduler.i> -%include <gr_swig_block_magic.i> -%include <gr_sync_block.i> -%include <gr_sync_decimator.i> -%include <gr_sync_interpolator.i> -%include <gr_tagged_stream_block.i> -%include <gr_tags.i> -%include <gr_top_block.i> -%include <runtime_block_gateway.i> +%include <gnuradio/endianness.h> +%include <basic_block.i> +%include <block.i> +%include <block_detail.i> +%include <buffer.i> +%include <constants.i> +%include <dispatcher.i> +%include <feval.i> +%include <error_handler.i> +%include <hier_block2.i> +%include <io_signature.i> +%include <message.i> +%include <msg_handler.i> +%include <msg_queue.i> +%include <prefs.i> +%include <realtime.i> +%include <single_threaded_scheduler.i> +%include <sync_block.i> +%include <sync_decimator.i> +%include <sync_interpolator.i> +%include <tagged_stream_block.i> +%include <tags.i> +%include <top_block.i> +%include <block_gateway.i> +%include <gr_swig_block_magic.i> %include <gr_ctrlport.i> diff --git a/gnuradio-runtime/swig/gr_single_threaded_scheduler.i b/gnuradio-runtime/swig/single_threaded_scheduler.i index 7305cc9ada..f4fbed075c 100644 --- a/gnuradio-runtime/swig/gr_single_threaded_scheduler.i +++ b/gnuradio-runtime/swig/single_threaded_scheduler.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2004,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,31 +20,31 @@ * Boston, MA 02110-1301, USA. */ -#include <gr_runtime.h> +#include <gnuradio/runtime.h> -class gr_single_threaded_scheduler; -typedef boost::shared_ptr<gr_single_threaded_scheduler> gr_single_threaded_scheduler_sptr; -%template(gr_single_threaded_scheduler_sptr) boost::shared_ptr<gr_single_threaded_scheduler>; -%rename(single_threaded_scheduler) gr_make_single_threaded_scheduler; -%ignore gr_single_threaded_scheduler; +class gr::single_threaded_scheduler; +typedef boost::shared_ptr<gr::single_threaded_scheduler> gr::single_threaded_scheduler_sptr; +%template(single_threaded_scheduler_sptr) boost::shared_ptr<gr::single_threaded_scheduler>; +%rename(single_threaded_scheduler) gr::make_single_threaded_scheduler; +%ignore gr::single_threaded_scheduler; -gr_single_threaded_scheduler_sptr -gr_make_single_threaded_scheduler (const std::vector<gr_block_sptr> &modules); +gr::single_threaded_scheduler_sptr +gr::make_single_threaded_scheduler(const std::vector<gr::block_sptr> &modules); -class gr_single_threaded_scheduler { +class gr::single_threaded_scheduler { public: - ~gr_single_threaded_scheduler (); + ~single_threaded_scheduler (); // void run (); void stop (); private: - gr_single_threaded_scheduler (const std::vector<gr_block_sptr> &modules); + single_threaded_scheduler (const std::vector<block_sptr> &modules); }; #ifdef SWIGPYTHON %inline %{ - void sts_pyrun (gr_single_threaded_scheduler_sptr s) { + void sts_pyrun (gr::single_threaded_scheduler_sptr s) { Py_BEGIN_ALLOW_THREADS; // release global interpreter lock s->run (); Py_END_ALLOW_THREADS; // acquire global interpreter lock diff --git a/gnuradio-runtime/swig/gr_sync_block.i b/gnuradio-runtime/swig/sync_block.i index d3e1bb9578..892e58e4a0 100644 --- a/gnuradio-runtime/swig/gr_sync_block.i +++ b/gnuradio-runtime/swig/sync_block.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2004,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -19,11 +19,12 @@ * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ -class gr_sync_block : public gr_block + +class gr::sync_block : public gr::block { protected: - gr_sync_block (const std::string &name, - gr_io_signature_sptr input_signature, - gr_io_signature_sptr output_signature); + sync_block(const std::string &name, + gr::io_signature::sptr input_signature, + gr::io_signature::sptr output_signature); }; diff --git a/gnuradio-runtime/swig/gr_sync_decimator.i b/gnuradio-runtime/swig/sync_decimator.i index af4574b193..9c0506bd54 100644 --- a/gnuradio-runtime/swig/gr_sync_decimator.i +++ b/gnuradio-runtime/swig/sync_decimator.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2004,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,12 +20,12 @@ * Boston, MA 02110-1301, USA. */ -class gr_sync_decimator : public gr_sync_block +class gr::sync_decimator : public gr::sync_block { protected: - gr_sync_decimator (const std::string &name, - gr_io_signature_sptr input_signature, - gr_io_signature_sptr output_signature, - unsigned decimation); + sync_decimator(const std::string &name, + gr::io_signature::sptr input_signature, + gr::io_signature::sptr output_signature, + unsigned decimation); }; diff --git a/gnuradio-runtime/swig/gr_sync_interpolator.i b/gnuradio-runtime/swig/sync_interpolator.i index 6f8b08252f..9ebbb460dd 100644 --- a/gnuradio-runtime/swig/gr_sync_interpolator.i +++ b/gnuradio-runtime/swig/sync_interpolator.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2004,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,12 +20,12 @@ * Boston, MA 02110-1301, USA. */ -class gr_sync_interpolator : public gr_sync_block +class gr::sync_interpolator : public gr::sync_block { protected: - gr_sync_interpolator (const std::string &name, - gr_io_signature_sptr input_signature, - gr_io_signature_sptr output_signature, - unsigned interpolation); + sync_interpolator(const std::string &name, + gr::io_signature::sptr input_signature, + gr::io_signature::sptr output_signature, + unsigned interpolation); }; diff --git a/gnuradio-runtime/swig/gr_tagged_stream_block.i b/gnuradio-runtime/swig/tagged_stream_block.i index 9fc803dca1..10943f58de 100644 --- a/gnuradio-runtime/swig/gr_tagged_stream_block.i +++ b/gnuradio-runtime/swig/tagged_stream_block.i @@ -19,12 +19,13 @@ * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ -class gr_tagged_stream_block : public gr_block + +class gr::tagged_stream_block : public gr::block { protected: - gr_tagged_stream_block (const std::string &name, - gr_io_signature_sptr input_signature, - gr_io_signature_sptr output_signature, - const std::string &length_tag_key); + tagged_stream_block(const std::string &name, + gr::io_signature::sptr input_signature, + gr::io_signature::sptr output_signature, + const std::string &length_tag_key); }; diff --git a/gnuradio-runtime/swig/gr_tags.i b/gnuradio-runtime/swig/tags.i index 828d0147ce..f466e9f60b 100644 --- a/gnuradio-runtime/swig/gr_tags.i +++ b/gnuradio-runtime/swig/tags.i @@ -1,5 +1,5 @@ /* - * Copyright 2011 Free Software Foundation, Inc. + * Copyright 2011,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,13 +20,13 @@ */ %{ -#include <gr_tags.h> +#include <gnuradio/tags.h> %} %include <pmt_swig.i> //for pmt support -%include <gr_tags.h> +%include <gnuradio/tags.h> //gives support for a vector of tags (get tags in range) %include "std_vector.i" -%template(tags_vector_t) std::vector<gr_tag_t>; +%template(tags_vector_t) std::vector<gr::tag_t>; diff --git a/gnuradio-runtime/swig/gr_top_block.i b/gnuradio-runtime/swig/top_block.i index 1612ddf8c5..7639403393 100644 --- a/gnuradio-runtime/swig/gr_top_block.i +++ b/gnuradio-runtime/swig/top_block.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007,2008,2010 Free Software Foundation, Inc. + * Copyright 2007,2008,2010,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,50 +20,50 @@ * Boston, MA 02110-1301, USA. */ -class gr_top_block; -typedef boost::shared_ptr<gr_top_block> gr_top_block_sptr; -%template(gr_top_block_sptr) boost::shared_ptr<gr_top_block>; +%template(top_block_sptr) boost::shared_ptr<gr::top_block>; -// Hack to have a Python shim implementation of gr.top_block -// that instantiates one of these and passes through calls -%rename(top_block_swig) gr_make_top_block; -gr_top_block_sptr gr_make_top_block(const std::string name) - throw (std::logic_error); +namespace gr { + // Hack to have a Python shim implementation of gr.top_block + // that instantiates one of these and passes through calls + %rename(top_block_swig) make_top_block; + gr::top_block_sptr make_top_block(const std::string name) + throw (std::logic_error); -class gr_top_block : public gr_hier_block2 -{ -private: - gr_top_block(const std::string &name); - -public: - ~gr_top_block(); + class top_block : public gr::hier_block2 + { + private: + top_block(const std::string &name); - void start(int max_noutput_items=100000000) throw (std::runtime_error); - void stop(); - //void wait(); - //void run() throw (std::runtime_error); - void lock(); - void unlock() throw (std::runtime_error); - std::string edge_list(); - void dump(); + public: + ~top_block(); - int max_noutput_items(); - void set_max_noutput_items(int nmax); + void start(int max_noutput_items=100000000) throw (std::runtime_error); + void stop(); + //void wait(); + //void run() throw (std::runtime_error); + void lock(); + void unlock() throw (std::runtime_error); + std::string edge_list(); + void dump(); - gr_top_block_sptr to_top_block(); // Needed for Python type coercion -}; + int max_noutput_items(); + void set_max_noutput_items(int nmax); + gr::top_block_sptr to_top_block(); // Needed for Python type coercion + }; +} + #ifdef SWIGPYTHON %inline %{ -void top_block_run_unlocked(gr_top_block_sptr r) throw (std::runtime_error) +void top_block_run_unlocked(gr::top_block_sptr r) throw (std::runtime_error) { Py_BEGIN_ALLOW_THREADS; // release global interpreter lock r->run(); Py_END_ALLOW_THREADS; // acquire global interpreter lock } -void top_block_wait_unlocked(gr_top_block_sptr r) throw (std::runtime_error) +void top_block_wait_unlocked(gr::top_block_sptr r) throw (std::runtime_error) { Py_BEGIN_ALLOW_THREADS; // release global interpreter lock r->wait(); |