discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Overloaded make() with pybind11


From: Franco VENTURI
Subject: Re: Overloaded make() with pybind11
Date: Fri, 22 Jan 2021 18:03:14 -0500 (EST)

If I understand correctly what you are trying to do, I think I had a similar 
problem with the pybind11 bindings when I wrote the 'gr-sdrplay3' OOT module 
for GNU Radio 3.9.

I just took a quick look at the code and I see I used 
'py::detail::overload_cast_impl' (see here: 
https://github.com/fventuri/gr-sdrplay3/blob/master/python/bindings/rspduo_python.cc).

Hope it helps,
Franco


> On 01/22/2021 4:38 PM Marcus Müller <mmueller@gnuradio.org> wrote:
> 
>  
> Hi Daniel,
> engineer's finest remark:
> 
> "That is an *interesting* problem"
> 
> The problem here is that the arguments don't really allow for deduction with 
> "make" you
> meant, so:
> 
> I'd quickly work around that using a lambda function; try something like
> 
>       .def(py::init(
>         [](int dual_basis, int interleave) {
>             return decode_rs::make(dual_basis, int interleave);
>         }),
>            py::arg("dual_basis"),
>            py::arg("interleave"),
>            D(decode_rs,make)
>         );
> 
> On 22.01.21 19:09, Daniel Estévez wrote:
> > Hi,
> > 
> > I'm porting gr-satellites to GNU Radio 3.9. I have some blocks that have an 
> > overloaded
> > make() method, for example:
> > 
> > https://github.com/daniestevez/gr-satellites/blob/master/include/satellites/decode_rs.h
> > 
> > Maybe this wasn't a very wise design decision on my side.
> > 
> > Now I'm wondering if it's possible to use this with pybind11, and if so how 
> > to do it.
> > 
> > gr_modtool bind (with pygccxml installed) is generating this:
> > 
> > https://gist.github.com/daniestevez/a3d0aaf7e6b2a68933ebb30e9043e7ac
> > 
> > which gives build problems like
> > 
> > /home/daniel/gr-satellites/python/bindings/decode_rs_python.cc: In function 
> > 'void
> > bind_decode_rs(pybind11::module&)':
> > /home/daniel/gr-satellites/python/bindings/decode_rs_python.cc:39:39: 
> > error: no matching
> > function for call to 'init(<unresolved overloaded function type>)'
> >    39 |         .def(py::init(&decode_rs::make),
> >       |                                       ^
> > 
> > 
> > Best,
> > 
> > Daniel.
> >



reply via email to

[Prev in Thread] Current Thread [Next in Thread]