Hi Daniel,

Unfortunately, the automated tools aren't smart enough to come up with the
bindings for the overload make function.  It doesn't seem to be a bad
design decision in and of itself, and fortunately, it is done in certain
places in the GR code.

Take a look at gr-uhd/python/uhd/bindings/usrp_sink_python.cc

        .def(py::init((std::shared_ptr<gr::uhd::usrp_sink>(*)(const
::uhd::device_addr_t&,
                                                              const
::uhd::stream_args_t&,
                                                              const
std::string&)) &
                      usrp_sink::make),
             py::arg("device_addr"),
             py::arg("stream_args"),
             py::arg("tsb_tag_name") = "",
             D(usrp_sink, make))

        .def(py::init((std::shared_ptr<gr::uhd::usrp_sink>(*)(const
std::string&,
                                                              const
::uhd::stream_args_t&,
                                                              const
std::string&)) &
                      usrp_sink::make),
             py::arg("device_addr"),
             py::arg("stream_args"),
             py::arg("tsb_tag_name") = "",
             D(usrp_sink, make))

When init is overloaded in the python bindings, the make functions have to
be given explicit function pointers.  So you will have to do this manually.

Josh


On Fri, Jan 22, 2021 at 1:12 PM Daniel Estévez <dan...@destevez.net> 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