From 393b21d91d8d5a7c80ea9be6a42909e4dffe385c Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 20 Aug 2012 01:18:45 -0700 Subject: runtime: lots of swig work, not over yet --- include/gnuradio/block.hpp | 4 +-- include/gnuradio/gr_block.h | 17 +++++++++- include/gnuradio/gr_hier_block2.h | 2 +- include/gnuradio/gr_sync_block.h | 7 +--- lib/block.cpp | 2 +- lib/gr_block.cpp | 12 ++++++- lib/gr_sync_block.cpp | 10 ------ swig/gr_tags.i | 32 ++++++++++++++++++ swig/runtime.i | 68 +++++++++++++++++++++++++++++++++++++++ 9 files changed, 132 insertions(+), 22 deletions(-) create mode 100644 swig/gr_tags.i create mode 100644 swig/runtime.i diff --git a/include/gnuradio/block.hpp b/include/gnuradio/block.hpp index 42f5f8d..28cb4f7 100644 --- a/include/gnuradio/block.hpp +++ b/include/gnuradio/block.hpp @@ -158,7 +158,7 @@ struct GR_RUNTIME_API Block : Element typedef std::vector > OutputItems; //! The official call into the work routine (overload please) - virtual int work( + virtual int Work( const InputItems &input_items, const OutputItems &output_items ) = 0; @@ -166,7 +166,7 @@ struct GR_RUNTIME_API Block : Element //! forcast requirements, can be overloaded virtual void forecast( int noutput_items, - std::vector &ninput_items_required + std::vector &ninput_items_required ); }; diff --git a/include/gnuradio/gr_block.h b/include/gnuradio/gr_block.h index 92f613a..bed1ef2 100644 --- a/include/gnuradio/gr_block.h +++ b/include/gnuradio/gr_block.h @@ -38,7 +38,7 @@ struct GR_RUNTIME_API gr_block : gnuradio::Block template void set_msg_handler(T msg_handler){/*LOL*/} //! implements work -> calls general work - int work( + int Work( const InputItems &input_items, const OutputItems &output_items ); @@ -63,6 +63,21 @@ struct GR_RUNTIME_API gr_block : gnuradio::Block gr_vector_const_void_star &input_items, gr_vector_void_star &output_items ) = 0; + + unsigned history(void) const + { + return gnuradio::Block::history(); + } + + void set_history(unsigned history) + { + gnuradio::Block::set_history(history); + } + + void set_alignment(const size_t alignment); + + bool is_unaligned(void); + }; typedef boost::shared_ptr gr_block_sptr; diff --git a/include/gnuradio/gr_hier_block2.h b/include/gnuradio/gr_hier_block2.h index 7bf1ae9..a8c7fbf 100644 --- a/include/gnuradio/gr_hier_block2.h +++ b/include/gnuradio/gr_hier_block2.h @@ -32,7 +32,7 @@ struct GR_RUNTIME_API gr_hier_block2 : gnuradio::HierBlock gr_io_signature_sptr output_signature ); - const Element &self(void) const + const gr_hier_block2 &self(void) const { return *this; } diff --git a/include/gnuradio/gr_sync_block.h b/include/gnuradio/gr_sync_block.h index 2cff2f1..6e5ad96 100644 --- a/include/gnuradio/gr_sync_block.h +++ b/include/gnuradio/gr_sync_block.h @@ -20,9 +20,8 @@ #include #include -struct GR_RUNTIME_API gr_sync_block : gr_block +struct GR_RUNTIME_API gr_sync_block : public gr_block { - gr_sync_block(void); gr_sync_block( @@ -41,10 +40,6 @@ struct GR_RUNTIME_API gr_sync_block : gr_block return this->work(noutput_items, input_items, output_items); } - void set_alignment(const size_t alignment); - - bool is_unaligned(void); - /*! * \brief just like gr_block::general_work, only this arranges to call consume_each for you * diff --git a/lib/block.cpp b/lib/block.cpp index 1bd1217..ce94c76 100644 --- a/lib/block.cpp +++ b/lib/block.cpp @@ -202,7 +202,7 @@ static int mylround(double x) void Block::forecast( int noutput_items, - std::vector &ninput_items_required + std::vector &ninput_items_required ){ for (size_t i = 0; i < ninput_items_required.size(); i++) { diff --git a/lib/gr_block.cpp b/lib/gr_block.cpp index 2c51f75..dfc4d0b 100644 --- a/lib/gr_block.cpp +++ b/lib/gr_block.cpp @@ -34,7 +34,7 @@ gr_block::gr_block( this->set_output_signature(output_signature); } -int gr_block::work( +int gr_block::Work( const InputItems &input_items, const OutputItems &output_items ){ @@ -45,3 +45,13 @@ int gr_block::work( (*this)->work_output_items ); } + +void gr_block::set_alignment(const size_t alignment) +{ + //TODO +} + +bool gr_block::is_unaligned(void) +{ + //TODO +} diff --git a/lib/gr_sync_block.cpp b/lib/gr_sync_block.cpp index a6a9c2b..4cc9ae7 100644 --- a/lib/gr_sync_block.cpp +++ b/lib/gr_sync_block.cpp @@ -33,16 +33,6 @@ gr_sync_block::gr_sync_block( this->set_fixed_rate(true); } -void gr_sync_block::set_alignment(const size_t alignment) -{ - //TODO -} - -bool gr_sync_block::is_unaligned(void) -{ - //TODO -} - gr_sync_interpolator::gr_sync_interpolator(void) { //NOP diff --git a/swig/gr_tags.i b/swig/gr_tags.i new file mode 100644 index 0000000..828d014 --- /dev/null +++ b/swig/gr_tags.i @@ -0,0 +1,32 @@ +/* + * 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 +%} + +%include //for pmt support + +%include + +//gives support for a vector of tags (get tags in range) +%include "std_vector.i" +%template(tags_vector_t) std::vector; diff --git a/swig/runtime.i b/swig/runtime.i new file mode 100644 index 0000000..9d06cc1 --- /dev/null +++ b/swig/runtime.i @@ -0,0 +1,68 @@ +// +// Copyright 2012 Josh Blum +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program 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 Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with io_sig program. If not, see . + +#define GR_CORE_API +#define GR_RUNTIME_API + +%constant int sizeof_char = sizeof(char); +%constant int sizeof_short = sizeof(short); +%constant int sizeof_int = sizeof(int); +%constant int sizeof_float = sizeof(float); +%constant int sizeof_double = sizeof(double); +%constant int sizeof_gr_complex = sizeof(gr_complex); + +%{ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +%} + +%include +%include +%include +%include +%include +%include +%include +%include +%include +%include +%include +%include +%include +%include +%include +%include +%include +%include + -- cgit