[C++-sig] returning vector arrays and multiple values

Leonard Ritter paniq at paniq.org
Thu Oct 23 22:53:35 CEST 2008


thanks for your help, the solution i used was this one:

#include <boost/python.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
using namespace boost::python;

tuple py_audio_get_recording_buffer() {
    int write_ptr = 0;
    std::vector<float> buffer = audio_get_recording_buffer(write_ptr);
    return make_tuple(buffer, write_ptr);
}

BOOST_PYTHON_MODULE(nucleus) {
    class_< std::vector<float> >("vector_float")
        .def(vector_indexing_suite< std::vector<float> >());

    def("get_recording_buffer", py_audio_get_recording_buffer);
}


On Thu, Oct 23, 2008 at 4:03 PM, Stefan Seefeld <seefeld at sympatico.ca>wrote:

> object get_recording_buffer_wrapper()
> {
>  size_t write_ptr;
>  std::vector<float> buffer = get_recording_buffer(write_ptr);
>  list l;
>  for (std::vector::iterator i = buffer.begin(); i != buffer.end(); ++i)
>   l.append(*i);
>  return make_tuple(l, write_ptr);
> }
>
>
> HTH,
>      Stefan
>
> --
>
>     ...ich hab' noch einen Koffer in Berlin...
>
> _______________________________________________
> Cplusplus-sig mailing list
> Cplusplus-sig at python.org
> http://mail.python.org/mailman/listinfo/cplusplus-sig
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20081023/e942793d/attachment.htm>


More information about the Cplusplus-sig mailing list