Tuesday, August 2, 2016

Re: [Discuss-gnuradio] SWIG std::vector issue

Thank you very much Marcus!  I'll give that a go later today :D

On Tue, Aug 2, 2016 at 2:38 AM, Marcus Müller <marcus.mueller@ettus.com> wrote:

Hi Dave,

that's a bit hard to tell without context; generally, Python can construct wrapper code for std::vector that makes those iterable, and handles the interna a bit different, but with PMTs the non-bracket method of access might work:

your_vector_of_pmts_in_python.at(index)

if that works, you can tell SWIG that your vector type should be an iterable; try going into your OOT's swig/ootname.i and add a

%include <std_vector.i>

pretty much at the beginneing, and make sure to have in your %{%}:

%{  #include <pmt/pmt.h>  #include <vector>  %}    
and further down, declare
%template(ootname_vector_pmt_t) std::vector<pmt::pmt_t>;   

And then hope that SWIG does what you want :(


Best regards,

Marcus

On 01.08.2016 23:49, Dave NotTelling wrote:
Anyone able to help with this?  I had to create helper methods to serialize the PMT objects and return a vector of strings.  Not the best solution :(

On Thu, Jul 28, 2016 at 11:04 AM, Dave NotTelling <dmp250net@gmail.com> wrote:
I have a utility lib in C++ created with 'gr_modtool add noblock' that has a function that returns a vector of pmt::pmt_t values.  I need to then be able to access the elements of that vector via Python.  Right now I get the following error when using a for loop to iterate over the vector:


TypeError: 'SwigPyObject' object is not iterable
swig/python detected a memory leak of type 'std::vector< boost::intrusive_ptr< pmt::pmt_base >,std::allocator< boost::intrusive_ptr< pmt::pmt_base > > > *', no destructor found.


How does one iterate over the elements of a std::vector<pmt::pmt_t> in Python?

Thanks!



_______________________________________________  Discuss-gnuradio mailing list  Discuss-gnuradio@gnu.org  https://lists.gnu.org/mailman/listinfo/discuss-gnuradio  


_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


No comments:

Post a Comment